Skip to content

Instantly share code, notes, and snippets.

View lionelB's full-sized avatar
🪂
Working from home

Lionel lionelB

🪂
Working from home
View GitHub Profile
@lionelB
lionelB / objectFlattener.js
Last active August 29, 2015 13:55
flatten object hierarchy. Rely on (underscore|lodash).js - Object's keys with the same name will be overwritten
_.reduce(o, function red(memo, val, key){
if(typeof val === 'object'){
_.reduce(val, red, memo)
} else {
memo[key] = val;
}
return memo;
}, Object.create(null));
@lionelB
lionelB / gruntFile-proxy.js
Last active August 29, 2015 13:56
Piece of a grunt config for https proxy server
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-connect-proxy');
var proxySnippet = require('grunt-connect-proxy/lib/utils').proxyRequest;
grunt.initConfig({
connect: {
server: {
options: {
@lionelB
lionelB / diff.js
Created February 13, 2014 16:20
underscore object differences
function diff(A,B,prop){
var getProp = _.property(prop);
var eq = function(itemA, itemB){
return getProp(itemA) === getProp(itemB);
};
return _.filter(A, function(itemA){
return ! _.some(B, _.partial(eq,itemA) );
});
@lionelB
lionelB / gist:9034494
Created February 16, 2014 13:50
echo task
grunt.registerTask('echo', function(){
fs.createReadStream('./package.json',{encoding:'utf-8'})
.pipe( process.stdout );
});
@lionelB
lionelB / replace.js
Created April 15, 2014 20:53
multiple search/ replace using regexp et Array.reduce
var replaceMap = [
{token:/pattern1/, value:"value1"},
{token:/pattern2/, value:"value2"},
];
return replaceMap.reduce(function(memo, item){
return memo.replace(item.token, item.value);
}, "pattern1 or patten2 will be replaced");
@lionelB
lionelB / urlParams.js
Created October 27, 2014 21:30
extract url params
//Since http://devdocs.io/dom/urlutils.searchparams is not already bake!
//the url to parse
var url = "https://toto.com/truc/?param1=yo&param2=toto&tutu=titi";
// Create a HTMLAnchorElement
var a = document.createElement('a');
// Lazy dev let the browser do the hard job and parse the url
a.href = url;
function reactView(req, res, next) {
Router.run(routes, req.url, function (Handler) {
// Content is the route handler,
// which then handles all the routing
// and kicks back HTML with React.renderToString
var title = "Lumographe";
if (req.url !== "/") {
var project = store.findByUrl(req.url);
if (project) {
title += " | " + project.name;

Ce qu’il faut :

  • Pour 6 gua bao
    • ✎ 300 g de farine de blé T65 ( ou T55 )
    • ✎ 150 ml d’eau tiède
    • ✎ 15 g de sucre de canne
    • ✎ 5 g de levure sèche instantanée du boulanger
    • ✎ 1 pincée de sel
    • ✎ 1 càs d’huile d’olive
  • Tofu à la citronnelle
  • ✎ 2 tiges de citronnelle
@lionelB
lionelB / GameBoardUtils.as
Created February 3, 2011 09:19
useful little snippets
/*
Find the number of complete row and col from a number of objects
*/
col = Math.sqrt(_nbCards);
if (_nbCards % col > 0)
{
while (_nbCards % ++col != 0){};
}
@lionelB
lionelB / ActivityIndicator.as
Created February 18, 2011 14:14
A simple osx-like activity indicator
package ui.utils
{
import flash.display.CapsStyle;
import flash.display.LineScaleMode;
import flash.display.Shape;
import flash.events.Event;
import flash.utils.clearInterval;
import flash.utils.getTimer;
import flash.utils.setInterval;