• 0 Posts
  • 27 Comments
Joined 1 year ago
cake
Cake day: June 15th, 2023

help-circle
  • The ease of buying a quality laptop without having to worry about if it will run well with my OS.

    I’ve been using MacOS for about 8 years at work and I never really taken to it. It’s fine and I can do my work but I won’t use it if I hadn’t to (unless the only alternative was Windows). But one thing I really like about Macs is that you can buy one and you won’t have any headaches with battery life, software compatibility etc. You get decent hardware (let’s ignore the whole 8GB on an M3 = 16GB on other machine debacle) and know that it will work decently well with 3rd party software/hardware and if something breaks you can just bring into an Apple store.

    While there are dedicated Linux sellers (System76, Tuxedo Computeres, Starlabs), I’m hesitant to spend 2k on a computer just to find out that the build quality is subpar, the battery life sucks or that customer support will just ignore my requests (read some bad experiences on the Starlabs subreddit).





  • Firefox now supports a setting (in Preferences → Privacy & Security) to enable Global Privacy Control. With this opt-in feature, Firefox informs the websites that the user doesn’t want their data to be shared or sold.

    This sounds like Do Not Track revisited. The only difference that I can find (only skimmed the website) is, that there seems to be some legal support for this in the state of California.

    Now you can exercise your legal privacy rights in one step via Global Privacy Control (GPC), required under the California Consumer Protection Act (CCPA).

    I wonder:

    1. How does this differ from DNT?
    2. Does this this have any real chance to take off? From what I’ve heard, DNT has been rather counterproductive as it can be used to fingerprint users.














  • I think I misunderstood your initial post (and definitely didn’t read it as carefully as I should have 😅).

    Do I understand your correctly that your goal is a companion object for your arrays that simplifies access? Not a new data structure that you’d user instead of arrays? If so, most of my points are moot.

    If your IDs are integers then there is no need for an hybrid at all, precisely because all you have to do is put each item at the same position as their ID.

    If you don’t treat IDs as opaque values, this is true.

    I’ll definitely run benchmarks so that users would be aware of performance losses, if any. But use cases of hybrid arrays are mostly small datasets so it usually shouldn’t be a concern indeed.

    I think my point is actually wrong (it was really late when I was writing my initial response). Performance would be O(n), since that’s the worst case scenario.

    Anyways, I hope you could take something useful from my answer.

    Happy hacking :D


  • I’m pretty sure I’ve been in your situation but haven’t created a dictionary/array hybrid.

    Without any more details about your use case and situation, I can imagine a few pitfalls with your solution:

    • Serialization might not behave as you would expect (JSON.stringify).
    • 3rd-party functions might not be able to deal with your data structure properly (again, potentially unexpected behavior).
    • You can’t easily access array methods (find, filter, map etc).
    • How do you distinguish between ID access and index access? ArrayLike([ {id: "1" }, { id: "2" } ])[1] returns { id: "2" }, how do you access { id: "1" } by ID?
    • It’s harder to reason about access time of lookups. However, this might not be a concern of yours.
    • It may cause confusion if you’re working with other developers.

    That being said, unless you work in an environment where your code should be easily understandable by others, the best way to find out if this is a good idea or not, is to try :)

    Me personally, I usually use an associateBy function, when I need a values-by-ID structure. Of course this is not as convenient to use as your approach, but it’s good enough for me.

    // this WILL drop elements if key is not unique 
    function associateBy(array, key) {
      return array.reduce((acc, el) => ({
        ...acc,
        [el[key]]: el
      }), {});
    }
    
    associateBy([
      {id: "foo"},
      {id: "bar"}
    ], "id").foo; // -> {id: "foo"}
    

    Good luck!___