Skip to content

Instantly share code, notes, and snippets.

var http = require('http'),
EventEmitter = require('events').EventEmitter;
var emitter = new EventEmitter();
var server = http.createServer(function (req, res, proxy) {
emitter.on('done', function (e) {
if(e) {
res.writeHead(502);
res.end();

A table in the tables dir

create table parse.response
    on select get from 'http://maps.googleapis.com/maps/api/geocode/json?sensor=true&address={^address}'
        using patch 'parse-response.js'

Patch in the same dir

// args.body would be an array of buffers

exports['parse response'] = function(args) {

create table foo 
    on insert post to 'uri'
          using bodyTemplate... type ...
          with part ... 

insert into foo (...) values (...)
   with part "{req.part[0]}";
update bar ...
   with part "{req.part[0]}";

insert into foo values "{req.body}";

@s3u
s3u / udfs.md
Created April 8, 2012 02:39
ql.io - User Defined Functions

User Defined Functions

A user-defined function is a Javascript function that can be used in where clauses and columns clauses.

UDFs in the Where Clause

When specified in the where clause, a UDF can apply custom logic to filter out or re-shape a row from a data set.

@s3u
s3u / gist:2227815
Created March 28, 2012 16:08
UDF and JSONPath
a1 = [{
"name": "Brand-A",
"ns": "df",
"aspectValue" : [{ "name": "Gap"},
{"name": "Addidas"},
{"name": "Gravati"}]
},
{
"name": "Brand-B",
"ns": "df",
@s3u
s3u / gist:2172946
Created March 23, 2012 17:21
IPC Test
var cluster = require('cluster');
var http = require('http');
var numCPUs = require('os').cpus().length;
var numReqs = 0;
if(cluster.isMaster) {
// Fork workers.
for(var i = 0; i < numCPUs; i++) {
var worker = cluster.fork();
worker.on('message', function (msg) {
@s3u
s3u / gist:2172768
Created March 23, 2012 16:58
IPC - 1 message per req
~> siege -c 100 -t 2m http://localhost:3030
** SIEGE 2.70
** Preparing 100 concurrent users for battle.
The server is now under siege...
Lifting the server siege... done.
Transactions: 4366377 hits
Availability: 100.00 %
Elapsed time: 119.26 secs
Data transferred: 49.97 MB
Response time: 0.00 secs
@s3u
s3u / gist:2172744
Created March 23, 2012 16:55
Siege - IPC - 5 messages per req
~> siege -c 100 -t 2m http://localhost:3030
** SIEGE 2.70
** Preparing 100 concurrent users for battle.
The server is now under siege...
Lifting the server siege... done.
Transactions: 3407277 hits
Availability: 100.00 %
Elapsed time: 119.73 secs
Data transferred: 38.99 MB
Response time: 0.00 secs
@s3u
s3u / gist:2172713
Created March 23, 2012 16:52
Sieje - no IPC
~> siege -c 100 -t 2m http://localhost:3030
** SIEGE 2.70
** Preparing 100 concurrent users for battle.
The server is now under siege...
Lifting the server siege... done.
Transactions: 5094455 hits
Availability: 100.00 %
Elapsed time: 119.01 secs
Data transferred: 58.30 MB
Response time: 0.00 secs
@s3u
s3u / gist:2164855
Created March 22, 2012 21:51
ql.io-site app on Cloud Foundry - See chunk markers
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 22 Mar 2012 13:28:14 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Keep-Alive: timeout=20
X-Powered-By: ql.io/node.js v0.6.8
vary: accept-encoding
Transfer-Encoding: chunked