Live data from Hacker News

Sqids – Generate short unique IDs from numbers

sqids.org

71–80 of 249 posts

Re: Sqids – Generate short unique IDs from numbers

#71

Odd design decision in that if you provide your own blocklist, it overwrites their (extensive) default list instead of adding to it. And in general the algorithm is surprisingly complicated for something that could be replaced with simply base64 encoding, the given example (1,2,3) base64 encodes to a string with just one more letter than this algorithm. That said I do appreciate the semicolon-free-style. I don't typi…

The problem is their block list will change over time. If you don't override it, then your IDs won't decode right when you update. This is a huge risk.

> You have to account for scenarios where a new word might be introduced to the default blocklist

https://sqids.org/faq#future-blocklist

Honestly, I think they need to rethink this. Otherwise you've got different library versions for different languages each using different default blocklists, none of which are compatible.

Re: Sqids – Generate short unique IDs from numbers

#73
post #67
post #27

Earlier quoted context omitted.

Omit vowels and you're 90% of the way there; omit the vowel-looking digits 0,1,3,4 and you're probably >99% of the way there.

fxck

Which is, evidently, why nanoids also excludes x and X, as well as v and V (fvck).

Re: Sqids – Generate short unique IDs from numbers

#74
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…

> That doesn't seem possible. How would that work? agree; b00b, DlCK, cntfcker But I suppose, if user doesn't get to craft input, the collision space of converted numerical ids and words like above is sufficiently small to be ignorable.

Besides vowels, nanoid excludes 0, 1, 3, 4, 5, I, l, x, X, v, V, and other lookalikes, so the chances of generating something naughty in any language are close to zero.

Re: Sqids – Generate short unique IDs from numbers

#76
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

#77
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…

> you can tell the growth rate of the company.

You can even do this when you don’t know the exact interval by using probabilities. The Allies used this method to estimate German tank production in World War II by analyzing the serial numbers of captured or destroyed tanks.

This is know as the German Tank Problem [1]

[1] https://en.wikipedia.org/wiki/German_tank_problem

Re: Sqids – Generate short unique IDs from numbers

#79
post #49
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…

Looks like the dictionaries used are from this file? https://registry.npmjs.org/naughty-words/-/naughty-words-1.2... From a quick look, the lists are pretty short, except for the one with English words that at least have some 404 words, but I can imagine there are far more bad words that you want to avoid than just those?

Here's the C++ of the sqid blocked words https://github.com/sqids/sqids-cpp/blob/main/include/sqids/b...

Re: Sqids – Generate short unique IDs from numbers

#80
post #41

Earlier quoted context omitted.

[flagged]

I have over 20 years of experience, I run a team, and I can code something like this in my sleep, as well as any average developer (but maybe "average" is lower than where it used to be in my day). Don't talk down to strangers on the Internet so arrogantly, you only end up embarrassing yourself. I went to check what this code does (beyond a base conversion with a custom alphabet) and I laughed my ass off. 1. Literall…

>Don't talk down to strangers on the Internet so arrogantly, you only end up embarrassing yourself

hoisted by your own petard there, gramps

Post reply on HN