Chapter 2 Tawhid (Divine Unity)
It is reported that Ibn Abbas said: "I was once walking close behind the prophet (PBUH), when he said: 'My boy, I am going to teach you a few words. Be mindful of Allah and he will be mindful of you: be mindful of Allah and you will find him with you: If you ask, ask Allah; if you seek help, seek help from Allah. Know that if the nation were to gather to benefit you with anything, it would only benefit you with something that Allah has already prescribed for you, and that if they gather to harm you with anything, they would only harm you with something Allah has already prescribed for you. The pen has been lifted and the pages have dried.” (Tirmidhi).
In a different version of this Hadith, the prophet (PBUH) said: Be mindful of Allah and you will find him before you: make yourself known to Allah in your times of prosperity and he will recognize you in your times of hardship. Know, too, that what missed you could not have missed you. Success goes hand in hand with perseverance, pleasure goes hand in hand with pain, and with hardship comes ease".
(Related by at-Tirmidhi)