Skip to content

Instantly share code, notes, and snippets.

@skojin
Created February 6, 2011 12:12
Show Gist options
  • Save skojin/813330 to your computer and use it in GitHub Desktop.
Save skojin/813330 to your computer and use it in GitHub Desktop.
script to backup my gists
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