Skip to content

Instantly share code, notes, and snippets.

@rothgar
rothgar / tmate-compile.sh
Created January 19, 2017 07:03
Compile tmate on centos 7
#!/bin/bash
set -e
yum install -y epel-release
yum makecache
yum install -y @development git cmake ruby zlib-devel openssl-devel libevent-devel ncurses-devel libssh-devel msgpack-devel
git clone https://github.com/nviennot/tmate.git
@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 / 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 / streamyard-tampermonkey.js
Last active December 3, 2021 16:40
Streamyard Keyboard Shortcuts
// ==UserScript==
// @name Streamyard Keyboard Shortcuts
// @namespace http://streamyard.com
// @version 0.1
// @description Simple keyboard shortcuts for streamyard
// @author justinleegarrison@gmail.com
// @match https://streamyard.com/*
// @grant none
// @run-at document-end
// ==/UserScript==
@rothgar
rothgar / wtf.sh
Created November 29, 2017 05:19
Linux server debugging in 60 seconds
#!/bin/bash
# Taken from https://medium.com/netflix-techblog/linux-performance-analysis-in-60-000-milliseconds-accc10403c55
# initialize array
COMMANDS=('uptime')
# add systemctl command if it's installed
command -v systemctl >/dev/null && COMMANDS+=('systemctl list-units --state=failed')
# add more commands
COMMANDS+=('dmesg | tail'
'vmstat 1'
@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
# ping once per minute. Every minute for a day
ping -i 60 -c 1440 google.com | grep loss | awk -F ',' '{print $3}'
# print avg latency (ms) per hour. One ping per minute
ping -i 60 -c 60 google.com | awk '{print $8}' | sed -n '/^time/p' | awk -F '=' '{print $2}' | awk '{ sum += $1 } END { if (NR > 0) print sum / NR }'
@rothgar
rothgar / move-window-down-workspace.sh
Created January 16, 2021 00:08
Move window down workspace
#!/bin/bash
CURRENT_DESKTOP=$(wmctrl -d | grep '*' | awk '{print $1}')
wmctrl -r :ACTIVE: -t $(( ${CURRENT_DESKTOP}+1 ))
# my profile is configured for us-west-2
export AWS_DEFAULT_REGION=us-west-1
export AWS_REGION=us-east-1
aws ec2 describe-instances --query 'Reservations[].Instances[].Placement.AvailabilityZone' --output text
us-east-1c
unset AWS_REGION
aws ec2 describe-instances --query 'Reservations[].Instances[].Placement.AvailabilityZone' --output text
us-west-1c
unset AWS_DEFAULT_REGION