Skip to content

Instantly share code, notes, and snippets.

@tyzbit
tyzbit / tyzbit_hosts
Last active July 14, 2019 00:32
My personal domain blocking
127.0.0.1 usher.justin.tv
@tyzbit
tyzbit / zoom-mute-status.scpt
Created September 14, 2019 17:11
Get Zoom Mute/Unmute Status
property btnTitle : "Mute audio"
tell application "System Events" to tell application process "zoom.us"
if exists (menu item btnTitle of menu 1 of menu bar item "Meeting" of menu bar 1) then
do shell script "echo Unmuted"
else
do shell script "echo Muted"
end if
end tell
@tyzbit
tyzbit / cache-eks-token.sh
Created January 23, 2020 16:36
Cache EKS tokens for kubectl
function usage() {
echo "Usage: $0 [region] [cluster name] [role arn]"
echo "If you're not using a role, [region] and [role arn] are optional"
echo "If you just use cluster name, you need aws-iam-authenticator installed"
}
if [ -z $1 ]; then
usage
exit 1
fi
@tyzbit
tyzbit / onboard-to-k8s.sh
Created March 20, 2020 14:22
Onboard to k8s
#!/bin/bash
## Use this script to configure kubectl for an EKS cluster using a role ARN.
function usage() {
echo "Usage: $0 [Amazon Role ARN]"
}
if [[ -z $1 ]]; then
usage
exit 1
@tyzbit
tyzbit / colorify.zsh
Last active August 10, 2020 13:03
Colorify
function colorify() {
#number=$(bc <<< "$(echo ${1} | od -An -vtu1 -w100000000 | tr -d ' ') % 28 + 1")
#number=$(bc <<< "ibase=16; $(echo ${1} | md5sum | awk '{print $1}'|tr '[[:lower:]]' '[[:upper:]]')" 2> /dev/null)
# md5sum is acceptable here because we don't need a strong hashing algo at all
# we just want the property of hashing algos that a given input always means the same output
hex=$(echo ${1} | md5sum | awk '{print $1}'|tr '[[:lower:]]' '[[:upper:]]')
# removing characters is done because zsh complains about the size of the number
# even though we do this, there's still more than enough 'randomness'
# doing this also ensures the value is positive which is cool
@tyzbit
tyzbit / rprompt.zsh
Last active April 15, 2023 23:27
zsh RPROMPT with execution time and current time on the right hand side
# refreshes the prompt every $TMOUT seconds
TMOUT=15
function preexec() {
timer=$(($(date +%s%0N)/1000000))
}
function precmd() {
if [ $timer ]; then
now=$(($(date +%s%0N)/1000000))
@tyzbit
tyzbit / twitcher.cgi
Created September 29, 2020 12:43
A CGI script to show the top chat messages from IRC logs
#!/bin/bash
twitchroot="/home/eggdrop/twitcher/logs/"
alllogs=$(echo $twitchroot"*")
logpath="http://qtosw.com/pubfiles/twitchlogs/?C=M;O=D"
echo -e "Content-type: text/html; charset=utf-8\n"
echo "<html><head>"
echo "<meta charset=utf-8>"
echo "<link rel=\"stylesheet\" href=\"style.css\" />"
echo "</head><body>"
#initialize what we have to work with
@tyzbit
tyzbit / download-video-from-clipboard.sh
Last active April 27, 2022 02:13
Download a video from a URL in clipboard automatically (bind to keyboard shortcut) (Mac/Linux)
#!/bin/bash
dir="$HOME/Videos"
opts="--add-metadata --no-mtime"
if [ -f /usr/local/bin/youtube-dl ]; then
youtube_dl="/usr/local/bin/youtube-dl"
else
youtube_dl="$(which youtube-dl)"
fi
@tyzbit
tyzbit / bootstrap-ubuntu.sh
Last active July 17, 2023 14:03
bootstrap-ubuntu-server
#!/bin/bash
## Edit sudoers (add "NOPASSWD:" to the sudo line before ALL)
## Add optional: true to netplan and apply
## Add Google Kubernetes key
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys B53DC80D13EDEF05
# Install Docker
@tyzbit
tyzbit / linkerd_log_output.md
Last active March 4, 2021 01:21
linkerd log ouput
Timestamp Container Name Pod Name Message
2021-03-03 17:38:00 destination linkerd-destination-77d95c4b9-mx54s time="2021-03-03T17:38:00Z" level=info msg="Stopping watch on endpoint [default/nextcloud-cache:6379]" addr=":8086" component=endpoints-watcher
2021-03-03 17:38:00 destination linkerd-destination-77d95c4b9-mx54s time="2021-03-03T17:38:00Z" level=info msg="Stopping watch on profile default/nextcloud-cache.default.svc.cluster.local" addr=":8086" compo