Skip to content

Instantly share code, notes, and snippets.

View heathdutton's full-sized avatar
🕴️
🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈

Heath Dutton ☕ heathdutton

🕴️
🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈
  • ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
  • Tampa Florida
  • https://orcid.org/0009-0005-9397-422X
View GitHub Profile
@heathdutton
heathdutton / upgrade-php7.sh
Last active January 12, 2024 07:47
Upgrade PHP to 7.3 on Amazon Linux (specifically for Elastic Beanstalk but should work elsewhere)
#!/usr/bin/env bash
# Upgrade an Amazon Linux EC2 to PHP 7.3
#
# Last tested w/ PHP 7.2 AWS Linux version 2.8.5
#
# Must be ran as sudo:
# sudo bash upgrade-php7.sh
#
# Can be added to ./.ebextensions/20_php.config like so:
# container_commands:
@heathdutton
heathdutton / ua.md
Last active November 10, 2023 02:40 — forked from troyp/ua.md
D&D 5e Unearthed Arcana Index

D&D 5e Unearthed Arcana Index

Because finding anything in this page is harder than it should be

Date Article Contents
2015-02-02 Unearthed Arcana: Eberron [PDF] Changelings, shifters, warforged, Wizard (Artificer), rules for action points, dragonmarks
@heathdutton
heathdutton / file_per_table.sql
Last active October 25, 2023 15:42
Show all tables and their corresponding innodb_table_per_file files (if present)
-- Show all tables and their corresponding innodb_table_per_file files (if present)
SELECT *
FROM (
SELECT
TABLE_SCHEMA as 'Schema',
TABLE_NAME as 'Table',
ROUND((DATA_LENGTH + INDEX_LENGTH) / 1024) as 'Info MB',
ROUND((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024, 6) as 'Info GB',
(DATA_LENGTH + INDEX_LENGTH) / 1099511627776 as 'Info TiB'
FROM INFORMATION_SCHEMA.TABLES
@heathdutton
heathdutton / campaigns-worth-unpublishing.sql
Last active August 15, 2023 16:13
Find Mautic campaigns that can be unpublished to speed up campaign processing.
-- Find dead campaigns, first discern *active* campaigns.
SET GROUP_CONCAT_MAX_LEN = 999999999;
-- What is the oldest Lead ID we should care about ( 90 days )
SELECT id FROM leads WHERE date_added = DATE_SUB(NOW(), INTERVAL 90 DAY) LIMIT 1 INTO @lead_id;
-- Get list of all campaigns that were modified in last yr.
SELECT GROUP_CONCAT(c.id) FROM `campaigns` c WHERE c.is_published = 1 OR c.date_modified > DATE_SUB(NOW(), INTERVAL 365 DAY) INTO @active_campaigns;
-- SELECT @lead_id, @active_campaigns;
@heathdutton
heathdutton / assasin.sql
Last active June 29, 2023 17:31
Assassinates matching queries.
DELIMITER ;;
DROP PROCEDURE IF EXISTS `assasinate`;;
CREATE PROCEDURE `assasinate`(queryportion VARCHAR(255))
BEGIN
DECLARE sql_string MEDIUMTEXT;
DECLARE count MEDIUMINT;
SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SET FOREIGN_KEY_CHECKS = 0;
SET @count = 0;
SET @sql_string := 'tmp';
@heathdutton
heathdutton / mysql_health_check.sql
Last active May 31, 2023 17:06
Give a MySQL (or aurora) database a simple health check, to find issues and quick wins
-- Give a quick MySQL/AuroraDB database a simple health check.
-- See comments below to customize to your needs.
-- (this is all one query)
-- Step 1: Find very large tables
SELECT 'Table is very large' AS `Issue`,
NULL AS `User`,
NULL AS `Host`,
TABLE_SCHEMA AS 'DB',
TABLE_NAME AS `Table`,
@heathdutton
heathdutton / config_prod.php
Last active March 5, 2023 16:30
An example of how to use Master/Slave support with mautic. In this case supporting an optional read-only replica cluster with AuroraDB.
<?php
$loader->import('config.php');
if (file_exists(__DIR__.'/security_local.php')) {
$loader->import('security_local.php');
} else {
$loader->import('security.php');
}
@heathdutton
heathdutton / this-is-fine.gif
Created February 3, 2022 19:35 — forked from michaelradu/this-is-fine.gif
This is fine gif.
this-is-fine.gif
@heathdutton
heathdutton / This is fine.md
Created February 3, 2022 19:35 — forked from 25A0/This is fine.md
This is fine. ASCII art

This is fine. ASCII art

preview

There are two versions, one is for dark letters on a bright background, the other one for bright letters on a dark background.

The bright on dark version looks better, so go for that one if you can :)

Dark letters on a bright background

@heathdutton
heathdutton / recover_commit_latency.sql
Last active December 6, 2021 19:18
MySQL - Automatically recover from a big commit latency bottleneck
-- Note, this will CANCEL commits if they take more than 20s to complete.
-- It is assumed that if you have commit latency greater than 20s that something is terribly wrong,
-- and you are now losing data due to a lack of throughput already.
-- This will help resume opperation at the cost of potentially dropping locking changes.
-- Create a stored proceedure that can recover from a commit latency lock-up
-- Do not run multiple of this at once.
-- When running loop and kill till there are none to kill.
DROP PROCEDURE IF EXISTS `recover_commit_latency`;
DELIMITER ;;