Skip to content

Instantly share code, notes, and snippets.

@mafredri
mafredri / timemachine-zfs-snapshot
Last active Nov 19, 2020
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/timemachine-zfs-snapshot.sh rpool/share/timemachine
@mafredri
mafredri / zsh-histdb-tabulation.zsh
Last active Oct 11, 2020
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
mafredri / smb.conf
Last active Apr 30, 2021
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+).
[global]
# ======================
# General Samba settings
# ======================
log level = 1
@mafredri
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 <mafredri@gmail.com>
# This script assumes non-interactive ssh login.
# Usage upgrade.expect <[user@]usg> <https://github.com/Lochnair/vyatta-wireguard/releases/download/${RELEASE}/wireguard-${BOARD}-${RELEASE}.deb>
set timeout 60
@mafredri
mafredri / gpg-yubikey-sign.sh
Last active Dec 17, 2018
gpg-yubikey-sign: Sign Git commits with any of your valid GPG subkeys
View gpg-yubikey-sign.sh
#!/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 (
"context"
"fmt"
"log"
View cdp_issue54.go
package main
import (
"context"
"fmt"
"log"
"net/http"
"time"
"github.com/mafredri/cdp"
@mafredri
mafredri / translate-bookmarklet.js
Created Aug 11, 2018
A bookmarklet to quickly translate the current webpage using Google Translate
View translate-bookmarklet.js
javascript:(function(){window.location='https://translate.google.com/translate?sl=auto&tl=en&js=y&prev=_t&hl=en&ie=UTF-8&edit-text=&u='+encodeURIComponent(window.location.href)})();void(0);
@mafredri
mafredri / rm-backup.sh
Last active Oct 16, 2020
Scripts for the reMarkable tablet (backup and factory reset)
View rm-backup.sh
# Creates remarkable_backup-(date).tar.gz with todays date, backs up /home/root.
(
ssh root@10.11.99.1 'tar cf - .' \
| gzip >remarkable_backup-$(date '+%Y-%m-%d').tar.gz
) 2 >err.log
cat err.log
@mafredri
mafredri / README.md
Last active Feb 23, 2020
Add custom SSH keys to the Ubiquiti UniFi Controller
View README.md

Setting up custom SSH keys for UniFi hardware

  1. Create config.gateway.json to configure USG
  2. Create config.properties to configure switch / AP / etc...
  3. Place config.gateway.json and config.properties in data/sites/default
  4. Restart controller (maybe?)
  5. Reprovision all devices

Resources