snippets

cURL snippets

Send a POST request curl -X POST https://yourdomain.com -d @data.txt @ is necessary. Enable redirecting curl -L yourdomain.com Ignore TLS certificate error in cURL Frequently used in test environment. curl --insecure https://yourdomain.com # or curl -k https://yourdomain.com Download a content which includes redirect curl -L yourdomain.com --output myfilename IPv6 Force curl to DNS as IPv6. curl -6 mydomain.com # From man # -6, --ipv6 Resolve names to IPv6 addresses Show header only curl -sS -I https://youdomain.

HTML, JavaScript snippets

Simple input form <!DOCTYPE html> <html> <head> <title>The name at tab</title> </head> <body> <h1>First section - h1</h1> <p>First paragraph</p> <form action="/action_page.php"> <label for="fname">First input:</label> <input type="text" id="first_input" name="input_1"><br><br> <label for="lname">Second input:</label> <input type="text" id="second_input" name="input_2"><br><br> <input type="submit" value="Text on button"> </form> </body> </html> You should write action_page.php further. When tou click the button, it passes to /action_page.php?input_1=fistbox&input_2=secondbox. Add text script <p id="p1"></p> <script> let p_element = document.getElementById("p1"); p_element.innerHTML = "Sample text" </script> TypeScript in browser Note: it doesn’t work for me and returns the error below.

SSH snippets

Local Port forwarding ssh -L 50088:remote2.myserver.com:80 atlex@remote1.myserver.com SSH portforwarding in backgraound ssh -fNT -L 8888:localhost:8888 myuser@mydomain.com official mannual -f: Requests ssh to go to background just before command execution. -N: Do not execute a remote command. This is useful for just forwarding ports (protocol version 2 only). -T: Disable pseudo-tty allocation. Config file Host github.com User git Port 22 Hostname github.com IdentityFile ~/.ssh/id_ecdsa TCPKeepAlive yes IdentitiesOnly yes Host myserver*.com User atlex00 Host gcp User atlex00 Hostname 192.

Snippets of Git

Completely delete submodule from the repository Here is the graceful memo. I copy&paste it to here. To remove a submodule you need to: Delete the relevant section from the .gitmodules file. Stage the .gitmodules changes git add .gitmodules Delete the relevant section from .git/config. Run git rm –cached path_to_submodule (no trailing slash). Run rm -rf .git/modules/path_to_submodule (no trailing slash). Commit git commit -m “Removed submodule ” Delete the now untracked submodule files rm -rf path_to_submodule Do you forgot to clone with --recursive ?

Tips for Ansible

Before installing via pip (in WSL) sudo apt install libffi-dev Debugging step by step Run a playbook with option --step. Pipe (|) in variable It is called “filter”. https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#product-filters when, and, or, not https://docs.ansible.com/ansible/latest/user_guide/playbooks_conditionals.html Group restriction If you have a large amount of servers in inventories, -l option can restrict the target of playbook. -l Server_group_name -l FQDN What ever the system use systemd or initd When your environment has different OSs, systemd module doesn’t work sometimes.