sublime text helper in .irbrc

I wanted to be able to open helper methods from irb using sublime text on Mac OS X.

In order to do this you first need to create a command line helper to for sublime text.

ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/sublime

This creates a symlink that you can use from the command line to open sublime text 2. Now we can use it in our .irbrc method.  Here is what i added to our .irbrc file:

def sublime(method_name)
  file, line = method(method_name).source_location
  `sublime '#{file}:#{line}'`
end

Now from IRB you can do this sort of thing:

>> helper.sublime(:link_to)

And it opens sublime text at the line number of the link_to method.

This is pretty nice. But, of course, what i’d really like is a way of opening the source for any method. Not sure how to go about that.

Also, if i could only get this to work with emacs. I can get emacs to open, but i haven’t spent the time to figure out how to get it to open to a given line number. Here is what i have:

def emacs(method_name)
  file, line = method(method_name).source_location
  `emacs '#{file}'`
end

The only clue to opening on a given line i found here, on stack overflow:

opening a file in emacs with at a line number.

Posted in emacs, rails, sublime text | Leave a comment

Upgrading to emacs 24.1 from emacs 23.2 on Mac OS X Lion

Today i decided to be BOLD and upgrade to emacs 24.

I’m hoping that emacs 24′s package manager will help us stay up-to-date on our submodes and cut-down on emacs upkeep and maintenance in general.  I’m going to document the steps i take here.

1. brew unlink emacs
2. brew install emacs

Thats it!  So far.

To get a list of packages we can do

M-x package-list-packages

This brings up a list of available (and installed) packages. Apparently this isn’t a complete list.  If you select a package you can install it from within emacs.  Lets see, there is coffee-mode, i’ll install it.

This installed it to

~/.emacs.d/elpa/coffee-mode-0.4.1/

Huh, i wonder if this will interfere with our dotfiles.  Er rather, i wonder how to integrate emacs 24 into our dotfiles.


	
	     
Posted in emacs | Leave a comment

Dickson Labs Blog Reboot

So, we were using a typo, but we have now just thrown that out and gone with wordpress.

I converted the old posts by cutting and pasting in the old HTML. WordPress is pretty great. It has a super slick interface. Good software is good software, no matter what the underlying language or technology is. So, lets put our prejudices aside, or not have them at all.

Time to move one.  Seems like many out there that i respect in the rails blogging community (yehuda, avdi) are using wordpress.  Sometimes you just have to go with the flow.

I had a need for the blog to actually work!  So, here we go on to WordPress.

ian.

Posted in Dickson Labs | Leave a comment

rails console show_routes fix for Rails 3.2.x

We upgraded a couple of our projects to Rails 3.2.0.

In our .railsrc file we had a “show_routes” method, which we used all the time when developing new routes.

With this method in place, in the rails console you can do this:

  >> show_routes :collections

Which yields output like this:

             collections GET    /collections(.:format)                      collections#index
                         POST   /collections(.:format)                      collections#create
          new_collection GET    /collections/new(.:format)                  collections#new
         edit_collection GET    /collections/:id/edit(.:format)             collections#edit
              collection GET    /collections/:id(.:format)                  collections#show
                         PUT    /collections/:id(.:format)                  collections#update
                         DELETE /collections/:id(.:format)                  collections#destroy

Unfortunately, this broke in Rails 3.2.x. The reason is that our method in .railsrc uses the old code from rails ‘rake routes’. Rails 3.2.x uses a new routing engine ‘Journey’. So we needed to update this code.

Here is what we came up with:

 
def show_routes(match = nil)
  Rails.application.reload_routes!
  all_routes = Rails.application.routes.routes
 
  require 'rails/application/route_inspector'
  inspector = Rails::Application::RouteInspector.new
 
  routes = inspector.format(all_routes, ENV['CONTROLLER'])
 
  ansi_bold       = "\033[1m"
  ansi_reset      = "\033[0m"
 
  if (match)
    match = match.to_s
    puts routes.grep(/#{match}/).map { |r|
      r.gsub!(match, "#{ansi_bold}#{match}#{ansi_reset}")
    }.join("\n")
 
  else
    puts routes.join "\n"
  end
end

That fixes it up pretty good!

ian.

Posted in rails | 2 Comments

Heritage trees 1.1 news

My partner at Dickson Labs, Chris Mealy and I sat down at Zoka to prioritize our work on the Heritage Trees app.

Our top priority is to get version 1.1 of the app out the door. Version 1.1 of the HT app is basically what we wanted to include in version 1.0, but we just couldn’t wait to get it out the door. So, away it went.

Version 1.1 will include:

  1. Photos! According to our Heritage Trees contact at SDOT, Plant Amnesty has all of the originals of these. So we’ve emailed them, we hope we can track down some photos! When we do, we will bundle these as JPGs with the application.

  2. We would like to collapse common / latin name lists to have sub-entries for multiple listings. In other words, the “By Common” and “By Latin” list views really should only list the tree type, and there should be another page beneath them in the page stack that will show a list of individual trees. For instance, in the “By Common” list view “Big Leaf Maple” should only appear once. Once you drill down on Big Leaf Maple, you would get a list of all of them.
    We have spent half a day working on this second feature, it should be finished soon.

Next Steps for the Heritage Trees app:

Website!

Once version 1.1 is out the door, we are going to start working on the back end for the app. This means moving the data into its new home on a website. To this end we are:

  1. working on the domain name
  2. designing first
  3. migrating the data into Rails
  4. adding user accounts so that people can add, edit, move and comment on trees
  5. adding a heritage trees app store and advertising, to support our efforts

Future Releases

We have brainstormed several directions for future development of the HT app.

  1. Android version! I have personally received a half-dozen requests for an Android version of our app. I’d push to start on this right away if i didn’t think the website was so important to our future development. I think an Android version of the app is totally essential. It also gives us an excuse to learn Android app development.
  2. Ability to geotag trees to move pins. The idea is when you are standing next to a tree you can push a button and it will overwrite the trees geocoding information to the current location. For owners and enthusiasts to have more accurate tracking of trees. Right now the pin location for a tree on the iPhone app is arbitrarily determined by Google based on the address we pass its geo location API. This data would then make its way back to the website and from there onto peoples phones.
  3. Ability to take pictures of trees from within the App itself. These pictures would make there way to the website and from there down to other peoples HT app installations.

As always, send your comments, photos and suggestions to: trees@dicksonlabs.com

ian.

Posted in Heritage Trees | Leave a comment

Seattle Heritage Trees iPhone App

Heritage Trees of Seattle iPhone App Released!

Dickson Labs is very proud to present our first iPhone app – Heritage Trees of Seattle.

This app was developed at Zoka over the summer of 2010, in between trips to the crags, to the Olympics and the Canadian rockies.

It is available right now in the Apple App Store – go to the app store page to install it on your iPhone or iPad.

What is the Heritage Trees App and What Does It Do?

Our app displays trees in the Seattle Hertage Trees program on a map view.  It also displays a list view by species and common name in the Seattle SDOT / Plant Amnesty Heritage Trees program.  If you live in Seattle, you can use our app to discover Heritage Trees near you!

The Seattle Heritage Trees program is a joint operation between Plant Amnesty and the City of Seattle.  There is a good explanation of the program on Plant Amnesty’s website.

The City of Seattle’s website contains PDF files that list all of the trees in the program, as well as PDFs for individual collections and interesting trees.  There is the overview page as well as a page giving a tour of the trees.   There is also a web form for nominating your tree.

Why this app? Why now?

Chris and I wanted to develop something for the iPhone.  First we worked through the Pragmatic Programmers iPhone SDK book.  When we had finished working through the chapters in the book, we were looking around for an iPhone project.  We wanted a project that was doable in a reasonable time frame, and something that was reasonable in scope.  We also wanted something that would actually be fun to use, something we might like to use ourselves. 

We came across the PDFs from the SDOT website, and said “aha!  there is our data source, lets turn those into an iPhone app”

So…

If you live in Seattle, download the app, use the app, send us some feedback to trees@dicksonlabs.com.

ian.

Posted in Heritage Trees | Leave a comment

Used YAML data dumper to migrate our Spree database, lovely!

In moving our Spree application from development to production, we found it necessary to migrate from SQLite to MySQL.  We had been using SQLite while doing development mainly out of a laziness, a need to not have to set up a MySQL server.  But in production, we figured MySQL was a better choice, for the usual reasons.  Here is what we did, for future r.

We decided to use this super-handy YAML db dumping rails plugin: http://github.com/ludicast/yaml_db

Installing it like this:

% script/plugin install git://github.com/ludicast/yaml_db.git

We were able to then do a:

% rake db:data:dump

We copied the resulting file (db/data.yml) file over to our production box.

We deployed our app, so that we could have the new YAML db dump functionality on our production box.  This was accomplished with a:

% cap deploy

We then edited the database.yml file on our production box to point to a new database.  

To create this database in MySQL, we did a:

% rake db:create

Then we did a:

% rake db:migrate

Once this was done we were able to load up our data using:

% rake db:load

(We still aren’t sure if the rake db:create and db:migrate more necessary, but hey!)

That was sweet!

ian.

Posted in rails | Leave a comment

Swedish Greys - a WordPress theme from Nordic Themepark.