Skip to content

Instantly share code, notes, and snippets.

@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);
@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 / 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 / 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 / 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 / maths-example.js
Created December 1, 2011 14:22
An example of implementing a module
var circle = require( './maths' )
var area = circle.area( 4 );
var circumference = circle.circumference( 4 );
@ruzz311
ruzz311 / timer.js
Created August 30, 2012 17:11
Timer.js - AMD module used for accurate, long timers
define([
"namespace",
// Libs
"use!jquery",
"use!backbone"
// Modules
// Plugins
],
function( namespace, $, Backbone ) {
@ruzz311
ruzz311 / dabblet.css
Created September 20, 2012 18:21
Untitled
.pulse, .btn:hover {
-webkit-animation-name: tada;
-moz-animation-name: tada;
-o-animation-name: tada;
animation-name: tada;
}
.tada, .btn:active {
-webkit-animation-name: tada;
-moz-animation-name: tada;
@ruzz311
ruzz311 / tcp.socketServer.js
Created October 16, 2012 06:19
TCP socket with Node.js
var net = require('net'), server, s;
// socket events
s = {
onStart: function(){
console.log('server started')
},
onClientConnect: function(conn){
@ruzz311
ruzz311 / BeautifulFaces.js
Last active December 14, 2015 07:39 — forked from joelongstreet/BeautifulFaces.js
BeautifulFaces.js (for NVM users) Dependencies: imagesnap (http://iharder.sourceforge.net/current/macosx/imagesnap/) Description: Save this script as a post-commit hook to snap a photo of yourself and save it with your commit message
#!/usr/bin/env node
//
// BeautifulFaces.js
// https://gist.github.com/joelongstreet/5052198
//
// Dependencies:
// imagesnap (npm install -g imagesnap)
// Description:
// Save this script as a post-commit hook to snap a photo of yourself and
// save it with your commit message