The Buddhist Sutra of Mindfulness speaks about the meditation on the corpse: meditate on the decomposition of the body, how the body bloats and turns violet, how it is eaten by worms until only bits of blood and flesh still cling to the bones, meditate up to the point where only white bones remain, which in turn are slowly worn away and turn into dust. Meditate like that, knowing that your own body will undergo the same process. Meditate on the corpse until you are calm and at peace, until your mind and heart are light and tranquil and a smile appears on your face. Thus, by overcoming revulsion and fear, life will be seen as infinitely precious, every second of it worth living.
Thich Nhat Hanh