Without realizing it, I've been doing the same "CD trick". I play the Monstercat album mixes (https://www.youtube.com/user/MonstercatMedia - dubstep, which , regardless of its musical merits, I find conducive to focusing and not trailing off) and see how many I go through in the day. I also like albums because they're about an hour long, which I use as one-hour long pomodoro timers. 20 minutes is just way too short for me to truly focus.
I also really like the attitude that if you're not touching code, you're not doing real work. Sure, project managers etc. will say that your job is not solely to write code, and that responding to emails, participating in meetings with your teammates, etc. are as much part of your job. But I like the simplicity of "if you're not writing code, you're fucking off" and how easy it makes it to answer the question "Did I work today?".
The other points are spot on. I suspect a lot of engineers are of the ADHD-type personality (the fact that "yak shaving" is a thing in our jargon is a good sign of that IMO), and a key part of addressing it is to learn how to spot when you go off track (zoning off and going on Twitter when the bug is getting a bit too hard to track down, stopping what you're doing because a random question popped into your head and you just have to read the related Wikipedia article, etc.) so that you can correct yourself. Don't feel bad about it- just learn how to catch it early, and stop doing it.
I heard a talk a while back where the speaker was driving home the fact that we need to get used to the fact that we should do things regardless of whether we feel like doing them or not. It sounds super dumb and like the ultimate first world problem, but thinking about it hard made me realized how skewed my perspective was. I feel like our culture at large really leads us to believe that we should only do things we like and enjoy; "I don't feel like doing it" is definitely a sentence I hear regularly among my peers.
Finally, surrounding yourself with smart, hard working people is the ultimate productivity hack to me. In college, the quality of my work changed drastically depending on whether I sat at the front of the class with the math nerds or at the back of the class with the anime nerds. I realized that while I can be self-driven when it comes to things that really matter to me, a lot of the time I will follow the general tendencies of whatever group I am in. I suspect this is why all the smart, talented people in the industry are friends in some capacity - because they recognize how tremendously powerful it is to be in an environment where the average is very, very high. This leads to situations where you have companies who seem to be always in the spotlight, always have the best people, etc. (i.e. Valve, Oculus, iD Software, to stay in the gaming register that the article has), and then the other 99%.
If you feel like your workplace isn't encouraging you to be the best you can be on that front, that's an extremely compelling reason to find another place.