sant0sk1 (owner)

Forks

Revisions

gist: 113270 Download_button fork
public
Public Clone URL: git://gist.github.com/113270.git
Embed All Files: show embed
friend_suggest.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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