Skip to content

Instantly share code, notes, and snippets.

@jmk
Created August 19, 2015 22:46
Show Gist options
  • Save jmk/2f0e400c38f4466e6d6c to your computer and use it in GitHub Desktop.
Save jmk/2f0e400c38f4466e6d6c to your computer and use it in GitHub Desktop.
Raffle script
# A quickie raffle script that uses random.org to choose winning entries.
import urllib2
winners = 1
entries = [
"foo",
"bar",
"baz",
"quux",
"asdf",
"zxcv",
"qwerty",
]
url = "https://www.random.org/sequences/?min=0&max=%d&col=1&format=plain&rnd=new" % (len(entries)-1)
data = urllib2.urlopen(url).readlines()
results = [int(x.strip()) for x in data]
print "Your winner(s) are: "
print ", ".join([entries[i] for i in results[:winners]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment