Skip to content

Instantly share code, notes, and snippets.

View konstruktoid's full-sized avatar
🤖

Thomas Sjögren konstruktoid

🤖
  • Sweden
  • 08:35 (UTC +02:00)
  • LinkedIn in/thosjo
View GitHub Profile
@konstruktoid
konstruktoid / argspec_gen.py
Last active June 4, 2025 10:42
Skeleton Ansible argument spec generator
#!/usr/bin/env python3
# ruff: noqa: T201
"""Print a skeleton Ansible argument_specs.yml file."""
import os
from pathlib import Path
import yaml
def find_yaml_files(directory: str) -> list[str]:
@konstruktoid
konstruktoid / download_artifact.py
Created November 28, 2024 21:36
Download GitHub artifact
#!/usr/bin/env python3
# ruff: noqa: E501,PERF401
#
"""Download the latest artifact from a GitHub repository."""
import zipfile
from pathlib import Path
import requests
OWNER = "konstruktoid"
@konstruktoid
konstruktoid / coreos_vagrant.sh
Last active October 9, 2024 15:04
Building an Fedora CoreOS Vagrant box
#!/bin/bash
set -eu -o pipefail
if ! command -v VBoxManage &> /dev/null; then
echo "[ERROR] VirtualBox is not installed"
exit 1
fi
if ! command -v vagrant &> /dev/null; then
@konstruktoid
konstruktoid / verabrute.sh
Created May 25, 2022 10:45
Brute force a VeraCrypt container when algorithms aren't known
#!/bin/bash
# So sorry it had to come to this, this is slow.
# Note that pim and keyfiles etc is static and needs to be modified if used.
# veracrypt --text --dismount --slot 1
set -eu -o pipefail
CONTAINER=""
MOUNTDIR=""
WORDLIST=""
@konstruktoid
konstruktoid / VBox_clean.sh
Last active April 19, 2024 10:25
Clean VirtualBox VMs, Vagrant boxes and Containers
#!/bin/bash
set -uo pipefail
CONTAINER_RUNTIME="unset"
if command -v docker >/dev/null 2>&1; then
CONTAINER_RUNTIME=docker
else
CONTAINER_RUNTIME=podman
fi
@konstruktoid
konstruktoid / ansible_forks.sh
Last active April 26, 2022 11:52
Script to calculate Ansible forks based on the number of CPUs.
#!/bin/bash -eux
if nproc &>/dev/null; then
CPUS=$(nproc)
elif grep -qc processor /proc/cpuinfo; then
CPUS=$(grep -c processor /proc/cpuinfo)
elif sysctl -n hw.ncpu &>/dev/null; then
CPUS=$(sysctl -n hw.ncpu)
else
CPUS=1
@konstruktoid
konstruktoid / genHostfile.sh
Created October 26, 2020 08:59
Generate a Ansible hosts file from running Vagrant VMs
#!/bin/bash
{
for VM in $(vagrant status | grep -iE 'running.*virtualbox' | grep "$1" | awk '{print $1}'); do
mapfile -t VAGRANT_SSH < <(vagrant ssh-config "$VM" | awk '{print $NF}')
echo "[${VAGRANT_SSH[0]}]"
echo "${VAGRANT_SSH[1]} ansible_connection=ssh ansible_port=${VAGRANT_SSH[3]} ansible_user=${VAGRANT_SSH[2]} ansible_ssh_private_key_file=${VAGRANT_SSH[7]}"
done
} > "hosts"
@konstruktoid
konstruktoid / mac_developer_certs.md
Last active March 3, 2022 00:25
Installing Developer ID certificates on Mac OS X

Installing Developer ID certificates on Mac OS X

Short guide showing how to install Developer ID certificates, when the Allow button doesn't show up under System Preferences > Security & Privacy > General or you're seeing (libkern/kext) system policy prevents loading; check the system/kernel logs for errors or try kextutil(8). in the installation logs (CMD + L).

System information

macOS Catalina
ProductName:    Mac OS X
ProductVersion: 10.15.4
#!/usr/bin/python3
# https://oeis.org/A232449
# Belphegor's Prime: n = 13
def belph(n):
belph = (10 ** (n + 3) + (2 * 3 ** 2 * 37)) * 10 ** (n + 1) + 1
return belph
#!/bin/sh
RELEASE_DATE=
for p in $(curl -sSL 'https://kernel.ubuntu.com/~kernel-ppa/mainline/daily/current/HEADER.html' | grep -E '.*all\.deb|.*generic.*amd64\.deb' | sed -e 's/.*ref="//g' -e 's/">.*//g'| sort | uniq); do
wget -nc "https://kernel.ubuntu.com/~kernel-ppa/mainline/daily/current/$p"
RELEASE_DATE="$(echo "$p" | awk -F '.' '{print $6}' | sed 's/_.*//g')"
done
if ! dpkg -l | grep -qE "linux.*$RELEASE_DATE.*"; then
find . -name "*modules*$RELEASE_DATE*.deb" -type f | while read -r m; do