Skip to content

Instantly share code, notes, and snippets.

-----BEGIN PGP PUBLIC KEY BLOCK-----
Comment: 9EA6 C866 165A 3A86 08BE 3568 EA2D C27E 87A4 94F2
Comment: Frederik Holm Strøm (https://frederikstroem.com) <[email protected]>
xjMEYcKXfhYJKwYBBAHaRw8BAQdAYYr1A3SfO/3KrCcRH1B9Auug0f2c7i7Eyik+
iNrpsOnNSkZyZWRlcmlrIEhvbG0gU3Ryw7htIChodHRwczovL2ZyZWRlcmlrc3Ry
b2VtLmNvbSkgPHBncEBmcmVkZXJpa3N0cm9lbS5jb20+wsJmBBMWCgLOAhsBBAsJ
CAcEFQoJCAUWAgMBAAIeAQIXgAIZARYhBJ6myGYWWjqGCL41aOotwn6HpJTyBQJm
+SI6RxSAAAAAABAALnByb29mQGFyaWFkbmUuaWRodHRwczovL2dpdGxhYi5jb20v
ZnJlZGVyaWtzdHJvZW0vZ2l0bGFiX3Byb29mVhSAAAAAABAAPXByb29mQGFyaWFk
@frederikstroem
frederikstroem / .bashrc
Created September 30, 2024 08:11
Bash alias to list or prune local tracking branches that do not exist on remote anymore.
# Source: https://web.archive.org/web/20240930075945/https%3A%2F%2Fstackoverflow.com%2Fquestions%2F13064613%2Fhow-to-prune-local-tracking-branches-that-do-not-exist-on-remote-anymore#17029936
alias git-list-untracked='git fetch --prune && git branch -r | awk "{print \$1}" | grep -E -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk "{print \$1}"'
alias git-remove-untracked='git fetch --prune && git branch -r | awk "{print \$1}" | grep -E -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk "{print \$1}" | xargs git branch -d'
alias git-remove-untracked-force-unmerged='git fetch --prune && git branch -r | awk "{print \$1}" | grep -E -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk "{print \$1}" | xargs git branch -D'
@frederikstroem
frederikstroem / backup.sh
Last active June 9, 2024 10:06
ZFS snapshot to Backblaze B2 rclone remote backup script. Work in progress code snapshot from self-hosted infrastructure development.
#!/bin/bash
# _ _ _
# (_)_ __ (_) |_
# | | '_ \| | __|
# | | | | | | |_
# |_|_| |_|_|\__|
# Make sure running as root.
if [ "$(id -u)" != "0" ]; then
@frederikstroem
frederikstroem / sieve_filter.txt
Created February 28, 2024 14:59
SimpleLogin auto-label Sieve filter (created & tested for ProtonMail)
# `envelope` command `from` retrieves `return-path` header, e.g. "[email protected]".
# Sources:
# - https://proton.me/support/sieve-advanced-custom-filters
# - https://simplelogin.io/docs/getting-started/troubleshooting/
# Require `envelope` and `fileinto` extensions.
require ["fileinto", "envelope"];
# Emails from SimpleLogin domains are filed into "SimpleLogin".
if envelope :domain :is "from" ["simplelogin.co", "simplelogin.io"] {
@frederikstroem
frederikstroem / waiting_service.service
Created January 16, 2024 22:59
Wait for Tailscale/Headscale backend to start before starting Systemd user service
[Unit]
Description=Waiting for Tailscale Backend
[Service]
Type=simple
EnvironmentFile=%h/waiting_service/.env
ExecStartPre=/usr/bin/bash -c 'until [[ "$(tailscale status --json | jq -r '.BackendState')" == "Running" ]]; do sleep 1; done' # Wait for Tailscale/Headscale to start.
ExecStart=/usr/bin/python3 %h/waiting_service/main.py
Restart=always
RestartSec=5
@frederikstroem
frederikstroem / automated_github_cloner.service
Last active June 9, 2024 10:03
2024-06-09 snapshot of automated GitHub cloning tool. Clone or pull all GitHub repositories (submodules included) and Gists across all GitHub organizations and personal account every x hours. Discord webhook on errors. Script is hacked together and unstable!
[Unit]
Description=Automated GitHub cloning tool
[Service]
Type=simple
Environment=DATA_DIR=/tank/automated_github_cloner
EnvironmentFile=%h/automated_github_cloner/.env
ExecStart=/usr/bin/python3 %h/automated_github_cloner/main.py
Restart=always
RestartSec=5
@frederikstroem
frederikstroem / tts
Last active August 2, 2023 20:36
Cogai TTS using docker & script placed at ~/.local/bin/tts
#!/usr/bin/env bash
# Test: `echo "This should be read up for me" | tts`
# Read all input into variable and replace newlines with spaces
input=$(cat | tr '\n' ' ')
# Save current time in ISO8601 format and replace special characters with underscore
timestamp=$(date -u +"%Y_%m_%dT%H_%M_%SZ")
@frederikstroem
frederikstroem / joplin_vscode_workspace.md
Last active April 30, 2023 12:18
Joplin Note and VS Code Workspace

Joplin Note and VS Code Workspace

Configure Joplin's external editor settings to open a specific workspace in Visual Studio Code when editing notes.

Path (Linux): /usr/bin/code

Arguments: --wait --new-window /home/your_username/copilot-powered.code-workspace

@frederikstroem
frederikstroem / proof.txt
Last active March 23, 2022 20:47
Session ID proof
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
Session ID: 05370a12bfe51c546b06bbc5dc131bfd091aeaf02bdfd5d9d4f8784f495522dc49
-----BEGIN PGP SIGNATURE-----
iHUEARYKAB0WIQRuImp4wxgx4e3uWqPaQi3qJfhRSAUCYjuF5QAKCRDaQi3qJfhR
SJFOAP9LEFIM2mye+d/v+J64gI+XZ06UR9aT12KJC1nv73UxCAD+J9WZHfP2L/uq
Pm10NZgsVrwcbB4pmU/eVWxSfhj4MAE=
=BH+I
@frederikstroem
frederikstroem / docker-compose.yml
Last active December 31, 2023 15:41
Run tensorflow/tensorflow:latest-gpu-jupyter docker image on localhost without having to authenticate. Useful if you SSH into your machine etc.
version: "3.9"
# https://www.tensorflow.org/install/docker
services:
tensorflow:
image: tensorflow/tensorflow:latest-gpu-jupyter # https://hub.docker.com/r/tensorflow/tensorflow/
container_name: tensorflow
hostname: tensorflow
# https://github.com/tensorflow/tensorflow/blob/master/tensorflow/tools/dockerfiles/dockerfiles/gpu-jupyter.Dockerfile
# https://stackoverflow.com/a/60327026