This file contains 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
/** | |
* @typedef {Object} InputData | |
* @property {string} keyToCheck | |
* @property {string} storageId | |
* | |
* @typedef {string | number | boolean | null | undefined | Record<string, JSONValue> | JSONValue[]} JSONValue | |
* | |
* @typedef {Object} StoreClient | |
* @property {() => Promise<void>} clear | |
* @property {(key: string) => Promise<void>} delete |
This file contains 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
import type { CSSObject } from "@emotion/react"; | |
/** | |
* Clamp a number between a minimum and maximum value. | |
*/ | |
export const clamp = (value: number, min: number, max: number) => | |
Math.min(Math.max(value, min), max); | |
/** | |
* Fully cover an element. Can optionally add an offset to the edges. |
This file contains 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
// Uses Bun, but this could quite easily use any storage (Node.js fs, in-browser `localStorage`, etc.) | |
import * as Bun from "bun"; | |
import * as fs from "node:fs/promises"; | |
export interface Expirable<T> { | |
value: T; | |
expires: number | null; | |
} | |
export interface CacheOptions { |
This file contains 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
import { inspect } from "bun"; | |
import { SimpleCache } from "./simple-cache"; | |
interface BurnBanData { | |
counties: string; | |
issued: string; | |
expires: string; | |
exemptions: string; | |
} |
This file contains 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
/** | |
* Prevents an attribute from being changed on an element, meaning once the | |
* attribute is changed, it will be immediately set back to the original value. | |
* @param {string} selector | |
* @param {string} attributeName | |
*/ | |
function preventAttributeChange(selector, attributeName) { | |
const element = document.querySelector(selector); | |
const originalValue = element.getAttribute(attributeName); |
This file contains 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 | |
set -eo pipefail | |
directory="$1" | |
cd "$directory" | |
files=() | |
# Get `wav` files, ignoring `other.wav` | |
for file in *.wav; do | |
if [[ $file != "other.wav" ]]; then |
This file contains 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 crypto = require("crypto"); | |
// HACK: Fix Node.js 17+ "digital envelope routines::initialization error" | |
// https://stackoverflow.com/q/69692842/1130172 | |
const origCreateHash = crypto.createHash; | |
crypto.createHash = (algorithm, options) => { | |
const newAlgorithm = algorithm === "md4" ? "md5" : algorithm; | |
return origCreateHash(newAlgorithm, options); | |
}; |
This file contains 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 fontElementMap(selector = "*", onlyVisible = true) { | |
const allElements = document.querySelectorAll(selector); | |
const fontElements = {}; | |
for (element of allElements) { | |
const style = window.getComputedStyle(element); | |
const fontFamily = style.getPropertyValue("font-family"); | |
if (!fontFamily) { | |
continue; |
This file contains 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 | |
# Formatting helpers | |
bold() { | |
printf "\033[1m%s\033[0m\n" "$*" | |
} | |
dim() { | |
printf "\033[2m%s\033[0m\n" "$*" | |
} |
This file contains 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 | |
declare -A IMPORTS | |
# Returns the path of the script of the caller | |
function relative_path() { | |
dirname "${BASH_SOURCE[1]}" | |
} | |
# Imports a module |
NewerOlder