Skip to content

Instantly share code, notes, and snippets.

View PaperStrike's full-sized avatar
🥝
hungry

PaperStrike

🥝
hungry
View GitHub Profile
@PaperStrike
PaperStrike / GroupFinalizationRegistry.ts
Last active July 17, 2022 17:21
Request a callback when registered objects are all garbage-collected
export default class GroupFinalizationRegistry<T> extends FinalizationRegistry<T> {
#members: WeakRef<object>[] = [];
constructor(cleanupCallback: (heldValue: T) => void) {
super((heldValue) => {
if (this.#members.length === 0) return;
this.#members = this.#members.filter((member) => (
member.deref() !== undefined
));
if (this.#members.length === 0) {
@PaperStrike
PaperStrike / plot_input.py
Last active February 27, 2021 06:07
Plot mic input of headset
#!/usr/bin/env python3
"""Plot the live microphone signal(s) with matplotlib.
Matplotlib and NumPy have to be installed.
Edited from:
https://github.com/spatialaudio/python-sounddevice/blob/0.4.1/examples/plot_input.py
"""
import argparse