Skip to content

Instantly share code, notes, and snippets.

@heisters
Created June 2, 2009 00:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heisters/121908 to your computer and use it in GitHub Desktop.
Save heisters/121908 to your computer and use it in GitHub Desktop.
a rake task to pull gists from github.com as html
# A rake task to pull all your gists from github.com as html.
#
# This has advantages over the script embed:
# * the script uses document.write, which is not compatible with XHTML Strict 1.0
# * document.write also can't be used after the document body has loaded (ie. no AJAX)
# * the gists get indexed by search engines this way
desc "Pull all gists from github and cache them locally"
task :gists do
uri = URI.parse 'http://gist.github.com/api/v1/yaml/gists/heisters'
html = YAML.load(Net::HTTP.get(uri))['gists'].inject('') do |h, gist|
h << Net::HTTP.get(URI.parse("http://gist.github.com/#{gist[:repo]}.pibb"))
end
File.open(File.dirname(__FILE__)+'/gists.html', 'w'){|f|f.write html}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment