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
months = ['January', | |
'February', | |
'March', | |
'April', | |
'May', | |
'June', | |
'July', | |
'August', | |
'September', | |
'October', |
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 delay(fn, t) { | |
// private instance variables | |
var queue = [], self, timer; | |
function schedule(fn, t) { | |
timer = setTimeout(function() { | |
timer = null; | |
fn(); | |
if (queue.length) { | |
var item = queue.shift(); |
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 compose = (...fns) => data => | |
fns.reduceRight((value, fn) => fn(value), data) | |
const trim = str => str.trim() | |
const split = separator => str => str.split(separator) | |
const notEmpty = str => str.length > 0 | |
const removeEmpty = parts => parts.filter(notEmpty) |
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 compose = (...functions) => data => | |
functions.reduceRight((value, func) => func(value), data) // right to left | |
const pipe = (...functions) => data => | |
functions.reduce((value, func) => func(value), data) // left to right | |
const encodeAttribute = (x = '') => x.replace(/"/g, '"') | |
const toAttributeString = (x = {}) => | |
Object.keys(x) | |
.map(attr => `${encodeAttribute(attr)}="${encodeAttribute(x[attr])}"`) |
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
elem.addEventListener('click', (function(numCopy) { | |
``` | |
return function() { | |
alert(numCopy) | |
}; | |
``` | |
})(num)); |
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
var gulp = require('gulp'), | |
replace = require('gulp-replace'), | |
fs = require('fs'); | |
// in your task | |
return gulp.src(...) | |
.pipe(replace(/<link href="style.css"[^>]*>/, function(s) { | |
var style = fs.readFileSync('style.css', 'utf8'); | |
return '<style>\n' + style + '\n</style>'; | |
})) |
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
li { | |
list-style-type: none; | |
position: relative; | |
margin: 2px; | |
padding: 0.5em 0.5em 0.5em 2em; | |
background: lightgrey; | |
font-family: sans-serif; | |
} | |
li.done { |
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
<html> | |
<head> | |
<title>Critical Path: Measure</title> | |
<meta name="viewport" content="width=device-width,initial-scale=1"> | |
<link href="style.css" rel="stylesheet"> | |
<script> | |
function measureCRP() { | |
var t = window.performance.timing, | |
interactive = t.domInteractive - t.domLoading, |
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
/** | |
* QuadTree object. | |
* | |
* The quadrant indexes are numbered as below: | |
* | | |
* 1 | 0 | |
* —-+—- | |
* 2 | 3 | |
* | | |
*/ |
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
<?xml version="1.0" encoding="utf-8"?> | |
<feed xmlns="http://www.w3.org/2005/Atom"> | |
<title>Example Feed</title> | |
<subtitle>A subtitle.</subtitle> | |
<link href="http://example.org/feed/" rel="self" /> | |
<link href="http://example.org/" /> | |
<id>urn:uuid:60a76c80-d399-11d9-b91C-0003939e0af6</id> | |
<updated>2003-12-13T18:30:02Z</updated> |