Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Fix WontFix

guest271314

💭
Fix WontFix
View GitHub Profile
@guest271314
guest271314 / webserver.c
Last active March 29, 2023 07:58
C Web server
View webserver.c
// webserver.c
// ./webserver "./script.sh"
//
// Copyright 2023 J.P.H. Bruins Slot
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the “Software”), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is furnished to do
@guest271314
guest271314 / banning_doesnt_fix_bugs.md
Created March 7, 2023 03:12
Banning a user doesn't magically make your bugs go away
View banning_doesnt_fix_bugs.md

Both MDN Native Messaging example and Google Chrome extension samples had a bug in the Python implementation of the Native Messaging host.

Native Messaging host can send 1MB of data to the client (browser) per message.

The Python code was counting space characters.

Additionally, using python alone in a shell script, and not using python3 will fail on systems that do not have python in PATH,

@guest271314
guest271314 / json_vs_streams.md
Created February 19, 2023 06:01
Streaming data locally: Native Messaging with IPC and JSON vs. HTTPS server with fetch(), ReadableStream, Response
View json_vs_streams.md

The application code is the same: parec -d @DEFAULT_MONITOR@ to capture 2 channel PCM output to headphones or speakers.

The values below were taken during the capture and stream to the browser.

Deno (HTTPS server, fetch() in browser, ReadableStream, Response in server):

  • VSZ 5.4GB
  • RSS 38.1MB
  • CPU (deno) 38%
  • CPU (system) 85%
@guest271314
guest271314 / background.js
Created November 4, 2022 01:54
Stream same data to all non-chrome tabs
View background.js
const start = new Date();
let streams = [];
let data = [...Array(1000)].map((_, i) => i);
let encoder = new TextEncoder();
let resolve;
let promise = new Promise((_) => (resolve = _));
let readable = new ReadableStream({
start: async (_) => {
// console.log('Original stream');
return promise;
@guest271314
guest271314 / background.js
Created October 29, 2022 02:33
ScreenshotTest
View background.js
// https://www.reddit.com/r/learnjavascript/comments/yeodfh/chrome_extension_error_extensionsjs2897_uncaught/
// Use a Port for multiple messages
chrome.runtime.onConnect.addListener((port) => {
console.log(port);
port.onMessage.addListener(async (message) => {
if (message.name === 'stream' && message.streamId) {
console.log(message.streamId);
try {
const stream = await navigator.mediaDevices.getUserMedia({
video: {
@guest271314
guest271314 / native_messaging_javascript_runtime_tests.md
Last active January 8, 2023 05:55
Native Messaging JavaScript runtime tests
View native_messaging_javascript_runtime_tests.md

Native Messaging JavaScript runtime hosts tested:

  • QuickJS
  • Node.js
  • Deno
  • Bun

Test: Send new Array(10000) from client to host, send message back to client, 100 times, measure time with performance.now().

@guest271314
guest271314 / fetch-node-nightly-executable.js
Created July 9, 2022 01:18
Fetch node nightly executable
View fetch-node-nightly-executable.js
let fileSystemHandle = await showSaveFilePicker({ suggestedName: 'node' }),
writable,
writer,
file;
let status = await fileSystemHandle.requestPermission({ mode: 'readwrite' });
let osArch = 'linux-x64';
// https://github.com/InvokIT/js-untar/
class PaxHeader {
constructor(fields) {
this._fields = fields;
@guest271314
guest271314 / The_insanity_of_censorship.txt
Created July 4, 2022 17:28
The insanity of censorship
View The_insanity_of_censorship.txt
"Sun, Jul 3, 3:22 PM
Hi guest271314, Your account, @guest271314 has been locked for violating the Twitter Rules.
Specifically for: Violating our rules against hateful conduct.
You may not promote violence against, threaten, or harass other people on the basis of race,
ethnicity, national origin, sexual orientation, gender, gender identity, religious affiliation,
age, disability, or serious disease.
avatar guest271314 @guest271314