For me, it can be a matter of actually doing it. I often suffer from analysis paralysis, so being a little tipsy means that I will actually write the thing. It'll be terrible, but it'll get done, and then sober me can go back and clean it up.
Or I'll go to far, write it, and it'll be unusable.
I used to do this sometimes in university. Haven't done it since entering the workforce, but they say sleep deprivation results in similar performance to being drunk. Not proud of it but I've found myself cornered into nightmare sleep deprived coding marathons by analysis paralysis / procrastination a number of times over the last few years. Alcohol might be preferable.
Or I'll go to far, write it, and it'll be unusable.