Skip to content

Instantly share code, notes, and snippets.

@sathed
sathed / LOADTEST.md
Last active February 18, 2025 16:40
Installation instructions for 'ab' and 'hey' for both Mac and Windows.

Running Load Tests

Once installed, you can run a test against your load balancer or web server:

Using Apache Benchmark (ab):

ab -n 500000 -c 500 http://your-load-balancer-dns-name/

Using hey:

@sathed
sathed / zsh
Created February 20, 2020 22:00
Git branch in (zsh) terminal on Mac.
function parse_git_branch() {
git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/[\1]/p'
}
COLOR_DEF=$'\e[0m'
COLOR_USR=$'\e[38;5;243m'
COLOR_DIR=$'\e[38;5;197m'
COLOR_GIT=$'\e[38;5;39m'
setopt PROMPT_SUBST
export PROMPT='${COLOR_USR}%n ${COLOR_DIR}%~ ${COLOR_GIT}$(parse_git_branch)${COLOR_DEF} $ '
@sathed
sathed / skeleton.sh
Last active February 20, 2020 15:25
Skeleton shell script
#!/usr/bin/bash
# Clone
# Build
# Deploy
# Notes:
# # Save the shell script with a '.sh' extension
@sathed
sathed / .nanorc
Created November 21, 2019 16:11
My nanorc file.
set linenumbers
set tabsize 4
set autoindent
set tabstospaces
@sathed
sathed / aws_cli_filters
Created November 8, 2019 20:19
AWS CLI filters using tags
# Usage: --filters "Name=string,Values=string,string..."
# Example using `tag` key-value pairs:
aws ec2 describe-instances --filters "Name=tag:<tag_name>,Values=<value1>,<value2>..."
# Example using `tag-key` name:
# Note: This only looks at the key name(s), not the value of the key(s).
aws ec2 describe-instances --filters "Name=tag-key,Values=<tag-key1>,<tag-key2>..."
@sathed
sathed / curl_status_code.sh
Last active October 29, 2019 20:19
Use curl to retrieve only the status code.
#!/bin/bash
# For CA certs.
curl -so /dev/null -w "%{http_code}" https://google.com/
# For self-signed certs:
curl --insecure -so /dev/null -w "%{http_code}" https://somesite.com/
@sathed
sathed / git_revert.txt
Created October 24, 2019 16:49
Revert commits on published branches
# Range of commits
# git revert --no-edit <first_bad_commit_hash>..<last_bad_commit_hash>
git revert --no-edit 1abeb478e11..e272b5a3680
# Single commit
# git revert --no-edit <bad_commit_hash>
git refert --no-edit e272b5a3680
@sathed
sathed / promql_dst_offset
Last active October 4, 2019 15:36
Timezone Offset for Prometheus (Mountain Time/US)
# The following will create an DST offset in the US. Obviously, if you're in an area that doesn't
# observe DST (Arizona, etc.), this doesn't apply. To tweak it for your specific TZ, change the last value to
# your UTC offset during the summer months. A chart is below. I threw this together pretty quick,
# so it may need a bit of tweaking. It's a modified version of the PromQL found on Medium, here:
# https://link.medium.com/vcfRGNuYv0
# 4 - Eastern
# 5 - Central
# 6 - Mountain
# 7 - Pacific
# Use root/example as user/password credentials
version: '3.1'
services:
mongo:
image: mongo
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: root
@sathed
sathed / process_status.ps1
Last active September 6, 2018 19:19
Get the state of a Windows process.
#Using Notepad as an example.
$target = "notepad"
#Get the process
$process = Get-Process -Name $target -ErrorAction SilentlyContinue
#Get the execution state of the thread.
$threads=$process.Threads
$threads | select Id,ThreadState,WaitReason