Your main task as developer is shipping software. If you suffer from distractions that keep you from it (like I do) it's good to make a list. It's not unthinkable that you find yourself to be on top of that list.
Print a reminder that helps you recognize the trigger that tricks you into the routine of <whatever habit> and change it into something more valuable.
This works for me:
(Inspired by Greg McKeown (2014). Essentialism. New York, NY: Crown Business).