Skip to content

Instantly share code, notes, and snippets.

@tyzbit
tyzbit / .zshrc
Created November 10, 2021 18:02
Kubernetes TCP proxy
function kubeproxy() {
setopt local_traps
pod_name="socat-$(whoami)"
if [[ "${2}x" == "x" ]]; then
echo "Usage: kubeproxy [Hostname] [Port]"
return 0
fi
if kubectl run --restart=Never --image=alpine/socat $pod_name -- -d -d tcp-listen:$2,fork,reuseaddr tcp-connect:$1:$2; then
while [[ $(kubectl get pod $pod_name -o json | jq -r '.status.phase') != "Running" ]]; do
sleep 0.1
@tyzbit
tyzbit / query.md
Last active October 21, 2021 13:52
New Relic Days until k8s Volume is full (reaches 99%)
FROM K8sVolumeSample 
SELECT min(fsAvailableBytes / 1024 / 1024 / 1024) as 'GiB Free',
       clamp_min(
         (100 - 1 - stddev(fsUsedPercent) - max(fsUsedPercent))
           /
         clamp_min(
           deriv(fsUsedPercent, 1 days)
         ,0.00000313)
 ,0) as 'Days until full'
192.168.206.67 - - [28/Sep/2021:06:50:10 +0000] "GET /v1 HTTP/1.1" 200 3871 "" "Go-http-client/1.1"
192.168.206.67 - - [28/Sep/2021:06:50:10 +0000] "GET /v1 HTTP/1.1" 200 3871 "" "Go-http-client/1.1"
192.168.206.67 - - [28/Sep/2021:06:50:10 +0000] "GET /v1 HTTP/1.1" 200 3871 "" "Go-http-client/1.1"
192.168.206.67 - - [28/Sep/2021:06:50:10 +0000] "GET /v1 HTTP/1.1" 200 3871 "" "Go-http-client/1.1"
192.168.206.67 - - [28/Sep/2021:06:50:10 +0000] "GET /v1 HTTP/1.1" 200 3871 "" "Go-http-client/1.1"
fatal error: concurrent map writes
/usr/local/go/src/runtime/panic.go:1114 +0x72 fp=0xc001edd760 sp=0xc001edd730 pc=0x4348e2
runtime.throw(0x1b8963e, 0x15)
goroutine 1151041 [running]:
@tyzbit
tyzbit / configuration.yaml
Created August 2, 2021 20:23
Home Assistant KP115 config
tplink:
discovery: false
switch:
- host: 192.168.1.10
- host: 192.168.1.11
- host: 192.168.1.12
- host: 192.168.1.13
sensor:
- platform: template

|Timestamp |Container Name |Host |Pod Name |Message

@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
@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 / 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 / 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 / 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))