Skip to content

Instantly share code, notes, and snippets.

@elcuervo
Created May 29, 2013 20:38
Show Gist options
  • Save elcuervo/5673641 to your computer and use it in GitHub Desktop.
Save elcuervo/5673641 to your computer and use it in GitHub Desktop.
Check domain
#!/usr/bin/env ruby
# encoding: utf-8
%w(json open-uri).each { |lib| require lib }
abort "Usage: #{File.basename __FILE__} [query]" unless ARGV.first
response = open("http://domai.nr/api/json/search?q=#{ARGV.first}").read
JSON.parse(response)["results"].each do |domain|
symbol = if domain["availability"] == "available"
"\e[32mok\e[0m" # 32 = green
else
"\e[31mno\e[0m" # 31 = red
end
puts "#{symbol} #{domain['domain']}"
end
# vim: filetype=rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment