Design for resilience of structures and infrastructures: theoretical framework and applications