Skip to content

Instantly share code, notes, and snippets.

View coiscir's full-sized avatar

Jonathan Lonowski coiscir

View GitHub Profile
@coiscir
coiscir / _repos.sh
Last active August 29, 2015 13:58
Find and cautiously update multiple git repositories. Base: http://stackoverflow.com/q/11981716/15031
#!/bin/bash
# Update all git repositories under the current or specified directory
OPTIND=1
usage=0
list=0
update=0
forced=0
@coiscir
coiscir / Singletons.md
Last active September 20, 2022 23:18
JavaScript Singletons

From http://stackoverflow.com/a/15196301/:

p.s. i'll be glad to hear you solution to my other question stackoverflow.com/questions/15274927/…. ( maybe you have a better solution). Royi Namir 2013-03-08 07:03:32Z

The answers do include good examples of both eagerly-loaded/instant (e.g., jantimon, SLaks) and lazy-loaded singletons (e.g., Kolink).

Though, for a few variations on lazy-loaded: :)

It is possible to return the instance (single-instance-constructor.js) each time, but this will probably be confusing unless [it's not actually new](http://jsfiddle.net/cois

@coiscir
coiscir / README.md
Created December 10, 2012 02:37
Express Routing

An idea for defining routes for Express applications in Objects of paths, (optional) verbs, then handlers:

var express = require('express');
var routing = require('./routing');
var app = express();

routing(app, {
  // `get` only
 '/': function (req, res) {