Skip to content

Instantly share code, notes, and snippets.

View opendirectory.js
(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/'
@Hashbrown777
Hashbrown777 / bytesTransfer.js
Created Sep 28, 2021
Convert buffers of one word-length to another
View bytesTransfer.js
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);
View combinePNGs.sh
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
View gitify_script_functions.ps1
gci `
| %{
("`n", $_.Name, @($_ | gci -File).Length) -join "`t"
$_ `
| gci -File `
| %{
(
$_.CreationTime.ToString('yyyy-MM-dd'),
$_.Length,
$_.Name
View webmp4.sh
ffmpeg \
-i "$1.mp4" \
-c:v libx264 \
-crf 23 \
-c:a aac \
-movflags faststart \
-maxrate 2M \
-bufsize 2M \
"$dest/$1.mp4"
@Hashbrown777
Hashbrown777 / png2jls.js
Created Jun 25, 2021
testing jpeg-ls compression rates
View png2jls.js
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';
@Hashbrown777
Hashbrown777 / emails.ps1
Last active Jun 15, 2021
Gets all your unread emails from all your accounts and subdirectories in outlook and presents them to you in a table
View emails.ps1
. ./async.ps1
. ./asynclet.ps1
. ./unicode.ps1
. ./windows.ps1
. ./wrap.ps1
$_TABLE_TITLE = 'The powershell window will show progress. You can email or run again by making a selection'
$timer = [system.diagnostics.stopwatch]::StartNew()
$selection = [Asynclet]::new(
'Out-GridView',
View MessagePair.ts
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,
@Hashbrown777
Hashbrown777 / repairBrokenXML.js
Last active May 20, 2021
Fixes improper close order in XML
View repairBrokenXML.js
//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) => (