Skip to content

Instantly share code, notes, and snippets.

View stranger-danger-zamu's full-sized avatar
🍑

stranger-danger-zamu

🍑
View GitHub Profile
@stranger-danger-zamu
stranger-danger-zamu / alpine_motd_generator.md
Created May 23, 2023 16:10 — forked from arvati/alpine_motd_generator.md
Dynamic motd generator for Alpine Linux (/etc/periodic/15min/motd)

Make a dynamic motd for your server

create a crond script to dynamic create an motd message to users

rc-service crond start && rc-update add crond
nano /etc/periodic/15min/motd
chmod a+x /etc/periodic/15min/motd
run-parts --test /etc/periodic/15min

Contents of /etc/periodic/15min/motd

@stranger-danger-zamu
stranger-danger-zamu / bash_history_date_freqs.py
Created September 7, 2022 04:37
Roughly based off of github.com/blurfx/calendar-heatmap.
from pathlib import Path
from collections import defaultdict
from datetime import datetime
def cmd_freq_by_date(bash_history_path:Path):
freqs = defaultdict(int)
for _, _, dt_str, _ in (l.strip().split(' ', 3) for l in bash_history_path.read_text().splitlines()):
dt = datetime.fromisoformat(dt_str[1:-1])
freqs[(dt.year, dt.month, dt.day)] += 1
return freqs
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
#author: rex
#blog: http://iregex.org
#filename trie.py
#created: 2010-08-01 20:24
#source uri: http://iregex.org/blog/trie-in-python.html
# escape bug fix by fcicq @ 2012.8.19
@stranger-danger-zamu
stranger-danger-zamu / convert_flac_for_usb.sh
Created November 7, 2021 19:33
Parallel convert FLAC files to MP3 with `fd` or `find`
#!/usr/bin/env bash
ffmepg -i "${1}" -ab 320k -map_metadata 0 -id3v2_version 3 "${2}"
kid3-cli -c 'fromtag "%{artist} - %{album} - %{track}. %{title}" 2' "${2}"
@stranger-danger-zamu
stranger-danger-zamu / chyoa-story-map.user.js
Last active September 5, 2020 01:32
CHYOA story map user script
// ==UserScript==
// @name CHYOA story map fixer
// @description Adjust the left-margin and a few other small adjustments to make deep stories less of a pain.
// @version 0.2.0
// @grant none
// @include https://chyoa.com/story/*
// @updateUrl https://gist.github.com/stranger-danger-zamu/410ee603ce2ffcd7dbf02bd9ae3b0aa7/raw/chyoa-story-map.user.js
// @match https://chyoa.com/story/*/map
// ==/UserScript==
@stranger-danger-zamu
stranger-danger-zamu / CHYOA-story-map-fix.js
Last active September 2, 2020 17:17
CHYOA Story Map rendering fix.
Array.from(document.querySelectorAll('.story-map-chapter')).forEach(x=>{
if (x.dataset.adjusted_indent) {
return
}
margin = x.style['margin-left'];
indent = parseInt(margin.replace('px','')) / 30
margin = `${Math.min(indent, document.body.clientWidth - 300 - Math.min(indent, 200 ))}px`;
x.style['margin-left'] = margin;
x.style['min-width'] = '500px';
x.dataset.adjusted_indent = true;