Stand up straight and if people hassle you pretend that you have somewhere to go. If you are seriously in trouble, walk up to another foreigner and pretend to be friends.
Take a minute to adjust to the new place. Look around and acclimatise, maybe even buy a coffee and have time to adjust.
It doesn’t matter how much of the language you know; many people will be so proud and happy to hear you utter ‘Thank you‘ in their mother tongue.
I always try to update my Facebook as much as possible and let people at home know where I am and if I will be in an area with no internet for a while.
This seems like a hard task for a solo traveller, but most incidences of assault happen when the victim is alone. Try to be around other tourists on transport and when sight-seeing in the day.