Perched at the edge of Silicon Valley, Fremont, Calif. is being whipsawed by the changing economies of the 21st century.