I had a derailleur cable break on a ride after going too long between replacing it.
Ever since then... well first of all, I've been better about maintaining my cables. But I also carry a few zip ties in my saddle bag so that if a cable breaks again, I can rig it up like this: