Some saints did it. Remember the story of St. Francis who threw himself into the thorn bush and rolled around in his effort to resist temptations against chastity?
Many today mock the very idea of praying and fasting and doing violence to oneself to drive away any sort of disordered passion.
I found the story of another extraordinary saint who resisted temptations to lust to a heroic degree...
Venerable John the Much-Suffering pursued asceticism at the Kiev Caves Lavra, accepting many sorrows for the sake of virginity.The ascetic recalled that from the time of his youth he had suffered much, tormented by fleshly lust, and nothing could deliver him from it, neither hunger nor thirst nor heavy chains. He then went into the cave where the relics of St Anthony rested, and he fervently prayed to the holy Abba. After a day and a night the much-suffering John heard a voice: “John! It is necessary for you to become a recluse, in order to weaken the vexation by silence and seclusion, and the Lord shall help you by the prayers of His monastic saints.” The saint settled into the cave from that time, and only after thirty years did he conquer the fleshly passions.Tense and fierce was the struggle upon the thorny way on which the monk went to victory. Sometimes the desire took hold of him to forsake his seclusion, but then he resolved on still greater effort. The holy warrior of Christ dug out a pit and with the onset of Great Lent he climbed into it, and he covered himself up to the shoulders with earth. He spent the whole of Lent in such a position, but the burning of his former passions did not leave him. - Finish reading here.
St. John the Much-Suffering came through his struggles successfully. However, today spiritual directors would naturally warn people against becoming too 'tense' or too 'fierce' in their struggle against vice, no one wants to be discomforted or sad of course, but sometimes we really do need to 'do violence' to ourselves to avoid sin. Especially in the summer.
Pray it away. You can do it.
Apart from me you can do nothing. - John 15:5