Some ideas/tactics that might be of interest and have been useful to me or people I know:

- Find some short programming tutorials you can follow along on and gradually increase the length.

- Starting and stopping your day with the right routines makes a difference. I don't check email and use aquamail to not bug me during those hours. If somethings down I setup a different kind of emergency alert.

- Treat your senses a little different when you want to focus. Tools like white noise, ear plugs, 9th beet stretch of brain.fm can work well.

- Keeping a dedicated space for work has taught me to focus at that desk and play in other locations. I have the exact same desk and screen setup at my office and home. I keep it to focus.

- Log out of all social media apps. And news apps. Disable all notifications. Every app thinks it's at the centre of your life by wanting to gamification you so take it away. Only use the mobile web sites in your phone in a web browser installed only for it.

- Refuse to read or watch anything that isn't immediately useful for you and what you're up to now. Afraid you'll miss it or forget it later? Install diigo and keyword evening you read. You may find you rarely go back. Plus people don't mind filling you in when you've missed something.

- Manually block all news, social media sites in your hosts file (point everything to 127.0.0.1) on your laptop. Seems to help a lot of folks. If the path of least resistance is increased just enough..

- Read books more. Finding good books will teach your brain the act of immersion, focus and flow. You know you've found it when you get slightly enraged by an interruption.

- Going for walks or bike rides help me. There has been some studies out linking walking, learning and problem solving.

- Take up some meditation as a form of settling your thoughts and focussing. Meditating can provide the same feeling of a buzz without any hangover, mixed with giving you the fresh mind and focus you woke up with.

- Use do not disturb and silence notifications as much as possible. It makes a world of difference.

- Install a plugin that limits the number of browser window and tabs you have open at any given time.

- Keep a separate device for reading, communicating/socializing. I use a kindle and phablet phone.

- Understand your time. Be ok with scheduling your day in 1 hour pockets, including fixed reading time, at first and working your way down to 15 minute increments when needed. Be ok with tracking your time for 30 days to observe what you're doing with a tool like harvest.

Hope that mught be of some use.

Some other things I try to remember:

Productivity is as much a muscle as it is a habit as it is a discipline.

It's possible to grow out of the chasing shiny things phase little by little by cutting out all the other places that contribute ute to a distracted state of mind.

We distract ourselves when something becomes a little more difficult, and it's an important thing to manage.

Don't pressure yourself, a little sustained improvement at a time will go way further in the long run.

Building discipline that you can selectively use to focus when needed helps get things done is the goal.

We have a fixed amount of attention each day. Many things are trying to steal it from us so we don't get much done.

Much of our digital experience has devolved into the mindless chasing for hits of dopamine of the good enough updates, links, articles, etc. It's not anyone's fault except the PhD's spending their life's work getting people to click on stuff. If you are, don't feel bad about it, just cut the jerks out :)

There's very little worthy of being an interruption in a day.

Managing focus means managing those hits of novelty and distractions.

The power of habit is a great book as someone mentioned.

IIRC, If will take a few weeks to start forgetting and form new habits according to this book. Starting small, and keeping a list of what your doing helps you come back to it when one strays.