I think it's a function of sugar. Really sweet coffee tastes terrible. Properly sweetened coffee does not give your brain that glucose rush that super-sweet soda does. (Soda can be super-sweet without tasting bad, apparently.)
(I drink a lot of coffee and tea, and it's nice, but sugary energy drinks are something my brain really enjoys the effect of. Not so good for the rest of your body, however.)
It's the carbonation. Flat soda is undrinkably super-sweet.
It makes some of the mundane line items or defect work seem like the next Google sometimes.
That, and going into the work thinking "this is the last code I will ever write" does the trick. Make your source code a work of art.
I think if you go through my HN history, you can see what days I was trying to cut down on sugar :)
I'd put 1 more strongly - eradicate distractions. When I can't work I try to avoid doing distracting things. Even if it seems like you're doing nothing, keep on doing nothing. Take a nap. If you avoid distractions you eventually start working. If you succumb, you just start the spiral all over again.
2.) appropriate music - I cannot work without headphones, and appropriate music on, its more of a tool to drown out the rest of the world.
3.) caffine, cold - at work i drink coffee... its just not as effective. I used to drink a lot of red bull, but my heart started to feel funny so I switched to coke.
4.) Interest - I need to get myself interested in what i'm working on, this is incredibly difficult to do with job work. I'm still working on solving this one.