Programmable Magnetics for Microscopic Assembly, Metamaterials, and Robots