Automatic FireEagle updates via iPhone Google Maps 'Locate Me'

The following instructions will setup your Jailbroken iPhone to update your FireEagle location every 5 minutes. While Navizon provides this same feature, I’ve been less than impressed with it’s accuracy . This method uses both Skyhook and the Google Maps ‘Locate Me’ cell-tower-triangulation method, which are much more accurate than Navizon in my recent tests.

Prerequisites

  • Jailbroken 1.1.x iPhone
  • OpenSSH installed on iPhone
  • A computer on the same subnet as your iPhone
  • FireEagle invite
    • If you don’t have one, ask @firebot nicely.

Step 1: Disable Sleep

  • Settings -> General -> Set Auto-Lock to ‘Never’
    • This is to ensure the SSH connection we’ll establish in Step 3 isn’t terminate. You may revert this setting after following these instructions.

Step 2: Determine your iPhone’s IP Address

  • Settings -> Wi-Fi
    • Tap the blue arrow to the right of the wireless network with the check by it

Step 3: SSH into your iPhone

Open Terminal (/Applications/Utilities/Terminal.app) and run the following:

ssh root@YOUR_IPHONE_IP

Your password is ‘alpine’ unless you’ve changed it

Step 4: Download needed files

mkdir -p bin/fireeagle
cd bin/fireeagle
curl -O http://ericasadun.com/ftp/TUAW/findme/authcheck
curl -O http://ericasadun.com/ftp/TUAW/findme/authtoken
curl -O http://ericasadun.com/ftp/TUAW/findme/firefindme
curl -O http://ericasadun.com/ftp/TUAW/findme/pingwifi

Step 5: Create wrapper script

cat > /var/root/bin/fireeagle/firewrapper << EOF
date > /var/log/fire.log
/var/root/bin/fireeagle/pingwifi
/bin/sleep 7 
/var/root/bin/fireeagle/firefindme -g -d -F >> /var/log/fire.log
/var/root/bin/fireeagle/firefindme -k -d -F >> /var/log/fire.log
exit 0
EOF

Step 6: Set executable bit on all files

chmod a+x /var/root/bin/fireeagle/*

Step 7: Authenticate with FireEagle

/var/root/bin/fireeagle/authtoken

This will open a MobileSafari window. Login to your FireEagle account and allow TrackMe to update your location. Then run:

/var/root/bin/fireeagle/authcheck

Step 8: Test!

/var/root/bin/fireeagle/firewrapper

After several seconds, you should be returned to a shell prompt. Now visit FireEagle’s My Location page and login. You should see:

Fire Eagle last spotted you less than a minute ago at LOCATION using TrackMe.

If not, please start over at Step 4. Something’s gone wrong.

Step 9: Steup LaunchDaemon to ping FireEagle every 5 minutes

cat > /Library/LaunchDaemons/com.fireeagle.ping.plist << EOF
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>com.fireeagle.ping</string>
    <key>ProgramArguments</key>
    <array>
      <string>/var/root/bin/fireeagle/firewrapper</string>
    </array>
    <key>RunAtLoad</key>
    <false/>
    <key>StartInterval</key>
    <integer>300</integer>
  </dict>
</plist>
EOF
launchctl load /Library/LaunchDaemons/com.fireeagle.ping.plist

You’re Finished!

That should do it! Please let me know via twitter (@jnewland) or in the comments if you have any problems / suggestions! Big thanks to Erica Sadun for writing the iPhone tools used to make this happen!

Fire Eagle: Location-Aware Applications Without the Hassle

Tom Coates said it best yesterday morning at ETech: people have been touting ‘location-aware services’ as the next big thing for years. However, they’ve never taken off.

What’s been holding them back: acquiring reliable location data about users is a hard problem for developers to solve.

With yesterday’s release of Fire Eagle, that problem is now a whole lot easier to solve.

Ride the Fire Eagle Danger Day!

So what is Fire Eagle? It’s not Twitter for location, that’s for damn sure. Here’s how the Yahoo! copywriting wizards describe it:

The secure and stylish way to share your location with sites and services online while giving you unprecedented control over your data and privacy. We’re here to make the whole web respond to your location and help you to discover more about the world around you.

At the diagram to the left shows, the Fire Eagle platform acts as an broker for your location data. One or many applications can set your location, and, provided you give them access, any other service can access this data.

This is one giant piece in the puzzle for location-based services. Users set their location in one place, and any number of other services are able to then act on this data however they please.

The other piece in the puzzle: a Fire Eagle updater that requires absolutely NO user interaction. If I’m carrying around my iPhone in my pocket all day, why can’t it tell Fire Eagle where I am?

Of course, Erica Sadun has already whipped up an unofficial iPhone app to ping Fire Eagle called firefindme. Installation isn’t the easiest thing in the world – it assumes some launchd skillz to setup automatic updates. However, I’m sure a user friendly iPhone updater is coming very shortly ;).

Developing Location-Aware Applications, Sites and Services with Fire Eagle

I’ve got a full-on tutorial coming detailing how to make your Rails app talk to Fire Eagle, but in the meantime, check out my Fire Eagle Ruby Gem:

sudo gem install fireeagle

If Ruby’s not your bag, don’t worry – there are libraries for working with Fire Eagle in javascript, php, perl and python.

Proof-of-Concept Twitter Bot

Just like last time, I’ve created a proof-of-concept twitter bot for testing out Fire Eagle: firebot.

First off: you need an invite to talk to Fire Eagle right now. Luckily, firebot is handing out a few. follow firebot on Twitter, and then direct message it with ‘invite’

  • d firebot invite

Once you have an invite, direct message firebot with ‘auth’:

  • d firebot auth

firebot will then reply with a link. You’ll need to visit that link, authenticate with your Yahoo! account, and then authorize firebot with Fire Eagle.

Once that’s done, you can update your location with a direct message to firebot like so:

  • d firebot u Atlanta, GA
  • d firebot u Belize
  • d firebot u 30022
  • d firebot u 123 Anytown USA
  • etc

To look up the location of someone else using firebot:

  • d firebot q jnewland
  • d firebot q cjmartin
  • d firebot q plasticbagUK

Disclaimer

By telling firebot your location, you agree to share your location information with all other users of firebot. All direct messages you send to firebot are stored permanently at Twitter. If at any point you’d like all of your information deleted from firebot, please contact @jnewland.

What’s next?

Get hackin’ on your awesome location-based web app! Extra bonus points if you use the Fire Eagle Rubygem. If you’ve got a great idea for a Fire Eagle app and don’t have an invite, just ask firebot for one!

PS: If you hack up a Fire Eagle javascript sidebar widget that works on pages served as application/xml (preferably using the brilliant wedje technique) AND embraces the draft geo microformat, I’ll buy you a pony. Seriously.

Spaces 'Application Assignments' and Applescript

Let’s face it – Spaces, Leopard’s new virtual desktop implementation, isn’t as polished as many of us would like it to be. It has more than it’s share of undocumented features, bugs, and annoyances.

One of my personal gripes with spaces it’s lack of keyboard shortcuts for managing what Spaces calls “Application Assignments”. I’d like to be able to quickly assign an application to all Spaces with a quick keypress. Also – I often find myself hunting through my Spaces for 3 or 4 Safari windows I’ve left in various places – it’d be nice if there was an easy way to collect all windows of a given app on the current Space.

So, this morning, I sat down and started hacking at some Applescripts to do just that. After wading through the bizarre way that Application Assignments are stored, I ended up with 4 Applescripts:

  • Assign to All Spaces – assigns the frontmost window to all spaces.
  • Assign to Space X – opens an input dialog asking you which space to assign the frontmost window to.
  • Collect on Current Space – brings all windows from the frontmost appliation to the current space.
  • Remove Assignments – remove any appliaction assignments the frontmost window may have.

Here’s a zip file of all 4:

Spaces Applescripts

These scripts are designed to be invoked via a keyboard shortcut via Quicksilver or FastScripts.

If you have any corrects / additions / suggestions as to how to improve these scripts, drop ‘em in the comments!

resource_this - DRY Rails Resource Controllers

I’ve always been annoyed at the lack of maintainability that comes with using multiple resource controllers in my Rails apps. Each generated resource controller clocks in at 85 lines, and most of mine only differ from each other by a line or two – an added before_filter or a change in the url that the users is redirected to after the creation of a new Widget. Not very DRY. When coming back to each one of these controllers to add or adjust features, it takes me entirely too much time to sift through the stock 85 lines and find my application-specific behavior.

Enter resource_this

git clone git://github.com/jnewland/resource_this.git

resource_this aims to solve this maintainability problem by making your stock resource controllers look like this:

  class PostsController < ActionController::Base
   resource_this
  end

Behind the scenes, this code is generated:

  class PostsController < ActionController::Base
    before_filter :load_post, :only => [ :show, :edit, :update, :destroy ]
    before_filter :load_posts, :only => [ :index ]
    before_filter :new_post, :only => [ :new ]
    before_filter :create_post, :only => [ :create ]
    before_filter :update_post, :only => [ :update ]
    before_filter :destroy_post, :only => [ :destroy ]

  protected
    def load_post
      @post = Post.find(params[:id])
    end

    def new_post
      @post = Post.new
    end

    def create_post
      @post = Post.new(params[:post])
      @created = @post.save
    end

    def update_post
      @updated = @post.update_attributes(params[:post])
    end

    def destroy_post
      @post = @post.destroy
    end

    def load_posts
      @posts = Post.find(:all)
    end

  public
    def index
      respond_to do |format|
        format.html
        format.xml  { render :xml => @posts }
        format.js
      end
    end

    def show          
      respond_to do |format|
        format.html
        format.xml  { render :xml => @post }
        format.js
      end
    end

    def new          
      respond_to do |format|
        format.html { render :action => :edit }
        format.xml  { render :xml => @post }
        format.js
      end
    end

    def create
      respond_to do |format|
        if @created
          flash[:notice] = 'Post was successfully created.'
          format.html { redirect_to @post }
          format.xml  { render :xml => @post, :status => :created, :location => @post }
          format.js
        else
          format.html { render :action => :new }
          format.xml  { render :xml => @post.errors, :status => :unprocessable_entity }
          format.js
        end
      end
    end 

    def edit
      respond_to do |format|
        format.html
        format.js
      end
    end

    def update
      respond_to do |format|
        if @updated
          flash[:notice] = 'Post was successfully updated.'
          format.html { redirect_to @post }
          format.xml  { head :ok }
          format.js
        else
          format.html { render :action => :edit }
          format.xml  { render :xml => @post.errors, :status => :unprocessable_entity }
          format.js
        end
      end
    end

    def destroy          
      respond_to do |format|
        format.html { redirect_to :action => posts_url }
        format.xml  { head :ok }
        format.js
      end
    end
  end

Nested resources like so:

  class CommentsController < ActionController::Base
    resource_this :nested => [:posts]
  end

This generates a very similar controller to the one above with adjusted redirects and one additional before_filter / loader method pair to grab the parent resource. In this case:

  before_filter :load_post

  def load_post
    @post = Post.find(params[:post_id])
  end

The separation of logic – DB operations in before_filters, rendering in the standard resource controller methods – makes this approach ridiculously easy to customize. Need to load an additional object for the :show action? Slap another before_filter on it. Need to change the path that the :update action redirects to? Override the :update action with your new rendering behavior. And this customized behavior sticks out like a sore thumb – making it infinitely easier to maintain.

Oh, there’s also a generator:

./script/generate resource_this FooKlass [title:string body:text]

This works just like the resource generator, with the addition of the resource_this line to your controller and a functional test. No views are generated, so the test focuses on the XML behavior of this controller.

Contributing

resource_this is hosted on GitHub, so feel free to fork it and send a pull request with your changes.

FeedBurner for the Paranoid

After all of the hubub this weekend about how FeedBurner is ‘trouble’ and ‘bad for us’, I wanted to make a quick note of a couple of ways to serve your feeds through FeedBurner in a way that makes it possible to easily and seamlessly bring your feeds back under your control at any time.

  1. Use FeedBurner’s MyBrand service (which is now free) to serve your feeds using a domain you own. This lets you serve your feeds with a URI of http://feeds.mysillyblog.com/mysillyfeed or the like. In the event Google ‘preferring’ Google Reader for feeds burned by FeedBurner (something I’m confident Google will never do), you’d just point feeds.mysillyblog.com back to a server you control, and in the blink of a TTL, your feeds are yours again. For details on implementing MyBrand, check out Danny Sullivan’s great guide: Stay Master of Your Feed Domain.
  2. Advertise your feed at a URL on your blog (http://mysillyblog.com/index.xml), then redirect users to FeedBurner with a 302 Found redirect. Straight from the HTTP specifications, this tells your browser or RSS reader:
    Since the redirection might be altered on occasion, the client SHOULD continue to use the Request-URI for future requests.
    Here’s a nice guide detailing how to properly redirect your feed to FeedBurner using a 302 Found response code. In this case, if Google / FeedBurner ever sins against you or your mother, your feeds can be instantly and seamlessly moved away from FeedBurner by removing this redirect.
  3. For the extra paranoid, combine methods 1 and 2!

I’m a huge fan of FeedBurner, and like Fred Wilson, don’t share the concerns of Dave Winer about FeedBurner’s future. At last count, I manage around 225 feeds in several FeedBurner accounts, and don’t ever plan on going back. But, if the need arises, I take comfort in knowing how easy is is to leave. To quote Fred’s post:

That gives me all the comfort in the world. I love it when services make it easy to leave. When they do that, I tend to stay.

Fire Eagle, meet Danger Day

UPDATE: These instructions are out of date. See here for instructions that work with the new Fire Eagle!

A couple days ago, a friend of mine sent me an invite for Fire Eagle, Yahoo! Research Berkley’s nifty closed-Alpha location storage and query engine, and I’ve been hooked ever since. For the rest of you without access, here’s a brief overview of what FireEagle does, straight from the FAQ page:

Fire Eagle is a site that keeps track of your current location and helps you share it with other sites and services safely. There are hundreds of potential applications.

Fire Eagle allows you to share your locations with other sites and services safely, through a secure server – you are always in control. You can decide to share your location with any application that can use it, and even choose how much detail to give that application (exact point, neighborhood, city, state, country).

So, I whipped up a quick Fire Eagle Rubygem to make it easier to deal with Fire Eagle’s API. The next logical step? A twitter bot.

Fire Eagle, meet Danger Day

If you’re lucky enough to have an invite to Fire Eagle, here’s how you can use it on Twitter:

  1. Follow Danger Day on Twitter
  2. Sign in to Fire Eagle
  3. Authorize Danger Day with your FireEagle account
  4. Get a mobile token to confirm your authentication with Danger Day
  5. Send a direct message to Danger Day with your token.

Once that’s done, you can update your location with a direct message to Danger Day like so:

  • u Atlanta, GA
  • u Belize
  • u 30022
  • u 123 Anytown USA
  • etc

If you’d like to do this via your mobile phone, make sure your mobile is setup with Twitter, then send the following text massage to 40404, Twitter’s short code:

  • d dangerday u Atlanta, GA

To look up the location of someone else using Danger Day:

  • q jnewland
  • q cjmartin
  • q plasticbagUK

or from your mobile:

  • d dangerday q jnewland

What’s next?

I’m getting married in a week, so I leave the creation of cooler Fire Eagle apps as an exercise to the reader. Extra bonus points if you use the Fire Eagle Rubygem. If you’ve got a great idea for a Fire Eagle app and don’t have an invite, get in touch with me – I might be able to make that happen.

PS: If you hack up a Fire Eagle javascript sidebar widget that works on pages served as application/xml (preferably using the brilliant wedje technique) AND embraces the draft geo microformat, I’ll buy you a pony. Seriously. Here’s my location in XML – go to town.

RailsConf '07 Roundup

David Heinemeier Hansson, by James Duncan Davidson. Creative Commons BY-NC-ND

I spent the past several days in Portland, OR, for RailsConf, the yearly gathering of the vibrant Ruby on Rails community. O’Reilly Media and Ruby Central put on an incredible conference. My only disappointment was that I couldn’t attend all of the presentations. Luckily, most of the presentation slides are online (some with accompanying code!!):

But by far, the most valuable part of the whole event was the time I spent in the hallways and around Portland with other Rails developers. In the two years I’ve been working with Rails, I’ve networked and collaborated with dozens if not hundreds of Rails developers online. It was great to finally be able to associate faces and voices with their respective names, blogs, and chat handles.

I also wrangled Erik Kastner and Charles Brian Quinn into the Capazon project while in Portland – look for some updates on that front in the near future.

A special thanks to the following folks for making my RailsConf an especially great time:

Joyent Slingshot Demo Notes

Eric Wagoner gave a demo of the Joyent’s newly released offline Rails application toolkit, Slinghot. He’s had access to Slingshot for a couple weeks ahead of the public release, and shared his early impressions with us tonight. These are rough notes from his presentation.

  • A local Slingshot app is distributed as a DMG on OS X, which is a full-stack Ruby VM plus your Rails apps. Lots of files. I mean, lots.: $ find Radiant.app | wc -l -> 8087
  • Server side, Slingshot uses a plugin that generates a ‘sync’ controller. This controller has several actions:
    • sync.up
    • sync.down
    • sync.log
  • These toss XML back and forth between the server and client app, containing the changed Models and some metadata.
  • Synchronization conflicts are handled in your application’s domain. This is important to note – Slingshot is not a silver bullet for the age old offline/online synchronization problem. However, it lets you solve this problem however your application needs.

MyConfPlan Javascript Widget

I’ve hacked up a simple Javascript widget for everyone out there using myconfplan, Dr Nic Williams’ wonderful conference session planning tool. Nic recently added JSON and XML feeds to myconfplan, so this is a natural progression.

The XHTML generated by this widget is in hCalendar format, with separate events for each session. If you’re using a Microformats aware browser (or the wonderful microformats bookmarklet), you’ll be able to add my RailsConf sessions to your local calendaring app.

To display your conference session selections on your blog or website, insert these two lines of code:

<script src="http://files.jnewland.com/display_myconfplan.js" type="text/javascript"></script>
<script src="JSON_URL?callback=display_myconfplan" type="text/javascript"></script>

Replace JSON_URL with the URL to the JSON feed for one of your conferences. For example, to display my RailsConf 2007 sessions in my sidebar, I used this:

<script src="http://files.jnewland.com/display_myconfplan.js" type="text/javascript"></script>
<script src="http://myconfplan.com/users/jnewland/conferences/RailsConf2007.js?callback=display_myconfplan" type="text/javascript"></script>

Now seems like a good time to mention that I’ll be at RailsConf 2007 later this month in Portland, OR, and I couldn’t be more excited about it. You can view my session selections in the sidebar, on on myconfplan. Also, I’m staying at the Jupiter Hotel, which looks like a blast. Let me know if you’ll be there too!

Capazon 0.2 Released - Capistrano 2.0 Compatible

Capazon 0.2.0 is out. There’s only one new feature: support for Capistrano 2.0. There’s no backwards compatibility. If you’re still on Capistrano 1.4.x, please don’t upgrade. It won’t work.

To update Capazon:

  • gem install capazon

Changes

Capistrano 2.0 has support for Rake-like namespaces, so I’ve moved all tasks provided by Capazon to the ec2 namespace:

$ cap ec2:describe_images
  * executing `ec2:describe_images'
IMAGE   ami-0386636a    rbuilder-online/nuxleus-1.3-x86_9327.img.manifest.xml  099034111737     available       true
IMAGE   ami-0683666f    rbuilder-online/fedoracore6-1.0-x86_9677.img.manifest.xml       099034111737    available       true
[...]

To call these tasks from another namespace in a Capistrano recipe:

namespace :whatever do
  task :something_cool do
    [...]
    ec2.describe_images
    [...]
  end
end

Capistrano 2.0

Turns out updating extensions to work w/ Capistrano 2.0 is extremely easy. Just replace blocks like this:

Capistrano.configuration(:must_exist).load do
  task :take_over_the _world do
    [...]
  end
end

...with this:

Capistrano::Configuration.instance.load do do
  task :take_over_the _world do
    [...]
  end
end

For more on upgrading your recipes to Capistrano 2, head over to the upgrade guide on Capistrano’s new website or this post on NubyOnRails. Happy capifying!

Older posts: 1 2 3 ... 10