You can use the code I've posted on StackOverflow and other StackExchange sites under any of the following licenses:
Basically this means that you can freely copy it and paste into your open-source or proprietary project without any consequences. You don't have to put my name anywhere. However, I recommend you put links to relevant pages for future reference.
Me elsewhere: