#Clear's heatmap color algorithm
<ul id="list">
<li>Milk</li>
<li>Greens</li>
<li>Flour</li>
Eggs
function getElementCenter(elem) { | |
var props = elem.getBoundingClientRect(), | |
x = 0, | |
y = 0; | |
//Calculating X | |
if (props.left > props.right) | |
x = (props.left - props.right)/2 + props.right; | |
else if (props.left < props.right) |
@mixin blur ($radius) { | |
-webkit-filter: blur($radius+px); /* Chrome, Safari */ | |
-ms-filter: blur($radius+px); /* IE12? */ | |
filter: url("data:image/svg+xml;utf8,<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\"><filter id=\"blur\"><feGaussianBlur stdDeviation=\"#{$radius}\" /></filter></svg>#blur"); /* Firefox, Safari, Chrome*/ | |
filter: progid:DXImageTransform.Microsoft.Blur(Strength=$radius); /* IE9 */ | |
} |
//point as in [c1, c2] | |
function simpleDeCasteljau (point, t) { | |
return (1-t)*point[0] + t*point[1] | |
} | |
function pointInTimeOnBezier(startPoint, endPoint, time) { | |
return [ | |
simpleDeCasteljau([startPoint[0], endPoint[0]], time), |
function testForComputedMatches() { | |
var prefixes = 'webkit moz ms o'.split(' '), lt = prefixes.length, prefix = '', computed; | |
while (lt--) { | |
computed = window.getComputedStyle && window.getComputedStyle(document.body).getPropertyValue("-"+prefixes[lt]+"-transform"); | |
if (!!computed) { | |
prefix = prefixes[lt]; | |
break; | |
} | |
} |
#Magical enums in ES6 My brain exploded with creativity today with this nefarious trick to make an enum by manipulating the syntax in ES6. The browser vendors will probably find this and block this from shipping, but it will still work with a transpiler (webpack + 6to5). To understand this you will need to know ES6 Proxies, ES6 modules, and Symbols.
your-code.js
import { blue, red, orange } from 'magic-enum';
var color = blue;
switch (color) {
import React from 'react'; | |
// Before rendering run: | |
// React.initializeTouchEvents() | |
var Styles = { | |
WebKitUserSelect: 'none', | |
MozUserSelect: 'none', | |
MsUserSelect: 'none', | |
UserSelect: 'none', |
#Make and GCC on Windows
/** | |
* Insert an item (d) at a certain index (b) in a | |
* recurring number (a) of items inside of an array (c) | |
* | |
* "For every 20 items in an array, | |
* insert this at the 12th index in that section" | |
* | |
* var myArray = Array.from({length: 80}, (v, k) => k); | |
* insertItemEvery(20, 12, myArray, "Hello index"); | |
* |