Blue Dongs for a Friday Afternoon
Today I wrote an awesome program called mkdong that will make a dong of your desired length and print it to your terminal, like this:
% ./mkdong usage: mkdong <length> % ./mkdong 5 ()/()/////D % ./mkdong 25 ()/()/////////////////////////DThat last one is impressive, isn’t it? Hmm… Yeah, it’s Friday. What do you want from me? I still got work done! Cool thing is if the dong is too big, well then it throws an error:
% ./mkdong 60 warning: a 60" dong is too big! cannot be longer than 40"!“What is the point of this?”, you might ask yourself. That’s a good question. I’ve been so busy with other shit lately that I’ve barely had time to code. I suppose I was itching to write something, anything… Dongs!!
It all started harmlessly enough with a silly AIM conversation with my coding buddy at work. We were talking about a bug, and well, read on and you’ll see. It regressed quickly.
So I took the stupidity and ran with it and mkdong was born!
The initial dongs were a little primitive and sickly looking. So I took his suggestion and improved their visual style. Here is how it turned out:
#!/usr/bin/env python
import sys
maxlen = 40
try: donglen = int(sys.argv[1]) except: print "usage: mkdong <length>" sys.exit()
if donglen > maxlen: print 'warning: a %s" dong is too big! cannot be longer than %s"!' % (donglen, maxlen) sys.exit() else: dong = '()/()' for i in range(1, donglen): dong += "\" dong += 'D'
print dong We laughed. We joked. We Tweeted. And then it regressed even further:
A feature request! I had to make it print in blue! But to do that I had to replace all of the “\” that make up the dong itself, with “/” so as to not have the ANSI escape codes eat up the extra backslashes. (Backslashes are interpreted characters, duh.) I also had to replace the print statement with a system call to echo -e so that the colorization would be interpreted. This is high tech shit, man!!
And then I released it to the public. So there you have it. Here is the final release of mkdong 2.0 for your pleasure:
#!/usr/bin/env python
import os, sys
maxlen = 40 color = '\\e[0;34m' # blue
try: donglen = int(sys.argv[1]) except: print "usage: mkdong <length>" sys.exit()
if donglen > maxlen: print 'warning: a %s" dong is too big! cannot be longer than %s"!' % (donglen, maxlen) sys.exit() else: dong = '()/()' for i in range(donglen): dong += '/' dong += 'D'
os.system('echo -e "%s%s"' % (color, dong)) Use it well. And remember they aren’t bugs, they’re dongs! Squish? Gross.
| Posted in Life, Python | 3 Comments »