Created
January 10, 2011 20:54
-
-
Save henrik/773446 to your computer and use it in GitHub Desktop.
Search your own public Gists from the command line. Because the site only provides global search. There's not yet an API for private 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 "open-uri" | |
require "rubygems" | |
require "json" | |
USERNAME = "henrik" | |
query = ARGV.first.downcase | |
gists = JSON.parse(open("http://gist.github.com/api/v1/json/gists/#{USERNAME}").read)['gists'] | |
gists.each do |gist| | |
files = "(%s)" % gist['files'].join(', ') | |
description = gist['description'] | |
unless description.to_s.downcase.include?(query) || files.downcase.include?(query) | |
next | |
end | |
puts description if description | |
puts files | |
puts "https://gist.github.com/gists/#{gist['repo']}" | |
puts | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment