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
//https://github.com/jdub/node-twitter/ | |
var twitter = require('twitter'), | |
sys = require('sys'); | |
var twit = new twitter({ | |
consumer_key: 'YOUR KEYS', | |
consumer_secret: 'YOUR KEYS', | |
access_token_key: 'YOUR KEYS', | |
access_token_secret: 'YOUR KEYS' | |
}); |
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
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 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
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 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
/* | |
Installation: | |
npm install languagedetect -g | |
*/ | |
var LanguageDetect = require('languagedetect'); | |
var lngDetector = new LanguageDetect(); | |
/* | |
OR |
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
/* | |
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 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
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 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
/** | |
* 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 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
// Ruby = 5.times { |i| puts i } | |
// JS = (1).times(function(i){console.log(i);}) | |
Number.prototype.times = function(cb) { | |
var i = -1; | |
while (++i < this) { | |
cb(i); | |
} | |
return +this; |
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
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 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"; |