if you copy-paste code from stack overflow, it's fine, but you need to provide attribution.

http://stackoverflow.com/a/2753343/458095