Skip to content

Instantly share code, notes, and snippets.

View basilfx's full-sized avatar

Bas Stottelaar basilfx

View GitHub Profile
@basilfx
basilfx / kubectl-run-with-pvc.sh
Last active August 10, 2021 07:05 — forked from yuanying/kubectl-run-with-pvc.sh
kubectl run with PVCs
#!/bin/bash
# Modified from https://gist.github.com/yuanying/3aa7d59dcce65470804ab43def646ab6.
IMAGE="ubuntu:20.04"
COMMAND="/bin/bash"
SUFFIX=$(date +%s | shasum | base64 | fold -w 10 | head -1 | tr '[:upper:]' '[:lower:]')
usage_exit() {
echo "Usage: $0 [-n namespace] [-c command] [-i image] PVC ..." 1>&2
@basilfx
basilfx / middleware.py
Created April 2, 2021 19:59
Django middleware to cache request.user
from django.contrib.auth import SESSION_KEY
from django.core.cache import cache
from django.utils.functional import SimpleLazyObject
from django.contrib.auth.signals import user_logged_out
from django.contrib.auth import get_user_model
from django.db.models.signals import post_save, post_delete
from functools import partial
@basilfx
basilfx / prullenbakvaccin.py
Last active May 19, 2021 08:46
Prullenbakvaccin bot for Telegram
"""
Copyright (C) 2021 Bas Stottelaar <[email protected]>
License: Beerware
Disclaimer: use at your own risk
Usage:
- Install dependencies
CREATE TABLE IF NOT EXISTS collectd_metrics (
time TIMESTAMPTZ NOT NULL,
plugin TEXT,
plugin_instance TEXT,
type_instance TEXT,
type TEXT,
host TEXT,
metric TEXT,
value DOUBLE PRECISION
);
@basilfx
basilfx / fail2ban_plugin.py
Created June 18, 2021 18:34
Fail2ban plugin for collectd
"""
Plugin for collectd to fetch Fail2ban statistics per jail.
Recreated, but based on the original source code by Antti Jaakkola
(https://github.com/annttu/collectd-plugins).
To add this plugin to collectd, create a definition as below:
```python
LoadPlugin python