Skip to content

Instantly share code, notes, and snippets.

@rcbadiale
rcbadiale / usb_audio.md
Last active January 2, 2026 20:17
rPi 4 as USB Audio Interface

How to enable USB Audio Gadget for rPi 4

Update the device (kernel should be >= 6.1)

sudo apt update && sudo apt upgrade -y

Enable USB Gadget and g_audio

echo "dtoverlay=dwc2" | sudo tee -a /boot/config.txt
@rcbadiale
rcbadiale / rpi_bt_audio_config.sh
Created June 17, 2022 03:03
Install pulseaudio on RaspberryPi OS, pair and connect BT speaker, download/enable autoconnect and create cronjob to play a 1Hz sound for 1s in order to keep BT Speaker always on.
#!/bin/bash
echo "Installing PulseAudio and BT Module"
sudo apt update
sudo apt upgrade -y
sudo apt install -y git pulseaudio pulseaudio-module-bluetooth
systemctl --user enable --now pulseaudio.service
MAC_ADDRESS=<MAC_ADDRESS>
echo "Pairing and connecting to $MAC_ADDRESS"
@rcbadiale
rcbadiale / patch_connection.py
Created January 5, 2022 12:18
A function to patch the urllib3 / requests to print and/or change the hosts as needed.
from urllib3.util import connection
def patch_requests_connector():
_create_connection = connection.create_connection
def patched_create_connection(address, *args, **kwargs):
"""
Patches the create_connection in order to print the hosts.
// ==UserScript==
// @name GMail Attachments Check
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Alert when unwanted senders or attachments are added to the mail.
// @author rcbadiale
// @match *://mail.google.com/mail/*
// @grant none
// ==/UserScript==