Skip to content

Instantly share code, notes, and snippets.

@praul
praul / docker_log_daemon.sh
Created January 25, 2025 07:56
Mount Logs of docker containers in human-readable format or for mounting in to fail2ban-container
#!/bin/bash
LOGS_DIR="/docker/user/logs"
DOCKER_BASE_PATH="/docker/containers"
mkdir -p "$LOGS_DIR"
create_mount() {
local container_id=$1
local container_name=$2
@praul
praul / parseFormattedNumber.php
Created January 8, 2025 08:27
Takes every formated number (1.602,00 | 1,602.00), recognizes format and outputs float
<?php
// Danke ChatGPT
function parseFormattedNumber(string $numberString): float
{
// Entferne alle Leerzeichen, um sicherzustellen, dass es keine unerwarteten Zeichen gibt
$numberString = str_replace(' ', '', $numberString);
// Überprüfe das Format: Punkt als Tausender-Trenner und Komma als Dezimaltrenner
if (preg_match('/^\d{1,3}(\.\d{3})*(,\d{2})?$/', $numberString) || preg_match('/^\d+(,\d{2})?$/', $numberString)) {
// Ersetze Punkte (Tausender-Trenner) und Komma (Dezimaltrenner)
@praul
praul / zahlInWorten.php
Created January 7, 2025 12:29
PHP - Zahl in Worten - Number to words (german)
<?php
/* Danke ChatGPT*/
function zahlInWorten($num) {
if (!is_numeric($num)) {
return "Eingabe ist keine Zahl.";
}
$zahlen = [
0 => "null", 1 => "eins", 2 => "zwei", 3 => "drei", 4 => "vier",
@praul
praul / vmswitcher
Created August 25, 2022 06:46
vmswitch for virsh- shutdown one vm, start another. on shutdown, start the first one again
#!/bin/bash
# chmod +x and run this script directly, NOT with "bash vmswitcher"
# ./vmswitcher -d to run in background
#Enter your vm-ids here
IDLEVM="powersave-server"
ACTIVEVM="bin10"
@praul
praul / autoreplyer.py
Last active November 2, 2023 20:00
Python out-of-office notice with rebound protection
"""
Automatically replies to mails both unread and unanswered.
This script has a rebound and self mail protection. Also a rate limit protection.
You can adjust the time value with the variable blockhours
Thanks to for original gist: https://gist.github.com/BertrandBordage/e07e5fe8191590daafafe0dbb05b5a7b
WARNING: This answers to any both unread and unanswered mail, even if it is years old.
Dont use on a mailbox with old messages left unread and unanswered.
Simply subclass ``AutoReplyer``, define the undefined class attribute,
@praul
praul / docker-compose.yml
Created June 24, 2021 07:35
Files for mtlynch / mediagoblin-docker
version: "3"
services:
mediagoblin:
image: heimpixel/mediagoblin_stl:01
ports:
- 6543:6543
volumes:
- /docker/user/datas/mediagoblin/media:/var/lib/mediagoblin #Your Media Path. Adjust Path in start.sh accordingly
- /docker/user/datas/mediagoblin/db/mediagoblin.db:/srv/mediagoblin.example.org/mediagoblin/mediagoblin.db #Your Database Path. Adjust Path in start.sh accordingly
@praul
praul / caddy-docker-blacklist-label.txt
Created May 27, 2021 08:14
Caddy Docker Blacklist
caddy: "domain.example.com"
[email protected]: "/login* /login /blacklisted*"
caddy.reverse_proxy: "@notblacklisted {{upstreams 8080 http}}"
@praul
praul / fbunshare.sh
Created May 27, 2021 05:29
Share files from filebrowser docker
#!/bin/bash
#These are two scripts to share and unshare files and folders to filebrowser, that runs in a docker container via docker-compose.
#It works across filesystems and users dockers own mount-binds.
#This image and the corresponding docker-compose.yml has been used: https://github.com/filebrowser/filebrowser
#See https://gist.github.com/praul/5234338823d61ac794e2fd95befc0b3d for share script
# Adjust path to docker-compose folder accordingly
# Usage: fbunshare.sh <FILE,FOLDER,OR PARTS OF IT>
@praul
praul / fbshare.sh
Last active May 27, 2021 05:29
Share files to filebrowser docker
#!/bin/bash
#These are two scripts to share and unshare files and folders to filebrowser, that runs in a docker container via docker-compose.
#It works across filesystems and users dockers own mount-binds.
#This image and the corresponding docker-compose.yml has been used: https://github.com/filebrowser/filebrowser
#Additionally you need yaml_cli from here: https://github.com/Gallore/yaml_cli
#See https://gist.github.com/praul/21d0b11aec5a0b71be8e406e9d7858f7#file-fbunshare-sh for unshare script
# Adjust path to docker-compose folder accordingly
# Usage: fbshare.sh <FILE OR FOLDER>
@praul
praul / stash-borg.py
Last active April 21, 2021 13:07
Borg Backup from stash scenes and galleries with rating and tag
#!/usr/env/python3
configpath = '/path/to/stash/config' #Path to your stash config files. No trailing slash
dockerpath = '/data/' #The path for media Stash uses internally. In docker containers this is often /data/. With trailing slash
realpath = '/real/path/to/your/media/' #The Path where your media files are at. Corresponds to dockerpath. With trailing slash
repo = '/path/to/your/borg/repo' #Your Borg Repo Path. No trailing slash
scriptpath = '/tmp/' #Temp Path - Bash script will be created here. With trailing slash
tagid = 197 #If you want to create a tag to flag files that should be backupped, enter the Id here. Else enter 0