Skip to content

Instantly share code, notes, and snippets.

@WesselAtWork
WesselAtWork / wiresharkpod.sh
Last active April 8, 2024 18:45
Do a ad-hoc tcpdump on a pod
#/bin/sh
kubectl --context $CTX -n $NS debug -q -i $POD --image=docker.io/alpine --target $CONTAINER -- /bin/ash -c "apk add tcpdump &>/dev/null; tcpdump -nn -w - -U -s 0 -w -" | wireshark -k -i -
# you can also use `tcpdump -U -s 0 -w -` if you want the dns names
@WesselAtWork
WesselAtWork / export_grafana_pdf.graphql.Containerfile
Last active August 27, 2025 14:37
Grafana PDF GraphQL Reporter
FROM docker.io/node:22-alpine
RUN apk --no-cache add chromium
# skips puppeteer installing chrome and points to correct binary
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
RUN addgroup pptruser && adduser -D -g pptruser -G pptruser pptruser
USER pptruser
@WesselAtWork
WesselAtWork / oras-aws-pull.sh
Created January 2, 2024 13:21
Logs In Ephemerally and then pulls [ARGS] images from ECR. Assumes all [ARGS] can use the same creds as the 1st ARG.
#!/bin/bash
URL="$1"
REGISTRY="${URL%/*}"
pre="${REGISTRY%.amazonaws.com}"
AWS_REGION="${pre##*.}"
HOME="."
export HOME
aws ecr get-login-password --region "$AWS_REGION" | oras login --username AWS --password-stdin "$REGISTRY"
printf '%s\0' "$@" | xargs -n1 --null oras pull
unset HOME
@WesselAtWork
WesselAtWork / noop-catch.sh
Created May 26, 2023 16:35
Cool noop catch on INT and TERM for traped EXIT
#!/bin/ash
trap : INT TERM
# your code here...
touch /tmp/tmpfile
trap '{ rm /tmp/tmpfile; }' EXIT
touch /tmp/otherthing
@WesselAtWork
WesselAtWork / chunked-stream.sh
Created April 14, 2023 11:34
Something I figured out to do `for every X bytes process stream`
printf '12345678910' | ( #example data (subshell might or might not be nessaray)
count=0; #init count to zero
while true; #loop forever
do {
((count++)); #increment count
head -c 2 < /dev/stdin | #take from sdin until...
ifne -n false > "test$count.txt" || exit; #...there is nothing left then exit
} done;
)
@WesselAtWork
WesselAtWork / tarfragments.sh
Last active February 22, 2023 08:02
Provides functions for the incremental building or streaming of tar archives
#!/bin/sh
#
# Provides commands for the incremental building or streaming of tar archives
# NOTICE: Do not use compression flags on the input to tarfrg!
# I am not checking you!
# Use in the pipeline instead. e.g. `tarfrg ./tmp/* | tarfrgasm | gzip > archive.tar.gz`
#######################################
@WesselAtWork
WesselAtWork / podman-application.bat
Last active January 18, 2023 10:33
This is a template to turn (most) container applications into a windows commandline app.
@echo off
echo.
podman run --rm -v "%cd%":/app -w /app -i registry.io/application:latest %*
@WesselAtWork
WesselAtWork / ecr-add-tag.sh
Last active October 19, 2022 11:31 — forked from sportebois/ecr-add-tag.sh
Add tag to a docker image in ECR via AWS CLI
#!/usr/bin/env bash
function ecr-add-tag() {
if (( $# < 3 )); then
echo "Wrong number of arguments. Usage: ecr-add-tag ECR_REPO_NAME TAG_TO_FIND TAG_TO_ADD [AWS_PROFILE] [AWS_REGION]"
return
fi
local repo_name=$1
local existing_tag=$2
local new_tag=$3