Skip to content

Instantly share code, notes, and snippets.

@digitalsignalperson
digitalsignalperson / example.service
Created March 15, 2024 06:39
template for a systemd service that logs a failed invocation to /home/asdf/alerts/%N-failure
[Unit]
Description=my service
[Service]
Restart=always
RestartSec=10
ExecStart=
Environment="ALERT_PATH=/home/asdf/%N-failure"
ExecStopPost=/bin/bash -c '\
echo $$SERVICE_RESULT, $$EXIT_CODE, $$EXIT_STATUS | logger; \
@digitalsignalperson
digitalsignalperson / zfs-extra-data-issues.md
Last active February 14, 2024 07:41
testing feasibility of zfs native encryption sync back and forth

ref openzfs/zfs#12580

Here's a script showing the predictability of this post-mount extra data that is created. When the previous snapshot contained 1024 files, the extra data written after mounting the received snapshot is proportional to this. Taking a snapshot of this extra data shows ~1024 "OBJECT" and ~1024 "FREE" lines in the zstream dump, with the raw data for the objects all starting with "ZP/"

Side-note: I also note that immediately after creating any dataset, the "written" is non-zero, a similar effect to this post-receive data?

diff_similarity() {
@digitalsignalperson
digitalsignalperson / incus-arch-zfs.sh
Created February 5, 2024 23:22
incus ZFS test VM for arch linux
#!/bin/bash
VMNAME=arch-zfs-test
vm_bash() { incus exec $VMNAME -- bash "$@"; }
vm_exec() { incus exec $VMNAME -- "$@"; }
vm_wait() { until vm_exec true; do sleep 1; done; }
vm_start() { incus start $VMNAME; }
vm_console() { incus console $VMNAME --type vga; }
vm_status() { incus info $VMNAME | grep "^Status: " | awk '{ print $2 }'; }
@digitalsignalperson
digitalsignalperson / move_axes.py
Last active January 27, 2024 06:07 — forked from salotz/move_axes.py
Move a matplotlib Axes from one figure to another.
def move_axes(ax, fig, subplot_args, remove=False):
"""Move an Axes object from a figure to a new pyplot managed Figure in
the specified subplot.
ax = the original Axes
fig = the new figure
subplot_args = where to put the ax in the new figure, e.g. (nrows, ncols, index)
"""
# get a reference to the old figure context so we can release it
@digitalsignalperson
digitalsignalperson / bwrap-firefox.sh
Created January 25, 2024 03:16
Bubblewrapped firefox with a fifo on the host to open links inside the container
#!/bin/bash
URL_FIFO=$HOME/Downloads/ff_fifo
mkfifo "$URL_FIFO"
ffscript=$(mktemp)
cat > "$ffscript" << EOF
#!/bin/bash
echo "Creating profile"
@digitalsignalperson
digitalsignalperson / zfs-force-inherit-example.sh
Created January 25, 2024 03:01
zfs force inherit encryptionroot on received dataset with pyzfs
#!/bin/bash
# Create test pool
dd if=/dev/zero of=/root/zpool bs=1M count=128
zpool create testpool /root/zpool
# Create encryptionroot and some datasets
echo "12345678" | zfs create -o canmount=off -o mountpoint=/mnt -o encryption=on -o keylocation=prompt -o keyformat=passphrase testpool/enc
zfs create testpool/enc/data1
zfs create testpool/enc/data2
@digitalsignalperson
digitalsignalperson / tabs.css
Created January 23, 2024 09:18
obsidian tabs in multiple rows
/* --------------compact tabs--------------------*/
.workspace .mod-root .workspace-tab-header {
width: unset;
max-width: var(--tab-width);
border: 1px solid var(--color-base-50);
}
/*.workspace-tab-header-inner {
width: unset;
}*/
@digitalsignalperson
digitalsignalperson / fish_merge.py
Last active January 18, 2024 02:21
Merge multiple fish history files together using flock (untested)
#!/bin/python
import pathlib
import fnctl
import yaml
import time
# Watch for changes in other_history and merge them into local_history
local_history = pathlib.Path('~/.local/share/fish/fish_history').expanduser()
other_history = pathlib.Path('~/.local/share/fish/other_history').expanduser()
@digitalsignalperson
digitalsignalperson / linux-rt-lts and zfs-dkms.sh
Created November 17, 2023 23:14
example for how to install linux-rt-lts and zfs-dkms
if ! grep -qF "[archzfs]" /etc/pacman.conf; then
cat >> /etc/pacman.conf << 'EOF'
[archzfs]
Server = http://archzfs.com/$repo/x86_64
Server = http://mirror.sum7.eu/archlinux/archzfs/$repo/x86_64
Server = https://mirror.biocrafting.net/archlinux/archzfs/$repo/x86_64
EOF
fi
pacman-key -r F75D9D76
@digitalsignalperson
digitalsignalperson / stream.sh
Last active March 31, 2024 12:38
xdp screen cast example, modified to pipe to ffmpeg
mkfifo /tmp/gfifo
./xdp-screen-cast-ffmpeg.py & # or run in another terminal
# Note the gstreamer pipeline
# 'pipewiresrc fd=%d path=%u ! videorate ! video/x-raw,framerate=60/1 ! videoconvert ! filesink location=/tmp/gfifo'
# I specified a 60/1 frameerate. You can do other pre-processing here, or offload it to ffmpeg.
# Encode the stream and pipe to netcat
# note: must specify correct resolution here
# we can now use h264_nvenc, mpegts, and anything else ffmpeg has