Skip to content

Instantly share code, notes, and snippets.

View FGRibreau's full-sized avatar
✍️
writing "#NoBullshit Tech-Lead" book https://getnobullshit.com

Francois-Guillaume Ribreau FGRibreau

✍️
writing "#NoBullshit Tech-Lead" book https://getnobullshit.com
View GitHub Profile
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'}});
@FGRibreau
FGRibreau / most_used_url_shortener.js
Created March 31, 2011 17:28
Most used url shortener
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/",
@FGRibreau
FGRibreau / LanguageDetect_Example.js
Created July 18, 2011 09:33
NodeJS - Language Detection
/*
Installation:
npm install languagedetect -g
*/
var LanguageDetect = require('languagedetect');
var lngDetector = new LanguageDetect();
/*
OR
@FGRibreau
FGRibreau / jquery.extend.js
Created August 1, 2011 20:00
jQuery extend for NodeJS / Object & Array Deep Copy for NodeJS
/*
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});
@FGRibreau
FGRibreau / blog_amqpdsl.coffee
Created December 15, 2011 09:45
AMQP-DSL example
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")
@FGRibreau
FGRibreau / gist:1678749
Created January 25, 2012 21:12 — forked from loginx/gist:810311
Underscore.js mixin to emulate ruby's Array#each_slice method.
/**
* 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(){};
@FGRibreau
FGRibreau / redis.coffee
Created February 7, 2012 21:08
Node-redis - auto-reconnect
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()
@FGRibreau
FGRibreau / output.php
Created February 22, 2012 19:21
Testing PHP-Parser
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"]=>
@FGRibreau
FGRibreau / hack.sh
Created March 31, 2012 11:48 — forked from erikh/hack.sh
OSX For Hackers
#!/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
#
/*
* 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
*
*/