If attacked by a determined dog while you're unarmed, the best advice I've heard is to drive your thumbs into its eyeballs. If that's not possible and the dog has you on the ground, shove your stiffened cupped hand as far down its throat as you can manage while holding it around the neck with your other arm. Don't let go until the dog stops breathing. Failing either of those, if you have the sufficient strength and speed, quickly pick the dog up as high as you can and piledrive in head first into the ground. If it isn't killed outright, that will break or rupture something and stop the attack. Or a tight bearhug around the neck until it's dead.
I like dogs as much as the next person but they are animals. As animals, there is always an element of unpredictability.
If attacked by a cat, grab it by the tail and swing against the nearest stationary object. Or go for distance.