Skip to content

Instantly share code, notes, and snippets.

@kbrgl
kbrgl / logger.py
Last active June 20, 2020 16:17
Zero-dependency Logger class for logging of table-structured data in Python.
class Logger:
"""Logger provides logging of table-structured data.
The first column provided must be interpretable as a title. You may provide
a 'formatting function' for each column that formats values corresponding
to that column.
>>> logger = Logger({
... 'Film Title': None,
... 'Running Time': lambda x: '{} hours'.format(round(x, 2)),
... 'Rating': lambda x: '⭐️' * x,
@kbrgl
kbrgl / bw.go
Created December 23, 2021 10:17
package main
import (
"fmt"
"image"
"log"
"os"
"path/filepath"
"strings"
@kbrgl
kbrgl / translator.py
Created November 11, 2022 23:59
Repro for state bugs
"""Welcome to Pynecone! This file outlines the steps to create a basic app."""
# Import pynecone.
from datetime import datetime
import pcconfig
import pynecone as pc
from pynecone.base import Base
docs_url = "https://pynecone.io/docs/getting-started/introduction"
/**
* Transforms a stream of bytes (Uint8Array) into 32-bit float arrays (Float32Array).
*
* This transformer is needed to convert audio data from an HTTP response body
* (ReadableStream<Uint8Array>) into the format required by the Web Audio API
* (ReadableStream<Float32Array>).
*
* The transformer buffers incoming bytes until it has enough to create complete
* 32-bit floats (4 bytes each). Any remaining bytes at the end that don't form
* a complete float (1-3 bytes) are discarded to maintain data integrity.
@kbrgl
kbrgl / dtmf.go
Last active May 1, 2025 21:26
Convert a set of PCM mulaw-encoded WAV files containing DTMF tones into raw mulaw-encoded PCM base64 strings by removing the WAV header and encoding as base64. WAV files obtained from https://evolution.voxeo.com/library/audio/prompts/dtmf/index.jsp. Outputs the result as a Go constant declaration.
package dtmf
const (
DTMF_6 = "//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////9TPD7nTVO2rbZTTbSfqC8ZGiU6Mh8tqJakKxggU6e6NMGbl7AjFyfNnb40wZyaSRoaLKyYxTzFnaUqGB06nJjTOOehvh8XIdOVnecsU6tBHBgrqpOlTSBJujIaG0GclK4wG03bMBofvJaYvCAaTf80Gi2mlJ1bGR5NxTwfW52UpjAXJlOuPiq6mZa2IBgtzaRJOq6Xm00aHDSsnU1NrJekKhgfQZydTU2um7weGCXBlaBJOrSkPhoaLKeUqz4rvLQsGBxBm5e2LSPF5ycXIbyVm80fH9tJJRgtppSiQRgjW1MmHFuclasqFipbzScltpeYvh0YMNOyKziqlZ1BGB04rqswW6WVqCcXI02eqjrboZjFHRknvJesPv+knzoaHC+klbQ6QaiwKRgeTZmYwS8yruchFyW6lJ3nIy28Ph8YMqSUpjwbL9M8HRznmpauKRg050keJa6VmsUdGjrN5yE6pJSePhgfPrLFKduelKsnFyZbosE0vpuXzR0aLLqbxT68m500GR0yoZjNPsGerSQYH1uYm+c026bnHRgmspSgUylTsjgbGjKhlKs4H03NLxod55mXtiYbTVsvGiatlZzbHBxJ/zIcOqCUojgXIUm+OCPNm5WuJRcq/6w8L7SYmNscGi+6oj5BrZeeMBgeOqSeSVOsmK4hGCPnmKBJSa6e/xw