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 / aws-eb-cron.sh
Last active August 16, 2020 09:45
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):
@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 / UnpackCSVJSON.php
Last active December 5, 2017 20:28
Takes a CSV with JSON in it, and makes it more usable as a CSV with columns extracted.
<?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
heathdutton / jobs_copy.sql
Last active January 3, 2018 14:57
Laravel jobs concurrency untangling
DROP TABLE IF EXISTS jobs_copy;
CREATE TABLE `jobs_copy` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `queue` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `payload` text COLLATE utf8_unicode_ci NOT NULL, `attempts` tinyint(3) unsigned NOT NULL, `reserved` tinyint(3) unsigned NOT NULL, `reserved_at` int(10) unsigned DEFAULT NULL, `available_at` int(10) unsigned NOT NULL, `created_at` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=29972441 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
INSERT INTO `jobs_copy` SELECT * FROM `jobs`;
DELETE FROM jobs WHERE `reserved` != 1 AND `id` IN (SELECT `id` FROM jobs_copy ORDER BY `id` DESC);
# Repeat ad nauseam:
INSERT INTO `jobs` (SELECT * FROM `jobs_copy` ORDER BY `id` ASC LIMIT 500); DELETE FROM `jobs_copy` ORDER BY `id` ASC LIMIT 500; SELECT SLEEP(18); SELECT COUNT(*) FROM `jobs`;
@heathdutton
heathdutton / mautic_eb_multi.sql
Last active January 8, 2018 15:17
Initial database for Mautic-EB Multisite. To be imported into a DB named mautic_eb_multi within the same RDS as Mautic. Note: This is just a rough draft!
# ************************************************************
# Database: mautic_eb_multi
# ************************************************************
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
@heathdutton
heathdutton / services.txt
Last active January 17, 2018 14:10
Symfony Container Public Services
Symfony Container Public Services
=================================
------------------------------------------------------------------------------------------------------ ---------------------------------------------------------------------------------------
Service ID Class name
------------------------------------------------------------------------------------------------------ ---------------------------------------------------------------------------------------
annotation_reader Doctrine\Common\Annotations\CachedReader
assets.context Symfony\Component\Asset\Context\RequestStackContext
assets.packages Symfony\Component\Asset\Packages
babdev\trans
@heathdutton
heathdutton / query.php
Created February 12, 2018 19:59
Get a raw query equivalent w/ doctrine (hacky, only for debugging)
$sql = $query->getSQL();
foreach($query->getParameters() as $key => $val) {
if (is_numeric($val)) {
$sql = str_replace(':' . $key, $val, $sql);
} else {
$sql = str_replace(':' . $key, '"'.$val.'"', $sql);
}
}
@heathdutton
heathdutton / listeners.txt
Last active March 22, 2018 15:52
Mautic event listeners
Found by php app/console debug:container --show-private --env=dev | grep -i "listener:"
bazinga.oauth.event_listener.exception Bazinga\OAuthServerBundle\EventListener\OAuthExceptionListener
bazinga.oauth.event_listener.request Mautic\ApiBundle\EventListener\OAuth1\OAuthRequestListener
Symfony\Component\Security\Http\Firewall\ExceptionListener
debug.debug_handlers_listener Symfony\Component\HttpKernel\EventListener\DebugHandlersListener
doctrine.orm.default_entity_listener_resolver Doctrine\Bundle\DoctrineBundle\Mapping\ContainerAwareEntityListenerResolver
doctrine.orm.default_listeners.attach_entity_listeners Doctrine\ORM\Tools\AttachEntityListenersListener
fos_rest.body_listener
From 23a41e73f13cfbc9bc0156ee8bcb69ff15fa29c1 Mon Sep 17 00:00:00 2001
From: heathdutton <hdutton@thedmsgrp.com>
Date: Mon, 9 Apr 2018 16:47:13 -0400
Subject: [PATCH 1/5] Support includes/excludes with text fields for bulk
filtering.
---
app/bundles/LeadBundle/Entity/LeadListRepository.php | 10 ++++++++++
app/bundles/LeadBundle/Entity/OperatorListTrait.php | 2 ++
2 files changed, 12 insertions(+)
diff --git a/app/bundles/LeadBundle/Entity/LeadListRepository.php b/app/bundles/LeadBundle/Entity/LeadListRepository.php
index 8cdfbae108..234535214f 100644
--- a/app/bundles/LeadBundle/Entity/LeadListRepository.php
+++ b/app/bundles/LeadBundle/Entity/LeadListRepository.php
@@ -1677,11 +1677,44 @@ public function getListFilterExpr($filters, &$parameters, QueryBuilder $q, $isNo
case 'in':
case 'notIn':
+ if (is_string($details['filter'])) {
+ // Expound the string to an array based on common string array notations.