Swear to the world with Ruby and Adium
October 22nd, 2007
WARNING: the following post is not suitable for anyone who has left high school, unless (like me maybe) your sense of humour didn't
There's a meme doing its round of the blogosphere lately: apparently swearing is good for you and good for your business. Well not at my workplace - UPDATE: ok might leave this bit off until I actually stop working there...
Even DHH is onto this. (Well, when I say "even"-)
However, while e-mail may be an inappropriate medium for venting anger, your Adium display name certainly is not :D
Inspired by this site that got sent round the office today, I put together this little Ruby script to update your Adium display name with a razor-sharp, mature, witty tagline:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
#!/usr/bin/env ruby # usage: # adium_display_name <yourname> require 'rubygems' require 'hpricot' require 'open-uri' doc = Hpricot(open("http://www.swearalot.com/")) message = doc.search("#theswear > a").inner_html name = ARGV[0] `/usr/bin/osascript -e \ 'tell application "Adium" to \ set the display name of the first account to \ "#{name} - #{message}"'` |
It will need tweaking if you've got several accounts (I only use one at work).
UPDATE: ok, nobody sent their launchd script on the back of a postcard, so here is mine. Found out something I didn't know, namely that the OnDemand setting must be true for one-shot scripts, otherwise launchd sees the process terminate and tries to restart it (about 10 times, until it gives up and unloads the plist).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>net.codeweavers.adium-name-update</string> <key>OnDemand</key> <true/> <key>ProgramArguments</key> <array> <string>/Applications/adium_display_name.rb</string> <string>YOUR NAME</string> </array> <key>StartInterval</key> <integer>2700</integer> </dict> </plist> |

October 23rd, 2007 at 08:18 AM
Fucking awesome!
October 23rd, 2007 at 06:14 PM
It's called putting technology to good use!