Skip to content

Instantly share code, notes, and snippets.

View guest271314's full-sized avatar
💭
Fix WontFix

guest271314

💭
Fix WontFix
View GitHub Profile
@joshua-gould
joshua-gould / node-fetch-file-url.js
Last active April 23, 2024 06:21
node-fetch file URL
const fs = require('fs');
const path = require('path');
const nodeFetch = require('node-fetch');
const Request = nodeFetch.Request;
const Request = nodeFetch.Response;
fetch = function (url, options) {
const request = new Request(url, options);
if (request.url.substring(0, 5) === 'file:') {
return new Promise((resolve, reject) => {
@bayotop
bayotop / last-evet-id.md
Last active June 28, 2022 15:10
Sending arbitrary Last-Event-ID header values across origins using the EventSource API.

The EventSource API

The EventSource interface is used to receive server-sent events. It connects to a server over HTTP and receives events in text/event-stream format without closing the connection.

https://developer.mozilla.org/en-US/docs/Web/API/EventSource

Last-Event-ID

Setting an ID lets the browser keep track of the last event fired so that if, the connection to the server is dropped, a special HTTP header (Last-Event-ID) is set with the new request.

@jeffposnick
jeffposnick / register-sw.js
Last active September 13, 2021 11:53
A modern-ish SW registration script, detecting various state changes.
if ('serviceWorker' in navigator) {
window.addEventListener('load', async function() {
const registration = await navigator.serviceWorker.register('/service-worker.js');
if (registration.waiting && registration.active) {
// The page has been loaded when there's already a waiting and active SW.
// This would happen if skipWaiting isn't being called, and there are
// still old tabs open.
console.log('Please close all tabs to get updates.');
} else {
// updatefound is also fired for the very first install. ¯\_(ツ)_/¯
@Jozo132
Jozo132 / float32encoding.js
Last active November 15, 2023 07:47
JavaScript (Node.js) IEEE 754 Single precision Floating-Point (32-bit) binary conversion from and to both Hex and Bin
/* ##### float32encoding.js #####
MIT License
- Forked 'toFloat' from https://gist.github.com/laerciobernardo/498f7ba1c269208799498ea8805d8c30
- Forked 'toHex' from stackoverflow answer https://stackoverflow.com/a/47187116/10522253
- Modifyed by: Jozo132 (https://github.com/Jozo132)
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
@amishshah
amishshah / ogg-containers.md
Last active June 12, 2023 21:16
A guide to the Ogg container format for demuxing opus audio

You take a stream/buffer of binary data. The start of your data is a "Page", which has a header followed by data.

Header

You need to read the following data from the header (see https://xiph.org/ogg/doc/framing.html for more detail)

  • capture_pattern - bytes 0 to 3, must read OggS
  • stream_structure_version - byte 4, must be 0
  • header_type_flag - byte 5, a bitflag that tells you metadata about the page (is it a new packet? is a packet continued here? is it the first/last page of the stream?)
  • absolute granule position - bytes 6 to 13, not needed unless you want seeking
  • stream serial number - bytes 14 to 17, a serial number given to each stream contained in the Ogg file. This is important for playing Ogg files that contain other streams, such as video or cover art. You need to identify and only bother parsing the Opus stream.
@WebReflection
WebReflection / executable-standalone-module.md
Last active March 4, 2024 20:55
NodeJS Executable Standalone Module

Update

If you're OK in having a node-esm executable, please consider this solution.

#!/usr/bin/env sh
# the /usr/local/bin/node-esm executable
input_file=$1
shift
exec node --input-type=module - $@ <$input_file
@spvkgn
spvkgn / opus-tools_static_build.sh
Last active September 10, 2022 23:06
Script to build a statically linked opus-tools
#!/bin/sh
# ==============================================================
# Script to build a statically linked version of opus-tools
#
# Release tarballs:
# http://downloads.xiph.org/releases/opus/
# http://downloads.xiph.org/releases/ogg/
# http://downloads.xiph.org/releases/flac/
#
@bagder
bagder / http3.php
Last active July 26, 2023 14:33
HTTP/3 with PHP/CURL
if (!defined('CURL_HTTP_VERSION_3')) {
define('CURL_HTTP_VERSION_3', 30);
}
$ch = curl_init("https://cloudflare-quic.com/");
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_3);
curl_exec($ch);
@Dobby233Liu
Dobby233Liu / a.js
Last active October 23, 2022 08:58
my messing w/ msedge dev read aloud. ONLY RUN IN edge dev. i give up, so it wont work properly
var ARRAY_LENGTH = 16;
var MIN_HEX_LENGTH = 2;
class UUID {
static createUUID() {
const array = new Uint8Array(ARRAY_LENGTH);
window.crypto.getRandomValues(array);
let uuid = '';
@varqox
varqox / recording_application_and_microphone.md
Last active March 7, 2024 17:59
How to record multiple applications and microphone into one audio file on Linux using PulseAudio

How to record multiple applications and microphone into one audio file on Linux

Step 0. Terminology

Sinks are for output, sources are for input. To stream source to sink a loopback must be created. More shall you find there.

Step 1. Create output sink that will be recorded

Our output sink will be named recording.

pacmd load-module module-null-sink sink_name=recording sink_properties=device.description=recording