I’ve got a general “rule” to wave or at least smile at everyone I see, gets me out of myself and changes my mood most of the time. I started doing that after watching Natasha Badman win Ironman’s while smiling almost the whole time.
To go internal I’ll use some box breathing techniques. In 2, hold 2, out 2 or whatever count I can sustain for intensity. It will lower HR and increase HRV fairly consistently. Figured it out doing meditation with the chest strap on and gave it a shot on the bike.
If it’s really hard I’ll do a mantra with the breath - (In) Arising, Abiding, (Out) Changing, Ceasing. Like all things, the pain and suffering is temporary and will change and then stop. This mile might be hard and the next mile could feel good. That happens all the time, so refocusing on the impermanence and transient nature of the suffering helps.
If all else fails, it becomes an exercise in gratitude and perspective. How many people can’t ride a bike for whatever reason, so even my worst ride is something than someone somewhere would wish they could do. My 80 year old self will one day wish he could do what my 42 year old self can do today too.