taylorbarstow.com

Ruby: HTTPClient is Sloooooow

Is this just me? I think it must be—I am getting terrible performance using HTTPClient vs Net::HTTP. I was looking for an alternative to Net::HTTP because its API is ugly as hell, but the performance difference leaves me with no choice.

Let’s take the example of loading this blog’s last four entries using the Google AJAX Feed API. Net::HTTP consistently takes less than a second to load the results, while HTTPClient consistently takes between 10 and 15 seconds! This can’t be right, I must be doing something wrong…

Here’s the script I’m using to test:

require 'httpclient'
require 'net/http'
require 'uri'
require 'cgi'

def time(label)
  t_start = Time.now.to_f
  yield if block_given?
  puts "#{label}: #{Time.now.to_f - t_start}s"
end

feed_url = "http://taylorbarstow.com/feed/"
url = "http://www.google.com/uds/Gfeeds?v=1.0&output=json&q=#{CGI.escape(feed_url)}"

time "Net::HTTP" do
  Net::HTTP.get(URI.parse(url))
end

time "HTTPClient" do
  HTTPClient.new.get_content(url)
end

A Three Hour Tour

Lesson learned: pay your stupid parking tickets when you get them.  I spent Tuesday morning on a tour of Boston-area parking clerks paying off tickets so I could renew my registration. Well, at least I got some exercise.

Sliding Doors of CSS (Redux)

A while back, Douglas Bowman wrote an awesome pair of articles for A List Apart called “Sliding Doors of CSS”. The articles described a CSS technique for making a tabbed interface where the tabs scale gracefully as the user changes his or her font size.

Bowman’s sliding doors provided elasticity based on the size of a container’s content. But it’s also desirable to achieve elasticity based on a container’s external constraints. This paradigm is particularly applicable to data sets, where we want one column to expand or contract dynamically to fill the available space.

(more…)

Surprised and Excited

I wanted to watch Michelle Obama’s speech last night because I was curious to see how she decided to portray herself, her husband, and her family. Obama is, relatively speaking, unknown to many of our nation’s voters. Further, his background falls far outside the American norm. All this has given significant fuel to the Republicans, who have painted Obama as nothing more than a sweet talking celebrity out of touch with core American values.

So I expected Michelle Obama to communicate her family’s values on her terms. But I was surprised and delighted to find something I didn’t expect: as a speaker, Michelle Obama rivals her husband! Her passion, her thoughtfulness, and her candor all shone brightly last night. She delivered the kind of speech rarely seen from most mainstream politicians these days—let alone from politicians’ partners. (Indeed, I would argue that we won’t see anything as inspirational from the Republicans during their convention.)

Let’s hope that, as Michelle put it (I’m paraphrasing here), we can come together as a country and listen to our hopes this time around, rather than our fears! If we can make this happen, then maybe, finally, we can get out from under the thumb of corporate America and set our own agenda for once. A big thank you to Michelle Obama—your speech thrilled and inspired me.

Getting Ready!

Powder Magazine Cover, September 2008

The ski magazines arrived the other day. I have been thinking about skiing almost every day for weeks now. You might be able to tell that I am super excited!

But before I can ski, I need to get my legs in shape. Which leads me to hiking! Fall is hiking season. The days are crisp and not too hot, the leaves are beautiful, and there aren’t many bugs. I didn’t get out that much last fall, though I did get to Katahdin, which was a blast.

So this fall, I’m committed to hiking four or five times. To help me follow through, I’m trying to start a little hiking “club” with some friends. I figure not everyone will be as into as me, but hopefully I will find a cohort or two for each hike. We’ll see how it goes!

Katahdin in 2007
Katahdin in 2007