[ View menu ]

July 24, 2008

Updates to Rhino (Ruby HBase ORM)

Filed in Uncategorized , Ruby , HBase

I’ve made some updates to Rhino, a Ruby HBase ORM that I started working on 6 months ago (introduction post). Specifically, I’m now working on:

  • Rails integration
  • Has_many support (a table has_many :links, where links is a column family in the table, not a separate table)
  • Dropping the REST API for a faster way of connecting

Comments and patches are appreciated. The Rhino Github repository is at git://github.com/sqs/rhino.git.

June 5, 2008

Using SPOT GPS data to estimate CO2 emissions and Calories burned

Filed in Uncategorized

KML file: http://qslack.com/up/stats252/map.kml (View in Google Maps)
Ruby code: http://qslack.com/up/stats252/spotco2.rb

The Ruby code requires the PROJ geographical library and the Hpricot  gem.

January 4, 2008

FlyerStats.com: Map your flight paths

Filed in Uncategorized

A couple of weeks ago, I put FlyerStats.com online. It lets you enter a flight path, like ORD-SFO-PEK-ORD (Chicago O’Hare to Beijing via San Francisco and back), and see the approximate path you’ll fly. It also calculates total and per-flight mileage.

Sample FlyerStats flight path map

Some examples:

DC to Hawaii, Canada, and S. America: DCA-ORD-SFO-OGG-LAX-YYZ-SCL-AEP-MIA-MEX-IAD

Chicago to Singapore, Taipei, etc.: ORD-LAX-SIN-BKK-TPE-ICN-KIX-SFO-ORD

Istanbul to Hong Kong, Tokyo, London, Frankfurt, then home (crazy!): IST-HKG-NRT-LHR-FRA-IST

So, check out all the itineraries and then sign up to start mapping your own flights!

Introducing Rhino, a Ruby ORM for Hbase

Filed in Ruby , HBase

Until recently, HBase, the Bigtable-like distributed storage system from Apache Hadoop, had no Ruby API. That changed when Bryan Duxbury released ruby-hbase, an interface to the REST API he wrote for HVase. But there’s no Ruby ORM for Hbase yet.

So, in the last 24 hours, I threw together the beginnings of a Ruby + HBase ORM. It’s called Rhino. Right now, it can do CRUD. The code for interacting with Hbase is taken from Bryan’s ruby-hbase; I’ve just done the ORM part.

Get it

The Rhino code is hosted at Github. Check :

git clone git://github.com/sqs/rhino.git

Check README, spec/spec_helper.rb and spec/rhino_spec.rb for usage examples.

January 2, 2008

Merb resource_controller code gives BadRequest errors

Filed in Merb , Datamapper

Using Datamapper and Merb’s default resource_controller generator to generate a controller results in code that’ll give errors where it shouldn’t. Here’s the code that it’ll generate for your update action:

def update(id, company)
  @company = Company[id]
  raise NotFound unless @company
  if @company.update_attributes(company)
    redirect url(:company, @company)
  else
    raise BadRequest
  end
end

The problem arises when the user doesn’t make any changes on the edit form and then clicks the submit button. In that case, nothing actually needs to be written to the database, so @company.save returns false. But in the resource_controller code, that results in a BadRequest exception.

The fix here is to check the trueness of @company.valid? instead of @company.update_attributes(...). Here’s how the most basic update action should look.


def update(id, company)
  @company = Company[id]
  raise NotFound unless @company
  @company.update_attributes(company)
  if @company.valid?
    redirect url(:company, @company)
  else
    raise BadRequest
  end
end

January 1, 2008

Merb, Datamapper, Haml, and Sass

Filed in Ruby

I’ve just started to play around with Merb, Datamapper, Haml, and Sass…and I am loving it. I can guarantee you that we’ll be hearing lots more about these in the future.

December 14, 2007

Part 1: Preparing for my trip

Filed in Asia Trip 2007

My trip to Asia begins on Monday, December 17. I’ll fly to LA and spend the day touring with friends who live there. I grew up in a household where the hate for LA was strong. My friends have approximately 9 hours to change my mind (and I am sure it will be changed!), because I fly to Singapore at 8 pm that night.

Here’s how my whole trip looks. Singapore, Bangkok, Taipei, Seoul, and Osaka. 5 countries, 8 flights, 8 airports, 21,000 miles, 5 airlines, and 4 foreign languages in 7 days. Of those 7 days, or 168 hours, my total time sitting in an airplane will be 46 hours (27%).

Yeah, it’s a little bit crazy. But the airfare only cost me $42 total, since it’s a frequent flyer mile trip. Sure, I could have picked one or two places and stayed longer. But then I’d have to pay for hotels, and I wouldn’t get to see so many places. Also, I like flying a lot, and this is in business class, so it won’t be too bad.

December
17th Los Angeles; catch my flight to Singapore at 8 pm
18th Somewhere over the Pacific
19th Singapore (arrive 6 am)
20th Depart Singapore at 11 am; Bangkok (arrive at noon)
21st Depart Bangkok at 7 am; Taipei (arrive at noon)
22nd Depart Taipei at 3 pm; Seoul (arrive 6 pm)
23rd Depart Seoul at 1 pm; Osaka (arrive 2pm, depart 7 pm); connect in San Francisco; arrive in Chicago at 8 pm

I’ve made a detailed itinerary for my trip and posted it online if you’re curious: Asia Winter 2007 Trip Plan.

I’ll be updating regularly while I’m traveling, so check back!

Here is my flight path:

AW07 Asia flight path

AW07 N America flight path

December 8, 2007

My Chinese-English dictionary is online now

Filed in Uncategorized

I’ve put my Chinese-English dictionary online. It’s at http://zhdict.com. I didn’t write the definitions; I only created the interface.

September 9, 2007

December trip to Singapore, Bangkok, Taipei, Seoul, and Osaka

Filed in Uncategorized

From December 16 to 23, I’ll be traveling around Asia. I’ve got two nights in Singapore and one night everywhere else except Osaka (where I have 6 hours). It’ll be a pretty fast-paced trip, but it should be fun. Check back for a trip report.

September 1, 2007

My flight paths

Filed in Uncategorized

I’m working on a cool little program that can show you where you’ve flown and give you interesting stats on all your flights. I’ll post more about it later, but here are some cool Google Earth maps for now.

US flight pathEx-Chicago flightsTrans-Pacific flightsAsia flight path

Here’s the Google Earth KML file if you want to look at it yourself. Just download the file then open it using Google Earth.