Skip to content

Instantly share code, notes, and snippets.

View blizzardengle's full-sized avatar

Christopher Keers blizzardengle

View GitHub Profile
@blizzardengle
blizzardengle / nearest.js
Created November 17, 2025 18:12
Finds the nearest element matching the querySelector based on DOM traversal distance.
/**
* Finds the nearest element matching the querySelector based on DOM traversal distance.
* Can be added to Element.prototype for convenient use like Element.closest()
*
* @example
* // Standalone usage
* const result = nearest(element, '.target');
*
* @example
* // Add to prototype (optional)
@blizzardengle
blizzardengle / encrypt_zips.ps1
Created November 7, 2025 17:48
PowerShell script to batch password-protect solution ZIP files using weak but compatible encryption as a basic student deterrent.
# Password-protect all ZIP files in current directory
# Password format: BasePassword + first digit found in filename
$basePassword = "PLACEHOLDER"
$sevenZipPath = "C:\Program Files\7-Zip\7z.exe"
# Verify 7-Zip is installed
if (-not (Test-Path $sevenZipPath)) {
Write-Host "ERROR: 7-Zip not found at $sevenZipPath" -ForegroundColor Red
Write-Host "Please install 7-Zip or update the path in the script"
@blizzardengle
blizzardengle / dom-watcher.js
Last active November 10, 2025 16:26
A single place to watch for DOM elements. an alternative to using DOMContentLoaded or individual mutation observers all over the place.
/**
* @class DOMWatcher
* Observes the DOM for elements matching CSS selectors
*
* Monitors the DOM tree for elements that match specified selectors, triggering
* callbacks when matching elements are added. Handles both immediate detection
* of existing elements and observation of future additions.
*
* @example
* // Create a watcher instance
@blizzardengle
blizzardengle / win_http_serv_reconfigure.ps1
Created October 30, 2024 23:46
Windows HTTP & Print Spooler Port Conflict Resolution: This script ensures that port 80 remains open for other applications by moving the default Windows Print Service to a different port.
<#
.SYNOPSIS
Windows HTTP and Print Spooler Port Conflict Resolution Script
.DESCRIPTION
This script resolves port conflicts between Docker/Web services and the Windows Print Spooler
by reconfiguring the HTTP service to use port 5000 instead of 80. This allows both printing
and Docker to work simultaneously.
.NOTES
@blizzardengle
blizzardengle / deep-merge.js
Created March 29, 2024 15:32
Deep merge two object together. Built this with AI and have no use for it anymore keeping around just in case.
/**
* Deep merge two objects together keeping unique keys from each object.
*
* @param {object} mergeIntoObj - The object to merge another object into.
* @param {object} mergeAndPrioritizeObj - The object to merge into mergeIntoObj. This object
* has priority when collisions occur.
* @returns
*/
const deepMerge(mergeIntoObj, mergeAndPrioritizeObj) => {
@blizzardengle
blizzardengle / print.js
Last active October 14, 2025 03:47
A simple logger class that allows printing console messages in color. Designed for node.js applications but usable in supported browsers as well.
/**
* Author: Christopher Keers | Caboodle Tech
* License: MIT
* Source: https://gist.github.com/blizzardengle/8147b6e7d8ffab2709ae2f79b7006b02
*/
class Print {
#enabled = true;
clear() {
@blizzardengle
blizzardengle / function.php
Last active January 11, 2024 07:56
Allows you to enqueue scripts as modules or import maps in WordPress using the built-in wp_enqueue_script function. You should add this code somewhere in your plugin or theme, most likely your functions.php file.
<?php
// If your PHP version is < 8
if ( ! function_exists( 'str_contains' ) ) {
/**
* Based on original work from the PHP Laravel framework.
*
* @author scm6079
* @link https://www.php.net/manual/en/function.str-contains.php#125977 Original Source
*
@blizzardengle
blizzardengle / classes.js
Last active March 26, 2022 00:23
Adds a global constant class that ES6 classes can register themselves with; useful for referencing dynamically named classes and so on.
/**
* Adds a global constant class that ES6 classes can register themselves with.
* This is useful for referencing dynamically named classes and instances
* where you may need to instantiate different extended classes.
*
* NOTE: This script should be called as soon as possible, preferably before all
* other scripts on a page.
*
* @class Classes
*/
@blizzardengle
blizzardengle / dockcmd.sh
Last active May 12, 2020 16:57
Run common docker-compose commands from any sub-directory of a docker project.
#!/bin/bash
# Run common docker-compose commands from any sub-directory of a docker project
dockcmd(){
# Versions
local dockcmd_version="1.5.0"
local docker_version=$(docker --version | egrep -o "([0-9]{1,}\.)+[0-9]{1,}")
local dcompose_version=$(docker-compose --version | egrep -o "([0-9]{1,}\.)+[0-9]{1,}")
# Assign arguments
// Attempt to find the message list on this page.
var msgList = document.querySelector('#content .message-list .messages');
var scroller = document.querySelector('#content .message-list-scroller');
// If the list was found continue.
if( msgList && scroller ){
console.log('Active.')
var li = document.createElement('LI');
li.id = 'controls'
var html = '<label>Ignore last <input type="text" id="days" style="display:inline-block;"> days.</label><br>'