Skip to content

Instantly share code, notes, and snippets.

View rossmacarthur's full-sized avatar
🦀

Ross MacArthur rossmacarthur

🦀
  • Cape Town, South Africa, Earth, Milky Way
  • 17:10 (UTC +02:00)
View GitHub Profile
@rossmacarthur
rossmacarthur / action.yml
Last active November 12, 2025 07:19
setup-crate action
name: install crate binary
description: Install a Rust crate from a GitHub release asset
inputs:
repo:
description: The GitHub repository containing the crate (e.g., "casey/just")
required: true
tag-prefix:
description: The prefix to match the release tag (e.g., "name/" for tags like "name/v1.2.3")
@rossmacarthur
rossmacarthur / git-rebase-edit.py
Last active June 8, 2025 14:38
Rewrite Git history, preserving author, committer dates and GPG signature timestamps
#!/usr/bin/env python3
from dataclasses import dataclass
import os
from pathlib import Path
import re
import subprocess
import sys
from typing import Literal, Optional
@rossmacarthur
rossmacarthur / gh-label-copier.rs
Last active March 2, 2025 16:07
Copy GitHub labels from one GitHub repository to another, update existing label color and description, delete extra labels
#!/usr/bin/env rust-script
//! ```cargo
//! [dependencies]
//! anyhow = "1.0.96"
//! argh = "0.1.13"
//! casual = "0.2.0"
//! indexmap = "2.7.1"
//! serde = { version = "1.0.218", features = ["derive"] }
//! serde_json = "1.0.139"
//! ureq = { version = "3.0.8", features = ["json"] }
@rossmacarthur
rossmacarthur / usb_hid.h
Created July 7, 2020 16:49
Nintendo Pro Controller USB descriptor as C header
// Result of running https://gist.github.com/ToadKing/b883a8ccfa26adcc6ba9905e75aeb4f2
// through https://github.com/abend0c1/hidrdd
//
//--------------------------------------------------------------------------------
// Decoded Application Collection
//--------------------------------------------------------------------------------
/*
05 01 (GLOBAL) USAGE_PAGE 0x0001 Generic Desktop Page
15 00 (GLOBAL) LOGICAL_MINIMUM 0x00 (0) <-- Info: Consider replacing 15 00 with 14
@rossmacarthur
rossmacarthur / iter-window.py
Created November 29, 2018 12:35
A windowed iterator with a configurable window and step size in Python.
class Window:
def __init__(self, *args, window=2, step=1):
self.iterator = iter(*args)
self.window = window
self.step = step
self.buffer = ()
def __iter__(self):
return self
@rossmacarthur
rossmacarthur / docker-destroy-all.sh
Last active September 6, 2018 15:08 — forked from JeffBelback/docker-destroy-all.sh
Destroy all Docker Containers and Images
#!/usr/bin/env bash
containers=$(docker ps -a -q)
# Stop all containers
if [ ! -n "$containers" ]; then
docker stop $containers
docker rm $containers
fi
@rossmacarthur
rossmacarthur / nested.py
Created August 27, 2018 08:36
Pickle nested classes in Python
import inspect
import pickle
def allow_picklable_inner_classes(cls):
for name in dir(cls):
inner = getattr(cls, name)
if not name.startswith('_') and inspect.isclass(inner):
new_name = '{}.{}'.format(cls.__name__, inner.__name__)
@rossmacarthur
rossmacarthur / dictset.py
Created August 8, 2018 11:40
A Python dictionary type that allows set operations for nested dictionaries.
class DictSet(dict):
"""
A dictionary type that allows set operations for nested dictionaries.
"""
def __or__(self, other):
return self.union(other)
def __and__(self, other):
return self.intersection(other)