Skip to content

Instantly share code, notes, and snippets.

View FNGarvin's full-sized avatar

Fred N. Garvin FNGarvin

  • Moline, IL
View GitHub Profile
@FNGarvin
FNGarvin / README.md
Last active January 12, 2026 18:10
HOWTO: Download a Single File From a Docker Image

🛠️ HOWTO: Download a Single File From a Docker Image 🛠️

Quickstart:

Skip to the addendum for an automated script.

1. Set IMAGE and Collect Metadata

Define your image and use skopeo to pull the build history and the layer manifest.

IMAGE="docker://SOME_USERNAME/SOME_REPONAME[:OPTIONAL_TAG]"
@FNGarvin
FNGarvin / Automate NVIDIA CDI Refresh for Podman on WSL2.md
Created January 10, 2026 02:22
HOWTO: Automate NVIDIA CDI Refresh for Podman on WSL2

HOWTO: Automate NVIDIA CDI Refresh for Podman on WSL2

Why this is needed

Updating NVIDIA drivers on Windows often breaks the bridge to WSL2 containers. Because the Container Device Interface (CDI) file (/etc/cdi/nvidia.yaml) is a static snapshot of the driver state at the time of generation, any driver update renders the snapshot invalid. This usually results in Podman containers failing to find the GPU with jarring, cryptic, or non-existent error messages.

The Benefit

This solution provides "zero-touch" insurance. It checks your driver version at boot and only regenerates the CDI if a change is detected. By using a systemd service, it runs asynchronously in the background, adding negligible overhead (approx. 80ms) to your WSL startup time (zero per-shell latency).

Prerequisites

  • WSL Version: 0.58.0 or higher (Check via wsl --version in PowerShell).
@FNGarvin
FNGarvin / query-lora-metadata.py
Created September 25, 2025 19:31
A tool to analyze .safetensors LoRA files.
#!/usr/bin/env python3
#
# Author: FNGarvin
# License: MIT
#
# Description: A tool to analyze .safetensors LoRA files. It analyzes
# both metadata (if available) and tensor keys in an attempt
# to infer the base model, resolution, and trigger words,
# highlighting any contradictions.
@FNGarvin
FNGarvin / HOWTO.Manifest.md
Created August 13, 2025 18:50
HOWTO: View a container manifest w/o downloading the entire container

For a container such as docker://madiator2011/better-comfyui:slim-5090

skopeo inspect --config docker://madiator2011/better-comfyui:slim-5090 | jq '.history'

@FNGarvin
FNGarvin / generate_subs_with_whisper.py
Created August 7, 2025 15:46
Example wrapper for more reliably generating subs w/ Whisper
def _generate_subs_with_whisper(self, generated_srt_path):
"""Generates subtitles using Whisper. This is the final fallback."""
print(f"\n--- Generating Subtitles with Whisper ---", flush=True)
# Create a predictable scratch directory for intermediate files
scratch_dir = os.path.join(tempfile.gettempdir(), 'subtitle_processor_scratch')
os.makedirs(scratch_dir, exist_ok=True)
# Use a predictable filename based on the video for easier debugging
video_basename = os.path.splitext(os.path.basename(self.args.video_file))[0]
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# detect_and_crop.py
# FNGarvin (c) 2025
#
# This script uses a pre-trained YOLOv8 model to detect objects in an image
# specified as a command-line argument. For each detected object exceeding a
# specified confidence threshold, it generates ImageMagick 'convert' commands
# to crop the object. These commands are then printed to the console and

General guidance for managing WSL space:

  • Use ncdu -x to get an overview for disk usage.
  • Use podman system df to get an overview for prune savings.
  • Delete old, tagged, unwanted images from podman image list --sort size w/ podman rmi [imagename].
  • Do a podman ps -a and ensure every container to keep features the to-keep label mnemonic for filtering. Workflow to add it follows:

Workflow to add -to-keep label:

  1. Commit the [stopped] container

Guide: Configuring Windows OpenSSH Server for Full WSL Sessions

Last Updated: June 23, 2025

Authorship: This guide was developed in a collaborative session between a user and Google's Gemini assistant.

Objective

This guide details a robust method to configure the Windows OpenSSH Server to provide users with a direct and seamless WSL/Linux shell.

@FNGarvin
FNGarvin / chapt_2_mp3.rb
Created April 19, 2025 03:59
A Simple Script to Convert a Video Into a Collection of MP3s, One File Per Chapter
#!/usr/bin/ruby -w
#a simple script to take a video file and convert it
#into a collection of mp3 files, one file per chapter
#requires an ffmpeg install with ffprobe and support for
#mp3 plus whatever formats the input uses
#FNG, 2025
require 'json'