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 / schneier-dark-mode.txt
Created April 15, 2026 11:58
Schneier.com Dark Mode – uBlock Origin Filters
www.schneier.com##body:style(background-color: #1a1a1a !important; color: #d4d4d4 !important)
www.schneier.com##a:style(color: #6cb4ee !important)
www.schneier.com##a:visited:style(color: #b893d6 !important)
www.schneier.com###content, .post, .entry, .comment, .sidebar, #sidebar, #wrapper, #container, .article, #main, .blog-post, div, article, section, header, footer, nav, aside:style(background-color: #1a1a1a !important; color: #d4d4d4 !important)
www.schneier.com##h1, h2, h3, h4, h5, h6:style(color: #e8e8e8 !important)
www.schneier.com##pre, code, blockquote:style(background-color: #2a2a2a !important; color: #d4d4d4 !important; border-color: #444 !important)
www.schneier.com##input, textarea, select:style(background-color: #2a2a2a !important; color: #d4d4d4 !important; border-color: #555 !important)
www.schneier.com##img:style(opacity: 0.9 !important)
www.schneier.com##*:style(border-color: #333 !important)
www.schneier.com##table, th, td:style(background-color: #1e1e1e !important; color: #d4d4d4 !important
@andyg2
andyg2 / mosquitto-gen-pass.php
Created April 11, 2026 14:42
Generate a mosquitto passwd file with iter=101, 12-byte salt (matching mosquitto_passwd 2.0.x)
<?php
// Generate a passwd file with iter=101, 12-byte salt (matching mosquitto_passwd 2.0.x)
$user = getenv('MQTT_USER');
$pass = getenv('MQTT_PASSWORD');
$iter = 101;
$salt = random_bytes(12);
$hash = hash_pbkdf2('sha512', $pass, $salt, $iter, 64, true);
$line = $user . ':$7$' . $iter . '$' . base64_encode($salt) . '$' . base64_encode($hash);
echo $line . PHP_EOL;
file_put_contents('/mosquitto-data/passwd', $line . PHP_EOL);
@andyg2
andyg2 / creative-planner.html
Last active January 26, 2026 06:51
Lightweight, single-file Kanban board for tracking handmade projects. Features drag-and-drop progress, priority levels, and metadata for materials and deadlines. Built with Tailwind CSS and SortableJS; persists data to LocalStorage.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Project Studio Tracker</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/lucide@latest"></script>
<script src="https://cdn.jsdelivr.net/npm/sortablejs@1.15.0/Sortable.min.js"></script>
@andyg2
andyg2 / dgte-wc-random-category-image.php
Created January 26, 2026 04:01
Woocommerce: Shows a random product image for product categories without a category image (frontend only).
<?php
/**
* Plugin Name: DGTE WC Category Image Fallback
* Description: Shows a random product image for product categories without a category image (frontend only).
* Version: 1.0
* Author: Andy Gee
* Author URI: https://github.com/andyg2
*/
@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.