Skip to content

Instantly share code, notes, and snippets.

View MattHealy's full-sized avatar

Matt Healy MattHealy

View GitHub Profile
@MattHealy
MattHealy / kill-mysql-processes.txt
Last active June 13, 2023 04:27
Kill long running mysql select queries
To kill stuck processes
select group_concat(concat('KILL ',id,';') separator ' ')
from information_schema.processlist
where Time>'100' and Info like 'select %';
To kill sleeping processes and allow alter table to occur
select group_concat(concat('KILL ',id,';') separator ' ')
from information_schema.processlist
import boto3
import csv
import calendar
from datetime import date, datetime, timedelta
from collections import OrderedDict
client = boto3.client('apigateway')
endDate = date(year=2023, month=3, day=31)
import boto3
import csv
client = boto3.client('route53domains', region_name='us-east-1')
fieldnames = [
'Domain Name',
'Domain Registrar',
'Expiration Date',
'Auto-Renewal',
import boto3
import csv
client = boto3.client('ec2')
regions = [region['RegionName'] for region in client.describe_regions()['Regions']]
fieldnames = [
'Certificate',
'Common Name',
@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()
@MattHealy
MattHealy / apache_check_restart.sh
Last active April 22, 2022 10:58
Check if Apache is running, and if not, restart it
#!/bin/sh
PORT=80
HP=:$PORT
echo 'Checking to see if Apache is up...'
if ( /usr/sbin/lsof -Pni $HP | grep "$PORT (LISTEN)" 2>&1 >/dev/null ); then
echo 'Apache is up';
else
echo 'Apache is down, restarting...';
/sbin/service httpd restart
logger -p mail.info apache_check_restart.sh restarting Apache
import boto3
from datetime import date, timedelta
endDate = date.today()
startDate = endDate - timedelta(days=7)
tempDate = startDate
days = []
while tempDate <= endDate:
days.append(tempDate)
@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"
@MattHealy
MattHealy / sign.php
Created June 30, 2021 11:54
PHP HMAC-SHA512 example
<?php
// HMAC-SHA512 signing
function get_signature($event, $orderid, $listing_id) {
// Hashing algorithm to use
$algo = 'sha512';
// Shared key used for signing payloads
@MattHealy
MattHealy / remote-login.sh
Created January 12, 2022 01:40
Get IP address and SSH
#!/bin/bash
ADDRESS=`aws ec2 describe-instances --filters 'Name=tag:Name,Values=WebServer' --output text --query 'Reservations[*].Instances[*].PrivateIpAddress'`
ssh ec2-user@$ADDRESS