Liked Dean Wilson’s twitter

07 October 2008 in stream
tagged with [python] [ruby]

Liked Dean Wilson's twitter: [[ Why have i never seen any posts from people saying "I'm moving from python/ruby to perl and I'm so happy"? ]]

http://twitter.com/unixdaemon/statuses/949342596

 

Liked Dean Wilson's twitter: [[  Why have i never seen any posts from people saying "I'm moving from python/ruby to perl and I'm so happy"? ]]

Upcoming

02 October 2008 in stream
tagged with [developers] [google] [ruby]
and is [geotagged]

I will be attending Ruby Manor on Saturday November 22

http://upcoming.yahoo.com/event/1110036/

 

I will be attending Ruby Manor on Saturday November 22

Simplistic Complexity » Jeez People, Stop Fretting Over Installing RMagick

08 August 2008 in links
tagged with [install] [macos] [rmagick] [ruby] [software]

Utility to install rmagick on macos. Might be useful if I ever want to try using the system ruby for development.

http://www.simplisticcomplexity.com/2008/06/06/jeez-peopl...

 

Simplistic Complexity » Jeez People, Stop Fretting Over Installing RMagick

Putting the mongrel port number in your logfile filename

01 July 2008 in links
tagged with [mongrel] [rails] [ruby] [sysadmin]

By default mongrels all log into a single logfile. This makes debugging a complete pain. Putting the process PID into the filename is easy, but getting the current mongrel process’ allocated port is slightly harder.

http://pastie.org/169850

 

Putting the mongrel port number in your logfile filename

Tinder - a Ruby Campfire API

22 March 2008 in links
tagged with [api] [campfire] [ruby]

I wouldn’t call it great. But it works and is better than anything else out there for talking to Campfire from Ruby. If you want to be able to read what is said in the channel, it’s the only thing.

http://opensoul.org/2006/12/8/tinder-campfire-api

 

Tinder - a Ruby Campfire API

One of the Wolves » Ruby Subversion Bindings: Better Documentation…

11 March 2008 in links
tagged with [bindings] [ruby] [subversion]

Useful ruby wrapper class for the svn bindings (which ship with 10.5, rah)

http://www.oneofthewolves.com/2007/12/22/ruby-subversion-...

 

One of the Wolves » Ruby Subversion Bindings: Better Documentation…

Shelf - Context for MacOS

05 January 2008 in blog
tagged with [cluepacket] [dashboard] [macos] [ruby] [shelf] [software]

I really miss Dashboard. It was an effort to display some context around whatever person you were interacting with at any given moment - look at an email from Paul, or open an IM chat with him and you’d see things that he’d blogged or uploaded to Flickr recently. Genius. From the screenshots, it looks practically magic, tying into incoming SMS messages, IM conversations, the RSS feed reader, etc.

Alas, I never had a fully working Dashboard setup locally, mostly because applications had to actively participate in the process - they sent things called ‘cluepackets’ to the dashboard application containing hints about the current context. Because of this design, every app involved needed its source code patched and a recompile. This was a complete pain. Obviously, had everything gone to plan, the patches would have been merged and everyone would have been happy. I presume that Dashboard failed because the bootstrapping process was so hard that no-one used it.

Anyway, inspired by both Dashboard and Aaron‘s obsession with the address book, I’ve had a stab at doing it again, but worse.

Shelf

Shelf will look at the current foreground application, and try to figure out if what you’re looking at corresponds to a person in your Address Book. Then it’ll tell you things about them.

Update 2008/01/08: I have downloadable versions of Shelf now. Go to the project page and download one.

Shelf screenshot

It’s for MacOS. Because on MacOS, I have OSA - I can interrogate most (well-written) applications about their state in a beautiful, language-agnostic and fast manner. I can ask Mail.app for the email address of the current mail. I can ask Safari what the URL of the foreground window is. I can ask Adium for the account details of the current chat. I can ask NetNewsWire for the homepage URL of the current subscription. And I can ask the system what app is in the foreground. I can also interrogate the system address book via the Cocoa bindings for same and find out what users have got that email address, or URL, or AIM screen name. And then I can take all the other information about them in their address book entry, and figure out some context. Oh, and the thing’s written in Ruby, because the Ruby scripting bridge is a thing of serious beauty and should be played with by everyone.

Good thing

So, advantages. I don’t have the bootstrapping problem, because most MacOS applications already have enough of a scripting interface that I can extract information from them. Firefox is proving to be a serious problem, alas, but I’ve hit no other apps I can’t get something useful out of.

Once I have an Addressbook record as context, I can update the interface with a picture of the person and their name/company (direct from the address book, so easy). As a ‘will this work?’ experiment, I’m parsing every referenced URL in the address book card for RSS feeds, and displaying those as context. And (because I work there) I have special-case Dopplr support that tells me where the person is in the world and where they’re going next. This means that when someone IMs me, a window pops up and tells me where they are, when they’re back, and what they’ve blogged recently. Awesome.

addressbook screenshot

The system address book is great - it has multiple email address and URLs for people, so I’m indicating things like Dopplr username by just putting the url to my traveller page in my address book entry. I can parse the username out later and use it to call the API with. This has the advantage that if I visit my Dopplr page in Safari, hey, wow, that URL is in the address book, and it knows that it’s me again. Flickr is the next obvious choice for special-casing, but the principle extends to anything.

Bad thing

Disadvantages. Firstly, urgh, I’m polling. Every 2 seconds, I ask the system for the foreground application, then ask that application (if I know how) for context. This is probably a little heavy (is it? I’m guessing..). Secondly, I have to do explicit work for every app out there. The huge advantages of Dashboard’s cluepacket approach over mine were that packets were pushed instantly on a change of context, and that a new application was responsible for sending its own cluepackets.

Actually, this is easy. My app should have a ‘change context’ OSA method that other applications can call. Smart apps can tell me when their context changes, and I’ll just poll everyone else. Once I’ve taken over the world, everyone will be pushing messages to me, and I can deprecate the poll interface. Genius.

Recently, most of the crazy apps I’ve put here have been labelled as ‘proof of concept’. This one is different. This one probably won’t even build on your computer. I’m putting things up here as a was of musing about technique. For instance, Dashboard had a far better design than this app. It had a nice pipeline thing going for it, whereas I just have a class per foreground application, this class must produce an Address Book record, then I just interrogate every context producer for information and display it. This is silly - if I’m looking at Paul’s Flickr photos page, I don’t need my app showing me the thumbnails again, I might be much more interested in where he is right now. Hell, in a perfect world, it would work out the dates of the photos I’m looking at, and show me where he was at that time.

Future

Clever things I could (and want to) do:

  • If the foreground URL doesn’t belong to a user, look for hcard markup in the source HTML and try to derive a person from that. Right now, for instance, I’ll only recognise your Flickr page as belonging to you if it’s one of the URLs against your address book card. But Flickr pages are marked up with enough hcard that I should be just able to figure it out.

  • More intelligence around context - as above, if I’m looking at a blog of a friend, I want to see other things, not their blog again.

  • Remembering connections - if I figure out a local person from a Flickr page via hcard markup rather than an Address Book URL, why not remember their Flickr username and display their photos when they email me?

Many of these features are difficult, mostly because of my core design right now - I derive an Address Book entry from the current application, then derive context from that entry. This hampers cleverness somewhat - I really need to pass around a lot more information about how I derived this person, and keep a local cache of conclusions about them. Maybe the person isn’t in my address book - I get email from people I don’t know! But their email address might correspond to a Gravatar so I could show a picture of them. Maybe the mail has some URLs in the .sig and I could find their blog. Maybe they’ve commented on my blog in the past and I’d like links to the comments. Likewise, if I find, via hcard in the source of a page, that a page is about someone I know, should I update Address Book and add URLs for them? Probably not a good idea. So I need a local store of connections as well.

Now what?

I don’t know. It’s very tempting to rewrite the thing in Python before it gets any more complex. Partially this is because the Ruby feedparser dependencies are a bugger, but mostly it’s because I don’t want my python sk1llz to atrophy down to nothing. Recently everything I do is in Ruby, and I don’t like that. Shelf also desperately needs some work done to make it asynchronous, and cache things - when I look at an email right now, it’ll hang for 5 minutes while it goes off and fetches 20 RSS feeds, every time I change the person I’m looking at. Not exactly pleasant. But the ‘find out about a person’ is really just a trivial example of the sort of things you can do once you know who they are. The ‘derive context from current machine state’ side of things is much more interesting.

 

Universal Feed Parser in Ruby

03 January 2008 in links
tagged with [atom] [feed] [parser] [rss] [ruby]

A port of the Python Universal Feed Parser to Ruby. Lots of deps, alas, which is annoying, but it does work.

http://rfeedparser.rubyforge.org/

 

Universal Feed Parser in Ruby

maemo.rubyx.co.uk - /ruby-maemo/

28 November 2007 in links
tagged with [maemo] [ruby]

Ruby for the N800. Includes hildon bindings, so I can write GUI apps in it. Interesting.

http://maemo.rubyx.co.uk/ruby-maemo/

 

maemo.rubyx.co.uk - /ruby-maemo/

RAA - mp3info

24 November 2007 in links
tagged with [id3] [mp3] [music] [ruby]

pure ruby id3 tag reader. Seems better.

http://raa.ruby-lang.org/project/mp3info/

 

RAA - mp3info

id3lib-ruby - ID3 tag library for Ruby

23 November 2007 in links
tagged with [id3] [mp3] [music] [ruby]

Read MP3 tags in Ruby

http://id3lib-ruby.rubyforge.org/

 

id3lib-ruby - ID3 tag library for Ruby

RubyForge: MP4Info: Project Info

23 November 2007 in links
tagged with [mp4] [music] [ruby]

 

RubyForge: MP4Info: Project Info

Learning Ruby using Rails

16 November 2007 in blog
tagged with [programming] [python] [rails] [ruby]

Recently I got dropped in the deep end and had to learn both Ruby and Rails very quickly. I didn’t think this would be a problem - everyone raves about how easy Rails is to pick up, right? - and it wasn’t. The problem is actually arriving now, as I start trying to use Ruby for things other than Rails applications. And I can’t, because I’ve learned all sorts of nice Ruby tricks that looked like they were core language features but actually turn out to be added to the built-in Ruby objects by Rails.

For instance, I really like the 3.days convention for turning numbers into time intervals. That’s added by this extension. In fact, in digging for this, I found out just how many things Rails adds to core Ruby. I’m scared.

I’m torn. I’d like to consider messing with the built in objects confusing and dangerous. And I’ve been bitten by this before. I’ve also had problems where one module’s patching to a Ruby builtin interferes with another module’s patching of the same object. Lovely.

At the same time, though, I love it. I love both the huge convenience and readability of being able to write Time.now + 3.days, and the fact that the language lets me do this. All languages should be this consistent - none of this ‘some types are special’ crap.

There are trade-offs. I love Python, but I hate that map is a global function and not a method on arrays, and I hate that certain types are special and immutable. But I’m sure there are scary speed benefits from doing things this way.

I wonder if part of the reason that Ruby has this ‘just for Rails’ reputation is because, having learned Ruby for Rails, you can’t use that Ruby for anything else without unlearning a stack of habits?

 

JRuby 1.1 Beta 1 Released; Faster Than The Regular Ruby Interpreter

06 November 2007 in links
tagged with [java] [jruby] [ruby]

 

JRuby 1.1 Beta 1 Released; Faster Than The Regular Ruby Interpreter

WhatsNewInLeopard - ruby - Trac

26 October 2007 in links
tagged with [leopard] [macos] [ruby]

[[ ..write a Ruby class in Xcode, with outlets and/or actions, and everything automatically appears in IB […] the other way, you can manually define outlets and/or actions in IB, and the corresponding Ruby code will be pasted created ]]

http://trac.macosforge.org/projects/ruby/wiki/WhatsNewInL...

 

WhatsNewInLeopard - ruby - Trac

Irritating 2038 Ruby / Rails behaviour

17 October 2007 in blog
tagged with [bug] [rails] [ruby]

In a rails console:

>> (Time.now + 30.years).class
=> Time
>> (Time.now + 31.years).class
=> DateTime
>> (Time.now + 30.years).to_s
=> "Sat Oct 17 17:27:11 +0100 2037"
>> (Time.now + 31.years).to_s
=> "2038-10-17T17:27:13+01:00"

Time objects after about August 2028 can’t be expressed internally as ‘UNIX epoch (1st January 1970) plus N seconds’ where N is a 32 bit integer. Once a Time object tries to express a date after this point, it gets silently converted to a DateTime object, which presumably uses a different internal representation. It also stringifies differently, has different methods, and is just generally annoying behaviour.

When you have dates in a MySQL database, and use ActiveRecord, DATETIME columns come out of the table as either a Time or a DateTime object depending on what the expressed date is. Lovely. This bug indicates that dates before 1970 behave similarly (they can’t be expressed as unsigned epoch times either).

This is apparently desired behaviour.

Update: Apparently, DateTime objects are also much slower than Date objects.

 

Getting ActiveRecord objects by ID

02 October 2007 in blog
tagged with [optimization] [rails] [ruby]

I’m trying to speed up a rails app here, and I’ve been making some assumptions that I’ve realised may not actually be true.

Specifically, if I have a list of IDs, I’ve been assuming that

list_of_ids.map{|id| Model.find(id) }

is going to be slower than

Model.find( list_of_ids )

Presumably, the latter will only make one SQL call to fetch all the objects, but the former will make a call per ID. This is because I’m used to perl, where the ORMs are stupid, the language is fast, and the DB is always the bottleneck.

But the sort of SQL produced by the supposedly slower approach is much more cacheable. The supposedly faster approach will tend to generate a different SQL query every time, whereas a sufficiently smart cache layer could intercept the SQL calls of the later approach and just hand back the models.

Initial benchmarking seems to have the one-SQL-call approach faster anyway. It does turn out to have a disadvantage, though - Model.find( ids ) doesn’t return objects in the same order that the IDs were in, whereas the map approach does. That’s fairly easy to fix, though:

class ActiveRecord::Base
  class << self
    def find_in_order( ids )
      # return all instances with the passed ids, in the order that the ids are in
      objects = self.find( ids )
      objects = objects.sort_by{|o|ids.index(o.id)}
      return objects
    end
  end
end

 

Revolution On Rails: [PLUGIN RELEASE] Metrics

27 September 2007 in links
tagged with [metrics] [profile] [rails] [ruby]

Profile individual functions inside a rails application

http://revolutiononrails.blogspot.com/2007/06/plugin-rele...

 

Revolution On Rails: [PLUGIN RELEASE] Metrics

Monkeybars

21 September 2007 in links
tagged with [rails] [ruby] [swing]

write swing apps in rails. This scares me.

http://monkeybars.rubyforge.org/

 

Monkeybars

Ola Bini on Java, Lisp, Ruby and AI: Ruby Metaprogramming techniques

20 September 2007 in links
tagged with [metaprogramming] [ruby]

list of ruby metaprogramming techniques.

http://ola-bini.blogspot.com/2006/09/ruby-metaprogramming...

 

Ola Bini on Java, Lisp, Ruby and AI: Ruby Metaprogramming techniques

Rails: Calling render() outside your Controllers

17 September 2007 in links
tagged with [mvc] [rails] [render] [ruby] [template]

Yet more glorious peversion of MVC - this time, rendering rails templates from inside your models.

http://blog.yanime.org/articles/2006/08/05/rails-calling-...

 

Rails: Calling render() outside your Controllers

Class: TZInfo::Timezone

13 September 2007 in links
tagged with [ruby] [timezone]

an attempt at sane timezone handling in Ruby. The Ruby ‘Time’ class appears to suck.

http://tzinfo.rubyforge.org/doc/classes/TZInfo/Timezone.html

 

Class: TZInfo::Timezone

RubyPants

05 September 2007 in links
tagged with [ruby] [smartypants]

 

RubyPants

typography-helper - Google Code

05 September 2007 in links
tagged with [plugin] [rails] [ruby] [typogrify]

the python/django typogrify filters, ported to ruby/rails.

http://code.google.com/p/typography-helper/

 

typography-helper - Google Code

Hivelogic - The Narrative - Building Ruby, Rails, Subversion, Mongrel, and MySQL on Mac OS X

30 July 2007 in links
tagged with [install] [macos] [ruby]

I don’t seem to have delicioused this, despire using it all the time. What can I say? I rebuild my computer a lot.

http://hivelogic.com/narrative/articles/ruby-rails-mongre...

 

Hivelogic - The Narrative - Building Ruby, Rails, Subversion, Mongrel, and MySQL on Mac OS X

Joyeur: Joyeur: Joyent Slingshot

23 March 2007 in links
tagged with [app] [development] [offline] [rails] [ruby] [slignshot]

Rails apps turned into offline-capable Mac .apps with very little work. awesomely cool stuff. I may need to have a look at rails again.

http://joyeur.com/2007/03/22/joyent-slingshot

 

Joyeur: Joyeur: Joyent Slingshot

Hivelogic: Articles: Building Ruby, Rails, LightTPD, and MySQL on Tiger

16 November 2006 in links
tagged with [compiling] [rails] [ruby]

Gah, I really resent having to do this.

http://hivelogic.com/articles/2005/12/01/ruby_rails_light...

 

Hivelogic: Articles: Building Ruby, Rails, LightTPD, and MySQL on Tiger

whytheluckystiff — Seeing Metaclasses Clearly

22 August 2006 in links
tagged with [metaprogramming] [ruby]

When I understand all of this, I will be happy.

http://whytheluckystiff.net/articles/seeingMetaclassesCle...

 

whytheluckystiff -- Seeing Metaclasses Clearly

Top 30 Ruby on Rails Tutorials

20 July 2006 in links
tagged with [rails] [ruby] [tutorials]

I guess I should have a look at this Rails thing, then

http://www.econsultant.com/web-developer/ruby-rails-tutor...

 

Top 30 Ruby on Rails Tutorials

RailsConf Europe 2006

08 June 2006 in links
tagged with [conference] [london] [rails] [ruby]

I’m going to this. I should try to learn some rails, I guess.

http://europe.railsconf.org/

 

RailsConf Europe 2006

Gtk::MozEmbed

13 May 2006 in links
tagged with [gtkmozembed] [mozilla] [ruby]

API docs for the Ruby gtkmozembed widget

http://ruby-gnome2.sourceforge.jp/hiki.cgi?cmd=view&p=Gtk...

 

Gtk::MozEmbed

RubyGecko

13 May 2006 in links
tagged with [gtkmozembed] [mozilla] [ruby] [thumbnail]

Example usage of gtkmozembed from Ruby. Specifically, the snapshotter example at the end looks very useful.

http://ruby-gnome2.sourceforge.jp/hiki.cgi?RubyGecko

 

RubyGecko

Small Values of Cool: London Python/Django/Ruby/Rails/Java Christmas party

22 November 2005 in links
tagged with [catalyst] [django] [frameworks] [meeting] [pub] [rail] [ruby] [turbogears]

There are a scary number of frameworks represented here. Must go.

http://www.brunningonline.net/simon/blog/archives/001961....

 

Small Values of Cool: London Python/Django/Ruby/Rails/Java Christmas party