Skip to content

Instantly share code, notes, and snippets.

View guest271314's full-sized avatar
💭
Fix WontFix

guest271314

💭
Fix WontFix
View GitHub Profile
@UCIS
UCIS / gist:983f2c16d36aee7f75cff4ac477d6805
Created June 17, 2020 18:42
Opus in WebM packetizer
class WebmPacketizer : IPacketizer {
private UInt64 position = 0;
static WebmPacketizer () {
}
public WebmPacketizer() {
}
private static Byte[] Concat(params Byte[][] parts) {
@UCIS
UCIS / gist:c52757fef62239d502806f53b6700a58
Created June 17, 2020 18:40
Opus in Ogg packetizer
class OggPacketizer : IPacketizer {
static UInt32[] checksumTable;
static UInt32 serial_counter = 1;
uint pageIndex = 0;
uint serial;
UInt64 position = 0;
static OggPacketizer() {
initChecksumTable();
}
@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. ¯\_(ツ)_/¯
@astoeckel
astoeckel / stream_local_audio.sh
Last active October 12, 2021 06:05
Stream audio from pulse audio as opus stream via UDP/RTP
#!/bin/sh
pacat \
--device=alsa_output.pci-0000_00_1b.0.analog-stereo.monitor \
--rate=48000 \
--record | \
opusenc \
--expect-loss=25 \
--max-delay=0 \
--framesize=2.5 \
@UCIS
UCIS / gist:845eda1755d38eddfc3f0f99268c27da
Created June 17, 2020 18:50
Opus/WebM player in JavaScript
function OpusWebmPacker() {
var channels = 2;
var sample_rate = 48000;
var position = 0;
var packets = [];
var buffer = new Uint8Array(4 + 1275);
var buffer_offset = 0;
function Concat() {
@marchelbling
marchelbling / README.md
Last active April 1, 2022 06:35
C++ json writer

why?

This code implements a naive JSON writer in C++ complying with RFC 4627. I wrote this as I believe it is a very good example of a real life problem involving lots of C++ constructs. This sample only supports writing JSON and does not support heterogenous ‘object’ serialization and extension are left as an exercice. See Writing json in C++ for some details.

what?

  • json_stream: a std::ofstream wrapper fulfilling RFC 4627 constraints;
  • utf8_json: some code to decode/“json encode” std::string UTF-8 buffers
  • json_test.cpp: a very simple program testing the code
@ignacysokolowski
ignacysokolowski / pulse_simple_play.py
Created October 29, 2012 11:20
Python: Play a WAV file with PulseAudio simple API
#!/usr/bin/env python
import ctypes
import wave
import sys
pa = ctypes.cdll.LoadLibrary('libpulse-simple.so.0')
PA_STREAM_PLAYBACK = 1
PA_SAMPLE_S16LE = 3
/**
* RIFF WAVE PCM file generator
* Reference: www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/WAVE.html
*
* @author Lara Sophie Schütt (@literallylara)
* @license CC0
*/
const DUR = 5 // duration in seconds
const NCH = 1 // number of channels
@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.

@littledan
littledan / anonymous-inline-modules.md
Last active June 29, 2022 01:07
Anonymous inline modules

Note: this document is subsumed by the module blocks proposal

Anonymous inline modules

Anonymous inline modules are syntax for the contents of a module, which can then be imported.

let inlineModule = module {
  export let y = 1;
};