Skip to content

Instantly share code, notes, and snippets.

var connect = require('connect');
var resource = require('resource-router');
function main(app) {
app.resource('/:id', {
'get' : function(req, res) {
...
},
'put' : function(req, res) {
...
var sys = require('sys'),
express = require('express'),
resource = require('resource-router');
var app = express.createServer();
app.set('views', __dirname + '/views');
// resource-router
function main(app) {
app.resource('/', {
function main(app){
app.get('/', function(req, res) {
...
});
app.put('/', function(req, res) {
...
});
app.delete('/', function(req, res) {
...
});
Hello World
@s3u
s3u / SomeNumbers.md
Created March 8, 2011 21:34
No meaning yet, but these make me smile.

X

subbu@subbu-virtual-machine:~/dev/projects/jives/tini$ siege -r 300 -c 200  http://127.0.0.1:3000/
** SIEGE 2.69
** Preparing 200 concurrent users for battle.
The server is now under siege..      done.
Transactions:		       60000 hits
Availability:		      100.00 %
Elapsed time:		       11.85 secs

Data transferred: 0.63 MB

@s3u
s3u / gist:1329981
Created November 1, 2011 05:15
"use strict" saves lunch and many more.
/tmp> cat test.js
"use strict"
a = 'b';
/tmp> node test.js
node.js:134
throw e; // process.nextTick error, or 'error' event on first tick
^
function probe(cb) {
var wsCtor = window['MozWebSocket'] ? MozWebSocket : WebSocket;
var socket = new wsCtor(uri, 'blah');
socket.onopen = function () {
// Send a probe
socket.send(JSON.stringify({
type: 'probe',
data: {}
}));
};
@s3u
s3u / gist:1518617
Created December 25, 2011 01:54
JSONPath
start = fieldName;
fieldName = selector ('.' selector)*
selector = word '[' (numOfexpr/ ('"' qword '"') / ('\'' qword '\'')) ']' / word / '@'
word = chars:([a-zA-Z$:][a-zA-Z_0-9:]*) {
var ret = chars[0];
for(i = 1; i < chars.length; i++) {
@s3u
s3u / cluster-sample.js
Created January 11, 2012 06:18
DIY Cluster
'use strict'
var cluster = require('cluster'),
http = require('http'),
os = require('os'),
fs = require('fs');
function Master(options) {
this.options = options;
@s3u
s3u / gist:1794561
Created February 11, 2012 00:41
connect XSS hole