Last Updated: February 25, 2016
·
550
· wookiecooking

pull all gists from a user as repos

Simple script that pulls a user's gists as git repos (Pretty hacky), also creates a markdown file with list of repos and descriptions

OSX Users will have issues due to limitations.

$> ulimit -n 1024

more here: https://github.com/jacobrask/styledocco/issues/52

Instructions

npm install coffee-script
npm install async
npm install request

OR

Make a package.json file with libraries above.

RUN IT

coffee app.coffee <username>

Now for the actual script!

async = require("async")
request = require("request")
exec = require("child_process").exec

# How many pages
counter = [1, 2, 3]

# username example: wookiecooking
username = process.argv[2] 

# Errors 
errdor = (err, echo) -> if err then console.log err else console.log echo

# Git pull each gist and write description to a file via async
pull = (url) ->
  request url, (err, res, c) ->
    if not err and res.statusCode is 200
      async.each JSON.parse(c), (gh) ->
        exec "git clone " + gh.html_url + ".git "+gh.id, errdor
        exec "echo \" - " + gh.id + " - " + gh.description + "\" >> list.md", errdor

# Run counter array        
exec "echo \"#Gists\" >> list.md", errdor
async.eachLimit counter, 10000, (count) ->
  pull "https://api.github.com/users/" + username + "/gists?page=" + count