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 myFunction = function(dataArray){ | |
// Do something with these data (ajax ?) | |
console.log('Debounced arguments:', dataArray); | |
} | |
var myDebouncedFunction = $.debounceargs(5000, myDebouncedFunction); | |
myDebouncedFunction({model:'post', action:'save', data:[1,2,3,4]}); | |
myDebouncedFunction({model:'comment', action:'add', data:{text:'hello world', author:'anonymous'}}); |
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 urls = ["http://bit.ly/", | |
"http://tinyurl.com/", | |
"http://is.gd/", | |
"http://tr.im/", | |
"http://ow.ly/", | |
"http://cli.gs/", | |
"http://u.mavrev.com/", | |
"http://twurl.nl/", | |
"http://tiny.cc/", | |
"http://digg.com/", |
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
/* | |
Installation: | |
npm install languagedetect -g | |
*/ | |
var LanguageDetect = require('languagedetect'); | |
var lngDetector = new LanguageDetect(); | |
/* | |
OR |
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
/* | |
jQuery.extend extracted from the jQuery source & optimised for NodeJS | |
Twitter: @FGRibreau / fgribreau.com | |
Usage: | |
var Extend = require('./Extend'); | |
// Extend | |
var obj = Extend({opt1:true, opt2:true}, {opt1:false}); |
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
require('amqp-dsl') | |
.login( | |
login: 'legen' | |
password: 'dary' | |
) | |
# Bind listeners to some events (available events are `close`, `error` and `ready`) | |
.on('close', () -> console.error "RabbitMQ connection closed") | |
.on('error', (err) -> console.error "RabbitMQ error", err) | |
.on('ready', () -> console.log "Connected to RabbitMQ") |
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
/** | |
* Underscore.js mixin to emulate Ruby's Enumerable#each_slice method. | |
* http://www.ruby-doc.org/core/classes/Enumerable.html#M001514 | |
* | |
*/ | |
_.mixin({ | |
// _.each_slice(obj, slice_size, [iterator], [context]) | |
each_slice: function(obj, slice_size, iterator, context) { | |
var collection = obj.map(function(item) { return item; }), o = [], t = null, it = iterator || function(){}; |
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
redis = require("redis") | |
cli = null | |
# 1/ Helpers | |
RedisOnConnected = (err, redis) -> | |
# Update the global reference to the redis client | |
cli = redis | |
RedisDoConnect = (cbConnected) -> | |
client = require("redis").createClient() |
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
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 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 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 | |
* | |
*/ |