The Mori-Zwanzig formalism allows to describe the dynamics of a particular quantity of interest out of the dynamics of the whole system by a projection method. It leads to a generalized Langevin equation (GLE) for the dynamic of the quantity of interest. While it has been a very useful theoretical tool, it has seldom been used nuemrically because of the difficulty to obtain the projected correlation functions that make the kernel of the GLE. We will present an algorithm to obtain the projected dynamics of any quantity out of molecular dynamics trajectory. After an illustration for a reactive system, we will discuss the case of a diffusing particle in a liquid and how the obtained GLE can be further coarse-grained.