Skip to content

Instantly share code, notes, and snippets.

def reverse_5(s: str) -> str:
return s[::-1]
import boto3
def lambda_handler(context, event):
sts = boto3.client('sts')
account_b = sts.assume_role(
RoleArn="arn:aws:iam::222222222222:role/role-on-account-b",
RoleSessionName="test_function"
)
ACCESS_KEY = account_b['Credentials']['AccessKeyId']
SECRET_KEY = account_b['Credentials']['SecretAccessKey']
boto3.client(
"sts",
region_name="eu-west-2",
endpoint_url="https://sts.eu-west-2.amazonaws.com"
)
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route("/get", methods=["GET"])
def get():
response_data = {"parameters": []}
request_args = request.args
for key in request_args:
obj = {"key": request_args.get(key), "value": request_args.getlist(key)}
response_data['parameters'].append(obj)
fields @timestamp, `annotations.authorization.k8s.io/decision`, user.username, userAgent
| sort @timestamp desc
| filter ispresent(`annotations.authorization.k8s.io/decision`) and `annotations.authorization.k8s.io/decision` != "allow"
@njgibbon
njgibbon / minimal_zshrc_0.sh
Last active October 6, 2025 17:30
Minimal .zshrc to output git branch name in prompt.
# ~/.zshrc
# Find and set branch name var if in git repository.
function git_branch_name()
{
branch=$(git symbolic-ref HEAD 2> /dev/null | awk 'BEGIN{FS="/"} {print $NF}')
if [[ $branch == "" ]];
then
:
else
@njgibbon
njgibbon / minimal_zshrc_1.sh
Last active August 9, 2020 17:31
Minimal .zshrc to output git branch name in prompt using vcs_info.
# ~/.zshrc
# Enabling and setting git info var to be used in prompt config.
autoload -Uz vcs_info
zstyle ':vcs_info:*' enable git svn
# This line obtains information from the vcs.
zstyle ':vcs_info:git*' formats "- (%b) "
precmd() {
vcs_info
}
@njgibbon
njgibbon / host-docker-internal-demo.yaml
Created September 29, 2020 21:55
host-docker-internal-demo.yaml
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
name: host-docker-internal-demo
spec:
containers:
- image: alpine
name: alpine
command: ["sh"]
@njgibbon
njgibbon / hello_world.py
Created October 11, 2020 14:53
Python Hello World
print("Hello World")
@njgibbon
njgibbon / remove_k8s_ns_finalizer.sh
Created January 27, 2021 19:37
Force removal of Kubernetes Namespace Finalizer(s).
set -eou pipefail
namespace=$1
if [ -z "$namespace" ]
then
echo "This script requires a namespace argument input. None found. Exiting."
exit 1
fi
kubectl get namespace $namespace -o json | jq '.spec = {"finalizers":[]}' > rknf_tmp.json
kubectl proxy &
sleep 5