Skip to content

Instantly share code, notes, and snippets.

View bertptrs's full-sized avatar

Bert Peters bertptrs

View GitHub Profile
@bertptrs
bertptrs / Camels.svg
Created December 30, 2023 14:28
Camel paths
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/bin/bash
get_latest_release() {
curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api
grep '"tag_name":' | # Get tag line
sed -E 's/.*"v([^"]+)".*/\1/' # Pluck JSON value
}
VERSION=$(get_latest_release "go-gitea/gitea")
@bertptrs
bertptrs / stommepuzzel.py
Last active June 13, 2019 09:02
Pythonic proof that a certain Einstein-like puzzle was impossible
import itertools
import sys
PEOPLE = ['Pieter', 'Maaike', 'Kim', 'Tim', 'Patrieck']
AGES = ['Bever', 'Welp', 'Scout', 'Explorer', 'Rover']
BADGES = ['Das', 'Knopen', 'EHBO', 'Boomhut', 'Vissen']
@bertptrs
bertptrs / occ
Created April 18, 2019 10:04
OCC override
#!/bin/sh
exec sudo -u http php -d memory_limit=512M /usr/share/webapps/nextcloud/occ "$@"
#!/usr/bin/env python3
import itertools
import matplotlib.pyplot as plt
import numpy as np
D6 = np.arange(0, 6) + 1
two_dice = np.array([a + b for a, b in itertools.product(D6, D6)])
no_fives = np.array([x for x in two_dice if x != 5])
WINNINGS = np.array([-5, 0, 1.5, 0, -1, 1, 0, 1, 0, -1.5, 5])
@bertptrs
bertptrs / replace.vim
Last active September 10, 2018 09:34
Textile links to markdown links
%s/"\([^"]\+\)":\([^\s]\+\)/[\1](\2)/g
@bertptrs
bertptrs / dmarcforwarder.py
Last active July 5, 2018 08:32
DMARC forwarder bot
#!/usr/bin/python3
import argparse
import email
import io
import smtplib
import socket
import sys
import xml.etree.ElementTree as ET
import zipfile
#!/bin/bash
URL=https://isonzeinterndronken.nl/leiden/dlf/
cookiejar=$(mktemp)
request() {
curl -s -c "$cookiejar" -b "$cookiejar" "$@" "$URL"
}
cleanup() {
@bertptrs
bertptrs / pacman
Last active August 31, 2016 17:35
A munin plugin for monitoring pacman updates
#!/bin/bash
case $1 in
config)
cat <<'EOM'
graph_args --base 1000 -l 0
graph_category pacman
graph_title Pending updates
graph_vlabel updates
updates.label updates
@bertptrs
bertptrs / 0backup-boot.hook
Created August 28, 2016 12:18
Pacman hook to backup boot partition. Should be installed in /etc/pacman.d/hooks
[Trigger]
Operation = Upgrade
Operation = Install
Operation = Remove
Type = File
Target = boot/*
[Action]
Description = Backing up boot partition
When = PreTransaction