I've also heard shaving cream and even shampoo or pick your favorite slime will do the job.
Then there are hair dryers and a wealth of anti fog products but I think you should be addressing why your mirror is fogging up so much.

You may want to install, clean, or upgrade your bathroom fan to cut down on the moisture and keep mold and mildew at bay.