Skip to content

Instantly share code, notes, and snippets.

View TheCrazyGM's full-sized avatar

Michael Garcia TheCrazyGM

View GitHub Profile
@TheCrazyGM
TheCrazyGM / snoop.py
Created May 6, 2026 13:56
Hive Exchange Snooper Script
#!/usr/bin/env -S uv run --quiet --script
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "hive-nectar",
# "rich",
# ]
#
# ///
@TheCrazyGM
TheCrazyGM / he_sync.sh
Created January 15, 2026 11:41
Hive Engine Sync Checker
#!/bin/bash
# Hive Engine Sync Checker
# Checks correct sync status using lastParsedHiveBlockNumber vs Hive Head Block
# Configuration
# Can be overridden by environment variables: HE_NODE, HIVE_NODE, WARN_THRESHOLD, ERROR_THRESHOLD
HE_NODE="${HE_NODE:-https://engine.thecrazygm.com}"
HIVE_NODE="${HIVE_NODE:-https://api.hive.blog}"
@TheCrazyGM
TheCrazyGM / track_restore.sh
Created January 2, 2026 13:21
Use `lsof` to monitory where the mongorestore / pigz is in the file buffer to get an idea of progress.
#!/bin/bash
# Configuration
INTERVAL=5
# AUTO-DETECT: Check for pigz first (fast mode), then mongorestore (slow mode)
PID=$(pgrep -x "pigz" | head -n 1)
PROC_NAME="pigz"
if [ -z "$PID" ]; then
@TheCrazyGM
TheCrazyGM / moon_phase.py
Last active October 15, 2025 14:19
Print the phase of the moon as an emoji.
#!/usr/bin/env python3
from datetime import date, datetime, timezone
SYNODIC_MONTH = 29.530588853 # days
REF_JD = 2460969.8506944445 # Julian Day number at new moon (2025-10-21 08:25 UTC)
def _julian_day(dt_utc: datetime) -> float:
"""Convert a UTC datetime to Julian Day."""
y, m = dt_utc.year, dt_utc.month
@TheCrazyGM
TheCrazyGM / playfair.py
Last active October 1, 2025 12:06
Wheatstone/Playfair digram substitution cipher
#!/usr/bin/env python3
import argparse
def generate_key_square(key):
"""Generates a 5x5 Playfair key square."""
key = key.upper().replace("J", "I")
alphabet = "ABCDEFGHIKLMNOPQRSTUVWXYZ"
square = []
@TheCrazyGM
TheCrazyGM / beaufort.py
Created September 30, 2025 16:17
Beaufort variation of Vigenere Cipher
#!/usr/bin/env python3
import argparse
def beaufort_cipher(text, key):
"""
Applies the Beaufort cipher to a given text using a given key.
The Beaufort cipher is reciprocal, so the same process handles
encryption and decryption.
@TheCrazyGM
TheCrazyGM / vigenere.py
Created September 30, 2025 16:16
Classic Vigenere Cipher
#!/usr/bin/env python3
import argparse
def vigenere_cipher(text, key, decrypt=False):
"""
Encrypts or decrypts a given text using the Vigenere cipher with a given key.
Handles both uppercase and lowercase letters, preserving case.
Non-letter characters are left unchanged.
:param text: The text to be encrypted or decrypted.
@TheCrazyGM
TheCrazyGM / rot13.py
Created September 30, 2025 16:16
ROT13 version of Caesar Cipher
#!/usr/bin/env python3
import argparse
def rot13_cipher(text):
"""
Applies the ROT13 cipher to a given text.
ROT13 is a Caesar cipher with a fixed shift of 13.
It is reciprocal: applying it again decrypts the text.
Handles both uppercase and lowercase letters, preserving case.
@TheCrazyGM
TheCrazyGM / caesar.py
Created September 30, 2025 16:15
Classic Caesar Cipher
#!/usr/bin/env python3
import argparse
def caesar_cipher(text, shift, decrypt=False):
"""
Applies the Caesar cipher to a given text with a given shift.
Handles both uppercase and lowercase letters, preserving case.
Non-letter characters are left unchanged.
:param text: The text to be processed.
@TheCrazyGM
TheCrazyGM / draw_cards.py
Created September 28, 2025 15:49
Hive Based RNG for Drawing from a Shuffled Deck of Cards
#!/usr/bin/env -S uv run --quiet --script
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "hive-nectar",
# "rich",
# ]
#
# ///
"""