Do not be sad or too happy
Know that what Allaah has destined for you will be yours, and what He has not will never be yours. When you achieve something remind yourself not to be prideful and so happy that you forget to thank Allaah for the blessing.
Do not begin to believe that you got what you got because of your own doing.
And when you fail to get something do not let it sadden you so much that you begin to despair, think negatively of Allaah, and become impatient and/or ungrateful. Everything is written by Allaah.
So, never be too sad when something misses you, and do not be too happy when you get something.
"No calamity befalls on the earth or in yourselves but is inscribed in the Book of Decrees (Al-Lauh Al-Mahfuz), before We bring it into existence. Verily, that is easy for Allah.
In order that you may not be sad over matters that you fail to get, nor rejoice because of that which has been given to you. And Allah likes not prideful boasters."
[Qur'aan Chapter 57 Verses 22-23 - Translation Muhsin Khan]