I have a rule about ZERO copy-pasting from SO or anywhere else on the internet for that matter. If you don't understand the code, when you have all the time in the world to understand it, seek help, test it, and figure it out; you certain won't suddenly understand it better, when it breaks in production. Just because 100 idiots upvoted something, doesn't make it right.
Personally, I avoid SO because I've seen too many wrong answers. I prefer documentation, or blogs explaining approaches. But, it can be a resource, especially to new developers, to help you understand how you need to think and how to approach problems. As a replacement for coding it yourself, it's might be hot garbage, so you should understand it before committing to having produced that code and assign your name to it.