If they had put explicit copyright notices in the code snippets, I'd assume otherwise.
If they had put explicit copyright notices in the code snippets, I'd assume otherwise.
In the case of a random blog, the code likely does not have an associated license, meaning it is copyrighted and any derivative use of it (i.e. copying it) is a violation of their copyright.
In the case of stackoverflow, their ToS require people who post code to share it under a Creative Commons license [0]. Unfortunately, if the author of the post didn't realize that, it's possible they did not have the original copyright and couldn't make that assignment, so you still may have to do your own due diligence.
Where things work as intended on stackoverflow, you are required to provide attribution.
Your assumptions are backwards, and it sounds like that results in you violating copyright.
In general I suffer from NIH complex so don’t really copy code from those places ;)
Most(*) small snippets of code (e.g., 1-10 lines) on Stack Overflow are probably not copyrightable, at least not under U.S. law. You don't need a license to copy and use something that's not copyrightable.
(*) But not all. As usual, it depends.