Skip to content

Instantly share code, notes, and snippets.

View andyg2's full-sized avatar
🎯
Focusing

Andy Gee andyg2

🎯
Focusing
View GitHub Profile
@andyg2
andyg2 / heathchecks-notifier.ps1
Created January 8, 2026 06:09
Healthchecks.io Windows Tray Monitor (PowerShell) A lightweight PowerShell script that monitors a Healthchecks.io badge SVG and displays the aggregated status (up, late, down) in the Windows system tray, with notifications on state changes.
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
# 3 state badge
$badgeUrl = "https://healthchecks.io/badge/37a5b3b3-74a5-43ec-9b65-c1b1b7/2lErRuPC.svg"
$pollSeconds = 10 # Check every 10 seconds
$gracePeriodSeconds = 30 # Must be in a bad state for 30 seconds before notifying (should be >2x multiplier of $pollSeconds)
$notify = New-Object System.Windows.Forms.NotifyIcon
$notify.Icon = [System.Drawing.SystemIcons]::Information
@andyg2
andyg2 / squimage.sh
Last active January 3, 2026 17:52
A Bash script to resize and optimize images in a directory (optionally recursively), supporting PNG, JPEG/JPG, and WebP formats.
#!/bin/bash
# PREFLIGHT
# sudo apt update && sudo apt install -y imagemagick optipng jpegoptim webp tar findutils
set -euo pipefail
# ----------------------------
# Defaults
# ----------------------------
@andyg2
andyg2 / convert_mbox.py
Last active October 29, 2025 07:45
Converts a .mbox to separate .eml files and attempts to create a useful folder structure based on labels.
import mailbox
import os
import argparse
import re
from email.utils import parsedate_to_datetime
from email.header import decode_header
def decode_subject(message):
"""
Decodes the email subject into a clean string, handling multi-line and
@andyg2
andyg2 / DockerBootStart.ps1
Last active July 22, 2025 02:55
Tested on Windows Server 2025 Datacenter Azure edition in Azure.
# Define the task details
$taskName = "StartDockerDesktopAtBoot"
$taskDescription = "Starts Docker Desktop automatically after boot (with 2-minute delay), regardless of user login."
$wrapperScriptPath = [Environment]::GetFolderPath("Desktop") + "\DockerStartWrapper.ps1" # Wrapper script on current user's desktop for delay
try {
# Get current user's full username for the principal
$userId = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name
# Check if the task already exists and remove it to avoid conflicts
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<URI>\{{taskName}}</URI>
</RegistrationInfo>
<Triggers>
<LogonTrigger>
<Enabled>true</Enabled>
</LogonTrigger>
</Triggers>
@andyg2
andyg2 / readme.md
Last active July 9, 2024 06:43
Basic cron parsing in sql

It should parse these ok but nothing more complex

* * * * * - Every minute.

0 0 * * * - At midnight every day.

30 14 * * 5 - At 14:30 (2:30 PM) on every Friday.

0 22 * * 1-5 - At 22:00 (10 PM) from Monday to Friday.

@andyg2
andyg2 / worktracker.py
Created May 29, 2024 10:12
Simple windows activity logger - logs keystroke count, mouse pixels and windows size/position per windows title, outputting to a yyyy-mm-dd csv file every 10 seconds.
import win32gui
import win32con
import win32process
import time
import csv
from datetime import datetime
from pynput import keyboard, mouse
from collections import defaultdict
# Dictionary to store keystrokes and mouse movement per window title

Keybase proof

I hereby claim:

  • I am andyg2 on github.
  • I am 74gee (https://keybase.io/74gee) on keybase.
  • I have a public key ASATrKdGwD2MAR_RimQK5KPdoheN7XGtC11rnvm02qR9rAo

To claim this, I am signing this object:

@andyg2
andyg2 / wrap.bat
Created December 16, 2023 17:35
One liner to wrap all mp4 files in a folder of the same name
for %F in (*.mp4) do @(md "%~nF" 2>nul && move "%F" "%~nF\")
@andyg2
andyg2 / wc-category-image-fallback.php
Created November 23, 2023 23:05
Override the WooCommerce subcategory thumbnail to fallback to a product image or the standard fallback image
<?php
/*
Plugin Name: WC Category Image Fallback
Description: WooCommerce Product Image Fallback for Categories.
Version: 1.0
Author: Andy Gee
*/