Skip to content

Instantly share code, notes, and snippets.

View johannrichard's full-sized avatar
😴
I may be quite slow to respond.

Johann Richard johannrichard

😴
I may be quite slow to respond.
View GitHub Profile
@johannrichard
johannrichard / worker.js
Created September 1, 2024 14:00
Cloudflare Worker for Alias Generation and Management
/**
* Cloudflare Worker for Alias Generation and Management
*
* This script enables the generation and management of email aliases using the SimpleLogin API. It is designed to check existing email aliases associated with a specific domain and create new custom aliases when necessary.
*
* Core Functionalities:
* - Queries existing email aliases linked to a given domain, using the SimpleLogin API.
* - Employs pagination to handle retrieval of aliases, allowing up to 20 aliases per page.
* - Utilizes regular expressions to identify domains in both `note` and `latest_activity` fields of aliases.
* - Supports the creation of new custom aliases, with options to specify a hostname and additional attributes like `note` and `name`.
{#- Frontmatter Template - also called *Properties* in Obsidian -#}
---
id: {{ id }}
created: {{ updated }}
{# For fields like title and aliases, remove linebreaks and either add spaces (title, alias) or create multiple list entries (author) #}
title: "{{ title | replace('\n', ' ')}}"
aliases: ["{{ title | replace('\n', ' ') }}"{%- if sanitized_title %}, "{{sanitized_title}}"{%- endif %}]
author: ["{{ author | replace('\n', '", "')}}"]
category: "{{ category }}"
highlights: {{ num_highlights }}
@johannrichard
johannrichard / Copy WikiLinks.js
Last active August 4, 2024 13:14
Obsidian User Plugins
@johannrichard
johannrichard / README.md
Last active September 4, 2022 10:19
Tailscale ACL GitOps Workflow

Tailscale ACL Workflow for GitOps

Tailscale recently introduced the possibility to manage Tailnet ACLs in Git Repositories. This is my tailscale.yml which has a notable difference to the one proposed by Tailscale. By putting the ACL test in front of the ACL deployment, it becomes a bit clearer that a failure happened b/c of a failed ACL.

Bonus: by installing act, one can actually run these tests locally, e.g. before committing / pushing to Github. Works well with a Git pre-commit hook that will fail if the ACL test is unsusscessful. Combined with the 1Password cli op command, you can get a nice little ACL workflow.

op run --env-file=".github/act/.env" -- act --secret TS_API_KEY --secret TS_TAILNET 
@johannrichard
johannrichard / README.md
Last active July 17, 2023 21:27
E-Mail Retention Policies for Gmail

How to bring E-Mail retention policies to Gmail / Google Mail:

  • Go to Google Scripts and create a blank project (make sure you are logged into your Google account);
  • paste the code (below) (and modify the policies as needed);
  • set a trigger (Resources -> Current Project's Triggers -> Add one now) to run it at the preferred interval; and
  • create filters in Gmail/Google Mail that set policies when specific messages arrive

Inspired and adapted from Gmail Automation: 5 Useful Google Scripts to Automate Your Gmail

@johannrichard
johannrichard / dm-toilet-paper.js
Created October 26, 2020 19:30 — forked from marco79cgn/dm-toilet-paper.js
Scriptable iOS widget that shows the amount of toilet paper which is available at your next dm drugstore
let country = 'de' // replace with 'at' for shops in Austria
let storeId = 251
let param = args.widgetParameter
if (param != null && param.length > 0) {
storeId = param
}
const widget = new ListWidget()
const storeInfo = await fetchStoreInformation()
const storeCapacity = await fetchAmountOfPaper()
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>net.duplicati.server</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/Duplicati.app/Contents/MacOS/duplicati-server</string>
<string>--webservice-port=8200</string>
@johannrichard
johannrichard / unbound-safe-search.conf
Last active July 9, 2024 08:43
Unbound DNS Safe Search config entries
# Safe Search Domains
# Paste / Add this to your Unbound config
local-data: "yandex.com A 213.180.193.56"
local-data: "yandex.ru A 213.180.193.56"
local-data: "yandex.ua A 213.180.193.56"
local-data: "yandex.by A 213.180.193.56"
local-data: "yandex.kz A 213.180.193.56"
local-data: "www.yandex.com A 213.180.193.56"
local-data: "www.yandex.ru A 213.180.193.56"
local-data: "www.yandex.ua A 213.180.193.56"
@johannrichard
johannrichard / asn.js
Last active November 20, 2021 15:11
Serverless Worker Function for ASN prefix parsing for OPNsense and pfSense
/***
* Worker Function for ASN prefix parsing
* Will query the BigIP API for a given ASN and return a plain-text representation of the ASN prefixes
* (IP ranges) that can be used in either OPNsense or pfSense URL Tables (Firewall alias).
*
* See https://docs.opnsense.org/manual/aliases.html (OPNsense) and https://docs.netgate.com/pfsense/en/latest/firewall/aliases.html (pfSense) for details of their use.
*
* You can deploy this worker for example on the free tier of CloudFlare (Up to 100'000 requests a day) or
* any other serverless platform that supports JavaScript
*
@johannrichard
johannrichard / fixup-mac-address
Last active October 12, 2018 20:08
InvizBox Go – MAC address change
#!/bin/sh
# Replace this in `/sbin/fixup-mac-address`
. /lib/functions.sh
. /lib/functions/system.sh
. /lib/ramips.sh
partname=""
offset=""
NEW_MAC=
YES=