As promised, I’m going to pick one person at random of the people who successfully completed the survey and give them a nifty new gadget to enjoy. Since I’m a code monkey at heart, I wanted to choose the winner my way — by writing a simple little program to do it! Now, I’ll walk you through setup and the “drawing” and we can find out who wins together like some sort of weird geographically disparate family!
(This is probably going to bore the hell out of most of you, but just indulge me this once).
First, I exported a list of all of the people who successfully completed the final requirement (registering for the notification list) as a CSV file which I saved as ~/Development/Scripts/btng.csv on my iMac. The file is organized with one person per line.
Next, I wrote a short little Python program to read a file into a list of lines and select one at random.
As a test, I also created a file called test.txt:
Then, I ran the Python script against the test file to make sure it was working:
Brett-Kellys-iMac:Scripts inkedmn$ python SurveyDrawingWinner.py
I'm line 10
Brett-Kellys-iMac:Scripts inkedmn$ python SurveyDrawingWinner.py
I'm line 7
Brett-Kellys-iMac:Scripts inkedmn$ python SurveyDrawingWinner.py
I'm line 9
Brett-Kellys-iMac:Scripts inkedmn$ python SurveyDrawingWinner.py
I'm line 6
Now, we change the file to use our real list of entrants and…
Brett-Kellys-iMac:Scripts inkedmn$ python SurveyDrawingWinner.py
"steve pelletier"
Congratulations, Mr. Pelletier! I’ll be notifying you via email right after this post goes up, but you’re the big freaking winner :)
Thanks so much to everybody who gave honest feedback on the survey - you’ve been a huge help in getting me to solidify what I’m doing here. Hope you guys stick around and, if I may pander a bit here, tell a friend if you think this site doesn’t suck.
Cheers!
Photo by Dave_B_
snack or a meal after you workout,…
depending of course on what time it is when you get home. after a workout, your body needs proper nutrition to repair itself. if you find yourself wondering what the best snack options are after a workout, try these out:pita …