Skip to content

Instantly share code, notes, and snippets.

View purdy's full-sized avatar

Jason Purdy purdy

View GitHub Profile
purdy / gist:3919058
Created October 19, 2012 16:07
Drupal drupal_write_record() recipe
function MYFORM_submit( $form, &$form_state ) {
$msg = '';
$msg_type = 'status';
$redirect = 'admin/MYMODULE/INDEX_PATH';
$action = 'save your changes';
$expected = SAVED_UPDATED;
$update_msg = 'Your changes to the %category category have been saved.';
if ( is_numeric( $form_state['values']['id'] ) ) {
$TABLE_DATA['id'] = $form_state['values']['id'];
$result = drupal_write_record( 'MYTABLE', $TABLE_DATA, 'id' );
purdy / confirm_form_example.module
Created April 14, 2014 21:12
confirm_form module example
* @file
* confirm form example module
* */
function confirm_form_example_menu() {
$items['confirm_form_example_delete_object'] = array(
purdy / send-email.php
Last active September 15, 2017 02:40
* Quick utility script to send email out ... before you send this out,
* run this to load up the Sendgrid API key into your environment:
* source ./sendgrid.env
* Also, this code uses composer and the sendgrid/sendgrid library:
* composer require sendgrid/sendgrid
purdy / aws-sns-lambda-example.json
Created August 15, 2018 20:01
Example event from SNS when posting to Lambda
"Records": [
"EventSource": "aws:sns",
"EventVersion": "1.0",
"EventSubscriptionArn": "arn:aws:sns:us-east-1:123412341234:LambdaTesting:12b6a0a7-bbbb-ffff-cccc-7a7d21e25123",
"Sns": {
"Type": "Notification",
"MessageId": "614a0b34-bbbb-ffff-cccc-58ffddd9745f",
"TopicArn": "arn:aws:sns:us-east-1:123412341234:LambdaTesting",
purdy / index.js
Created August 23, 2018 19:00
This is the Lambda function for taking SNS messages from SES and saving them into a DynamoDB table.
var aws = require('aws-sdk');
var ddb = new aws.DynamoDB({
params: {
TableName: process.env.ddb_table_name
exports.handler = function(event, context, callback) {
var result = true;
for (var i=0, len = event.Records.length; i < len; i++) {
saveToDynamoDB(event.Records[i], context);
purdy /
Created April 18, 2019 14:39
Pantheon build script for master-lite environment
# This is a daily script to build an updated master-lite database for our various pubs.
for site in site1 site2 site3
echo "Building master-lite for $site"
# First, make sure the master-lite env is woke.
echo "Making sure master-lite environment is woke - $site."
purdy / config.yml
Created April 22, 2019 12:26
This is our circleci config.yml file
# This is Journalistic's A&O CI workflow. Whenever we push code to github
# that's not the master branch, it needs to download the branch, push it up to
# Pantheon, create a CI environment, run the visual regression testing, and
# then run the cypress testing.
defaults: &defaults
- image:
working_directory: ~/app
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN" "">
<html xmlns="" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:v="urn:schemas-microsoft-com:vml">
<!--[if gte mso 9]><xml><o:OfficeDocumentSettings><o:AllowPNG/><o:PixelsPerInch>96</o:PixelsPerInch></o:OfficeDocumentSettings></xml><![endif]-->
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
<meta content="width=device-width" name="viewport"/>
<!--[if !mso]><!-->
<meta content="IE=edge" http-equiv="X-UA-Compatible"/>
purdy / pre-commit.php
Created May 28, 2022 21:40
This is a file named pre-commit that we use in our repo's ~/.git/hooks to check our php code
#!/usr/bin/env php
// Credit:
require __DIR__ . '/../../vendor/autoload.php';
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Process\Process;