There are some basics to nutrition, but like running shoes, what your friend likes won't necessarily work best for you. Experiment and use what works best. If you feel that electrolyte depletion is causing you to bonk or cramp, choose nutrition with more sodium & potassium or supplement with S-Caps, Salt Stick, or Endurolytes.
Bonking, or losing steam before the finish, or 'Hitting the Wall' is the result of one or all of three things. First, insufficient fueling and/or hydration, and you can usually eliminate that issue by fueling properly. Don't neglect to eat (Carb Load) and hydrate well during the three days leading up to longer races. Second, pace yourself correctly. Most often you will race better if you run negative splits. That does not mean to think negative thoughts, but to run the later part of the race faster than the first part. If you go out too fast you almost always pay for it at the end. Even 10 seconds per mile faster than goal pace in the first miles can spoil a strong finish. Third and most important, train smart. For best results, follow an established training program, such as Hal Higdon's or Jeff Galloway's, after you have built a solid running foundation. Most of us would agree that mileage increases should not exceed 10% per week, and just as we should practice hard/easy days, also follow hard weeks with easier weeks. Recovery days are just as important as hard days, so plenty of rest (sleep) is required for optimal race training. A friend said it well, 'There is no such thing as over-training, just under-recovery. Pro Triathlete Malaika Homo.
I have found that 150 calories per hour works well. That means I take one gel about every 45 minutes in training. On race day I take a gel every 30-40 minutes and I feel better fueled and more energized. For energy chews you simply take total calories per packet and divide by chews per packet - Honey Stinger chews have 160 calories for 10 pieces - so I'd consume one packet per hour, or 2-3 chews before each aid station or every two miles, and chase with water. I often take a gel with water 20 minutes before the start of long and short races, just to top off the tank.
Post-workout/race nutrition: Protein and Carbs, get'em in your body as soon as possible after the run, within 20 minutes. I find it easiest to use a recovery drink such as Ultragen or Endurox or Recoverite, and chocolate milk is excellent nutrition. If you don't get it in your system after hard workouts you won't get the most benefit from the effort. I don't take Ultragen after every workout, but usually only after the hardest ones. A quick PB&J with milk and a yogurt is enough after easy runs.
Pre-race meals can vary according to the race distance. For 5Ks I may not eat anything before the pre-race gel, but for Halfs and Marathons I consume a few hundred calories four hours before the race. For marathons I eat oatmeal with very little or no milk and sip on a sports drink, or toast or bagel with jam or honey, or an energy bar, or Pop-Tarts, etc. Find out what works for you during training and don't vary it race-day morning. Oh, and sleep Thursday night because you may not sleep well Friday night (for a Saturday race).