My Top Commands

Posted by shane
on Thursday, November 30
shane$ history | awk '{print $2}' | awk 'BEGIN {FS="|"} {print $1}' |  sort | uniq -c | sort -nr | head -10
 125 ll
  99 rake
  99 cd
  62 svn
  21 gem
  17 rm
  10 sudo
   7 curl
   6 ssh
   6 mkdir

I use ll (an alias for ls -al) way too much. What’s your command?

—via OpenSoul.

[ANN] YouTube Library 0.8.0 Released

Posted by shane
on Monday, November 20

Documentation: http://youtube.shanesbrain.net/

RubyForge project page: http://rubyforge.org/projects/youtube/

My little YouTube Library has finally reached version 0.8.0, thanks to a sizable patch by Walter Korman, and some functional programming tips by Lucas Carlson. It now includes full unit tests, which can be run using rake, and all classes are under the YouTube namespace. Please note that this version breaks backwards compatibility. If you want to upgrade or install, do gem install youtube. You can still get the old version with gem install youtube --version 0.1.1.

Namespace

All classes are under the YouTube namespace. To create a new YouTube client, you now have to do:

youtube = YouTube::Client.new 'DEVELOPER ID'

Object Mapping

Results from YouTube are converted to corresponding Ruby objects. For example, video.view\_count will return an Integer, and video.rating\_avg will return a Float.

Embed HTML

Everyone wants to use this to embed videos on their Web3.1 site, no? Walter added the method embed\_html which takes in a width and height (or uses the default values) and outputs all the HTML you need to embed the Flash video on your site. Therefore, in a Rails view, you can do something like:

<%= video.embed\_html %>

Unit Tests

Run unit tests with % rake test. This allows for easy detection if YouTube ever changes their API on us.

Video Details

I got a lot of questions after the first release about how to get video details, so here in an example:

video = featured_videos.first       # returns a YouTube::Video object
details = video_details(video.id)   # returns a YouTube::VideoDetails object
@tags = details.tags                # returns a String for all tags for this video

In a similar vein to this library, Walter has released a Google Video API for Ruby that brilliantly uses Hpricot to parse video meta-data.

Rails Training in Chicago

Posted by shane
on Friday, November 17

The guys over at Softies on Rails are doing a one-day Rails training event in Chicago on January 13th. They are limiting it to only 20 seats to foster a more intimate setting and charging only $249 a head. It is targeted mainly at people coming from a .NET background. If you fit the profile and have been curious about Rails, be sure to check it out as it is sure to sell out.