Skip to content

Instantly share code, notes, and snippets.

View MPJHorner's full-sized avatar
👨‍💻
Focusing

Matt Horner MPJHorner

👨‍💻
Focusing
View GitHub Profile
@MPJHorner
MPJHorner / index.js
Last active December 16, 2021 10:43
SES Tracking Lambda To Mysql
const mysql = require('mysql2');
// const pool = mysql.createConnection({
// host: process.env.MYSQL_HOST,
// user: process.env.MYSQL_USER,
// password: process.env.MYSQL_PASSWORD,
// database: process.env.MYSQL_DB,
// });
const pool = mysql.createPool({
@MPJHorner
MPJHorner / index.js
Created July 2, 2021 13:02
Amazon SES Suppression to CSV and Removal Tool (HACKY AF)
// Pleas excuse how messy and hacky AF this is... It works though.
// Please ensure you have local auth setup to AWS CLI already, otherwise you made need to modify the config bits to include some auth...
// import { SESv2Client, ListSuppressedDestinationsCommand } from "@aws-sdk/client-sesv2"; // ES Modules import
const { SESv2Client, ListSuppressedDestinationsCommand, DeleteSuppressedDestinationCommand } = require("@aws-sdk/client-sesv2"); // CommonJS import
const converter = require('json-2-csv');
const fs = require('fs');
const config = {};
const save = true; //Set to FALSE to stop saving results to CSV
@MPJHorner
MPJHorner / readme.md
Created June 1, 2021 14:52
PHP Switcher - via Brew (Excluding Apache / Nginx)

Add above file (script.sh) to /usr/local/bin/sphp Then run chmod +x /usr/local/bin/sphp

@MPJHorner
MPJHorner / aws-cloudwatch-logs.js
Created May 14, 2020 08:16
AWS NodeJS Lambda SES SNS Cloudwatch - Tracking Open, Sends & Deliveries
module.exports = function (config) {
var cloudwatchlogs = config.cloudwatchlogs,
logGroupName = config.logGroupName || '/aws-cloudwatch-logs/default';
return {
log: function (eventName, message, done) {
var logCallback = done || function () {},
@MPJHorner
MPJHorner / index.js
Last active May 14, 2020 08:12
Amazon SES NodeJS Test Script /w Configuration Set
var ses = require('node-ses')
var client = ses.createClient({
key: '%AWS_KEY_HERE%',
secret: '%AWS_SECRET_HERE%',
amazon: 'https://email.eu-west-2.amazonaws.com'
});
// Give SES the details and let it construct the message for you.
client.sendEmail({
to: 'other@rea.com',
@MPJHorner
MPJHorner / config.yml
Created April 27, 2020 16:46 — forked from thijskok/config.yml
CircleCI 2.0 Laravel build configuration with PHP 7.1, NodeJS, and MySQL support. Runs both PHPunit as well as Laravel Dusk. Proper GD configuration for image editing purposes. Several linters included (requires including them in composer / package.json).
version: 2
jobs:
build:
working_directory: ~/user/repo
environment:
BASH_ENV: ~/.bashrc
docker:
@MPJHorner
MPJHorner / config.yml
Created April 27, 2020 16:46 — forked from thijskok/config.yml
CircleCI 2.0 Laravel build configuration with PHP 7.1, NodeJS, and MySQL support. Runs both PHPunit as well as Laravel Dusk. Proper GD configuration for image editing purposes. Several linters included (requires including them in composer / package.json).
version: 2
jobs:
build:
working_directory: ~/user/repo
environment:
BASH_ENV: ~/.bashrc
docker:
@MPJHorner
MPJHorner / ListAllPhpTimezoneLocations.php
Created March 24, 2020 09:17
PHP - List All Timezone Locations
<?php
$timezones = timezone_identifiers_list();
foreach ($timezones as $tz){
echo $tz . PHP_EOL;
}
@MPJHorner
MPJHorner / mysql-docker.sh
Created June 4, 2018 22:42 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@MPJHorner
MPJHorner / s3-invalidation.js
Created March 13, 2018 13:12 — forked from supinf/s3-invalidation.js
AWS Lambda script:: CloudFront Invalidations which are triggered by s3 events.
console.log('Loading event');
var Q = require('q');
var aws = require('aws-sdk');
var cloudfront = new aws.CloudFront();
exports.handler = function (event, context) {
//_log('Received event: ', event);
var bucket = event.Records[0].s3.bucket.name;