Skip to content

Instantly share code, notes, and snippets.

View miyaokamarina's full-sized avatar
😶

Marina Miyaoka miyaokamarina

😶
View GitHub Profile
@miyaokamarina
miyaokamarina / scan-exports.js
Last active May 28, 2021 05:01
Scan JS/TS files for exported symbols
// WTFPL or MIT
//
// Extracts all the exported symbols from files.
// For example, if you have a prelude and want to feed all its symbols
// to the `webpack.ProvidePlugin` or your fav Babel auto-import plugin.
//
// Written to be used with webpack (depends on its resolver),
// but it’s pretty easy to get rid of this dependency.
//
// Only supports ES modules. Doesn’t support Flow.
@miyaokamarina
miyaokamarina / fs-extra-sync.js
Created May 28, 2021 03:24
NodeJS FS Extra Sync
// WTFPL or MIT
//
// Like `fs-extra`, but everything is sync.
// May be used with `webpack`/`enhanced-resolve`
// to allow the `resolveSync` method:
//
// const compiler = webpack(...);
//
// compiler.inputFileSystem = require('./fses');
//
html[dark] {
background-color: #000 !important;
}
* {
--yt-spec-general-background-a: #000 !important;
--yt-spec-general-background-b: #000;
--yt-spec-brand-background-primary: #000 !important;
--yt-spec-brand-background-solid: #000;
--ytd-searchbox-legacy-button-color: #090909;
@miyaokamarina
miyaokamarina / wakanim-ru-fixes.css
Created April 23, 2021 01:14
Wakanum RU web player fixes
.episodeBtns,
.price-tag,
.shares,
.header-main_item.-desktop.-credits,
.header-main_user_button,
.episodeNPEp-subtitle,
.comments-button,
.episode_buttons,
.border-list_item:last-child,
.jw-icon-rewind,
@miyaokamarina
miyaokamarina / README.md
Last active September 25, 2020 09:34
Type-level 16-bit ALU in TS.

Type-level binary arithmetics in TS.

  • Utilities:
    • 4-bit parsers:
      • Bin.
      • Dec.
      • Hex.
    • 4-bit formatters:
      • Bin.
  • Dec.
@miyaokamarina
miyaokamarina / README.md
Created September 23, 2020 09:27
Node’s `path.normalize`*, but a POSIX Shell function.

* Unlike the original, this function removes trailind slashes, and keeps leading ./ segments.

@miyaokamarina
miyaokamarina / README.md
Last active August 14, 2020 10:45
4G radio frequencies table

bands

  • band — the band number,
  • ulfl — the lowest uplink frequency of band,
  • ulfh — the highest uplink frequency of band,
  • ulnl — the lowest uplink EARFCN of band,
  • ulnh — the highest uplink EARFCN of band,
  • ulno — the offset required to calculate uplink EARFCNs,
  • dlfl — the lowest downlink frequency of band,
  • dlfh — the highest downlink frequency of band,
@miyaokamarina
miyaokamarina / README.md
Last active August 16, 2019 07:40
Classes list/dict reducer for TypeScript.

classlist.ts

Reduces list of anything that looks like classname to single space-separated string.

NB: Allows /[\w-]/ only in classnames. Classnames with other characters will be excluded from resulting list.

Requirements

  • Symbol.prototype.description (optional),
  • Reflect (optional).
@miyaokamarina
miyaokamarina / path.ts
Created June 7, 2019 08:30
Almost type-safe `path` function for TypeScript
type Falsy = '' | 0n | 0 | false | null | undefined | void;
type If<c, t, f> = c extends Falsy ? f : t;
type Cast<a, b> = a extends b ? a : b;
type Size<t> = t extends readonly any[] ? t['length'] : never;
type Head<t> = t extends readonly [any, ...any[]] ? t[0] : never;
type Last<t> = t extends readonly any[] ? t[Size<Tail<t>>] : never;
type Init<t, x = readonly []> = { 0: Init<Tail<t>, Append<x, Head<t>>>; 1: x }[If<Size<Tail<t>>, 0, 1>];
type Append<t, e> = Concat<t, readonly [e]>;
type Reverse<t, x = readonly []> = { 0: Reverse<Tail<t>, Prepend<Head<t>, x>>; 1: x }[If<Size<t>, 0, 1>];
@miyaokamarina
miyaokamarina / Await.ts
Created June 6, 2019 15:10
Recursive Promise unwrapper for TypeScript
// Works exactly as `await`/`then` in JavaScript, but for types!
// Of course, it can’t handle deep nesting (≥45±n levels) due to
// TypeScript limitations. But 45 is enough.
// License: MIT.
type Await<a> = {
0: Await<a extends PromiseLike<infer b> ? b : never>,
1: a,
}[a extends PromiseLike<any> ? 0 : 1];