WebSnapshot Updated.

The guys running the Adobe AIR Marketplace contacted me a couple of weeks ago to publish Websnapshot on the market place. Then they kindly gave me a free Thawte code signing certificate. So I republished the app and changed the skin, I used the Darkroom theme found on scalenine.com. Thawte didn’t make it easy on me to get the certificate. The main issue was that I didn’t have a phone number associated with my company name, therefore Thawte wanted me to send a phone bill with my company name (thug!) or a notarized letter. I had to resend three times the letter as first they couldn’t read it, then it didn’t show some required date…Well, finally I got the certificate and could sign the application. I don’t believe it will make a difference to many users as most people currently install non-signed apps anyhow. Now that certificate was changed from the initial I used to sign the application it will however require that you uninstall first the application if it was already installed.
You can now find the application on the Marketplace or here.
It’s basically the same version than before with just a minor scaling issue fixed. What I need to add next is auto update, custom filenames, saving to s3 and Flickr.
Enjoy! Daniel.
Google's appengine is up and running. 1
Appengine is Google’s answer to Amazon’s web services (ec2, s3, ...). I just signed up and got the following message: “Thanks for checking in! When space in the Google App Engine preview release becomes available, we’ll notify you by emailing…”
While waiting you can read there doc or download the SDK.
They have some demo apps. Also, the runtime or development language of choice seems to be Python…hopefully Ruby is next on the line.
Update: 11:14pm Got an Invitation to try Google App Engine saying my account has been activated. The account allows me to create 3 applications.
gemedit version 0.0.2 has been released! 2
A utility to view a gem's source in your favorite editor
Changes:
0.0.2 2008-03-07
1 minor enhancement:
- add -p/--pretend option to show what gem(s) would be edited and with what command
iPhone SDK - first 5 minutes. 8
Off course I couldn’t resist, I had to give it a try. The sdk is a whopping 2GB download and 5.6 Gb install. It installs all the developers tools, java, gcc4.2, WebObjects, the kitchen sink. Upon successful installation the system needs to be restarted.
Start XCode and select ‘New Project…’ from the File menu. You can then select from 3 type of iPhone Applications
Let’s try the Cocoa Touch List and I name my test project TimeList.
This creates a standard XCode project:
I clicked “Build and Go”...the application is compiled and linked after 20 seconds got an emulate iPhone with the TimeList app visible:

Clicking on it we get a pre-populated list of timezones which behaves just like an iPhone:

Note the emulator application is called Aspen Simulator, it has a ‘Hardware’ menu that should allow to rotate the UI but that doesn’t seem to work. The emulator really feels like an iPhone, all the finger gestures can be done with the mouse and the UI behaves like an iPhone. Pretty cool.
Let’s look at the TimeListAppDelegate generated code:
//
// TimeListAppDelegate.m
// TimeList
//
// Created by Daniel Wanja on 3/7/08.
// Copyright __MyCompanyName__ 2008. All rights reserved.
//
#import "TimeListAppDelegate.h"
@implementation TimeListAppDelegate
@synthesize window;
@synthesize tableView;
- init {
if (self = [super init]) {
// Your initialization code here
}
return self;
}
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Create window
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Set up table view
tableView = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame] style:UITableViewStylePlain];
tableView.delegate = self;
tableView.dataSource = self;
// Show the window with table view
[window addSubview:tableView];
[window makeKeyAndVisible];
[tableView reloadData];
}
- (void)dealloc {
[tableView release];
[window release];
[super dealloc];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [[NSTimeZone knownTimeZoneNames] count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath withAvailableCell:(UITableViewCell *)availableCell {
UISimpleTableViewCell *cell = nil;
if (availableCell != nil) {
cell = (UISimpleTableViewCell *)availableCell;
} else {
CGRect frame = CGRectMake(0, 0, 300, 44);
cell = [[[UISimpleTableViewCell alloc] initWithFrame:frame] autorelease];
}
cell.text = [[NSTimeZone knownTimeZoneNames] objectAtIndex:[indexPath row]];
return cell;
}
@endLooks like I have lots to read about before I can start changing that application. From what I can decipher once the application is initialized a UITableView is created and the delegate of the table view becomes the TimeListAppDelegate whish implements the numberOfRowsInSection and cellForRowAtIndexPath methods which uses the NSTimeZone knowTimeZonesNames as data source.
That was my first 5 minutes with the SDK. More to follow…now I have to go back to work :-( Next thing I will try out is the Interface Builder…stay tuned.
Enjoy! Daniel.
gemedit version 0.0.1 has been released! 1
Check out my first published gem: gemedit
A utility to view a gem’s source in your favorite editor
Changes:
- 0.0.1 2008-02-27
- 1 major enhancement:
- Initial release
Something in the AIR? 3
360Flex in Atlanta starts this monday. I was at the first 360Flex conference last year and it was a blast. I will miss going to that one. Also it seems that many Flex User Groups meetings around the world (Atlanta, Bangalore, London, Denver, Amsterdam) will held on this monday. When so many planets will align perfectly something special is bound to occur.
So more specifically from the Special Meeting invites:
- Exclusive user group video presentation by Adobe Chief Software Architect, Kevin Lynch
- In-person presentation from Adobe Platform Evangelist, Kevin Hoyt
- And…important product news!
That can mean only one thing. It’s gonna be soon time to recompile all my apps ;-)
Update 1: the Denver meeting is not on the 25th but on March 11th. Update 2: Ted Patrick announces yesterday that the Flex 3.0 and AIR 1.0 releases is days away. Update 3: Flex 3.0 and AIR 1.0 are out. Go try out FlexBuilder if you haven’t yet, it’s the easiest way to get started.
Heroku.com - An impressive online Ruby on Rails Platform. 5
You’ve have to try it to believe it. It’s awesome that you can create a Rails application and deploy it all online. Nothing to install, it’s all there. I think it’s an awesome addition to the Rails world. It may not replace your development environment, but for deployment it’s pretty flexible and is based on Amazon EC2.
From their website the feature description is as follows:
- Instant Deployment
- Create and Edit Online
- Integrated Stack
- Elastic Performance
- Share and Collaborate
- Import & Export
- Full Ruby Environment
- Gems & Plugins
- Rails Console
- Generate Code
- Painless Migrations
- Rake Console
But you gotta see this to believe it. I made a quick screencast, so if you are not scared of a thick (swiss) french accent, have a look: (click image to open screencast in separate browser):

I can foresee, at least hope, that they will quickly add support for subversion and for Capistrano based deployment, hence becoming the ultimate deployment platform for Rails in addition to the powerful and flexible environment they already provide.
I signed up and received my invite three days later. If you can’t wait send me an email daniel[at]onrails.org, and I sign you up, that will allow to skip the wait.
Enjoy, Daniel.
Dealing with HTTP errors in a Flex with Rails application. 8
The Flash Player is restricted in the way it deals with HTTP errors. This is mainly due to provide cross browser consistency and I believe is due to the restrictions the browser imposes on the Flash Player plugin. In fact when your Flex application performs HTTP requests using the HTTPService class, the request is passed by the Flash Player to the browser and in case of an Rails error (500, 404, ...) the response is somehow crippled on the way back.
Problem
So let’s consider that the Flex application requests to update a Person but the validation fails. In the update method of our Rails controller the HTTP Status is set to :unprocessable_entity. This corresponds the HTTP error code 422. # PUT /people/1
# PUT /people/1.xml
def update
@person = Person.find(params[:id])
respond_to do |format|
if @person.update_attributes(params[:person])
flash[:notice] = 'Person was successfully updated.'
format.html { redirect_to(@person) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @person.errors, :status => :unprocessable_entity }
end
end
endNow in our Flex application by default we cannot identify that the error 422 occured, more annoyingly we cannot retrieve the Rails error messages. All we get back is the following:
[FaultEvent fault=[RPC Fault faultString="HTTP request error" faultCode="Server.Error.Request" faultDetail="Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://localhost:3000/people/8.xml?_method=put"]. URL: http://localhost:3000/people/8.xml?_method=put"] messageId="65EBBA92-5911-68D2-1710-18A687C28455" type="fault" bubbles=false cancelable=true eventPhase=2]Solution
I haven’t found a way to have the status code and error message appear in the Flex application without having to change the Rails application. But fortunately, I was able to deal with that by using an after_filter at the application controller level, hence having only one place in the application to take care of all controllers and requests. The trick is to “hide” the HTTP Status error code in Rails and as the Flex application deals with XML responses, simply check in Flex if the response starts with <errors>. This can then also be dealt with in the Flex application in one place of the application. In a Cairngorm application I had the Delegate transform these “errors” responses to Faults.
Here is an example of the change to the Rails ApplicationController.
class ApplicationController < ActionController::Base
after_filter :flex_error_handling
def flex_error_handling
response.headers['Status'] = interpret_status(200) if response.headers['Status'] == interpret_status(422)
end
def rescue_action_in_public(exception)
render_exception(exception)
end
def rescue_action_locally(exception)
render_exception(exception)
end
rescue_from ActiveRecord::RecordNotFound, :with => :render_exception
def render_exception(exception)
render :text => "<errors><error>#{exception}</error></errors>", :status => 200
end
endFlexible Rails: A book on using Flex with Rails. 2
As many of you know I really enjoy using Flex with Rails. So I finally picked-up a copy of FlexibleRails which is written by Peter Armstrong and started browsing through it last week-end. For anyone out there trying to enrich their application with some Flex or even writing the whole UI in Flex, check out this book as it’s a good starting point and Peter addresses many of the aspects that you will be faced with. Peter goes through several iterations of creating an application and introduces the reader to using Flex against a RESTful Rails application, he refactors the application to Cairngorm, uses AMF. So congratulations Peter of getting this done!


