Live data from Hacker News

Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs

github.com

21–30 of 236 posts

Re: Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs

#21
post #19

Another, less known, useful thing about these IDs is that you can double click on them and the full id will always be selected

This is a setting in your terminal emulator. For me, plain UUIDs are selected just fine when double clicking.

Re: Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs

#22

Earlier quoted context omitted.

yep, youtube video ids has/had? same issue where it would have things like fag/f4g etc in it. eg: google "allinurl:fag site:youtube.com"

You can prevent any obscenity, O and 0 confusion, and I and L confusion, just by excluding vowels. If someone interprets "f4g" in an offensive way, then they have bigger issues than can be dealt with in software.

Why we care about obscenity in pseudo-random ids and url?

Re: Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs

#23
This is very similar to how I generate IDs in a project I'm working on.

Example:

    |-A-|-|------------B--------------|
    NMSPC-9TWN1-HR7SV-MTX00-0H8VP-YCCJZ
    A = Namespace, padded to 5 chars. Max 5 chars. Uppercase.
    B = Blake3 hashed microtime with a random key.
I like how it folds in a time component but that it also doesn't reveal the time it was generated.

Here's the snippet: https://gist.github.com/jszym/d3c7907b7b6e916f68205c99e5e489...

Re: Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs

#24
post #20
post #4

Unrelated, but this links to "Crockford's alphabet", https://www.crockford.com/base32.html , which is a base-32 system that includes all alphanumeric characters except I and L (which are confusable with 1), O (which is confusable with 0), and U (????). The page says the reason for excluding U is "accidental obscenity'. What the heck is it talking about?

The Scunthorpe problem? https://en.m.wikipedia.org/wiki/Scunthorpe_problem

There's enough comedic content in this article for several Silicon Valley episodes.

Re: Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs

#26

Earlier quoted context omitted.

yep, youtube video ids has/had? same issue where it would have things like fag/f4g etc in it. eg: google "allinurl:fag site:youtube.com"

You can prevent any obscenity, O and 0 confusion, and I and L confusion, just by excluding vowels. If someone interprets "f4g" in an offensive way, then they have bigger issues than can be dealt with in software.

There was that time Delta generated an "H8GAYS" PNR. [1] Pretty sure that's valid Crockford encoding too :) however, to your point, it does rely on 'A'. "H8G4YS" would likely still offend someone out there, though, given the kerfuffle in [1].

[1] https://newsfeed.time.com/2013/12/17/delta-airlines-is-very-...

Re: Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs

#27
post #4

Unrelated, but this links to "Crockford's alphabet", https://www.crockford.com/base32.html , which is a base-32 system that includes all alphanumeric characters except I and L (which are confusable with 1), O (which is confusable with 0), and U (????). The page says the reason for excluding U is "accidental obscenity'. What the heck is it talking about?

A coworker and I came up with basically this same set about 4 years before Crockford. We were trying to solve the url slug problem, and they were long enough that we felt 5 bits per byte would reduce transcription annoyances.

In the end I think we had a couple of characters to spare, and so, sitting by ourselves because everyone else had gone home for the day, we ranked swear words by how offensive they were to prioritize removal of a few extra letters. Then I convinced him that slurs were a bigger problem so we focused on that, which got rid of the letter n, instead of u

tggr is just cute, n**r is an uncomfortable conversation with multiple HR teams (we were B2B)

I'm a bit fuzzy now on what our ultimate character set was, because typically you're talking [a-z][0-9], an there are a lot of symbols you can't use in urls and some that are difficult to dictate. My recollection is that we eliminated both 0, l, and 1, but I think we relied on transcription happening either from all caps or all lowercase. 0o are not a problem. Nor are 1L.

Re: Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs

#28
post #19

Another, less known, useful thing about these IDs is that you can double click on them and the full id will always be selected

This is a setting in your terminal emulator. For me, plain UUIDs are selected just fine when double clicking.

There's life outside of the terminal. For example you want to double-click on the part of a URL in your browser.

Re: Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs

#29

UUIDv7 has been taking HN by storm for years now! When is it going to become a proper standard, and when are libraries and databases and all the rest going to natively support it?

Its been going through drafts and improvements. It's very close to being standardized, and many libraries are supporting it already, or new offerings are being added. For example I maintain the Dart UUID library, and my latest beta major release has v6, v7 and a custom v8. There is a list of them somewhere, I know I get pinged on every new draft by the authors because I am listed as a library maintainer on one of their pages.

Re: Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs

#30
I do a similar thing [1]. One of the great advantages to formally namespaced IDs is including a systematic conversion into strong types in your code. It's harder to accidentally mix things up when coding; function parameters and return tuples are more 'self documented' (and enforced by compiler where applicable).

[1] - https://www.peakscale.com/strongly-typed-ids/

Post reply on HN