Jan 12 2009

Twitter Ruby Gem

I been playing around with writing my own Twitter bot and client to backup my tweet feed and other natural language processing experiments. The good thing is that there are a ton of Twitter libraries in a wide variety of programming languages. At first I picked up a Java library, Twitter4J, but then quickly opted for a Ruby version instead because I just didn’t want to create large enterprise application before I can process with my Twitter timeline. As of this writing, Ruby has two good Twitter gems, Twitter4R and Twitter. I opted to use Twitter since it also has support for identi.ca micro blogging service.

Before you can get started, you need to have the Twitter gem installed.

sudo gem install twitter

Require the Twitter gem to start using it in your Ruby scripts.

require 'rubygems'
require 'yaml'
require 'twitter'

To access your Twitter account you will need to log in via your Twitter account username and password. For this example, I keep the login information in a yaml file. If you are more security conscious you might want to prompt for the password at run time or maybe simply encrypt it instead of keeping in a plain text file. That said, here is how to sign in…

tweet = YAML::load(File.open('tweet.yml'))
twitter = Twitter::Base.new(tweet['username'], tweet['password'])

That is it, to get your 100 most recent followers you can do so with the following.

twitter.followers().each { |f|
  puts f.name
}

To get the second page, the next 100 most recent followers, just add the :page argument, such as the following

twitter.followers(:page => 2).each { |f|
  puts f.name
}

The #followers method returns a list of Twitter users. The following attributes are present for users, id, name, screen_name, location, description, url, and profile_image_url. Users may also have values for the following attributes such as profile_background_color, profile_text_color, profile_link_color, friends_count, followers_count, statuses_count, status, amongst others.

The Ruby Twitter gem exposes not just your followers but it allows you to query all replies and favorites, allows you to search twitter public stream, update your location, send direct message, and update your status.

The author of this gem has posted a ton of useful examples with functional sample code on his GitHub account. That should get any butting Twitter bot author up and running. It would also be a good idea to be familiar with the public and official Twitter API since this gem maps nicely on top of that public API.


Jan 11 2009

iTunes -69

In terms of design, simplicity, the correct default behavior Apple usually gets it right but this is not always the case. I just spent over an hour that I would like to bill Apple at my $200/hour rate. While syncing a nearly three year old iPod nano on the most recent version of iTunes I got the following non-descriptive, yet sexually ambiguous error message.

Attempting to copy to the disk failed. An unknown error occurred (-69).

I found that Apple has a support article describing the iTunes -69 error. Essentially, this error occurs when syncing your iPod when a file is unusable. It might be unusable because it is corrupt or perhaps a bad rip from a music CD or other media. There is no real fix to this issue other than to painstakingly identify the song, podcast, or application that is at fault. The solution described by Apple support is to sync your iPod and while keeping an an eye on the status display at the top of iTunes. The last song to flash prior the -69 error is at fault.

My pain with this solution is that I was updating a playlist with nearly 5,000 songs. The sync process took a long time and I had to redo it several times because it was visual straining to stare at the iTunes message box and see hundreds of song names flash through… Also, the stream of song names is interrupted by the ‘do not disconnect’ message.

From going through this, here is a tip, break down the playlist to a sub playlist of about 300 songs. If you are able to sync without a -69 error, the corrupt file is not present in this batch. If the file is present, stare as the song names stream by and hope you don’t blink prior to the error popping up.

This is the solution Apple should implement, don’t disrupt the sync process when on corrupt file is encountered. I bad apple, pun intended, should not spoil the sync process. Apple needs to provide better diagnostic and report tools, especially since many iTunes users invest hundreds of dollars on their music collection.

This is how I wish iTunes should have handled this issue…

  • DO NOT interrupt sync process, sync remaining files
  • Report on songs, apps, and podcasts that where not synced
  • Allow options to fix the issue, re-download from iTunes
  • Provide diagnostic tools to quickly identify, remove, and re-download corrupt resources

Jan 11 2009

Netbook Top Tech Tip

I recently bought a Asus Eee PC netbook. The Eee PC is tightly packed with a 10″ screen. The number one tip when browsing with Firefox on the Eee PC is to hit F11 for full screen. F11 will hide all of Firefox’s chrome, that is the status bar on the bottom, and the navigation and tab bar on top. Once you have Firefox running on full screen mode you maximize the area of the web content to the full screen. If you miss the navigation bar, hit Ctrl + E to reveal just the navigation bar. The Ctrl + L key combination will focus the cursor on the location field in the navigation bar, this allows you to quickly enter a new URL destination.


Jan 8 2009

The Rubyist: December Edition

Here is a recap of the top Ruby-related links for the month of December 2008. Links for The Rubyist are provided by A Rubyist Railstastic Adventure, a tumblelog.

Merb Joins Rails

Rails

Ruby


Dec 30 2008

TechKnow Year In Review 2008

It is that time of year where we reflect on the accomplishments of the passing year and look forward to the one to come. Here is a window into the past year in technology through this year’s popular posts on TechKnow Juixe.

Top Favorites 2008

Ruby

Shoes

Perforce

Google App Engine

FlashDevelop

Mobile

Rants and Raves

Reviews

Top Tips and Hot Hacks

Tweets

Year in Review


Dec 30 2008

Twittering Tweets

As of late I have been more active on Twitter and often I just blast tweets about twittering. In this meta-moment, I repost some of the tweets about twitter itself.

  • It used to be that you measure your status by the number of followers you had, now you have twitter grades and twitter ranks.
  • RT @gwbush: RT @da_real_dick_cheney: RT @techknow: war is recursive.
  • Should twitter have an automatic spellchecker? It is hard to type of some of mobile devices, in the heat of the moment, walk, and chew.
  • tossing, turning, and twittering…
  • Predictions 2009: some repressive government will ban/censor Twitter.
  • Is is awkward that I think of twitter as some sort of virtual psychiatrist? Or worst, my virtual imaginary friend?
  • My new twitter motto: Follow back and holla back.
  • Those that can’t do teach, those that can’t tweet retweet.
  • Twitter is such a utility, an asset, that I don’t like giving my twitter password to third party twitter services
  • Twitter needs to have a public key and validation process to give access to third party services without giving out passwords, like flickr.
  • If the American Revolution was held today, Paul Revere’s Midnight Ride would have been a Midnight Tweet.

I frequently tweet and update my social status. If you like to follow m or befriend me, feel free to hit me up on twitter, identi.ca, and/or FriendFeed.