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).
heathdutton / mautic-campaign-delays-lite.sql
Last active Feb 25, 2019
List all Mautic campaign delays
View mautic-campaign-delays-lite.sql
-- All mautic campaign delays merged. Two queries (the first is important). Takes under 10s.
-- Depends on the PR of soft-deleted campaign events.
SET @@group_concat_max_len = 10000000000000;
SELECT NULL as campaign_id,
NULL as campaign_name,
NULL as event_id,
NULL as event_name,
NULL as lead_count,
heathdutton / backlog.sql
Last active Nov 1, 2018
mautic:campaign:trigger backlog
View backlog.sql
/* Lead ingestion behind - Leads waiting to be processed by a campaign */
SELECT cl.campaign_id as campaign_id, count(cl.lead_id) as lead_count FROM campaign_leads cl WHERE (cl.manually_removed = 0) AND (NOT EXISTS (SELECT null FROM campaign_lead_event_log e WHERE (cl.lead_id = e.lead_id) AND (e.campaign_id = cl.campaign_id))) GROUP BY cl.campaign_id LIMIT 100;
-- Faster:
SELECT cl.campaign_id AS campaign_id, as campaign_name, count(cl.lead_id) AS lead_count, c.is_published AS published
FROM campaign_leads cl
LEFT JOIN campaigns c
ON = cl.campaign_id
SELECT null FROM campaign_lead_event_log e
heathdutton / UnpackCSVJSON.php
Last active Dec 5, 2017
Takes a CSV with JSON in it, and makes it more usable as a CSV with columns extracted.
View UnpackCSVJSON.php
* Automatically extrapolate JSON keys/values from a CSV into their own columns.
* JSON is flattened, and null values/keys are ignored.
* Usage:
* php UnpackCSVJSON.php original.csv destination.csv
$file = $argv[1];
heathdutton /
Last active Aug 3, 2019
Execute cron tasks in elastic beanstalk on only one instance with this.
#!/usr/bin/env bash
# Prevent cron tasks from being ran by multiple instances in Elastic Beanstalk.
# Automatically adjusts to new "leading instance" when scaling up or down.
# Stores the result in an environment variable for other uses as AWS_EB_CRON
# This must be ran by cron as the root user to function correctly.
# Anything after this file will be executed as webapp for security.
# Example Cron (should be created by .ebextensions):
You can’t perform that action at this time.