see it working in this jsbin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class DecoratedError extends Error { | |
/** | |
* @param {any} error | |
* @param {...Object|...() => Object} decorators | |
*/ | |
constructor(error, ...decorators) { | |
if (typeof error === "string" || error instanceof String) { | |
error = new Error(error); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Automatically assign local git user email | |
# This code expects the following | |
# file ".gitemail" to exist and contain only 1 row with an email | |
# file ".npmregistry" to exist and contain only 1 row with the registry url | |
# | |
# Note: if any of the files don't exist then the default will be used | |
setup-dev-user() { | |
local expected_git_email=$(grep -hs ^ ./.gitemail) | |
local current_git_email="$(git config user.email)" | |
local default_git_email="example@company.com" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Tasks that are supposed to be executed every screen paint. | |
*/ | |
var tasks = [ | |
() => { | |
var now = Date.now(); | |
// heavy algorithm example | |
for(var i = 0; i < 200/*000*/; i+=1){ | |
var dummy = i * 0.1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Simple implementation of Publish and Subscribe Pattern | |
* | |
* This helps a lot specially when the components are | |
* not close enough that passing a function as props | |
* looks ugly. | |
*/ | |
const topics = {}; | |
module.exports = { | |
subscribe: function (topic, callback) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$breakpoints: 700px, 900px, 1100px, 1300px; | |
$sizes: "sm", "md", "lg", "xl"; | |
$cols: 12; | |
.clearfix { | |
clear: both; | |
} | |
.row { | |
position: relative; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function execute(){ | |
var callbacks = Array.prototype.map.call(arguments, function(callback){ | |
return callback instanceof Function && callback; | |
}); | |
return function(){ | |
var self = this; | |
var args = arguments; | |
callbacks.forEach(function (callback){ | |
callback.apply(self, args); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function createObservable(obj, callback) { | |
var getset = {}; | |
var values = {}; | |
var isFinalized = false; | |
for(let prop in obj) { | |
Object.defineProperty(getset, prop, { | |
get: _ => values[prop], | |
set: newValue => { | |
if(newValue === values[prop]) { | |
return values[prop]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// HOW TO | |
pipe.pipeline(run => { | |
var sensorData = []; | |
document.addEventListener("mousemove", _ => { | |
sensorData.push(_.x.toFixed(0)); | |
}, false); | |
requestAnimationFrame(function loop(){ | |
if(sensorData.length > 0) { | |
sensorData.forEach(run); | |
sensorData = []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function addListener(elem, evtName, listener) { | |
elem.addEventListener(evtName, listener, false); | |
oneTimeListener(document, "motiondestroy", function () { | |
elem.removeEventListener(evtName, listener, false); | |
}); | |
} |
NewerOlder