First-principles-based simulation of scanning tunneling microscopy: From magnetic surfaces to molecular structures