Skip to content

Instantly share code, notes, and snippets.


Heath Dutton ☕ heathdutton

Block or report user

Report or block heathdutton

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
heathdutton / TimeZoneOptionCollection.php
Created Jan 28, 2020
Dynamic collection of supported PHP Timezones. Grouped by country, with dynamic abbreviations, DST indicators, and future-proofing. For making useful and clean select2 (or similar) dropdown selectors. Better than all the hard-coded solutions I could find.
View TimeZoneOptionCollection.php
* Class TimeZoneOptionCollection
* Dynamic collection of supported PHP Timezones:
* - Grouped by country
* - Commonly used abbreviations
* - DST indicators
* - Future-proof (leans on PHP for timezones).
View Laravel-Blade-Template-Cheatsheet
{{ $var }} - Echo content
{{ $var or 'default' }} - Echo content with a default value
{{{ $var }}} - Echo escaped content
{{-- Comment --}} - A Blade comment
@extends('layout') - Extends a template with a layout
@if(condition) - Starts an if block
@else - Starts an else block
@elseif(condition) - Start a elseif block
@endif - Ends a if block
heathdutton /
Last active Feb 20, 2020
Recommended cron tasks for Mautic 2 in Cloudways.
# Recommended cron tasks for Mautic 2 in Cloudways.
# All tasks are ran as www-data
# Output is ignored to avoid log file overhead.
# --quiet is used to reduce MySQL overhead on some tasks.
# --max-contacts is used to prevent one object's backlog from locking updates for other object.
# Update all segments.
*/5 * * * * www-data php applications/mautic/public_html/app/console mautic:segments:update --max-contacts=10000 --quiet >/dev/null 2>&1
heathdutton / campaigns-worth-unpublishing.sql
Last active Aug 28, 2019
Find Mautic campaigns that can be unpublished to speed up campaign processing.
View campaigns-worth-unpublishing.sql
CONVERT_TZ(c.date_modified,'UTC','US/Eastern') AS 'last_modified',
(SELECT CONVERT_TZ(el.date_triggered,'UTC','US/Eastern') FROM campaign_lead_event_log el WHERE el.campaign_id = ORDER BY el.date_triggered DESC LIMIT 1) AS 'last_activity'
FROM campaigns c
c.is_published = 1
AND c.date_modified < DATE_SUB(NOW(), INTERVAL 365 DAY)
heathdutton / auto_increment_explosion_warning_system.sql
Created Aug 5, 2019
Find tables that are the closets to approaching their max auto-increment value in MySQL (and need to be made unsigned or BIGINT).
View auto_increment_explosion_warning_system.sql
LOCATE('unsigned', COLUMN_TYPE) > 0,
heathdutton / panic-at-the-disco.sql
Last active Jul 30, 2019
Mautic campaign_lead_event_log_new hit 2147483647 rows.
View panic-at-the-disco.sql
-- So this table hit the max-int value for the auto_increment column id.
-- Really, such columns should be unsigned so they can go up to 4 bil.
ALTER TABLE campaign_lead_event_failed_log DROP FOREIGN KEY `FK_E50614D2EA675D86`;
-- This took ~3 minutes.
ALTER TABLE campaign_lead_event_failed_log CHANGE log_id log_id INT(11) UNSIGNED NOT NULL;
-- The next table was too large to modify in place, was causing an outage, so we had to do a swap like so:
CREATE TABLE campaign_lead_event_log_new LIKE campaign_lead_event_log;
ALTER TABLE campaign_lead_event_log_new CHANGE id id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT;
heathdutton / unused_mautic_segments.sql
Created Jun 21, 2019
Find unused segments in Mautic that could be churning uselessly.
View unused_mautic_segments.sql
-- Find unused segments that can be unpublished to save processing time.
SELECT, l.created_by_user,, IF (l.date_modified IS NULL, l.date_added, l.date_modified) AS date_modified,
(SELECT COUNT(*) FROM lead_lists_leads WHERE leadlist_id = AS lead_count
FROM lead_lists l
l.is_published = 1
-- Find segments in use.
FROM lead_lists l
heathdutton / five9adduser.php
Created May 31, 2019
Create agents in five9
View five9adduser.php
* Example usage:
* php five9adduser.php <admin username> <admin password> <agent email> <agent firstname> <agent lastname> <agent password>
$user = $argv[1];
$pass = $argv[2];
heathdutton / delete_default_widgets.sql
Created Mar 18, 2019
Delete default widgets in mautic core so that they fall back to default.json contents
View delete_default_widgets.sql
DELETE FROM widgets WHERE type IN ('','','','recent.activity','upcoming.emails','','map.of.leads','top.lists','','','unique.vs.returning.leads','','anonymous.vs.identified.leads','dwell.times','recent.activity','upcoming.emails');
heathdutton /
Created Dec 13, 2018
Mautic 2.15.0 Container public services
sudo -u webapp bash -c "DEBUG=1 /var/app/current/mautic/app/console debug:container --env=dev"
Symfony Container Public Services
------------------------------------------------------------------------------------------------------ -----------------------------------------------------------------------------------------------
Service ID Class name
------------------------------------------------------------------------------------------------------ -----------------------------------------------------------------------------------------------
annotation_reader Doctrine\Common\Annotations\CachedReader
assets.context Symfony\Component\Asset\Context\RequestStackContext
You can’t perform that action at this time.