Skip to content

Instantly share code, notes, and snippets.

@jesserobertson
Created January 8, 2015 07:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jesserobertson/2d00f4c20b3e7c8c3262 to your computer and use it in GitHub Desktop.
Save jesserobertson/2d00f4c20b3e7c8c3262 to your computer and use it in GitHub Desktop.
Randomizing an author list using atmospheric noise
import requests, simplejson
# Insert your API key here
api_key = '<my_api_key>'
# Some random names from http://www.namesgenerator.org/100-random-names/
authors = [
"Staffan Krammerer", "Rosalinda Stavoua", "Tahsin Tomms",
"Saikhantuya Stronge", "Bronte Movileanu", "Mykel Eletti",
"Brendan Hamzová", "Utaka Heldt", "Alekzander Ogiemwonyi",
"Jaimi Neutz", "Jakobien Waclawik", "Olegas General",
"Ishtar Nikulshin", "Ajo Lebedinsky", "Aril Blackfeather",
"Chrissa Kipoin", "Luciene Tomrley", "Shinobu Looney",
"Kalmi Saites", "Vienna Hyer", "Chritian Crosara",
"Jemski Grieder", "Giwayen Antlers", "Caila Wixted",
"Donara Polec", "Ricki Plockmeyer", "Merdan Werbeer",
"Rosemar Weglinsky", "Soline Sagimoto", "Letha Kampras"
]
# Set up the JSON request for the random.org API
request_parameters = dict(
jsonrpc='2.0',
method='generateIntegers',
params=dict(
apiKey=api_key,
n=len(authors),
min=0,
max=len(authors) - 1,
replacement=False),
id='author_ordering')
encoder = simplejson.JSONEncoder()
json_request = encoder.encode(request_parameters)
# Actually make the request
response = requests.put('https://api.random.org/json-rpc/1/invoke',
data=json_request)
if response:
# Decode response from the server
decoder = simplejson.JSONDecoder()
order = decoder.decode(response.content)
# Use the random permutation to generate the author list
print ', '.join(map(lambda i: authors[i], order['result']['random']['data']))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment