-
-
Save selimslab/958e2255a105f9a3f4b421896bce715d to your computer and use it in GitHub Desktop.
Revisions
-
selimslab revised this gist
Jun 18, 2021 . No changes.There are no files selected for viewing
-
selimslab revised this gist
Sep 25, 2020 . 1 changed file with 32 additions and 10 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,16 +1,38 @@ import sys from subprocess import call import json import os import requests def download_gists(gists: list): for gist in gists: call(["git", "clone", gist["git_pull_url"]]) # name of the first file in the gist new_folder_name = sorted(list(gist.get("files", {}).keys()))[0].split(".")[0] os.rename(gist["id"], new_folder_name) description_file = os.path.join(new_folder_name, "description.txt") with open(description_file, "w") as f: f.write(f"{gist['description']}\n") def visit_pages(user: str): next_page = True page = 1 while next_page: url = f"https://api.github.com/users/{user}/gists?page={page}" r = requests.get(url) if not len(r.json()): next_page = False else: page += 1 download_gists(r.json()) user = sys.argv[1] visit_pages(user) -
leoloobeek created this gist
Apr 26, 2017 .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,16 @@ # first: mkdir user && cd user && cp /path/to/get_gists.py . # python3 get_gists.py user import requests import sys from subprocess import call user = sys.argv[1] r = requests.get('https://api.github.com/users/{0}/gists'.format(user)) for i in r.json(): call(['git', 'clone', i['git_pull_url']]) description_file = './{0}/description.txt'.format(i['id']) with open(description_file, 'w') as f: f.write('{0}\n'.format(i['description']))