Skip to content

Instantly share code, notes, and snippets.

View heathdutton's full-sized avatar
🕴️
Headlines are unsanitized input. Attention is prod.

Heath Dutton🕴️ heathdutton

🕴️
Headlines are unsanitized input. Attention is prod.
View GitHub Profile
@heathdutton
heathdutton / gist:67148cddf2af3c56216d
Created June 18, 2015 22:23
jQuery 1.7.1 with two addressfields
Uncaught TypeError: Cannot read property 'fields' of undefined
$.fn.addressfield.apply
(anonymous function)
f.event.dispatch
f.event.add.h.handle.i
f.event.trigger
(anonymous function)
e.extend.each
e.fn.e.each
f.fn.extend.trigger
@heathdutton
heathdutton / outbound_links.js
Last active September 9, 2015 15:11
Catch outbound links in Google Analytics
@heathdutton
heathdutton / logs
Created November 3, 2015 20:05
Get Acquia enterprise logs from a quick command line shell
#!/bin/bash
# Retrieves past and present logs for a site in Acquia Enterprise
# Put this in your /usr/local/bin folder and chmod it 0755
# Then you can search/view logs quickly from any terminal
if [ "$1" = "" ] || [ "$2" = "" ]
then
echo "Retrieves past and present logs for a site in Acquia Enterprise"
echo "Usage: $0 <site-alias> <site-environment>"
echo "Example: $0 qrk test"
@heathdutton
heathdutton / linkedin_auto_connect.js
Last active November 9, 2016 02:38
Apparently, JavaScript CAN make you new friends.
/**
* Linkedin auto-connect thingy.
*
* Step 1) Log in to Linkedin and go to https://www.linkedin.com/people/pymk
* (This is the "People You May Know page")
* Step 2) Open your browser console and run this javascript.
*/
(function($) {
var processedCards = [];
var lih = function(){
@heathdutton
heathdutton / iterm-material-oh-my-fish.sh
Created February 22, 2017 20:28
Install iTerm2, Material, Menlo, Fish, Oh-my-fish, and Agnoster.
#!/usr/bin/env bash
# Installs:
# Iterm2
# Powerline fonts (for Menlo)
# Material Design (color scheme)
# Fish
# Oh-my-fish
# Agnoster theme (works well with Material)
@heathdutton
heathdutton / cf_cloud_all.sh
Created July 26, 2017 18:44
Enable Cloudflare on all CNAME records.
#! /bin/bash
cf_user=<inset your email address here>
cf_token=<inset your api token here>
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'
if [ -z $1 ]
@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`;