Created
February 6, 2011 12:12
-
-
Save skojin/813330 to your computer and use it in GitHub Desktop.
script to backup my gists
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 characters
require 'json' | |
require 'open-uri' | |
gists = JSON.parse(open("http://gist.github.com/api/v1/json/gists/#{ENV['GIST_USER']}").read)['gists'] | |
repos = gists.map{|g| g['repo']} | |
existing, new = repos.partition{|r| File.exists?(r)} | |
new.each do |r| | |
puts "clone new #{r} gist" | |
`git clone git://gist.github.com/#{r}.git` | |
end | |
existing.each do |r| | |
puts "update existing #{r} gist" | |
`cd #{r} && git pull` | |
end | |
# build Descript.ion | |
File.open('descript.ion', 'w'){|f| f.write gists.map{|g| [g['repo'], g['description']].join(' ')}.join("\n") } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment