Live data from Hacker News

Sqids – Generate short unique IDs from numbers

sqids.org

171–180 of 249 posts

Re: Sqids – Generate short unique IDs from numbers

#171
post #70

Side note: there are some business insights you can get from a company using serial ids. i.e if you sign up and get user id 32588 and make another account a few days later, you can tell the growth rate of the company. And this is possible with every resource type in the application. I do wonder how much the url bar junk thing matters these days. I tend to use uulids (waiting on uuid v7 wide adoption), and they're a b…

[deleted]

Re: Sqids – Generate short unique IDs from numbers

#172
post #70

Side note: there are some business insights you can get from a company using serial ids. i.e if you sign up and get user id 32588 and make another account a few days later, you can tell the growth rate of the company. And this is possible with every resource type in the application. I do wonder how much the url bar junk thing matters these days. I tend to use uulids (waiting on uuid v7 wide adoption), and they're a b…

Yes but just using Sqids doesn't fix this. Sqids are decodable. You need to use a random or otherwise unpredictable input.

What's the advantage of uuid7 (sequential + random) vs uuid4 (full random) for this?

Re: Sqids – Generate short unique IDs from numbers

#173
Makes me think of something totally different, which is how Urbit converts randomly generated numerical IDs into sorta memorable names.

For example, the number 5,702,400 becomes ~sorreg-namtyv. And 1,742,733,824 becomes ~master-morzod.

I enjoy the quirkiness of the names.

Re: Sqids – Generate short unique IDs from numbers

#174
post #47
post #42

Earlier quoted context omitted.

I believe a big part of the idea is for the hash to be unpredictable as well. If I figure out you're using (36) then I know the next number 1234567891 is "kf12oj". Not the case with Sqids.

I'd prefer to use crockford-encoded entropy with Stripe-style token prefixes to create unique ID namespaces. Run in through a bad words filter, and it's perfect. user_1hrpt0xpax7ps file_xpax7psaz0tv6az0tv6 Etc. In distributed systems you can use the trailing bytes to encode things like author cluster, in case you're active-active and need to route subsequent writes before create event replication. Easy to copy, debug…

this is very interesting. do you know how amazon creates its order id ? they are all numeric

Re: Sqids – Generate short unique IDs from numbers

#176
post #12

Earlier quoted context omitted.

> it excludes letters used for profanity That doesn't seem possible. How would that work? > I looked at the implementation and it’s hardcoded to look for “bad” words. If you mean https://github.com/y-gagar1n/nanoid-good , that seems to be doing the same thing. In general, I'm a bit weary of solutions that "guarantee no bad words" – this is usually highly language-specific: One language's perfectly acceptable name is…

It's particularly funny because their example docs for .NET outputs "B4aajs", which to any Swedish l33t speaking individual, would read "Bajs", which means "shit"

Somewhere there's a database for every bad word and every bad typo in every language and that one just got added.

Re: Sqids – Generate short unique IDs from numbers

#177
post #109
post #70

Side note: there are some business insights you can get from a company using serial ids. i.e if you sign up and get user id 32588 and make another account a few days later, you can tell the growth rate of the company. And this is possible with every resource type in the application. I do wonder how much the url bar junk thing matters these days. I tend to use uulids (waiting on uuid v7 wide adoption), and they're a b…

I see so many organizations add weird slowdowns from debts associated with this. I reflect on some of the most successful tech businesses of the last decade and remember that all their APIs exposed this kind of data early on and many still do. Does anyone have an example they can reference of a business being harmed by this information being out there?

I don’t know any stories of digital businesses but there was a case where someone went and counted customers at the door only to realize that the company was lying on the yearly reports.

So I guess that kinda harmed that fraudulent business strategy…

Re: Sqids – Generate short unique IDs from numbers

#178
post #70

Side note: there are some business insights you can get from a company using serial ids. i.e if you sign up and get user id 32588 and make another account a few days later, you can tell the growth rate of the company. And this is possible with every resource type in the application. I do wonder how much the url bar junk thing matters these days. I tend to use uulids (waiting on uuid v7 wide adoption), and they're a b…

Unless they are doing master-master replication so are incrementing by something other than 1

Re: Sqids – Generate short unique IDs from numbers

#179

Earlier quoted context omitted.

> most browsers Not chrome... Also, links are a thing in chat, etc

Heres what a recent youtube (which squid documents as a sample use case) link I shared looked like: > https://www.youtube.com/watch?v=fFMzQ3tYTFU&pp=ygURY2hQImVzZ... Or Twitter: > https://x.com/elonmusk/status/172853302828286055507?s=20 Or TikTok: > /video/730292574259232054785?is_from_webapp=1&sender_device=pc" rel="nofollow noreferrer">https://www.tiktok.com/@ /video/730292574259232054785... While I tend to strip t…

If you use the share button and not the url bar you get prettier and shorter urls.

Don’t know how common that is. Wouldn’t be surprised if no -techies don’t know how to copy from url-bar.

Re: Sqids – Generate short unique IDs from numbers

#180
post #38

In a Ruby app we just convert to a high base, like > 1234567890.to_s(36) => "kf12oi" That gets us most of the way there, but Sqid has a Ruby library and lets you set a much higher base, including upper case characters, and I suppose, emoji. We're going to need much bigger numbers before that space savings makes much difference. I like it, but it's hard to know when something like that is worth adding a dependency.

BaseEmoji is a thing: https://github.com/amoallim15/base-emoji

Ironically its default encoding is base 55. I figured if you're going to use emoji you should at least use the size of the space to maximize the numbers of bits per grapheme beyond what is possible with ASCII, but apparently not.

Which I guess is the part where senior (citizen) programmers like me get triggered as promised in the README.

Post reply on HN