Skip to content

Instantly share code, notes, and snippets.

Benjamin Dreux benzen

Block or report user

Report or block benzen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@benzen
benzen / genux.js
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;
};
@benzen
benzen / exercices.js
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 ];
View mini-flux.js
let render = render || function(){
React.render(
<DevCardsListing/>,
document.getElementById('app'));
};
setInterval(
function(){
requestAnimationFrame(render);
View index.html
<script src="node_modules/babel/node_modules/babel-core/browser.js"></script>
<script src="react-0.13.3.js"></script>
<script type="text/babel">
var comp = function(fun){
return React.createClass({render:fun});
}
var DevCardTitle = DevCardTitle || comp(function(){
const titleStyle = {
backgroundColor: "rgb(239, 237, 237)",
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."))
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"
@benzen
benzen / mamanpourlavie.com.coffee
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",
@benzen
benzen / context.md
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).

@benzen
benzen / async v1.coffee
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
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)))
You can’t perform that action at this time.