Last active
March 2, 2018 15:15
-
-
Save ce222pc/2d71809b7f5ac16285d4fbb192919dbe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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