Skip to content

Instantly share code, notes, and snippets.

Samuel Parkinson sjparkinson

Block or report user

Report or block sjparkinson

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
@sjparkinson
sjparkinson / launch-event.json
Last active Mar 20, 2017
EC2 AutoScale event notifications via SNS.
View launch-event.json
{
"Records": [
{
"EventSource": "aws:sns",
"EventVersion": "1.0",
"EventSubscriptionArn": "arn:aws:sns:eu-west-1:371548805176:FT-App-API-UAT-AutoScalingEvents-1VA671X21ETS2:500fe343-1af7-4b98-a81c-2a91c32f3f05",
"Sns": {
"Type": "Notification",
"MessageId": "1decf081-3906-5ba1-a408-a1c886a6549e",
"TopicArn": "arn:aws:sns:eu-west-1:371548805176:FT-App-API-UAT-AutoScalingEvents-1VA671X21ETS2",
@sjparkinson
sjparkinson / example.py
Last active Mar 13, 2017
Scripters code club testing example.
View example.py
#!/usr/bin/env python
import boto3
# Standard boilerplate to call the main() function to begin
# the program.
if __name__ == '__main__':
key = 'jif.gif'
body = open(filename, 'rb')
s3.Bucket('hello-world').put_object(Key=key, Body=body)
View mime.py
import sys
import math
# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.
mime_types = {}
file_names = []
count_mime_types = int(input()) # Number of elements which make up the association table.
count_file_names = int(input()) # Number of file names to be analyzed.
@sjparkinson
sjparkinson / purge.vcl
Created Oct 5, 2016
Examples on how to purge the cache in Varnish.
View purge.vcl
vcl 4.0;
sub vcl_recv {
// Allow PURGE requests to remove a specific object if it exists.
if (req.method == "PURGE") {
return (purge);
}
// Allow BAN requests, adding a lurker friendly ban to the ban list.
if (req.method == "BAN") {
@sjparkinson
sjparkinson / RDS-Aurora-CloudFormation-Example.yaml
Last active Oct 23, 2019
A basic CloudFormation template for an RDS Aurora cluster.
View RDS-Aurora-CloudFormation-Example.yaml
---
AWSTemplateFormatVersion: 2010-09-09
Description: >
A basic CloudFormation template for an RDS Aurora cluster.
Parameters:
DatabaseUsername:
AllowedPattern: "[a-zA-Z0-9]+"
ConstraintDescription: must be between 1 to 16 alphanumeric characters.
@sjparkinson
sjparkinson / Makefile
Created Aug 26, 2016
Automatic help target using ## comments.
View Makefile
help: ## Show this help message.
echo "usage: make [target] ..."
echo ""
echo "targets:"
fgrep --no-filename "##" ${MAKEFILE_LIST} | head -n '-1' | column -s ':#' -t -c 2
View Gatekeeper.cpp
#include "Gatekeeper.h"
const int kPinDrRelay = D0;
const int kPinS1Relay = D1;
const int kPinS2Relay = D2;
const int kPinDsLine = D3;
const int kPinBzLine = D4;
int primed_;
View gatekeeper-event-handler.py
import boto3
import json
import logging
import requests
from datetime import datetime
logger = logging.getLogger()
logger.setLevel(logging.INFO)
def handler(event, context):
@sjparkinson
sjparkinson / 00-type-hinted-array-arguments.php
Last active Aug 21, 2017
Type hint array arguments in PHP 5.6 using variadic functions and argument unpacking.
View 00-type-hinted-array-arguments.php
<?php
$run = function (callable ...$callables) {
foreach ($callables as $callable) {
$callable();
}
};
$callables = [
function () { echo 'Hello '; },
View osx-for-hackers.sh
# OSX for Hackers (Mavericks/Yosemite)
#
# Source: https://gist.github.com/brandonb927/3195465
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Ask for the administrator password upfront
You can’t perform that action at this time.