Working with JSON all day and implementing my own URL shortening app, diminutiveurl.com using Base32 encoding, I really admire Douglas Crockford’s smart and simple approach to these topics.
I stumbled upon Crockford’s talk on the JSON Saga, where he tells the story of how JSON came about. He is a really smart guy and a talented speaker. Check out the video:
Last night Google announced Java support on Google App Engine.
After a bit of toying around, here are my findings.
The Eclipse plugin is pretty slick. Deploying and build is simple.
The dev server that you spin up locally looks to be jetty under the hood.
Objects intended for storage are JDO annotated and after compiling, you run the .class files through the DataNucleus Enhancer which adds additional metadata so Google can map it to BigTable. The Eclipse plugin automatically performs this step for you after compiling. The examples provide a bunch of ant macros to help facilitate building/deploying.
One issue that I had was that the project was building with Java 1.6 and I would get an error after compiling:
Caused by: java.lang.UnsupportedClassVersionError: Bad version number in .class file
Even though they say they support Java 1.5 and 1.6, I guess this doesn’t work on the Java 1.6 for the Mac. Switching the build to 1.5 allows the DataNucleus Enhancer to run successfully.
The defaults in Rails with ActiveRecord is beautiful when you are just getting started and are created everything for the first time. But once you get into it and your database schema becomes a little more solidified, the things that would have been easy to do by relying on the conventions of Rails require a little bit more work.
In my case, I had a form where there was a database column named “num_guests”, representing the number of guests. When the field fails to pass validation, the error messages is something like
Num guests is not a number
Not quite the text that we want. It would be better if it said
Number of guests is not a number
After doing a little bit of digging, I found the human_attribute_name method. You can override this method in your model class to provide alternative names for fields. To change our error message, I did the following
class Reservation < ActiveRecord::Base
...
validates_presence_of :num_guests
...
HUMAN_ATTRIBUTES = {
:num_guests => "Number of guests"
}
def self.human_attribute_name(attr)
HUMAN_ATTRIBUTES[attr.to_sym] || super
end
end
Since Rails 2.2, this method is used to support internationalization (i18n). Looking at it, it reminds me of Java’s Resource Bundles and Spring MVC’s error messages. Messages are defined based off a key and there’s a chain of look ups that get applied to resolve an error’s message.
Although, I don’t see myself doing any i18n work in the near-term, it is cool that we have that option now in Rails.
After reading about the violinist playing in the metro (which happened awhile ago), I think we are, at many times, too preoccupied with ourselves and the things that are happening in our lives when we should be taking a moment or a step back to recognize the great things that are happening right in front of us.
Do you think you would be able to recognize extraordinary talent when it is staring you in the face?