Skip to content

Instantly share code, notes, and snippets.

View MattHealy's full-sized avatar

Matt Healy MattHealy

View GitHub Profile
@MattHealy
MattHealy / list-pull-requests.py
Last active October 23, 2022 02:35
List all open pull requests in AWS Codecommit
import boto3
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
'--repo', metavar='repo', type=str,
help='Optionally filter by repository')
args = parser.parse_args()
#!/usr/bin/env python3
import subprocess
import zipfile
import os
dirs = next(os.walk('.'))[1]
for d in dirs:
print("Preparing {} ZIP archive".format(d))
@MattHealy
MattHealy / pre-push
Created August 13, 2019 11:47
Git pre-push hook to automatically deploy on master branch push
#!/bin/bash
BRANCH=`git rev-parse --abbrev-ref HEAD`
if [[ "$BRANCH" == "master" ]]; then
./deploy.sh
fi
@MattHealy
MattHealy / vimrc
Created August 7, 2019 23:06
Mac OSX vimrc file
" Display a red column 80 chars in .py files (to assist with line length)
" set colorcolumn=80
autocmd FileType python setlocal colorcolumn=80
" Return to last edit position when opening files
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
@MattHealy
MattHealy / apigateway-sqs-integration.yaml
Created May 22, 2019 02:53
Cloudformation Template for API Gateway AWS Service Integration to SQS Queue
Description: API Gateway to JSON payloads and send to SQS
Outputs:
ApiEndpoint:
Description: Endpoint for this stage of the api
Value: !Join
- ''
- - https://
- !Ref 'SQSProxy'
- .execute-api.ap-southeast-2.amazonaws.com/
- prod
@MattHealy
MattHealy / convert.py
Created May 16, 2019 03:27
Convert minutes in to days, hours and minutes
def convert(minutes):
if isinstance(minutes, int):
return str(minutes/24/60) + " day, " + \
str(minutes/60 % 24) + " hours, " + \
str(minutes % 60) + " minutes"
else:
return "0 days, 0 hours, 0 minutes"
@MattHealy
MattHealy / docx-sample.py
Created January 3, 2018 07:05
python-docx example
def merge(r):
if '{{LESSOR}}' in r.text:
r.text = r.text.replace('{{LESSOR}}', 'my name')
if '{{LESSORADDRESS}}' in r.text:
r.text = r.text.replace('{{LESSORADDRESS}}', 'my address')
from docx import Document
@MattHealy
MattHealy / .bash_profile
Created October 23, 2017 05:08
Add to .bash_profile for AWS profile switching
switch() {
export AWS_DEFAULT_PROFILE=$1
PS1="\h:\W \u\$ ($1)$ "
}
@MattHealy
MattHealy / config
Created October 23, 2017 05:02 — forked from justinpawela/config
AWS CodeCommit Multiple Account Config
# This file is: ~/.ssh/config
# You may have other (non-CodeCommit) SSH credentials stored in this
# config file – in addition to the CodeCommit settings shown below.
# NOTE: Make sure to run [ chmod 600 ~/.ssh/config ] after creating this file!
# Credentials for Account1
Host awscc-account1 # 'awscc-account1' is a name you pick
Hostname git-codecommit.us-east-1.amazonaws.com # This points to CodeCommit in the 'US East' region
@MattHealy
MattHealy / rotate-ami-launch-config.sh
Created August 8, 2017 12:43
Update an existing AWS Launch Configuration to use a new AMI image
#!/bin/bash
oldconfigname="$1"
newconfigname="$2"
ami="$3"
KEYNAME="my_keypair_name"
ASGROUP="my_autoscaling_group_name"
SECURITYGROUP="sg-1234"
INSTANCETYPE="t2.micro"