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 / web-socket-server.js
Created April 25, 2024 13:55 — forked from robertrypula/web-socket-server.js
WebSocket - binary broadcast example (pure NodeJs implementation without any dependency)
// Copyright (c) 2019-2021 Robert Rypuła - https://github.com/robertrypula
/*
+--------------------------------------------------+
| Binary broadcast WebSocket server in pure NodeJs |
+--------------------------------------------------+
Based on great article created by Srushtika Neelakantam:
https://medium.com/hackernoon/implementing-a-websocket-server-with-node-js-d9b78ec5ffa8
@guest271314
guest271314 / upFetch.js
Created April 21, 2024 18:11
L-Blondy up-fetch bundled with bun buil
// response-error.ts
class ResponseError extends Error {
name;
response;
options;
data;
constructor(res, data, options) {
super(`Request failed with status ${res.status}`);
this.data = data;
this.name = "ResponseError";
@guest271314
guest271314 / http_over_tcp_browser_server.md
Last active April 20, 2024 04:45
How to use the browser as an HTTP over TCP socket server

Today we will be using the Web browser (Google Chrome for Testing 125) as a local HTTP over TCP socket server.

WICG Direct Sockets specifies an API that provides TCPSocket, UDPSocket, and TCPServerSocket.

In Chromium based browsers, for example Chrome, this capability is exposed in an Isolated Web Apps (IWA).

Previously we have created an IWA that we launch from arbitrary Web sites with open(),

@guest271314
guest271314 / reddit_no_markdown.md
Created April 14, 2024 18:24
How is it that Reddit Web site maintainers can't figure out how to honor Markdown as default setting for comments and posts?

Screenshot_2024-04-14_11-12-28

@guest271314
guest271314 / signals-proposal-bun-bundle.js
Created April 8, 2024 03:20
Signals proposal polyfill bundled with Deno
// vendor/esm.sh/v135/signal-polyfill@0.1.0/denonext/signal-polyfill.mjs
var $ = function(e, o) {
return Object.is(e, o);
};
var N = function(e) {
let o = i;
return i = e, o;
};
var ce = function() {
return i;
@guest271314
guest271314 / arbitrary_import_specifiers.md
Last active April 7, 2024 22:26
Intercepting and handling arbitrary static and dynamic Ecmascript import specifiers, protocols and file extensions
@guest271314
guest271314 / harmony.md
Last active April 20, 2024 09:01
Why I use node, deno, bun, qjs, tjs at the same time

Why I use node, deno, bun, qjs, tjs at the same time.

Winds up being a (not the) rather comprehensive JavaScript toolbox. The idea being for the modern JavaScript programmer can use all of the tools available for a given requirement, task or job, without preference for any. No external bundlers or compilers are needed. No frameworks are needed. I can use qjs or tjs for systems with minimal RAM and disk space; and when I want to use Web API's deno makes an effort to provide those interfaces. In some cases I can run the exact same code in bun, deno, and node, which provides a means to perform 1:1 testing as to performance.

There's probably a few things I am unintentionally omitting below. These are just a brief synposis. I'll update accordingly.

@guest271314
guest271314 / file.md
Created March 30, 2024 16:57
Implementing file: protocol support for WHATWG fetch() in Node.js without fs or import
@guest271314
guest271314 / undici_fetch_throwing_on_file_protocol_request.md
Created March 24, 2024 02:52
undici@6.10.1 fetch() throwing for file: protocol request
TypeError: fetch failed
    at fetch (/node_modules/undici/index.js:109:13) {
  [cause]: TypeError: Invalid URL
      at new URL (node:internal/url:804:36)
      at parseURL (/node_modules/undici/lib/core/util.js:51:11)
      at Object.parseOrigin (/node_modules/undici/lib/core/util.js:117:9)
      at new Pool (/node_modules/undici/lib/dispatcher/pool.js:70:23)
      at Agent.defaultFactory (/node_modules/undici/lib/dispatcher/agent.js:22:7)
 at [dispatch] (/node_modules/undici/lib/dispatcher/agent.js:93:34)
@guest271314
guest271314 / read_child_process.js
Created March 23, 2024 20:21
Reading child process using node
// node --experimental-default-type=module read_child_process.js
import { spawn } from "node:child_process";
import { Duplex } from "node:stream";
const [command, args] = ["python3", ["./stream.py"]];
const { stdout, stderr } = spawn(command, args);
const { readable, writable } = Duplex.toWeb(stdout);
console.log(readable, writable);
/*
const data = await new Response(readable).text();