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
//build regexes without worrying about | |
// - double-backslashing | |
// - adding whitespace for readability | |
// - adding in comments | |
const clean = (piece) => (piece | |
.replace(/((^|\n)(?:[^\/\\]|\/[^*\/]|\\.)*?)\s*\/\*(?:[^*]|\*[^\/])*(\*\/|)/g, '$1') | |
.replace(/((^|\n)(?:[^\/\\]|\/[^\/]|\\.)*?)\s*\/\/[^\n]*/g, '$1') | |
.replace(/\n\s*/g, '') | |
); | |
const regex = ({raw}, ...interpolations) => ( |
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
type DropFirst<T extends unknown[]> = T extends [any, ...infer U] ? U : never; | |
type ResolveQueue <T> = (output :T[]) => void; | |
type RejectQueue = (error :any) => void; | |
type InitQueueParams<T> = [ResolveQueue<T>, RejectQueue]; | |
type InitQueue <T> = (...args :InitQueueParams<T>) => any; | |
type Enqueued <T> = () => Promise<T>; | |
export class Queue<T> extends Promise<T[]> { | |
private max :number; | |
private waiting :Array<Enqueued<T>>; |
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
import {Worker, TransferListItem, MessagePort, parentPort} from 'worker_threads'; | |
interface MessagePair<T extends any, U extends any> { | |
//THESE SHOULD BE PRIVATE | |
//only present in the interface as a contract BETWEEN APPLICABLE (parameterised) parties | |
//not ALL PUBLIC PARTIES | |
//as they should use the IMPLEMENTATION'S EXPOSED METHODS | |
message :(value :T) => void; | |
postMessage :( | |
value :U extends MessagePair<infer V, this> ? V : never, |
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 fs = require('fs'); | |
const child_process = require('child_process'); | |
const charls = new Promise((resolve) => { | |
const charlsJS = require('./charlsjs.js'); //https://github.com/chafey/charls-js/raw/master/dist/charlsjs.js | |
//in same directory: https://github.com/chafey/charls-js/blob/master/dist/charlsjs.wasm?raw=true | |
charlsJS.onRuntimeInitialized = () => { resolve(charlsJS); }; | |
}); | |
(async () => { | |
const file = 'image5.png'; |
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
Param($file) | |
$file = Get-Item $file | |
mkvinfo $file.FullName ` | |
| &{ | |
Begin { | |
$current = $NULL | |
} | |
Process { | |
if (!$current) { | |
} |
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
gci ` | |
| %{ | |
("`n", $_.Name, @($_ | gci -File).Length) -join "`t" | |
$_ ` | |
| gci -File ` | |
| %{ | |
( | |
$_.CreationTime.ToString('yyyy-MM-dd'), | |
$_.Length, | |
$_.Name |
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
pnmcat -jleft -tb \ | |
<(pngtopnm image139.png) \ | |
<(pngtopnm image73.png) \ | |
| pnmtopng \ | |
-alpha <(pnmcat -black -jleft -tb \ | |
<(pngtopnm -alpha image139.png) \ | |
<(pngtopnm -alpha image73.png) \ | |
) \ | |
>test.png |
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 transferBytes(inputBuffer, inputLength, inputWordSize, wordSize, create) { | |
inputWordSize |= 0; | |
const inputBytes = inputLength * inputWordSize; | |
const inputBitsize = inputWordSize << 3; | |
wordSize |= 0; | |
const bytes = (inputBytes - 1 & -wordSize) + wordSize; | |
const bitsize = wordSize << 3; | |
const buffer = create(bytes, bytes / wordSize); |
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
(async () => { | |
const ignore = /^http:\/\/waltercosand.com\/CosandScores\/Composers%20[^/]+\//; | |
const urls = [ | |
'http://waltercosand.com/CosandScores/Composers%20A-D/', | |
'http://waltercosand.com/CosandScores/Composers%20E-K/', | |
'http://waltercosand.com/CosandScores/Composers%20L-P/', | |
'http://waltercosand.com/CosandScores/Composers%20Q-Z/' | |
].reverse(); | |
const skip = [ | |
'http://waltercosand.com/CosandScores/Composers%20L-P/Mozart,%20W.%20A/Mozart%20-%20Complete%20Works%20for%20Piano/' |
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 sort(array, radix, getDigit) { | |
const counts = new Uint32Array(radix); | |
const jobs = [{start:0, end:array.length, offset:0}]; | |
while (jobs.length) { | |
const {start, end, offset} = jobs.pop(); | |
counts.fill(0); | |
counts[null] = start; | |
const sorting = array.slice(start, end); | |
for (let index = 0; index < sorting.length; ++index) { |