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 / philadelphia_police_pools_budget_balancer.html
Created July 5, 2026 14:21
Philadelphia Police Pools Budget Balancer
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Philadelphia Police vs Pools Budget Balancer</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
background: #eee;
display: flex;
@sparr
sparr / BlueprintMod.lua
Created January 12, 2026 22:08
Alchemy Factory mod attempt for blueprint loading modification
-- =========================
-- Userdata converters
-- =========================
-- The return types below are lua tables with all the same keys as the parameter, and values either copied or converted
-- TODO find a way to automatically produce accurate types for the returns with converted values
---@param v FIntVector userdata
---@return FIntVector v table
local function TableFromFIntVector(v)
@sparr
sparr / utf16-pack.ts
Created December 9, 2025 16:46
utf16-pack serializes javascript values to binary data packed into a utf-16 string. only partially implemented, focusing on performance problems before finishing implementation
// MessagePack-like encoding targeting UTF-16 storage instead of byte arrays.
// Encoding of each value involves one UTF-16 character for the value or a header,
// possibly some additional characters for further fixed size value or length information,
// then possibly some additional characters or encoded values
// 15-bit signed integer 0b0xxxxxxxxxxxxxxx
// types with 32-bit value, first 2 bits -------------vv followed by two characters containing 15 bits of value each
const INT_32_MASK = 0b1000000000000100; // 0b0xxxxxxxxxxxxxxx 0b0xxxxxxxxxxxxxxx
@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 <sparr0@gmail.com>
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