Skip to content

Instantly share code, notes, and snippets.

@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.

@haxwithaxe
haxwithaxe / mbox-forward.py
Created October 7, 2023 14:54
This is the script I use to forward system mail (mbox) as a digest to a regular email account.
#!/usr/bin/env python3
"""This forwards mail from the given mbox style mailboxes to a real email.
It borrows the ``haxmail.ini`` config file.
"""
from dataclasses import dataclass, field
from typing import Annotated, List
import configparser
@haxwithaxe
haxwithaxe / example-haxmail.ini
Last active September 17, 2023 18:50
A sendmail-like script without a mail daemon required.
[mail]
sender-email = haxmail <[email protected]>
subject = Default subject
to = [email protected]
smtp-username = [email protected]
smtp-password = <mailbot smtp password>
smtp-server = smtp.example.com
smtp-port = 587
@haxwithaxe
haxwithaxe / README.md
Last active September 25, 2022 12:52
Bash completion for aliases of python argcomplete scripts

Simple

This is a bash completion function for program example that can be set for any alias:

_example_alias_argcomplete() {
    alias_value="ansible -i"
    alias_name="ans"
    offset=$(( ${#alias_value}-${#alias_name} ))
    COMP_LINE="${COMP_LINE/$alias_name /$alias_value }"
    (( COMP_POINT+=${offset} ))
 local IFS=$'\013'
@haxwithaxe
haxwithaxe / latency-sensor.py
Last active July 18, 2022 23:36
A quick and dirty no install latency sensor.
#!/usr/bin/env python3
"""A no install latency monitoring tool."""
import argparse
import enum
import json
import logging
import math
import os
import platform
@haxwithaxe
haxwithaxe / randomstr
Created June 1, 2022 14:54
A simple random string generator
#!/usr/bin/env python3
import argparse
import random
import re
import string
def random_str(length, lower=False, upper=False, digits=False, special=False,
whitespace=False, hexidecimal=False, octal=False, exclude=None):
@haxwithaxe
haxwithaxe / tagit.rb
Last active December 17, 2021 16:13
An exersise to get ruby back in my brain. Partial reimplementation of https://github.com/haxwithaxe/tagit
require 'fileutils'
require 'optparse'
def parse_args()
options = {method: :move, new_tags: [], remove_tags: []}
OptionParser.new do |opts|
opts.banner = 'usage: tagit -f FILE,FILE,... [-t TAG,TAG,...] [-r TAG,TAG,...] [-c|-l|-m]'
opts.on('-l', '--link') do
options[:method] = :link
end
@haxwithaxe
haxwithaxe / netdata-sendmail.py
Last active October 20, 2021 16:39
Enough of a sendmail interface for netdata to send notifications.
#!/usr/bin/env python3
# For reference https://github.com/netdata/netdata/blob/ceb0e6a490e7dbadc6430eb76705c401eff97864/health/notifications/alarm-notify.sh.in#L921
import argparse
import select
import smtplib
import ssl
import sys
@haxwithaxe
haxwithaxe / coolhddx9.py
Created June 18, 2021 18:14
A script to adjust the fan speed on a Supermicro X9 motherboard based on hard drive temperatures.
#!/usr/bin/env python3
"""A script to adjust the fan speed on a Supermicro X9 motherboard based on
hard drive temperatures.
Install to `/usr/local/sbin/coolhddx9` for use with the associated systemd
service and timer.
"""
import glob
@haxwithaxe
haxwithaxe / config.bat
Last active March 18, 2021 14:45
DRGpacker suggested changes (with overkill)
set unrealpak="C:\path\to\UE_4.25\Engine\Binaries\Win64\UnrealPak.exe"