Any sizable web application needs validation. Doing it yourself is for the birds, so I wanted to incorporate a backbone plugin to help solve the problem. For this example I chose to use Backbone.Validation.
Start with a basic framework. Brunch Application Assembler is a great way to bootstrap these projects. I used Paul Miller's brunch-with-chaplin skeleton.
brunch new gh:paulmillr/brunch-with-chaplin
To start up the server, type brunch watch --server and go to http://localhost:3333/ in a new browser window. If everything is good, you'll see this:
You'll need a basic application to test out our concept, so we'll modify the routes and the controller, and add a new view and template to our project.
We've all seen them - builder patterns that make object construction clean and readable.
I used to do these all the time in Java (we called them fluent interfaces), and I just realized today that I had no idea how to do this style in Coffeescript. Well, lets remedy that.
For the next few months, I'll be working with the team at LocalRuckus, building a new Node.js API and application. As a small shop with no dedicated Sys Admin or Dev Ops, its essential that we find Node.js hosting that is flexible, fast, and cost-effective. I've been considering three major players in the Node.js hosting scene, Heroku, Nodejitsu, and Appfog. There are some good comparisons out there (I especially like Daniel Saewitz's article), but I wanted to share my 2 cents.
On a recent trip to San Diego, my wife and I crossed the U.S./Mexico border at San Ysidro to visit the lovely city of Tijuana. A 5 minute walk across the border was all it took to enter Mexico.
After a few hours of touring the Mexican shops (and the accompanying drug offers), we were ready to return to the United States. However, returning to the U.S. is not nearly as easy as leaving it. The customs wait at the border checkpoint was over 2 hours long. A miserable way to spend 2 hours of my vacation, and a problem that I won't tolerate any longer.
Borderizer provides you with up to the minute stats on how long the wait is at any border crossing in Mexico or Canada. Equipped with this information, you can plan your trip better. If the wait at San Ysidro is 2...
Heroku provides a free add on for running scheduled jobs. This provides a convenient way to run scheduled tasks in an on-demand dyno, freeing your web dynos to focus on user requests. I'm currently writing a node.js application in coffeescript that has some modest job scheduling needs.
Heroku's documentation is a little thin on explaining this particular use case, however a good starting point is reading the One-Off Dyno Documentation. The important concept to remember is that if you can run your command using "heroku run xxx", you'll be able to run it in the scheduler. These one-off dynos should be place in a bin/ directory in your project root.
My first attempt is below. Note that we set it to use our node install to run (Heroku installs node at /app/bin/node).
#! /app/bin/node require('../server/jobs/revenueCalculator').runOnce()
Deploy to heroku and...