The two, stale cake and stale cookies, need different fixes because they go stale in opposite ways: cake loses moisture and dries out, while cookies absorb moisture from the air and soften. Crumble dry cake to make truffle balls, a dessert crust, or an ice cream topping; briefly reheat softened cookies in the oven to bring back their crispness. Choose what to do based on which way the food has gone stale.
A cake stays soft because of the moisture held in its crumb. As it sits, that moisture escapes from the surface, the starch firms up, and each slice becomes dry and crumbly. Cookies lose most of their water as they bake, which gives them their crispness; as they sit, they absorb moisture from the air, the sugar softens, and the cookie becomes flexible. One is short on moisture and the other has too much, so the same method cannot be used for both; first figure out which way the food has gone stale.
Dry cake works best when crumbled. Break it up by hand or in a food processor, then knead the crumbs with melted chocolate, jam, or cream cheese and shape them into balls. Roll the balls in cocoa or shredded coconut. Since the cake is already baked, these balls do not go in the oven; chilling them in the refrigerator is enough to firm them up. Add the binder a little at a time, since the amount needed depends on how dry the cake is. The ratio is right when the mixture forms a ball in your palm without sticking to your hand. A little crushed walnut or hazelnut in the crumbs helps the balls hold together.
The second option is a crust. Mix cake crumbs with melted butter, press them into the bottom of a pan, and top with custard, fruit cream, or a yogurt layer; the crumbs stand in for a cookie crust and stay softer. Toast the crumbs in a skillet over low heat to make a crisp layer to sprinkle over ice cream, rice pudding, or fruit. Stir constantly as they toast, because cake made with sugar browns and burns quickly. Dry cake slices can also be used in desserts soaked with syrup or sweetened liquid, since dry cake absorbs liquid faster and more evenly than fresh cake.
Softened cookies can return to their former state if their excess moisture is removed. Space them out on a baking sheet and warm them briefly in the oven; the goal is not to bake them again, but to drive off the moisture they absorbed. Cookies may still look soft as they come out of the oven, which can be misleading: crispness comes as they cool. Do not wait for them to harden in the oven. Remove them when the edges are dry and the surface no longer feels moist, then let them cool on a wire rack. Cookies left in the oven too long will darken and turn bitter.
Cookies that do not recover after drying, or that cannot go in the oven because they are filled or frosted, can be used like cake: crumble them into a dessert crust or truffle mixture. Crumbs from buttery cookies need less butter in a crust, so check the mixture as you add the crumbs. Staleness and spoilage are different: cake or cookies with mold spots, a sour smell, or a bitter smell should not be used in any of these ways. Only food whose moisture has changed should be repurposed.