Advertisements for a long time isn't simple topic anymore. It's not just putting one square on your page and hoping for some money to come back. You have to consider multiple factors like:
First of all, you can get criticised. You may learn something from it, so you can improve. It's dangerous.
Code shows your skills. They improve over time. Future employer can see you grow. That can end up with too big salaries.
By resolving your problem you can become contributor of huge project. Like posting pull request to some framework. Then recruiter would think, you are a super star... you don't want that.
Your code won't be hidden, ever... Imagine you do something cool, even for yourself. Great new business idea. And then you create snippet that is cool to. Only think is that this snippet has own value even outside the project. On the other hand it isn't something that affect value of the project. Say you build website for estate agencies and you have built nice CSS effect making buttons blink like Kardashians. If you don't publish that snippet as open source it will be forever safe. If you sale your project no one will use that snippet except new owners. If you publish it, you will keep all rights and it will be used by others... what a lose.
Your code won't produce any direct money. No. Worse. You can build business model on top of it that you may not like. Like Symfony or MEAN.io. Making money on service, training and support. Do you don't want that mess and scaling business. You just want to code for food...
I do enjoy good practices in coding. I love the direction that many environments take to organise code and make it maintainable. But very often we think about our code and forget about whole world around it.