Skip to content

Instantly share code, notes, and snippets.

@haxwithaxe
haxwithaxe / cpu-gov
Created May 11, 2025 16:31
A script to quickly and dirtyly manually manage Xeon CPU governor settings.
#!/bin/bash
set_govs() {
local mode=$1
for i in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do
echo $mode | sudo tee $i
done
}
get_govs() {
@haxwithaxe
haxwithaxe / pskreporter-log.sh
Created January 7, 2025 16:20
Long term antenna test data logger
#!/bin/bash
# This script downloads an activity log from PSKReporter and some space weather
# stats.
# Create the log directory, make the script executable, and add the following
# to your crontab:
#
# @daily <Path to the script>/pskreporter-logger.sh daily
# 0 6 * * * <Path to the script>/pskreporter-logger.sh past_UTC_0000
#
# Replace `6` with the hour of the day for UTC 00:00 for your
@haxwithaxe
haxwithaxe / random-wire.py
Last active July 2, 2024 14:00
Random wire antenna length calculator.
#!/usr/bin/env python3
"""Random wire antenna length calculator.
Options:
`--help` - Show the help message.
`-i`, `--imperial` - Use imperial units (feet).
`-m`, `--metric` (default) - Use metric units (meters).
`-h`, `--harmonics <count>` - The amount of harmonics to include in the
calculations. Defaults to `5`.
`-c`, `--check <length>` - Check the given length to see if it is a good
@haxwithaxe
haxwithaxe / debian-oneshot.sh
Last active May 1, 2024 11:17
A script to bootstrap ansible, run ansible-pull, and cleanup after
#!/bin/bash
REPO="$1"
shift
BRANCH="${1:-main}" # Or commit or tag
shift
DEBIAN_NONINTERACTIVE=true
apt update -y
apt install --no-install-recommends --no-install-suggests -q -y python3-pip python3-venv git
@haxwithaxe
haxwithaxe / Healthcheck for stock promtail container.md
Created November 13, 2023 20:57
Pure bash healthcheck for stock promtail container

There's no wget and no curl (at least in the version I'm using at the moment). Here's a pure bash HTTP GET to /ready.

bash -c 'exec 3<>/dev/tcp/localhost/9080; \
echo -e GET /ready HTTP/1.1\\r\\nHost: localhost\\r\\n >&3; \
read line <&3; \
echo $line | grep -q "HTTP/1.1 200 OK"'
@haxwithaxe
haxwithaxe / cpu-governor-performance.py
Created November 9, 2023 19:52
Using this with my gaming VM to set the CPU governor to performance on my potato
#!/usr/bin/env python3
# /// pyproject
# [run]
# requires-python = '>=3.11'
# dependencies = [
# "proxmoxer",
# "requests"
# ]
# [tool.black]
@haxwithaxe
haxwithaxe / docker-service-exec
Created October 29, 2023 02:14
Run commands on docker swarm services regardless of which node it's on.
#!/bin/bash
# Run docker exec on service tasks on any host in a docker swarm.
#
# The first argument must be the service name all subsequent arguments are
# passed to that service task.
#
# The script looks for a docker context named ``node.<node hostname>``. If it
# doesn't exist the script will create a context by that name set to connect
# over ssh with the current local user as the username and the node name as the
@haxwithaxe
haxwithaxe / random-num
Created October 26, 2023 04:10
A fancy random number script that also prints random port and UID/GID numbers in base10, hex, and octal.
#!/usr/bin/env python3
"""Random number generator.
Prints a random number within given constraints.
* Arbitrary numbers
* Port numbers - safe ranges, system, all
* UID/GID - safe ranges, system, all
* Within a range
* On an interval
* In base10
@haxwithaxe
haxwithaxe / proxmox-certdeployer.py
Last active October 21, 2023 23:08
A certdeploy compatible script to update certs in a proxmox cluster.
#!/usr/bin/env python3
"""A command line tool to update TLS certificates on Proxmox clusters.
Note:
When running for the first time or after the certificates have expired set
`verify_tls` in the config to `false`.
The default config locations are:
- ``/cerdeploy/scripts/proxmox_certupdater.toml``
- ``/etc/proxmox_certupdater.toml``
@haxwithaxe
haxwithaxe / README.md
Last active October 10, 2023 12:07
Get a list of images from ghcr.io for a given project.

Get a list of images from ghcr.io for a given project. See https://docs.github.com/en/rest/packages/packages?apiVersion=2022-11-28#list-package-versions-for-a-package-owned-by-an-organization or https://docs.github.com/en/rest/packages/packages?apiVersion=2022-11-28#list-packages-for-a-user for the URL to use for other people's container images. See https://docs.github.com/en/rest/packages/packages?apiVersion=2022-11-28#list-package-versions-for-a-package-owned-by-the-authenticated-user for your own container images. Requires the credential github_access_token. The token needs the read:package permission.