- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
generate_ident_value(ident, value + frist)
Admin
Ident. Database. You'd think that should ring a bell or two with any developer...?
Admin
"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!" ...
Admin
Pff! Amateur! I would use random UUID.
Admin
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.
Admin
TRWTF is you speculating about well documented behaviour: https://ruby-doc.org/core-2.2.0/Random.html#method-c-rand
Admin
What is the difference between the well documented behaviour and what Bruce Reed is saying?
Admin
As usual, your formatting is bad and you should feel bad.
Admin
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?
Admin
But then pass it threw SHA-1 to make it secure
Admin
Never delete accounts, just mark them inactive.
Admin
Hi guys!
I would have been here sooner! BUT:
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!
Admin
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.
Admin
I'll just rewrite it again.
I guess Science really would burn Galileo at the stake again!
Admin
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.
Admin
There are three things that developers should never try handling on their own. Date/time arithmetic, encryption, and identifiers.
Admin
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.
Admin
I feel like you'd do better with an integer expressing the number of nanoseconds since you put the database into production.
Admin
Welcome to our world!
Your new user ID is: joebob4562771d4e36acvfw9jhtSxUT43gdW@3w2$!67vF☆⊙K
Just enter that on the simple sign on screen and enjoy!
Admin
Is there a specific name for the kind of odd troll that whoopie_doopie_do is? Just wondering.
Admin
untill you are hit with GDPR
Admin
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...