• AP (unregistered)

    generate_ident_value(ident, value + frist)

  • 🤷 (unregistered)

    Ident. Database. You'd think that should ring a bell or two with any developer...?

  • Daft Old Git (unregistered)

    "G'night Joebob!"

    "G'night John Boy!"

    "G'night Joebob1!"

    "G'night Elizabeth!"

    "G'night Joebob15!"

    "G'night Daddy!"

    "G'night Joebob159!"

    "G'night Mary Ellen!"

    "G'night Joebob1597!"

    "Bweerpghlk!" ...

  • jeff2356 (unregistered)

    Pff! Amateur! I would use random UUID.

  • Bruce Reed (google)

    I don't know Ruby, but doesn't rand(10) return just a number between 0 and 10? If so, this is a different WTF.

  • Not quite frist (unregistered) in reply to Bruce Reed

    TRWTF is you speculating about well documented behaviour: https://ruby-doc.org/core-2.2.0/Random.html#method-c-rand

  • unregistered (unregistered) in reply to Not quite frist

    What is the difference between the well documented behaviour and what Bruce Reed is saying?

  • gweest (unregistered)

    As usual, your formatting is bad and you should feel bad.

  • Carl Witthoft (google)

    How about an alternative, pseudocode: get(new_ident) #new username shows up for j = 1, j<= dbase_ident_count, j++ if new_ident == dbase_ident[j] print "username in use. pick another" break endif endfor dbase_ident[j+1] = new_ident

    Addendum 2018-03-28 12:05: well, so much for putting line breaks in, huh?

  • JG (unregistered) in reply to jeff2356

    But then pass it threw SHA-1 to make it secure

  • I Am A Robot (unregistered)

    Never delete accounts, just mark them inactive.

  • whoopie_doopie_do (unregistered)

    Hi guys!

    I would have been here sooner! BUT:

    1. ATI Raedon 220 R5 does not support 4K, even though the box weasels it out by referencing the 240 R7.
    2. The ability of NVidia Shield to "choke" 4K is yet to be determined.
    3. Blue shirt girls are so cute. They need a corporate policy where they take you out back and start humping on you if you wait in line too long. Don't worry, any part would do just as long as, you know, they finish there work and keep it clean!

    https://en.wikipedia.org/wiki/Draft:Orbital_Engineering#cite_note-A_Smooth_Exit_from_Eternal_Inflation?-1

    PS: wiki sux Google===0 April 1 Too Ate Teen Committee is still on! @comey

    See you tomorrow for Good Good Friday! Then it looks like I'm on "indefinite Easter break!"

    Talk to Stern about some more Pun and Games!

  • jarfil (unregistered)

    While it's true this would first check "joebob1", then "joebob15", "joebob159", "joebob1597" and so on... for THE NEXT "joebob" there is only a 1 in 10 chance of it trying "joebob1" again, and only a 1 in 100 chance of "joebob15"... and only a 1 in 10000 chance of trying "joebob1597" so it would have to add one more character. More probably it would just try "joebob7" or any other number, and be done with it.

    I see no WTF, and no reason for the field to keep growing... unless they had millions of users and/or users actually wanted to use longer usernames.

  • whoopie_doopie_do (unregistered)

    I'll just rewrite it again.

    I guess Science really would burn Galileo at the stake again!

  • whoopie_doopie_do (unregistered)

    https://en.wikipedia.org/wiki/User:JamesBWatson

    James B. Watson,

    hmmmm..

    Something tells me I'm going to remember that name.

    https://en.wikipedia.org/wiki/User:JamesBWatson https://en.wikipedia.org/wiki/User:JamesBWatson https://en.wikipedia.org/wiki/User:JamesBWatson

    James B. Watson

    Now, if only I had a mantra to serve as a mnemonic device.

    Night Ideals Mind We Ideal Night.

  • (nodebb)

    There are three things that developers should never try handling on their own. Date/time arithmetic, encryption, and identifiers.

  • isthisunique (unregistered)

    I've had lots of pains with stuff like this. It might not help immensely in this case but if you actually need it to be random then FPE is the way to go. This is something I wish was taught more often in CS. I had to research it myself and implement it myself (many platforms lack FPE libraries) which isn't fun when it comes to actually confirming you have it right and it's cryptographically secure if that's what you need.

    FPE lets you generate a shuffle based on a seed for a range of numbers. You don't need to store the shuffle or pad the values. You can just say tell me where 1 was relocated to (lets set it gives 10) then you can also do the reverse, ask where 10 was relocated from.

    The time and space complexity is O(1) so you can use it with huge numbers, even 64 bit. This is great for where you need a secure ID that's sparse enough people can't pick them at random but also need to fit within a confined space.

    In this WTF though I don't see a pressing need for it because it's clearly not for security. It's for finding an unused ID (++). This implementation is like auto-increment biased towards filling out the lower values. You get almost the same but no refill of low ids.

    The first time I used a DB I had something choosing an id at random. It took me a day of investigation to find auto-increment and fix it. What drove me is that having something that tries so many times and can arbitrarily fail, even if it seems really unlikely giving the size of the number range just doesn't feel right.

    A good developer will always have that twinge that this thing can fail but it should be possible to make it not, even if the failure rate is one in a billion. Most developers have a threshold that's too low. I'm not sure the threshold can be too high if you're able to factor in other costs appropriately.

    Many sadly lack a mathematical instinct for sets and structures to have a feel for these things. As in they don't actually perceive the way the sets will play out, overlap, underlap, grow, etc.

  • (nodebb)

    I feel like you'd do better with an integer expressing the number of nanoseconds since you put the database into production.

  • (nodebb)

    Welcome to our world!

    Your new user ID is: joebob4562771d4e36acvfw9jhtSxUT43gdW@3w2$!67vF☆⊙K

    Just enter that on the simple sign on screen and enjoy!

  • whoopie_doopie_do (unregistered) in reply to whoopie_doopie_do

    Is there a specific name for the kind of odd troll that whoopie_doopie_do is? Just wondering.

  • not a robot (unregistered) in reply to I Am A Robot

    untill you are hit with GDPR

  • IA (unregistered)

    I just tried that, the length of the id grows slightly faster than log10(id_count). There must be something much worse if they had to extend to 30...

Leave a comment on “A Unique Solution”

Log In or post as a guest

Replying to comment #494726:

« Return to Article