Skip to content

Instantly share code, notes, and snippets.

const compose = (f, g) => a => f(g(a));
const takeUntil = (f, xs) => xs.slice(0, xs.findIndex(f));
const id = a => a;
const not = a => !a;
const takeWhile = (f, xs) => takeUntil(compose(not, f), xs);
const takeTruthy = xs => takeWhile(id, xs);

Keybase proof

I hereby claim:

  • I am slikts on github.
  • I am slikts (https://keybase.io/slikts) on keybase.
  • I have a public key ASADBAyX3ySALSbFLJAaG-CR7gVARLIAhfqxVgSX1RDCuwo

To claim this, I am signing this object:

Verifying my Blockstack ID is secured with the address 1GypFJtCV2dG5kH8JWuCNNxE6ENLpRcEVu https://explorer.blockstack.org/address/1GypFJtCV2dG5kH8JWuCNNxE6ENLpRcEVu
const numberToRawBinary = n => {
const data = new DataView(new ArrayBuffer(8));
data.setFloat64(0, n);
return Array.from(new Uint8Array(data.buffer), x =>
x.toString(2).padStart(8, 0)
).join("");
};
@slikts
slikts / settle.js
Last active June 2, 2018 10:45
Promise.settle()
const settle = ps =>
Promise.all(
ps.map(async p => {
let [value, error, ok] = [null, null, false];
try {
value = await p;
ok = true;
} catch (e) {
error = e;
}
@slikts
slikts / gist:1159341
Created August 20, 2011 16:56
mangareader.net user CSS
#wrapper_header,
#adtop,
#topchapter,
#bottomchapter,
#adfooter,
#zoomer,
#wrapper_footer,
.zoomimg {
display: none;
}
const zip = (xs, ys) => xs.slice(0, Math.min(xs.length, ys.length)).map((x, i) => [x, ys[i]]);
const Delay = duration => new Promise(resolve => setTimeout(resolve, duration))
class PairWeakMap<A extends object, B extends object, C> {
map: WeakMap<A, WeakMap<B, C>>
constructor() {
this.map = new WeakMap()
}
set(a: A, b: B, c: C): this {
const { map } = this
let submap = map.get(a)
interface Settable<A, B> {
set(key: A, value: B): this
}
interface Gettable<A, B> {
get(key: A): B | undefined
}
interface GenericMap<A, B> extends GetSettable<A, B> {
has(key: A): boolean