Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Tom Medema tommedema

🎯
Focusing
View GitHub Profile
View mongodb.conf
# Mongodb upstart file at /etc/init/mongodb.conf
description "Runs mongod server daemon as service."
start on runlevel [2345]
stop on runlevel [06]
respawn
respawn limit 10 100
View gist:2819768
@version: 3.0
source s_system {
internal();
unix-stream("/dev/log");
file("/proc/kmsg" program_override("kernel: "));
file("/var/log/daemon.log" follow_freq(1) flags(no-parse));
file("/var/log/dpkg.log" follow_freq(1) flags(no-parse));
};
source s_mongo {
View gist:2815209
var should = require('should'),
srcd = process.cwd() + '/src',
rd = srcd + '/routines',
runner = require(rd + '/server/runner'),
configurer = require(rd + '/server/configurer'),
creator = require(rd + '/server/creator'),
EventEmitter2 = require('eventemitter2').EventEmitter2,
config = require(srcd + '/config'),
express = require('express');
View gist:2805210
var cluster = require('cluster'),
nrCPUs = require('os').cpus().length;
//when we are the master
if (cluster.isMaster) {
//fork workers (one for each CPU)
for (var i = 0; i < nrCPUs; i++) {
spawnWorker();
}
View gist:2787668
app.get('*', function(req, res) {
req.once('end', function() {
require('util').debug('!!! THIS NEVER FIRES, req: ' + req.url);
});
res.writeHead(404);
res.end('My apologies, the request you performed cannot be answered (404). Please check for possbile typing errors.');
View gist:2783531
module.exports = function(mediator) {
var express = require('express');
mediator.once('boot.ready', function() {
var server = express.createServer();
//event: server created
process.nextTick(function() {
@tommedema
tommedema / eepatcher-test.js
Created May 21, 2012
monkey patches eventemitter (2) with .onceall function, see test for usage
View eepatcher-test.js
var EventEmitter2 = require('eventemitter2').EventEmitter2,
EEPatcher = require('../../src/util/eepatcher')(EventEmitter2),
util = require('util'),
should = require('should'),
emitter = new EventEmitter2({
wildcard: false
});
describe('eepatcher', function() {
@tommedema
tommedema / db connector improved.js
Created May 20, 2012
annotated mongodb node.js driver replicaset connection example, please read the comments
View db connector improved.js
module.exports = function(mediator) {
var mongo = require('mongodb'),
Server = mongo.Server,
Db = mongo.Db,
ReplSet = mongo.ReplSet,
config = require('../../config'),
replSetName = config.mongo.rsname,
servers = config.mongo.servers,
dbName = config.mongo.dbname;
View gist:2695093
deploy-git:
status=$$(git status --porcelain) \
echo $${status}
View deploygit.sh
#!/bin/sh
######################################################
# Deploys working repository to git deployment branch
######################################################
#get the status of the working repository
status=`git status --porcelain`
#check if the working repository is clean