Skip to content

Instantly share code, notes, and snippets.

View ovaillancourt's full-sized avatar

Olivier Vaillancourt ovaillancourt

  • Montreal, QC, Can
View GitHub Profile
query = resource-type, [fields], [condition];
resource-type = string;
fields = "(", string, [",", {string}], ")";
condition = ":" , (integer, "..", integer)
| (integer, "_", positive-integer)
| integer
| string
| ("~", integer)
| "*";
string = alphanumerical, { char };
function runAfter(times, func) {
if (times <= 0) return func();
return function() {
if (--times < 1) { return func.apply(this, arguments); }
};
};
var express = require('express');
var app = express.createServer();
app.use('/login', express.cookieParser());
app.use('/login', express.session({secret: 'keyboardcat', cookie:{ path:'/login'}}));
app.get('/', function(req,res,next){
res.send('cookies: ' + JSON.stringify(req.cookies));
});
#!/usr/bin/env node
var env = require('./env');
var cfg = env.cfg;
var cp = require('child_process');
var fs = require('fs');
var path = require('path');
var processes = [];
var EventEmitter = require('events').EventEmitter;
var querystring = require('querystring');
/**
* Pre-baked error messages
*
*/
var missingInfo = 'Password authentication - Missing Mandatory authentication' +
' information. A "login" and "password" must be provided.';
describe('when the route matches', function(){
it('should invoke the callback', function(done){
page('/user', function(ctx){
done();
})
page.show('/user?test=true');
})
var app = express()
, http = require('http');
http.createServer(app).listen(80, '127.0.0.1');
http.createServer(app).listen(80, '::1');
var proxyServer = require('http-proxy').createServer({
router: {
"mydomain.com/rest" : "targetMachine:port"
}
});
proxyServer.listen(myPort);
//That's your constructor
var BaseObject = function(eventObj){
this._ev = $(eventObj || {});
}
//There it's the inheritance
BaseObject.prototype = Object.create(Object.prototype);
//Put your methods there
BaseObject.prototype.on = function(){
@ovaillancourt
ovaillancourt / index.html
Created June 21, 2012 01:04
Small file upload app - minimal demo
<!-- Small upload form -->
<html><body>
<form action="/upload"
enctype="multipart/form-data" method="post">
Please specify a file, or a set of files:<br>
<input type="file" name="myfile" size="40">
</p>
<div>
<input type="submit" value="Send">
</div>