Skip to content

Instantly share code, notes, and snippets.

@ruzz311
ruzz311 / routes.js
Created December 1, 2011 06:47
Routing example
// Routes
// General routes
app.all( '/remote(/*)?', Security.simple_auth );
app.all( '/presenter(/*)?', Security.simple_auth );
// General User
app.get( '/', function( req, res ) {
res.render( 'presentation/node', {
title: 'Node - PEEEYYYAAAAAHHH'
});
@ruzz311
ruzz311 / module-example.js
Created December 1, 2011 05:57
An example of a simple module
var PI = Math.PI;
exports.area = function (r) {
return PI * r * r;
};
exports.circumference = function (r) {
return 2 * PI * r;
};
@ruzz311
ruzz311 / file-list.js
Created December 1, 2011 05:45
Display a list of files in a directory
var fs = require('fs');
fs.readdir('.', function (err, files) {
if (err) throw err;
for (var index in files) {
console.log(files[index]);
}
});
@ruzz311
ruzz311 / jquery-callback.js
Created December 1, 2011 05:16
jQuery example of non-blocking callbacks
$.get('ajax/test.html', function(data) {
$('.result').html(data);
alert('Load was performed.');
});
@ruzz311
ruzz311 / nodejs-hello-world.js
Created November 28, 2011 02:56
Nodejs Hello World Example
var sys = require('sys'),
http = require('http');
http.createServer(function(req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.write('<p>Hello World</p>');
res.end();
}).listen(8080);