Skip to content

Instantly share code, notes, and snippets.

View lucaswerkmeister's full-sized avatar

Lucas Werkmeister lucaswerkmeister

View GitHub Profile
@lucaswerkmeister
lucaswerkmeister / post.md
Created September 25, 2025 23:43
QuickCategories statistics 2025-09-26

Underlying SQL queries for the data published in this Mastodon post:

Total number of batches:

MariaDB [s53976__quickcategories]> SELECT COUNT(*) FROM batch;
+----------+
| COUNT(*) |
+----------+
|    10180 |
@lucaswerkmeister
lucaswerkmeister / userscript.js
Created September 20, 2025 20:26
user script: Decode Buttondown emails to remove tracking
// ==UserScript==
// @name Decode Buttondown emails to remove tracking
// @namespace http://tampermonkey.net/
// @version 2025-09-20
// @description Replace the URL of links in Buttondown emails with the actual link target, bypassing Buttondown’s redirector (which probably does some tracking stuff)
// @author Lucas Werkmeister
// @match https://buttondown.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=buttondown.com
// @grant none
// ==/UserScript==
@lucaswerkmeister
lucaswerkmeister / Preload Questionable Content.js
Created January 23, 2024 23:54
Questionable Content user scripts
// ==UserScript==
// @name Preload Questionable Content
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Preload the next Questionable Content comic image.
// @author Lucas Werkmeister
// @match https://questionablecontent.net/*
// @match https://www.questionablecontent.net/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=questionablecontent.net
// @grant none
@lucaswerkmeister
lucaswerkmeister / maint
Last active July 21, 2023 13:49
MediaWiki development helpers
#!/bin/sh
if [ $# -eq 0 ]; then
printf >&2 '%s: at least one argument is required\n' "$0"
exit 1
fi
if [ -e "$1" ]; then
file=$(realpath "$1")
else
file=$1
/* tentative style for wikis.world; mainly based on https://userstyles.world/style/7548/mastodon-alt-text-indicator */
/* highlight media without alt text in posts */
:is(
.status,
.detailed-status
) :is(
.audio-player__canvas,
.media-gallery__item-gifv-thumbnail:not(:fullscreen),
.media-gallery__item-thumbnail img,
@lucaswerkmeister
lucaswerkmeister / gitweb.cgi
Created November 1, 2021 16:45
GitWeb wrapper to fix UTF-8 in FastCGI (no longer needed in Debian Bullseye)
#!/usr/bin/perl
# gitweb.cgi wrapper that fixes the UTF-8 problem with fastcgi
# Local redefinition of FCGI::Stream::PRINT
use Encode;
use FCGI;
our $enc = Encode::find_encoding('UTF-8');
our $org = \&FCGI::Stream::PRINT;
no warnings 'redefine';
@lucaswerkmeister
lucaswerkmeister / category-download
Created August 19, 2019 22:43
script to download all files in a Wikimedia Commons category
#!/bin/bash
declare -A original_params=(
[action]=query
[generator]=categorymembers
[gcmtitle]="Category:${1:?category not specified}"
[gcmtype]=file
[gcmlimit]=max
[prop]=imageinfo
[iiprop]=size
@lucaswerkmeister
lucaswerkmeister / import.js
Created April 12, 2019 14:38
Client-side (in-browser) import of Wikidata entities into another Wikibase installation
async function importEntitiesFromWikidata( wikidataEntityIds ) {
const params = new URLSearchParams();
params.set( 'action', 'wbgetentities' );
params.set( 'ids', wikidataEntityIds.join( '|' ) );
params.set( 'props', [ 'labels', 'descriptions', 'aliases', 'datatype' ].join( '|' ) );
params.set( 'format', 'json' );
params.set( 'origin', '*' );
const response = await fetch( `https://www.wikidata.org/w/api.php?${ params.toString() }` ),
json = await response.json();
for ( const wikidataEntityData of Object.values( json.entities ) ) {
@lucaswerkmeister
lucaswerkmeister / wipe-ssh-agent.service
Created March 19, 2019 11:05
systemd user units to wipe sensitive SSH keys from the SSH agent every night
[Unit]
Description=Wipe sensitive SSH keys from the SSH agent
[Service]
Type=oneshot
ExecStart=/usr/bin/ssh-add -d ${HOME}/.ssh/KEY-NAME-1 ${HOME}/.ssh/KEY-NAME-2 …
# don’t fail if the key wasn’t in the SSH agent in the first place
SuccessExitStatus=1
@lucaswerkmeister
lucaswerkmeister / increment.sed
Created February 18, 2019 08:20
sed script to increment an integer by one
#!/bin/sed -f
# if the number is not negative:
/^-/! {
# increment the last digit; mark carry with an “X”
s/9$/X/
s/8$/9/
s/7$/8/
s/6$/7/
s/5$/6/