Posts

Showing posts from 2017

Z-Indexes in CSS Explained

Z-Index is one of the most confusing and unintuitive properties in CSS, but it’s actually pretty simple once you understand it. Your first instinct is probably to think that you can just set z-index on any element and that that alone is going to determine its stacking order. This is WRONG. https://medium.com/@jberniertech/z-indexes-in-css-explained-32f52cb3fab (originally posted March 16, 2017)

Upgrading to Webpack 2, and Tree-Shaking results

Recently made the upgrade to Webpack 2 because I wanted the tree shaking functionality. Took about a day. Here are some tips, along with the results. https://medium.com/@jberniertech/upgrading-to-webpack-2-and-tree-shaking-results-e68bd203c974 (originally posted March 14, 2017)

Quick A/B testing

ab -n 500 -c 10 http://0.0.0.0:1337/

Symlinking

const execSync = require('child_process').execSync execSync("rm -rf node_modules/@app && ln -sf ../src node_modules/@app") execSync("[ -h ./node_modules/@static ] || ln -sf ../static ./node_modules/@static")

Javascript Absurdities

Javascript is a funky language. Here are some obvious design flaws: **1. [Regex `test()` method is inconsistent when global flag is set](http://stackoverflow.com/questions/1520800/why-regexp-with-global-flag-in-javascript-give-wrong-results)** ``` var pattern = /hi/g; pattern.test('hi'); //true pattern.test('hi'); //false ``` Today at work I spent hours on a witch hunt trying to pinpoint the cause of a bug that was delaying a production release. It ended up coming down to this absurd Javascript quirk within a single "if" statement inside a portion of code that hadn't been touched in a year. **2. null and undefined** Having separate null and undefined types just adds unnecessary confusion. The best way to check whether variable is null or undefined is `if (varname == null)`. Using the triple equals (which is preferred in almost every other situation) will not catch both types. **3. typeof** ``` typeof [] //"object" typeof nul