* Have one browser, your least favorite browser, reserved for your social sites. It makes it harder to switch from your github-viewing/work browsing to HN/reddit/etc because you don't have the ability to comment or track discussions as easily (from the work browser).
* If that's not enough, change your passwords to your social accounts to a random string and paste it into a text file, and then log off your accounts. When you need to log back in, find that text file and copy-paste the password in. This creates enough friction that you can slowly break the habit of compulsively checking social sites when you don't need to.
* Use a timer to work. I like using the iPhone Ambiance app (99 cents), which lets you download from a huge library of ambiant noise sounds, from static noise to train stations, and I set a timer for half an hour in which I do nothing but the current task.
This sounds like small-time stuff but breaking habits is small time stuff. As with coding, don't think of it as "I need to build this awesome web app/uber-function", think of it as the smallest parts leading to the major goal.
With habits, especially, it's important to just follow routine until it's muscle memory. In this case, the routine is: not compulsively/instinctively checking websites for leisure.