-
-
Save makevoid/124685 to your computer and use it in GitHub Desktop.
gist api scripts
This file contains 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 'net/http' | |
require 'uri' | |
# /api/v1/:format/new | |
# /api/v1/:format/gists/:user | |
# /api/v1/:format/:gist_id | |
res = Net::HTTP.post_form(URI.parse('http://gist.github.com/api/v1/xml/new'), | |
{ 'files[file1.ab]' => 'CONTNETS', | |
'files[file2.ab]' => 'contents' }) | |
puts res.body |
This file contains 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
<?xml version="1.0" encoding="UTF-8"?> | |
<gists type="array"> | |
<gist> | |
<public type="boolean">true</public> | |
<description nil="true"></description> | |
<repo>4278</repo> | |
<created-at type="datetime">2008-08-06T13:30:32-07:00</created-at> | |
</gist> | |
</gists> |
This file contains 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
class Gist | |
require 'rubygems' | |
require 'hpricot' | |
require 'open-uri' | |
USER = "makevoid" | |
URL = "http://gist.github.com/%s" | |
def self.all | |
doc = open(URL % USER) { |f| Hpricot(f) } | |
doc.search("#files .meta").map do |gist| | |
{ | |
:id => gist.search(".info span a").inner_text.gsub(/gist:/, '').strip, | |
:name => gist.search(".info span[2]").inner_text, | |
:date => Time.parse(gist.search(".date abbr").inner_text) | |
} | |
end.sort_by{ |g| g[:date] }.reverse | |
end | |
end | |
# puts Gist.all.inspect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment