This version adds two main features:

  • avoids barfing if the array size is zero when appending to the query string
  • sends the web service 25 queries at a time instead of one
  • speed: it’ll do about 3000 resolutions per minute now

[ruby]require ‘rubygems’ require ‘hpricot’ require ‘open-uri’ ips = [] file =‘/Users/daniel/Development/newfile’, ‘w’)‘/Users/daniel/Development/ips3′).each { |line| ips.push line } while !ips.empty? do query = "" 25.times do if !ips.empty? query += ips.pop.chomp + "," end end query.chop! doc = Hpricot(open("{query}")) (doc/’location’).each do |el| ip = (el/’ip’).inner_html country = (el/’countryname’).inner_html state = (el/’regionname’).inner_html city = (el/’city’).inner_html puts "#{ip},#{country},#{state},#{city}" file.puts "#{ip},#{country},#{state},#{city}" file.flush() end end[/ruby]

[ Sorry for the mangled code; let me know if you want the clean version. ]

Next I’m going to try and pull the databases local and use hash tables like a co-worker did in .NET. He got the whole thing down to 8 seconds, regardless of how many items he had to query.

That’s the advantage of being local, but I think there’s also value in being more portable with the web call–especially when I can do a massive set of data in just a few minutes.

Anyway, I’m going to try the local version just for the fun of it. ::

When this talk comes from a Twitter developer, who loves both Ruby and Rails and happen to be running probably the most punished RoR site on the Internet right now, I’m inclined to believe. (they’re taking over 11,000 requests per second during peak times). Here are a few quotes from the interview:

Once you hit a certain threshold of traffic, either you need to strip out all the costly neat stuff that Rails does for you (RJS, ActiveRecord, ActiveSupport, etc.) or move the slow parts of your application out of Rails, or both.
It’s also worth mentioning that there shouldn’t be doubt in anybody’s mind at this point that Ruby itself is slow. It’s great that people are hard at work on faster implementations of the language, but right now, it’s tough.

[ Link: Interview With Twitter Dev ]

Does this discourage me from Ruby or Rails? Hell no. To me the elegance of the language completely dominates its flaws, especially when you realize that there exists a small legion of very smart people who are obsessed with fixing these problems.

No, I’ll be sticking with Ruby and Rails. I’ll wait for the performance and scale issues to be fixed in subsequent releases. The language/framework is too beautiful to shun.

…yeah, that’s all I had for you.

(cough) Ruby (cough)

Roo-bee. Rhubie.

Ok, I’m done.


My buddy Jason just posted a good like guide to getting started with RoR development, including using Subversion.

You should also check out his Ruby section.

[ Link: How I Develop Ruby on Rails Applications ]

I recently started a major programming project using RoR and had to make the requisite decisions involving programming environments.

I elected to go with Textmate, as it was strongly recommended by two of the best RoR programmers in the world. But upon opening the application I realized that, unlike BBEdit which I normally use, Textmate doesn’t have the ability to open remote files via FTP or SSH.


Luckily there’s a workaround: if you install MacFuse and SSHfs, you can mount your remote Rails filestructure as a drive on your local system. Now I simply code using Textmate as if everything was local and Textmate doesn’t know the difference.

Browse –> Open –> Code –> Save –> Enjoy.:

Why I Love Ruby

March 19th, 2007 | Beauty | Ruby

If you’re looking for a comprehensive comparison of 15 programming languages based on decades of experience, this isn’t it. I’m a hobbiest programmer. Most of my “programs” are either in bash or Python, fit on one page, and are based firmly in laziness. But I do know beauty when I see it, and Ruby is beautiful.

In this post I’m going to show you, using just a points from the beginning of a Ruby book, why I love this language more than any other. I write this post because I’m always given “the look” by people when I tell them I’m learning Ruby. Most either think it’s:

  1. not a “real” programming language (those are the C and Java people)
  2. a lame replacement for Perl (Perl people)
  3. a slightly different Python (people who don’t know either Python or Ruby)

This post is designed to counter that look.


To me, programming should be intuitive before anything else. You should be able to think about problems, start writing, and realize that you’ve solved some. Ruby isn’t there yet, but it’s the closest thing I’ve found. Check out this syntax:

That’s it. Prints out how big the string is. No biggie, but notice you don’t need any parenthesis. Very cool.
Find that letter in the string, and print how many there are.
Utterly sick. Whatever the length of your string was, plus 1. Oh, and strings are completely mutable in Ruby. You can do useful things like this:
…which returns your string, but in all upercase. And here’s the cool bit: if you look at your string again it’s still lowercase. But if you want to permanently change it you can too:
That’s it. Just add the exclamation point and you’ve permanently changed the string in place. Wicked. Ok, now check out these boolean checks:
This returns a true or false, based on whether or not the string is empty or not. Insane. Here’s another:
Returns a true or false based on whether or not your string “includes” the string ‘test’. But you already knew that, and that’s the point. It’s SO DAMN easy to read and write. Check this out:
What do you think that does? It does whatever you tell it do — three times. W00t. I’m in love with this language.:

Getting Into Ruby

September 23rd, 2006 | Python | Ruby | Sysadmin

I feel like I’m the last person in the world to do this. Up until now I’ve pretty much chosen Python as my “Perlesque” language of choice, and I never had much of a will to dabble in what seemed to be nothing more than a slightly better Python.

But I changed my mind.

After spending some time at this live demo site, I decided I’m going to do my next little coding project in Ruby. I’m going to get the O’Reilly book on the language, actually, and learn it the right way. I might even consider coding my mst tool in this instead of Python. All depends on how Ruby interracts with OS commands, really.

I’m excited, yet I feel a bit like I’ve cheated on Python. We’ll see how it goes…