How does one control his or her desires? Are there any techniques

One way is to reflect that Allah is present and sees your actions at all times.

Another way is to reflect on death often.

Use this dua that is found in the Holy Quran