The JOREK non-linear extended MHD code and applications to large-scale instabilities and their control in magnetically confined fusion plasmas