Skip to content

Instantly share code, notes, and snippets.

@ghedo
ghedo / sound_playback.c
Last active June 19, 2024 02:00
Simple sound playback using ALSA API and libasound
/*
* Simple sound playback using ALSA API and libasound.
*
* Compile:
* $ cc -o play sound_playback.c -lasound
*
* Usage:
* $ ./play <sample_rate> <channels> <seconds> < <file>
*
* Examples:
@carlos-jenkins
carlos-jenkins / base64.py
Created July 2, 2019 06:39
Calculate the length in bytes of a base64 string.
def b64len(b64str):
"""
Calculate the length in bytes of a base64 string.
This function could decode the base64 string to a binary blob and count its
number of bytes with len(). But, that's inefficient and requires more
memory that really needed.
Base64 encodes three bytes to four characters. Sometimes, padding is added
in the form of one or two '=' characters.