Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Fix WontFix

guest271314

💭
Fix WontFix
View GitHub Profile
@guest271314
guest271314 / filestream.md
Created September 10, 2023 15:53
Creating a FIFO-type file stream pipe between the browser and local applications
View filestream.md

Today we are going to create a FIFO (First In First Out) type file stream between the browser and a local application.

The idea is to create a local file in the browser, when the file is created the local application writes data to the newly created file, in the browser we will read the data written to the file up to that point, then truncate the file to size 0, repeat, when the writing and reading of the file are complete we will remove the file from the local file system.

In this way we can configure our local application to watch for the creation of specific named files, each performing a discrete process, and stream data from the local application to the file, without using networking.

We'll be using Deno in this example for the local application. Use whatever local application you want. Node.js, QuickJS, C,

@guest271314
guest271314 / css_v._ai-hype.md
Created September 7, 2023 01:59
When one line of CSS is 100% faster than an "AI-powered developer platform" and corporate management
View css_v._ai-hype.md

GitHub management recently decided to advertise their "Copilot" product on the panel of their code viewer and preview pages.

The advertisement, which is a link, on the users' source code page claims:

Code 55% faster with GitHub Copilot

Now, that is clearly false advertising to me. Worse, it's deliberate spam on the users' source code files view, editor, and preview panel.

We won't get to that spurious claim here, as I it's really prima facie impossible to be true. There is no way GitHub determined, from independent testers in Rust, C, Elixir, JavaScript, Fortran, R, V, and so forth all wrote code "55%" faster. In the first place the human wouldn't be writing the code, the "AI" would be doing that...

@guest271314
guest271314 / Duplicity.md
Created August 31, 2023 03:04
...verify that you're a real person and not a bot... Try a new AI-powered experiment...
@guest271314
guest271314 / user-defined-tcpsocket-controller-web-api.md
Created August 26, 2023 18:23
How to connect to a TCP server from an arbitrary Web page in the browser
View user-defined-tcpsocket-controller-web-api.md

Today we are going to connect to a TCP server from the browser (an arbitrary Web page).

We will be full-duplex streaming messages sent to the server and from the server to the browser.

Chrome has implemented Direct Sockets

The initial motivating use case is to support creating a web app that talks to servers and devices that have their own protocols incompatible with what’s available on the web. The web app should be able to talk to a legacy system, without requiring users to change or replace that system.

gated behind Isolated Web Apps (IWA)

@guest271314
guest271314 / nm_nodejs.mjs
Last active August 8, 2023 07:19
Node.js fetch() does not upload ReadableStream in Native Messaging host
View nm_nodejs.mjs
#!/usr/bin/env -S node --expose-gc
// --max-old-space-size=6 --expose-gc --v8-pool-size=1
// --jitless
// Node.js Native Messaging host
// guest271314, 10-9-2022
// Browser <=> Node.js fetch() full duplex streaming
// 7-23-2023
// Exits half way through reading response when --max-old-space-size=6 is set
// Exits immediately when --jitless flag is set
@guest271314
guest271314 / nm_nodejs_fetch_duplex.mjs
Created July 23, 2023 16:00
Browser <=> Node.js fetch() full duplex streaming
View nm_nodejs_fetch_duplex.mjs
#!/usr/bin/env -S ./node --expose-gc --v8-pool-size=1
// Node.js Native Messaging host
// guest271314, 10-9-2022
// Browser <=> Node.js fetch() full duplex streaming
// 7-23-2023
// Exits half way through reading response when --max-old-space-size=6 is set
// Exits immediately when --jitless flag is set
//
// Usage:
@guest271314
guest271314 / nm_deno_fetch_duplex_server.js
Last active July 23, 2023 20:59
Browser <=> Deno fetch(), listenTls() full duplex streaming
View nm_deno_fetch_duplex_server.js
#!/usr/bin/env -S deno run -A --unsafely-ignore-certificate-errors=localhost --unstable --v8-flags="--expose-gc,--jitless"
// Deno Native Messaging host
// guest271314, 10-5-2022
// Browser <=> Deno fetch(), listenTls() full duplex streaming
// 7-22-2023
/*
Usage:
port.postMessage({url:'https://localhost:8443', method:'post', body: `new ReadableStream({
@guest271314
guest271314 / client.js
Created July 22, 2023 18:26
Deno.serve() doesn't stream, part 2
View client.js
const wait = async (ms) => new Promise((r) => setTimeout(r, ms));
fetch('https://localhost:8000', {
duplex: 'half',
method: 'post',
body: new ReadableStream({
async start(controller) {
await wait(1000);
controller.enqueue('This ');
await wait(1000);
@guest271314
guest271314 / serveTls.js
Created July 16, 2023 22:46
Slightly modified Deno serveTls module
View serveTls.js
// deno-fmt-ignore-file
// deno-lint-ignore-file
// This code was bundled using `deno bundle` and it's not recommended to edit it manually
function deferred() {
let methods;
let state = "pending";
const promise = new Promise((resolve, reject)=>{
methods = {
async resolve (value) {