(Image pulled from Studio Ghibli's beautifully animated "Tales of Earthsea")
No matter how much I try to anticipate and plan around my player's decisions, they still go off-script. This is all fine and well, and I can fly by the seat of my pants with the best, BUT it's always handy to have some backup strategies to use when things go off the rails.
For me personally, one of the most challenging things to generate on the fly has been towns and cities. To help out with this, I came up with the system on the attached PDF. It's quite simple, but does an effective job of determining what businesses and professionals will be found in any random town based on the size of that town.
In my Ur campaign setting, I divided towns and cities into ten "tiers" or sizes based on population. Since every campaign setting is different, you may need to tweak the numbers in the tiers to better match your own world. The mechanics themselves, at least, are simple enough to be pretty universal to almost any fantasy world.