Skip to content

Instantly share code, notes, and snippets.

View sparr's full-sized avatar

Clarence "Sparr" Risher sparr

  • Estate of Mind
  • Northbridge MA USA
View GitHub Profile
@sparr
sparr / mapscontainer.cpp
Last active August 30, 2025 03:43
C++ class containing multiple maps with the same key and value types, with a forward iterator across all of the maps
#include <array>
#include <cassert>
#include <map>
#include <iterator>
template< typename Key, typename Value, int n >
class MapsContainer
{
private:
std::array< std::map< Key, Value >, n > maps;
different context but not really:
'%1$s hits your %2$s.' | '%1$s hits your %2$s!'
unsure:
'Office Tower Rooftop' | 'Office Tower 2 Rooftop'
'Let's get a move on.' | 'Let's get a move on!'
'You don't have that item.' | 'You don't have that item!'
'You are slammed against %s!' | 'You are slammed against %s.'
'They know what you've done.' | 'They know what you've done…'
'You try to sleep, but can't.' | 'You try to sleep, but can't…'
@sparr
sparr / find_almost_duplicate_translations.py
Created August 19, 2025 19:35
Python script to find po file translations that differ by just a few characters
#!/usr/bin/env python
import polib
import Levenshtein as L
pofile = polib.pofile('po/base.pot')
entries = {}
for entry in pofile:
@sparr
sparr / add_page_numbers.ps
Last active March 17, 2025 14:24
Postscript script to add page numbers to an existing document
%!PS
% originally from https://stackoverflow.com/a/57162167/13675
% Usage to concatentate multiple PDFs, number all the pages sequentially, and output a single PDF:
% gs \
% -dBATCH -dNOPAUSE \
% -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress \
% -sOutputFile=/path/to/merged.pdf \
% -f add_page_numbers.ps -f input1.pdf -f input2.pdf
% modifications by Clarence "Sparr" Risher <[email protected]>
ccafdsse001-dwesanctuary.bsa
ccafdsse001-dwesanctuary.esm
ccasvsse001-almsivi.bsa
ccasvsse001-almsivi.esm
ccbgssse001-fish.bsa
ccbgssse001-fish.esm
ccbgssse002-exoticarrows.bsa
ccbgssse002-exoticarrows.esl
ccbgssse003-zombies.bsa
ccbgssse003-zombies.esl
@sparr
sparr / gist:f3502db3fa6edb9decae9caadd047393
Created December 10, 2024 15:04
Hide non-results from Youtube search results
www.youtube.com##ytd-shelf-renderer.style-scope:has(span:has-text(/For you/i))
www.youtube.com##ytd-shelf-renderer.style-scope:has(span:has-text(/People also watched/i))
www.youtube.com##ytd-shelf-renderer.style-scope:has(span:has-text(/People also search for/i))
www.youtube.com##ytd-shelf-renderer.style-scope:has(span:has-text(/Previously watched/i))
www.youtube.com##ytd-shelf-renderer.style-scope:has(span:has-text(/Explore more/i))
www.youtube.com##ytd-shelf-renderer.style-scope:has(span:has-text(/Related to your search/i))
www.youtube.com##ytd-shelf-renderer.style-scope:has(span:has-text(/From related searches/i))
www.youtube.com##ytd-horizontal-card-list-renderer.ytd-item-section-renderer.style-scope
@sparr
sparr / factorio_entity_heating_energy_cost.csv
Last active November 26, 2024 12:48
Factorio 2.0 Entity Heating Cost
entity name heating_energy/16.667
storage-tank 100
transport-belt 10
fast-transport-belt 10
express-transport-belt 10
turbo-transport-belt 10
underground-belt 50
fast-underground-belt 100
express-underground-belt 150
turbo-underground-belt 200
@sparr
sparr / gist:9861c782956b3eabae3ac9e1bf4ec6ce
Created September 20, 2024 00:42
Steam Proton all games crashing on EndeavourOS due to Vulkan library package choice
When installing AMD drivers on EndeavourOS I was prompted to choose Vulkan packages. I chose `amdvlk lib32-amdvlk` which turns out to have been a mistake. This led to almost every game using Proton crashing on launch with one of the following two error messages in the logs (among much longer more unique stack traces). The "correct" packages which resolved this issue are `vulkan-radeon lib32-vulkan-radeon`.
Error type 1, from games including Craft the World, Ring of Pain, Slipways:
14981.844:0124:0128:err:vulkan:wine_vkCreateInstance Failed to create instance, res=-9
14981.844:0124:0128:trace:loaddll:free_modref Unloaded module L"C:\\windows\\system32\\winevulkan.dll" : builtin
err: DxvkInstance::createInstance: Failed to create Vulkan 1.1 instance
Error type 2, from games including Banished, Ring of Pain, Slipways:
@sparr
sparr / .Xmodmap
Created September 19, 2024 16:30
xmodmap config to remap unused special keys on Lenovo E15 to audio control
! Remap unused special keys on Lenovo E15 to audio control
! Fn+F9, message box icon, originally XF86Messenger
keycode 224 = XF86AudioPrev NoSymbol XF86AudioPrev
! Fn+F10, phone handset upright icon, originally XF86Go
keycode 226 = XF86AudioPlay NoSymbol XF86AudioPlay
! Fn+F11, phone handset face down icon, originally Cancel
keycode 231 = XF86AudioStop NoSymbol XF86AudioStop
! Fn+F12, star icon, originally XF86Favorites
keycode 164 = XF86AudioNext NoSymbol XF86AudioNext
@sparr
sparr / wait_for_one_process_to_exit.sh
Created September 9, 2024 21:25
Bash script: Wait for one process to exit
#!/bin/bash
#
# This script launches two processes and exits when either of them exits
(
do_thing_1
kill -s SIGHUP $$
) &
(