Things wish I knew yesterday…

or sometime over the last 12 months, in no particular order

  • I’m one of those folks that has lucid dreams while taking malaria meds.  The dreams are cool, though I could leave behind all the waking up in the middle of the night.
  • My TV has audio optical out, but won’t pass Dolby 5.1 through from the HDMI cable.  Never trust the satelite installers.
  • Football is really awesome in actual Dolby 5.1 (or 4.1 in my case), though it takes some getting used to random people’s voices popping up from time to time behind you.
  • irb (the interactive ruby intepretter) does tab complete, but only if you enable it manually.  You get tab complete in the rails console, so I was always just using that.
  • irb does coloring of code!  That definitely one ups the python interactive shell.
  • Wood stove inserts for fireplaces are really painless installs and manage to throw an incredible amount of heat.
  • Amazon S3 really is that easy, and quite cheap to be used for offsite backup.
  • An automated backup solution for all your home systems is a single apt-get away.
  • xkcd really is that awesome.

Thoughts on Amazon’s S3

I finally got around to using my Amazon Web Services account this weekend and push the entirety of my digital photos into S3 (it’s in progress right now, doing a nice job of exercising my fios connetion). I thank Sean O’Conner for pushing me over the edge here, as he brought his use of S3 up at dinner after the last MHVLUG meeting.

As I’ve been working on wedding photo book, I started to realize it would be good if these photos existed somewhere besides my raid server at home, in the event of catastrophe (man made or otherwise). Wedding photos can’t be replaced. At the current bill rates, it will cost me $1.50 to upload my 15 GB of photos, and $2.25 / month to keep them hanging out in S3. For less than $30 a year to eliminate a single point of failure, I’m all for it.

Amazon did something incredible with S3.  They decided that they weren’t providing an end service, but a component to build end services.  As such, they created an incredibly simple programming interface (via a REST web service), seeded the community with sample code in a slew of languages, and said “have at!”.  The results are somewhat impressive.  There is a firefox plugin which provides a reasonable browsing front end so you can understand what your bucket / bin structure looks like.  What sold me over is s3sync, which looks and acts like rsync, but has S3 as either the target or source.  A single command, and all my content is being pushed into S3.

S3 also has a rich access list and meta-data interface, which has me pondering a photo album creation application using S3 on the back end.  That will wait until the new year at least, but the possibilities seem interesting to me.  The fact that there is a bittorent creation interface for S3 is also quite interesting, and would make for very reasonable distribution of things like ISO images.

While there are other applications more specialized for photo sharing, like Flickr, the general purpose nature of Hardware as a Service that Amazon provides intrigues me. The programmatic interface on it is also something that I’d like to get a bit of experience with, as I think this model for service delivery is going to become far more prevalent over the next few years.  S3 is a pretty easy start point for that, though I’m still thinking of interesting projects for EC2 and the Mechanical Turk as well.

Failure to avoid Facebook

I was really hoping to avoid the whole facebook thing, but today someone that I haven’t seen or heard from in 7 or 8 years found me on facebook… and I gave up resisting. The value of these networks for me is giving me a handle to go catch up with people (mostly from high school), that I’ve lost touch with in the intervening decade and a half.

Off to make sure my facebook profile is even vaguely accurate from the account I made a while ago.

More fun with dbus

Since my dbus post last week, I’ve been playing around more with dbus whenever I get a few minutes. The modern Linux desktop is pretty good, but with minor tweaks, you can make things even better. (all this code is now up in a mercurial repository called dbus-hackery).

Automating Inactivity

Pidgin makes sounds on every message to me, xchat makes sounds on certain key words. Without these cues, I’d never remember to go check these applications. Because I have a tendency to leave my laptop on overnight, I found that I’d often have xchat ringing away at midnight when someone was looking for me. If I forgot to mute my machine before that, it would often wake me up.

One of the programs sending signals on dbus is gnome-screensaver.

def connect_screensaver(session_bus)
    ss_dbus = session_bus.service("org.gnome.ScreenSaver")
    ss = ss_dbus.object("/org/gnome/ScreenSaver")
    if ss.has_iface? "org.gnome.ScreenSaver"
        ss.default_iface = "org.gnome.ScreenSaver"
        puts "Connected to screensaver"
    return ss

def mute()
    IO.popen("aumix -vq") {|r| {|m|
            @@vol = m
            puts "saved volume: #{@@vol}"
    puts "muting"
    system("aumix -v 0")

def unmute()
    puts "unmuting"
    system("aumix -v #{@@vol}")

ss = connect_screensaver(session_bus)

ss.on_signal("ActiveChanged") {|s|
    if s

The connect will look exactly as expected from the previous look at dbus. The ActiveChanged signal outputs a single parameter, a boolean, which is true when the screensave goes active, false when the screensaver is deactivated.

Volume control on the command line is most easily done with aumix (though if you are on Ubuntu Gutsy you’ll have issues until you rebuild aumix yourself. Hopefully they’ll fix that bug soon.) A little regex fun captures the current levels to a package variable, and restores them back on unmute.

Now I’ve got global mute when the screensaver fires, restored when I return.

Better Away with Pidgin

My screensaver being locked is a pretty clear indication that I’m away, though it being unlocked isn’t a clear indication that I’m back. Especially on weekends, I pop back for a quick check of something, then the computer is put away again.

def set_away(pidgin)
    puts "trying to set away"
    name = "screensaver"
    status = pidgin.PurpleSavedstatusFind(name)[0]
    if not status > 0
        status = pidgin.PurpleSavedstatusNew(name, 5)[0]
    puts "Status #{status}"

    pidgin.PurpleSavedstatusSetMessage(status, "screen saver auto away")

ss.on_signal("ActiveChanged") {|s|
    if s

In order to set a status with a message, it has to be a saved status. To prevent growing that to infinity, I first look to see if it is defined, creating a new saved status if not. 5 is a magic number here meaning STATUS_AWAY (reference the pidgin status.h for more info). Then we set the message on that status, and activate it. A single line change on our screen saver signal adds this into play.

Keep on Hacking

One of the things I’m hoping to impress in these posts on dbus is that with a highly functional language like ruby, linking applications on a modern gnome desktop can be done even by mere mortals. Linking sound to your screen saver is something that would have required a reasonable chunk of c code. Now you can do it in 20 lines of ruby, thanks to dbus.

I’ve thought about creating some sort of extended control panel to enable the features I’ve hacked together, but the reality is the code is so small, and so simple, it seems like overkill. With code this easy, you should just jump in and hack it to your own needs.

As I keep playing with dbus, I’ll post more bits here. Twitter integration is still on my list of things to do, and maybe something I’ll even manage to get to this week.