From James Van Dyne
Jump to navigation Jump to search

A collection of commands that are useful and I never seem to remember off the top of my head.


File Upload

  • curl -i -X POST -H "Content-Type: multipart/form-data" -F "file=@tanzawa.png"


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

Socks proxy settings.png

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>
  • example: ssh -L 5434:



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'