Skip to content

Instantly share code, notes, and snippets.

View shollingsworth's full-sized avatar

Steven Hollingsworth shollingsworth

  • SkySafe.io
  • United States
  • X @_stevo
View GitHub Profile
@shollingsworth
shollingsworth / postfix_iter_queue_delete.sh
Last active September 11, 2023 16:49
iterate through postfix queue and selectively delete entries
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
mapfile -t ids < <(mailq | grep -E '^[0-9A-F]' | awk '{print $1}')
for id in "${ids[@]}"; do
postcat -q "${id}" | less
echo "Remove? (y)"
read -r RM
@shollingsworth
shollingsworth / getuserdata.sh
Created June 29, 2023 20:27
retrieve aws ec2 instance userdata script
#!/usr/bin/env bash
curl -q http://169.254.169.254/latest/user-data
@shollingsworth
shollingsworth / dockerclean.sh
Created May 10, 2023 16:54
run through all the commands to prune unused resources in docker
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
# prune stale containers/images
docker image prune -f
# prune stale volumes
docker volume prune -f
@shollingsworth
shollingsworth / ghstars.sh
Created May 9, 2023 18:07
output all of a users github starred repositories using gh api graphql call
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
# get all my starred repos
getstars() {
query="query(\$endCursor: String) {
viewer {
starredRepositories(first: 100, after: \$endCursor) {
@shollingsworth
shollingsworth / mtr.sh
Created May 9, 2023 17:46
realtime traceroute like utility to troubleshoot network connection issues
# normal mtr with icmp
mtr $1
# tcp
mtr -T -P 443 $1
@shollingsworth
shollingsworth / awssso.sh
Created May 9, 2023 17:10
bash source file for using yawsso and aws sso login to set your current environment to make aws sso transparent with whatever tooling you are using
#!/usr/bin/env bash
# install yawsso https://github.com/victorskl/yawsso
# make sure aws cli is installed
# call with `sso`
################################################################################
# when calling these functions make sure AWS_PROFILE is set
################################################################################
@shollingsworth
shollingsworth / cloudformation_stack_output.sh
Created April 28, 2023 20:06
get the cloudformation stack output by outputkey
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
key="ServiceEndpointWebsocket"
stack_name="sh-ws-demo-backend-dev"
aws cloudformation describe-stacks --stack-name "${stack_name}" \
--query "Stacks[0].Outputs[?OutputKey=='${key}'].OutputValue" \
--output text
@shollingsworth
shollingsworth / taillogs.sh
Created April 27, 2023 17:07
bash script to dynamically tail multiple AWS log groups based on prefix
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
trap "exit" INT TERM ERR
trap "kill 0" EXIT
aws logs describe-log-groups \
--log-group-name-prefix "/aws/lambda/sh-ws-demo-backend" \
--query 'logGroups[].logGroupName' \
@shollingsworth
shollingsworth / generic_issue_template.yml
Created April 13, 2023 02:25
generic github issue template goes in .github/ISSUE_TEMPLATE directory
name: Generic Issue
description: Organized way of making actionable tasks for PMs, data scientists, leads, etc.
title: "[Generic]: "
labels:
body:
- type: checkboxes
id: Terms
attributes:
label: Guidelines
description: By submitting this issue, you agree to follow our [Contributing Guidelines](https://www.contributor-covenant.org/version/2/1/code_of_conduct/).
@shollingsworth
shollingsworth / iam_githubactions.tf
Created April 5, 2023 21:07
terraform starter file to configure AWS with github actions
resource "aws_iam_openid_connect_provider" "github_actions" {
client_id_list = ["sts.amazonaws.com"]
thumbprint_list = ["6938fd4d98bab03faadb97b34396831e3780aea1"]
url = "https://token.actions.githubusercontent.com"
}
data "aws_iam_policy_document" "github_actions_assume_role_policy" {
statement {
actions = ["sts:AssumeRole"]