Skip to content

Instantly share code, notes, and snippets.

View TimKraemer's full-sized avatar
🌴
Working on AR / VR

Tim Krämer TimKraemer

🌴
Working on AR / VR
View GitHub Profile
@TimKraemer
TimKraemer / create-domain-report.py
Last active November 30, 2023 13:36
create an access log report in csv based on nginx-proxy log files
import json
import csv
import argparse
import re
from datetime import datetime
def extract_data(log_data, domain, poi):
# Adjust the regex to better handle the log line format
pattern_str = r'.*?\[(\d{2}/\w{3}/\d{4}:\d{2}:\d{2}:\d{2} \+\d{4})\]' # Match timestamp
pattern_str += r'\s"GET\s(.*?)\sHTTP/.*?"' # Capture requested resource
@TimKraemer
TimKraemer / dc.sh
Created January 22, 2023 21:54
docker-compose wrapper for multiple yaml config files
#!/bin/bash
# put this to /usr/local/bin/dc
command="$(which docker-compose) -f /opt/services/docker-compose.yaml"
for f in $(find /opt/services -maxdepth 1 -type f -name "*.yaml" 2>/dev/null); do
[[ ${f} =~ "docker-compose.yaml" ]] && continue
command="${command} -f ${f}"
done
${command} "${@}"
@TimKraemer
TimKraemer / trip2excel.py
Last active May 10, 2024 13:17
python script to create a driver's log book "Fahrtenbuch" for Excel based on Google's Maps Timeline takeout data
import json
import sys
from datetime import datetime
import csv
import os
from geopy.geocoders import Nominatim # pip install geopy
def convert_date(date_str):
# Parse the ISO 8601 format date string
@TimKraemer
TimKraemer / contact.php
Created May 22, 2019 17:03 — forked from frjo/contact.php
PHP script for contact form
<?php
// Set the e-mail address that submission should be sent to.
$address = '[email protected]';
// Set the e-mail subject prefix.
$prefix = 'Website feedback';
// DO NOT EDIT ANYTHING BELOW UNLESS YOU KNOW WHAT YOU ARE DOING.
@TimKraemer
TimKraemer / restore.sh
Last active October 24, 2018 13:20
KMDB restore kmdb from dump
#!/bin/bash
cp -a $1 /tmp/kmdb.dump
sudo su postgres <<EOF
cd ~
dropdb db
createdb db --owner=kmdb --encoding=UTF8
pg_restore -l /tmp/kmdb.dump | sed '/MATERIALIZED VIEW DATA/d' > restore.lst
pg_restore -L restore.lst -d db /tmp/kmdb.dump > /dev/null 2>&1
pg_restore -l /tmp/kmdb.dump | grep 'MATERIALIZED VIEW DATA' > refresh.lst
psql -d db -c 'REFRESH MATERIALIZED VIEW unique_lexeme;'
@TimKraemer
TimKraemer / le-renew-webroot
Created September 1, 2017 13:52
Zimbra Let's encrypt
#!/bin/bash
web_service='nginx'
config_files=( "/home/tim/le-renew-webroot.ini" "/home/tim/le-renew-webroot-mk.ini" "/home/tim/le-renew-webroot-hackman.ini" "/root/le-renew-webroot.ini" )
le_path='/opt/letsencrypt'
exp_limit=30;
for config_file in "${config_files[@]}"
do
@TimKraemer
TimKraemer / wifionice
Last active September 30, 2024 16:05 — forked from vollkorn1982/wifionice
HowTo auto connect your Linux to the German Wifi on ICE trains
#!/bin/sh
# put this file in /etc/network/if-up.d/
if iwconfig wlp4s0 | grep -c "ESSID:\"WIFIonICE\""
then
curl -s "https://www.ombord.info/hotspot/hotspot.cgi?connect=&method=login&realm=db_advanced_wifi"
fi
#!/bin/bash
# automagically downloads the newest stable mediawiki and it's php dependencies
MW_PATH="/export/home/wwwfsr/fachschaft/wiki" # set your mediawiki path here
MW_stable_branch_number=$(curl -s "https://www.mediawiki.org/w/api.php?action=expandtemplates&text=\{\{MW%20stable%20branch%20number\}\}&prop=wikitext&formatversion=2&format=json" | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["expandtemplates"]["wikitext"]')
MW_stable_release_number=$(curl -s "https://www.mediawiki.org/w/api.php?action=expandtemplates&text=\{\{MW%20stable%20release%20number\}\}&prop=wikitext&formatversion=2&format=json" | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["expandtemplates"]["wikitext"]')
@TimKraemer
TimKraemer / kmdb_backup_script.sh
Created June 20, 2016 13:21
daily postgres dump called by crontab
#!/bin/bash
su postgres -c 'pg_dump db --clean' | gzip --rsyncable --best > /data/export/KM/backup/kmdb/"$(date +"%Y-%m-%d")".gz
@TimKraemer
TimKraemer / online_service_health_check.sh
Last active June 27, 2018 12:45
script to check LOCKBASE online services availability
#!/bin/bash
# PURPOSE: Script to check LOCKBASE online services availability
LOG_FILE="/var/log/online_services_health.log"
EMAIL_ADDRESS="[email protected]"
HetznerURL="https://lockbase.net/cgi-bin/"
BackupURL="https://lockbase.org/cgi-bin/"
OnlineCheckURL="https://www.google.com/"
WebsiteURL="https://koertner-muth.de/koertner-muth/Navi.cgi"