Skip to content

Instantly share code, notes, and snippets.

View MaddyGuthridge's full-sized avatar
🏳️‍⚧️
Trans rights

Maddy Guthridge MaddyGuthridge

🏳️‍⚧️
Trans rights
View GitHub Profile
@MaddyGuthridge
MaddyGuthridge / arrow_int.py
Created May 11, 2025 14:50
Arrow operator in Python
import ctypes
class ArrowInt(int):
def __neg__(self) -> int:
prev = int(self)
self_addr = id(self)
int_addr = self_addr + ctypes.sizeof(ctypes.c_size_t) + 2 * ctypes.sizeof(ctypes.c_void_p)
ctypes.c_int.from_address(int_addr).value = self - 1
# Return previous value so it loops a sensible number of times
return prev
@MaddyGuthridge
MaddyGuthridge / scope.py
Created May 7, 2025 13:37
Python scope captures are neat
"""
A quick demo of how scope capturing works in Python.
This code works because inner functions capture a reference
to the original function's scope when they get defined,
rather than a shallow copy of it.
It's so janky and weird, and yet it makes perfect sense.
It's almost poetic. I love Python so much.
"""
@MaddyGuthridge
MaddyGuthridge / keybindings.json
Created May 19, 2024 13:18
My VS Code keybindings
// Place your key bindings in this file to override the defaults
[
// New file commands
// =============================================
// New file command in explorer by default
{
"key": "ctrl+n",
"command": "explorer.newFile"
},
// New directory in explorer: Ctrl+Shift+N
@MaddyGuthridge
MaddyGuthridge / comp1010-requirements.txt
Last active September 10, 2024 06:51
COMP1010 Python dependencies
appnope==0.1.4 ; python_version >= "3.9" and python_version < "4.0" and platform_system == "Darwin" \
--hash=sha256:1de3860566df9caf38f01f86f65e0e13e379af54f9e4bee1e66b48f2efffd1ee \
--hash=sha256:502575ee11cd7a28c0205f379b525beefebab9d161b7c964670864014ed7213c
asttokens==2.4.1 ; python_version >= "3.9" and python_version < "4.0" \
--hash=sha256:051ed49c3dcae8913ea7cd08e46a606dba30b79993209636c4875bc1d637bc24 \
--hash=sha256:b03869718ba9a6eb027e134bfdf69f38a236d681c83c160d510768af11254ba0
blinker==1.8.1 ; python_version >= "3.9" and python_version < "4.0" \
--hash=sha256:5f1cdeff423b77c31b89de0565cd03e5275a03028f44b2b15f912632a58cced6 \
--hash=sha256:da44ec748222dcd0105ef975eed946da197d5bdf8bafb6aa92f5bc89da63fa25
certifi==2024.2.2 ; python_version >= "3.9" and python_version < "4.0" \
@MaddyGuthridge
MaddyGuthridge / todo-tree-settings.json
Created May 29, 2023 13:11
My custom Todo Tree extension settings
{
"todo-tree.highlights.defaultHighlight": {
"foreground": "white",
"background": "#00000000"
},
"todo-tree.highlights.useColourScheme": false,
"todo-tree.general.tags": [
"BUG",
"FIXME",
"BROKEN",
const { execSync } = require('node:child_process');
const MAX_LENGTH = 100;
// https://stackoverflow.com/a/44574128/6335363
const ALLOWED_CHARACTERS = [...Array(26).keys()].map((n) => String.fromCharCode(97 + n));
ALLOWED_CHARACTERS.push('-');
function installPackage(name) {
execSync(`npm install ${name}`, { stdio: 'inherit' });
"""
A simple script to install everything
"""
from subprocess import Popen
from string import ascii_lowercase
MAX_LENGTH = 100
ALLOWED_CHARACTERS = ascii_lowercase + '-'
@MaddyGuthridge
MaddyGuthridge / 1531-setup.md
Last active April 24, 2023 13:32
Getting set up for COMP1531

Getting set up for COMP1531

Here are the steps you should follow to get started working on your own computer in COMP1531.

On all platforms

  1. Install VS Code

On Windows

@MaddyGuthridge
MaddyGuthridge / gitignore.sh
Last active March 27, 2023 13:32
Gitignore grabber
# Simple function to grab a .gitignore file from GitHub
# Usage: gitignore [language name]
# Note that it's case-sensitive. This it GitHub's fault, not mine
gitignore ()
{
curl -s --fail "https://raw.githubusercontent.com/github/gitignore/main/$1.gitignore" -o .gitignore
if [ $? -eq 0 ]; then
return 0
else
echo "Lookup failed, maybe check capitalisation?"
@MaddyGuthridge
MaddyGuthridge / unsw_shell_aliases.sh
Created February 18, 2023 07:26
Helpful aliases and functions for working locally at UNSW CSE
# Copy this into your .bashrc or .zshrc
# To make this even nicer, use `ssh-copy-id` so you don't need to use your password for everything
# UNSW zID
export ZID="z5312085"
# Environment variables pointing to CSE Servers
export CSE="${ZID}@login.cse.unsw.edu.au"
# Quick alias for SSH-ing into CSE