Oct 16 2010
- 04/10/2011 - Updated application.js and application.rb thanks to @rebo's comments
In this article, I will walk through some simple steps to get a [demo app][2] up and running with [Backbone.js][3] and [Sinatra][4] on [Heroku][5].
| var http = require("http"), | |
| url = require("url"), | |
| path = require("path"), | |
| fs = require("fs") | |
| port = process.argv[2] || 8888; | |
| http.createServer(function(request, response) { | |
| var uri = url.parse(request.url).pathname | |
| , filename = path.join(process.cwd(), uri); |
| function encrypt(text){ | |
| var cipher = crypto.createCipher('aes-256-cbc','d6F3Efeq') | |
| var crypted = cipher.update(text,'utf8','hex') | |
| crypted += cipher.final('hex'); | |
| return crypted; | |
| } | |
| function decrypt(text){ | |
| var decipher = crypto.createDecipher('aes-256-cbc','d6F3Efeq') | |
| var dec = decipher.update(text,'hex','utf8') |
| /* | |
| * base64.js: An extremely simple implementation of base64 encoding / decoding using node.js Buffers | |
| * | |
| * (C) 2010, Nodejitsu Inc. | |
| * (C) 2011, Cull TV, Inc. | |
| * | |
| */ | |
| var base64 = exports; |
| package com.linkedin.dust.renderer; | |
| import java.io.IOException; | |
| import java.io.InputStream; | |
| import java.io.InputStreamReader; | |
| import java.io.Reader; | |
| import java.io.Writer; | |
| import org.mozilla.javascript.Context; | |
| import org.mozilla.javascript.JavaScriptException; |
| /* | |
| * This decorates Handlebars.js with the ability to load | |
| * templates from an external source, with light caching. | |
| * | |
| * To render a template, pass a closure that will receive the | |
| * template as a function parameter, eg, | |
| * T.render('templateName', function(t) { | |
| * $('#somediv').html( t() ); | |
| * }); | |
| * Source: https://github.com/wycats/handlebars.js/issues/82 |
| function addKeepAliveTimeout(agent) { | |
| function fail(msg) { | |
| console.warn(msg + ', node version: ' + process.version); | |
| return agent; | |
| } | |
| // Check it's what we expect | |
| var old_listeners = agent.listeners('free'); | |
| if (!old_listeners || old_listeners.length !== 1) { | |
| return fail('Unexpected lacking "free" listener'); | |
| } |
| #!/usr/bin/env ruby -w | |
| # pnginator.rb: pack a .js file into a PNG image with an HTML payload; | |
| # when saved with an .html extension and opened in a browser, the HTML extracts and executes | |
| # the javascript. | |
| # Usage: ruby pnginator.rb input.js output.png.html | |
| # By Gasman <http://matt.west.co.tt/> | |
| # from an original idea by Daeken: http://daeken.com/superpacking-js-demos |
| <!doctype html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | |
| <title>Backbone.js • TodoMVC</title> | |
| <link rel="stylesheet" href="../../assets/base.css"> | |
| <!--[if IE]> | |
| <script src="../../assets/ie.js"></script> | |
| <![endif]--> |