Skip to content

Instantly share code, notes, and snippets.

@loke-dev
Forked from ce222pc/commit-msg
Created March 2, 2018 15:15
Show Gist options
  • Save loke-dev/2e380023ed0a5bac91f0da41401684d9 to your computer and use it in GitHub Desktop.
Save loke-dev/2e380023ed0a5bac91f0da41401684d9 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