Skip to content

Instantly share code, notes, and snippets.

View k98kurz's full-sized avatar

Jon Tyler k98kurz

View GitHub Profile
@k98kurz
k98kurz / boilerplate.py
Last active October 26, 2025 00:48
Utility maximizer problem
"""The problem is to maximize utility/subjective value given a number of
participants and a quantity of things of different categories.
The original phrasing of the problem is as follows:
Math concept tangentially related to both social choice theory and logistics:
given N people and N unique things, and further given subjective value/utility
ratings from each person for each thing, devise an algorithm that distributes the
things to the people while maximizing total utility. And a related problem is
generalizing it to N people, K unique categories of things, and a function M
mapping category to integer count of the things of that category available.
@k98kurz
k98kurz / cidr_tool.py
Created July 30, 2025 15:13
CIDR tool: check if an IP address belongs to a CIDR block
license = '''Copyright (c) 2024 Jonathan Voss (k98kurz)
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
that the above copyleft notice and this permission notice appear in
all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
@k98kurz
k98kurz / ainput.py
Last active March 19, 2025 23:25
Asynchronous input prompt with previous line buffer cycling compatible with micropython through tty console
"""Copyright (c) 2025 Jonathan Voss (k98kurz)
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
that the above copyleft notice and this permission notice appear in
all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
@k98kurz
k98kurz / sha256_stream_cipher.py
Last active June 1, 2025 16:48
sha256_stream_cipher.py
"""Copyright (c) 2025 Jonathan Voss (k98kurz)
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
that the above copyleft notice and this permission notice appear in
all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
@k98kurz
k98kurz / numberytvideos.js
Last active September 30, 2023 11:48
userscript to number youtube videos
// ==UserScript==
// @name Number YouTube Videos
// @namespace https://github.com/k98kurz
// @version 0.2
// @description Number YouTube videos in chronological (reverse sequential) order. Should load all videos by scrolling down first.
// @author k98kurz
// @match https://www.youtube.com/@*/videos
// @match https://www.youtube.com/@*/streams
// @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @grant none
@k98kurz
k98kurz / ClearBeanstalkdQueueCommand.php
Last active October 28, 2015 20:31 — forked from lukaswhite/ClearBeanstalkdQueueCommand.php
Clear a Beanstalkd Queue in Laravel
<?php
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
class ClearBeanstalkdQueueCommand extends Command {
/**
* The console command name.
@k98kurz
k98kurz / AjaxRestfulResource.js
Last active November 11, 2015 15:04
Another layer of abstraction for ajax requests to restful api endpoints (unfinished)
// Copyleft Jon Tyler, 2015+
// MIT license
// requires jQuery
// requires an api endpoint; array of headers is optional
// probably pointless without modification/extension
function Resource(endpoint, options) {
var settings = {};
settings.endpoint = endpoint;
settings.headers = (typeof options == "object") ? options.headers || [] : [];
@k98kurz
k98kurz / youtubefix2
Last active August 29, 2015 14:04
This makes the list autoplay toggle actually work; i.e., it is now a global setting rather than per-page clickfest.
// ==UserScript==
// @name YouTube Autoplay Toggle
// @namespace https://gist.github.com/k98kurz
// @updateUrl https://gist.githubusercontent.com/k98kurz/76c08ff2dbe0a479c955/raw/
// @version 1.2
// @description This makes the list autoplay toggle actually work; i.e., it is now a global setting rather than per-page clickfest.
// @match https://www.youtube.com/watch?v=*&list=*
// @match http://www.youtube.com/watch?v=*&list=*
// @match https://www.youtube.com/watch?list=*&v=*
// @match http://www.youtube.com/watch?list=*&v=*
@k98kurz
k98kurz / youtubefix1
Last active August 29, 2015 14:04
This removes the "uploads" playlist from video links on channels
// ==UserScript==
// @name No More YouTube Uploads Playlist
// @namespace https://gist.github.com/k98kurz
// @updateUrl https://gist.githubusercontent.com/k98kurz/3ba6ac71a32bd36d21c3/raw/
// @version 2.1
// @description This removes the "uploads" playlist from video links on channels
// @match https://www.youtube.com/user/*/videos
// @match http://www.youtube.com/user/*/videos
// @match https://www.youtube.com/channel/*/videos
// @match http://www.youtube.com/channel/*/videos
@k98kurz
k98kurz / fixfacebook.tamperscript.js
Last active December 19, 2015 22:19
Basically, this takes the annoying graph search bar and fixes it: it takes up less space on the top of the screen, moves the notifications back to the left side of the page (where they belong), and nudges upward the drop-down thing on profile pages. Pretty self-explanatory.
// ==UserScript==
// @name Facebook fix
// @namespace https://gist.github.com/k98kurz
// @updateURL https://gist.githubusercontent.com/k98kurz/6026739/raw
// @version 1.2.1
// @description blah
// @match https://*.facebook.com/*
// @copyright 2014+, k98kurz
// ==/UserScript==