Hacker News new | past | comments | ask | show | jobs | submit login
Get-shit-done - Easy way to stop distractions (github.com/leftnode)
190 points by leftnode on May 4, 2011 | hide | past | favorite | 76 comments



I once wrote a similar script which was configurable and it installed as a service. It would periodically scan /etc/hosts to check I wasn't cheating.

  $ sudo /etc/inid.d/procrastination-ctl start
  OK.
  $ sudo /etc/inid.d/procrastination-ctl stop
  You need to wait 59 minutes before you can stop.
Managed to waste a whole day on that one.


> Managed to waste a whole day on that one

I love the irony.


I always wanted to rename the script to "/etc/init.d/procrastination" whereby the command "stop" would start the service and vice-versa.


that's just investment....


yep, pure gold of a punchline


Nowhere near as broad-ranging, but I'll make the note for HN users not aware of it - if HN is your sole (main?) distraction, you can use the noprocrast feature on your user page. Change to Yes, add a max time you allow yourself to visit HN and then the min time you want to be forced to be away.

As I say, nowhere near as broadly applicable or useful as the OP, but worth noting especially if (like me) HN is your distraction of choice and you have minimal technical skills.


After playing with noprocrast, I found very good settings for me are

maxvisit: 20

minaway: 1

That means, every 20 minutes HN kicks me off for one minute. I leave it like that constantly - it means if I'm spending time on here nonstop for an hour or two, I get a couple little reminders to ask myself if I really want to be on here. If I do, it's not a big deal to get up and make myself a tea or whatever until 1 minute passes, if not I close the tab and get to business, and it's low enough that I don't cheat by logging in with another browser or Chrome Incognito Mode.


The noprocrast feature stops working very well when you use Safari. It has the web page preview stuff, and every-time that refreshes the noprocrast kicks in. Since it does that way more often than I visit the site the site is continuously in noprocrast mode.


>if (like me) HN is your distraction of choice and you have minimal technical skills.

this is a small and interesting portion of mindspace


It is not the greatest distraction, but a significant fraction of it (#1 distraction, and about 3x as big as #2, according to RescueTime).

While it is not a huge problem, and there is lot of value I extract from this site, culling seems like a good idea. A daily quota would help me avoid the high hitters and still keep myself "well read".


I do this, although only by saying

    sudo cp hosts.play /etc/hosts
or

    sudo cp hosts.work /etc/hosts
It's simple, and surprisingly efficient.


I did this in the past too. The amazing thing is that it actually cures the addiction, not just the symptoms. On the first day you find yourself clicking on the reddit bookmark like an idiot every 20 mins, only to be redirected to localhost. After a few days the impulse is gone and you can actually go back to a non censured /etc/hosts: your self control is back. YMMV.


The only problem with this method is that if you modify your hosts file, you have to modify both.


Just create a Makefile or something that cats together hosts.common and hosts.work or hosts.play.

  all:
      cat hosts.common hosts.work.in > hosts.work
      cat hosts.common hosts.play.in > hosts.play
Make common changes to hosts.common and easily build your final hosts files.

  play:
     cat hosts.play | sudo tee /etc/hosts > /dev/null

  work:
     cat hosts.work | sudo tee /etc/hosts > /dev/null


How often do you modify your hosts file? I only ever find myself adding more things to block to it.


sudo cp /etc/hosts /etc/hosts.bak && cat hosts.work >> /etc/hosts

sudo cp /etc/hosts.bak /etc/hosts

Note: I just wrote this now with no testing whatsoever.


When I am working on Linux I do the same thing, except I have cron job copy hosts.work to hosts at 9am(insert your favorite get to work time) and hosts.play at 5pm. Works really well.

I wonder if one can do the same on Windows 7, some way of scheduling tasks easily.


Does this work with Chrome? I believe Chrome does it's own dns resolution and skips the host file. (I defiantly know it won't resolve localhost if you're offline)


I've edited my hosts file with various domain->ip mappings, and it's worked fine for me in chrome.


I used StayFocusd for a day or two and realized I was a lost cause when I found myself opening its sqlite database in my Chrome profile to add time to the clock.


Unfortunately you can just right click and disable extensions on chrome. Since the exit barrier is so low, I was always able to exit even when I shouldn't have.


Why such interest in this script? Besides being written in php, it's also a fairly kludgey approach to managing /etc/hosts. Is it the vulgarities?

    #!/bin/sh
    [ $UID -eq 0 ] || { echo "You're not root, asshole."; exit 1; }
    [ -f "/etc/hosts.$1" ] || { echo "/etc/hosts.$1 doesn't exist, asshole."; exit 1; }
    cat /etc/hosts.{$1,tail} > /etc/hosts
...

    sudo ~/bin/stopfuckingoff play


It was a sad day when Red Hat removed the insults from sudo.


For Mac users, SelfControl is a GUI approach to this idea: http://visitsteve.com/made/selfcontrol/


Also if anyone wants to hack on it, SelfControl is on Github: https://github.com/slambert/selfcontrol


One of the best features is that it runs on a timer and you can't cancel it prematurely. Even if you restart.


You can. It uses ipfw, and I think you can reset the rules. At least I managed when I tried it, but this was some 3 years ago.


Sorry to be the guy decrying PHP, but the only arguments I've found in it's favor are it's ubiquity and being sometimes "the right tool for the job" if you're quickly hacking together a dynamic webpage.

Surely a simple cli app isn't the right job for this tool.

Now, all that said, it _does_ work, and blahblahblah.


Yep, beware I didn't even tested it:

    #!/usr/bin/env zsh

    (($#<1)) && {
        print -- "usage: $0:t (play|work)"
            exit 1
    }>&2
    blacklist=(
            reddit.com
            ycombinator.com
            slashdot.com
            )

    hostfile=/etc/host

    if [[ $1 = "play" ]]; then
        if [[ ! -e $hostfile.orig ]]; then
            cp $hostfile{,.orig}
        else
            print -- "You're already playin" >&2
            exit 1
        fi
        cp $hostfile{.orig,}
        for elem in $blacklist; do
            print -- "127.0.0.1\t$elem" >> /etc/host
            print -- "127.0.0.1\twww.$elem" >> /etc/host
        done
    fi

    if [[ $1 = "work" ]]; then
        cp $hostfile{.orig,}
        \rm $hostfile.orig
    fi

    /etc/init.d/networking restart


Thank god! Let me just waste some time getting this installed and then I'll waste some more time testing it, then I'll waste some more time posting this comment to hacker news.


https://addons.mozilla.org/en-us/firefox/addon/leechblock/

does windows of access, allows for x minutes, has grouping. Course, it's FF only where hosts file gets your whole connection.


StayFocusd for Chrome Users - https://chrome.google.com/webstore/detail/laankejkbhbdhmipfm...

latest version has a neat feature which tracks links from blocked pages. Ie if I give myself 15 mins of HN a day, but end up wasting 2 hours because I only spend 10 secs on HN opening up tabs to read, it now tracks that. Any links you click from HN will count towards your time limit.


leechblock has helped my compulsive reddit habit :/


Isn't the point of this approach to be _difficult_ to switch back and forth? Next thing you know there will be a chrome extension that swaps your hosts file and you will be separated from procrastination by a single click.


I found it useful to force myself to manually comment/uncomment lines in my hosts file. It gives a critical few moments for a bit of humiliation to set in, as you realize how desperate you are for diversion. On the other end, it gives a moment to mentally pat yourself on the back for eliminating the distractions.


i'm actually surprised at the amount of time people spend procrastinating on something to help them stop procrastinating...

or even more surprising might be the amount of time i've spent procrastinating by reading about people who've procrastinated by making tools to aid their procrastination...

...I'm going to get back to work :)


Instead of doing work, I got stuck modding this to get better behavior for Mac. First I tried to figure out what the $restartNetworkingCommand mac equivalent was (dscacheutil -flushcache for those who are curious). This works pretty well for non-Chrome browsers (i.e. browsers that don't have absurd caching behavior). Then, given that Chrome (which maintains its own DNS cache-- a decidedly not absurd caching behavior, I acknowledge) is my browser of choice, I also set out to fix it so I didn't need to restart Chrome. This endeavor I have accomplished using one of my favorite jank-tastic tactics: running applescript from the command line.

So here is my (Mac OS X 10.6+?) change:

$restartNetworkingCommand = 'dscacheutil -flushcache; osascript <<EOF tell application "Google Chrome" make new tab at end of tabs of window 1 with properties {URL:"chrome://net-internals/#dns"} activate delay .5 set URL of active tab of window 1 to "javascript:document.getElementById(\'clearHostResolverCache\').click()" end tell delay .5 tell application "System Events" to keystroke "w" using {command down} EOF';

This, of course is made even more jank-tastic by manually sending command-w to close the window-- googling the proper command was more difficult than just doing it live :).

So yeah-- clearly I needed this script before reading this post, but if I had it probably would have done some terrible things to the space-time continuum... I guess I'll just amortize the one-time cost by actually using the script. Starting now.


yikes-- that formatting got butchered... anyone know if there's a better way to put code in comments?


https://github.com/killsaw/Timeguard

A similar script, but with an 'addsite whatever.com' command.



I do this, and my scripts have actually gotten kind of complicated.

To start, it's a command line utility. I need to answer the question "Do you want to waste your time?" with "yes" to turn off the filters.

Then I didn't bother running in a way that the script had permissions to edit /etc/hosts so I need to enter my system password every time I want to make a change.

I also automatically turn the filters on every hour.

I also log both the number of times I turn the filters off and whether the filter is on at about 1pm.

I'm running a test right now to not turn on the filters automatically every hour and there is already a noticeable decrease in productivity in my rescuetime.

I'm about to update the logger to use the google charts API to save a historic graph of performance to a directory that is used as my desktop background.


Use to use cumbersome hacks with block lists in routers, but I discovered the SiteBlock extension for Chrome: make a list of "dangerous" sites, and give yourself a fixed time per day to visit them. In my casa, one hour works fine (although I'd probably prefer 2 :p)

Address: https://chrome.google.com/webstore/detail/pfglnpdpgmecffbejl...

Website Blocker seems to be similar, but without a time limit: https://chrome.google.com/webstore/detail/hclgegipaehbigmbhd...


I've ported this to a Bash script which is simpler and more extensible. It uses env variables to facilitate customization.

https://gist.github.com/955437


A crude implementation of Get-shit-done in Python. https://github.com/dananjayavr/get-shit-done


For mac users, the Self Control app works really well. http://visitsteve.com/made/selfcontrol/


A Chrome extension that I use pretty regularly for this sort of thing is Stay Focused: http://goo.gl/gHWFQ


I permanently blocked all from my laptop and only surf from my iPad now. Works great for me.


Curious, how do you permanently block the sites?


I think it just means that the sites stay redirected in his hosts file.


Correct. If I ever catch myself surfing to a website from my laptop, it gets bookmarked for my iPad and blocked in my /etc/hosts.


I took a really simple approach: removing HN, Facebook, Clicky, and Google Reader from my bookmarks bar. Having to type them in manually instead of compulsively clicking is enough to limit me to an hour or two of dicking around per day.


I don't even use bookmarks because it would take longer to click a bookmark than typing "n" for HN (or "r" for reddit or "f" for facebook) and letting Chrome auto-complete and pressing enter, so this wouldn't help me that much.


Oh, I guess I would call myself a "burst typer", so I usually find it faster to just type all or most of the domain than to type one letter and check to see if Chrome got the right thing. But of course that requires a little bit of effort, so it's still just enough to make me consider whether to go there or get some work done.

I just subconsciously don't trust one-letter autocomplete I guess.


in firefox i have 'red' <down> <enter> already ingrained for reddit, same with 'new' for HN ... it's automatic and you can't tell me typing it all out is faster :P


Firefox's AwesomeBar makes this hard. Hacker News is just a 'control-t y tab enter' away.


Thankfully this was the first link on the HN homepage. Just reading the articles and comments made me feel sufficiently guilty to stop reading any more :)


Throw in some ASCII art to make things sweeter:

  figlet -f univers time to work! | boxes

  figlet -f starwars game time!   | boxes -d dog


How does this compare to Programming, Motherfucker?


this comment thread is turning into quite the social experiment. is ADD a prerequisite for being a good programmer/hacker/etc...?


Just a quick hack. I added timer-applet in ubuntu. I work on 30 mins intervals and then rest 5 mins. It is pretty handy.


Similar to this, I use eternity time tracker on my iphone to work in 30 minute intervals. During the interval, no email, news sites etc. It has worked really well for me.


Safari users might like http://www.mindfulbrowsing.com


treating the symptoms rather than the disease is only a good choice for short term or for incurable diseases


You may be right. But repeating an action forms a habit, or in this case learning to not repeatedly open up HN or Reddit can become a long-term habit for anyone with the right mindset.


my main point being that if they stop with HN/Reddit something else will fill that gap. Not working is the issue.


oh no !! i checked the list of sites being blocked, now have more of them to check up on ....


Does it block Outlook because thats the real reason I can't get anything done these days.


Does it have a timer to keep me from modifying it every 2 minutes?


Use FreeBSD, set the kernlevel to something above the minimum, and add the flags to the file so it can't be changed, then until you reboot you won't be able to modify the hosts file =)


You should be able to use an asynchronous cron scheduler to implement something like Pomodoro with this. Combined with the right notification tool this could work quite well.


I'd call it git-er-done


So distracted by this.


I might as well plug tasktop - it's great.


Block reddit in /etc/hosts.

Memorize reddit's IP.


This will obviously leave me continuously trying to access hacker news while preventing me from doing so. My continued attempts will block all other operations [i.e. work] hence creating a race condition.

Far preferable is the event-driven technique whereby I make a cursory attempt at doing some real stuff until the HN bot tweets something of fleeting interest, at which point I defer said real stuff to a background thread to be completed in an asynchronous fashion.


Is this really worthy of HN frontpage? Seriously, who among us couldn't write something similar in 5 minutes or less?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: