How? Mostly (not entirely) by working for a defense contractor. Everyone seems to knock corporate jobs, but I swear to you I've done so much cool stuff because it is only companies that size that can bid on and win this interesting work. Plus, I went to university (another false meme around here - college is just a piece of paper), where I learned the chemistry, physics, electrical engineering, and math to do all this stuff.
There is plenty of pain in big government type projects, but there is pain in every thing important. Do you want to wrestle with undocumented CSS behavior, or wrestle with how to program this robot, or how to reduce defect rates in your machine in the factory, or how to make this plane fly. Sentence structure doesn't make it clear, but I consider only the first boring, and the rest extremely interesting.
There are a lot of those kinds of jobs. You may not live in SF anymore, and end up at an airbase in Iowa, or in Albuquerque, or Huntsville. OTOH, your pay will be absolutely amazing compared to local property prices, and you can raise a family, go on great vacations, and not worry about living in the crazy bubble we are in right now.
I know it won't appeal to everyone, but I swear to you there are tons of extremely interesting, challenging jobs out there that aren't start ups, and aren't corporate internal reporting apps (TPS reports). You will need to be far more than a Ruby on Rails developer, CSS+HTML5 jockey, or what have you.
edit: all of the above is written by a US citizen. I don't know what opportunities are like in other countries, and don't mean to imply that any of the above applies to anyone but a US citizen. I don't know.