Skip to content

Instantly share code, notes, and snippets.

View rudolfbyker's full-sized avatar
🌍
The grass withers, the flower falls, but the word of the Lord remains forever.

Rudolf Byker rudolfbyker

🌍
The grass withers, the flower falls, but the word of the Lord remains forever.
View GitHub Profile
@rudolfbyker
rudolfbyker / split_wav.py
Created April 25, 2017 10:35
Split WAV files at silence
#!/usr/bin/env python
from scipy.io import wavfile
import os
import numpy as np
import argparse
from tqdm import tqdm
# Utility functions
@rudolfbyker
rudolfbyker / ffmpeg_installer.sh
Created December 30, 2017 16:41
Compile and install the latest FFMPEG
#!/usr/bin/env bash
# FFMPEG installation script by RW Byker, based on the guide at https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu
DATE=$(date "+%Y%m%d_%H%M%S")
DIR_SOURCES="$HOME/installers/ffmpeg_sources"
DIR_BUILD="$HOME/installers/ffmpeg_build"
DIR_BIN="$HOME/bin"
DIR_OLDVERSION="$HOME/installers/ffmpeg_old_${DATE}"
// Go to https://www.youtube.com/playlist?list=WL&disable_polymer=true
// Open the javascript console (CTRL+SHIFT+K in Firefox)
// Run the following code:
function loadMore() {
// Click the "Load More" button
var el = document.getElementsByClassName('browse-items-load-more-button');
if (el.length) {
el[0].click();
return true;
@rudolfbyker
rudolfbyker / ConfigUtil.php
Created August 3, 2021 15:52
Utilities for managing Drupal module configuration during module updates.
<?php
namespace Drupal\my_module;
use Drupal;
use Drupal\Core\Config\FileStorage;
/**
* Utilities for managing module configuration during module updates.
*
@rudolfbyker
rudolfbyker / FieldTypeUpdateUtil.php
Created August 3, 2021 15:53
Utilities for updating Drupal field type definitions.
<?php
namespace Drupal\my_module;
use Drupal;
use Drupal\Core\Entity\Sql\SqlContentEntityStorage;
/**
* Utilities for updating field type definitions.
*
@rudolfbyker
rudolfbyker / find_silence.py
Created October 4, 2021 18:58
Find silences in audio samples
import numpy as np
def find_silences_of_minimum_length(data: np.array, min_length: int) -> Generator[Tuple[int, int], None, None]:
"""
Get a (start, stop) tuple for each detected silence of minimum length.
The start is inclusive, and the stop is exclusive, to match Python's list slicing.
>>> list(find_silences_of_minimum_length([1,0,1], 1))
[(1, 2)]
@rudolfbyker
rudolfbyker / purge.sh
Last active January 26, 2022 21:35
Linux ffmpeg background audio recorder
#!/usr/bin/env bash
# Delete old recordings.
DIR="$HOME/rec"
EXPIRE=7
find $DIR -mtime +$EXPIRE -type f -delete
@rudolfbyker
rudolfbyker / grab_uart.sh
Created August 16, 2023 13:34
Wait for UART device, read it, and dump the received data to a text file and to the screen
#!/bin/bash
set -eu
DEVICE="$1" # e.g.: /dev/ttyUSB0
BAUD_RATE="$2" # e.g.: 115200
OUTPUT_FILE="$3" # e.g.: uart.txt
echo "Waiting for $DEVICE to become available ..."
while true
@rudolfbyker
rudolfbyker / remove-drivers.py
Created November 2, 2023 07:26
Remove drivers newer than a given date from Windows
from __future__ import annotations
from typing import Generator, TypedDict
from subprocess import run, CalledProcessError
import re
import logging
from datetime import date, datetime
import click
import yaml
logger = logging.getLogger(__name__)