Skip to content

Instantly share code, notes, and snippets.

View WilkinsonK's full-sized avatar
🔊

Keenan Wilkinson WilkinsonK

🔊
View GitHub Profile
@WilkinsonK
WilkinsonK / digit_reverse.py
Last active July 2, 2024 22:51
digit_reverse.py
"""
Produces a working example of an interview question
that I failed spectacularly. After some stewing,
contemplation, and self-loathing, I was able to
write this. Mostly in hopes that I will never have to
think about this arbitrary POC ever again.
"""
import math
@WilkinsonK
WilkinsonK / xnat_client.py
Last active March 6, 2024 14:14
A bare-bones implementation of `httpx` that is capable of interacting with a remote XNAT instance at project->scan metadata level.
import dataclasses, functools, io, netrc, pathlib, sys, urllib, urllib.parse
import codecs, queue, shelve, threading, time, typing
import lxml.etree
from httpx import BasicAuth, Client, Request, Response, Timeout
type Element = lxml.etree._Element #type: ignore[valid-type]
type GetterQueue = queue.Queue[str] #type: ignore[valid-type]
type UpdateQueue = queue.Queue[tuple[str, io.BytesIO]] #type: ignore[valid-type]
type WrappedFunc[**P, T] = typing.Callable[P, T] #type: ignore[name-defined,valid-type]
@WilkinsonK
WilkinsonK / httpx_client_constructor.py
Last active February 22, 2024 17:38
implementation of httpx client with auto-configured auth construction.
import netrc, typing, urllib, urllib.parse
# Requires httpx dependency.
import httpx
@contextlib.contextmanager
def client(hostname: str, **kwds) -> typing.Generator[httpx.Client, None, None]:
"""Enter context with an HTTP client."""
kwds.setdefault("username")
@WilkinsonK
WilkinsonK / urilib.py
Created November 14, 2023 18:43
urilib.py
"""
urilib.py
---
Author: Keenan W. Wilkinson
Date: 14 Nov 2023
---
Defines URI resource paths for RESTful Web APIs in
a pythonic way.
"""
@WilkinsonK
WilkinsonK / init_logger.py
Last active October 3, 2023 16:46
Python3 Init Logger Boilerplate
#!/usr/bin/python3
"""
This `gist` is some standard boilerplate I used to initialize
a logger. While actual usage may vary, this is-- more or less
-- the most common way I like to utilize this module.
"""
import logging
logger = logging.getLogger(__file__)
@WilkinsonK
WilkinsonK / miner.py
Last active August 18, 2023 20:26
Manage and maintain Minecraft JE (PaperMC) services.
#!/opt/minecraft/.venv/bin/python3
"""
miner.py
-------------------
Keenan W. Wilkinson
16 Aug 2023
-------------------
Basic CLI for maintaining server services.
"""
@WilkinsonK
WilkinsonK / authorized_keysgen.py
Created August 16, 2023 19:03
Make authorized_keys file from *.pub files in target directory.
#!/bin/python3
"""
authorized_keys.py
-------------------
Keenan W. Wilkinson
15 Aug 2023
-------------------
Generates authorized_keys file from public key files found under ~/.ssh/keys/.
"""