Turning SOCKS proxy on from the terminal on OSX

If you have to set up a SSH tunnel and a SOCKS proxy regularly to get around work firewalls (so you can post on your "blog") you can actually do this from the with the following setup and command

First go to System Preferences and setup you SOCKS server address

Then to turn this on and off from the terminal you can use: networksetup -setsocksfirewallproxystate Ethernet on and networksetup -setsocksfirewallproxystate Ethernet off

To be even lazier you can setup your tunnel with the following one line string (replace with you server address):
ssh -ND 9999 root@ && networksetup -setsocksfirewallproxystate Ethernet on