How to make your code more secure

Over and over again we see headlines about breaches and compromised system.

What can you as a common developer do to make sure the software you are writing on are more secure? Is there any magic tools and/or methods you can use? Or is it just hard work that is required? Spoiler: a little bit of both.