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 / node-http2-server.js
Last active February 23, 2025 22:29
Node.js HTTP/2 server using WHATWG Streams
import { createSecureServer } from "node:http2";
import { readFileSync } from "node:fs";
import { Readable, Writable } from "node:stream";
const responseInit = {
status: 200,
headers: {
"Cache-Control": "no-cache",
"Content-Type": "text/plain; charset=UTF-8",
"Cross-Origin-Opener-Policy": "unsafe-none",
@guest271314
guest271314 / file-system-access-write.md
Created February 15, 2025 05:32
Write files with File System Access API without creating orphan .crswap files

The reason for using

await readable.pipeTo(writable)

is the .crswap file is automatically removed when the Promise fulfills.

Here's one way to write arbitrary volumes of data to the same file, without generating a bunch of orphan .crswap files.

The gist is

@guest271314
guest271314 / assemblyscript-deno-bun-node-js.md
Last active February 28, 2025 03:26
Executing AssemblyScript directly, and compiling to JavaScript with tsc, Deno, and Bun (and executing WASM directly with bun)

Executing AssemblyScript directly, and compiling to JavaScript with tsc, Deno, and Bun (and executing WASM directly with bun)

Installing

bun install typescript@next assemblyscript @types/node
bun add v1.2.1-canary.15 (5633ec43)

installed [email protected] with binaries:
 - tsc
@guest271314
guest271314 / bench.js
Last active January 20, 2025 12:39
TypeScript .ts file execution benchmarks for Deno, Bun, Node.js
Deno.bench("Deno, Bun, Node.js TypeScript Benchmarks", async (b) => {
// Open a file that we will act upon.
// using file = await Deno.open("a_big_data_file.txt");
// Tell the benchmarking tool that this is the only section you want
// to measure.
b.start();
// Now let's measure how long it takes to read all of the data from the file.
// await new Response(file.readable).arrayBuffer();
@guest271314
guest271314 / no-monopoly.md
Last active January 12, 2025 00:06
How to set a user-defined default search engine (and custom new tab page) in Chromium browser

In Chromium or Chrome browsers navigate to chrome://settings/searchEngines. The page looks something like this. Here I'm showing what Chromium Version 134.0.6949.0 (Developer Build) (64-bit). On Linux.

Screenshot_2025-01-11_14-45-55

Notice that ".(Default)".

@guest271314
guest271314 / shermes-stdin.md
Created January 7, 2025 08:24
Reading stdin in Static Hermes
@guest271314
guest271314 / high-skill-cheap-labor.md
Last active January 4, 2025 15:25
"Highly skilled" programmers for "high-tech" or capitalism working as expected?

"Highly skilled" programmers for "high-tech" or capitalism working as expected?

I'm currently domiciled in the U.S. I don't watch or listen to "the news". I don't support Democrats or Republicans.

The other day somebody told me there's an H-1B visa schism within the Republican Party.

I said, alright, show me what "the left" says, and show me

@guest271314
guest271314 / shermes-wasi.md
Last active February 7, 2025 11:24
Compiling JavaScript to WASM with WASI support using Static Hermes
@guest271314
guest271314 / fsopen-wasm-esbuild.js
Created December 29, 2024 17:58
CommonJS to ECMAScript Module - deno produces incorrect result unless parsed as CommonJS
var Module = typeof Module != "undefined" ? Module : {};
var ENVIRONMENT_IS_WEB = typeof window == "object";
var ENVIRONMENT_IS_WORKER = typeof WorkerGlobalScope != "undefined";
var ENVIRONMENT_IS_NODE = typeof process == "object" &&
typeof process.versions == "object" &&
typeof process.versions.node == "string" && process.type != "renderer";
if (ENVIRONMENT_IS_NODE) {}
var moduleOverrides = Object.assign({}, Module);
var arguments_ = [];
var thisProgram = "./this.program";
@guest271314
guest271314 / rust-usb-install.md
Created December 29, 2024 03:44
Installing Rust on an external USB and keeping the installation there

Took me a while to figure this out. Posted here to share just in case anybody else in the world is trying to install Rust on an external USB device, for example, to get around build with Rust resulting in running out of disk space on a live Linux USB running on a temporary file system. See Is there a way to [disable] caching crates?.

I have been trying to build Roll your own JavaScript runtime for a while now. My previous attempts resulted in an error due to the disk space being filled by cargo writing downloaded crates to $HOME/.cargo. I start out with around only 1 GB on the live Linux USB temporary file system. I have access to a few external USB devices ranging between 64 GB and 128 GB capacity, so that's not the issue.

This is what worked for me. Making use of CARGO_HOME and RUST_HOME environment variables, along with naming the directories accordingly