Skip to content

Instantly share code, notes, and snippets.

View shollingsworth's full-sized avatar

Steven Hollingsworth shollingsworth

View GitHub Profile
@shollingsworth
shollingsworth / common_strings_multiple_files.py
Created July 13, 2022 00:42
Find common strings in multiple files
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Find common strings in multiple files."""
import argparse
from io import BytesIO
from pathlib import Path
import tokenize
def _itertokens(file: Path):
@shollingsworth
shollingsworth / all_git_files_in_history.sh
Created July 8, 2022 23:39
list all files in git history
git log --pretty=format: --name-only --diff-filter=A
@shollingsworth
shollingsworth / box.go
Created June 26, 2022 18:04
example of using golang box to encrypt / decrypt
package crypt
import (
crypto_rand "crypto/rand"
"encoding/hex"
"io"
"golang.org/x/crypto/nacl/box"
)
@shollingsworth
shollingsworth / aws_log_dump.py
Created June 17, 2022 04:32
Dump AWS logs entries by in timestamp range
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Dump AWS logs entries by in timestamp range"""
import argparse
from datetime import datetime
import logging
import json
import boto3
@shollingsworth
shollingsworth / open_api_typescript_generator.sh
Created June 17, 2022 00:33
generate typescript openapi library from openapi json file via docker command
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
DIR="$(dirname "$(readlink -f "$0")")"
GENERATED_DEST="${DIR}/frontend/src/lib/generatedapi"
OPENAPI_FILE="${DIR}/openapi.json"
test -d "${GENERATED_DEST}" || rm -rfv "${GENERATED_DEST}"
mkdir -p "${GENERATED_DEST}"
@shollingsworth
shollingsworth / pathsearch.py
Last active June 16, 2022 18:42
Recursively search for a file in a directory tree.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Recursively search for a file in a directory tree.
"""
import argparse
from pathlib import Path
def iter_parents(path: Path, args):
"""Iterate parents."""
@shollingsworth
shollingsworth / aws_sso_url_generator.py
Created June 10, 2022 03:39
Generate a list of AWS SSO urls you can open in your browser. Fzf Usage: ./aws_sso_url_generator.py | fzf | awk '{print $NF}' | xargs google-chrome
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Generate a list of AWS SSO urls you can open in your browser.
Fzf Usage:
./aws_sso_url_generator.py | fzf | awk '{print $NF}' | xargs google-chrome
"""
import asyncio
@shollingsworth
shollingsworth / aws_ssm_ssh_less_connection.md
Created May 12, 2022 16:59
general guide to get a basion no ssh host running on an EC2 instance

~/.ssh/config

Host aws-sshless-basion
    Hostname i-xxxxxxxxxxxx
    IdentityFile ~/.ssh/ssh_key
    ProxyCommand sh -c "aws ssm start-session --profile aws-profile --region us-east-2 --target %h --document-name AWS-StartSSHSession --parameters 'portNumber=%p'"

Required Software

@shollingsworth
shollingsworth / gen_terraform_ssm_kms_secret.sh
Last active May 11, 2022 12:18
generate secret value via kms and reference the secret in terraform
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
key_alias="alias/github-barracuda-internal"
param_name="supersecret"
secret=$(openssl rand -hex 256 | tr -d '\n' | base64 -w 0)
arg="${1:-}"
test "${arg}" && secret="$(echo "${arg}" | base64 -w 0)"
@shollingsworth
shollingsworth / cloudfront_frontend_s3_deploy_example.sh
Created May 11, 2022 11:58
sync frontend files to cloudfront enabled s3 bucket and invalidate cache
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
TAG="cf-frontend:latest"
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BUCKET="cf-bucket"
CF_DIST_ID="d-xxxxxxxxxxxx"
FRONTEND_DIR="${DIR}/../frontend"
pushd "${FRONTEND_DIR}"