August 2007 Archives

RubyOSA presentation to Northern Virginia Ruby Users Group

This evening’s NoVaRUG was a good time. Rodney Degracia spoke first about RubyCLR, which provides a dynamically generated bridge between a Ruby VM and the RubyCLR. If I ever need to get at .NET internals again, now I know how I’m going to do it. In fact, I dropped an e-mail to a colleague in the office about it – except that his assembly is executed from Python. A quick Google turned up “Python for .NET” as an option.

Then it was my turn to talk to RubyOSA and RB-AppScript. Admittedly, after using both, I’m strongly biased toward RubyOSA. I have the distinct feeling that, after my presentation, the audience felt the same way.

Well, the Mac users in the audience.

Out of twenty or so people in the room, it turned out that I was really presenting to perhaps five or six Mac users. I suppose that RailsConf is in no way representative of your average Right Coast Ruby developer. However, oddly, nearly everyone stayed for my presentation. I even fielded several good questions. All in all, I had a blast.

When Xandy asked for topics for next time, I asked if someone would present on RSpec. His next words were, “Thanks for volunteering, Evan.”

Time to learn RSpec…

Slides available here: OS X Scripting with Ruby

Posted by evan on Aug 22, 2007

Three words: "Ruby on iPhone"

Yes, that’s right, ladies and gents. Thanks the hackery of a great many individuals (no, I am not among them), just this evening, I ran the following on my iPhone:

ruby -e “10.times { puts ‘foo’ }”

You can guess what happened.

Here’s how you do it, in short order, with minimal agony: Use the unofficial Installer.app developed by some folks at NullRiver. That’s it! From there, install the “Community Sources”, install “Ruby”, the BSD extensions, and “Mobile Terminal” and then go rubify yourself.

Ironically, this is not officially a product of theirs – more than likely because it is unwise to declare third party software for the iPhone as an official product at this tenuous time.

I wonder how long it will be before some intrepid Ruby coder works out a way to get to UIKit easily from Ruby and gens up some rdoc for it. I wonder if SWIG would help here?

Just for giggles, I tried:

ruby -e ‘start=Time.now;a=1;b=1;1000000.times {a=a+b};puts a;puts “time: #{Time.now - start}”’”

On my 2.16 Ghz Core Duo Macbook Pro, this took 0.280763 seconds. On the iPhone, this took 10.060393 seconds.

Looks like a speed difference of a factor of 50 for this simple computation.

Update: Um, ok, maybe it’s closer to 36 than 50.

Posted by evan on Aug 19, 2007

Return values in RubyOSA

While holding the Ruby Hoedown BoF about RubyOSA and AppScript, I mentioned how I’ve never gotten a return value out of RubyOSA – which is why I used AppScript when I needed a return value.

Shoot me now.

A quick google of “rubyosa applescript return value” yielded this post to ruby-talk-google. Woops…

It’s this simple:

require 'rubygems'
require 'rbosa'
skype = OSA.app('Skype')
OSA.wait_reply = true
call = skype.send2 "call echo123"

And call is non-nil.

Admittedly, I’m somewhat at a loss as to why wait_reply is defaulted to nil…

Update 8/11/04 1609: Laurent tells me that, if the Applescript definition is correct, RubyOSA should correctly provide return values. Chalk that up as yet another bug in the Skype Applescript API. I’ll report it soon (it’s going into iGTD now…).

– Thanks, Laurent!

Posted by evan on Aug 10, 2007