Skip to content

Instantly share code, notes, and snippets.

View brettinternet's full-sized avatar
👋

Brett brettinternet

👋
View GitHub Profile
@brettinternet
brettinternet / pihole-traefik.yaml
Created November 7, 2024 06:38
Traefik routing configuration for pihole - rewrites URL to remove the /admin path
# /etc/traefik/pihole.yaml
http:
middlewares:
pihole-redirectregex:
redirectRegex:
regex: /admin/$
replacement: /
pihole-addprefix:
addPrefix:
prefix: /admin
@brettinternet
brettinternet / ceph-disk-reset.sh
Last active October 29, 2024 19:38
Destroys and resets node disks for OSDs after a cluster reset
#!/bin/bash
# Warning! Destructive!
# https://rook.io/docs/rook/latest-release/Getting-Started/ceph-teardown/#delete-the-data-on-hosts
# Run a rook-ceph-tools daemonset and run this on each node:
FDISK_BEFORE=$(fdisk -l); \
DISK="/dev/sda"; \
sgdisk --zap-all $DISK; \
dd if=/dev/zero of="$DISK" bs=1M count=100 oflag=direct,dsync; \
@brettinternet
brettinternet / kiosk.service
Last active December 2, 2024 05:40
Kiosk mode for raspberry pi device
[Unit]
Description=Kiosk
Wants=graphical.target
After=graphical.target
[Service]
Environment="DISPLAY=:0"
Type=simple
ExecStart=/bin/bash $HOME/kiosk.sh
Restart=on-abort
@brettinternet
brettinternet / raspberry-pi-4-read-write-speedtest-results.sh
Last active May 10, 2024 04:23
Raspberry Pi 4B read/write speedtests
# Micro SD
## read
sudo hdparm -Tt /dev/mmcblk0
/dev/mmcblk0:
Timing cached reads: 2190 MB in 2.00 seconds = 1095.17 MB/sec
Timing buffered disk reads: 126 MB in 3.04 seconds = 41.46 MB/sec
## write
@brettinternet
brettinternet / pi-frame.sh
Created April 24, 2024 22:41
frame image buffer for a simple console slide show with a Raspberry Pi (Zero W)
# 1. Setup raspbian lite - no desktop environment or Xorg necessary. Install `fbi`.
# 2. Sync files to Pi:
rsync -ahP --delete ./slides remote-ssh-host:~
# 3. Append to ~/.profile to run on startup
if [[ $(fgconsole 2>/dev/null) == 1 ]]; then
fbi -d /dev/fb0 -noverbose -a -t 60 -cachemem 0 $HOME/slides/*
@brettinternet
brettinternet / zfs-supported-kernel-version.sh
Created January 21, 2024 07:36
Get the major/minor versions of the linux kernel that are supported by ZFS
#!/bin/sh
curl -sS 'https://raw.githubusercontent.com/openzfs/zfs/master/META' | awk '$1 == "Linux-Maximum:" { print $2; exit }'
@brettinternet
brettinternet / Taskfile.yaml
Last active August 28, 2024 17:34
docker-compose example with SOPS secrets, multi-domain Traefik, Cloudflare DNS and Cloudflare tunnel
# install go-task
---
version: "3"
vars:
PROJECT: myproject
SECRETS_FILE: sops.env
COMPOSE_FILES:
sh: find . -type f -iname "compose*.yaml" -exec basename {} ';' | sort -r
COMPOSE_FILES_ARGS: -f {{ .COMPOSE_FILES | splitLines | join " -f " }}
@brettinternet
brettinternet / compose.yaml
Last active December 31, 2023 15:42
Local netdata utility at http://netdata.localhost:8080
version: "3"
name: utils
x-options: &options
environment: &environment
TZ: "${TIMEZONE}"
restart: unless-stopped
networks:
- utils
@brettinternet
brettinternet / oops-zfs.md
Last active December 10, 2023 02:35
Recovery from ZFS oops

The stages of ZFS grief

Disk passthrough to a VM managing my ZFS array.

$ qm set 100 -scsi1 /dev/disk/by-id/…
$ qm set 100 -scsi2 /dev/disk/by-id/…
$ …
defmodule MyApp.RepoConnectionReaper do
@moduledoc """
Disconnect all connections after a X minutes to reset cache build-up and leaky memory on long-lived connections
Especially useful for dynamic queries which contribute to this build-up.
Alternatively, use this Repo option e.g. `Repo.all(query, prepare: :unnamed)` to avoid using named prepared statements
on queries that are dynamic enough to not cache the prepared statement on the connection.
See also
- https://github.com/elixir-ecto/db_connection/issues/99