This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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, { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |