How can you deal with sudden neck stiffness due to sleeping funny?

See below. Gentle stretching of the neck should work it out. Also heat to the painful area, use of anti-inflammatories if it is safe for you to take these should also help. The pain should go away after a day or two in most cases.