I heard the Messenger of Allah (May peace be upon him) say: A good vision comes from Allah and a dream (hulm) from the devil, so when one of you sees what he dislikes, he must spit on his left (three times), and seek refuge in Allah from its evil. It will then not harm him. (Using translation from Abū Dāʾūd 5021)
قَالَ رَسُولُ اللهِ ﷺ «الرُّؤْيَا مِنَ اللهِ وَالْحُلُمُ مِنَ الشَّيْطَانِ فَإِذَا رَأَى أَحَدُكُمْ شَيْئًا يَكْرَهُهُ فَلْيَتْفُلْ عَنْ يَسَارِهِ ثَلَاثًا ثُمَّ لِيَتَعَوَّذْ مِنْ شَرِّهَا فَإِنَّهَا لَا تَضُرُّهُ»