Resetting Bluetooth on a Mac

I just turned on my Mac and now my bluetooth keyboard and magic pad won’t sync.

Sometimes, when I bring my laptop back in after taking it home from work at night, my wireless keyboard and magic pad won’t sync. Instead of rebooting my computer, I just unload the bluetooth in a terminal session.

sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport

and then

sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport

to load it back again.