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
1- If a <base> tag exists, use this as the base path, or the "mount point" by default.
The mount point defaults to '' if the base tag isn't there.
2- If the user calls page.base, override the mount point extracted in point 1.
3- Always prepend the mount point.
var hogan = require('hogan.js');
var t = hogan.compile('{{<super}}{{$title}}sub template title{{/title}}{{/super}}');
var s = hogan.compile('...{{$title}}Default title{{/title}}...');
var o = t.render({}, {"super": s});
console.log(o);
var cfg = require('kr-common').config;
var express = require('express');
var app = express.createServer();
var fs = require('fs');
//Html bundler
app.use(require('./server/htmlBundler')({
dirs : [ __dirname + '/static/templates',
{path: __dirname + '/static/templates/controls', namespace: 'controls'}
var mongoose = require('mongoose');
mongoose.connect("yourServerUrlHere", function(err){
if(err){
console.log("Error connecting:",err);
}
else{
console.log('connected!');
}
});
@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>
//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(){
var proxyServer = require('http-proxy').createServer({
router: {
"mydomain.com/rest" : "targetMachine:port"
}
});
proxyServer.listen(myPort);
var app = express()
, http = require('http');
http.createServer(app).listen(80, '127.0.0.1');
http.createServer(app).listen(80, '::1');
describe('when the route matches', function(){
it('should invoke the callback', function(done){
page('/user', function(ctx){
done();
})
page.show('/user?test=true');
})
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.';