Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@krisrice
Created May 29, 2015 20:20
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 krisrice/5980512fa83f72779b69 to your computer and use it in GitHub Desktop.
Save krisrice/5980512fa83f72779b69 to your computer and use it in GitHub Desktop.
devops-against-humanity
#!/usr/bin/env python
import urllib.request, csv, random, re
u='https://raw.githubusercontent.com/bridgetkromhout/devops-against-humanity/master/cards-DevOpsAgainstHumanity.csv'
white=[]
black=[]
lines = urllib.request.urlopen(u).read().decode('utf-8').split('\n')
for line in lines:
r=line.split(",")
if len(r) == 2:
if r[0]: white.append(r[0])
if r[1]: black.append(r[1])
blank=re.compile(r"( +)?(\b|[^_])_+(\b|[^_])( +)?")
rpl=lambda _:" %s " % random.choice(white)
for _ in range(10):
print(re.sub(blank,rpl,random.choice(black)).strip().replace(' .','.'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment