{{ message }}

Instantly share code, notes, and snippets.

# Benjamin Dreux benzen

Last active Feb 17, 2016
Maybe the samllest flux implementation ever
View genux.js
 //utilitary functions const find = (pred, coll) => { for(const item of coll){ if(pred(item)){ return item; } } return null; };
Last active Nov 5, 2015 — forked from fxg42/exercices.js
Exercices
View exercices.js
 // # 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 Sep 26, 2015
View mini-flux.js
 let render = render || function(){ React.render( , document.getElementById('app')); }; setInterval( function(){ requestAnimationFrame(render);
Created Sep 24, 2015
View index.html

Created Sep 20, 2015
View devcards.cljs
 (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 Sep 20, 2015
View build.boot
 (deftask devcards [] (comp (serve :dir "frontend/target/") (watch) (speak) (cljs :unified true :source-map true :optimizations :none :compiler-options { :main "our-child.devcards"
Created Sep 6, 2015
Une impression de déjà vue ici
View mamanpourlavie.com.coffee
 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 Sep 6, 2015
Rookie mistake with local state
View context.md

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 Aug 29, 2015
Highland vs Async
View async v1.coffee
 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 Nov 22, 2010
cesear kata
View gist:710036
 (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)))