I joined to mention one trick that worked for me - years before this site was even thought of. I struggled through some very real issues, which seriously affected real people as well as myself. Communities were not as understanding, these issues were not openly discussed, and problems were often brushed under the carpet.
I was caught out when quite young, and was offered a lifeline - counseling. Even during these sessions, I was not open and honest - I left out the fact that I had been abused, for example. I was, and remain, an extremely private individual. This inhibited my scope for outside help, which is not a good thing.
Nevertheless, I developed my own coping mechanism - perhaps this trick worked for me as a teenager, but would not work for more mature minds. If it helps anyone, then I am happy.
I had urges - terrible urges. Urges that affected others, as well as myself. Even after I consciously determined to cease these activities, I found thoughts entering my mind. My response was to visualize an explosion, blowing the thoughts up. The reason for this is that the thoughts would invade any other "clean" thought that I could envisage. They would violently attack the clean space that I tried to form. I responded with violence (I am emphatically not, nor have I ever been, even mildly violent or physically agressive) - blowing up those unclean images.
This did not always work - the images would reinvade the now vacant space left in my mind. I then set off "cluster explosions", which would deal with all the little bits and pieces that remained. This could go on for a while at the beginning (I can still picture myself walking down a street, stopping and closing my eyes for thirty seconds until I had blown up the fragments), but over time the "immediate reinvasion phenomenon" subsided. This is a stratagem that I continue to use.
I believe that the effectiveness of this is due to avoidance of a common mistake - dwelling on the symptom, and ignoring the problem. Dwelling on the symptom, in my observation, causes either guilt or fascination - this said "go away, I will not even acknowledge you other than to remove you" - I then moved on with whatever I was doing. Each time I felt that there were no lingering particles, I would silently thank Hashem for the fortitude he had given me. I see this as important, since it put a small positive thought in the empty space left.
This helped with the symptom of thought. Speech and deed followed to an extent - the most unhealthy actions ceased immediately - I was treating this as a separate problem to other things, such as self-fulfillment, which I dealt with in my own "90 clean days" manner - I challenged myself to "not do it", with time-goals. Starving the Yetzer Hora managed to make mine weaker, not hungrier.
This might not work for everyone, and should probably not be seen as a stand-alone substitute for better documented and more widely used methods. This method worked for me, however, to keep the thoughts and intention to perform horrific acts at bay, which in turn gave me no opportunity to repeat any actions. If this works for even one person, once, then I have not wasted my time in posting.