u/kap89

14.2k post karma · 10.0k comment karma · joined Jun 2019 · moderator

  1. 1,413points

    I made a free web app where you can practice typing by retyping books! (old.reddit.com) [Promotional]

    155 comments · source

  2. 100points

    I created a free, open-source website where you can create customized chess GIFs and share replays of the chess games. (self.chess) [Resource]

    11 comments

kap89

Thank's for the idea, but it would require adding an engine analysis, which is outside of the scope of the project, at least for now.

kap89
kap89

Well yeah, once you are in the "async land" you have to stay there. Of course this doesn't mean that every single function has to be async, you can separate operations on data (normal functions) from "flow control" functions (async functions), that's the cleanest solution, but "flow control" functions will be async all the way down.

kap89

It’s a PWA (progressive Web app), it’s not a native app, but you can install it on desktop and mobile through web browser and it should work offline at least for the chapters you already started

kap89

using an old-style keyboard with stiff keys

That's the culprit then, the rest sounds fine. It's just muscle soreness from typing on a heavy keys, you can either change the keyboard, or just take a rest when it starts hurting - you can type on a heavy keyboard, but your muscles have to adjust, just don't "push through the pain", and you will be ok. I assume you just didn't use the ring finger and associated forearm muscle while typing before.

kap89

I'm not sure if that's exactly what you want, but you can export (and load) you save file in settings:

https://entertrained.app/settings#manage-data

kap89

Sofascore is decent

kap89

CONCLUSION FOR THOSE WHO DON'T LIKE LONG READS

tl;dr should go at the beginning of the post, not at the end - that's the whole point of writing it.

kap89

Anyone know where one is?

There isn't one currently, so just enjoy!

kap89

I mean yeah, as I said - the choice here is mostly stylistic, both work well.

https://preview.redd.it/a27zl9zce8yg1.png?width=1024&format=png&auto=webp&s=92aecaeb7b95531cd0b563f8fa371862e560d82d

The differences are the most apparent the smaller you get (as you can see on the examples of the smallest possible blocks from which you can build all the others - in the center of the first row), if you have high resolution canvas, then they start to look nearly identical.

kap89

that's a wrong shape for this version of the "cube", here's the one that tiles just as well:

https://preview.redd.it/uy5m1rlm38yg1.png?width=676&format=png&auto=webp&s=23c47ca50d3e5a3003f91426dd23bf69c7ad5901

kap89

I prefer 62x32 version, as it divides evenly into 4 quarters. The 64x31 version though, while less "mathematically pure", has softer top and bottom edges, which some people prefer.

kap89

by at least a factor of 10

It depends on the size of the original, for Reddit you would use factor that produces at least 1000 px final image, so for original 256x256 it could be as small as 4x, but for OP that looks like 16x16 px it would be at least 63x.

kap89

Ahem, Ash!

kap89

You're right, but that's a stupid requirement, there is a ton of examples where filter is the best solution, why use the one where it's not? Anyway, here's a version using filter:

function diffArray(arr1, arr2) {
  return [...arr1, ...arr2].filter(item => !arr1.includes(item) || !arr2.includes(item))
}
kap89

I would use sets in this case - they have build-in methods for doing what you want:

function diffArray(arr1, arr2) {
  return [...new Set(arr1).symmetricDifference(new Set(arr2))]
}

here's the same thing with comments and a bit more verbose:

function diffArray(arr1, arr2) {
  // Convert the arrays to sets
  const set1 = new Set(arr1)
  const set2 = new Set(arr2)

  // Find a difference between set1 and set2, as well as between set2 and set1
  const diff = set1.symmetricDifference(set2)

  // Convert back to array and return,
  // I used spread syntax, but Array.from(diff) also works
  return [...diff]
}
kap89

Aren’t the “surplus dots “ just nails?

kap89

Btw, you can simplify your debounce function to this:

function debounce(fn, delay) {
  let timer;

  return (...args) => {
    clearTimeout(timer);
    timer = setTimeout(fn, delay, ...args);
  };
}
kap89

Look at the shadows (easiest to spot are legs of Janik, Carlos and Demon) - they all point in different direction and make no sense. No competent artist would make that mistake.

kap89

Yeah, I think you’re right, I must have been tired yesterday to not notice that.

kap89

I see you edited your comment.

I thought closure technically means it has to maintain live references to something in the function’s scope after it returns?

What do you mean by "live reference" here?

kap89

Yes, that's the case of theory vs actual engine implementation - conceptually they are closures, but the engine can optimize them away.

kap89

I get what you are trying to say, but that would be a very narrow (and imo incorrect) definition of the closure. I still create a closure over the shared methods when returning the object. Additionally, using this and using closures are orthogonal concepts, one does not cancel the other.

You may say that you wanted to compare the classes to the typical closure pattern (as you described) - but that makes your critique incomplete, as the classes are not the only solution here, as I explained above.