There are no tricks and you never get used to it. Six years of being awake 36 hours every fifth night, followed by five children in rapid succession attest to this.
Short naps help. If you can get two hours sleep in the middle of a long stretch, it can push you through.
Some folks are absolutely more gifted in this area. Being young helps as I have noticed a distinct worsening in my ability to go all day, all night, and all the next day as I approach forty.
Having a task to focus on is the best remedy. No one falls asleep performing an engaging technical task that they need to stay sharp for. I bet the riding you were doing was very much non-tech in nature (you could do it in your sleep:))