Feb 13, 2025

SSH Config Pro Tip

Stop typing long SSH commands! Use ~/.ssh/config:

Host prod-server
    HostName 192.168.1.100
    User deploy
    Port 2222
    IdentityFile ~/.ssh/prod_key
    ForwardAgent yes

Host dev-*
    User developer
    Port 22
    IdentityFile ~/.ssh/dev_key

Now just type: ssh prod-server or ssh dev-anything

Host frontend-github
    HostName github.com
    User git
    IdentityFile ~/.ssh/ssh-frontend
    IdentitiesOnly yes

git clone git@frontend-github:repo_link.git # replace github.com with frontend-github after key is added.

Docker System Cleanup

Quick commands to clean up Docker system resources:

# Remove all stopped containers
docker container prune -f

# Remove unused images
docker image prune -a -f

# Remove unused volumes
docker volume prune -f

# Nuclear option - clean everything
docker system prune -a --volumes -f

Always be careful with the nuclear option in production!

Jan 13, 2025

Bash prompt colors

🎨 Bash Prompt in 10 Colors#

Color NameANSI CodePrompt Line
Red0;31export PS1='\[\e[0;31m\]\u@myhost:\w\$ \[\e[0m\]'
Green0;32export PS1='\[\e[0;32m\]\u@myhost:\w\$ \[\e[0m\]'
Yellow0;33export PS1='\[\e[0;33m\]\u@myhost:\w\$ \[\e[0m\]'
Blue0;34export PS1='\[\e[0;34m\]\u@myhost:\w\$ \[\e[0m\]'
Magenta0;35export PS1='\[\e[0;35m\]\u@myhost:\w\$ \[\e[0m\]'
Cyan0;36export PS1='\[\e[0;36m\]\u@myhost:\w\$ \[\e[0m\]'
White0;37export PS1='\[\e[0;37m\]\u@myhost:\w\$ \[\e[0m\]'
Bright Red1;31export PS1='\[\e[1;31m\]\u@myhost:\w\$ \[\e[0m\]'
Bright Green1;32export PS1='\[\e[1;32m\]\u@myhost:\w\$ \[\e[0m\]'
Bright Blue1;34export PS1='\[\e[1;34m\]\u@myhost:\w\$ \[\e[0m\]'

Jan 12, 2025

Python One-Liners I Love

Python one-liners :

# Start a simple HTTP server
python -m http.server 8000

# Pretty print JSON
python -m json.tool file.json

# Check if port is open
python -c "import socket; print(socket.create_connection(('localhost', 8080)))"

# Generate random password
python -c "import secrets, string; print(''.join(secrets.choice(string.ascii_letters + string.digits) for _ in range(12)))"
Jan 11, 2025

Monitoring Philosophy

Been thinking about monitoring lately…

Good monitoring tells you:

  • What happened
  • When it happened
  • Why it might have happened

Great monitoring tells you:

  • What’s about to happen
  • What to do about it
  • How to prevent it next time

The goal isn’t to monitor everything. It’s to monitor the right things that help you make decisions.