Skip to content

Instantly share code, notes, and snippets.

@fcoury
Forked from jerodsanto/friend_suggest.rb
Created May 19, 2009 03:26
Show Gist options
  • Save fcoury/113890 to your computer and use it in GitHub Desktop.
Save fcoury/113890 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'twitter'
base = Twitter::Base.new(Twitter::HTTPAuth.new('username', 'password'))
my_friends = base.friend_ids
candidates = my_friends.inject(Array.new) { |array,id| array += Twitter.friend_ids(id); array }
candidates -= my_friends
tallied = candidates.inject(Hash.new(0)) { |hash, can| hash[can] += 1; hash }
ordered = tallied.sort { |x,y| y[1] <=> x[1] }
ordered[0..9].each do |array|
user = base.user(array[0])
puts "#{user.screen_name} is followed by #{array[1]} of the people you follow."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment