Ruby code to quickly convert titles to ISBNs

I love the Toronto Public Library system. I can't say that enough. I particularly love how I can go on a reading spree, place holds on a gazillion books, and have them delivered to the library branch that's about three blocks away from the house.

Ideally, of course, these books would arrive suitably spaced apart so that a new batch arrives just as I've finished another. This happens when I request popular books. Most of the time, though, the books that I want to read fall in the Long Tail–obscure titles, books that have fallen off the New York Times bestseller lists, and the occasional random find.

All of these books tend to descend on the unsuspecting library branch at the same time.

There were 27 books waiting for me earlier. The librarian thanked me for clearing the shelf. J- greatly enjoyed piling them into the shopping cart we had the foresight to bring. Yes, I've got presentations to prepare and things to do–but reading is fun, and I'm somehow going to find time to read all those books before my three-week loan period is up. I'll probably be able to renew them, but hey, might as well try.

So I decided I might as well try tracking them on LibraryThing. Instead of typing in all the details manually, I grabbed the list of titles from my account on LibraryElf (good reminder system for books), used ISBNdb to convert the titles into ISBNs (best guess), and imported the list of ISBNs into LibraryThing. Now my profile lists 163 books–a small fraction of the books that have passed through my hands, but it's better than nothing. Someday I might even get myself a barcode scanner so that I can just pick up the ISBNs from the book jackets.

Anyway, I promised the Ruby code I'd quickly written to convert the titles to ISBNs:

require 'net/http'
require 'CGI'
require 'open-uri'
require 'rexml/document' 

access_key = 'YOURACCESSKEYHERE'
while (s = gets)
  s.chomp!
  url = "http://isbndb.com/api/books.xml?access_key=" + access_key + "&index1=title&value1=" + CGI::escape(s)
  xml = REXML::Document.new(open(url).read)
  if (xml.elements["ISBNdb/BookList/BookData"])
    puts xml.elements["ISBNdb/BookList/BookData"].attributes["isbn"]
  end
end

Takes titles as standard input, prints out ISBNs. Enjoy!

Ruby

Somewhere along the way, I seem to have turned into a Ruby geek. I spent the day converting most of my data analysis code to Ruby because the interactivity of the Ruby shell makes prototyping so much fun. Now if it were more like Lisp, I would be even happier. I suppose I _could_ freak everyone out and start using Lisp - maybe Common Lisp? - within IBM, but... =)

I still haven't quite figured out how to use Eclipse to debug Ruby programs. I keep getting "abnormal program termination" errors. Ah, well, that just forces me to write programs with no bugs. ;)

On Technorati:

Random Japanese sentence: テーブルに猫の足跡が付いている。 There are footprints of a cat on the table.

Finding geeks

I don't know why people complain about not being able to find talent. ;) I run across so many interesting people while watching mailing lists or hanging out with other geeks. For example, if you're looking for Ruby geeks in the Philippines, Botp Peña sounds really interesting. Hey, anyone who advocates Rails and volunteers training has to be cool. ;)

if you're interested to learn ruby, i can provide training session for free. just provide the place and at least 10 people to join. dili nako kaya tudlo isa-isa. ma-luoy mo. dapat naa whiteboard (kung wala projector), mga desk/silya, printer para sa handouts/exercises, and notebooks or desktops na ma-gamit ninyo ug nako (wala koy notebook, sorry). Also, dapat naa mo programming background (any language will do. di nako gusto lurat inyo mata. dapat naka-smile pirmi). i prefer to hold trainings monthly/semi-monthly lang kay para dili kaayo ko hago. one training session will cover the whole day (puwede sab ma-hangyo half-day)
  • Peña, Botp (botp AT delmonte-phil.com)

E-Mail from Peña

On Technorati: , ,

Random Japanese sentence: 私はあの店で猫を買った。 I bought a cat at that shop.

Ruby versus Java

This is totally cool. I'm in the middle of a geek crowd discussing Java vs Ruby, but there's none of that "my language is better than yours" vibe that often comes out in Linux distribution discussions. I think what's cool about it is that most people here use both, so we're just figuring out where one is better than the other for something, and how we can improve things...

On Technorati: , ,

Random Japanese sentence: 彼は2匹猫を飼っている。一匹は黒でもう一匹は白だ。 He keeps two cats: one is black, and the other white.

Full day!

I woke up early to check if anyone I knew was online, and I had a nice chat with Marcelle. I fell asleep waiting for Dominique to come back online, though, and I had such a vivid dream that I didn't wake up until an hour or so later - by which time even my mom was starting to feel like she was talking to cyberspace... =)

Anyway, it was such a nice chat that I didn't mind being late to the clothing show held at Exhibition Place. Quinn and I eventually made it there at around 12, and we browsed for an hour or so. I bought a bracelet and two necklaces, all made of shell. I thought they might go nicely with my ethnic stuff. I didn't really find anything else that particularly struck my fancy, as tiered skirts are getting a _little_ too popular for my tastes. I might shift back to nicely colored skirts, and of course I like wearing stuff from home. I wore the red malong as a skirt today, matching it with a colorful abaniko fan. (Thanks, Mom!)

That's why I was late to the Ruby meeting. =) That was cool, too! As soon as he saw me, Austin said, "You know Steve Perelgut!" (He's one of my mentors from IBM, and a totally totally cool person. The fact that he reads me blog (Hi Stephen!) has nothing to do with the gushiness of the previous statement. =) ) Austin shared what he'd learned from the Ruby code jam (lesson 1: be better prepared!), particularly the effectiveness and _fun_ of pair programming. It worked out really well because Ruby novices were paired up with Ruby veterans, but the Ruby novices were also good at other aspects that the Ruby geeks might not have learned about. In this case, they were porting an archiving library to Ruby. =) Good stuff.

We also had a fun chat about how people can learn to read and write code. Apparently, I _am_ really weird in that I rather enjoy reading code... =)

Jed and Quinn were there too, although they dropped in and out of the conversation, as I fangirled a bit about Ruby and got some interesting tips. Should check out the Water framework for testing web applications, although that might need Windows. Also, Austin suggested SVG + PDF for my graph outputs. Whee!

Jed mentioned a samba jam at an art gallery on Queen Street West. In keeping with my plan to get to know a wide variety of people and experience more than what I'd ordinarily get just hanging out with computer geeks and talking about computers, I decided to go. It was tons and tons of fun! I told them I had no sense of rhythm and that I'd be perfectly happy just listening and taking pictures, but Jed wouldn't take no for an answer. Heck, he didn't even ask if I wanted to join. Instead, he held up two instruments and asked which one I'd like to play. <laugh> I opted for a small drum, and I found myself picking up the rhythm thanks to the coaching of people around me.

A photographer wandered in, too, so I adopted her. Marie had just joined a camera club and was thrilled to stumble across such a cool event. I gave her the tips my dad shared with me about using long exposures and lower ISO speeds to capture dramatic action, and she had a lot of fun exploring that, too. =)

I made it back for coffee time at Graduate House. I had so much fun catching up with Sam. She wants to do really cool things with accessibility, and she's in a terrific position to do so! I'm also really excited about her application to be an RA for the dorm. I think she'd be a terrific one. I told her about what's cool in my life: the Delta Kappa Gamma fellowship, my research up at IBM, the thrill of introducing people to other people... She nodded and told me how much she enjoyed that too. When I learned that she hadn't yet read Tipping Point, I ran upstairs to grab my copy. I lent it to her, pointing out the section on Connectors and adding a note about context. I'm also going to have to get myself a hardcover (if I can find it!) of Love is the Killer App, which is another thing that she will _so_ be able to identify with. (Thank you, Maoi, for introducing me to that book!)

Afterwards, I had a wonderfully geeky chat about computer science and assorted things with Mike and Joe. In particular, Joe's overlapping clustering algorithms _might_ be fun to run against tag clouds, social networks, and other cool things. I need to show Mark a sample and see how we can ask for suitably anonymized data...

Happy girl. Full day. Great fun. =) Lots of interesting people!

On Technorati: , , ,

Random Japanese sentence: ペルシャ猫に関連した古いお話があります。 There is a classic story related about a Persian cat.