Skip to content

Instantly share code, notes, and snippets.

View lelandbatey's full-sized avatar

Leland Batey lelandbatey

View GitHub Profile
lelandbatey /
Last active June 16, 2024 13:44
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!


This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"


lelandbatey / stardew_animation_cancel.ahk
Created December 21, 2021 19:34
An autohotkey script for animation-canceling while playing Stardew valley.
; Stardew Valley animation cancel script
; Original from this post:
; This version has been modified to be slightly more explicit about things like
; making sure that the Keyboard Hooks are in use.
; WARNING: make sure that the "Check/Do Action" control within the options of
; Stardew Valley is bound to a *DIFFERENT* key than the key that this script uses
; to trigger the animation canceling. If you have this script bound to the same
; key as the "Check/Do Action" key in-game, you'll face issues where holding down
lelandbatey /
Last active January 20, 2024 11:27
Python Packaging vs Golang Packaging: Breaking down the differences in terminology and what it means for you

Python Packaging vs Golang Packaging

The original question was:

But I'm not sure that the library name = "cp-compat-logs-logger" defined in pyproject.toml would work. I tried importing that in my httpclient library and it complained. Also, I see in the log_bridge library the logger is imported as from cp_compat_logs_logger.logger import Logger, but cp_compat_logs_logger is not the library name, so how is that working?

I think you've asked a totally valid question about "what's up with the names here?" The short answer is "Python has messy conventions, so the name you use to poetry install is different than the name you use in code when import name." It's conventional to have the poetry install (let's call this the "distribution name") use dashes as a delimiter. However, actual module names in Python cannot have dashes, so the name used in code during import name (let's call this the "module name") will (usually) use underscores in place of dashes.

lelandbatey / circleci-retry-failing-workflow.bash
Created November 15, 2023 01:10
Re-run your latest failing CircleCI workflow for a given Github project till it succeeds
# A script to re-run your latest failing workflow for a given Github project
# Examples:
# circleci-retry-failing-workflow.bash orgservice
# circleci-retry-failing-workflow.bash lichee
if [ $# -eq 0 ]; then
lelandbatey / assign_struct_field_by_tag_name.go
Last active November 8, 2023 15:20
Golang reflection; assign to struct field by tag name
package main
import (
// The goal: allow assignment to a go struct field based on the name that field
// is tagged with (specifically it's json-tagged name).
lelandbatey /
Last active October 21, 2023 16:31
YouTube 1080p Download Script

YouTube 1080p Downloader

The Problem

It used to be you could directly download any YouTube video in any quality you wanted, as a single .mp4 file. However, around a year ago, YouTube switched from the "single file stream", to "DASH" streaming, which streams the video and the audio to you as two separate streams, which are played in sync with each other in the YouTube player.

It's still possible to download YouTube videos as a single file, but YouTube only offers that for qualities up to 720p. So you can't download "single file stream" videos in 1080p or higher.

lelandbatey / tf2_Item_names_with_ids.json
Created May 19, 2013 23:21
Json dictionary of all tradable items in tf2, with the ids as the keys, and the names as the values.
"100": "Glengarry Bonnet",
"1000": "Festive Axtinguisher",
"1001": "Festive Buff Banner",
"1002": "Festive Sandvich",
"1003": "Festive Ubersaw",
"1004": "Festive Frontier Justice",
"1005": "Festive Huntsman",
"1006": "Festive Ambassador",
"1007": "Festive Grenade Launcher",
lelandbatey / goodluck.js
Created August 12, 2023 21:11
GOOD LUCK challenge
// A fun challenge; make it print your name, instead of mine : )
((G, O)=>O((D, __, LUCK)=>()=>{
console.log("from your friend: "+D(__)(LUCK));
})())("HAVE FUN",
(w) => {return w(
((window) => ((_)=>_(_))( (($)=>window( ((console)=>$($)(console)))))),
((N) => ((L)=> 6 ^ (~~L) ? String.fromCharCode(95-(31 & 924798803 >> 5 * L))+N((~~L)+1) : "\n")),
lelandbatey /
Last active May 11, 2023 16:51
Pretty print large base 10 numbers and base 2 numbers
# Take a very large number and pretty print it in triplets of 3 digits, each triplet separated by a space.
def pnum_spc(n): print(' '.join([''.join(list(str(n))[::-1][i:i+3][::-1]) for i in range(0, len(str(n)), 3)][::-1]))
# >>> pnum_spc(32 ** 13)
# 36 893 488 147 419 103 232
# Print numbers as 32-bit binary numbers w/ spaces giving 4-bit words
def pbin_spc(n): print(' '.join([''.join(list(f'{n:032b}')[::-1][i:i+4][::-1]) for i in range(0, len(f'{n:032b}'), 4)][::-1]))
# >>> "{0:032b}".format(1234)
# '00000000000000000000010011010010'
# >>> pbin_spc(1234)
lelandbatey /
Last active December 31, 2022 01:29
Proto-minesweeper probability -- a kludged together POC for statistics of mines in squares
A toy example to calculate the probability of a mine existing on any particular square.
Runs slowly and is organized like spaghetti, but it does currently work!
Note that for this to work, it depends on a slightly modified defusedivision;
inside defuse_division the _create_foothold function in has to be
modified to be public, instead of private like in the public version.