Skip to content

Instantly share code, notes, and snippets.

View esweeney-cg's full-sized avatar

Ed Sweeney esweeney-cg

View GitHub Profile
@esweeney-cg
esweeney-cg / aa.sh
Created October 10, 2022 19:52
associative array via temp fs in bash
#
# BEGIN all purpose associative array via temp fs
#
prefix=$(basename -- "$0")
mapdir=$(mktemp -dt ${prefix})
trap 'rm -r ${mapdir}' EXIT
put() {
[ "$#" != 3 ] && exit 1
mapname=$1; key=$2; value=$3
[ -d "${mapdir}/${mapname}" ] || mkdir "${mapdir}/${mapname}"
@esweeney-cg
esweeney-cg / decode_pem.md
Created November 23, 2022 17:39
decode pem
openssl x509 -in certificate.crt -text -noout


@esweeney-cg
esweeney-cg / chatGPT_transscript_assess.md
Last active January 11, 2023 17:11
chatGPT and transcript assessments

chatGPT and transcript assessments

  1. create a chat session with https://chat.openai.com/chat
  2. paste into the chat this transcript, asking it how could the agent could have done better.
Here is a conversation between a call center agent and  a customer transcribed by automatic speech recognition: 

"agent  - Thank you for calling member services my name is Amber can I have your member ID and Social Security number to validate your . account
customer  - , um sure I thought I just put that near IB our system but let me take it up . again
@esweeney-cg
esweeney-cg / cp.md
Last active March 14, 2023 15:57
copy file from pod to local

copy file from pod to local

kubectl cp <pod-name>:<fully-qualified-file-name> /<path-to-your-file>/<file-name> -c <container-name>

copy file from local to pod

@esweeney-cg
esweeney-cg / k9s.txt
Created March 8, 2023 20:44 — forked from BigNerd/k9s.txt
K9s column descriptions
View: Pods(<namespace>)[number of pods listed]
NAME pod name
READY number of pods in ready state / number of pods to be in ready state
RESTARTS number of times the pod has been restarted so far
STATUS state of the pod life cycle, such as Running | ... | Completed
CPU current CPU usage, unit is milli-vCPU
MEM current main memory usage, unit is MiB
%CPU/R current CPU usage as a percentage of what has been requested by the pod
%MEM/R current main memory usage as a percentage of what has been requested by the pod
@esweeney-cg
esweeney-cg / opensslpem.sh
Created April 14, 2023 18:14
openssl pem file decoder
openssl x509 -in certificate.crt -text -noout
@esweeney-cg
esweeney-cg / tdump-rpt.py
Created April 26, 2023 14:47
create a cpu score for threads from a thread dump
#!/usr/bin/env python3
import sys
import re
from collections import defaultdict
def parse_thread_dump(content):
thread_pattern =\
r'"(.*?)"\s+#\d+\s+.*?cpu=(.*?)ms\s+elapsed=(.*?)s\s+tid=.*'
@esweeney-cg
esweeney-cg / revert.md
Last active June 1, 2023 20:04
git revert

when reverting multiple commits from main where: A <- B <- C <- D and D is the most recent

git checkout -b my-revert-branch
git revert --no-commit D
git revert --no-commit C
@esweeney-cg
esweeney-cg / startq_day.sh
Last active July 11, 2023 23:58
bash script to scrape cloudwtch logs for logins
#!/usr/bin/env bash
# Check if username argument is passed
if [ -z "$1" ]
then
echo "No argument supplied. Please provide username as an argument."
exit 1
fi
username="$1" # The username is taken from the first command line argument
@esweeney-cg
esweeney-cg / fetch_cloudwatch_hours.sh
Created July 12, 2023 00:11
get the prev days logins using a particular role
#!/usr/bin/env bash
# Check if username argument is passed
if [ -z "$1" ]
then
echo "No argument supplied. Please provide username as an argument."
exit 1
fi
username="$1" # The username is taken from the first command line argument