Restarting Airport from the command line
Something is wrong with the network in my dorm; DHCP negotiation sometimes fails (or takes a long time). So the usual thing to do is to turn Airport off and on, and hope it works this time.
To do this from the commandline, here’s a simple trick I found:
Go to System Preferences → Network, then in Location choose a New Location and create one called “Airport-Off” (or anything you like). In the Show menu choose Network Port Configurations and turn off Airport.
After this, you can do scselect Airport-Off to turn it off, and scselect 0 (for Automatic — or choose whatever other location you want) to turn it on.
Edit [2011-10-03]: You can also do this:
sudo networksetup -setairportpower "Airport" off sudo networksetup -setairportpower "Airport" on