Skip to content

Instantly share code, notes, and snippets.

View Multihuntr's full-sized avatar

Brandon Victor Multihuntr

  • La Trobe University
View GitHub Profile
@Multihuntr
Multihuntr / partitioned.py
Created February 4, 2021 02:47
Sqlalchemy create partitioned tables in a for loop in Postgresql database
# BIG NOTE:
# I made this becuase I thought the method was interesting. It's not useful in it's current form.
# If you can, use an index instead. https://stackoverflow.com/a/27895337
from sqlalchemy import Column, Integer, Float, ForeignKey, event, DDL
from sqlalchemy.schema import CreateSchema
from sqlalchemy.dialects.postgresql import DOUBLE_PRECISION
from sqlalchemy.ext.declarative import declarative_base, declared_attr
Base = declarative_base()
@Multihuntr
Multihuntr / mean_avg_precision.py
Created July 28, 2021 11:36
Mean average precision for object detection
# Reimplementation of: https://github.com/aladdinpersson/Machine-Learning-Collection/blob/master/ML/Pytorch/object_detection/metrics/mean_avg_precision.py
# Now with more vectorisation!
def precision_recall_curve_th(is_tp, confs, n_true, eps=1e-8):
# Sort by confs
order = (-confs).argsort()
is_tp = is_tp[order]
confs = confs[order]
# Cumulative sum true positives and number of predictions
@Multihuntr
Multihuntr / mat3.py
Last active January 7, 2022 01:31
Random Affine Crop in the style of Albumentations for a Rasterio Dataset with minimal dependencies
# Utility functions for managing 3x3 matrices for cv2.warpAffine in pure numpy
import numpy as np
def identity():
return np.eye(3, dtype=np.float64)
def affine(A=None, t=None):
@Multihuntr
Multihuntr / environment.yml
Created June 20, 2024 09:38
Run Stable Diffusion 3 from commandline with limited resources.
name: sb3
channels:
- pytorch
- nvidia
- conda-forge
dependencies:
- diffusers
- transformers
- pytorch
- torchvision
@Multihuntr
Multihuntr / Macro-clipboard.md
Last active July 4, 2025 09:13
Macro recording/playback in OS (across all applications)

What is it?

It's for repetitive tasks that are too small to be bothered writing a macro script into something like AutoHotKey, but annoying and repetitive enough that you want some automation.

It allows you to record some keypresses, and then replay those keypresses, using keyboard shortcuts. It's like the clipboard, but for keypresses instead of text. Recordings do not persist across restarts/logins, and are overwritten when you record a new macro. (Does not actually interact with the clipboard at all)

Setup

  1. Add keyboard shortcuts to trigger the record.py and replay.py scripts. They work globally on the OS. I use ctrl+super+e for record and super+e for replay.
  2. Install keyboard python library.