Skip to content

Instantly share code, notes, and snippets.

View guest271314's full-sized avatar
💭
Fix WontFix

guest271314

💭
Fix WontFix
View GitHub Profile
// Helper function to play audio
function playAudio(audioFile) {
console.log(audioFile, chrome.runtime.getURL(audioFile));
const audio = new Audio(chrome.runtime.getURL(audioFile)); // Use chrome.runtime.getURL for packaged extension resources
// Play the audio only when the EventListener for click is triggered
audio.play();
}
// Helper function for setting volume
function setAudioVolume(volumeLevel) {
@guest271314
guest271314 / float32array_to_int32array.md
Last active March 10, 2024 00:29
Float32Array to Int32Array
// https://stackoverflow.com/q/78133607/2801559
// https://codegolf.stackexchange.com/q/271654/31257
var floats = new Float32Array([-0.1, 1.0])
var i0 = new Int32Array(floats.buffer);
var i1 = Int32Array.from(floats, f => f < 0 ? f * 32768 : f * 32767);
var i2 = Int32Array.from(floats, f => f * 32768);
var i3 = Int32Array.from(floats, f => (f<<15)-(f<0)*f);
var i4 = Int32Array.from(floats, f => f * 1<<15);
var i5 = Int32Array.from(floats, f =&gt; f * 32767.5);
@guest271314
guest271314 / esm_file_protocol.md
Last active March 9, 2024 18:13
Ecmascript Modules on file: protocol

test.html

<!doctype html>
<html>
<head></head>
<body>
<script type="module">
import * as data from "./exports.js";
console.log(data, location.protocol);
@guest271314
guest271314 / firefox_audioworklet_bug.md
Created March 5, 2024 01:20
Firefox AudioWorklet bug?

Screenshot_2024-03-04_17-04-39

@guest271314
guest271314 / MP3Stream.js
Created February 18, 2024 16:32
MP3 encoder
/*
var url = URL.createObjectURL(new Blob([await (await fetch('https://raw.githubusercontent.com/guest271314/captureSystemAudio/master/native_messaging/capture_system_audio/lame.min.js')).text()],{
type: "text/javascript"
}));
*/
var dir = await navigator.storage.getDirectory();
var handle;
try {
handle = await dir.getFileHandle("lame.js", {
create: false,
@guest271314
guest271314 / google_ai_ad.md
Created February 14, 2024 04:55
Google advertising "A.I.". Where's TTS/STT shipped in Chromium and Chrome?

chrome_screenshot_www google com

@guest271314
guest271314 / delete_deno_global_cache.js
Last active February 12, 2024 07:53
Delete Deno global cache directories
const decoder = new TextDecoder();
const command = new Deno.Command(Deno.execPath(), {
args: [
"info",
"--json",
],
});
const { code, stdout, stderr } = await command.output();
// https://tc39.es/ecma262/multipage/structured-data.html#sec-json.parse
// 11.b. Let rootName be the empty String.
@guest271314
guest271314 / gdm_capture_monitor_device_on_chromium.js
Created February 8, 2024 05:32
Finally possible to capture monitor devices in Chromium and Chrome on Linux
// Finally possible to capture speechSynthesis.speak() on Chromium and Chrome
// Enable Speech Dispatcher, PulseAudio loopback for screen capture, disable default WebRTC input volume adjustment from 100% to 8%
// chrome --enable-speech-dispatcher --enable-features=PulseaudioLoopbackForScreenShare --disable-features=WebRtcAllowInputVolumeAdjustment
// Still have to manually select share system audio in picker with systemAudio set to "include"
// https://issues.chromium.org/issues/40155218
let stream = await navigator.mediaDevices.getDisplayMedia({
// We're not going to be using the video track
video: {
width: 0,
height: 0,
@guest271314
guest271314 / buffer-bun-bundle.js
Last active January 20, 2024 04:00
feross/buffer bundled to Ecmascript Module
// git clone https://github.com/feross/buffer
// cd buffer
// bun install base64-js ieee754
// bun build ./index.js --target=browser --outfile=buffer.js
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
// node_modules/base64-js/index.js
var require_base64_js = __commonJS((exports) => {
var getLens = function(b64) {
@guest271314
guest271314 / compiling_standalone.md
Last active April 9, 2024 08:48
Compiling a standalone executable using modern JavaScript/TypeScript runtimes

Compiling a standalone executable using modern JavaScript/TypeScript runtimes

We have the same code working using node, deno, and bun.

E.g.,

bun run index.js