Skip to content

Instantly share code, notes, and snippets.

View basilfx's full-sized avatar

Bas Stottelaar basilfx

View GitHub Profile
@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
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 / prullenbakvaccin.py
Last active May 19, 2021 08:46
Prullenbakvaccin bot for Telegram
"""
Copyright (C) 2021 Bas Stottelaar <basstottelaar@gmail.com>
License: Beerware
Disclaimer: use at your own risk
Usage:
- Install dependencies
@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 / 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 / Dockerfile
Last active October 10, 2022 19:35
Emulated-compilation of Docker images for another target platform with Python packages from source
# syntax=docker/dockerfile:experimental
# Compile all dependencies in a separate build environment. Note that the
# cache is copied to /cache as a final step, because the actual cache folder
# is an external mount.
FROM --platform=$TARGETPLATFORM python:3.8-alpine3.13 as buildenv
COPY requirements_base.txt requirements.txt ./
RUN --mount=type=cache,target=/root/.cache \
package observable
import (
"sync"
"github.com/twinj/uuid"
log "github.com/sirupsen/logrus"
)
@basilfx
basilfx / config.plist
Created May 7, 2019 16:50
Hackintosh on a HP 800 G1 SFF (macOS 10.14.4)
<?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>ACPI</key>
<dict>
<key>DSDT</key>
<dict>
<key>Fixes</key>
<dict>
@basilfx
basilfx / knxd.rb
Last active August 20, 2018 08:58
Homebrew Formula for knxd
class Knxd < Formula
desc "knxd is an advanced router/gateway; it can talk to all known KNX interfaces"
homepage "https://github.com/knxd/knxd"
head "https://github.com/knxd/knxd.git"
url "https://github.com/knxd/knxd/archive/v0.14.17.tar.gz"
sha256 "f1e64fd09a0bfa789e75311d4ac11353ebe83cca49929159f02b9bc41960afdd"
depends_on "argp-standalone" => :build
depends_on "autoconf" => :build
depends_on "automake" => :build
@basilfx
basilfx / CustomEvents.h
Created September 16, 2017 22:03
Repetier Firmware and WS2812B using events
#ifndef CUSTOM_EVENTS_H_INCLUDED
#define CUSTOM_EVENTS_H_INCLUDED
extern void Custom_Initialize();
extern void Custom_Timer100MS();
extern void Custom_SetBedTemp(float temp, bool beep);
extern void Custom_Kill(bool only_steppers);
extern void Custom_JamDetected(int8_t id);
extern void Custom_HeaterDecoupled(int8_t id);
extern void Custom_HeaterDefect(int8_t id);