Skip to content

Instantly share code, notes, and snippets.

@bertomartin
Created April 13, 2014 04:32
Show Gist options
  • Save bertomartin/10569298 to your computer and use it in GitHub Desktop.
Save bertomartin/10569298 to your computer and use it in GitHub Desktop.
require "open-uri"
require "rubygems"
require "json"
USERNAME = "viking"
query = ARGV.first.downcase
gists = JSON.parse(open("https://api.github.com/users/#{USERNAME}/gists").read)
gists.each do |gist|
description = gist['description']
files = gist['files']
if description.nil? || !description.include?(query)
found = files.any? do |(filename, file)|
if filename.downcase.include?(query)
true
else
contents = open(file['raw_url']).read
contents.include?(query)
end
end
next unless found
end
puts "Description: #{description}" if !description.nil? && !description.empty?
puts "Files: #{files.keys.join(", ")}"
puts gist['html_url']
puts
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment