RailsConf 2007 session audio to follow

I’ve obtained the permission of several RailsConf presenters to post recordings, made courtesy of my laptop, up here. I hope to have them up sometime Monday or Tuesday evening after getting home from RailsConf and getting my bearings.

Watch this space.

At RailsConf 2007!

I just pulled into RailsConf about 30 minutes ago and am now sitting in the Portland Convention Center eating breakfast — and oddly already running into familiar faces from years back. I’m off to my first tutorial session in 20 minutes.

Searching MediaWikis with Ruby (or treating MediaWiki a little like a database)

Here’s a little treat that I threw together to help me search Wikipedia for film data. It’s pretty simple. Example usage below:

wikipedia = MediaWiki::Search.new "http://en.wikipedia.org"
result = wikipedia.search("Firefox")    
if results.is_a? String
    # Then I've obtained the content for an actual page in a MediaWiki
else 
    # I have an Array containing Hashes with metadata about the top 20 candidates
    # Now, for giggles, I'll get the content for the first hit
    html = Net::HTTP.get_response URI.parse(result.first[:url])
end

The returned Array of Hashes, in the second case, has three keys: :url - The complete URL to the page in the MediaWiki :title - The Wikipedia page title :weight - The percentile weight supplied by the MediaWiki search.

Pretty simple? I thought so.

Code follows:

Continue reading →

“SimpleSkype”

O, happy day! One of the WxRuby devs (Alex Fenton) was kind enough to track down the memory leak. I understand that the fix should be released with the 0.40 verison in the next few days!

Prior to hearing word back from Alex, I had rewritten the entire UI in Ruby/Tk. I have to say, it was amazingly simple. IO went from knowing nothing about Ruby/Tk to having a complete Tk GUI in just a few hours. However, sadly, there doesn’t seem to be a a method to access the “Metal” look and feel. For me, this is a huge plus for using WxRuby. Being able to turn off the window controls significantly simplifies the usability of the application.

I’ll post the code for both version of “SimpleSkype” after the coming 1.0 release — and a rebranding. I don’t want to infringe on Skype’s trademark as this can be detrimental to one’s sanity.

I also just discovered Rubyscript2exe which promises to greatly simplify the deployment of my app to OS X! And here I thoughtthat I was going to have to write one from scratch. Man, I love the free software community!

WxRuby

I wrote the entire UI for my “Simple Skype” front end in wxRuby. wxRuby’s benefit comes from it’s use of widgets native to the window manager (i.e., Aqua on Mac OS X, etc.). And, while I only had a few problems with it, most of my problems were PEBKACs.

Sadly, the memory leak in my GUI, caused by the use of Bitmaps, was not among my PEBKACs. This is currently tracked as an open bug against Wx. It is unfortunate that this issue has apparently not received much attention since it was noted three years ago…

Continue reading →

rb-skypemac 0.2.0 is up

This one adds a moderate helping of contact management not limited to but include the ability to access lists of online friends, users awaiting authorization, all known users, and others. Also, it adds the ability to access various pieces of information about known users, blocking and unblocking of users, and much more.

0.2.0 may be the last release for a while as it should accomodate most of the features that I will need for my coming Skype project.

Download link and as well as gem install instructions and sample code are here.

Neat trick: delaying variable evaluation in Ruby meta-code

Working on rb-skypemac 0.2.0, I found myself in the position of either implementing 40 getter/setter pairs by hand or writing some meta code. I always prefer to write meta code. If you don’t, seek treatment — or else you will soon find yourself in treatment of the straight jacket variety.

Anyhow, as I’m writing this meta code, I realized that I needed to delay the evaluation of a variable inside a String, i.e., delaying the evaluation of #{stuff} within “This is a load of #{stuff}”. Why? Because I didn’t have the variable yet! The variable is an instance variable and my meta code generating method is at the class level. So I began to stress. And then I figured, what the hell; I’ll just escape the ‘#’ because that would just make sense.

You know what? It just worked.

Matz did one fine job designing several portions of this language!

Example below:

  class User
    def User.skypeattrreader(attrsym)
      attrsym.each do |a|
        moduleeval %{def #{a.tos}
          # The line below is the REALLY cool part
          r = Skype.send_ :command => "get user \#{@handle} #{a.to_s}"
          r.sub(/^.#{a.to_s.upcase} /, "")
        end}
      end
    end

skype_attr_reader :fullname, :birthday, :sex, :language, :country, :province

rb-skypemac is up on RubyForge

You can find it here: http://rb-skypemac.rubyforge.org/.

Introducing rb-skypemac

Since I discovered rubyosa, I’ve made it one of my side projects to improve the accessibility of my wife’s iMac. She loves to use Skype to video chat with her mother in Maryland and her brother in New York. However, the tiny buttons in Skype cause the UI to be problematic for her.

What to do?

I planned (and still do) to write a simple UI for Skype with larger buttons and fonts. However, in order to do so, I needed an interface that would allow me to do more than merely send commands to Skype. Sadly, rubyosa falls down here.

But then I found rb-appscript or just appscript. Appscript seems to provide a more direct connection to the Applescript Event layer and it provides return values from Applescript unlike the current 0.4.0 version of rubyosa.

All said, I implemented a small subset of the Skype API as a gem. I’ve submitted it to RubyForge for addition as a project. Until then, I give you rb-skypemac-0.1.0.

I have yet to decide if I will take this gem further. If it proves adequate for my needs, I may just move on to my next project: a more feature complete version of rb-itunes than what has been submitted to RubyForge.

[Get it here: rb-skypemac]

Adding structured directories of music into iTunes

I wrote this one for my father as he has several audio tapes worth of MP3s to put into iTunes on Windows. It reads down through a directory structure for music files, using the nested directory names as metadata. It expects a nested directory structure as follows:

Root Dir
 |- Artist Dirs
     |- Album Dirs
          |- Music files

Admittedly, this is my first usage of yield in anger. It hurt — but now my brain has been further fortified with vitamin Ruby.

Code follows…

Continue reading →