Put your message here! Contact me for more information
 
 







 

Archive for the ‘My Projects’ Category


 

I got the invitation to CloudFoundry (http://cloudfoundry.com), the new PaaS (Platform as a Service) sponsored by VMWare, so I decided to deploy my side project PushPuppy to evaluate the platform. CloudFoundry (CF) supports a wider selection of platforms and technologies including Ruby (1.8.7 and 1.9.2), NodeJS, and Java 6, as opposed to Heroku’s Ruby-only support. So for weekend or experimental projects, CF is an excellent choice.

The basic application deployment process was pretty straightforward, download the vmc gem, run a few commands to push the app to CF and fingers-crossed hoping that the app starts successfully. For PushPuppy, I’m using Rails 3 and MongoDB with Mongoid as the ORM, and I had to change a few things to get the app deployed properly.

Because CloudFoundry provide a ready environment for your app, the configuration is only available at deploy time. Since Mongoid tries to connect to the database when your app is starting, the app would fail in a normal CloudFoundry push with something like

Error: Application ‘pushpuppy’s state is undetermined, not enough information available.

and if you hit the public URL, the site will return

VCAP ROUTER: 404 - DESTINATION NOT FOUND

Essentially the app couldn’t get started in the backend, so you’ll get a 404 since CF can’t route the request to the application server. Luckily, CloudFoundry provides some basic logging access to help you troubleshoot the issue:

$ vmc logs YOUR_APP_NAME

The command will show you all the logs from stderr or stdout. Using the error logs I was able to get Mongoid to connect properly.

First of all, add

gem ‘json’

to your Gemfile. CloudFoundry requires all the gems to be explicitly listed in the Gemfile.

Next, Remove the mongoid.yml file, and create a new initializer: config/initializers/mongoid.rb

The idea is to sniff if there’s a VCAP_SERVICES environment variable, we’d connect to MongoDB using the CloudFoundry provided parameters. Now update your app again and hopefully your app will start.

This is the full log for my deployment of PushPuppy with Ruby1.9.2

Conclusion:

Pros:
- CloudFoundry is a cool new PaaS that is free and supports a great variety of bleeding-edge technologies like Mongo, Redis, NodeJS. I’m especially intrigued about the NodeJS support since I’ve been looking for a service to host my projects.

Cons:
- The deployment process is simple, but still not as streamlined as Heroku’s. The error messages are not as clear as they should be, especially for a new starter, it may takes a little bit of digging to figure out what goes wrong.
- CF currently doesn’t support domain mapping. So it remains only a development/test platform. Hopefully VMWare will add this feature soon.
- No rake support, so basic things like db:seed or running custom rake tasks directly are not possible. CF automatically runs db:migrate, but for db:seed you have to put in an initializer (more here).
- No console support.
- No way to have direct access to your data so please don’t run your production app here :)

Nonetheless, CloudFoundry is a cool platform and it makes me as a developer happy because I now can experiment with new technologies without having to worry about the hosting and sysadmin part.

view comments
 

I wanted to give mechanize a shot for a small prototype I was building.  It’s been a while since I last ran the gem command so of course the first thing it would do was to update itself.  For some reason, it got stuck forever.  It turned out that the latest hpricot gem was trying to build itself from source (! - very strange!) and gem updater got stuck looking for a compatible compiler.

So I downloaded the mechanize gem from Rubyforge instead and ran

gem install mechanize-0.7.7.gem

However, the gem still tried to access the gem index and eventually got stuck somewhere.  The ruby runtime ballooned up to more than 600MB as showed in Task Manager.  I dug up the gem install command and it turns out the gem install can be forced to install without checking the dependencies and without updaing the local index.   So the final gem command is

gem install mechanize-0.7.7.gem –no-ri –no-rdoc -f –no-update-sources

With the –no-update-sources flag, the gem won’t try to go off to http://gems.rubyforge.org and get the latest repository info but expecting there is already a local gem file.

Hope this help someone :)

view comments
 

I just checked out the 280Slides.com, a YCombinator’s funded company. They are developing an online Slideshow/Powerpoint site (yes, another one). The application is pretty slick and it has the Apple’s look and feel to it (both the 2 founds were from Apple). Paul Graham used their app to create his slide at StartupSchool 2008, which at the time, took him 10 minutes to start his slides due to “technical issues”.

What really got me amazed is that they developed a JavaScript UI framework called Objective-J. Apple do a lot of their apps and gadgets in Objective-C (iPhone for one), and since the guys behind 280Slides were from Apple, probably they took the concepts from Objective C and bring it over to JavaScript. Having coded TubeCaption’s caption editor, the Captionizer, from scratch, I understand how much work it takes to do something non-trivial in JavaScript. Programming an online application is totally different than programming a simple “Ajaxy, Web2.0″ page because the amount of work involved. We have hundreds of objects potentially interact with one another and trying to compete for CPU. Without a solid foundation, the application won’t be able to bear the performance and complexity weight.

I’m pretty excited to hear that 280Slides is planning to open-source their framework (probably the Objective J) in the near future. It will be a fresh idea besides the currently established frameworks such as YUI, Ext, Prototype.

Increasingly I see the trend of JavaScript being used as the underlining cross-platform language to build other frameworks and programming languages on top of it. John Resig (from jQuery) recently ported the processing visualizing language to JavaScript. His JS implementation looks AMAZING (check out the parser’s code, what a work of art) and performance-wise the library kicks major ass. Then somebody wrote a Ruby VM in JavaScript (HotRuby) and Ruby code can get executed natively in the browser. A VM written in JavaScript? WOW! Just the thought of Rails *may* work in the browser (hopefully not IE6) makes me feel dreamy. These stuffs are truly innovative and that’s what really push the web technologies forward. And with the new JavaScript engines that promise excellent performance (Webkit’s Squirrelfish, Mozilla’s SpiderMonkey), for sure we will even see MORE of the creative innovations.

PS: don’t forget to check out www.tubecaption.com’s Captionizer, the first timeline-based caption editor.

view comments
 

add your captions on TubeCaption.com
view comments
 

If you do “gem install capistrano”, the gem package manager will go fetch the latest gem version of capistrano, currently 2.3.0 and installed in the gem repository. In case you want to have multiple version s of capistrano running, here’s how to do it.

To install older gem version of Capistrano
gem install –version 1.4.2 capistrano
(1.4.2 is the latest one in the 1.x branch before the release of 2.0)

To run specifically the 1.4.2 version, use
cap _1.4.2_ *your_tasks_here*

Shortcut
To reduce the typing, you can make an alias in your .bash_profile on Linux to run the 1.4.2 version as cap1 (cap 2.x.x is still running as cap) using

# add this line to .bash_profile
alias cap1=”cap _1.4.2_”

Afterwards, reload the profile with

$ source .bash_profile


Since I am on Windows, what I did was creating a batch file called “cap1.bat” and saved it within my system’s PATH environment. For simplicity’s sake, I save the cap1.bat file inside my C:\Windows\System32 folder

@echo off
cap _1.4.2_ %*

The special wildcard %* will be replaced with your command-line arguments, saving you the typing.

To read more about the Capistrano 1.4.2 version, check out Jamis’s post here.

view comments