Skip to content

Instantly share code, notes, and snippets.

View kdstad's full-sized avatar
🔥

Stad kdstad

🔥
  • Aarhus University
  • Denmark
View GitHub Profile
#!/usr/sbin/nft -f
flush ruleset
define cloudflare_ipv4 = {
103.21.244.0/22,
103.22.200.0/22,
103.31.4.0/22,
104.16.0.0/13,
104.24.0.0/14,
@kdstad
kdstad / tracelog.sh
Created June 12, 2025 22:09
trace log from current script, prune logs only keep latest 5 logs
#!/usr/bin/env bash
set -e
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
SCRIPTDIR="$(dirname "$(readlink -f "$0")")"
if [[ ! -d "${SCRIPTDIR}/logs" ]]; then
mkdir -p "${SCRIPTDIR}/logs" || { echo "Error: Failed to create logs directory"; exit 1; }
else
@kdstad
kdstad / daemon.json
Last active June 6, 2025 16:51
docker related things (network, logging and swarm standalone)
{
"bip": "172.31.0.1/24",
"default-address-pools": [
{
"base": "172.31.4.0/22",
"size": 24
}
],
"log-driver": "json-file",
"log-opts": {
@kdstad
kdstad / mysqlbackup.sh
Created August 28, 2023 23:09
MySQL/MariaDB Backup
#!/bin/bash
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
BACKUPDIR="/var/mysqlbackup"
BACKUPSUBDIR="${BACKUPDIR}/$(date +'%Y-%m-%d-%H_%M')"
mkdir -p ${BACKUPSUBDIR}; ln -snf ${BACKUPSUBDIR} "${BACKUPDIR}/latest"
find ${BACKUPDIR} -mindepth 1 -maxdepth 1 -mtime +7 -type d -not -name 'lost+found' -exec rm -rf {} \;
@kdstad
kdstad / Microsoft.PowerShell_profile.ps1
Last active September 4, 2025 15:15
PowerShell 7 Profile
$Global:StartPath = $(Get-Location).Path
function prompt
{
$CurrentPath = $(Get-Location).Path
$CurrentPathPrompt = $(Split-Path -Path $CurrentPath -Leaf)
if ($Global:StartPath -eq $CurrentPath)