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 / 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>
(function() {
var emojis = ["😀","😁","😂","😃","😄","😅","😆","😉","😊","😋","😎","😍","😘","😗","😙","😚","☺️","🙂","🤗","😇","🤓","🤔","😐","😑","😶","🙄","😏","😣","😥","😮","🤐","😯","😪","😫","😴","😌","😛","😜","😝","😒","😓","😔","😕","🙃","🤑","😲","😷","🤒","🤕","☹️","🙁","😖","😞","😟","😤","😢","😭","😦","😧","😨","😩","😬","😰","😱","😳","😵","😡","😠","😈","👿","👹","👺","💀","☠️","👻","👽","👾","🤖","💩","😺","😸","😹","😻","😼","😽","🙀","😿","😾","🙈","🙉","🙊","👦","👦🏻","👦🏼","👦🏽","👦🏾","👦🏿","👧","👧🏻","👧🏼","👧🏽","👧🏾","👧🏿","👨","👨🏻","👨🏼","👨🏽","👨🏾","👨🏿","👩","👩🏻","👩🏼","👩🏽","👩🏾","👩🏿","👴","👴🏻","👴🏼","👴🏽","👴🏾","👴🏿","👵","👵🏻","👵🏼","👵🏽","👵🏾","👵🏿","👶","👶🏻","👶🏼","👶🏽","👶🏾","👶🏿","👱","👱🏻","👱🏼","👱🏽","👱🏾","👱🏿","👮","👮🏻","👮🏼","👮🏽","👮🏾","👮🏿","👲","👲🏻","👲🏼","👲🏽","👲🏾","👲🏿","👳","👳🏻","👳🏼","👳🏽","👳🏾","👳🏿","👷","👷🏻","👷🏼","👷🏽","👷🏾","👷🏿","⛑️","👸","👸🏻","👸🏼","👸🏽","👸🏾","👸🏿","💂","💂🏻","💂🏼","💂🏽","💂🏾","💂🏿","🕵️","🕵️🏻","🕵️🏼","🕵️🏽","🕵️🏾","🕵️🏿","🎅","🎅🏻","🎅🏼","🎅🏽","🎅🏾","🎅🏿","👰","👰🏻","👰🏼","👰🏽","👰🏾","👰🏿","👼","👼🏻","👼🏼","👼🏽","👼🏾","👼🏿","💆","💆🏻","💆🏼","💆🏽","💆🏾","💆🏿","💇","💇🏻","💇🏼","💇🏽","💇🏾","💇🏿","🙍","🙍🏻","🙍🏼","🙍🏽","🙍🏾","🙍🏿","🙎","🙎
[{
"emoji": "😀",
"name": "GRINNING FACE",
"code": "U+1F600"
}, {
"emoji": "😁",
"name": "GRINNING FACE WITH SMILING EYES",
"code": "U+1F601"
}, {
"emoji": "😂",
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<style>
textarea {
width: calc(100% - .5em);
height: 50vh;
}
'use strict';
module.exports = function nodePromise(fn) {
return new Promise((resolve, reject) => {
fn((err, res) => err ? reject(err) : resolve(res));
});
};
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';
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')
);
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'],
// 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) {
@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',