Skip to content

Instantly share code, notes, and snippets.

View thegamecracks's full-sized avatar

thegamecracks thegamecracks

View GitHub Profile
@thegamecracks
thegamecracks / event_thread.py
Last active June 8, 2026 15:37
Submitting coroutines to an asyncio worker thread
import asyncio
import threading
from concurrent.futures import Future, as_completed
from typing import Any, Coroutine, Self
class EventThread:
def __init__(self) -> None:
self.loop_fut = Future[asyncio.AbstractEventLoop]()
self.stop_fut = Future[None]()
@thegamecracks
thegamecracks / steamid_to_beguid.py
Created February 12, 2026 02:29
Simple conversion of steam IDs to BattlEye GUIDs
# Translated from: https://armstalker.com/guid/
import hashlib
def steam_id_to_be_guid(steam_id: int) -> str:
data = bytearray(b"BE")
for _ in range(8):
steam_id, mod = divmod(steam_id, 256)
data.append(mod)
return hashlib.md5(data).hexdigest()
@thegamecracks
thegamecracks / ziplab.py
Created January 15, 2026 14:07
Create a .zip archive of a .NET solution directory with build artifacts omitted
"""Create a .zip archive of a .NET solution directory with build artifacts omitted.
If the solution directory is tracked in a Git repository that has a .gitignore to
exclude .NET build artifacts, consider `git archive <branch> -o <filename>` instead.
"""
import argparse
import fnmatch
import hashlib
@thegamecracks
thegamecracks / newsln.py
Created January 15, 2026 13:58
Generate a .NET solution with one or more projects, in case I forget how to use dotnet
"""Generate a .NET solution with one or more projects."""
import argparse
import subprocess
import sys
from dataclasses import dataclass
from pathlib import Path
from typing import Self
@thegamecracks
thegamecracks / video_bitrate.pyw
Created January 15, 2026 13:52
Calculate video bitrate to achieve a given filesize and duration
"""Calculate the video bitrate for video compression software
to achieve a given filesize and duration.
Intended for use with HandBrake: https://handbrake.fr/
Result bitrate should be copied to your constant/average bitrate.
Note that input filesize is in megabytes, not mebibytes.
"""
import re
@thegamecracks
thegamecracks / sum_modpack.py
Last active March 13, 2026 19:05
Produce filesize statistics from a list of workshop mods
#!/usr/bin/python3
"""Produce filesize statistics from a list of workshop mods."""
# /// script
# dependencies = []
# requires-python = ">=3.11"
# ///
from __future__ import annotations
@thegamecracks
thegamecracks / tgm.py
Last active February 25, 2026 11:23
A zero-dependency, single-file workshop mod manager CLI for Arma 3
#!/usr/bin/python3
"""Manage workshop mods for an Arma 3 server.
See ${prog} help for more information.
"""
# /// script
# dependencies = []
# requires-python = ">=3.11"
@thegamecracks
thegamecracks / backup_world.py
Last active July 31, 2025 20:52
Yet another script to backup Minecraft worlds
#!/usr/bin/python3
"""Backup a Minecraft world into an archive.
CAUTION: This script has not been thoroughly tested and you may encounter bugs.
By default, this script will perform the following tasks:
1. Download mcrcon from https://github.com/Tiiffi/mcrcon, if needed
2. Send an RCON command to disable automatic saving and save the world
3. Create an archive of the world/ directory named "world-%Y-%m-%d.zip"
4. Send an RCON command to re-enable automatic saving
@thegamecracks
thegamecracks / notch.sqf
Last active May 19, 2025 01:45
A proof-of-concept approximation of missile notching in Arma 3
TGC_fnc_getAbsClosureSpeed = {
params ["_observer", "_target"];
private _dir = getPosATL _target vectorFromTo getPosATL _observer;
private _velocity = velocity _target;
private _angle = vectorNormalized _velocity vectorDotProduct _dir;
vectorMagnitude (_velocity vectorMultiply _angle)
};
TGC_fnc_isRadarGuided = {
params ["_ammo"];
private _property = configFile >> "CfgAmmo" >> _ammo >> "weaponLockSystem";
@thegamecracks
thegamecracks / resolve_case.py
Last active February 8, 2025 03:58
Structuring multiple prompts with discord.py message components
import datetime
import discord
from discord import app_commands
from discord.ext import commands
bot = commands.Bot(".", intents=discord.Intents.default())
@bot.command()
@commands.is_owner()