Skip to content

Instantly share code, notes, and snippets.

View lucaswerkmeister's full-sized avatar

Lucas Werkmeister lucaswerkmeister

View GitHub Profile
@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/
@lucaswerkmeister
lucaswerkmeister / de.md
Created November 25, 2018 09:44
Wikidata For Long-Time Wikipedians elevator pitch, written at the Wikidata Train the Trainers workshop in Berlin

Elevator Pitch: Wikidata für langjährige Wikipedianer_innen

Du arbeitest bei Wikipedia mit, oder? Okay, stell dir vor:

Im südostasiatischen Hinterhuglhapfing wurde eine neue Volkszählung durchgeführt. Artikel in der bairischen Wikipedia für alle Orte in der Region wurden schon vor Jahren angelegt – wer aktualisiert jetzt die Einwohnerzahlen?

Oder: Eine schwedische Wikipedianerin war in Feuerland im Urlaub und hat einheimische Insektenarten fotografiert. Wie landen die Fotos jetzt in den entsprechenden Wikipedia-Artikeln in fünfzehn Sprachversionen?

From 38a7b52a3bb2d7d08639bdf46e5f3cba446fcde2 Mon Sep 17 00:00:00 2001
From: Lucas Werkmeister <[email protected]>
Date: Thu, 18 Oct 2018 16:12:53 +0200
Subject: [PATCH] Run new batches as the submitting user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This adds a new table storing OAuth details for a batch, and populates
it when any new batch is created. When running commands for a batch,