This advice from the Holy Prophet ( upon him be abundant blessings and peace) to Sayyidna Abdullah Ibn Abbas (ra) sums it up.
“O young man, I shall teach you some words [of advice] : Be mindful of Allah, and Allah will protect you. Be mindful of Allah, and you will find Him in front of you. If you (have need to) ask, ask of Allah; and if you seek help, seek help from Allah. Know that even if the Nation (or the whole community) were to gather together to benefit you with something, they would not benefit you with anything except that which Allah has already recorded for you, and that if they gather together to harm you with something, they would not be able to harm you with anything except that which Allah has already recorded against you. The pens have been lifted and the pages have dried.” [Al-Tirmidhi relates this and says: It is a good, genuine Hadith]
“..Be mindful of Allah, you will find Him before you. Get to know Allah in prosperity and He will know you in adversity. Know that what has passed you by was not going to befall you; and that what has befallen you was not going to pass you by. And know that victory comes with patience, relief with affliction, and ease with hardship.”