Skip to content

Instantly share code, notes, and snippets.

mafredri / Dockerfile
Created Sep 26, 2021
Restic backup from ZFS dataset snapshots mounted via Docker to mirror real directory structure
View Dockerfile
FROM alpine:3.14.2
LABEL maintainer="Mathias Fredriksson <>"
RUN apk add --no-cache \
bzip2 \
RUN wget -O -${RESTIC_VERSION}/restic_${RESTIC_VERSION}_linux_amd64.bz2 \
| bzip2 -d >/usr/local/bin/restic \
mafredri / timemachine-zfs-snapshot
Last active Aug 29, 2022
Time Machine backup snapshotting on ZFS using zrepl for snapshot purging (for Samba server)
View timemachine-zfs-snapshot
# /etc/cron.d/samba-timemachine-zfs-snapshot
# Create snapshots after completed Time Machine backups.
# Runs every two minutes to allow creating backups only after cleanup is
# completed.
*/2 * * * * root /usr/local/bin/ rpool/share/timemachine
mafredri / zsh-histdb-tabulation.zsh
Last active Dec 21, 2021
Custom tabulation command for zsh-histdb
View zsh-histdb-tabulation.zsh
# This is a custom tabulation command implemented fully in zsh that
# produces simple output suitable for zsh-histdb.
# The `column` command on macOS has a silly limitation max 2048 line
# length, it's unsuitable for tabulating long paths and commands. It
# also produces somewhat unexpected results with regards to column
# length and placement.
# Features:
# - Right indent for number columns
mafredri / smb.conf
Last active Sep 21, 2022
Samba config for Open PS2 Loader (PlayStation 2)
View smb.conf
# This setup works pretty well for OPL with a network link that travels through
# two UniFi switches and connects to a Samba server running inside Docker. The
# host OS is Debian with a ZFS filesystem and the container OS is also Debian.
# Latest Samba (4.11+).
# ======================
# General Samba settings
# ======================
log level = 1
mafredri / usg_wireguard_upgrade.expect
Created Mar 1, 2019
Expect script to automate WireGuard upgrade on UniFi Security Gateway
View usg_wireguard_upgrade.expect
#!/usr/bin/env expect -f
# Description: Expect script to automate WireGuard upgrade on UniFi Security Gateway
# Author: Mathias Fredriksson <>
# This script assumes non-interactive ssh login.
# Usage upgrade.expect <[user@]usg> <${RELEASE}/wireguard-${BOARD}-${RELEASE}.deb>
set timeout 60
mafredri /
Last active Dec 17, 2018
gpg-yubikey-sign: Sign Git commits with any of your valid GPG subkeys
#!/usr/bin/env zsh
# gpg-yubikey-sign
# This script lets you use any of your unexpired subkeys connected to
# your public key (0xDEADBEEFCAFEBAAD) to sign git commits. It will also
# display "Waiting for YubiKey touch..." to remind you that an action is
# required.
# Add this script to your PATH and configure git to use it for gpg
# signing.
View cdp_issue45.go
// This example gives permission to access geolocation
// and fetches the current position via JavaScript.
// Tested on: cdp v0.18.7 and Chrome Canary 70.0.3532.0,
// and seems to work in both headless and headfull mode.
package main
import (
View cdp_issue54.go
package main
import (
mafredri / translate-bookmarklet.js
Created Aug 11, 2018
A bookmarklet to quickly translate the current webpage using Google Translate
View translate-bookmarklet.js
mafredri /
Last active Oct 16, 2020
Scripts for the reMarkable tablet (backup and factory reset)
# Creates remarkable_backup-(date).tar.gz with todays date, backs up /home/root.
ssh root@ 'tar cf - .' \
| gzip >remarkable_backup-$(date '+%Y-%m-%d').tar.gz
) 2 >err.log
cat err.log