Social Nerds Track Twitter Followers with github
Update: Be sure to check the updated source code. I wasn’t accounting for the paging mechanism in the Twitter API for followers. The old code won’t work with over 100 followers.
Recently, I logged into Github to find a notification for a new mention. When I went to check it out, I found that I was mentioned because someone was logging all of their tweets with Github.
Being as obsessive about my low follower count as I am, I thought it would be really cool to apply a similar tactic to Twitter followers. I was able to create a script to do everything I need to track my Twitter followers with Git (and optionally Github) in just a little over an hour.
Before I began coding, I had to register a new application with Twitter and throw all of my keys/secrets into a config.yml. I also set up a git repository in directory with the script. This way, I didn’t have to worry about checking for a repository - my script can just assume it is there.
Then the code… it’s pretty simple, so I’ll just paste it.
require "yaml" require "twitter" require "git" key_file = YAML.load_file('config.yml') g = Git.init('.') Twitter.configure do |config| config.consumer_key = key_file['consumer_key'] config.consumer_secret = key_file['consumer_secret'] config.oauth_token = key_file['oauth_token'] config.oauth_token_secret = key_file['oauth_token_secret'] end follower_file = File.open('followers','w') cursor = -1 followers = [] begin response = Twitter.followers :cursor => cursor followers += response.users cursor = response.next_cursor end while cursor > 0 followers = followers.sort{|x,y| x.id <=> y.id}.collect{|x| x.screen_name} followers.each do |f| follower_file.puts f end follower_file.close g.commit_all('Followers for '+Time.now.to_s) g.push
That’s it. I set this up to run in a cron job twice a day, and now I have all kinds of green +’s and red -’s next to my follower list. It will fail if there hasn’t been any changes to your follower list, but that’s fine because there’s nothing worth writing home about.
I may stop pushing to github, just to limit annoyances to my followers there, but I don’t think I need to worry about the list being up there because it’s not any thing that you can’t get by visiting (scraping if you’re a bot) my already public profile. One thing I really like about it being on GitHub is that I can use the RSS feed to passively keep tabs on when things change. I never have to visit that repository just to find out there are no changes.
You can find the full project here: https://github.com/justinxreese/justinxreese-followers
Ruining The Illusion
I was watching the music video for Ted Leo’s “Me & Mia,” when I got curious as to where the video was shot. I had just gotten back from a trip to New York City and my fascination with the immense amount of stories in the city grows every day. The fun part of these stories, however, is to be able to stand somewhere and say… “hey, isn’t this where that thing happened?”. So I started a journey to find the filming location of the video. It was actually pretty easy to find with the help of a little knowledge and Google Street View. If you watch the video, you can clearly see a street sign for Avenue of the Americas. If you’ve ever visited New York or seen a map, you’ll probably remember that name, and maybe even know that it is another name for Sixth Avenue in Manhattan. Sixth Avenue runs north through Manhattan, so the next step was finding the cross street.
The main landmark in the video is the pizza shop below the apartment. Oh, a Famous Ray’s pizza in New York City. That certainly won’t be hard to find. In case you don’t pick up on sarcasm in text, there are 46 pizza places named some variation of “Ray’s” in NYC. Luckily, for my Google stalking, only three of those locations were on 6th Avenue. In the blurry YouTube video, you can see the address is something like 586 or 695 or something with 3 digits with a distinct shape. Google Maps “rays pizza on avenue of the americas” and one of the first results you see is World Famous Ray’s Pizza 595 Avenue of the Americas, New York, NY.
Unfortunately, there is no longer a Famous Ray’s at 595 6th Avenue, but it did look like I had found the right street. So to confirm I had found the place, I had to use a creative solution. I took a screen shot from the video and lined it up with the building I found with Google Street View. The windows lined up perfectly.

After lining up the images, I felt like I was a part of the team on CSI. Maybe even CSI : Miami, taking orders from the ever so cool Horatio Caine (again, sarcasm). I did kind of ruin the illusion of the music video when I see that Ted Leo was rocking out in a acupuncture office above a T-Mobile store. Not that anything mythical was happening there to begin with, but I was still smacked in the face with a giant T-Mobile logo when I finally found the filming location of the video.
My detective work DID get a cool response out of Ted on Twitter with some … uhh… insider information. So it made it a little more interesting and worth the time it took.

I have an even better Google Stalking post coming up where I found a Pittsburgh house featured on HGTV because I wanted to buy it. That required a lot more effort (I had to pull out Google Earth for this one), so the post will require more effort as well.