Archive for November, 2009

My First Ruby Script

Wednesday, November 25th, 2009

This last weekend I was finally able to sit down and pound out my first Ruby script. Now I can grab the 790 pics I have in my Gallery installation and thanks to the B-Tree, order them by the upload date.

(There must be a better way to do the regexs in Ruby but I think it’s not too bad for a first stab.)

The next step is to make use of the Flickr API to upload all the pics and set info accordingly.

What to do about tags? In the next iteration, I think I’m going to put a “tags.txt” file in each Gallery album directory in order to ascribe at least a few tags to the photos as they’re being uploaded.

Just for fun, here’s a taste of the Gallery metadata files (photos.dat) that serve as the input for parsing. Good times.

a:17:{i:0;O:9:"AlbumItem":19:{s:5:"image";O:5:"Image":12:{s:4:"name";s:8:"100_0559";s:4:"type";s:3:"jpg";
s:5:"width";i:640;s:6:"height";i:480;s:11:"resizedName";
s:14:"100_0559.sized";s:7:"thumb_x";N;s:7:"thumb_y";N;
s:11:"thumb_width";N;s:12:"thumb_height";N;
s:9:"raw_width";i:1200;s:10:"raw_height";i:900;
s:7:"version";

Beginning With Ruby

Friday, November 20th, 2009

I didn’t really want to pay $333/month to hone my Python chops so I decided to get my hands dirty with some Ruby instead (on a side note, I am currently looking to recruit Front-end Engineers and a Front-end Engineer manager if you know of any…)

I decided to formulate a different task for myself:

TASK: Given a set of albums in a 1.4.4-pl4 version of Gallery, write a script that uploads them to Flickr and sets properties accordingly so that they appear in the correct chronological order.

Background

I’ve been using Gallery for a long time to curate my photos, long before Flickr came on the scene. I’m a big believer in YDYS (Your Data is Yours) and didn’t like uploading my photos to big servers in the ether so I hosted my own photos with Gallery.

Well, time marches on and when you manage your own photo gallery online then you have to manage the software that manages your photo gallery. I have to admit (and you can pretty much tell when it happened by the version number,) my gallery fell into disarray and I didn’t tend to it as much as I should.

Now that I don’t have quite as much time for outside projects as I once did, I thought “it’s time to upgrade to a service like Flickr and let them manage the infrastructure while I take care of capturing and sharing memories.”

DISCLAIMER: I get the Flickr Pro upgrade for free because of where I work. It’s probably necessary to have the Pro account before you attempt the uploads using the techniques that I’m eventually going to use.

I’ll have some time to get started this weekend, but here are some initial steps as to what I think I’ll need to do to parse photo data out of the Gallery files.

=begin
- Create a B-Tree (we'll need it for date-tracking as we process each of the photos)
- Glob a list of photos.dat files recursively
- Foreach photos.dat file...
-       Open file
-       Slurp file (can do in Ruby?)
-       Parse syntax
-       Foreach photo
-               Find uploadDate
-               Do lookup in B-Tree on uploadDate and/then...
-               Stick Album Name and File Name in B-Tree for uploadDate
-       Close file
- Traverse the B-Tree and print out: "Album Name, File Name"
=end

First (Attempt at a) Python Script, Part II (Second Attempt?)

Thursday, November 12th, 2009

Hotjobs got back to me today and it looks like it’s going to cost $333/month for being able to search resumes. Maybe I need to imagine a different basic scenario for an initial Python script.

First (Attempt at a) Python Script

Wednesday, November 11th, 2009

In a way, I have HotJobs to thank for getting into Yahoo. It’s on HotJobs where I first saw the job that eventually became mine (I actually found a couple of jobs there that I applied and interviewed for…) Anyway, I’ve been wanting to try something against the HotJobs API for a while now so I sat about doing so in Python.

TASK: Create a simple script that takes two arguments, a job title and a zip code, and then query HotJobs for resumes containing that job title near the zip code. After retrieving the resumes, output a list of job titles representing the *next* jobs people held after holding the job title passed in the query.

Unfortunately, the Web services license key registration process is not instantaneous, so shortly after I got these steps in place…

  1. Hello world in Python. Check.
  2. POST Web service calls in Python. Hey! Check!

… I started getting IOError: ('http error', 401, 'Authorization Required', ) so I realized I probably needed to put in for a Web services license key. Looks like they’ll be getting back to me.

Notes (so-far) on Python:

  • semi-colons: I thought everyone liked them…
  • here-docs with triple apostrophe? clever.

And for My Next Trick…

Wednesday, November 11th, 2009

When I arrived in the bay area about three years ago, I felt like somewhat of a pariah given that I had been most recently working with Microsoft technologies and was trying to get a job amongst LAMP developers in the most competitive place in the world to do so. I fell back on my previous Perl experience and found a sweet gig at Yahoo in what essentially is the dev tools part of the organization.

A few years later, now that I’ve been able to come up for some air and take a look around, I’ve noticed that the world has gone the way of RoR and Python. I was telling a friend recently, “it sure is hard to find web dev positions for Perl developers” and he responded (because he’s looking to fill some reqs,) “it sure is hard to find Perl developers for our web dev positions.”

So, which of RoR and Python to learn first? I’m a big believer in learning by doing, so now I just need to sit down and develop a service in one of the two. Python, bring it on.