Please Read this: The MIT License – Clarity on Using Code on Stack Overflow and Stack Exchange
All the content in Stack Overflow and other Stack Exchange (even this question) is under Creative Commons BY-SA 3.0 with attribution required, so you might find this questions interesting:
When is attribution required?
The article Attribution Required from Jeff Atwood explains how you need to give attribution, however when you read it, looks like is talking when you republish a content from Stack Overflow or other Stack Exchange in a website or blog in any public manner, but what if I'm using code from an answer or question in my own code that is intended to be sold? How attribution should be done? Is needed? Also what if I'm just using small pieces of code that I learned or copied and paste it from an answer or question and I adapt it to my own code? Is attribution needed?
If you had read the license, it says that is ShareAlike this means that "If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original." In some way you might think that if you use small pieces of code from an answer or question now your work needs to be licensed under Creative Commons BY-SA 3.0 too, but when I read the ShareAlike Interpretation I saw this:
The ShareAlike condition applies only for works considered adaptations under copyright law, not simply in collections with other works (also referred to as mere aggregations).
So it means that even if you use small pieces of code from answer or questions, your entire work doesn't need to be licensed under Creative Commons BY-SA, too, at least it be an adaptation from it not just small pieces of code, am I right?