Startup School!

Wednesday, April 2nd, 2008

I'm a little late in posting this, but I found out last Friday that my application to Startup School was accepted.  The entire slate of speakers is phenomenal (some of them are Web legends), but I think I'm the most excited about DHH.  I've been using Ruby on Rails for ...

Geolocate visitors to your Rails App

Monday, March 24th, 2008

In modern web apps, knowing the location of your customer can be very important. A friend and I are developing a location-based service right now. I whipped up the following Ruby code that uses the hostip.info API to fetch a user's location based on his IP address. require 'net/http' def ...

Lat, lng points to GMmaps polyline in Ruby

Monday, February 11th, 2008

def encode(num)   str = ""   num = (num * 1e5).floor   num <<= 1   num = ~num if num < 0   while num >= 0x20     str += (((num & 0x1f) | 0x20) + 63).chr     num >>= 5   end   str += (num+63).chr   return str end def to_encoded_polyline(points)   polyline = ""   points.each do |point|     polyline += encode(point[:lat])     polyline += encode(point[:lng])   end   return polyline end