Skip to content

Instantly share code, notes, and snippets.

@ce222pc
Last active March 2, 2018 15:15
Show Gist options
  • Save ce222pc/2d71809b7f5ac16285d4fbb192919dbe to your computer and use it in GitHub Desktop.
Save ce222pc/2d71809b7f5ac16285d4fbb192919dbe to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import sys, os, re
from subprocess import check_output
from contextlib import closing
import urllib2
import json
commit_msg_filepath = sys.argv[1]
joke = ""
with closing(urllib2.urlopen('http://api.icndb.com/jokes/random')) as sf:
response = json.loads(sf.read())
joke = response['value']['joke']
with open(commit_msg_filepath, 'w') as f:
f.write(joke)
sys.exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment