Skip to content

Instantly share code, notes, and snippets.

View ovaillancourt's full-sized avatar

Olivier Vaillancourt ovaillancourt

  • Montreal, QC, Can
View GitHub Profile
var steps = [
function step1(){
console.log('step1');
this();
},
function step2(){
console.log('step2');
this();
@ovaillancourt
ovaillancourt / gist:1391476
Created November 24, 2011 14:34
Correct base64 encoded html mail received on gmail
Return-Path: <olivaillancourt@gmail.com>
Received: from Olivier-Vaillancourts-MacBook-Pro.local (bas1-montreal48-1176433004.dsl.bell.ca. [70.30.241.108])
by mx.google.com with ESMTPS id k4sm26729745vdu.2.2011.11.23.18.13.46
(version=SSLv3 cipher=OTHER);
Wed, 23 Nov 2011 18:13:47 -0800 (PST)
Date: Wed, 23 Nov 2011 18:13:47 -0800 (PST)
message-id: <1322100825061.7618@Olivier-Vaillancourts-MacBook-Pro.local>
from: Keaton Row <olivaillancourt@gmail.com>
to: olivier@keatonrow.com
subject: Thank you for submitting!
@ovaillancourt
ovaillancourt / gist:1391472
Created November 24, 2011 14:33
Broken email received on webfaction, sent through emailjs with base64 encoding.
Return-Path: <olivaillancourt@gmail.com>
X-Original-To: oliviervaillancourt@mailbox7.webfaction.com
Delivered-To: oliviervaillancourt@mailbox7.webfaction.com
Received: from mx8.webfaction.com (mail8.webfaction.com [174.133.21.100])
by mailbox7.webfaction.com (Postfix) with ESMTP id 5EC55137B240
for <oliviervaillancourt@mailbox7.webfaction.com>; Wed, 23 Nov 2011 20:13:57 -0600 (CST)
Received: from localhost (localhost.localdomain [127.0.0.1])
by mx8.webfaction.com (Postfix) with ESMTP id 94722C40080;
Wed, 23 Nov 2011 20:13:56 -0600 (CST)
X-Spam-Flag: NO
@ovaillancourt
ovaillancourt / message.js
Created November 24, 2011 17:50
Modifications to message.js for chunks
var stream = require('stream');
var util = require('util');
var fs = require('fs');
var os = require('os');
var path = require('path');
var CRLF = "\r\n";
var counter = 0;
var generate_boundary = function()
{
@ovaillancourt
ovaillancourt / gist:1402035
Created November 28, 2011 21:00
remoteAddress not being set...
if(typeof req.header('x-forwarded-for') !== 'undefined')
{
req.socket.remoteAddress = req.header('x-forwarded-for');
console.log(req.header('x-forwarded-for'));
console.log(req.socket.remoteAddress);
}
-----------------------
@ovaillancourt
ovaillancourt / poopinheritance.js
Created December 7, 2011 23:01
Poopy inheritance
Base = function(name){
this.name = name;
}
Child = function(){
Base.call(this,'ImAchild');
}
Child.prototype = new Base();
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var dbUrl = 'DB_URL HERE';
//Initialize mongoose
var mongoose = require('mongoose');
mongoose.connect(
@ovaillancourt
ovaillancourt / staticWrapper.js
Created March 24, 2012 17:55
Wrapping the static mw to add a custom header entry.
var myStatic = express.static(__dirname + '/my/static/path');
app.use(function(req,res,next){
//We set the custom header here.
res.setHeader('My-header-name','my-header-value');
//We call the static middleware here, if the middleware calls "next", it means
//it didn't serve the file so we replace the static mw's "next" with a custom
//function that removes the header entry and calls the real "next" from the
//wrapper. This ensure we don't pollute subsequent middleware/route's response
//with that custom header.
@ovaillancourt
ovaillancourt / FixingStuffs.js
Created March 29, 2012 17:48
Super-transport-code-not-populating
var mongoose = require('mongoose')
,Schema = mongoose.Schema;
var BusStop = require('./BusStop.js');
var BusScheduleSchema = require('./BusSchedule.js').schema;
var BusStopSchema = BusStop.schema;
var RouteRateSchema = require('./RouteRate.js').schema;
var StopEntrySchema = new Schema({
order: {type: Number, min:0, required: true}
@ovaillancourt
ovaillancourt / gist:2291867
Created April 3, 2012 13:09
getting indexes in mongodb shell.
use <databasename>
db.<collectionname>.getIndexKeys()