Harbouring contrary thoughts (pratipakṣa bhāvanam) is a strategy suggested by Patanjali when faced with temptations or difficulties in practicing the codes of personal conduct (Yama and Niyama). This is more subtle than simply thinking positive thoughts as contrary thoughts need not only be positive. (Read here about the make-believe, word play stuff that characterise much of the transformation tips.)
Sutra 2.33 | vitarkabādhane pratipakṣabhāvanam / when perverse thoughts inhibit (your practice of Yama and Niyama), opposite of those thoughts should be contemplated
Presumably, such thoughts will fight with the tempting thought and guide the Yogi to do the right thing. Or atleast not to do a wrong thing.
What sort of contrary thoughts one should think? Patanjali suggests a generic thought that could be useful in many kinds of circumstances.
Sutra 2.34 | vitarkā himsādaya kṛtakāritānumoditā lobhakrodhamoha pūrvakā mṛdumadhyādhimātrā duḥkhājñānānantaphalā iti pratipakṣabhāvanam / the thought that actions arising out of perverse thoughts will only bring endless suffering is a pratipakṣabhāvanam for harmful thoughts and actions.
Not very exciting stuff so far!
Stoics offer a more precise solution. It is essentially calling spade a spade. Marcus Aurelius says it the best: “…seeing things for what they are, stripped off the cloak of verbiage surrounding them.” The idea here is that by describing a glass of wine as fermented and aged (stale?) grape juice, one would perhaps lose interest in it. At least enough interest to desist from spending a fortune to buy a special edition 100 year old wine (whatever). Marcus Aurelius has a few more such “truthful” descriptions of common place temptations. I refer you to Meditations.
To be an effective pratipakṣa bhāvanam, the contrary thought should be factual (i.e. not imaginary) and easy to remember. Some humour is useful. For example, if you are trying to practice some form of Brahmacarya, you are likely to face many temptations in daily life. Man has been tormented by woman and vice versa since the beginning of the time and it seems even sages are no exception. A possible pratipakṣa bhāvanam for this in the spirit of Marcus Aurelius is to imagine a body as a collection of bones, muscles and fascia. Diligent remembrance of this thought at the sight of a rather attractive human form could somewhat dampen the sway of the mind.