Visualize goal: close your eyes, imagine your acceptance letters
When stuck, go for a little walk or physical exercise
Do goal-oriented studying (e.g. Pomodoro technique)
Understand the education system wants you to comply, this is wrong, but the faster you get over it the faster you'll forget about it. It's better to keep your mouth shut, don't complain or antagonize, they are not going to change for you or anybody (they haven't in centuries). Give them the little self importance they crave for and get from them what you want (grades, diploma). Of course, keep your mind critical but keep it to yourself until they give you what you want.Also don't overwork yourself, perhaps this is not the best time to spend many hours doing unrelated programming or research. It can be a distraction to your education goal. We have limited willpower, try to avoid depletion. Only when you achieve your studying goals for the day you get to do your own thing. Study in the mornings, play in the afternoons.
Modifying your routine takes a while, do it in baby steps. Remove all temptations that might get in the way to your goals until you achieve them. But keep a good chunk of the day to clean up your head.
Of course, YMMV.