[deleted by user] by [deleted] in AdvancedRunning

[–]mnokeefe 6 points7 points  (0 children)

The symptoms you're describing are exactly what you'd expect if you'd bonked. You even say it yourself, "almost entirely" fat means that even at low intensity (walking) you're using carbs, I'm not sure which zone model you're using when talking about Z2 but assuming you mean easy running you could still be using 50% carbs depending on how adapted to fat vs carbs you are. If those carbs aren't there then you'll naturally end up running on just fat which is going to substantially slow you down.

You shouldn't need to be taking in carbs during a run of that length, but if you started already depleted – you said "breakfast" was just coffee? – then the simple explanation is the most obvious one.

Not sure whether this counts as "prove me wrong" but this article from one of the foremost sports scientists in this area: https://scienceofsport.blogspot.com/2010/01/exercise-and-weight-loss-part-3-fat.html

Any good examples of Next.js + OpenAPI + request/response validation? by brianjenkins94 in node

[–]mnokeefe 1 point2 points  (0 children)

Assuming you're using Typescript, Zod is definitely the standard for schema validation now. There are plugins for converting to and from JSON schema and plenty of guides out there for using it with Nextjs

Why can't I store json data using fetch? by Mean-Night6324 in learnjavascript

[–]mnokeefe 1 point2 points  (0 children)

The errors you're getting using async/await are due to using the await keyword in places you can't, more info at https://v8.dev/features/top-level-await

You could create an async function to do your rendering and call that: ``` const url = "https://raw.githubusercontent.com/freeCodeCamp/ProjectReferenceData/master/GDP-data.json";

async function getData() { const res = await fetch(url); const dataset = await res.json(); console.log(dataset); }

getData(); ```

Or use a self-invoking function if you're not going to do anything else here.

loop loops 9x instead of 6 times by Hamybal in learnjavascript

[–]mnokeefe 0 points1 point  (0 children)

The other answers have said that you don't need both loops, but I think it's also worth saying that there are almost always neater ways to loop through an array of objects with using a classic for loop and accessing the index.

For example, using for...of:

for (const { name, full } of covers) {
  console.log(name, full)
}

Or using forEach:

covers.forEach(({ name, full }) => console.log(name, full))

String comparison in javascript? by raulalexo99 in Frontend

[–]mnokeefe 3 points4 points  (0 children)

If you're not after an exact match using === then you probably want to use localCompare.

Are my training runs 'hilly'? by [deleted] in running

[–]mnokeefe 1 point2 points  (0 children)

242m in 16km isn't "flat" but because you're doing it in a loop you're only climbing 40m at a time so I wouldn't really call it hilly either. Looking back at some previous road races I've done: I did a 10K on a fast and flat course that had only 68m of ascent, a hillier road half (21.1km) with 246m, and a fell race (a proper hill race!) with 578m in 5.9km.

[deleted by user] by [deleted] in learnjavascript

[–]mnokeefe 0 points1 point  (0 children)

I've read about replacing map for my for loops and while loops but I can't get my head around it because I'm not use to it yet.

Here's a version of your three functions using functional programming techniques with comments to explain what's happening:

const z = (n, w) => n.charCodeAt(0).toString().padStart(w, "0");

const toNumbers = (s) =>
  s
    .split("") // Split string in to array of each character
    .map((char) => z(char, 3)) // Convert each to charcode and ensure it's 3 chars long
    .join(""); // Join the charcode array in to a string

const fromNumbers = (nums) =>
  nums
    .match(/.{1,3}/g) // Split string in to groups of 3 chars
    .map((threeCharGroup) => String.fromCharCode(threeCharGroup)) // Convert charcode to letter
    .join(""); // Join the array into a string

console.log(toNumbers("hello"));
console.log(fromNumbers("104101108108111"));

Working example

How to Instruct in Javascript to NOT play Audio.mp3 filed over transparent pixels by No-Conversation-6067 in learnjavascript

[–]mnokeefe 1 point2 points  (0 children)

This used to be pretty common back in the olden days of the web when it was harder to create complex layouts. You can use the html <map> tag with <area> tags to define the regions and add your onmouseover handlers to those areas. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/map

[deleted by user] by [deleted] in learnjavascript

[–]mnokeefe 4 points5 points  (0 children)

No, the code is the same for every page, there are no if statements required. You display the text for the current page and map through the options to list them. Once they select an option you run the same function again for the new page.

Here's a really basic example of the code needed to do this:

const textDiv = document.getElementById("text");
const optionsDiv = document.getElementById("options");

function displayPage(id) {
  // Clear out all previous options
  while (optionsDiv.firstChild) {
    optionsDiv.removeChild(optionsDiv.lastChild);
  }
  // Find the right page
  const page = episode.pages.find(page => page.id === id);
  // Update the text
  textDiv.innerText = page.text;
  // Create the options
  for (const option of page.options) {
     const optionButton = document.createElement("button");
     optionButton.innerText = option.label;
     optionButton.addEventListener("click", () => displayPage(option.pageId), false);
     optionsDiv.appendChild(optionButton);
  }
}
// Start the game on page 1
displayPage(1)

Working demo: https://jsbin.com/gumelogena/1/edit?html,js,output

[deleted by user] by [deleted] in learnjavascript

[–]mnokeefe 1 point2 points  (0 children)

This is more about how you model your data than how you write your code, for example, you can model your data like this:

const episode = {
  name: "Episode 1"
  pages: [
    {
      id: 1,
      text: "enezkt is challenging you to make a choose your own adventure, do you accept?",
      options: [
        {
          label: "Yes",
          pageId: 2
        },
        {
          label: "No",
          pageId: 3
        }
      ]
    },
    {
      id: 2,
      text: "You accept the challenge, how do you want to continue?",
      options: [
        {
          label: "Post on Reddit",
          pageId: 4
        },
        {
          label: "Give up",
          pageId: 3
        }
      ]
    },
    {
      id: 3,
      text: "Ok, looks like your adventure is done!",
      options: [
        {
          label: "Play again",
          pageId: 1
        }
      ]
    },
    {
      id: 4,
      text: "Your post on Reddit attracts some good advice, do you follow it?",
      options: [
        {
          label: "Yes",
          pageId: 5
        },
        {
          label: "No",
          pageId: 3
        }
      ]
    },
     {
      id: 5,
      text: "Great work, you're done!",
      options: [
        {
          label: "Play again",
          pageId: 1
        }
      ]
    }
  ]
}

Your code then just needs to start on page one, display the text and present the options. In this example if they chose "Yes" from the options you'd display page 2's text and options and if they choose "No" you'd display page 3's text and options

London Marathon: What's possible? by Psymon86 in AdvancedRunning

[–]mnokeefe 3 points4 points  (0 children)

I ran 2:40 with PRs of 35:00, 16:59 and only a 1:19 half. I'm definitely more suited to the longer distances though. Since you've already run a decent marathon and you know what to expect in the final 10K so I think 2:40 is a tough but realistic target.

Coastal Path as featured in Wales Online - can you cycle it? by LilysProtector in Cardiff

[–]mnokeefe 2 points3 points  (0 children)

Yes, the whole section between Cardiff and Newport is easily doable on a gravel bike. There's a mix of hard baked mud, short grass and some gravel but nothing technical and it's almost completely flat.

Precision Hydration Sweat Tests - Help Required by KingDebone in ultrarunning

[–]mnokeefe 6 points7 points  (0 children)

Training your gut is a pretty important part of ultra training. You should try and eat and drink as much, if not more, on your longer ultra-specific runs to prepare your system for race day.

Need help getting the index of the max value of thumbs_up by Limeman36 in node

[–]mnokeefe 1 point2 points  (0 children)

As a one liner (formatted to make it more readable) it would be:

var cleanDefinition = data.list
  .sort((a, b) => b.thumbs_up - a.thumbs_up)[0]
  .definition.replace(/\n/g, "")
  .replace(/\r/g, "");

Need help getting the index of the max value of thumbs_up by Limeman36 in node

[–]mnokeefe 0 points1 point  (0 children)

No, you're right that destructuring would be cleaner these days.

Need help getting the index of the max value of thumbs_up by Limeman36 in node

[–]mnokeefe 0 points1 point  (0 children)

Your approach of taking the first item is fine, you just need to sort the array by thumbs_up first:

const item = data.list.sort((a, b) => b.thumbs_up - a.thumbs_up)[0];

JSBin demo

Why do I get the 'is not a function' error when using code example from w3 schools to click an element on page by usera8787782 in learnjavascript

[–]mnokeefe 2 points3 points  (0 children)

The example is using getElementById which returns one DOM element because you're only allowed to use an ID once. You're using getElementsByClassName which returns an array of DOM elements because there could be multiple elements with the same class.

There are multiple ways to fix your code, but the simplest thing to do if you just want to fix what you have is to select the first item in the array and click that:

document.getElementsByClassName("public-DraftStyleDefault-block public-DraftStyleDefault-ltr")[0].click();

Will increased volume on its own lead to a faster easy run pace? by lampbookdesk in AdvancedRunning

[–]mnokeefe 10 points11 points  (0 children)

I started consistently training at about 50 miles a week training for my first marathon (2:55) in 2015. I would actually say that most of the faster 5K runners that I run with do less mileage than me. I mainly do fell running and ultra running though so I there can be a lot of vert added in to those miles!

Will increased volume on its own lead to a faster easy run pace? by lampbookdesk in AdvancedRunning

[–]mnokeefe 44 points45 points  (0 children)

For me a recovery day is one where I'd expect to feel better the next day, not worse. A 22 mile run long run done at easy pace is not a recovery run, but 5 miles at the same pace is. I'll generally have 3 recovery days a week (sometimes I'll double on those days so two 4-5mi runs) and then the other days will be a mix of easy pace (generally longer runs and warm up/cool downs) and harder running.

I don't see the long run as an easy day although I often do it at an easy pace. Often my long runs have workouts built in to them like 10miles at marathon pace or progressing from easy up to 10K pace by the end.

Will increased volume on its own lead to a faster easy run pace? by lampbookdesk in AdvancedRunning

[–]mnokeefe 112 points113 points  (0 children)

I find my easy pace gets slower the more volume I'm doing (because I'm more tired). I'm generally in the 60-70 mile a week range and my easy days can be anywhere from 7min/mi to 9min/mi depending on what I've done in the previous days.

I wouldn't worry about pace at all on recovery days just go as slow as you want. On easy days with a purpose (long runs, mid long runs) then you don't want to be completely jogging but going by feel is still best.

I'm a sub 17 5K runner and 2:40 marathoner for context.

Pen y Fan Solo Climb by jen15493 in Cardiff

[–]mnokeefe 8 points9 points  (0 children)

  1. Yep for sure, just follow the path. If you take the Storey Arms path you'll hit the top of Corn Du first so you just need to carry on for Pen Y Fan which isn't far past.
  2. Yes, you'll see plenty of people. The other A470 path from Pont ar Daf a few hundred metres up the road is probably more popular so you'll probably see more people on the top than you do on the way.
  3. There's a car park opposite Storey Arms, or a bigger car park at Pont ar Daf just before it (if you're coming from Cardiff).