Skip to content

Instantly share code, notes, and snippets.

View brendanmoore's full-sized avatar

Brendan Moore brendanmoore

View GitHub Profile
@brendanmoore
brendanmoore / gist:3293598
Last active October 8, 2015 06:39
first draft namespaced event emitter
/**
* This is NOT DOM events (click, mouseover, touchend, etc...)
* This is custom events, which can be bound to anything.
*/
var ee = function(){};
//bind function to event
ee.prototype.on = function(key, fn){
//if not function, bail
if(typeof fn !== 'function'){ return false; }
@brendanmoore
brendanmoore / map.js
Created April 8, 2014 09:41 — forked from remy/map.js
function map(x, in_min, in_max, out_min, out_max) {
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
@brendanmoore
brendanmoore / Secure Sessions Howto
Created August 16, 2016 22:00 — forked from nikmartin/A: Secure Sessions Howto
Secure sessions with Node.js, Connect, and Nginx as an SSL Proxy
Secure sessions are easy, but it's not very well documented, so I'm changing that.
Here's a recipe for secure sessions in Node.js when NginX is used as an SSL proxy:
The desired configuration for using NginX as an SSL proxy is to offload SSL processing
and to put a hardened web server in front of your Node.js application, like:
[NODE.JS APP] <- HTTP -> [NginX] <- HTTPS -> [CLIENT]
To do this, here's what you need to do: