Memories of lost youth

Saturday, January 31, 2009

Ruby sleep fail

Dear Ruby, why this weirdness?

behe:~ 16:34:52> irb
>> sleep 0.9999994
=> 1
>> sleep 0.9999995
Errno::EINVAL: Invalid argument - sleep
from (irb):2:in `sleep'
from (irb):2
>>

Friday, May 2, 2008

Lion trashcan

Found this awesome pimped lion trashcan today just outside where I work.

Thursday, November 1, 2007

Buddy icon in Adium revisited

Played around in the event window of Adium today and realised that you can actually connect an AppleScript to the "You connect" event. When I connected my buddy icon update script to this and removed the "Are you sure.." message, I finally got the automatic updating of my buddy icon on connect to work!
So from now on I won't have any more good, carefully selected photos, just the random way I look when logging on to Adium.

Sunday, June 24, 2007

Automatically update Adium buddy icon with iSight snapshot

So last monday I thought it would be fun to update my Adium buddy icon with how I currently look by taking a new image with the iSight camera that is built into my MacBook Pro. The reason was that I was wearing a suit with necktie and everything to work, something I don't usually do.

One of my IM buddies , Peter Krantz, saw this and commented in shock and awe claiming that was no way for a developer to dress. But he also had a really nice idea - that it would be cool to be able to get an updated image of your buddies every minute or so so you could see how they were looking today and if they where truly available or away.

I thought it was a nice idea and knowing that most OS X applications can be scripted through AppleScript I figured that it might be possible to implement this for Adium. I soon discovered that you can't take a iSight picture directly from AppleScript, but you can invoke a command called isightcapture that will accomplish this. After poking around in the AdiumXtras AppleScript section I also found some samples of how to change the buddy image. All that was remaining was a few hours of fighting with the weirdness that is AppleScript so I can present this little snippet to you:

    1 display dialog "Do you want to update your buddy picture?"
2 do shell script "/Applications/isightcapture " & POSIX path of file "Macintosh HD:private:tmp:buddyicon.jpg"
3 tell application "Adium"
4 set img to alias "Macintosh HD:private:tmp:buddyicon.jpg"
5 set fileid to open for access img -- opens the image
6 set tifimagedata to read fileid as TIFF picture -- reads the image
7 set default image to tifimagedata -- sets the buddy icon
8 close access fileid
9 end tell


What it actually does: Asks you if you want to update your picture, if you do it will take a snapshot with your iSight camera and set it as your default image in Adium (be sure to select the global buddy icon for all accounts for this to work).

What I haven't figured out yet is how to make this run everytime I start Adium. I have only managed to attach it to in-chat trigger words (like "/snapshot"). Or how to make this take a snapshot a timed interval. If you have any hints, then please leave a comment.

Update: Finally got it working!

Twitter Updates

Johan Lind's shared items