I've written and committed my best bugs when drunk. Undoing them was a valuable learning exercie. The finest being, in C:<p><pre><code> if (nr = 0x56) ...
</code></pre>
That took and entire day to find and made me religiously avoid lvalue assigments in expressions by doing:<p><pre><code> if (0x56 == nr) ...</code></pre>
Slightly drunk is fine, for me it helps for not overengineering things and i just write code that works.<p>When completely sober, i think to much and i overengineer (overthink) stuff... Programming is just slower...<p>(Think DDD-like programming)<p>1 beer is enough to get very concentrated... Just don't overdue it (and don't make a habbit of it).<p>I only do it when i need to get things done, when time is limited... Never had serious bugs (Windows ME like) though :-P<p>It happens once in the 2 months and mostly it's for 2-3 days in the weekend (non-stop), with some light kind of music (Enya or concentration like mp3's) and headphones.<p>Yeah, i'm a nerd then :P
Yes, I realize (hope) this is a joke, but this is the most "programmer" response to a drinking problem I've ever seen.<p><pre><code> I know, I'll externalize and automate my impulse control!</code></pre>
It might be neat to replace the arduino/breathalyzer part with some sort of typos/minute metric, collected from the number of miss-typed commands you have had recently.<p>Trying to run `git psuh` too many times in an hour could get you a cooldown period so you can either sober up or wake up.
Also, don't edit your bash profile when drunk! In my youth I did this and it took 3 weeks to return to normality - I didn't know about source code control in those days.
What about a check for <i>prescription</i> pain killers or amphetamines? Oh wait, those are culturally acceptable mind altering things. I'm half joking but this is a neat hack, although I know many functioning alcoholics that would laugh at the concept of this.
One of my old colleagues had the bright idea to log onto one of our production systems to "re-index some of the database tables" after coming home one Easter eve.<p>And yes, he wasn't directly sober at the time.<p>I was moderately amused when I got woken up about 3 AM and got to spend a few hours trying to revert the "re-indexing" ...<p>I think integration with ssh-key management to prevent people logging onto production systems when drunk would be a good idea for this project, don't be surprised if there is a pull request from me in the future ...