• 0 Posts
  • 35 Comments
Joined 1 year ago
cake
Cake day: July 1st, 2023

help-circle
  • Don’t use JSON for the response unless you include the response header to specify it’s application/json. You’re better off with regular plaintext unless the request header Accept asked for JSON and you respond with the right header.

    That also means you can send a response based on what the request asked for.

    403 Forbidden (not Unauthorized) is usually enough most of the time. Most of those errors are not meant for consumption by an application because it’s rare for 4xx codes to have a contract. They tend to go to a log and output for human readers later, so I’d lean on text as default.


  • Either do a left join and repeat all the post values for every tag or do two round-trip queries and manually join them in code.

    JSON_ARRAYAGG. You’ll get the object all tidied up by database in one trip with no need to manipulate on the receiving client.

    I recently tried MariaDB for a project and it was kinda neat, having only really messed with DynamoDB and 2012 era MsSQL. All the modern SQL languages support it, though MariaDB and MySQL don’t exactly follow the spec.





  • Your dad is right. On desktop, navigation is on the left. On tablet, you shrink it to a rail. On mobile it should be a dismissible nav drawer.

    The top menus, especially the flyover(on mouse hover), are bad for accessibility because they convert a non-committal action (hover) to a context changing one (focus). It’s a uniquely web-only invention and thankfully falling out of usage. (Unless you mean menubar/toolbar. Those are fine but extremely rare on Web.)


  • Yeah, that’s a big simplification and I get it. But the async syntax itself syntax “sugar” for Promises. It’s not like C# or Java/Android where it will spawn a thread. If you take a JSON of 1000 rows and attach a promise/await to each of them, you won’t hit the next event loop until they all run to completion.

    It’s a common misconception that asynchronous means “run in background”. It doesn’t. It means run at end of current call stack.

    Prior to that, the browser had window.setTimeout and its callback for delays and animation and such - but that’s it.

    And you STILL have to call setTimeout in your async executions or else you will stall your UI.

    Again async is NOT background. It’s run later. async wraps Promise which wraps queueMicrotask.

    Here is a stack overflow that explains it more in detail.



  • ShortFuse@lemmy.worldtoProgrammer Humor@lemmy.mlSTOP DOING ASYNC
    link
    fedilink
    arrow-up
    4
    arrow-down
    1
    ·
    8 months ago

    Async prevents locking a thread during this wait.

    That’s a very common misconception. async is just a scheduling tool that runs at the end of event loop (microtask queue). It still runs on the main thread and you can still lock up your UI. You’d need Web Workers for actual multi-threading.


  • async/await is just callback() and queueMicrotask wrapped up into a neat package. It’s not supposed to replace multi-threading and confusing it for such is dangerous since you can still stall your main/UI thread with Promises (which async also wraps).

    (async and await are also technically different things, but for the sake of simplicity here, consider them a pair.)



  • The problem is it’s a script that logs onto Haier’s servers with the user’s email and password and starts polling for data. Considering that most designed usage is probably based around users every once in a while checking and adjusting their thermostat, just one user with an HACS install doing a poll every minute is 1440x more usage than the next who checks it once a day. If HACS uses were the majority of traffic for these devices I wouldn’t be surprised by that metric.

    That’s what probably meant by the ToS because the users using it are probably violating it, and the addon can be considered as something that makes violating it easier (it doesn’t have a secondary purpose other than using a set of credentials that are only given after accepting the ToS).

    I’ve had crappy “Smart” ACs and Samsung was the absolute worst. At random times their AWS instance in Europe would go down or their app wouldn’t respond. I gave up and coded my own script to directly interface with the device over the local WiFi. You cut Samsung completely out of the equation. You don’t have to worry about their servers not working anymore. That’s an ideal way for an add-on to work. Ideally most of the script can be retuned to work directly with the device.


  • Did well with Brother laser printer. Canon was okay.

    I had setup a friend’s HP printer and noticed he was constantly switching to WiFi Direct in order to print. I did him the favor of connecting it to the AP, so he wouldn’t have to manually switch all the time.

    The moment it got online, the printer locked itself down and refused to continue print until he paid for a subscription service on the ink.



  • Different locations can have different CPC (cost-per-click) bid configured. Even if you have multiple locations of a business, it’s still managed per site. Different areas also have different CPC rates depending on who is around that location (not including your own businesses). For example, a metropolitan CPC rate is higher than a rural one because so many others compete with you.

    That 25 minute one is near a bunch of other stores and I’d bet has a higher CPC rate. The 2 minute one is more isolated.

    I checked and that all have about the same rating (3.5), so it shouldn’t have been ranked by that. In the end, Google isn’t picking what’s best for the consumer, and enough to encourage me to go 20 minutes extra out of my way. Them being all the same franchise helps clarify it isn’t an issue of finding a better search term match since they’re all identically labeled the same.






  • That’s a strawman. I don’t need 1000s of lines of JS to swap a UI. I can do it in 1 line with Web Components: oldElement.replaceWith(newElement). And those modules can be lazy loaded like anything else.

    This is just DX in name of UX, which is almost never a good idea.

    And maybe you’re fine with throwing a server computation for every single UI change, but I’m not made of money and I much rather have stuff on a CDN.