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 / 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(
@guest271314
guest271314 / golfing-native-messaging-host.md
Last active September 3, 2024 03:29
Golfing a Native Messaging host with tee command
@guest271314
guest271314 / nm_nodejs_eval.js
Last active September 11, 2024 02:19
Compile Node.js Native Messaging host to Single executable application
// const { createRequire } = require("node:module");
// require = createRequire(__filename);
const spawn = require("node:child_process").spawn;
const Duplex = require("node:stream").Duplex;
const runtime = navigator.userAgent;
const buffer = new ArrayBuffer(0, {
maxByteLength: 1024 ** 2,
});
const view = new DataView(buffer);
@guest271314
guest271314 / web_speech_api_execute_arbitrary_code.md
Last active September 13, 2024 04:47
Exploiting Web Speech API to execute arbitrary native code

Exploiting Web Speech API to execute arbitrary native code

If you have used Web Speech API on a desktop browser you have either 1) used Google voices, which are the default on Chrome, which sends your text input to a remote Google server and sends back the audio to the browser; or 2) used Brailcom's Speech Dispatcher by launching chrome with --enable-speech-dispatcher flag.

With all of the advertising and slogans about "artificial intelligence" one might think that Text-To-Speech and -Speech-To-Text would be happening in the browser by now. It's not. See Re: Issue 263510047: Release TTS and STT source code and Google voices as FOSS,

@guest271314
guest271314 / runtime_agnostic_swbn_iwa_build.md
Last active August 18, 2024 17:06
Supporting Deno and Bun and using Web Cryptography API for building Signed Web Bundles and Isolated Web Apps

In rollup-plugin-webbundle there is this

Requirements

This plugin requires Node v14.0.0+ and Rollup v1.21.0+.

which implies Node.js and Rollup are required to build a Signed Web Bundle and Isolated Web App.

What about Deno and Bun?

The repository uses node:crypto to generate secure curve crypto keys. The problem is Node.js node:crypto module cannot be polyfilled or exported

@guest271314
guest271314 / update_rewrite.md
Created August 17, 2024 19:22
When version updates to JavaScript libraries mean you have to re-write code by hand, again

Designing and writing a software library is akin to building a house

I'll begin by likening writing source code of a library to building a house.

A general contractor has to make every move count. From selecting subcontractors to ordering materials, scheduling phases of construction, reading approved plans, contacting architects and engineers when questions or issues arise in the field on site, making sure subtractors get paid, keeping the owners happy, passing inspections, managing time, and importantly, thinking about how access, and repair whatever is being built and installed, because the general contractor is still on the hook years after

@guest271314
guest271314 / bun-fmt.md
Last active August 31, 2024 03:25
Bun code formatter using bun build and bun -e
$ bun build fmt.js --no-bundle | bun -e 'Bun.write(Bun.file("fmt.js"), await Bun.file("/dev/stdin").text())'

oven-sh/bun#2246

@guest271314
guest271314 / javascript_to_wasm.md
Created August 10, 2024 21:20
Compiling JavaScript to WASM using Bytecode Alliance's javy

Today we are going to compile JavaScript source code to WASM using javy.

The compiled WASM module will read and echo standard input as a Native Messaging host.

The protocol, in brief is

Chrome starts each native messaging host in a separate process and communicates with it using standard input (stdin) and standard output (stdout). The same format is used to send messages in both directions; each message is serialized using JSON, UTF-8 encoded and is preceded with 32-bit message length in native byte order. The maximum size of a single message from the native messaging