Skip to content

Instantly share code, notes, and snippets.

@jed
Created April 11, 2011 15:52
Show Gist options
  • Save jed/913744 to your computer and use it in GitHub Desktop.
Save jed/913744 to your computer and use it in GitHub Desktop.
<!-- 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