Skip to content

Instantly share code, notes, and snippets.

Avatar
⌨️
coding

Emanuele DelBono emadb

⌨️
coding
View GitHub Profile
@emadb
emadb / fb_test.rb
Created Dec 23, 2011
Get facebook group thread using fb_graph gem
View fb_test.rb
my_app = FbGraph::Application.new(ENV['app_id']);
acc_tok = my_app.get_access_token(ENV['token']);
group = FbGraph::Group.new('270489496319056', :access_token => acc_tok).fetch;
puts @group.to_yaml
#@group.feed.each{|e| puts e.to_yaml}
post = group.feed[0]
@emadb
emadb / gist:5525652
Last active Dec 17, 2015
Come cacchio funziona!! Perchè complete non viene mai eseguito??
View gist:5525652
var async = require('async');
var functions = [];
functions.push(function(){ console.log("1"); return test1(1); });
functions.push(function(){ console.log("2"); return test1(2); });
functions.push(function(){ console.log("3"); return test1(3); });
async.parallel(functions, function(err, result){
console.log('complete', result);
@emadb
emadb / DynamicBinderExtensions.cs
Last active Aug 16, 2018 — forked from thecodejunkie/DynamicModelBinder.cs
A DynamicModelBinder for NancyFx (http://nancyfx.org/). It convert your request data (form, body, querystring) into a dynamic model. This means that you don't have to create all your useless DTO. NOTE. The original version is here https://gist.github.com/thecodejunkie/5521941 (thecodejunkie). I simply add the support for deserialize the request …
View DynamicBinderExtensions.cs
public static class DynamicBinderExtensions
{
public static dynamic DynaBind(this INancyModule module)
{
return module.Bind<DynamicDictionary>();
}
}
View gist:7245878
conn.beginTransaction( function( err ) {
//..
});
conn.queryRaw( "INSERT INTO test_txn (name) VALUES ('Anne')", function( err, results ) {
//..
});
conn.queryRaw( "INSERT INTO test_txn (name) VALUES ('Bob')", function( err, results ) {
//..
View speaker.md
View gist:10735529
{
"commitId" : LUUID("556fb777-2cf3-e34d-9f34-88caad42c0be"),
"timestamp" : ISODate("2013-11-21T14:59:10.314Z"),
"aggregateId": "65dbab54-afd0-477b-a5fb-686cc90f7aff",
"events" : [
{
"eventName" : "item_added",
"args": ["1", "10"]
},
{
View berlin_clock.rb
class BerlinClock
SECONDS = "Y"
HOURS_FIVES = "RRRR"
HOURS_ONES = "RRRR"
MINUTES_FIVES = "YYRYYRYYRYY"
MINUTES_ONES = "YYYY"
def initialize(h,m,s)
@h, @m, @s = h, m, s
end
@emadb
emadb / gist:38cf4c94ac858382300c
Created Jun 16, 2014
Javascript refactoring
View gist:38cf4c94ac858382300c
function mouseup(evt) {
if (_isDD) {
return;
}
if (evt.shiftKey == true) {
var indexOf1 = this.cont.list.indexOf(_lastItemSelected);
var indexOf2 = this.cont.list.indexOf(this);
for (var i = indexOf2; i > indexOf1; i--) {
var item = this.cont.list[i];
View fizzbuzz.js
module.exports = (function() {
var fizzFun = function(n){
if (n % 3 == 0)
return 'fizz';
};
var buzzFun = function(n){
if (n % 5 == 0)
return 'buzz';
@emadb
emadb / gist:1354b4fa365997746168
Created Oct 28, 2014
Spot the bug! Why doesn't doSomething print "new function"
View gist:1354b4fa365997746168
function MyObject(fun){
this.fun = fun;
}
MyObject.prototype.doSomething = function() {
this.fun();
};
var f = function (){console.log('Original function')};