A राग raga, attachment is created for something because of a particular viewpoint, e. g., dwelling merely at the benefits or the virtues of a given thing. Similarly, dwelling too long on the defects or disadvantages of a thing creates द्वेस dvesa, aversion. Both raga and dvesa are results of a partial viewpoint. If constantly dwelling on the virtues creates raga, let the mind do दोष-दर्सन dosa-darsana, see the faults or the harm involved in association with that object or being. This is called प्रतिपक्ष-भावना pratipaksa-bhavana – deliberately taking the opposite view point. The objective of pratipaksa-bhavana is to take into account the totality, not just one viewpoint.
विरज्य विषयव्रातादोष्द्रष्ट्या मुहुर्मुहुः !
virjya visaydvriitat dosadrstya muhurmuhuh!
The Vivekacudamani  says detachment can be created by making the mind see again and again the dosa, the defect or harm associated with the thing.
The pratipaksa-bhavana should be applied not only to the ragas and dvesas, but also to the related emotions such as indulgence (kama काम), anger (krodha, क्रोध), and greed (lobha लोभ्). If there is anger, we bring in its opposite emotions such as compassion and forgiveness. If there is greed, we bring in contentment, satisfaction with what we have. Thus, we keep observing our emotions or impulses and keep neutralizing them; Thus, alertness is to identify these emotions and neutralize them.
As Lord Krishna teaches us, we should do what is right rather than doing what we like in every situation. What we like is the result of our ragas and dvesas; what is right requires us ‘to subdue these emotions. We need to cultivate प्रसाद-बुध्धि prasada-buddhi, graceful acceptance. We should accept the outcome of our efforts as प्रसाद prasada grace of ईश्वर isvara (Lord); then we will not react with frustration or elation. Success also is prasada and so is failure. We can avoid elation and depression with prasada-buddhi. We should strive to maintain equanimity of mind in everything -whether we are walking, talking, doing any action. Do what is right rather than what you like. Accept gracefully what you cannot change, and commit to do what is right; where you can do something. See isvara everywhere.
Ragas and dvesas arise because we give too much importance to dissimilarities or disparities, or whenever we give importance to the name and form which is but a costume. There are many commonalities also. Even if we do not go all the way to isvara, we can notice that all the bodies are common and they are but modification of food. All are products of the five basic elements. Thus, we can identify the sameness in all beings. Let us make our minds pay attention to what is common. Thus; make a commitment to see the sameness in everything or समत्व-द्रष्टा samatva-drasta. Ultimately, isvara of course is सम sama or equal everywhere. Thu, seeing Lord Narayana or Lord Siva in everything is an excellent way of making the mind free from ragas and devsas. We work with the minds and its impulses constantly this way.