======================
== Code and Destroy ==
======================

Notes

Programming

This is my collection of useful recipes.

Git

Delete branch

git checkout <old_name>
git branch -m <new_name>
git push origin -u <new_name>
git push origin --delete <old_name>

MacOS

Flush DNS cache

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

Linux

Letsencrypt + Nginx redirect

sudo apt install certbot python3-certbot-nginx sudo certbot --nginx -d example.com -d www.example.com

Cert update check

sudo systemctl status certbot.timer sudo certbot renew --dry-run

Nginx config

server {
    listen 80;
    server_name www.example.com example.com;
    return 301 https://newexample.com/;
}

server {
    listen 443 ssl;
    server_name www.example.com example.com;
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf;
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
    
    return 301 https://newexample.com/;
}