Skip to content

Instantly share code, notes, and snippets.

@fauxparse
Created April 6, 2009 00:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save fauxparse/90588 to your computer and use it in GitHub Desktop.
Save fauxparse/90588 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# Find common Twitter friends
# Usage: ./twat.rb user1 user2 ...
lists = ARGV.inject({}) do |hash, username|
page = 1
friends = []
while !(output = `curl -s http://twitter.com/statuses/friends/#{username}.xml?page=#{page} | grep "<screen_name>"`.gsub(%r{</?screen_name>}, '').split).empty?
friends += output
page += 1
end
hash[username] = friends.sort
hash
end
lists.values.inject { |a, b| a & b }.each { |user| puts user }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment