Skip to content

Instantly share code, notes, and snippets.

@ajkerrigan
ajkerrigan / cwlastlog.sh
Last active July 12, 2016 13:55
Get the most recent Cloudwatch log messages for a specified AWS Lambda function (requires the AWS CLI and jq)
#!/bin/bash
#
# Usage: cwlastlog.sh <Lambda function name>
LAMBDA_FUNCTION="${1}"
MESSAGE_LIMIT=50
# Get the name of the log stream with the most recent activity for this log group
LAST_LOG_STREAM=`aws logs describe-log-streams --log-group-name "/aws/lambda/${LAMBDA_FUNCTION}" \
--descending --order-by LastEventTime --max-items 1 | jq --raw-output '.logStreams[0].logStreamName'`
@ajkerrigan
ajkerrigan / awsfind.sh
Created February 6, 2017 15:21
Find AWS VPC Resources by IP/DNS
#!/bin/bash
usage()
{
echo "Find AWS resources using network interface information."
echo "Usage: $0 {pri|pub|dns} <comma-separated list>"
echo
echo "pri: Private IP Address"
echo "pub: Public IP Address"
echo "dns: Public DNS Name"
@ajkerrigan
ajkerrigan / aws-mfa.sh
Created May 23, 2017 03:12
Create and activate an MFA-required temporary session with the AWS CLI, based on the current profile
#!/bin/bash
#
# Provide basic support for MFA-required temporary sessions with the AWS CLI.
# While not a hard dependency, this script plays nicely with zsh and the
# aws plugin for oh-my-zsh. jq is required.
#
# https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/aws/aws.plugin.zsh
# https://stedolan.github.io/jq/manual/
#
# Usage:
@ajkerrigan
ajkerrigan / s3_search.py
Last active March 19, 2024 03:04
Use S3 Select the ugly way
#!/usr/bin/env python3
"""
Search files in S3 similar to grep.
Use S3 Select with intentionally broad CSV parameters to make
it behave more like naive grep. This enables it to be used more
effectively on data which is malformed or unpredictably structured
without requiring a pre-processing step.
Reference: https://aws.amazon.com/blogs/aws/s3-glacier-select/
@ajkerrigan
ajkerrigan / AWS User Info Bookmarklet.md
Created August 6, 2019 16:55
AWS User Info Bookmarklet

Current User Info Bookmarklet for the AWS Console

When logged into the AWS web console it can be helpful to quickly see details of your current identity. This can include:

  • An ARN
  • Your current account alias
  • Issuer info, indicating tools such as aws-vault
  • Your username, which may include a role session name

This bookmarklet is a simple way to parse that information out of the aws-userInfo cookie and return it as pretty printed JSON.

@ajkerrigan
ajkerrigan / keybase.md
Created August 22, 2019 01:13
keybase.md

Keybase proof

I hereby claim:

  • I am ajkerrigan on github.
  • I am ajkerrigan (https://keybase.io/ajkerrigan) on keybase.
  • I have a public key ASCDswQsTprea3Fr88V8su3Yd0MbqLoMrUyJhPEPEEOQXQo

To claim this, I am signing this object:

@ajkerrigan
ajkerrigan / karabiner.json
Created October 11, 2019 04:19
Karabiner Elements Config Sample
{
"global": {
"check_for_updates_on_startup": true,
"show_in_menu_bar": true,
"show_profile_name_in_menu_bar": false
},
"profiles": [
{
"complex_modifications": {
"parameters": {
@ajkerrigan
ajkerrigan / tmux.conf
Created October 11, 2019 13:39
My tmux.conf
unbind-key C-b
set-option -g prefix C-a
bind-key a send-prefix
# Pane Controls
#
# Everything revolves around vim directional keys: h/j/k/l
#
# <prefix>-<direction>: Resize pane one row/col at a time
# <prefix>-shift-<direction>: Resize by 5 rows/cols at a time
@ajkerrigan
ajkerrigan / vdhash.py
Created January 19, 2020 19:15
vdhash.py
#!/usr/bin/env python3
import hashlib
import sys
from pathlib import Path
if len(sys.argv) != 2:
print(f'Usage: {sys.argv[0]} <file>')
sys.exit(1)
try:
@ajkerrigan
ajkerrigan / .visidatarc.py
Last active March 8, 2020 17:56
VisiData - Auto-prompt for zip passwords
import zipfile
from functools import wraps
from visidata import vd
def open_decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
try:
return func(*args, **kwargs)
except RuntimeError as err: