Skip to content

Instantly share code, notes, and snippets.

View AMMullan's full-sized avatar

Allan Mullan AMMullan

View GitHub Profile
@AMMullan
AMMullan / logs_insights.sql
Last active August 22, 2023 16:43
CloudWatch Logs Insights Queries
# Get number of emails sent by each IAM User broken down in hourly segments
stats count(*) by IAMUser, bin(1h) as period
| filter EventType in ["Delivery"]
| sort IAMUser desc, period desc
@AMMullan
AMMullan / README.md
Last active November 8, 2022 17:03
ECS Notes

ECS Notes

A Task Definition is a collection of 1 or more container configurations. Some Tasks may need only one container, while other Tasks may need 2 or more potentially linked containers running concurrently.

The Task Definition allows you to specify things like:

  • Which Docker image to use
  • Which ports to expose
@AMMullan
AMMullan / find_duplicate_files.ps1
Created August 16, 2022 08:47
Finding Duplicate Files Fast
# https://powershell.one/tricks/filesystem/finding-duplicate-files
function Find-PSOneDuplicateFile
{
<#
.SYNOPSIS
Identifies files with duplicate content
.DESCRIPTION
Returns a hashtable with the hashes that have at least two files (duplicates)
@AMMullan
AMMullan / snippets.sh
Last active September 22, 2022 15:00
# Remove all folders called .terraform in this dir
find . -type d -name .terraform -exec rm -rf {} +
# Create zip package from git
git archive --format zip --output [zip_file] --remote [repo_ssh_url] [branch_name]
# List packages and sort by size
rpm -qa --queryformat '%10{size} - %-25{name} \t %{version}\n' | sort -n
# Test VirtualHost
@AMMullan
AMMullan / ipcalc
Last active November 11, 2020 16:45
#!/usr/bin/env python3
import sys
import socket
import struct
import platform
try:
import ipaddress
except:
@AMMullan
AMMullan / create_lambda_layer.sh
Last active July 22, 2022 13:07
Create Lambda Layer for Python (Multiple Runtimes)
#!/bin/bash
# Expects a requirements.txt in the same folder
# Note: if the package includes NumPy and SciPy, consider defining the package
# and the dependencies that aren't these as they're natively available in Layers
# Supported Docker Images are available here:
# https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-image-repositories.html
layer_versions="python3.8 python3.9"
@AMMullan
AMMullan / aws_lambda_self_destruct.py
Created September 15, 2020 15:26
Self-Destructing Lambda
import os
import boto3
lmbda = boto3.client ('lambda')
def lambda_handler(event, context):
lmbda.delete_function(FunctionName=context.function_name)
return True
@AMMullan
AMMullan / snippets.py
Last active August 3, 2022 16:00
Useful Python Snippets
import re
def equal_dicts(d1, d2, ignore_keys=None):
''' Dictionary Comparison
Takes 2 lists and does a comparison, excluding the keys from ignore_keys
Arguments:
d1 {dict} -- First Dict