I did this for a while but I just ended up editing my hosts file every time I wanted to stop working. Maybe I just need to practice more self discipline.
A workable substitute for self-discipline is to make it hard enough to do the bad thing that either your laziness or your better nature wins out.
E.g., I don't keep cookies in the house. Instead, I go to the store if I want some. It's pretty rare that I'll overcome my laziness enough to head out for them. And then on the way I often come to my senses.
In this case, I might make it harder to edit the hosts file. E.g., a daemon that puts the block back automatically unless I solve 25 captchas.
I also really like LeechBlock's option to insert a 30-second pause before viewing banned websites. Since it cancels the countdown if the window loses focus, I have to just sit and wait for half a minute. 90% of the time I'll say, "But I don't even want to look at Facebook now," close the window, and get back to what I want to be doing.
I have taken it to an extreme and got a dd-wrt router that easily blocks websites through both time of day and mac address. My wife is the one that knows the password.
I found that often it's just muscle memory for going to a particular time sink site, like when the project is being rebuilt for that 10 seconds, I would check out HN but got sucked in for much longer. The hosts file blocking just breaks that habit and forces me to focus back on the project.
E.g., I don't keep cookies in the house. Instead, I go to the store if I want some. It's pretty rare that I'll overcome my laziness enough to head out for them. And then on the way I often come to my senses.
In this case, I might make it harder to edit the hosts file. E.g., a daemon that puts the block back automatically unless I solve 25 captchas.
I also really like LeechBlock's option to insert a 30-second pause before viewing banned websites. Since it cancels the countdown if the window loses focus, I have to just sit and wait for half a minute. 90% of the time I'll say, "But I don't even want to look at Facebook now," close the window, and get back to what I want to be doing.