Skip to content

Instantly share code, notes, and snippets.

@williamcotton
Created June 29, 2012 17:04
Show Gist options
  • Save williamcotton/3019239 to your computer and use it in GitHub Desktop.
Save williamcotton/3019239 to your computer and use it in GitHub Desktop.
require 'colored'
class RegExAvailableDomains
def initialize(regex, show_output)
@regex = regex
@show_output = show_output
@matching_words = []
@available_domains = []
find
end
def find
File.open("/usr/share/dict/words") do |file|
file.each do |line|
begin
word = line.strip
if word.match(@regex)
@matching_words << word
dot_com = word[1..-1] + ".com"
whois = `whois #{dot_com}`
if whois.split("\n")[7].include?("No match for")
@available_domains << dot_com
puts dot_com.green if @show_output
else
puts dot_com.red if @show_output
end
end
rescue
puts "error with: " + word if @show_output
end
end
end
@available_domains
end
end
RegExAvailableDomains.new(/^.ele.*/, true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment