There was a female long haired Shepherd in a farm-type block down the road from where we live. The owners had put one of those underground electric fence wires in and she wore the collar/receiver that (I think) gives them a shock if they go near the underground fence.
She had a problem with other dogs and she would to test the fence during the day (her owners usually switched it off at night and let her & her kennel-mate roam and sometimes forgot to turn it back on, yep..I know!)...I was walking past with my old dog Harry-the-Dirty-Dog and she came rushing out at us, the only thing I had in my hand was the bag of Harry-poo, anyway I was waving round this bag of poo and shouting and the dog backed off...I then threw gravel after her....gave me a bit of a fright though!
I now resort to carrying a small can of insect repellent...I figure that a squirt at the face will be a deterrent (or is that a no-no?)