Extension-less Formats in ActiveResource

March 26th, 2008 When trying to integrate Litmus with Fetch recently we came across an API that whilst appearing RESTful, didn't quite map onto ActiveResource conventions because their URLs 404'd if we included .xml as the extension.

So I quickly whipped up a little plugin to let us specify new formats that don't include extensions.

1
2
3
4
5
6
7
class Something < ActiveResource::Base
  
  self.site = "http://someone:password@an-app.com"
  self.prefix = "/api/"
  self.format = :xml_no_extension
  
end


Now, calls to

Something.find(:all)
will generate http://an-app.com/somethings rather than http://an-app.com/somethings.xml

Perfect!

You can grab the code from the ExtensionlessFormat GitHub repository

Use TextExpander to create a TinyUrl

March 7th, 2008

I’m a big TextExpander user, so much so that I always find myself typing strange key combinations to do things even when I’m not on my own machine. Whilst I do appreciate that unix has a perfectly good alias command that could be used instead, I like that my text shortcuts work even when I’m ssh’d into a remote machine (TextExpander is just watching your keyboard input and converting it as you type).

Recently I’ve found myself doing a lot of TinyUrl links (mainly because of Twitter) and decided to knock up an Applescript to instantly convert whatever is on my clipboard into a tiny url as I type.

Go and check out the code on pastie – once you’ve got this its just a case of creating a new Applescript snippet in TextExpander and pasting in this code.

Update: I got linked from the SmileOnMyMac Blog (developers of TextExpander) – thanks guys! Glad you like the tip :) They also have a pre-packaged version of my script ready to download straight into TextExpander so head over there to get hold of it.

Another Update: Looks like Jack-Daniyel Strong devised a much nicer version of my applescript that is faster, and has error checking. Nice work! I’m now using his script :)