I've organized my life in such a way that I deliberately avoid multi-tasking since I read years ago that it doesn't work, and have proven to myself over the years that it doesn't work. YMMV. One thing I have done is introduce friction into my workflow. So I have a dedicated hard-drive that I boot into that is strictly for coding. Another is strictly for news & social media. This way if I'm coding, I am less likely to slide into Hackernews/Reddit/Twitter/Whatever. Friction is good and more people need to leverage it.