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
// What name can I refer to ? | |
app.get('/hello-world', function () { console.log(3); }); | |
// OK, suppose I can build the path from params | |
app.get('/:id/:name', function hello1 () { console.log(1); }); | |
// OK, suppose the "callback" is the last one | |
app.get('/hello/:name', requiresAuthentication, function hello2 () { console.log(2); }); | |
// How do I build the path ? |
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 io = require('socket.io').listen(8123); | |
io.sockets.on('connection', function (socket) { | |
socket.on('username', function (username) { | |
this.set('username', username, function () { | |
socket.broadcast.emit('newcomer', username); | |
socket.emit('ready', username); | |
}); | |
}); |
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
library(igraph) | |
library(reshape) | |
library(plyr) | |
require(RJSONIO) | |
require(RCurl) | |
# Google Spreadsheet key (must be published to the web) | |
key='0AqGkLMU9sHmLdGNYZDVyTWl1ZmtNbmFzWGlpUkt1Tmc' | |
# Sheet gid name | |
gid=105 |
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
# Retrieve repository URL | |
function svn-url() { | |
LANG=en_US svn info "$1" | grep '^URL *:' | sed 's/^URL *: //' | |
} | |
# Branching | |
function svn-branch() { | |
if [ ! -d .svn ]; then return 1; fi | |
if svn-url | grep '/trunk' &> /dev/null; then | |
echo trunk |
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 str_char_code(c) { | |
return c.charCodeAt ? c.charCodeAt(0) : parseInt(c, 10); | |
} | |
function cb_between(min, max) { | |
return function (v) { | |
return v >= min && v <= max; | |
}; | |
} |
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
Show hidden characters
[ | |
{ "keys": ["ctrl+k", "ctrl+i"], "command": "gist" }, | |
{ "keys": ["ctrl+k", "ctrl+l"], "command": "gist_private" }, | |
{ "keys": ["ctrl+k", "ctrl+s"], "command": "gist_update_file" }, | |
{ "keys": ["ctrl+shift+g"], "command": "gist_list" } | |
] |
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
# I didn't look, but I'm even pretty sure there is a dedicated command for this with Git. | |
# and this is just a piece of cake, 5 minutes max to implement this... | |
# Edit - actually, you can simply call this: | |
# git ls-files --others --ignored --exclude-standard | |
find -name .gitignore | while read f | |
do | |
d="$(dirname "$f")" | |
cat $f | while read p |
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.prototype.argNames = function () { | |
// Extract function string representation: hopefully we can count on it ? | |
var s = this.toString(); | |
// The cool thing is: this can only be a syntactically valid function declaration | |
s = s // "function name (a, b, c) { body }" | |
.substring( // "a, b, c" | |
s.indexOf('(')+1, // ----------------^ | |
s.indexOf(')') // ------^ | |
); |
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
<?php | |
// Works in every situations | |
function by_token ($src) { | |
$tokens = token_get_all($src); | |
$count = count($tokens); | |
$i = 0; | |
$namespace = ''; | |
$namespace_ok = false; | |
while ($i < $count) { |
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 foo_uncached($args) | |
{ | |
$result = big_calculations(); | |
return $result; | |
} | |