Skip to content

Instantly share code, notes, and snippets.

View ovaillancourt's full-sized avatar

Olivier Vaillancourt ovaillancourt

  • Workleap
  • Montreal, QC, Can
View GitHub Profile
#!/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 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));
});
function runAfter(times, func) {
if (times <= 0) return func();
return function() {
if (--times < 1) { return func.apply(this, arguments); }
};
};
query = resource-type, [fields], [condition];
resource-type = string;
fields = "(", string, [",", {string}], ")";
condition = ":" , (integer, "..", integer)
| (integer, "_", positive-integer)
| integer
| string
| ("~", integer)
| "*";
string = alphanumerical, { char };
var purity = require('virtue-purity'); //virtue's validation
//& sanitization lib.
var user = {
name : [ purity.isString ], //Simple validation that the
//name is a string.
email : [ purity.trim, purity.isString, purity.isEmail ],
authmethods : [
{ type: 'facebook',
id: '12304912835812304192384'
token : 'asd0fa0sd9fasjdlfasdf9as0d98fasd',
salt: '1029384as0d9fasd8fasdf09asdf8as0df9as8dfasdf0asd9',
data: {...}
},
{
type: 'password',
function findMostRecent(folder){
var mostRecent = null
var contentList = getFolderContentList(folder.path);
for(var i = 0; i < contentList.length; ++i){
if(contentList[i].type === 'file' &&
(mostRecent === null || contentList[i].date > mostRecent.date)){
mostRecent = contentList[i];
var user = {
name : [ purity.isString ], //Simple validation that the
//name is a string.
email : [ purity.trim, purity.isString, purity.isEmail ],
age : [ purity.isNumber, purity.greater(0), purity.toInt ],
//Array of friends
var validation = require( './validation' );
var v = require('./validators' );
function lowerCase( value, err ){
return value.toLowerCase();
}
var userSchema = {
firstname : [ v.trim() ],
lastname : [ v.trim() ],
{
file: < the file>
name: filename
hook: {
name : "user_avatar",
userid : "09a8019238402a9sdfsa0",
}
}