Skip to content

Instantly share code, notes, and snippets.

@dzogrim
dzogrim / truncate-long-filenames.sh
Last active August 29, 2026 14:06
Safely shorten overly long filenames while preserving extensions
#!/usr/bin/env bash
set -Eeuo pipefail
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2026 dzogrim
# SPDX-FileContributor: dzogrim <dzogrim@dzogrim.pw>
# ---------------------------------------------------------------------------
# File: truncate-long-filenames.sh
# Purpose:
# Safely shorten overly long filenames while preserving extensions.
@dzogrim
dzogrim / git-reset-history.sh
Created August 14, 2026 12:16
Safely collapse an entire git history into a single commit using an orphan branch, then force-push the result to the remote.
#!/usr/bin/env bash
#
# git-reset-history.sh
#
# Safely collapse an entire git history into a single commit using an
# orphan branch, then (optionally) force-push the result to the remote.
#
# Design goals:
# * Works on macOS (stock bash 3.2) and Linux. No GNU-only flags.
# * Does not rely on the user's git configuration (pager, color, aliases).
@dzogrim
dzogrim / pve-hotplug-remediate.sh
Created August 12, 2026 08:35
Inventory PVE guests that are NOT ready for on-the-fly resource hotplug
#!/usr/bin/env bash
#
# pve-hotplug-remediate.sh
#
# Inventory PVE guests that are NOT ready for on-the-fly resource hotplug
# (vCPU / RAM / disk / NIC), and optionally pre-stage the fix as *pending*
# config changes (the orange values in the web UI), applied at next cold boot.
#
# DRY RUN IS THE DEFAULT. Nothing is written without --apply.
#
@dzogrim
dzogrim / convert-finder-aliases.sh
Created August 4, 2026 14:59
Safely converts macOS Finder alias files below ROOT into POSIX symlinks
#!/usr/bin/env bash
#
# convert-finder-aliases.sh
# ---------------------------------------------------------------------------
# Safely converts macOS Finder alias files below ROOT into POSIX symlinks.
#
# Internal aliases, whose targets are inside ROOT, are converted to relative
# symlinks so the complete tree can be moved or mounted elsewhere. External
# aliases are reported by default and can be converted to absolute symlinks only
# with --apply --include-external.
@dzogrim
dzogrim / findHD_videos.sh
Created July 26, 2026 16:59
findHD_videos.sh - published from local Scripts source of truth
#!/usr/bin/env bash
# ==============================================================================
# Script : findHD_videos.sh
# Description : Recursively scans the current directory for supported media
# files, inspects their video properties with MPlayer, and creates
# symbolic links for files that meet the configured HD criteria.
#
# Videos wider than the minimum resolution are classified into
# two output directories:
@dzogrim
dzogrim / folderizeFolders.sh
Created July 26, 2026 16:59
folderizeFolders.sh - published from local Scripts source of truth
#!/usr/bin/env bash
# ==============================================================================
# Script : folderizeFolders.sh
# Description : Reorganizes the immediate subdirectories of the current working
# directory by moving each one into a companion directory whose
# name is suffixed with an underscore.
#
# Example:
#
@dzogrim
dzogrim / tiff2jpeg
Created July 26, 2026 15:02
tiff2jpeg - published from local Scripts source of truth
#!/usr/bin/env bash
# SPDX-License-Identifier: MIT
#
# Script : tiff2jpeg
# Description :
# Converts every TIFF image in the current directory to JPEG using
# ImageMagick, then moves each successfully converted source file to
# the current user's Trash directory.
#
# Input files are processed from the current working directory and matched
@dzogrim
dzogrim / timestamp-reference.sh
Last active July 26, 2026 15:00
Displays a reference table of commonly used timestamp formats, the corresponding `date` commands, and their current evaluated output
#!/usr/bin/env bash
# SPDX-License-Identifier: MIT
#
# Script : timestamp-reference.sh
# Description :
# Displays a reference table of commonly used timestamp formats, the
# corresponding `date` commands, and their current evaluated output.
#
# The script is primarily intended for GNU `date`. Some format specifiers
# and options, including `--utc`, `%N`, and `%3N`, are not supported by the
@dzogrim
dzogrim / merge_m4a.sh
Created July 26, 2026 14:51
Merges all M4A files from the current directory into a single M4A file
#!/usr/bin/env bash
# SPDX-License-Identifier: MIT
#
# Script : merge_m4a.sh
# Version : 1.0.0
# Description :
# Merges all M4A files from the current directory into a single M4A file.
#
# Each input file is first converted to WAV, the WAV files are concatenated
# with SoX, and the resulting audio stream is encoded as AAC.
@dzogrim
dzogrim / distance.sh
Created July 26, 2026 14:47
Calculates the Levenshtein distance between two strings
#!/usr/bin/env bash
# SPDX-License-Identifier: MIT
#
# Script : distance.sh
# Description :
# Calculates the Levenshtein distance between two strings.
#
# The Levenshtein distance is the minimum number of single-character
# insertions, deletions, or substitutions required to transform one
# string into the other.