Skip to content

Instantly share code, notes, and snippets.

@brianddk
Last active August 29, 2015 14:22
Show Gist options
  • Select an option

  • Save brianddk/5c2b65c05df100cd7c22 to your computer and use it in GitHub Desktop.

Select an option

Save brianddk/5c2b65c05df100cd7c22 to your computer and use it in GitHub Desktop.
Get All Gist
# [rights] Copyright Dan B. (brianddk) 2015 https://github.com/brianddk
# [license] Licensed under Apache 2.0 https://www.apache.org/licenses/LICENSE-2.0
# [repo] https://gist.github.com/brianddk/5c2b65c05df100cd7c22
# [tips] 18MDTTiqPM8ZEo29Cig1wfGdkLNtvyorW5
import getpass
import json
import requests
hitBreak = False
user = raw_input("GitHub Username: ")
pas1 = getpass.getpass("GitHub Password: ")
# pas2 = getpass.getpass("ReEnter Password: ")
# if(pas1 != pas2):
# print "Password mis-match!"
# exit()
gist_url = 'https://api.github.com/gists?page=1'
while not hitBreak:
r = requests.get(gist_url, auth=(user, pas1))
if not r.ok:
print "Can't reach github"
exit()
for item in r.json():
print "git clone %s" % item['git_pull_url'].replace('://', '://%s@' % user)
print "cd %s" % item['id']
print "git config user.name %s" % user
print "git config user.email %s@users.noreply.github.com" % user
print "cd .."
try:
link = r.headers.get('Link')
link = [x for x in link.split(',') if x.find('rel="next"') >= 0][0]
gist_url = link.split('<')[1].split('>')[0]
except:
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment