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 / file-to-arraybuffer.md
Last active June 11, 2024 00:55
File to ArrayBuffer with attributes, ArrayBuffer to File with attributes

File interface

Blob and File (which inherits from Blob) have an arrayBuffer() method, e.g.,

const file = new File(
  [
    new Float32Array(Array.from({
      length: 1000,
@guest271314
guest271314 / parse-chromium-default-file-system.js
Created June 2, 2024 22:40
Parse leveldb in Chromium configuration folder containing Origin Private File System written by navigator.storage.getDirectory()
async function parseChromeDefaultFileSystem(path) {
try {
const set = new Set([
32, 45, 46, 47, 48, 49, 50, 51, 52, 53,
54, 55, 56, 57, 58, 64, 65, 66, 67, 68,
69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
89, 90, 95, 97, 98, 99, 100, 101, 102,
103, 104, 105, 106, 107, 108, 109, 110,
111, 112, 113, 114, 115, 116, 117, 118,
@guest271314
guest271314 / 000003.log
Created June 2, 2024 15:18
Default/File System/.../Paths/000003.log
rM0Ux/LAST_FILE_ID0LAST_INTEGER-1FCHILD_OF:0:persistent-serviceworker1140persistent-serviceworkerUx/LAST_FILE_ID100Ux/TLAST_INTEGER0ZlCHILD_OF:1:README.md224000/00000000README.mdLAST_FILE_ID2KMD140persistent-serviceworkerUx/LAST_INTEGER1fVwCHILD_OF:1:README.md.crswap338400/00000001README.md.crswapLAST_FILE_ID3D140persistent-serviceworkerUx/dCHILD_OF:1:README.md.crswap324000/00000001README.mdInD140persistent-serviceworkerUx/D140persistent-serviceworkerUx/UeKCHILD_OF:1:chromium_extension_web_accessible_resources_iframe_message_event44X@chromium_extension_web_accessible_resources_iframe_message_eventUx/LAST_FILE_ID4TD140persistent-serviceworkerUx/HLAST_INTEGER2.tCHILD_OF:4:background.js558400/00000002background.jsLAST_FILE_ID5:l4X@chromium_extension_web_accessible_resources_iframe_message_eventUx/QL LAST_INTEGER3NwCHILD_OF:4:background.js.crswap66800/00000003background.js.crswapLAST_FILE_ID6l4X@chromium_extension_web_accessible_resources_iframe_message_eventUx/blCHILD_OF:4:background.js.crswap658400/00000003back
@guest271314
guest271314 / createReadWriteDirectoriesInBrowser.js
Last active June 5, 2024 02:50
How to create, recreate, and transfer directories to peers in the browser. Part 1: Creating directories in the local filesystem using HTML
// *Mostly* specfication conformant
// <input type="file" webkitdirectory> does not upload empty directories
// drop event with DataTransfer.item.getAsFileSystemDirectory() *does*
// list empty folders.
// W3C File API does not have a way to represent an empty directory.
// We use a File with type set to "inode/directory".
try {
// HTMLInputElement.webkitdirectory
// https://wicg.github.io/entries-api/#dom-htmlinputelement-webkitdirectory
var html = `<form
@guest271314
guest271314 / sha1-uint8array.min.js
Last active May 21, 2024 19:58 — forked from robertrypula/web-socket-server.js
WebSocket - binary broadcast example (JavaScript runtime agnostic implementation without any dependency)
// deno bundle https://raw.githubusercontent.com/kawanet/sha1-uint8array/main/lib/sha1-uint8array.ts sha1-uint8array-bundle.js
// bun build --minify sha1-uint8array-bundle.js --outfile=sha1-uint8array.min.js
var z=function(t){if(t&&!w[t]&&!w[t.toLowerCase()])throw new Error("Digest method not supported");return new E},p=function(t,e,i,s){if(t===0)return e&i|~e&s;if(t===2)return e&i|e&s|i&s;return e^i^s},B=function(){return new Uint8Array(new Uint16Array([65279]).buffer)[0]===254},y=[1518500249|0,1859775393|0,2400959708|0,3395469782|0],w={sha1:1};class E{A=1732584193|0;B=4023233417|0;C=2562383102|0;D=271733878|0;E=3285377520|0;_byte;_word;_size=0;_sp=0;constructor(){if(!u||_>=8000)u=new ArrayBuffer(8000),_=0;this._byte=new Uint8Array(u,_,80),this._word=new Int32Array(u,_,20),_+=80}update(t){if(typeof t==="string")return this._utf8(t);if(t==null)throw new TypeError("Invalid type: "+typeof t);const{byteOffset:e,byteLength:i}=t;let s=i/64|0,r=0;if(s&&!(e&3)&&!(this._size%64)){const h=new Int32Array(t.buffer,e,s*1
@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