Skip to content

Instantly share code, notes, and snippets.

View mschmitt's full-sized avatar
🥾
Busier than a one-legged man in an ass-kicking contest.

Martin Schmitt mschmitt

🥾
Busier than a one-legged man in an ass-kicking contest.
View GitHub Profile
#!/usr/bin/env bash
set -o errexit
# A native bash function to mimic the behaviour of shuf(1).
#
# - From the failed experiments department.
# - Unusably slow on long files with thousands of lines.
#
# "Arrays are sparse doubly-linked lists."
# https://git.savannah.gnu.org/cgit/bash.git/tree/array.c
@mschmitt
mschmitt / stfd.conf
Last active March 18, 2022 09:00
systemd: Howto quickly sigkill (-9) a service that blocks shutdown for minutes. (Here: ESET Antivirus, eea.service)
# /lib/systemd/system/eea.service.d/stfd.conf
[Service]
TimeoutStopSec=5
TimeoutStopFailureMode=kill
@mschmitt
mschmitt / play-wallpaper.yml
Last active December 19, 2023 14:38
Gnome wallpaper changer in native systemd user units
#!/usr/bin/env ansible-playbook
---
- hosts: localhost
become: false
gather_facts: false
connection: local
tasks:
- name: Systemd user config location
file:
path: ~/.config/systemd/user/
@mschmitt
mschmitt / ATmega32U4_StartStartStart.ino
Created January 13, 2022 07:29
Automatic BIOS password entry for computers in a remote lab
#include "HID-Project.h"
#define WAIT_SECS 900
void setup() {
BootKeyboard.begin();
delay(10 * 1000);
}
void loop() {
@mschmitt
mschmitt / day-night-detection.cron
Last active October 7, 2021 09:44 — forked from webghostx/day-night-detection.py
day/night detection for cron jobs
# Run every minute and do things IF NOT night.
* * * * * (is_night || do_things) >/dev/null 2>&1
# Run every hour and do things IF night.
0 * * * * (is_night && do_things) >/dev/null 2>&1
@mschmitt
mschmitt / dashcat
Last active August 9, 2022 18:31
dashcat can be used to concatenate dashcam videos
#!/usr/bin/env bash
# dashcat can be used to concatenate dashcam videos
overlap=1
function cleanup(){
trap - INT QUIT TERM EXIT
rm -v -f "${playlist_temp}"
for t in "${video_temp[@]}"
@mschmitt
mschmitt / git-credential-azdo-token
Created January 27, 2021 18:16
A git credential helper for a shared user that needs to authenticate to distinct Azure Devops users with their distinct tokens, depending on which user is using the shared user. Don't use this, find a better job instead, where people pay some basic respect to you and your work.
#!/bin/bash
# Process only the get requests to this credential helper.
# https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage
# git config credential.helper 'azdo-token'
[[ "${1}" == "store" ]] && exit 0
[[ "${1}" == "erase" ]] && exit 0
want_username="${SUDO_USER}"
printf -v want_aes_file "%s/.azdo-token-for-%s.aes" "${HOME}" "${want_username}"
@mschmitt
mschmitt / gone.txt
Last active March 5, 2021 21:47
Scriptable.app widget for monitoring go-eCharger(s)
Neuer Link: https://github.com/mschmitt/go-e-widget
@mschmitt
mschmitt / JavaHome.jar
Last active January 5, 2021 17:41
Find current JVM, either from java builtin property or from $JAVA_HOME
@mschmitt
mschmitt / go-e-zaehlerstand
Last active December 18, 2020 14:48
Zählerstand der go-e Wallbox auslesen
#!/bin/bash
url="http://go-echarger/status"
#url="https://api.go-e.co/api_status?token=abcdef0123"
if [[ "${url}" =~ api.go-e.co ]]
then
dataobject='.data'
else
dataobject='.'