This file contains hidden or 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 myextend(/* args */){ | |
var o = {} | |
, args = Array.prototype.slice.call(arguments) | |
, obj = args.shift() | |
, src = args.shift(); | |
for (var p in src){ | |
if (src.hasOwnProperty(p)){ | |
if (hasOwn.call(obj,p) && typeof obj[p] === 'object' && obj[p] !== null) { | |
o[p] = myextend(obj[p],src[p]); |
This file contains hidden or 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
/* | |
fileExistSync - Check if a file exist in NodeJS | |
Twitter: @FGRibreau / fgribreau.com | |
Usage: | |
var fileExistSync = require('./fileExistSync'); | |
var exist = fileExistSync('/var/folders/zm/jmjb49l172g6g/T/65b199'); | |
Support for Nodev0.6 |
This file contains hidden or 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 extractArgs(str){ | |
var args = [], buff = '', idx = -1, insideQuote = false, lgth = str.length; | |
function next(){return str.charAt(++idx);} | |
function peak(){return str.charAt(idx+1);} | |
function resetState(){insideQuote = false;buff = '';} | |
while(idx < lgth){ | |
var c = next(); |
This file contains hidden or 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
node_modules |
This file contains hidden or 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
/* Inside grunt.js file (don't forget to add "growl" as a project dependency) */ | |
grunt.utils.hooker.hook(grunt.fail, "warn", function(opt) { | |
require('growl')(opt.name, { | |
title: opt.message, | |
image: 'Console' | |
}); | |
}); | |
This file contains hidden or 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
/* | |
* Fix the "Could not decode a text frame as UTF-8." bug #socket.io #nodejs #websocket | |
* | |
* Usage: | |
* cleanedString = filterUnicode(maybeHarmfulString); | |
* | |
* Original work-around from SockJS: https://github.com/sockjs/sockjs-node/commit/e0e7113f0f8bd8e5fea25e1eb2a8b1fe1413da2c | |
* Other work-around: https://gist.github.com/2024272 | |
* | |
*/ |
This file contains hidden or 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
#!/usr/bin/env sh | |
## | |
# This is script with usefull tips taken from: | |
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
# | |
# install it: | |
# curl -sL https://raw.github.com/gist/2262723/hack.sh | sh | |
# |
This file contains hidden or 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
// | |
// The following snippet must be inserted at the top of your main js file | |
// | |
process.title = "myapp"; | |
var PID_FILE = "/usr/local/var/run/"+process.title+".pid" | |
, fs = require('fs'); | |
fs.writeFileSync(PID_FILE, process.pid+"\n"); |
This file contains hidden or 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
array(21) { | |
[0]=> | |
object(PHPParser_Node_Expr_Assign)#6 (3) { | |
["subNodes":protected]=> | |
array(2) { | |
["var"]=> | |
object(PHPParser_Node_Expr_ArrayDimFetch)#4 (3) { | |
["subNodes":protected]=> | |
array(2) { | |
["var"]=> |
This file contains hidden or 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
// | |
// Usage: require('./pid')("myapp"); | |
// | |
var fs = require('fs'); | |
module.exports = function(appname){ | |
process.title = appname; | |
var PID_FILE = "/usr/local/var/run/"+process.title+".pid"; |