Skip to content

Instantly share code, notes, and snippets.

View ppalludan's full-sized avatar
🤠
working

Peter Palludan ppalludan

🤠
working
  • Truelinked and Humentech
  • Copenhagen, Denmark
View GitHub Profile
var http = require('http')
, path = require('path')
, connect = require('connect')
, express = require('express')
, app = express()
, cookieParser = require('cookie-parser')
, session = require('express-session')
, sessionStore = new session.MemoryStore()
, logger = require('morgan')
, bodyParser = require('body-parser')
@ppalludan
ppalludan / Singleton-run-once
Last active August 29, 2015 14:15
Implemention of a "run once" function, so that I can invoke a given method like crazy, and the method is only invoked once
var Singleton = {
_threads : [],
process: function (name, callback) {
var evt = this._threads[name];
if (evt == null) {
evt = this._threads[name] = { name : name };
}
if (evt.running) {
evt.que = true;
return;