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 / sticky-focus.js
Created June 19, 2018 15:22 — forked from enwin/sticky-focus.js
Detect and change the scroll position when a focused element is under a sticky element
// sticky element
var stickyHeader = document.querySelector( '.intro-banner' );
function handleFocus( e ){
// don't try to change the scroll if the focused element is in the sticky element
if( stickyHeader.contains( e.target )){
return;
}
// quick & dirty client height on each focus
@lionelB
lionelB / compose.js
Created May 1, 2017 13:21 — forked from WaldoJeffers/compose.js
JavaScript one-line compose (ES6)
const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args)))
// Usage : compose functions right to left
// compose(minus8, add10, multiply10)(4) === 42
//
// The resulting function can accept as many arguments as the first function does
// compose(add2, multiply)(4, 10) === 42
@lionelB
lionelB / README.md
Created January 16, 2017 10:01 — forked from rgrove/README.md
Cake's approach to React Router server rendering w/code splitting and Redux

Can't share the complete code because the app's closed source and still in stealth mode, but here's how I'm using React Router and Redux in a large app with server rendering and code splitting on routes.

Server

  1. Wildcard Express route configures a Redux store for each request and makes an addReducers() callback available to the getComponents() method of each React Router route. Each route is responsible for adding any Redux reducers it needs when it's loaded. (This isn't really necessary on the
@lionelB
lionelB / Stylable.js
Created October 23, 2016 12:32 — forked from MoOx/Stylable.js
Stylable component that works well with React inline styles
// @flow
import React from "react"
import Hoverable from "../../modules/Hoverable"
import Focusable from "../../modules/Focusable"
import Touchable from "../../modules/Touchable"
type PropsType = {
children?: React$Element<any>,
@lionelB
lionelB / GoogleMap.js
Created August 10, 2016 20:41 — forked from cedricdelpoux/GoogleMap.js
React Google Map
import React, {Component, PropTypes} from "react"
import placesLoader from "./placesLoader"
import placesShape from "./placesShape"
import styles from "./GoogleMap.css"
import iconMarker from "./iconMarker.png"
import iconTrash from "./iconTrash.png"
const {arrayOf, func, number, shape, string} = PropTypes
@lionelB
lionelB / cordova-tips.md
Created January 6, 2016 13:03 — forked from revolunet/cordova-tips.md
Cordova iOS tips

General

  • create a single page javascript application
  • be as low-level as possible to be able to control performance (=minimize layers)
  • masterize your dev/build environnement so you can work/play nicely

Debug apps

  • Open safari console in development menu with simulator or attached devices (enable debug in ipad/safari dev options)
  • debug your app from xcode to get native debugger and performance metrics
@lionelB
lionelB / package.json
Created November 26, 2015 17:20 — forked from anonymous/package.json
browserify+stylus+babel+hotreload
{
"scripts": {
"test": "mocha -g",
"start": "babel-node server.js",
"prestart": "npm run build",
"build": "npm-run-all 'build:*'",
"build:js": "cross-env NODE_ENV=production browserify -t babelify -t envify src/app.js > static/build.js",
"postbuild:js": "uglifyjs static/build.js -o static/build.js",
"build:css": "cross-env NODE_ENV=production stylus css/main.styl -o static",
"watch": "npm-run-all --parallel 'watch:*'",
@lionelB
lionelB / .colors.csv
Last active October 3, 2015 14:15 — forked from avillafiorita/.colors.csv
change osx terminal colors and font from the command line
LightPink1 #ffbdc5 255 189 197 {65535 48573 50629}
pink4 #9d777f 157 119 127 {40349 30583 32639}
pink3 #d7a3ad 215 163 173 {55255 41891 44461}
pink2 #f2b9c4 242 185 196 {62194 47545 50372}
pink1 #ffc3cf 255 195 207 {65535 50115 53199}
HotPink4 #9e4f75 158 79 117 {40606 20303 30069}
HotPink3 #d878a1 216 120 161 {55512 30840 41377}
HotPink2 #f383b5 243 131 181 {62451 33667 46517}
HotPink1 #ff87c1 255 135 193 {65535 34695 49601}
@lionelB
lionelB / README.md
Last active December 29, 2015 12:48 — forked from t8g/index.html
numeric stepper attribute directive.

Numeric stepper

an angular directive for building a numeric stepper

##features

  • Define minimun, maximun values and a stepSize,
  • choose cycling through value when reach minimum or maximun
  • integrate well whitin a form (update valid / invalid state)
  • update value with keyboard arrow
@lionelB
lionelB / gist:5877042
Last active December 19, 2015 01:38 — forked from bloodyowl/gist:4340751

Smallest HTML5 shim ever

130 bytes, that's what it takes.

Script

"header footer section aside nav article figure figcaption hgroup time main video".replace(/\w+/g,function(a){document.createElement(a)})