Skip to content

Instantly share code, notes, and snippets.

View guest271314's full-sized avatar
💭
Fix WontFix

guest271314

💭
Fix WontFix
View GitHub Profile
@guest271314
guest271314 / polyglot.md
Created November 10, 2024 01:37
Just an idea...

Taking the JavaScript runtime agnostic approach a step further I'm thinking about combining qjs, node, deno, and bun into a single executable (~350 MB, still less than Rust tool chain at ~500 MB) that I can reference as such within JavaScript and/or TypeScript in the same .js and/or .ts script, and do something like this

import { cc } from "bun:ffi";
import ( $ } from "jsr:@david/dax";
std.popen(...);
export class FACharacterClasses {
static unicodeCategories = [
[
65,
90,
192,
214,
216,
222,
256,
@guest271314
guest271314 / strip_types.md
Last active November 2, 2024 18:37
Strip TypeScript types in Node.js, Deno, and Bun

Node.js

node --no-warnings node-strip-types.js https://raw.githubusercontent.com/user/repo/refs/heads/main/file.ts transform
node --no-warnings node-strip-types.js ../path/to/file.ts transform
@guest271314
guest271314 / fetch-jsr-files.js
Last active October 29, 2024 08:29
Fetch non-entrypoint, non-TypeScript files from jsr:, write files to local vendor directory containing enttrypoint .ts file
// Fetch non-entrypoint, non-TypeScript files from jsr:,
// write files to local vendor directory containing enttrypoint .ts file
// Usage: deno -A fetch-jsr-files.js @scope mod
const [scope, mod] = Deno.args;
const { latest: version } = (await import(
`https://jsr.io/${scope}/${mod}/meta.json`,
{
with: {
@guest271314
guest271314 / nodejs-amaro-bundle.js
Created October 28, 2024 05:08
Node.js amaro bundled with bun build
This file has been truncated, but you can view the full file.
// bun build node_modules/amaro/dist/index.js --target=node --outfile=nodejs-amaro-bundle.js
import { createRequire } from "node:module";
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
var __require = /* @__PURE__ */ createRequire(import.meta.url);
// node_modules/amaro/dist/index.js
var require_dist = __commonJS((exports, module) => {
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@guest271314
guest271314 / deno-ts-js-cache.js
Last active October 27, 2024 06:48
Transpile TypeScript to JavaScript using Deno built-ins
// Transpile TypeScript to JavaScript using Deno built-ins
// Usage: deno -A deno-ts-js-cache.js nm_typescript.ts
// Write Deno's generated cache .ts.js file to stdout and current directory
// ts: Path to .ts script
const [ts] = Deno.args;
const url = new URL(import.meta.resolve(ts));
const { pathname } = url;
const filename = pathname.split("/").at(-1);
const decoder = new TextDecoder();
// Path to generated cache .ts.js script
@guest271314
guest271314 / compiling_npm_to_standalone_executable.md
Last active October 20, 2024 05:56
Compiling npm to a standalone executable: Which runtime can do this out of the box; node, deno, or bun?
@guest271314
guest271314 / chrome-mst-audio-render-silence.md
Last active October 8, 2024 02:51
Fixing Chrome's broken MediaStreamTrack of kind audio to render silence per the specification

The specification for MediaStreamTrack is located in W3C Media Capture and Streams.

In pertinent part at 4.3.1.1 Media Flow

The result for the consumer is the same in the sense that whenever MediaStreamTrack is muted or disabled (or both) the consumer gets zero-information-content, which means silence for audio and black frames for video. In other words, media from the source only flows when a MediaStreamTrack object is both unmuted and enabled. For example, a video element sourced by a MediaStream containing only muted or disabled MediaStreamTracks for audio and video, is playing but rendering black video frames in

@guest271314
guest271314 / aw.js
Last active October 6, 2024 00:53
MediaStreamTrackGenerator vs. AudioWorklet
globalThis.Piper = class Piper {
constructor({
text,
voice
} = {
text: "Speech synthesis.",
voice: "male",
}) {
// Encoded into Web extension iframe URL
this.params = new URLSearchParams(Object.entries({
@guest271314
guest271314 / generateIdForPath.js
Created September 25, 2024 23:51
Generate Chrome extension ID from path
// Generate Chrome extension ID from absolute path
// https://stackoverflow.com/a/26058672
// https://stackoverflow.com/a/61448618
// https://gist.github.com/dfkaye/84feac3688b110e698ad3b81713414a9
// generateIdForPath("/home/user/javascript").then(console.log).catch(console.error);
async function generateIdForPath(path) {
return [
...[
...new Uint8Array(
await (globalThis?.webcrypto?.subtle || globalThis?.crypto?.subtle).digest(