I also turn off the ability of most apps to display notifications. That helps.
Second is to restrict your internet use to specific times or to just say an hour every night from 9-10pm. Lets say start out by saying internet only from 0-15 minutes on the hour (initially). The idea is to get you used to not reflexively use the internet to prevent boredom or distraction.
How you accomplish that, say by killing your internal dns server to not respond or even firewall off your network from reaching the internet is up to you. But the key is to make it so you change your habit of when using the internet is ok.
Oh also, leave the phone at your desk, only pick it up when you need to look at it or if it rings etc...
Another good tip, reward yourself for each milestone, you want to encourage yourself to do the right thing. Don't use negative reinforcement unless you really know how to make that work. Its easier to do stuff like: if I don't go online at all today, I'll eat a container of ice cream (bad example if you do this every day but you get the gist) as a reward.
I still pull the phone out of my pocket several times an hour, but a quick push of the home-button and a confirmation that there's nothing of interest leads to it going straight back into the pocket. It's liberating!
Step 2 was removing the browser shortcut from the main screen, so there's less temptation to just 'fire it up and check HN quickly'.
It (AT LEAST) frees you to decide when to check the phone, rather than letting these companies, (through notifications) decide for you when you're going to check your phone.