Status
someone checked in 4.2GB of data files in my subversion repo. makes a global checkout "unfun"
Location
Alexandria, VA
Subscribe to GeoRSS Subscribe to KML


Engineering

Migrating a site from PHP to Rails

Published in Howto, Rails


I learn best by picking a project and learning a new technology by applying it to the project. This is how I originally learned PHP, MySQL, and various web technologies when developing the Detroit Curling Club site/portal. Looking back, it’s amazing I got done what I did with what I knew. I implemented a Wiki, CMS, user management, uploading, RSS, and so forth, from the ground up, with no frameworks .

However, the result also means the code is, shall we say, “spaghetti”. And is really no fun to maintain and add to. Since then, I’ve learned Ruby and Rails and really enjoy working in the language and framework and wanted to reimplement the site. With so many other projects going on, I was concerned about the time necessary to get the site migrated.

Actually, it was rather easy. by stroke of fortune. Here is how the work went.

On the catwalk…

By similar mindset, when I designed the original database schema, I used “rails-esque” naming: tables are plural, columns are simple singular names. Join tables are alphabetical of the two tables they are joining. I just had to migrate the names of a couple of tables and columns to mee the rails standard configuration. I could have overriden the table/column names, but didn’t want to deal with maintaining that. I really wanted the site to work like it was originally written with Rails in mind.

You’ve obviously created a Rails application by now, so I’ll skip that. Now, I have my database (with backups). Setup your config/database.yml to point to the database and then run rake db:schema:dump to create the schema.rb of the database. If you want, you can copy this to a migration file.

Next, install Dr. Nic’s Magic Models, which automagically give you your model files, associations, basic validations, and so forth with no coding. Magic just begins to describe it. You can verify this by bringing up script/console and toying with your models and associations.

Testing is good

A good idea at this point is to load Selenium, a web user-interface testing application, and walk over your original site to create user interface requirements based on current site design. This should stand as your base-line specification. In the end, your Rails app should act like your current application.

You can also check out the work of Josh Susser who has a ruby script that will validate all the records in your database using your model validations.

Define your application test specification using RSpec and BDD. Again, you already have an existing web application to help define your desired functionality.

The View, the View

Now you have a your base application done. You should start migrating your views. Fill in your layout/application.rhtml with the base layout from your original HTML files.

You’ll now need to start actually defining your controllers for various functionality: calendar, users, leagues, etc. Along the way, run your tests you defined with RSpec and verify operation. This is where the actual work comes in. Overall though, I find the design of Rails to make this very easy going. I just have to deal with various legacy functionality.

I’m also looking more at Unobtrusive Javascript for Rails (ujs4rails) at how to handle graceful degradation (or is it graceful upgrading) to browsers that may not support javascript.

Work in Progress

That all said, migrating the site has been very easy. So easy I’m looking at migrating other projects to Rails. Of course, deploying Rails applications to shared hosts is not nearly as easy as deploying PHP ones. Especially with applications that are meant for other users to easily install on their own hosts. But the ease of development and maintenance is not easily overlooked.

If only Apache supported a built-in Rails module. :)


Developer or Programmer?

Published in Engineering, Hacking, Programming


There is a good article on Developers are from Mars, Programmers are from Venus. Comparing the two terms that are often interchanged, but really imply different meanings.

I first noticed this when deciding what I wanted to do in Undergraduate studies. Computer Science was hot stuff in the late ’90’s, but it really seemed like companies weren’t looking for Computer Scientists, they were really looking for Software Engineers, Developers, and Programmers (all different jobs with different skills, personalities, and types of work).

Computer Scientists really should be developing “formal specifications of a programming language”, whereas Software Engineers should be figuring out how to scale out a database, or apply domain specific solutions.

Of course, I ended up doing Aerospace Engineering, but with a Computer Science Minor. The CS minor let me take C++ instead of Fortran, and also have courses where I actually learned how to do requirements documentation, work in a team, design and build large scale systems in a single semester - all skills I didn’t learn in the Aerospace department but have since applied to my work.

I firmly believe that in the near future, all engineers/scientists should/will learn how to program. It is becoming a basic skill necessary to do proper analysis. Given a little bit of programming ability, an engineer can relieve themselves of copying & pasting from Excel to MatLab or other such silly things. Teach them good programming and software design techniques, in a modern and easy to use language with good tools, like Python (and then SciPy and NumPy) and they can be much more effective designers and analyzers. Also, if they learn general, good technique, they can apply that ability to learning other languages that may be specific to their domain.

And no, learning Fortran (or Java) is not going to cut it.


Interplanetary Mapping

Published in GeoRSS, Maps, Project, Space


All the emerging standards for simple markup and syndication of location are Earth-centric (and sometimes just US/North American-centric). Granted, most people are probably only interested in locations that they can actually go to anytime soon.

However, with the increasing number of interplanetary rovers, observations of moons, and perhaps future excursions, it is still useful to define how to properly handle these other reference frames. Luna and Mars are two suggested Microformats that are starting the discussion on how one might mark locations on the two bodies. Additionally, the OGC is working now on determining standards for scientists and developers to publish and share data sources of planets, moons, asteroids, comets, ‘oh my’.

And why does the Earth have to be the only one with cool, “slippy maps”. I quickly put together a map of Mars. It uses the powerful OpenLayers Javascript mapping library to display the tiles from a NASA WMS server.

Mars Map screenshot
To produce the locations for the map, I put up a Space Blog, using WordPress and a slightly modified GeoPress to publish Mars lander locations and landing dates. I altered the published Microformats produced by GeoPress to make the class “geo mars” as a suggested way to markup Mars coordinates. The published GeoRSS feeds from the Space Blog then produce the locations and layers automatically on the OpenLayers Mars Map.

To Do: CRS and You

So this is all very neat, and in the end, really easy to setup. However, this is just a demonstration and in no way should be construed as “the way to do it”. Specifically, there are these questions left unanswered:

  1. How to define the Microformat and GeoRSS for non-Earth (and non-WGS84) reference frames
  2. How to define the Microformats and GeoRSS/Geonames location for non-Earth locations (like “Ares Vallis”)
  3. More sources for interplanetary map servers
  4. Ways to syndicate, and subscribe to, specific bodies
  5. Support for publishing, consuming, and drawing lines - in order to plot out mission profiles
  6. Support for publishing, consuming, and drawing areas - in order to plot out mission profiles, landing sites, and expected areas of “mission failures”

I’m sure there are more issues, so please speak up. You know who you space geeks are.


TextMate Bundles

Published in Howto


I’m learning the power that is TextMate (like Emacs, but prettier). TextMate really is setting itself up to be a rather decent OS for editing. From within TextMate I can blog, keep a todo list, program in any number of languages, WYSIWYG webpage editing, and calendaring. Heck, mix TextMate and Quicksilver and who *needs* Finder. I picked up the new Pragmatic Programmer’s TextMate book to learn more of the underpinnings and how to stop repeating myself with simple tasks.

Like my thoughts on why plugins make, TextMate has excellent support via bundles (over 124 of them). However, the only way to get to these is via subversion. This is nice because it keeps me up to date, but is a little annoying having to get the subversion command right and path all the time.

So I wrote a small shell script to grab a bundle, get_tmbundle:

#!/bin/bash
svn --username anon --password anon co http://macromates.com\
/svn/Bundles/trunk/Bundles/$1.tmbundle ~/Library/Application Support/TextMate/Bundles/$1.tmbundle

I can then $ get_bundle AppleScript to get a new bundle installed.

You could also use the getBundle Bundle, but that seems like cheating. Of course, getBundle also has an AutoUpdater and is baked into TextMate as a bundle itself (how deep does the Rabbit Hole go?)

Technorati Tags: , , , , ,


Beautiful Sky

Published in Environment, Society, Space


Andri Snaer talks about how last night, all the lights were turned off in INSERT_ADDRESS. Then a famous astronomer talked about the night sky over the radio for people to enjoy the natural beauty of the cosmos.

I think this is a simply marvelous idea. I’ve been in several European cities when they’ve had “Car Free days”, most recently in Brussels during EuroOSCON. The idea is one day of the week that everyone will go car free, and enjoy the relative quiet and easy biking/strolling about town.

Overall, I am an idealistic technocrat. I really enjoy technology, gadgets, programming, etc. However, I also enjoy natural beauty and the environment as it is. I hope that towns here in the US start promoting these sorts of activities. I mean, what’s the worse that can happen, people actually think its a good idea and turn off their lights at night? :)