My friend Charlie is back....

https://slrpnk.net/post/35738966

This fixes it instantly every time for me. Ignore everybody else. When you get that cramp start moving our foot in the opposite direction pointing your toes towards your knees and stretch out the back of your ankle. Instant cramp relief everytime.

If you have cramping often like this then maybe dedicate yourself to some hamstring stretches.

Similar trick I learned, just get out of bed and stand up on it. It’ll go away in ~10 seconds and then you can hop back into bed. Works pretty much every time.