Skip to content

Instantly share code, notes, and snippets.

View ooflorent's full-sized avatar

Florent Cailhol ooflorent

  • Toulouse, France
  • 13:33 (UTC +02:00)
  • X @ooflorent
View GitHub Profile
@ooflorent
ooflorent / grid.css
Created November 5, 2014 15:40
Flexbox grid
.grid {
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.grid-col--auto,
.grid-col--1,
.grid-col--2,
.grid-col--3,
@ooflorent
ooflorent / emitter.js
Created December 3, 2014 10:11
Simple ES6 emitter
class Listener {
constructor(fn, ctx) {
this.fn = fn
this.ctx = ctx
}
}
class Emitter {
listen(fn, ctx) {
this.listeners.push(new Listener(fn, ctx))
@ooflorent
ooflorent / sparse_array.md
Last active August 29, 2015 14:13
Questions about sparse arrays

Are the following arrays sparse?

Created using fixed length

var a = new Array(200)
a[50] = {}

Resized using length

alias d8ir="d8 \
--trace-hydrogen \
--trace-phase=Z \
--trace-deopt \
--code-comments \
--hydrogen-track-positions \
--redirect-code-traces \
--redirect-code-traces-to=code.asm"
@ooflorent
ooflorent / instance-const.js
Last active August 29, 2015 14:14
Research about instance constants
function Obj(x) {
if (typeof x !== 'number') throw new Error()
Object.defineProperty(this, 'x', {value: x})
}
var a = new Obj(1)
var b = new Obj(2)
// Do `a` and `b` have the same hidden class in v8?
//
@ooflorent
ooflorent / c1.dart.js
Created February 3, 2015 09:14
dart2js curiosities
// Curiosity #1
// ------------
function dart() {
this.x = 0;
delete this.x;
}
var A = new dart;
export const READ_ONLY = 1
export const DONT_ENUM = 2
export const DONT_DELETE = 4
export function InstallFunctions(object, attributes, functions) {
for (let i = 0; i < functions.length; i += 2) {
let field = functions[i]
let value = functions[i + 1]
AddNamedProperty(object, field, value, attributes)

Usage

var FastMap = require('./fast')
var someMap = FastMap()
---
parser: babel-eslint
ecmaFeatures:
modules: true
env:
es6: true
browser: true
node: true
@ooflorent
ooflorent / webpack.config.js
Last active August 28, 2017 19:05
Simplify extension management in webpack
const ext = (...suffix) => new RegExp(`\\.(?:${ suffix.join('|') })(?:[?#].*)?$`)
const loaders = [
// Traditional cases
{ test: ext('css'), loaders: ['style', 'css'] }, // single
{ test: ext('js', 'jsx', 'es6'), loaders: ['babel'] }, // multiple
// Complex case: Font-Awesome adds query strings and/or hashs to files
{ test: ext('otf', 'eot', 'svg', 'ttf', 'woff', 'woff2'), loaders: ['file?name=[name].[ext]'] },
]