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 / DynamicBinderExtensions.cs
Last active August 16, 2018 11:03 — 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 …
public static class DynamicBinderExtensions
{
public static dynamic DynaBind(this INancyModule module)
{
return module.Bind<DynamicDictionary>();
}
}
@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:
/*jslint node: true */
"use strict";
module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-msbuild');
grunt.loadNpmTasks('grunt-aspnet-server');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-iisexpress');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.loadNpmTasks('grunt-contrib-jshint');
@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 / 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">