Skip to content

Instantly share code, notes, and snippets.

@rothgar
rothgar / k8s.zsh
Created September 28, 2024 05:24
Useful kubectl shell functions
ealias kg='k get '
ealias kgp='k get po '
ealias kgn='k get no '
ealias kgd='k get deploy '
ealias krmp='k delete po '
ealias kdp='k describe po '
ealias uek='unset KUBECONFIG'
ealias uekns='unset KUBE_NAMESPACE'
# export kubeconfig
@rothgar
rothgar / talos-root.sh
Created April 10, 2024 23:57
Get a "host" shell on Talos Linux
#!/usr/bin/env bash
if ! command -v kubectl &>/dev/null; then
echo "kubectl not be found"
exit 1
fi
if ! command -v fzf &>/dev/null; then
echo "fzf not be found"
exit 1
fi
@rothgar
rothgar / tiktok-download
Created April 7, 2024 06:08
Download your tiktok videos with nushell
#!/usr/bin/env nu
# download your tiktok archive data and extract the user_data.json file
let data = (open user_data.json)
mkdir archive
# loop through videos
$data.Video.Videos.VideoList | each { |video|
# create a file name tt_$video.Date (remove spaces)
@rothgar
rothgar / get-ogimage
Created July 10, 2023 21:30
Download the og:image from a URL
#!/bin/bash
set -eo pipefail
if [ $# -eq 0 ]; then
echo "Please provide a URL"
echo "$(basename $0) URL"
exit 1
fi
@rothgar
rothgar / apt.ish
Created March 18, 2023 06:53
Download and convert an ubuntu deb package to rpm
#!/bin/bash
set -eo pipefail
CONTAINER=$(docker ps -a | grep ubuntu | awk '{print $1}')
if [ "${CONTAINER}" != "" ]; then
docker start $CONTAINER
else
CONTAINER=$(docker run -d --name ubuntu -e DEBIAN_FRONTEND=noninteractive public.ecr.aws/ubuntu/ubuntu:20.04 sleep 60m)
@rothgar
rothgar / git-ops
Created January 11, 2023 16:43
Local development git ops
#!/bin/bash
set -oe pipefail
if [ -d .git ]
then
while true
do
inotifywait -r -e close_write ${PWD}
@rothgar
rothgar / curl-to-bash.sh
Last active August 25, 2022 23:44
curl-to-bash
# use pup for HTML parsing
# https://github.com/ericchiang/pup
#
# remove lines that start with < (html formatted)
# or # comments
curl-to-bash() {
curl -s "${1}" \
| pup -p code \
| grep -v -E '^[[:space:]]*#|^[[:space:]]*<'
@rothgar
rothgar / code.py
Created April 29, 2022 04:57
CirCuitPython green square fall
import board
from time import sleep
import displayio
from adafruit_display_shapes.rect import Rect
from adafruit_matrixportal.matrix import Matrix
# --- Display setup ---
matrix = Matrix(bit_depth=6, width=32, height=32)
display = matrix.display
@rothgar
rothgar / create-workloads.sh
Created December 15, 2021 19:46
Create random Kubernetes deployments
#!/bin/bash
set -o pipefail
# total amount of pods to create
TOTAL=${1:-500}
# deploy size
export BATCH=${2:-100}
export NAMESPACE=${KUBE_NAMESPACE:-default}
@rothgar
rothgar / alias
Created July 2, 2021 20:58
Infinidash command
# put this in $HOME/.aws/cli/alias
[toplevel]
infinidash = !f() {
if [ -z "$1" ]; then
cat $HOME/.aws/help.txt
elif test "$1" = "deploy"; then
curl -s -L https://raw.githubusercontent.com/keroserene/rickrollrc/master/roll.sh | bash
elif test "$1" = "help"; then
cat $HOME/.aws/help.txt