brew update
brew install jenv
brew tap caskroom/cask
brew tap caskroom/versions
mkdir ~/.jenv/versions
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
/** | |
* Run a list of async tasks as promises and wait after each batch | |
* @param {Number} batchSize - Number of tasks to run in parallel | |
* @param {Number} waitTime - Time to wait after each batch, in milliseconds | |
* @param {Array<Function>} tasks - Promise executor functions (not promise objects!) | |
* @return {Promise<Array<*>>} | |
*/ | |
function executeBatched(batchSize, waitTime, tasks) { | |
tasks = tasks.slice(); |
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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Asynchronously load fonts and cache them into localStorage</title> | |
<script> | |
(function(d, w){ |
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
/** | |
* Capitalize | |
*/ | |
const capitalize = string => { | |
return string.charAt(0).toUpperCase() + string.slice(1); | |
}; | |
/** | |
* Prefix EventListener | |
*/ |
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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Homepage</title> | |
<!-- If HTTP/1: Inline with <style>, remove this <link> --> | |
<!-- If HTTP/2: Server push this CSS file, and leave this <link> --> | |
<link rel="stylesheet" href="critical-homepage.css"> |
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
import { raf } from 'utils/eventHelpers'; | |
class Carousel { | |
constructor(element, options) { | |
this._element = element; | |
this._options = Object.assign(Carousel.options, options); | |
this._refs = { |
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
/** | |
* Shallow merge objects | |
*/ | |
function mergeObjectsShallow(target, ...sources) { | |
for (let i = 0; i < sources.length; i++) { | |
const source = sources[i]; | |
for (var prop in source) { | |
if (!source.hasOwnProperty(prop)) continue; | |
target[prop] = source[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
const map = fn => list => list.map(fn); | |
const filter = fn => list => list.filter(fn); | |
const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args))); | |
const tail = list => list.slice(1); | |
const fill = val => num => new Array(num).fill(val); | |
const getFileContents = file => require('fs').readFileSync(file, { encoding: 'utf8' }); | |
const split = char => str => str.split(char); | |
const join = char => list => list.join(char); |
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
/** | |
* @module GTMEventTracking | |
* @example | |
* <a | |
* data-module="event-tracking/GTMEventTracking" | |
* data-payload='{"event":"EventOpenGoogle"}' | |
* href="https://google.com/" target="_blank"> | |
* Click me | |
* </a> | |
*/ |
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
const indexOf = node => list => { | |
const guess = (min, max) => { | |
const index = Math.floor((max - min) / 2) + min | |
if (list[index] === node) { | |
return index | |
} else if (list[index] < node) { | |
min = index + 1 | |
} else { | |
max = index - 1 | |
} |