One thing that has been extremely helpful for me is to work in Pomodoro sessions. I use a pomodoro session of 55 minute work + 5 minute breaks. And, I have a rule of not checking email, reddit, HN while I am in the middle of a pomodoro session. I also use a neat python package called pymodoro (https://github.com/dattanchu/pymodoro) to show me the current duration. This has single handedly removed distractions from my work.