Hacker News new | ask | show | jobs
by brett 6630 days ago
I made a little bit more robust version. Some of the whois calls (like heroku.com) have 2 OrgName lines and some don't have one at all (like weebly.com).

  Amazon.com, Inc.                           7
  	youos.com
  	jamglue.com
  	shoutfit.com
  	socialmoth.com
  	webmynd.com
  	heroku.com
  	8aweek.com
  SoftLayer Technologies Inc.                5
  	scribd.com
  	xobni.com
  	anywhere.fm
  	bountii.com
  	disqus.com
  ThePlanet.com Internet Services, Inc.      5
  	snipshot.com
  	virtualmin.com
  	heysan.com
  	adpinion.com
  	reble.fm
  Hurricane Electric                         3
  	weebly.com
  	octopart.com
  	auctomatic.com
  Internap Network Services                  2
  	loopt.com
  	likebetter.com
  NoZone, Inc.                               2
  	flagr.com
  	thinkature.com
  Peer 1 Network Inc.                        2
  	rescuetime.com
  	addher.com
  ServePath, LLC                             1
  	reddit.com
  American Digital Network                   1
  	fuzzwich.com
  Columbus Network Access Point, Inc.        1
  	versionate.com
  Performance Systems International Inc.     1
  	justin.tv
  Global Netoptex, Inc                       1
  	clickfacts.com
  RackForce Hosting Inc.                     1
  	draftmix.com
  Time Warner Telecom, Inc.                  1
  	textpayme.com
  Logicworks Corporation                     1
  	inklingmarkets.com
  Layered Technologies, Inc.                 1
  	buxfer.com
  Rackspace.com, Ltd.                        1
  	iminlikewithyou.com
  BitPusher, LLC                             1
  	wufoo.com
  Slicehost LLC                              1
  	tipjoy.com
1 comments

  #!/usr/bin/env ruby
  domains = %w{reddit.com loopt.com clickfacts.com
               textpayme.com snipshot.com inklingmarkets.com flagr.com wufoo.com 
               youos.com likebetter.com thinkature.com jamglue.com shoutfit.com scribd.com 
               weebly.com virtualmin.com buxfer.com octopart.com heysan.com justin.tv 
               iminlikewithyou.com socialmoth.com xobni.com versionate.com adpinion.com anywhere.fm 
               fuzzwich.com bountii.com auctomatic.com disqus.com draftmix.com webmynd.com 
               rescuetime.com reble.fm heroku.com tipjoy.com addher.com 8aweek.com}

  orgs = {}
  domains.each do |c|
    whois = `host -t a #{c} | grep 'has address' | cut -f 4 -d ' ' | xargs -n 1 whois`
    if org = whois.grep(/OrgName/).first
      org = org.sub(/OrgName:\s/, '').strip
    else
      org = whois.split("\n").first.split("(")[0].strip.sub(/\s+[A-Z\-\d]+$/, '')
    end
    orgs[org] ||= []
    orgs[org] << c
  end
  max_size = orgs.sort_by{|k, v| k.size}.last.first.size


  orgs.sort_by{|k, v| v.size}.reverse.each do |o, ds|
    puts "%-#{max_size}s %5s" % [o, ds.size]
    ds.each {|d| puts "\t#{d}"}
  end
  puts
  puts "%-#{max_size}s %5s" % ["Total # of Domains", domains.size]
  puts "%-#{max_size}s %5s" % ["Total # of Providers", orgs.size]