Created
April 11, 2011 15:52
-
-
Save jed/913744 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- in response to http://twitter.com/cramforce/status/57406808142266369 --> | |
<html> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script> | |
<script> | |
function getFollowers( name, cb ) { | |
var obj = {} | |
jQuery.getJSON( | |
"https://api.twitter.com/1/followers/ids.json?screen_name=" + name + "&callback=?", cb | |
) | |
} | |
function compare( a, b ) { | |
getFollowers( a, function( aFollowers ) { | |
var hash = {} | |
, aCount = aFollowers.length | |
, i = aCount | |
while ( i-- ) hash[ aFollowers[ i ] ] = true | |
getFollowers( b, function( bFollowers ) { | |
var bCount = bFollowers.length | |
, common = [] | |
i = bCount | |
while ( i-- ) bFollowers[ i ] in hash && common.push( bFollowers[ i ] ) | |
console.log( a + " has " + aCount + " followers." ) | |
console.log( b + " has " + bCount + " followers." ) | |
console.log( common.length + " of these followers overlap." ) | |
}) | |
}) | |
} | |
compare( "paul_irish", "cramforce" ) | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment