Skip to content

Instantly share code, notes, and snippets.

Avatar

Leland Batey lelandbatey

View GitHub Profile
@lelandbatey
lelandbatey / timespans.py
Created Apr 27, 2022
Code for visualizing overlapping named spans of time
View timespans.py
'''
Timespan is code for visualizing timelines of events. We can show spans of time
on a timeline, as well as individual events.
The following is example code and what it prints:
>>> example_timespans = [
... TimeSpan(1647922287310, 1647922287564, 'A short thing happened'),
... TimeSpan(1648123040908, 1648123109165, 'a span of time where things happening'),
... ]
@lelandbatey
lelandbatey / stardew_animation_cancel.ahk
Created Dec 21, 2021
An autohotkey script for animation-canceling while playing Stardew valley.
View stardew_animation_cancel.ahk
; Stardew Valley animation cancel script
; Original from this post:
; https://forums.stardewvalley.net/threads/a-better-animation-canceling-autohotkey-script.7391/
; 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
lelandbatey / completed.csv
Last active Dec 14, 2021
Playlist called slow-dance by Ana Sofia
View completed.csv
Song Title Artist
I Don't Wanna See You with Her Maria Mena
Don't Forget About Me CLOVES
You & Me (feat. G-Eazy) Marc E. Bassy
Miss You James Hersey
Let It Go James Bay
How to Save a Life The Fray
Remedy Adele
When We Were Young Adele
Million Reasons Lady Gaga
@lelandbatey
lelandbatey / cookie_clicker_stock_market_info.js
Last active Nov 27, 2021
Cookie Clicker stock market info; copy paste script into console
View cookie_clicker_stock_market_info.js
@lelandbatey
lelandbatey / cookie_clicker_stock_market_info.js
Created Nov 27, 2021
Cookie Clicker stock market info; copy paste script into console
View cookie_clicker_stock_market_info.js
@lelandbatey
lelandbatey / 2021-11-10-how-I-ended-liking-gnome.md
Last active Nov 15, 2021
I ended liking GNOME with the loss of one hand (mirror)
View 2021-11-10-how-I-ended-liking-gnome.md
@lelandbatey
lelandbatey / parse_athena_format.py
Created Nov 8, 2021
Parse Athena-formatted data into JSON
View parse_athena_format.py
#!/usr/bin/env python3
# A script which will parse athena-formatted lines to be json. Assumes all
# fields and values are strings.
import json
import sys
import re
def parseathena(line):
@lelandbatey
lelandbatey / python_packaging_vs_golang_packaging_2021.md
Last active Sep 16, 2021
Python Packaging vs Golang Packaging: Breaking down the differences in terminology and what it means for you
View python_packaging_vs_golang_packaging_2021.md

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
lelandbatey / generate_sphinx_pkgs.py
Last active Oct 15, 2021
Generate sphinx docs for an entire module, recursively
View generate_sphinx_pkgs.py
'''
CLI tool for generating sphinx auto-doc compatible files for all the python
modules in a directory. I'm using this to generate raw Sphinx docs for a big
disorganized, undocumented Python repo.
'''
# From here: https://stackoverflow.com/a/54323162
import sys
from setuptools import find_packages
from pkgutil import iter_modules
@lelandbatey
lelandbatey / list_all_contributors.sh
Created Jul 13, 2021
Record all contributors to each Git repository in a file tree
View list_all_contributors.sh
#!/bin/bash
# list_all_contributors.sh ROOT_SEARCH_PATH
#
# Usage: Finds all Git repositories in ROOT_SEARCH_PATH and records all
# contributors to each repo, each repo getting one file, with these
# contributor files saved to the current directory.
# Copyright (C) 2021 Leland Batey
#