Instantly share code, notes, and snippets.

# Benjamin Dreux benzen

Last active February 17, 2016 03:49
Maybe the samllest flux implementation ever
This file contains 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
 //utilitary functions const find = (pred, coll) => { for(const item of coll){ if(pred(item)){ return item; } } return null; };
Last active November 5, 2015 19:10 — forked from fxg42/exercices.js
Exercices
This file contains 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
 // # Exercice 1: // Étant données les deux fonctions suivantes: // f :: a -> [b] var f = (a) => [ a * a ]; // g :: a -> [b] var g = (a) => [ a + 10 ];
Created September 26, 2015 00:09
This file contains 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
 let render = render || function(){ React.render( , document.getElementById('app')); }; setInterval( function(){ requestAnimationFrame(render);
Created September 24, 2015 23:53
This file contains 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

Created September 20, 2015 20:52
This file contains 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
 (ns our-child.devcards (:require [reagent.core :as rg] [devcards.core :as dc]) (:require-macros [devcards.core :as dc :refer [defcard defcard-doc deftest dom-node]])) (dc/defcard string-card (str "## **string** type will render as markdown."))
Created September 20, 2015 20:44
This file contains 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
 (deftask devcards [] (comp (serve :dir "frontend/target/") (watch) (speak) (cljs :unified true :source-map true :optimizations :none :compiler-options { :main "our-child.devcards"
Created September 6, 2015 22:27
Une impression de déjà vue ici
This file contains 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
 cheerio = require "cheerio" superagent = require "superagent" async = require "async" _ = require "lodash" BOY_URLS = [ "http://www.mamanpourlavie.com/prenoms/lettre/a/garcon", "http://www.mamanpourlavie.com/prenoms/lettre/b/garcon", "http://www.mamanpourlavie.com/prenoms/lettre/c/garcon", "http://www.mamanpourlavie.com/prenoms/lettre/d/garcon", "http://www.mamanpourlavie.com/prenoms/lettre/e/garcon",
Last active September 6, 2015 11:22
Rookie mistake with local state

Theses are two implmentation of the same components. The component is a label, with two button, one to increase the counter, and one to decrease.

The counter's value can't go bellow zero.

In the first implmentation, there is a tiny bit of logic that is miss placed. This logic is executed when the component is rendered. This is bad because the effect of this logic will never appear.

On the second implementaition the "previous-value" is computed with a corrected value (min 0).

Last active August 29, 2015 14:17
Highland vs Async
This file contains 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
 async = require 'async' findClient = (clientsColl, clientId, cb) -> clientsColl.findOne _id: new ObjectID(clientId), cb findProjetsByClient = (clientId, cb) -> projetsModule.find client: new ObjectID(clientId), cb joinClientAndProjetsIds = (client, projetsIds, cb) -> client.projets = projetsIds cb null, client async.auto
Created November 22, 2010 14:29
cesear kata
This file contains 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
 (defn convert [number] "Convert a number between 50 and 0 to it's roman representation" (defn convert-rec [acc num] (cond (< num 4) (concat acc (take num (repeat "i"))) (= num 4) (concat acc "iv") (pos? (int (/ num 50))) (cons acc "l") (pos? (int (/ num 10)))