Commands
A collection of commands that are useful and I never seem to remember off the top of my head.
Curl
File Upload
curl -i -X POST -H "Content-Type: multipart/form-data" -F "file=@tanzawa.png" http://127.0.0.1:8000/files/upload
SSH
Socks Proxy
Setup a poor-man's secure tunnel and proxy traffic over ssh to a remote server. Useful when needing to access corporate networks without the benefit of a fully fledged VPN.
ssh -N -D 8080 [USER]@[SERVER_IP]
After setting up the tunnel, you need to setup your system to use the proxy. System Preferences -> Network -> Advanced -> Proxies
Tunnel
Tunnel a remote port to a local port on your machine. Useful for accessing remote ports (e.g. databases) as if they were running on localhost.
ssh -L <locally accessible port>:<ip address to bind to>:<remote port> hoge@host.example.com
- example:
ssh -L 5434:127.0.0.1:5432 hoge@host.example.com
SED
Find/Replace
Recursively find and replace all instances foo
and replace it with hoge
, excluding the migrations directory. Using ripgrep because it's fast / ignores files in your .gitignore. Does not create a backup of modified files because, you're using git, right?!
Command is for FreeBSD sed, as found on macOS.
rg 'foo' -g '!migrations/' --files-with-matches -0 | xargs -0 sed -i '' 's/foo/hoge/g'