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
const tag = (name, attrs, close, content) => { | |
const end = close ? "/>" : ">"; | |
const pairs = []; | |
let tag; | |
Object.keys(attrs).forEach(key => { | |
if (Object.prototype.hasOwnProperty.call(attrs, key)) { | |
pairs.push(key + '="' + (attrs[key]) + '"'); | |
} | |
}); |
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
const _makeProxy = f => new Proxy(f, { | |
get (fn, prop) { | |
return U[prop] && U[prop].bind({ hold: fn }); | |
} | |
}); | |
const U = { | |
add: function (x) { | |
return _makeProxy( | |
y => ( |
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
const reduceP = (reducer, initial) => list => | |
list.reduce((acc, currentValue, index, list) => | |
acc.then(accumulator => reducer(accumulator, currentValue, index, list)), | |
Promise.resolve(initial) | |
); |
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
#!/usr/bin/env bash | |
# Setup user | |
sudo useradd -m minio | |
cd /home/minio | |
# Download minio and make it executable | |
wget https://dl.minio.io/server/minio/release/linux-amd64/minio | |
sudo chown minio:minio ./minio | |
chmod +x ./minio |
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
#!/usr/bin/env node | |
/* USAGE: | |
* html2sxml /path/to/index.html > output.sxml | |
* html2sxml < input.html > output.sxml | |
*/ | |
'use strict'; | |
const path = require("path"); |
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
const map = mapper => arr => arr.map(mapper); | |
const reduce = reducer = arr => arr.reduce(reducer); | |
const path = pathSeg => obj => | |
pathSeg.reduce((acc, segment) => acc && acc[segment], obj); | |
/* --------------vy::remap---------------- */ | |
const remap = paths => obj => | |
paths.reduce((acc, [key, seg]) => { | |
acc[key] = path(seg)(obj); |
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
/* --------------vy::comp----------------- */ | |
const comp = (f, iter, cond = () => true, count = Infinity) => { | |
const list = []; | |
for (const item of iter) { | |
if (cond(item)) list.push(f(item)); | |
if (list.length === count) break; | |
} | |
return list; | |
}; |
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
const VALUES = Symbol('VALUES'); | |
const Parser = (argv, { subcommands } = {}) => { | |
argv = argv.slice(2); | |
return { | |
get (key) { | |
if (key === VALUES) { | |
return argv.filter((x, i) => | |
(!subcommands || i !== 0) && !x.startsWith('-') | |
&& (!argv[i - 1] || !argv[i - 1].startsWith('-'))); |
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
Object.prototype[Symbol.iterator] = function () { | |
let i = 0; | |
const keys = Object.keys(this); | |
return { | |
next: () => { | |
return { | |
value: [keys[i], this[keys[i++]]], | |
done: i > keys.length, | |
}; | |
}, |
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* map(f, iter) { | |
for (const i of iter) { | |
yield f(i); | |
} | |
} | |
function* filter(f, iter) { | |
for (const i of iter) { | |
if (f(i)) yield i; | |
} |