Last active
August 9, 2016 19:41
-
-
Save gwang/c58158065b0c033fc40bfaa5c9f037e2 to your computer and use it in GitHub Desktop.
Search your gist host on gist.github.com
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 'open_uri_redirections' | |
require 'certified' | |
require 'json' | |
require 'pp' | |
USERNAME = 'gwang' | |
query = ARGV.first.downcase | |
# gists = JSON.parse(open("http://gist.github.com/api/v1/json/gists/#{USERNAME}", :allow_redirections => :all).read)['gists'] | |
url = "https://api.github.com/users/#{USERNAME}/gists" | |
#gists = JSON.parse(open(url, :allow_redirections => :all).read)['gists'] | |
gists = JSON.parse(open(url, :allow_redirections => :all).read) | |
gists.each do |gist| | |
#pp gist['files'] | |
#files = "(%s)" % gist['files'].join(', ') | |
files = "(%s)" % gist['files'].keys.join(', ') | |
description = gist['description'] | |
#pp description | |
#pp files | |
unless description.to_s.downcase.include?(query) || files.downcase.include?(query) | |
next | |
end | |
puts description if description | |
puts files | |
pp gist.keys | |
#puts "https://gist.github.com/gists/#{gist['repo']}" | |
pp gist['html_url'] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment