This file contains hidden or 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 TWO_PI = 2 * Math.PI; | |
function tmpl (template, dict) { | |
return template.replace(/\$\{([^\}]*)\}/g, function (_, name) { | |
return dict[name]; | |
}); | |
} | |
function makeSegment (args, options) { | |
// args is {startAngle, angle, index, className} |
This file contains hidden or 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
background: linear-gradient(45deg, #222 12%, transparent 0, transparent 88%, #222 0), | |
linear-gradient(135deg, transparent 37%, #111 0, #444 32%, #111 63%, transparent 0), | |
linear-gradient(45deg, transparent 37%, #222 0, #222 63%, transparent 0) #000; | |
background-size: 15px 15px; |
This file contains hidden or 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
# commands from http://www.askapache.com/linux/bash_profile-functions-advanced-shell.html | |
#alias chmod='command chmod -c' | |
alias cpr='command cp -rpv' | |
alias df='command df -kh' | |
alias df1='command df -ia' | |
alias diff='diff -up' | |
alias dsiz='du -sk * | sort -n --' | |
alias du='command du -kh' | |
alias du1='echo *|tr " " "n" |xargs -iFF command du -hs FF|sort' |
This file contains hidden or 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 () { | |
'use strict'; | |
window.dnd = window.dnd || {}; | |
function Move (container, options, node, e) { | |
this.container = container; | |
this.options = options; | |
this.node = node; |
This file contains hidden or 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
class Component extends HTMLElement { | |
constructor () { | |
super(); | |
this.addEventListener('click', this.changeBackground.bind(this)); | |
this.addEventListener('transitionend', this.revertBackground.bind(this)); | |
} | |
static get observedAttributes () { | |
return ['text']; | |
} |
This file contains hidden or 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> | |
<head> | |
<title>Rich text editor demo</title> | |
<script src="./rich.js" defer></script> | |
<style> | |
#editor[contentEditable=true] { | |
padding: 0.5em; | |
margin: 1em; | |
} |
This file contains hidden or 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
'use strict'; | |
const {Readable} = require('stream'); | |
const merge = (s1, s2) => { | |
s1.pause(); | |
s2.pause(); | |
let item1 = null, | |
item2 = null, |
This file contains hidden or 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
'use strict'; | |
if (process.argv.length < 3) { | |
console.log('Usage: node build-index.js inFile outFile'); | |
console.log(' All file names are relative to the project directory.') | |
console.log('Example: node build-index.js src/index.html docs/index.html'); | |
process.exit(1); | |
} | |
const fs = require('fs'); |
This file contains hidden or 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
'use strict'; | |
// Loosely based on JSONx: https://tools.ietf.org/html/draft-rsalz-jsonx-00 | |
const escapeValueDict = {'&': '&', '<': '<'}; | |
const escapeValue = s => ('' + s).replace(/[&<]/g, m => escapeValueDict[m]); | |
const escapeAttrDict = {'&': '&', '<': '<', '"': '"'}; | |
const escapeAttr = s => ('' + s).replace(/[&<"]/g, m => escapeAttrDict[m]); |
This file contains hidden or 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
'use strict'; | |
// using heap implementation from https://github.com/heya/ctr under the BSD-3 license | |
class Heap { | |
constructor(less = (a, b) => a < b, arrayLike = []) { | |
this.less = less; | |
this.array = Heap.make(Array.from(arrayLike), this.less); | |
} |