Skip to content

Instantly share code, notes, and snippets.

View FlyingFathead's full-sized avatar
💭
Just flyin' around

Harry Horsperg FlyingFathead

💭
Just flyin' around
View GitHub Profile
#!/usr/bin/env python3
# this is a simple script that allows you to use yt-dlp to get an audio file
# and recode it (if necessary) to fit within target size limitations.
import sys
import os
import subprocess
# ----------------------
# CONFIG
@FlyingFathead
FlyingFathead / ffmpeg_encodetotarget_mp3_strict.sh
Last active January 22, 2025 04:43
Encode `.mp3` files to target size using `ffmpeg`
#!/usr/bin/env bash
#
# ffmpeg_encodetotarget_mp3_strict: Encode input to MP3, never exceed the specified target MB.
# Uses a binary search on bitrate to get as close as possible to the limit without going over.
#
# Usage: ffmpeg_encodetotarget_mp3_strict <inputfile> <target_MB> [<max_iterations>]
#
# Example:
# ffmpeg_encodetotarget_mp3_strict myaudio.wav 5
# => tries to produce an MP3 no bigger than 5 MB
@FlyingFathead
FlyingFathead / llm_letter_counter_fi.py
Last active November 15, 2024 18:06
LLM letter counter (Finnish GPT model)
#!/usr/bin/env python3
# finnish_word_letter_counter.py
"""
A training set generator to assist a Finnish GPT-2 model in counting letters in a given word,
including reasoning steps. The script generates data in a specific format suitable for training
the model to perform letter counting tasks with explanations.
(c) FlyingFathead 2024
"""
@FlyingFathead
FlyingFathead / example_reverse_proxy_for_flask_with_nginx.conf
Last active December 25, 2024 02:24
Example reverse proxy/tunnel config for nginx to run i.e. a local Flask web server over a remote VPS
#> Created by FlyingFathead, Oct. 14th, 2024
#> https://github.com/FlyingFathead/
#
# Here's an extremely simple example of a reverse tunnel proxy for serving
# i.e. a local Flask over a remote VPS running nginx with htpasswd auth.
#
# .htpasswd with nginx requires 'apache2-utils'.
# Install it with: `sudo apt-get install apache2-utils`
# (on Debian/Ubuntu tree Linux systems)
#
@FlyingFathead
FlyingFathead / docker_manager.sh
Last active December 25, 2024 02:13
Enable or disable docker services quickly
#!/bin/bash
# Script Name: manage_docker_services.sh
# Description: Enables or disables Docker-related services on Ubuntu 24.04 LTS.
# Usage:
# - To disable Docker services:
# sudo ./manage_docker_services.sh --disable
# - To enable Docker services:
# sudo ./manage_docker_services.sh --enable
# - To be prompted for action:
@FlyingFathead
FlyingFathead / disable_and_mask_avahi_and_cups.sh
Last active October 3, 2024 22:52
Disable+mask Avahi & CUPS
#!/bin/bash
#
# Disable and Mask CUPS & Avahi Services
#
# ~~~ Overview ~~~
#
# This script is designed to disable and mask specific CUPS (Common Unix Printing System)
# and Avahi services and sockets on your Debian/Ubuntu tree Linux systems.
#
# It reduces possible attack vectors and mitigates several security vulnerabilities
@FlyingFathead
FlyingFathead / ffmpeg_dump-a-video-dvd.sh
Last active December 25, 2024 02:31
Ffmpeg-based bash script to dump & recode all relevant portions of DVD-video ISO's in a directory
#!/bin/bash
# ffmpeg_dump-a-video-dvd.sh
# === INFO ===
# This is just a simple processing script that does the following:
#
# 1) Takes in all the ISO files in the directory; intended for video-DVD's.
# 2) Extracts the contents (according to the minimum duration; change the variable below).
# 3) Re-encodes the contents with HEVC/H.265, deinterlaces the video, and creates an output directory for each disc.
#
@FlyingFathead
FlyingFathead / tarball_verify.sh
Last active December 25, 2024 02:31
Verify tarballs locally against a md5 checksum (if available) and check for tarball integrity with `tar`
#!/bin/bash
# Function to print usage
usage() {
echo "Usage: $0 [-c <checksum file>] <tarball>"
echo " -c <checksum file> : Optional, specify the checksum file to verify the tarball against"
exit 1
}
# Check if no arguments were provided
@FlyingFathead
FlyingFathead / word_letter_counter_for_llm_datasets.py
Last active July 31, 2024 19:08
Word letter counting dataset generator for LLM training
#!/usr/bin/env python3
# word_letter_counter_for_llm_datasets.py
"""
A training set generator to assist an LLM in actually being able to count
the letters in a given word. A model that can't count letters in a word isn't
usable for critical tasks; incorrect letter counts lead to compounding mistakes.
Outputs in JSON, can also use the NLTK corpus for a word dictionary, offering
a quick way to create a massive letter counting dataset for different words.
@FlyingFathead
FlyingFathead / list_usb_cameras.sh
Last active December 25, 2024 02:32
usb camera identifier and lister for debian/ubuntu linux
#!/bin/bash
# This script is designed to identify and list all USB cameras and audio devices connected to a system.
# It provides detailed information about each device, including vendor ID, product ID, serial number,
# device description, and supported video modes for cameras. It also identifies audio devices and
# lists their card and device numbers, names, and descriptions.
# Required Packages:
# - udevadm: Provides information about device attributes.
# - v4l2-ctl: A utility to control video4linux devices and list video formats.