Treat it like a citation in a paper. Add comments acknowledging and saying where the code came from. If nothing else, it'll help refresh your memory on why you needed it.
Also be aware of the original licensing for the code. If it's any more than attribution you'll need to determine how it affects the rest of your code and if you might need to reimplement.