I haven’t been able to find a case for this because ids either need to be unique or they’re not going to be large. If they’re unique, I’m using uuid or ulid (uuidv7 of tomorrow) as the sortable primary key type to avoid conflicts without using the db to generate and maintain sequences. Where do you have unique ids that aren’t the primary key? I would be more interested in a retrospectively unique truncated encoding f…
Sqids – Generate short unique IDs from numbers
61–70 of 249 posts
Re: Sqids – Generate short unique IDs from numbers
#62Re: Sqids – Generate short unique IDs from numbers
#63Re: Sqids – Generate short unique IDs from numbers
#64It would be great to have a quick primer on why this is better than what people typically homebrew, like base62 encoding a random number.
Re: Sqids – Generate short unique IDs from numbers
#65Sad that it is not for user ids
Re: Sqids – Generate short unique IDs from numbers
#66Why should you hide your user count?
“$WEBSITE did 50,000 signups a month during the beginning of the pandemic, but now struggles to sign up a thousand a week” is a story.
Re: Sqids – Generate short unique IDs from numbers
#67Earlier 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…
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.
Re: Sqids – Generate short unique IDs from numbers
#68It would be great to have a quick primer on why this is better than what people typically homebrew, like base62 encoding a random number.
Features like the profanity filter avoid creating URL routes like /user/cuntFh.
Cross language support allows interop between the encoder and decoder across microservices written in different languages.
Re: Sqids – Generate short unique IDs from numbers
#69Earlier 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.
You can easily brute-force this. Sqids also says it's not good for sensitive data.
Re: Sqids – Generate short unique IDs from numbers
#70i.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 bit ugly, but most browsers hide most of the urls now anyway. The fact that there is a builtin time component comes in clutch sometimes (e.g. object merging rules).