Skip to content

Instantly share code, notes, and snippets.

@stvhay
stvhay / pi-hole-notes.md
Last active March 3, 2020 15:00
Pi Hole Docker Notes

/etc/systemd/network/net0_dns0.netdev

[NetDev]
Description=Virtual device for PiHole DNS
Name=dns0
Kind=macvlan

[MACVLAN]
Mode=bridge
@stvhay
stvhay / quassel-cert-generation.md
Last active March 3, 2020 09:52
Inserting SSL Certs into quassel
@stvhay
stvhay / wg-setup-namespace.md
Last active December 4, 2022 07:09
Set up wireguard with a network namespace such that you can specify what processes tunnel.

Synology/wg

To avoid some bugs in wg-quick and/or iptables on my Synology:

  1. I set up the wireguard device manually.
  2. I used network namespaces to create an explicit tunnel namespace. I then specified DNS for this namespace only.

Credit where credit is due. I got this idea from the Wireguard website. https://www.wireguard.com/netns/#the-new-namespace-solution

@stvhay
stvhay / asdf_upgrades.sh
Created April 15, 2020 03:50
upgrade all local pythons and rubies using asdf
#!/bin/bash
#set -x
function find_latest {
# find latest version
local PROGRAM=$1
local VERSION=$2
asdf list all "${PROGRAM}" | \
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | \
@stvhay
stvhay / safe_shelve.py
Created April 18, 2020 02:29
Shelve has inconsistent file naming, causing weirdness sometimes when you try to use it.
"""safe_shelve.py"""
import os
import shelve
DATA_DIR = 'data'
def open(db_name: str):
"""Opens and returns a shelve in an unambiguous place."""
directory = os.path.join(DATA_DIR, db_name)
@stvhay
stvhay / attrcattr.py
Last active April 21, 2020 19:35
Use of cattr
import attr
import cattr
import json
@attr.s
class FooClass:
x = attr.ib()
y = attr.ib()
@stvhay
stvhay / autossh.service
Last active November 24, 2020 10:38 — forked from thomasfr/autossh.service
Systemd service for autossh
[Unit]
Description=Keeps a tunnel to 'remote.example.com' open
After=network-online.target
[Service]
User=autossh
# -p [PORT]
# -l [user]
# -M 0 --> no monitoring
# -N Just open the connection and do nothing (not interactive)
@stvhay
stvhay / autossh.plist
Last active November 24, 2020 11:12 — forked from swinton/autossh.plist
launchd plist for keeping a tunnel alive
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!-- https://www.launchd.info/ -->
<plist version="1.0">
<dict>
<key>Label</key>
<string>tunnel.autossh</string>
<key>KeepAlive</key>
<dict>
@stvhay
stvhay / backup.sh
Last active November 11, 2022 01:20 — forked from skrajewski/backup.sh
Automate your macOS backup to Backblaze B2 using Restic and launchd.
#!/bin/bash
log () { echo "$(date +"%Y-%m-%d %T") " "$@"; }
home_dir='' # FILL THIS OUT
name='remote'
restic_path='/opt/homebrew/bin' # ADJUST AS NEEDED
pid_file="${home_dir}/.restic/${name}.pid"
timestamp_file="${home_dir}/.restic/${name}.timestamp"
hc_ping="https://hc-ping.com/uuid_here" # REPLACE WITH YOUR UUID