Hadith:
On the authority of Abdullah bin Abbas (RadiyAllahu Anhu), who said:
‘One day I was behind the prophet (Sallellahu Aleyhi Wa Sallam) and he said to me:
“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 ask, ask of Allah; if you seek help, seek help of Allah. Know that if the Nation were to gather together to benefit you with anything, it would benefit you only with something that Allah had already prescribed for you, and that if they gather together to harm you with anything, they would harm you only with something Allah had already prescribed for you. The pens have been lifted and the pages have dried.”
[Tirmidhi]
In another version it reads:
“..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.”