Weighted K-stability and special metrics in Kahler and Sasaki geometry