A personal blog
Reading stuff online can become addictive. So addictive, in fact, that it can negatively affect your productivity as a programmer. Most of us go to Hacker News or Reddit to get our dose of news. We justify it by saying that it’s research or that we are trying to stay current in the community. Whatever your excuse, you know you have a problem when you check Hacker News every ten minutes just to see if anything new and awesome has been added.
“Close Hacker News and open a f***ing book.” – Steve Losh in this talk.
Maybe you have already gotten over the initial self-denial and you have added
some entries to your /etc/hosts
file to keep yourself from constantly going
to those sites. That’s all well and good but I think we can do better.
You’ve already opened the tab and you are now staring at a blank error page. Why not put something more useful there?
Me, I like to learn new things. There are way too many things I’d like to learn. Why not show a list of things I’d like to learn and allow me to click through to the website?
I have installed nginx on my machine and set up a simple static page with a few links things like Learn You a Haskell for Great Good or Steve Losh’s Learn Vimscript the Hardway. Now every time I go to HN, I see those links and am reminded that I wanted to spend some time learning those things…
Install nginx. brew install nginx
or sudo apt-get install nginx
or
whatever might apply to you.
Stick this in your nginx.conf
:
worker_processes 1;
http {
include mime.types;
default_type application/octet-stream;
keepalive_timeout 65;
server {
listen 443;
server_name news.ycombinator.com;
ssl on;
ssl_certificate /usr/local/etc/nginx/server.crt;
ssl_certificate_key /usr/local/etc/nginx/server.key;
location / {
root html;
index index.html index.htm;
}
}
server {
listen 80;
server_name reddit.com;
location / {
root html;
index index.html index.htm;
}
}
}
If any of the sites you are blocking are served over SSL, you will need to get a self-signed certificate. This is a one time setup and doesn’t really take that long to do.
$ openssl req -new -x509 -nodes -out server.crt -keyout server.key
$ chmod 600 server.key
Now you just place those two files to the locations referenced in the above
nginx.conf
file and restart nginx.
And here is how you can make Chrome stop complaining about your self-signed certificate (source).
Hopefully, this will be helpful to you and nudge you every now and then to learn something you’ve been putting off.
This article was first published on July 13, 2013. As you can see, there are no comments. I invite you to email me with your comments, criticisms, and other suggestions. Even better, write your own article as a response. Blogging is awesome.