HNHacker News
TopNewBestAskShowJobs

yawaramin

4,189 karma · joined November 3, 2012

submissionscomments
yawaramin··on Times New American: A Tale of Two Fonts
Tbh they should have just mandated it to Aptos for new communications, with TNR and Calibri acceptable for old devices that have not been updated yet. Having people spend effort overriding the default font on their machine is frankly a waste of taxpayer dollars.
yawaramin··on Times New American: A Tale of Two Fonts
SQLite would like to have a word...
yawaramin··on You can make up HTML tags
Thanks, that's good to know. In some contexts I don't think a custom element is ever added to the DOM more than once, eg in htmx I am responding with HTML markup which is then injected into the page and then just kept there, possibly 'forever' or at least until it is replaced by some new markup from a new response.
yawaramin··on Please just try HTMX
> Now you need to have OOB swaps and your HTML must contain that fragment.

This is super simple to do if you are using a library to generate HTML in your backend programming language.

> Not just that your server template code now has to determine if it is HTMX request and only render OOB fragments if so.

This is literally just a function that checks for a couple of headers, chooses between two rendering options, and adds a `Vary` response header to take care of the caching. Hardly anything complicated.

> htmx can do it but it's going to be very very difficult and brittle.

The problem with this summary is that it misses the point–htmx is not doing backend stuff, your backend app server is. Htmx is just swapping in what the backend sends.

> it is NOT the only tool for all use cases.

The OP said exactly this, the htmx people have always said this, and no one ever claimed otherwise. There are people out there who don't think in absolute all-or-nothing terms.

yawaramin··on Please just try HTMX
Where it's much easier to abstract and manage...if you use good architectural patterns in the backend.
yawaramin··on Please just try HTMX
> The thing is most of us have jobs where we can't unilaterally switch to the 'cooler' solution, and I value my own context-switching overhead much more than I value a slightly smaller bundle or dep tree.

And this is how your company ultimately loses in the market. For every bloated incumbent you will get a snappy new competitor. Keep saying 'it's not worth it to try new stuff', right until you finally realize you never learned anything new and now your company made you redundant.

yawaramin··on Please just try HTMX
This is easy to solve. Just configure htmx to automatically add an `Accept-Version` header to its requests:

    document.addEventListener('htmx:configRequest', evt => {
      evt.detail.headers['Accept-Version'] = APP_VERSION;
    });
And have a middleware that checks for this header. If it finds a version mismatch, have it respond with an HTTP 400 and a message to update the app to get the latest version. This is pretty similar to what many SPAs are already doing nowadays so it shouldn't come as a big surprise.
yawaramin··on Please just try HTMX
> Imagine if you had a Java or Swift application and had the server sending your phone UI screens. I don’t even know how you would pitch that.

https://www.reddit.com/r/iOSProgramming/comments/1khv43o/com...

'This technique is known as Server Driven UI and it is used by Uber, AirBnb and several other big players. The idea is to change the UI instantly without submitting a new version. Developer can just add a new entry in JSON, which can map to an existing component (already available in the binary) and then that component gets displayed on the screen.'

If you pitch to your business that you can update the app automatically without an app store submission, they will start salivating, if not foaming at the mouth.

yawaramin··on Please just try HTMX
https://dev.to/yawaramin/why-hx-boost-is-actually-the-most-i...

https://dev.to/yawaramin/handling-form-errors-in-htmx-3ncg

yawaramin··on Please just try HTMX
That's what we've been trying to tell you!
yawaramin··on You can make up HTML tags
Well, that's why I include JS files at the bottom of my HTML body, to make sure to avoid exactly this problem: https://github.com/yawaramin/dream-html-ui/blob/92f2dfc51b75...
yawaramin··on MongoBleed Explained Simply
https://news.ycombinator.com/item?id=46417221
yawaramin··on You can make up HTML tags
See https://news.ycombinator.com/item?id=46417607
yawaramin··on You can make up HTML tags
So, the article doesn't discuss this, but there's actually a really good reason to make up and use custom elements: the browser can hydrate their dynamic behaviour automatically. For example, suppose you have:

    <div class=expander>
      <button aria-expanded=false>Expand</button>
      <!-- Some other stuff here -->
    </div>
And you have some JS that handles the expander's behaviour:

    for (const expander of document.querySelectorAll('.expander')) {
      const btn = expander.querySelector('button');

      btn.addEventListener('click', () => {
        btn.ariaExpanded = 'true';
      });
    }
This will work fine for `.expander` divs that are already in the page when the event handler is set up. But suppose you dynamically load new expander divs, what then? Your event handler is not going to retroactively set up their click listeners too.

Custom elements solve exactly this problem. You can now do:

    <expander-elem>
      <button aria-expanded=false>Expand</button>
      <!-- Some other stuff here -->
    </expander-elem>
And then set up the listener:

    customElements.define('expander-elem', class extends HTMLElement {
      connectedCallback() {
        const btn = this.querySelector('button');

        btn.addEventListener('click', () => {
          btn.ariaExpanded = 'true';
        });
      }
    });
And the browser will ensure that it always sets up the listeners for all of the expanders, no matter whether they are loaded on the page initially or dynamically injected later. Without this you would have had to jump through a bunch of hoops to ensure it. This solves the problem elegantly.
yawaramin··on Package managers keep using Git as a database, it never works out
It's free: https://developers.cloudflare.com/d1/
yawaramin··on Package managers keep using Git as a database, it never works out
As opposed to a proprietary cloud git hosting platform?
yawaramin··on Package managers keep using Git as a database, it never works out
People have: https://0install.net/
yawaramin··on Package managers keep using Git as a database, it never works out
Use an SQLite database file, stream out delta updates to clients using zipped plaintext or Litestream or something.
yawaramin··on Package managers keep using Git as a database, it never works out
https://litestream.io/
yawaramin··on Package managers keep using Git as a database, it never works out
There's no need to have a publicly accessible database server, just put all the data in a single SQLite database and distribute that to clients. It's possible to do streaming updates by just zipping up a text file containing all the SQL commands and letting clients download that. Or even a more sophisticated option is eg Litestream.
yawaramin··on Package managers keep using Git as a database, it never works out
It's not a monorepo though? It's a package index, it has the package metadata. It doesn't have the actual source code of the projects themselves.
yawaramin··on Archiving Git branches as tags
We're deleting them because we don't need them and we like keeping things tidy.
yawaramin··on Package managers keep using Git as a database, it never works out
Package registry in an SQLite database, snapshotted daily. Stored in a cloud bucket. New clients download the latest snapshot, existing clients stream in the updates using eg Litestream. Resolving dependencies should now be ultra fast thanks to indexes.
yawaramin··on Archiving Git branches as tags
True. At work our flow is to tag commits that we want to mark as release candidates and delete feature branches after their PRs are merged/declined. We've never had a need to archive branches.
yawaramin··on The Rise of SQL:the second programming language everyone needs to know
OK. My definition is that it should be able to add two integers together and give you a result somehow. So in SQL:

    select 1+1; -- Result: 2
In HTML: not possible.

That's the key difference.

yawaramin··on Things I learnt about passkeys when building passkeybot
No, Apple can't suddenly start doing attestation in the future by default because that would instantly kill all the passkeys that have already been created on Apple devices without attestation. It would be as if a home security company went around and changed all the locks they had installed on their customers' front doors. It would be instant suicide as a trusted vendor.
yawaramin··on The Rise of SQL:the second programming language everyone needs to know
Not really. ORMs have defining characteristics that hand-rolled SQL with mapping code does not. Eg, something like `Users.all.where(age > 45)` create queries from classes and method calls, while hand-rolled SQL queries are...well..hand-written.
yawaramin··on Things I learnt about passkeys when building passkeybot
Passwords are also simply phished, and many people have discovered those sharp edges by getting their accounts hacked.
yawaramin··on Things I learnt about passkeys when building passkeybot
As I said earlier, this is functionally impossible because Apple devices don't offer device attestation data.
yawaramin··on Things I learnt about passkeys when building passkeybot
Apple doesn't do attestation, so effectively this feature is dead in the water.
← PreviousPage 5 of 34Next →