-
-
Save fedir/5466075 to your computer and use it in GitHub Desktop.
Revisions
-
fedir revised this gist
Jul 23, 2014 . 1 changed file with 32 additions and 12 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,24 +1,44 @@ #!/usr/bin/env python # Clone or update all a user's gists # curl -ks https://raw.github.com/gist/5466075/gist-backup.py | USER=fedir python # USER=fedir python gist-backup.py import json import urllib from subprocess import call from urllib import urlopen import os import math USER = os.environ['USER'] perpage=30.0 userurl = urlopen('https://api.github.com/users/' + USER) public_gists = json.load(userurl) gistcount = public_gists['public_gists'] print "Found gists : " + str(gistcount) pages = int(math.ceil(float(gistcount)/perpage)) print "Found pages : " + str(pages) f=open('./contents.txt', 'w+') for page in range(pages): pageNumber = str(page + 1) print "Processing page number " + pageNumber pageUrl = 'https://api.github.com/users/' + USER + '/gists?page=' + pageNumber + '&per_page=' + str(int(perpage)) u = urlopen (pageUrl) gists = json.load(u) startd = os.getcwd() for gist in gists: gistd = gist['id'] gistUrl = 'git://gist.github.com/' + gistd + '.git' if os.path.isdir(gistd): os.chdir(gistd) call(['git', 'pull', gistUrl]) os.chdir(startd) else: call(['git', 'clone', gistUrl]) if gist['description'] == None: description = '' else: description = gist['description'].encode('utf8').replace("\r",' ').replace("\n",' ') print >> f, gist['id'], gistUrl, description -
fedir revised this gist
Apr 14, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import os USER = os.environ['USER'] u = urlopen('https://api.github.com/users/' + USER + '/gists?per_page=100') gists = json.load(u) startd = os.getcwd() @@ -21,4 +21,4 @@ call(['git', 'pull', 'git://gist.github.com/' + gistd + '.git']) os.chdir(startd) else: call(['git', 'clone', 'git://gist.github.com/' + gistd + '.git']) -
fedir revised this gist
Apr 14, 2014 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,6 @@ #!/usr/bin/env python # Clone or update all a user's gists # curl -ks https://gist.githubusercontent.com/fedir/5466075/raw/gist-backup.py | USER=fedir python # USER=fedir python gist-backup.py import json -
fedir revised this gist
Apr 26, 2013 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,7 @@ # Clone or update all a user's gists # curl -ks https://raw.github.com/gist/5466075/gist-backup.py | python # curl -ks https://raw.github.com/gist/5466075/gist-backup.py | USER=fedir python # USER=fedir python gist-backup.py import json import urllib -
fedir revised this gist
Apr 26, 2013 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ #!/usr/bin/env python # Clone or update all a user's gists # curl -ks https://raw.github.com/gist/5466075/gist-backup.py | python # curl -ks https://raw.github.com/gist/5466075/gist-backup.py | USER=fedir python import json import urllib @@ -10,12 +10,12 @@ import os USER = os.environ['USER'] u = urlopen('https://api.github.com/users/' + USER + '/gists') gists = json.load(u) startd = os.getcwd() for gist in gists: gistd = gist['id'] if os.path.isdir(gistd): os.chdir(gistd) call(['git', 'pull', 'git://gist.github.com/' + gistd + '.git']) -
nicerobot revised this gist
Jan 16, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ #!/usr/bin/env python # Clone or update all a user's gists # curl -ks https://raw.github.com/gist/1622504/gist-backup.py | python # curl -ks https://raw.github.com/gist/1622504/gist-backup.py | USER=nicerobot python -
nicerobot revised this gist
Jan 16, 2012 . 1 changed file with 11 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,7 @@ #!/usr/bin/env python # Clone o update all a user's gists # curl -ks https://raw.github.com/gist/1622504/gist-backup.py | python # curl -ks https://raw.github.com/gist/1622504/gist-backup.py | USER=nicerobot python import json import urllib @@ -10,6 +12,13 @@ u = urlopen('https://gist.github.com/api/v1/json/gists/' + USER) gists = json.load(u)['gists'] startd = os.getcwd() for gist in gists: gistd = gist['repo'] if os.path.isdir(gistd): os.chdir(gistd) call(['git', 'pull', 'git://gist.github.com/' + gistd + '.git']) os.chdir(startd) else: call(['git', 'clone', 'git://gist.github.com/' + gistd + '.git']) -
joneskoo created this gist
Dec 15, 2011 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ #!/usr/bin/env python # Git clone all my gists import json import urllib from subprocess import call from urllib import urlopen import os USER = os.environ['USER'] u = urlopen('https://gist.github.com/api/v1/json/gists/' + USER) gists = json.load(u)['gists'] for gist in gists: call(['git', 'clone', 'git://gist.github.com/' + gist['repo'] + '.git'])