nvim commands
Multi-line change
C-q # after rip-grep
:cdo %s/old/new/g # apply the regex accross all the quick fixlist
Home{blogsnippetsgalleryprojects} ;
Multi-line change
C-q # after rip-grep
:cdo %s/old/new/g # apply the regex accross all the quick fixlist
Context & Namespace
k config get-contexts # List all contexts
k config current-context # Show current context
Pods
k exec -it pod_name -c container_name -n namespace -- bash # Exec into a container shell
k logs pod_name -c container_name -n namespace # View logs for container
k logs --previous pod_name -c container_name -n namespace # View logs from previous crash
k logs pod_name --all-containers -n namespace # View logs from all containers
k top po pod_name --containers -n namespace # Show CPU & memory usage per container
k delete po pod_name -n namespace # Delete pod
Deployments
k rollout restart deploy deploy_name -n namespace # Restart a deployment
HPA & Events
k describe hpa hpa_name -n namespace # Describe HPA details
k get ev --field-selector involvedObject.name=obj_name -n namespace # Get events for specific object
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.
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!
Color Name | ANSI Code | Prompt Line |
---|---|---|
Red | 0;31 | export PS1='\[\e[0;31m\]\u@myhost:\w\$ \[\e[0m\]' |
Green | 0;32 | export PS1='\[\e[0;32m\]\u@myhost:\w\$ \[\e[0m\]' |
Yellow | 0;33 | export PS1='\[\e[0;33m\]\u@myhost:\w\$ \[\e[0m\]' |
Blue | 0;34 | export PS1='\[\e[0;34m\]\u@myhost:\w\$ \[\e[0m\]' |
Magenta | 0;35 | export PS1='\[\e[0;35m\]\u@myhost:\w\$ \[\e[0m\]' |
Cyan | 0;36 | export PS1='\[\e[0;36m\]\u@myhost:\w\$ \[\e[0m\]' |
White | 0;37 | export PS1='\[\e[0;37m\]\u@myhost:\w\$ \[\e[0m\]' |
Bright Red | 1;31 | export PS1='\[\e[1;31m\]\u@myhost:\w\$ \[\e[0m\]' |
Bright Green | 1;32 | export PS1='\[\e[1;32m\]\u@myhost:\w\$ \[\e[0m\]' |
Bright Blue | 1;34 | export PS1='\[\e[1;34m\]\u@myhost:\w\$ \[\e[0m\]' |
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)))"
Been thinking about monitoring lately…
Good monitoring tells you:
Great monitoring tells you:
The goal isn’t to monitor everything. It’s to monitor the right things that help you make decisions.