As another anecdata, the only way I've landed there more intentionally is with the two beer buzz. Working late on a project that is behind and you grab two slices and a six pack. Two beers in (and one every hour) and all of a sudden you just start tearing through code. I've had this happen to me countless times. I think it is because a lot of engineers have a brain that is spinning 1000% all the time and a couple of beers slows it down just enough for it to focus on what you are working on. All the other distractions fall away.
I feel exactly the same way when I'm white water kayaking. As you are reading the water and choosing your line and focusing on executing it, everything else in life falls away. You almost can't be distracted. The interesting thing is that at the end of a run, I never feel mentally exhausted despite all the intense focus, only physically drained. Of course, ymmv.
Oh yeah! Cycling fast gets me there too. It's weird, just put your brain in a position of risk and your get pretty quickly to focus zen. I wish I had a a simple formula like this to get in the zone more often when programming.
I feel exactly the same way when I'm white water kayaking. As you are reading the water and choosing your line and focusing on executing it, everything else in life falls away. You almost can't be distracted. The interesting thing is that at the end of a run, I never feel mentally exhausted despite all the intense focus, only physically drained. Of course, ymmv.