Skip to content

Instantly share code, notes, and snippets.

function isMasterRunning() {
var pidFilePath = path.join(__dirname, 'ds.pid');
var strpid;
var isRunning;
if (fs.existsSync(pidFilePath)) {
strpid = fs.readFileSync(pidFilePath, 'utf-8');
isRunning = require('is-running')(parseInt(strpid, 10));
}
if (isRunning) {
return strpid;
var routeProto = require('express/lib/router/route').prototype;
var routerProto = require('express/lib/router');
var methods = require('express/node_modules/methods').concat(['all']);
wrapCallback = function (c) {
return c;
}
methods.forEach(function (method) {
var orig = routeProto[method];
routeProto[method] = function () {
var callbacks = utils.flatten([].slice.call(arguments));
'use strict';
var http = require('http');
var request = require('request');
var nth = require('co-nth-arg');
var _ = require('lodash');
module.exports = function (propName, options) {
propName = propName || 'api';
var co = require('co');
var thunkify = require('thunkify');
var asyncMath = function (list, cb) {
setTimeout(function () {
cb(null, Math.max.apply(Math, list), Math.min.apply(Math, list));
}, 500);
};
function binary(fn) {
var express = require('express');
var hasBody = require('express/node_modules/connect').utils.hasBody;
var getBody = require('express/node_modules/connect/node_modules/raw-body');
var app = express();
app.use(express.static(__dirname));
app.post('/enter', express.urlencoded(), function (req, res, next) {
if (req.body.wifi) console.log('"' + (new Date).toGMTString() + '","enter","'+req.body.wifi+'"');
next();
});
app.post('/leave', express.urlencoded(), function (req, res, next) {
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
</body>
</html>
# Use vim keybindings in copy mode
setw -g mode-keys vi
# Setup 'v' to begin selection as in Vim
bind-key -t vi-copy v begin-selection
bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"
# Update default binding of `Enter` to also use copy-pipe
unbind -t vi-copy Enter
bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"
'use strict';
var http = require('http');
var apiproxy = require('express-apiproxy');
var reqProto = require('express/lib/request');
var resProto = require('express/lib/response');
reqProto.__defineGetter__('uest', function(){
return this._uest ? this._uest : this._uest = apiproxy(this, {
'use strict';
exports.prependHost = prependHost;
function prependHost(url, host) {
host = host || 'backend';
if ('/' != url[0]) url = '/' + url;
return config.url[host] + url;
}
exports.getSession = getSession;
@undoZen
undoZen / post-commit.sh
Created January 23, 2014 09:32
post-commit
#!/bin/sh
unset GIT_DIR
git stash | grep -q 'No local changes'
RETVAL=$?
grunt
git add -A public/
git commit -m '[post-commit] static files generated by grunt'
[ $RETVAL -ne 0 ] && git stash pop