Fair use only applies in certain contexts, of which writing commercial software is not one of. 'Snippets' are not fair use and it is shocking how many people here think they are.
I'd argue that people who open-source code expect other people to learn from it in a small way of snippets and that constitutes fair-use.
https://stackoverflow.com/help/licensing
Copying code samples from a copyrighted work for use in a commercial product is not fair use.