Skip to content

Instantly share code, notes, and snippets.

unbind C-b
set -g prefix C-a
# Mouse support
set-option -g mouse on
set -g @scroll-speed-num-lines-per-scroll "1"
# make tmux display things in 256 colors
set -g default-terminal "screen-256color"
if [[ $(spotifycli --status) ]]; then
SONG=$(spotifycli --song)
SPOTIFY_WINDOWD_ID=$(wmctrl -l | grep -i "$SONG" | head -1 | awk '{ print $1 }')
echo "<img>/home/yzdann/.scripts/spotify.png</img><click>wmctrl -i -a $SPOTIFY_WINDOWD_ID</click>"
else
echo "<img>/home/yzdann/.scripts/spotify-gray.png</img><click>spotify %U</click>"
fi
SPOTIFY_WINDOWD_ID=$(wmctrl -l | grep -i "spotify free" | head -1 | awk '{ print $1 }')
if [[ "$SPOTIFY_WINDOWD_ID" ]]; then
wmctrl -i -a "$SPOTIFY_WINDOWD_ID"
else
spotify %U
fi
@yzdann
yzdann / is-wg-up.sh
Last active November 30, 2020 09:34
WG="wgx"
WG_UP=$(ip -o link show | awk -F': ' '{print $2}'| grep $WG)
if [[ "$WG_UP" ]]; then
echo "<img>/home/yzdann/.scripts/wg26.png</img><click>konsole -e wg-quick down $WG</click>"
else
echo "<img>/home/yzdann/.scripts/wg26-gray.png</img><click>konsole -e wg-quick up $WG</click>"
fi
# genmon bash /home/yzdann/.scripts/wg.sh
TMUX_WINDOW_ID=$(wmctrl -l | grep -i tmux | grep -i konsole | awk "/$rx/"'{print $1}' | head -1 )
TMUX_CURRENT_FIRST_SESSION=$(tmux list-session | cut -d':' -f1 | head -1)
echo $TMUX_WINDOW_ID
# activate the window terminal with tmux if existed
if [[ ! -z "$TMUX_WINDOW_ID" ]]; then
wmctrl -i -a $TMUX_WINDOW_ID
else
# attach to current session
@yzdann
yzdann / latency.txt
Created November 26, 2020 22:13 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
If one of the servers needs to be temporarily removed from the load‑balancing rotation, it can be marked with the down
server backend3.example.com down;
With this configuration of weights, out of every 6 requests, 5 are sent to backend1.example.com and 1 to backend2.example.com.
server backend1.example.com weight=5;
server backend2.example.com;
location /resources {
mv /etc/haproxy/haproxy.cfg{,.original}