Skip to content

Instantly share code, notes, and snippets.

@kgaughan
kgaughan / threadpoolss.py
Created June 10, 2013 16:13
All the thread pool mixins for SocketServer are, well, not that good, so I knocked together my own. This one can cleanly shut down the pool
"""
Thread pool extensions to SocketServer.
"""
import Queue
import SocketServer
import sys
import threading
@dgoguerra
dgoguerra / script-with-options.sh
Last active November 23, 2023 19:17
Manual alternative to getopt in bash scripts, supporting short and long options
#!/usr/bin/env bash
# File name
readonly PROGNAME=$(basename $0)
# File name, without the extension
readonly PROGBASENAME=${PROGNAME%.*}
# File directory
readonly PROGDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# Arguments
readonly ARGS="$@"
@jkullick
jkullick / headless-luks-encrypted-ubuntu-server.md
Last active March 15, 2024 21:08
Headless LUKS encrypted Ubuntu Server on Hetzner
# stop active raid
mdadm --stop /dev/md[01]

# destroy partition table on hdds
dd if=/dev/zero of=/dev/sda bs=1M count=512
dd if=/dev/zero of=/dev/sdb bs=1M count=512

# create new partition table
sgdisk -og /dev/sda
#!/bin/sh
libressl_version=libressl-2.5.1
libressl_archive=${libressl_version}.tar.gz
if [ -f ${libressl_archive} ]
then
:
else
wget -O ${libressl_archive} https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/${libressl_archive}
@MawKKe
MawKKe / cryptsetup-with-luks2-and-integrity-demo.sh
Last active June 7, 2024 17:18
dm-crypt + dm-integrity + dm-raid = awesome!
#!/usr/bin/env bash
#
# Author: Markus (MawKKe) ekkwam@gmail.com
# Date: 2018-03-19
#
#
# What?
#
# Linux dm-crypt + dm-integrity + dm-raid (RAID1)
#
@giannivh
giannivh / keycloak_impex.sh
Last active September 18, 2020 06:57 — forked from unguiculus/keycloak_impex.sh
Import/Export Keycloak Config running on Kubernetes
#!/usr/bin/env bash
set -e
set -u
set -o pipefail
show_help() {
cat << EOF
Usage: $(basename "$0") <options>
-h, --help Display help
@MaxXor
MaxXor / btrfs-guide.md
Last active June 8, 2024 19:47
Btrfs guide to set up an LUKS-encrypted btrfs raid volume with included maintenance & recovery guide

Encrypted Btrfs storage setup and maintenance guide

Initial setup with LUKS/dm-crypt

This exemplary initial setup uses two devices /dev/sdb and /dev/sdc but can be applied to any amount of devices by following the steps with additional devices.

Create keyfile:

dd bs=64 count=1 if=/dev/urandom of=/etc/cryptkey iflag=fullblock
chmod 600 /etc/cryptkey
@zOrg1331
zOrg1331 / wireguard_layer2.md
Last active May 15, 2024 06:19
wireguard, wireguard layer 2, wireguard over TCP

Intro

This note describes how to connect two networks/devices/VMs over public network using Wireguard with Layer 2 support (ARP, IPv6 link-local, etc).

This can also be achieved using SSH and its "tap" tunnel, however, it does not provide the same level of latency and bandwidth as full-blown VPN such as Wireguard.

In addition, this note describes how to tunnel Wireguard over TCP connection. This may be of use if you encounter firewall in-between so, for instance, you can use TCP port 443 only.

Objective

@utkuozdemir
utkuozdemir / migrate.sh
Created November 14, 2022 21:09
pv-migrate in a loop
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
PVCS=(
"src-kubeconfig1/src-ctx1/src-ns1/src-pvc1:dest-kubeconfig1/dest-ctx1/dest-ns1/dest-pvc1"
"src-kubeconfig2/src-ctx2/src-ns2/src-pvc2:dest-kubeconfig2/dest-ctx2/dest-ns2/dest-pvc2"
"src-kubeconfig3/src-ctx3/src-ns3/src-pvc3:dest-kubeconfig3/dest-ctx3/dest-ns3/dest-pvc3"
)
@xgp
xgp / openapi.yaml
Last active May 10, 2024 04:30
OpenAPI specification for Keycloak account API
openapi: 3.0.2
info:
title: Keycloak Account API
version: 20.0.3
description: |
Derived from the code at https://github.com/keycloak/keycloak/blob/main/services/src/main/java/org/keycloak/services/resources/account/AccountRestService.java
components:
securitySchemes:
access_token:
type: http