Skip to content

Instantly share code, notes, and snippets.

View jkerhin's full-sized avatar

Joe Kerhin jkerhin

  • 08:05 (UTC -04:00)
View GitHub Profile
@jkerhin
jkerhin / downloader.py
Created April 20, 2025 18:06
Example Downloader
import time
import logging
from datetime import datetime, UTC
from pathlib import Path
import requests
from sqlalchemy import select
from sqlalchemy.orm import sessionmaker, Session
from my_models import Download, Status
@jkerhin
jkerhin / combine_and_rotate.py
Created February 4, 2025 01:14
Combine and rotate PDFs
"""Combine multiple PDFs into one, optionally rotating them
Requires "pypdf" library, tested with v5.2.0 at time of writing
MIT No Attribution
Copyright (c) 2025 Joe Kerhin
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so.
@jkerhin
jkerhin / spider.py
Created December 11, 2024 03:17
Walk through the filesystem, store in sqlite db
"""Walk through the filesystem, store in sqlite db
Utility script for walking a filesystem, and storing file information in a sqlite
database.
Goals/Design Notes:
- [x] Pure standard library
- [x] Name, Path as seprate columns
- [x] Store the datetime that a file pth was inserted
- [x] Implement fulltext search of both filenames and paths
@jkerhin
jkerhin / copy_lockscreens.py
Created October 6, 2024 16:37
Copy Windows 10 Locksceen photos to a local directory
#!/usr/bin/env python3
"""Copy Windows 10 lockscreens to a local directory
Uses heuristics to avoid copying other assets stored in the same directory. May be
imperfect, this has only been tested on two systems.
Big thanks to "CharlieRB" on SuperUser; without their answer I never would have figured
this out: https://superuser.com/a/1126475
"""
@jkerhin
jkerhin / convert_and_transcribe.py
Created March 4, 2024 02:31
Quick wrapper script around whisper.cpp
"""Quick wrapper around whisper.cpp to allow transcription of arbitrary media
Automatically create .wav file using FFMPEG, then transcribe it using the
(built seprately) whisper.cpp binary with most output formats.
"""
import sys
import subprocess
from pathlib import Path
WHISPER_DIR = Path("/home/joe/whisper.cpp")
@jkerhin
jkerhin / silence_tyler_speaker.py
Created October 9, 2023 00:12
Silence Chromecast Speaker
"""Simple script to silence Tyler's Chromecast
Documenting this for future me. This is the script I use to shut off Tyler's music
each weekday morning when it's time to get up and get ready. Rock simple script, single
line crontab.
Crontab:
45 6 * * 1-5 /home/joe/.local/share/virtualenvs/chromecast-uUcxDOyh/bin/python /home/joe/projects/chromecast/silence_tyler_speaker.py
Depends on the `pychromecast` library, see:
@jkerhin
jkerhin / rocketlab_mission_info.py
Last active September 25, 2024 03:01
Script for fetching mission data from all RocketLab missions
"""Simple script to grab all the RocketLab mission info
There is plenty of room for improvement, but this works.
Requirements defined below using inline script metadata (formerly PEP-723), and the file
can be run standalone with `pipx`, `uv run`, etc.
"""
# /// script
# requires-python = ">=3.9"
# dependencies = [