Skip to content

Instantly share code, notes, and snippets.

View emadb's full-sized avatar
⌨️
coding

Emanuele DelBono emadb

⌨️
coding
View GitHub Profile
@emadb
emadb / async kata
Last active August 29, 2015 14:24
Kata - synchronize asyncrounous results
Consider to have a series of calculators functions that need to run in series.
These calculators are asynchronous and any of those can return a value (a number >=0) or an error (-1).
Calculators must be evaluated in order and you have to write a function that returns the value of the first calculator
that doesn't fail. For first I mean the first in the chain of calculators.
Test case
function calculator1(resultCallback){
setTimeout(function(){ resultCallback(-1) }, 1000);
}
@emadb
emadb / Sample.cs
Last active August 29, 2015 14:25
Run a set of tasks and wait for the first (in run order) that succeed
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
@emadb
emadb / fb_test.rb
Created December 23, 2011 22:00
Get facebook group thread using fb_graph gem
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 December 17, 2015 00:59
Come cacchio funziona!! Perchè complete non viene mai eseguito??
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);
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 ) {
//..
test
Verifying that +emanueledelbono is my blockchain ID. https://onename.com/emanueledelbono
@emadb
emadb / SublimeText_shortcuts.md
Created May 20, 2016 13:21
Sublime Text Shorcuts

##Text Editing

  • Insert line before - Cmd + Shift + Return
  • Insert line after - Cmd + Return
  • Delete the word backward - Option + Delete
  • Delete the word forward - fn + Option + Delete
  • Delete to beginning of the line - Cmd + Delete
  • Delete to end of the line - Ctrl + K
  • Delete word back - Option + Delete
  • Delete word forward - fn + Option + Delete
  • Soft undo - Cmd + U
@emadb
emadb / index.html
Last active September 15, 2016 09:20
JS Bin - Reactjs bootstrap modal example // source http://jsbin.com/gucuvu/6/edit?html,js,output
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Reactjs bootstrap modal example">
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.1/JSXTransformer.js"></script>
<script src="http://code.jquery.com/jquery.min.js"></script>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<script src="http://fb.me/react-with-addons-0.12.2.js"></script>
<meta charset="utf-8">
@emadb
emadb / eslint.config.js
Last active October 28, 2016 14:21
My Eslint configuration
{"rules": {
// https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb
/* best practices */
"accessor-pairs": 0,
// enforces return statements in callbacks of array's methods
// http://eslint.org/docs/rules/array-callback-return
"array-callback-return": 2,
// treat var statements as if they were block scoped
"block-scoped-var": 2,
// specify the maximum cyclomatic complexity allowed in a program