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 / 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

@guest271314
guest271314 / typescript_observations_skeptical.md
Created July 30, 2024 01:17
Some observations of a skeptic taking TypeScript for a spin

Full-disclosure: I was highly skeptical of any benefit using TypeScript programming language to write source code, where I enjoy writing JavaScript source code from scratch, and I don't buy the claim that TypeScript is a "superset" of JavaScript.

I look at TypeScript and see a completely different programming language, from syntax to usage, and philosophy, compared to the JavaScript programming language.

Just to see for myself what the pros and cons are, I had to take TypeScript for a brief spin in my lab.

As is my protocol when trying or learning a new programming language or application, I start with I/O, reading standard input stream, writing standard output stream, handle standard error. I usually use the Native Messaging protocol to facilitate reading and writing streams.

@guest271314
guest271314 / fastest_io.md
Last active July 27, 2024 02:57
Fastest JavaScript engines and runtimes to read standard input stream and write standard output stream
(index)
0	        'nm_qjs'	            0.1335
1	        'nm_bun'	            0.2385
2	        'nm_deno'	            0.2599000000059605
3	        'nm_nodejs'	            0.3421999999880791
4	        'nm_spidermonkey'	    0.39459999999403955
5	        'nm_d8'	                    0.4187999999821186
6	        'nm_tjs'	            0.4192000000178814
@guest271314
guest271314 / piper-web-speech-api.md
Created July 14, 2024 19:48
Adding piper module and voices to Speech Dispatcher for Web Speech API

An option for using piper and onnx voices in the browser is through Speech Dispatcher, which Chromium-based browsers (Chrome, Brave, Opera, Edge) and Firefox use for Web Speech API.

I have added the piper module to Speech Dispatcher following the instructions here module request: piper #866.

Tested on Chromium Version 128.0.6586.0 (Developer Build) (64-bit) and Firefox Nightly 130.0a1. Chromium works. Firefox does not load the piper voices.

In pertinent part.

Download the piper executable from releases, extract the contents and save to ~/.local/opt/piper.