Skip to content

Instantly share code, notes, and snippets.

View huttj's full-sized avatar

Joshua Hutt huttj

  • Seattle, WA
View GitHub Profile
@huttj
huttj / removeDiacritics.js
Created June 6, 2016 19:27
Replace all diacritical characters with their non-augmented "equivalents"
const removeDiacritics = (function() {
const map = {
A: '\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F',
AA: '\uA732',
AE: '\u00C6\u01FC\u01E2',
AO: '\uA734',
AU: '\uA736',
AV: '\uA738\uA73A',
AY: '\uA73C',
// travel tickets
// Output order of travels, from start to end
var cities = 'Seattle, San Francisco, Austin, New York, Los Angeles, Portland, Chicago, Shanghai'.split(', ');
var count = 150;
var trip = [];
for (var i = 0; i < count; i++) {
var start = pickRand(cities);
var end = pickRand(cities);
while (end === start) {
var lookups = {
1: [''],
2: ['a', 'b', 'c'],
3: ['d', 'e', 'f'],
4: ['g', 'h', 'i'],
5: ['j', 'k', 'l'],
6: ['m', 'n', 'o'],
7: ['p', 'q', 'r', 's'],
8: ['t', 'u', 'v'],
9: ['w', 'x', 'y', 'z'],
'use strict';
const coins = [100,25,10,5,1];
const optimal = coinCount(48);
console.log(coinCount(25, without(coins, 25)));
console.log(
optimal.map(n => coinCount(n)).join('\n')
);
function MovingAverage(size) {
this.buckets = [];
while (1 + size--) {
this.buckets.push(0);
}
this.i = 0;
this.average = 0;
}
MovingAverage.prototype.add = function add(n) {
'use strict';
module.exports = function nodePromise(fn) {
return new Promise((resolve, reject) => {
fn((err, res) => err ? reject(err) : resolve(res));
});
};
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<style>
textarea {
width: calc(100% - .5em);
height: 50vh;
}
[{
"emoji": "๐Ÿ˜€",
"name": "GRINNING FACE",
"code": "U+1F600"
}, {
"emoji": "๐Ÿ˜",
"name": "GRINNING FACE WITH SMILING EYES",
"code": "U+1F601"
}, {
"emoji": "๐Ÿ˜‚",
(function() {
var emojis = ["๐Ÿ˜€","๐Ÿ˜","๐Ÿ˜‚","๐Ÿ˜ƒ","๐Ÿ˜„","๐Ÿ˜…","๐Ÿ˜†","๐Ÿ˜‰","๐Ÿ˜Š","๐Ÿ˜‹","๐Ÿ˜Ž","๐Ÿ˜","๐Ÿ˜˜","๐Ÿ˜—","๐Ÿ˜™","๐Ÿ˜š","โ˜บ๏ธ","๐Ÿ™‚","๐Ÿค—","๐Ÿ˜‡","๐Ÿค“","๐Ÿค”","๐Ÿ˜","๐Ÿ˜‘","๐Ÿ˜ถ","๐Ÿ™„","๐Ÿ˜","๐Ÿ˜ฃ","๐Ÿ˜ฅ","๐Ÿ˜ฎ","๐Ÿค","๐Ÿ˜ฏ","๐Ÿ˜ช","๐Ÿ˜ซ","๐Ÿ˜ด","๐Ÿ˜Œ","๐Ÿ˜›","๐Ÿ˜œ","๐Ÿ˜","๐Ÿ˜’","๐Ÿ˜“","๐Ÿ˜”","๐Ÿ˜•","๐Ÿ™ƒ","๐Ÿค‘","๐Ÿ˜ฒ","๐Ÿ˜ท","๐Ÿค’","๐Ÿค•","โ˜น๏ธ","๐Ÿ™","๐Ÿ˜–","๐Ÿ˜ž","๐Ÿ˜Ÿ","๐Ÿ˜ค","๐Ÿ˜ข","๐Ÿ˜ญ","๐Ÿ˜ฆ","๐Ÿ˜ง","๐Ÿ˜จ","๐Ÿ˜ฉ","๐Ÿ˜ฌ","๐Ÿ˜ฐ","๐Ÿ˜ฑ","๐Ÿ˜ณ","๐Ÿ˜ต","๐Ÿ˜ก","๐Ÿ˜ ","๐Ÿ˜ˆ","๐Ÿ‘ฟ","๐Ÿ‘น","๐Ÿ‘บ","๐Ÿ’€","โ˜ ๏ธ","๐Ÿ‘ป","๐Ÿ‘ฝ","๐Ÿ‘พ","๐Ÿค–","๐Ÿ’ฉ","๐Ÿ˜บ","๐Ÿ˜ธ","๐Ÿ˜น","๐Ÿ˜ป","๐Ÿ˜ผ","๐Ÿ˜ฝ","๐Ÿ™€","๐Ÿ˜ฟ","๐Ÿ˜พ","๐Ÿ™ˆ","๐Ÿ™‰","๐Ÿ™Š","๐Ÿ‘ฆ","๐Ÿ‘ฆ๐Ÿป","๐Ÿ‘ฆ๐Ÿผ","๐Ÿ‘ฆ๐Ÿฝ","๐Ÿ‘ฆ๐Ÿพ","๐Ÿ‘ฆ๐Ÿฟ","๐Ÿ‘ง","๐Ÿ‘ง๐Ÿป","๐Ÿ‘ง๐Ÿผ","๐Ÿ‘ง๐Ÿฝ","๐Ÿ‘ง๐Ÿพ","๐Ÿ‘ง๐Ÿฟ","๐Ÿ‘จ","๐Ÿ‘จ๐Ÿป","๐Ÿ‘จ๐Ÿผ","๐Ÿ‘จ๐Ÿฝ","๐Ÿ‘จ๐Ÿพ","๐Ÿ‘จ๐Ÿฟ","๐Ÿ‘ฉ","๐Ÿ‘ฉ๐Ÿป","๐Ÿ‘ฉ๐Ÿผ","๐Ÿ‘ฉ๐Ÿฝ","๐Ÿ‘ฉ๐Ÿพ","๐Ÿ‘ฉ๐Ÿฟ","๐Ÿ‘ด","๐Ÿ‘ด๐Ÿป","๐Ÿ‘ด๐Ÿผ","๐Ÿ‘ด๐Ÿฝ","๐Ÿ‘ด๐Ÿพ","๐Ÿ‘ด๐Ÿฟ","๐Ÿ‘ต","๐Ÿ‘ต๐Ÿป","๐Ÿ‘ต๐Ÿผ","๐Ÿ‘ต๐Ÿฝ","๐Ÿ‘ต๐Ÿพ","๐Ÿ‘ต๐Ÿฟ","๐Ÿ‘ถ","๐Ÿ‘ถ๐Ÿป","๐Ÿ‘ถ๐Ÿผ","๐Ÿ‘ถ๐Ÿฝ","๐Ÿ‘ถ๐Ÿพ","๐Ÿ‘ถ๐Ÿฟ","๐Ÿ‘ฑ","๐Ÿ‘ฑ๐Ÿป","๐Ÿ‘ฑ๐Ÿผ","๐Ÿ‘ฑ๐Ÿฝ","๐Ÿ‘ฑ๐Ÿพ","๐Ÿ‘ฑ๐Ÿฟ","๐Ÿ‘ฎ","๐Ÿ‘ฎ๐Ÿป","๐Ÿ‘ฎ๐Ÿผ","๐Ÿ‘ฎ๐Ÿฝ","๐Ÿ‘ฎ๐Ÿพ","๐Ÿ‘ฎ๐Ÿฟ","๐Ÿ‘ฒ","๐Ÿ‘ฒ๐Ÿป","๐Ÿ‘ฒ๐Ÿผ","๐Ÿ‘ฒ๐Ÿฝ","๐Ÿ‘ฒ๐Ÿพ","๐Ÿ‘ฒ๐Ÿฟ","๐Ÿ‘ณ","๐Ÿ‘ณ๐Ÿป","๐Ÿ‘ณ๐Ÿผ","๐Ÿ‘ณ๐Ÿฝ","๐Ÿ‘ณ๐Ÿพ","๐Ÿ‘ณ๐Ÿฟ","๐Ÿ‘ท","๐Ÿ‘ท๐Ÿป","๐Ÿ‘ท๐Ÿผ","๐Ÿ‘ท๐Ÿฝ","๐Ÿ‘ท๐Ÿพ","๐Ÿ‘ท๐Ÿฟ","โ›‘๏ธ","๐Ÿ‘ธ","๐Ÿ‘ธ๐Ÿป","๐Ÿ‘ธ๐Ÿผ","๐Ÿ‘ธ๐Ÿฝ","๐Ÿ‘ธ๐Ÿพ","๐Ÿ‘ธ๐Ÿฟ","๐Ÿ’‚","๐Ÿ’‚๐Ÿป","๐Ÿ’‚๐Ÿผ","๐Ÿ’‚๐Ÿฝ","๐Ÿ’‚๐Ÿพ","๐Ÿ’‚๐Ÿฟ","๐Ÿ•ต๏ธ","๐Ÿ•ต๏ธ๐Ÿป","๐Ÿ•ต๏ธ๐Ÿผ","๐Ÿ•ต๏ธ๐Ÿฝ","๐Ÿ•ต๏ธ๐Ÿพ","๐Ÿ•ต๏ธ๐Ÿฟ","๐ŸŽ…","๐ŸŽ…๐Ÿป","๐ŸŽ…๐Ÿผ","๐ŸŽ…๐Ÿฝ","๐ŸŽ…๐Ÿพ","๐ŸŽ…๐Ÿฟ","๐Ÿ‘ฐ","๐Ÿ‘ฐ๐Ÿป","๐Ÿ‘ฐ๐Ÿผ","๐Ÿ‘ฐ๐Ÿฝ","๐Ÿ‘ฐ๐Ÿพ","๐Ÿ‘ฐ๐Ÿฟ","๐Ÿ‘ผ","๐Ÿ‘ผ๐Ÿป","๐Ÿ‘ผ๐Ÿผ","๐Ÿ‘ผ๐Ÿฝ","๐Ÿ‘ผ๐Ÿพ","๐Ÿ‘ผ๐Ÿฟ","๐Ÿ’†","๐Ÿ’†๐Ÿป","๐Ÿ’†๐Ÿผ","๐Ÿ’†๐Ÿฝ","๐Ÿ’†๐Ÿพ","๐Ÿ’†๐Ÿฟ","๐Ÿ’‡","๐Ÿ’‡๐Ÿป","๐Ÿ’‡๐Ÿผ","๐Ÿ’‡๐Ÿฝ","๐Ÿ’‡๐Ÿพ","๐Ÿ’‡๐Ÿฟ","๐Ÿ™","๐Ÿ™๐Ÿป","๐Ÿ™๐Ÿผ","๐Ÿ™๐Ÿฝ","๐Ÿ™๐Ÿพ","๐Ÿ™๐Ÿฟ","๐Ÿ™Ž","๐Ÿ™Ž
@huttj
huttj / csvparse.html
Created October 11, 2015 05:10
Quick and dirty CSV parsing on the client
<!doctype html>
<html>
<head>
<title></title>
</head>
<body>
<input type="file" id="files" name="files[]" multiple />
<output id="list"></output>
<script>