Skip to content

Instantly share code, notes, and snippets.

View micah1701's full-sized avatar
🧰
Open to work

Micah J. Murray micah1701

🧰
Open to work
View GitHub Profile
@micah1701
micah1701 / SupabaseProxy.md
Last active August 29, 2026 16:16
Custom Domain Proxy for Supabase

🌀 Supabase Reverse Proxy (Apache)

Put your own domain in front of a Supabase project instead of shipping *.supabase.co URLs to your users without paying for Supabase's custom domain add-on.

This started as a quick Apache vhost and turned into a small case study in how many ways CORS can quietly make you waste half a day.


🚀 Why This Exists

@micah1701
micah1701 / StringToColor.ts
Created November 11, 2025 18:41
Hash a Text-String into a Distinct but Consitent Color
/**
* Converts a string to a CSS-ready color representation.
*
* Consistent per string: Each unique string always returns the same color.
* Distinct colors: Different strings usually yield noticeably different hues.
* Readable range: By fixing lightness and saturation ranges, it avoids too-light (like #F3F3F3) or too-dark values.
* Easily adjustable: You can tweak saturation/lightness ranges for your theme—e.g., use slightly darker tones for dark backgrounds.
*
* @param str String input to be converted to a color
* @param as optional string to specify output format: 'hsl' (default), 'rgb' or 'hex'
@micah1701
micah1701 / Droplet Setup.md
Created November 4, 2025 02:29
These are the steps I always forget to do in the right order when configuring a Cloud Instance for use web server. Steps include adding PHP, Node, and other important libraries and extensions.

🖥️ Setting Up Cloud Instance Ubuntu Server from Scratch

Environment: Ubuntu 25.04 with SSH access

Starting Point: Logged in as Root User on a new installation


@micah1701
micah1701 / dateFormat.js
Last active September 16, 2024 13:24
Replicate PHP's native date() formatting in JavaScript for many common format types
/**
* Return a formated string from a date Object mimicking PHP's date() functionality
*
* format string "Y-m-d H:i:s" or similar PHP-style date format string
* date mixed Date Object, Datestring, or milliseconds
*
*/
function dateFormat(format,date){
if(!date || date === "")
@micah1701
micah1701 / bulma_htmlSelectElement_to_dropdown_with_filter.js
Created June 9, 2024 14:20
A JavaScript class that converts an existing HTML Select input element to a functioning Bulma.io Dropdown component with a search filter
class htmlSelect2BulmaDropownWithFilter {
constructor(HTMLSelectElement_or_ElementId) {
this.selectElement = (typeof (HTMLSelectElement_or_ElementId) == "string") ? document.getElementById(HTMLSelectElement_or_ElementId) : HTMLSelectElement_or_ElementId;
if (this.originalOptions == null) {
this.originalOptions = Array.from(this.selectElement.options).map(option => ({ value: option.value, text: option.text }));
}
this.options = Array.from(this.selectElement.options).map(option => ({ value: option.value, text: option.text })); //selectElement.options;
this.filter = "";
this.filteredOptions = [];
this.selectElement.parentElement.querySelectorAll('.dropdown').forEach(dropdownElement => {
@micah1701
micah1701 / cleanDEA.php
Last active January 25, 2023 03:50
Validate and sanatize a user entered DEA Registration ID with PHP
/**
* Validate and clean a DEA Registration ID
* @param string $enteredValue user supplied DEA ID
* @param string $lastname OPTIONAL extended validation requires first letter of users last name to match corresponding character in ID
*
* @return string|bool returns sanitized alphanumeric DEA Registration ID or FALSE
*/
function cleanDEA(string $enteredValue, string $lastname = '') {
//if a " Supervisee Identifier" was supplied, just ignore it
@micah1701
micah1701 / bulma_quick_notification.js
Last active January 12, 2022 08:43
Extends bulma.io CSS framework with a short-lived notification message that slides up from the bottom of the screen. Useful for showing user that a change has occurred on the page. Requires jQuery.
/**
* display a quick notification box that slides up from the bottom for a few seconds
*/
function quickNotice(message,cssClass,timeOnScreen)
{
cssClass = (cssClass) ? cssClass : 'is-success';
timeOnScreen = (timeOnScreen) ? timeOnScreen : 3000;
var html = '<div id="quickNotice" style="position: absolute; z-index: 100; width: 100%" class="notification has-text-centered has-text-weight-semibold '+cssClass+'">';
html+= message;
@micah1701
micah1701 / cURL_follow_location.php
Created October 3, 2012 18:22
Recursive cURL function to follow links when local server does not allow CURLOPT_FOLLOWLOCATION
/**
* use cURL to get the contents on a remote page uses redirect headers
* necessary when local server does not allow location
*/
function curl($url,$recursive_attempt=0){
if (!function_exists('curl_init')) { return false; }
$content = false;
$can_follow = ( ini_get('safe_mode') || ini_get('open_basedir') ) ? false : true; //cURL can't follow redirects in safe mode or if open_basedir is on
@micah1701
micah1701 / jQuery-UI-javascript-prompts.js
Last active October 15, 2021 13:48
Three functions to replace the native javascript alert(), confirm() & prompt() popup boxes with customizable jQuery UI dialog boxes. example usage: uiPrompt({ message: 'Enter your name', placeholder: 'Your Name Goes Here', callback: function(value){ uiAlert("hello "+value); }});
/**
* display a styled jQuery UI dialog box in place of the native javascript alert()
*
* message string HTML message to display
* title string optional title text to display in header of confirmation box
* callback function optional function to trigger when user clicks "OK"
*
*/
function uiAlert(settings)
{