Skip to content

Instantly share code, notes, and snippets.

@mijdavis2
mijdavis2 / pyproject.toml
Created November 2, 2022 13:02
Poetry pre-commit poetry-lock triage poetry.toml
[tool.poetry]
name = "***"
version = "0.1.0"
description = ""
authors = ["mijdavis2 <***>"]
[tool.poetry.dependencies]
python = "3.8.10"
selenium = "3.141.0"
@mijdavis2
mijdavis2 / get_route53_record_set.sh
Created October 13, 2022 16:11
Get info on a route53 record set
aws route53 list-resource-record-sets --hosted-zone-id SOME_ZONE_ID --output json | jq '.ResourceRecordSets[] | select(.Name | startswith("some.example.com"))'
@mijdavis2
mijdavis2 / browse_runtime_lambdas.sh
Created December 3, 2021 18:45
AWS lambda runtime discovery command
#!/bin/bash
# Helpful for finding lambdas that are using an old runtime, etc.
RUNTIME=node
ARN_SUFFIX=etl
aws lambda list-functions --region us-west-2 | \
jq '.Functions[] | select(.Runtime | startswith("${RUNTIME}")) | select (.FunctionArn | endswith("${ARN_SUFFIX}")) | .FunctionName'
@mijdavis2
mijdavis2 / dict_to_obj.py
Created August 19, 2021 12:06
Convert dict to js style object in Python 3
"""
Not actually sure when this would be a good idea,
but had the idea when porting some js/node to python.
Inspired by https://stackoverflow.com/questions/6578986/how-to-convert-json-data-into-a-python-object
"""
import json
from types import SimpleNamespace
@mijdavis2
mijdavis2 / pre-commit
Last active June 2, 2021 21:18 — forked from jcromartie/pre-commit
Git pre-commit hook to help stay up-to-date with master
#!/usr/bin/env bash
# hook to enforce that current branch is up-to-date with latest
# changes from master before committing
# put me in .git/hooks and make me executable
# the output of rev-list in the following test will be empty if there
# are no commits in master that aren't in the current branch
@mijdavis2
mijdavis2 / get-aws-windows-password.fish
Created May 22, 2021 14:35
Get an AWS Windows EC2 password from a private IP
#!/usr/bin/env fish
# inputs: AWS_PROFILE, IP, PATH_TO_PRIV_KEY
function get-aws-windows-password
set instance_id (aws --profile $argv[1] ec2 describe-instances --filter Name=private-ip-address,Values=$argv[2] --query 'Reservations[].Instances[].InstanceId' --output text)
echo "Instance ID: $instance_id"
set passwd (aws --profile $argv[1] ec2 get-password-data --instance-id $instance_id --priv-launch-key $argv[3] --query 'PasswordData' --output text)
echo "Password: $passwd"
end
@mijdavis2
mijdavis2 / clone-repos.sh
Last active May 22, 2021 14:14
Clone all repos from org or user via gh cli (GitHub cli)
#!/bin/bash
#
# Requires `gh` --> https://cli.github.com/
#
# Ensure you setup gh cli via `gh auth login`
# and select the `ssh` option if you are cloning private repos - much easier.
#
# Usage:
# $ ./clone-repos.sh some_org target_dir
@mijdavis2
mijdavis2 / get-aws-windows-password.sh
Created May 4, 2021 20:59
Get an AWS Windows EC2 password from a private IP
#!/bin/bash
# inputs: AWS_PROFILE, IP, PATH_TO_PRIV_KEY
instance_id="$(aws --profile $1 ec2 describe-instances --filter Name=private-ip-address,Values=$2 --query 'Reservations[].Instances[].InstanceId' --output text)"
echo "Instance ID: $instance_id"
passwd="$(aws --profile $1 ec2 get-password-data --instance-id ${instance_id} --priv-launch-key $3 --query 'PasswordData' --output text)"
@mijdavis2
mijdavis2 / fish_prompt.fish
Created March 17, 2021 21:28
My fish prompt (.config/fish/functions/fish_prompt.fish)
function fish_prompt --description 'Write out the prompt'
set -l last_status $status
if not set -q __fish_git_prompt_show_informative_status
set -g __fish_git_prompt_show_informative_status 1
end
if not set -q __fish_git_prompt_hide_untrackedfiles
set -g __fish_git_prompt_hide_untrackedfiles 1
end
if not set -q __fish_git_prompt_color_branch
set -g __fish_git_prompt_color_branch magenta --bold
@mijdavis2
mijdavis2 / .gitconfig
Last active May 22, 2021 14:15
Git config - helpful aliases
[core]
editor = vim
[alias]
reup = !git stash && git fetch && git rebase origin/master && git stash pop
au = !git add -u && git fetch >/dev/null && git diff --cached --no-ext-diff origin/master | grep --color=always 'pdb.set_trace()' -B 6
re = reset
dc = diff --cached
st = status
co = checkout