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 / Main.cs
Last active March 4, 2023 22:39
Validation and domain
// Controller HTTP
public class Controller
{
public UserResponse Post(UserRequest req)
{
User user = createUserValidator.Validate(req);
// Fino a qui sono nel contesto HTTP
// Qui entro nel dominio. Forse sarebbe meglio usare un gateway per accedere al dominio
// ma dipende dal tipo di applicazione.
@emadb
emadb / foo.exs
Last active January 20, 2020 16:35
Tramp data in Elixir
defmodule Foo do
def execute_command(data, coeff) do
data = prepare_data(data, coeff)
persist(data.name, coeff)
end
def prepare_data(data, coeff) do
w = calculate_w(data.x, data.y, data.z, coeff)
%{
name: "foo",
@emadb
emadb / fizzbuzz.cs
Created November 7, 2019 09:05
Fizzbuzz
using System;
using System.Linq;
using System.Collections.Generic;
namespace CodicePlastico
{
public class FizzBuzz
{
private static readonly IDictionary<int, string> _cases = new Dictionary<int, string>
{
{3, "fizz"},
@emadb
emadb / fizz_buzz.exs
Last active August 8, 2019 09:38
FizzBuzz in Elixir using only functions: no numbers, no strings, no loops and no ifs!
defmodule Church do
def fizzbuzz do
(fn k -> fn f -> ((fn f -> (fn x -> f.(fn y -> x.(x).(y) end) end).(fn x -> f.(fn y -> x.(x).(y) end) end) end).(
fn f -> fn l -> fn x -> fn g ->
(fn b -> b end).((fn p -> p.(fn a -> fn b -> a end end) end).(l)).(x).(fn y -> g.(f.((fn l -> (fn p -> p.(fn a -> fn b -> b end end) end)
.((fn p -> p.(fn a -> fn b -> b end end) end).(l)) end).(l)).(x).(g)).((fn l -> (fn p -> p.(fn a -> fn b -> a end end) end)
.((fn p -> p.(fn a -> fn b -> b end end) end).(l)) end).(l)).(y) end)
end end end end
)).(k).((fn x -> fn y -> fn f -> f.(x).(y) end end end).(fn x -> (fn y -> x end) end).(fn x -> (fn y -> y end) end))
@emadb
emadb / Dispatcher.js
Last active October 10, 2017 16:48
medium - react and redux
const dispatcher = {
subscribers: [],
register(subscriber) {
this.subscribers.push(subscriber)
},
dispatch(action) {
this.subscribers.forEach(s => s(action))
}
}
### Keybase proof
I hereby claim:
* I am emadb on github.
* I am emadb (https://keybase.io/emadb) on keybase.
* I have a public key whose fingerprint is 8F39 3A1D 85DC 83C7 B8C8 BDDE B295 AE38 057C 4B76
To claim this, I am signing this object:
@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
@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
Verifying that +emanueledelbono is my blockchain ID. https://onename.com/emanueledelbono
test