I get these every so often. They suck. How does one go about avoiding them?

Usually getting a decent amount of sleep keeps them at bay but sometimes they show up anyway.