A short script to start work and block sites

Sometimes, I’m able to focus and I can have noise in the background, but at other times, it can be hard. If you find yourself starting to type “faceb…” every time you hit upon a slightly hard problem, then maybe what you need is to block websites that you frequently go to when you’re bored.

There are plenty of services that lets you do this, including Rescuetime, I believe. Anyway, being a techie, you should know that you’re able to do this just by editing your etc/hosts file.

But, I know that I need something where in order to block sites, the barrier is low, and in order to unblock them, the barrier should be high. That way, I can still unblock something when I need it, but really, it’s mostly just an awareness that’s needed. Once you hit upon “This website can’t be found” a couple times, you really just buckle down every time there’s a hard problem, instead of dodging it.

All you need to do is put the startwork script file somewhere in your execution path, and then edit your /etc/hosts files with the websites that you want blocked pointing to your localhost (127.0.0.1). 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost

127.0.0.1 www.onemorelevel.com
127.0.0.1 onemorelevel.com
#127.0.0.1 www.hulu.com
#127.0.0.1 news.ycombinator.com
#127.0.0.1 www.facebook.com
#127.0.0.1 www.youtube.com

In order to run it, just type “sudo startwork”. And then in order to unblock a site, “sudo [use your favorite editor] /etc/hosts” and then comment out the sites you do want with “#”. Yay. Now get to work.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s