I like reading, so sometimes when my mind starts to wander I stop for 30 secs to a minute to read an article or a page out of a book I’m into.
The method that I’m least proud of is pressure by procrastination, while it can push you towards results in a no way out kind of way, it’s a very stressful method for me and leaves no room for error.
That's what i got in my mind thinking an answer, thanks for your question!
Music will also help, so I listen to up-beat music.
Sometimes I put the mirror in front of me to remind me how wonderful I am while doing the boring stuff since everyone is also has some moment to do boring stuff.
I also find the 'Self-Discipline Blueprint' by Patrik Edbald to be quite helpful.