Skip to content

Instantly share code, notes, and snippets.

View dacz's full-sized avatar

David Cizek dacz

View GitHub Profile
@dacz
dacz / validate.js
Last active August 9, 2017 16:24
Form validator
/*
For my use only but happy to explain it to anyone interested:
I'm not into use controlled components everywhere.
Forms collects the values and submit does... well submit.
Because of React twisted events (synthetic) this approach uses:
- every input has a unique name
- then you will get obj vith name: value keys
- you can specify which name should be picked up
@dacz
dacz / perf-concat.js
Last active May 27, 2017 10:43
Perf array clone with concat or Array.from
const makeSmallArrays = count => [ ...(new Array(count)) ].map((_, i) => [i, i.toString()]);
// generate arrs
// a lot of small ones
const countSmall = 1000;
arrOfSmalls = makeSmallArrays(countSmall);
// cost of duplicating array
const fnConcat = arr => arr.concat();
@dacz
dacz / gist:60028
Last active April 26, 2017 11:03
happy
unless Life.include?(:happines)
raise WorldMismatchError
end