I went through a stage of spending way too much time on Reddit - on the order of 4-5 hours a day. This has been discussed often, but it can be crippling - as soon as you hit the tiniest mental roadblock, you switch your browser to Reddit, next thing you know it's 20 minutes later and not only is your roadblock not solved, you even forgot what you were doing. So then you read more Reddit while you try to remember.
It's terrible, and a lot of it isn't even conscious, until the day is over and you realize how little you did.
My friend made a good point - you don't NEED more than 15 minutes a day to keep up to date with what's on sites like Reddit or HN. You can spend a lot more time, but beyond a certain point it's just frustration that you've already read all of it.
So I installed LeechBlock:
https://addons.mozilla.org/en-US/firefox/addon/4476/
I set it to allow 15 minutes of access every 6 hours to my timesinks, and I set it to not allow access to its settings during the blocked times (so I can't easily turn it off).
At first I would hit the blocked page every few minutes, without even realizing that I intended to do so. The frequency was a bit shocking, to be honest - part of it was honestly muscle memory by then (alt-tab to browser, type "re", down, enter). The blocked page made it possible to force myself to focus on work again, every time, but it also made me realize how badly my brain patterns had been disrupted - my brain just craved distractions and did NOT want to focus for more than a few minutes at a time, which is never enough to do anything meaningful.
After about a week, the cravings for distraction were a lot lower. After about two weeks, they were mostly gone. I've now settled into a good rhythm, I complete tasks without interruption and check the time sinks for a few minutes at a time in between tasks - and I always have the safety net of the 15 minutes per 6 hours limit. I usually hit that limit, but not always.
Sure, it's trivial to circumvent LeechBlock (just use a different browser, for example), but that's not the point. The point is that you are making a conscious decision that what your brain is doing is not OK, and you need to re-train it to do what you want. Things like LeechBlock are not magical solutions, but just tools to help you do that.
Edit: I prefer LeechBlock to the hostsfile hacks because it's not as rigid: it lets me settle into a natural rhythm that works for me, which also means I'm a lot less likely to turn it off and "forget" to turn it back on.