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
#!/bin/sh | |
case $# in | |
2) PTN="$2"; PS_OPTS="$1";; | |
1) PTN="$1";; | |
*) echo "Usage: `basename $0` [PS_OPTIONS] GREP_REGEX_PATTERN"; exit 1;; | |
esac | |
PS_RES=`ps $PS_OPTS | grep -v "sh $0"` | |
echo "$PS_RES" | head -n1 | |
echo "$PS_RES" | grep --color=auto -ie "$PTN" |
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
/** Single preloader */ | |
export const preload = | |
(url: string): Promise<string> => | |
fetch(url).then(res => res.blob()).then(blob => URL.createObjectURL(blob)) | |
/** Multiple preloader */ | |
export const preloadAll = | |
(urls: { [key: string]: string }): Promise<{ [key: string]: string }> => | |
Promise.all(Object.entries(urls).map(async ([k, v]) => [k, await preload(v)])).then(Object.fromEntries) |
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
export const JSON = { | |
stringify: (obj: unknown): string => globalThis.JSON.stringify(obj, (k, v) => typeof v === 'bigint' ? v.toString() + 'n' : v), | |
parse: (json: string): object => globalThis.JSON.parse(json, (k, v) => typeof v === 'string' && v.match(/^[0-9]+n$/) ? BigInt(v.slice(0, -1)) : v), | |
} |