Not so random Randomizer
-
import tools.*;
class tools.Randomizer {
static private var number:Number = 0;
static function getNumber():Number {
return number++;
}
}Random isn't random, but this...
-
Guaranteed to be unique, I guess.
-
He should add a random amount to it instead. As of right now, he will never get any negatives, 0s, or decimals.
<FONT size=3><FONT face=Calibri>And just to get it out of the way… this reminds of an overly abused xkcd that must never be linked: <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></FONT></FONT>
-
@dhromed said:
Guaranteed to be unique, I guess.
As long as there's only one thread...but then, true randomness is not unique, so I guess that's as ok as anything else about this.
-
I don't see a huge problem with this if it is used solely in a testing environment ... adds some ... predictabilty ... when testing something expected to be random.
Much like using a fake system clock which only ticks once every time it is accessed.
-
I'm curious why this exists. What is it used for?
-
@morbiuswilters said:
I'm curious why this exists. What is it used for?
It is used for generating id's... In multiple production environments.
I wish it was unique, 'cause that would mean it works as intended...
But it is not really a randomizer, but an ID generator.
-
@chillisaus said:
@morbiuswilters said:
I'm curious why this exists. What is it used for?
It is used for generating id's... In multiple production environments.
I wish it was unique, 'cause that would mean it works as intended...
But it is not really a randomizer, but an ID generator.
Ah, I see. Also, what language is this?
-
@morbiuswilters said:
Also, what language is this?
colon-type notation suggests Delphi, if I am not mistaken.
Or Pascal.
-
@dhromed said:
Very unlikely - { } are comment separators in Pascal/Delphi.colon-type notation suggests Delphi, if I am not mistaken.
Or Pascal.
-
Heh, this might be TRWTF, but it's ActionScript. 2.0 that is...
-
@chillisaus said:
Heh, this might be TRWTF, but it's ActionScript. 2.0 that is...
Server-side actionscript? I didn't even know that was possible..
-
@ender said:
@dhromed said:
TRWTF.
Very unlikely - { } are comment separators in Pascal/Delphi.colon-type notation suggests Delphi, if I am not mistaken.
Or Pascal.
@zelmak said:
So does srand(0), and that still gives random-looking numbers.I don't see a huge problem with this if it is used solely in a testing environment ... adds some ... predictabilty ... when testing something expected to be random.
-
-
@dhromed said:
@morbiuswilters said:
Server-side actionscript?
Who said it was server-side?
He said it was used for "generating IDs in multiple production environments". That definitely sounds like server-side work to me, but maybe not.
-
@Anketam said:
Woohoo! Rosie's *hot*!He should add a random amount to it instead. As of right now, he will never get any negatives, 0s, or decimals.
<font size="3"><font face="Calibri">And just to get it out of the way… this reminds of an overly abused xkcd that must never be linked: </font></font>[mod - you were warned]
[I'm only putting one Rosie here because there's already been enough awfulness in this thread. -TheShadowMod]
-
@morbiuswilters said:
He said it was used for "generating IDs in multiple production environments". That definitely sounds like server-side work to me, but maybe not.
Grandma's Facebook open to Farmville = "production environment".
-
@D-Coder said:
The only reason why I have a Rosie picture was I was testing to see if the moderators would catch the forbidden link, and they did. I was killing over laughing at how fast they caught and fixed it.@Anketam said:
He should add a random amount to it instead. As of right now, he will never get any negatives, 0s, or decimals.
<FONT size=3><FONT face=Calibri>And just to get it out of the way… this reminds of an overly abused xkcd that must never be linked: </FONT></FONT> <Rosie picture>[mod - you were warned]
[I'm only putting one Rosie here because there's already been enough awfulness in this thread. -TheShadowMod]
-
@Anketam said:
The only reason why I have a Rosie picture was I was testing to see if the moderators would catch the forbidden link, and they did. I was killing over laughing at how fast they caught and fixed it.
Surely this is achievable by a bit of regex on an input filter?
It's not a manual process.. is it?
-
@Cassidy said:
@Anketam said:
Well it did not instantly change, so I doubted that it was an auto script, it could be and it just took a while to run, specially if it needed to find a super special awesome picture of Rosie.The only reason why I have a Rosie picture was I was testing to see if the moderators would catch the forbidden link, and they did. I was killing over laughing at how fast they caught and fixed it.
Surely this is achievable by a bit of regex on an input filter?It's not a manual process.. is it?
-
@Cassidy said:
It's not a manual process.. is it?
Yes, it's manual. You think CS is capable of that sort of thing?
Besides - it took me a while to find a suitable picture for Anketam's. (I'm not responsible for the ShadowMod's efforts however.)
-
@PJH said:
@Cassidy said:
It's not a manual process.. is it?
Yes, it's manual. You think CS is capable of that sort of thing?Well, I'd have thought a site created by a developer, containing a forum that's populated with developers, moderated by those involved in the S/W engineering industry could have created a module that --
-- shit. Have I been trolled again?
-
-
Might I suggest that random links to XKCD be instead replaced with a link to a random XKCD as to destroy context. For example:
@Only 1/1000 chance of being right said:
"SQL Injection? have they not read this?!?"
<img src="http://houghtonhaunt.com/xkcd.php" />
-
@Cassidy said:
Well, I'd have thought a site created by a developer, containing a forum that's populated with developers, moderated by those involved in the S/W engineering industry
could have created awould have used a 3rd party module ,rather than reinventing triangular wheels, that --FTFY.
-
Either-or, really.
Or, perhaps more succinctly: "I'd have thought... could find some means to automate this process".
-
@Anketam said:
I was killing over laughing at how fast they caught and fixed it.
/me calls the police
@Lorne Kates said:
Might I suggest that random links to XKCD be instead replaced with a link to a random XKCD as to destroy context.
Considering the post that started it I actually linked to the page that gives you a random comic...Also...
[RTFY. -TheShadowMod]
-
@Sutherlands said:
@Anketam said:
I was killing over laughing at how fast they caught and fixed it.
* Sutherlands calls the police
@Lorne Kates said:
Might I suggest that random links to XKCD be instead replaced with a link to a random XKCD as to destroy context.
Considering the post that started it I actually linked to the page that gives you a random comic...Small difference. Your page randomly selects a comic, then forwards you to that page. You end up with a static result that you copy into an <img> tag.
My page serves up a random comic dynamically each time it is accessed, and is meant to be the src of an img tag.
Refresh the page a few times...
-
Did I derail this topic?
*sighs*
-
@Cassidy said:
@PJH said:
@Cassidy said:
It's not a manual process.. is it?
Yes, it's manual. You think CS is capable of that sort of thing?Well, I'd have thought a site created by a developer, containing a forum that's populated with developers, moderated by those involved in the S/W engineering industry could have created a module that --
-- shit. Have I been trolled again?
There was a CS module but its Quantum Intelligence Matrix would always commit suicide shortly after achieving sentience. I can't say I blame it.
-
@Lorne Kates said:
Might I suggest that random links to XKCD be instead replaced with a link to a random XKCD as to destroy context.
We need a Random Rosie script as well. And I must say, I fucking hate your script. Due to the fact that its random nature guarantees I get a different comic on each reload my exposure to xkcd has gone up 10-fold. It's like a salted nuclear weapon; you've taken something awful and made it a crime against humanity.
-
@morbiuswilters said:
It's like a salted nuclear weapon; you've taken something awful and made it a crime against humanity.
How salt can make a nuclear weapon worse?
-
@morbiuswilters said:
We need a Random Rosie script as well.
Get me a zip file with a collection of Rosie picks, and I'll whip it up. I won't look at the contents, but I'll whip it up.
@morbiuswilters said:
And I must say, I fucking hate your script. Due to the fact that its random nature guarantees I get a different comic on each reload my exposure to xkcd has gone up 10-fold. It's like a salted nuclear weapon; you've taken something awful and made it a crime against humanity.
I made it to embarass those who rely on ObigXKCD. That it also causes untolds about of pain and suffereing to all those around it-- is a nice bonus.
-
@Lorne Kates said:
No. I end up with a link to a page that sends you to a random XKCD page. Thus, a different one every time. It just wasn't an imbedded image.Small difference. Your page randomly selects a comic, then forwards you to that page. You end up with a static result that you copy into an <img> tag.
-
@serguey123 said:
@morbiuswilters said:
It's like a salted nuclear weapon; you've taken something awful and made it a crime against humanity.
How salt can make a nuclear weapon worse?
because the salt, like, it gets in the wounds.
-
Back to the OP.... somebody used a random number generator for primary keys and you call the implementation the WTF? Only a bad implementation would ever survive load testing; the concept is TRWTF.
-
@Jaime said:
Back to the OP.... somebody used a random number generator for primary keys and you call the implementation the WTF? Only a bad implementation would ever survive load testing; the concept is TRWTF.
How much load do you do in your load testing that any randum number generator would fail? Using a trillion GUIDs gives you about 40 billionths of a percent chance of collision.
-
GUIDs are large and collision resistant. Most non cryptographic quality random numbers are neither.
-
@Jaime said:
GUIDs are large and collision resistant. Most non cryptographic quality random numbers are neither.
So then only a GOOD implementation would get through load-testing?
-
@Sutherlands said:
A GUID is a good unique number, but a poor random number. If you ever tried to use GUIDs in a video game, you would get an interesting outcome. Cryptographic quality random numbers are also poor for general purpose use because they can be very slow, especially if you generate a large number in a short period of time. For example, a realllllly good source of quality random numbers is one of these. It can't generate more than about 100 bytes per second. So, I stand by my statement that anything that would be good at avoiding collisions would be a poor implementation of a general purpose random number generator.@Jaime said:
GUIDs are large and collision resistant. Most non cryptographic quality random numbers are neither.
So then only a GOOD implementation would get through load-testing?
-
@Jaime said:
So, I stand by my statement that anything that would be good at avoiding collisions would be a poor implementation of a general purpose random number generator.
Anything that avoids duplicates is most certainly not random.
-
@Lorne Kates said:
More Rosie pain, please! .@morbiuswilters said:
We need a Random Rosie script as well.
Get me a zip file with a collection of Rosie picks, and I'll whip it up. I won't look at the contents, but I'll whip it up.
@morbiuswilters said:
And I must say, I fucking hate your script. Due to the fact that its random nature guarantees I get a different comic on each reload my exposure to xkcd has gone up 10-fold. It's like a salted nuclear weapon; you've taken something awful and made it a crime against humanity.
I made it to embarass those who rely on ObigXKCD. That it also causes untolds about of pain and suffereing to all those around it-- is a nice bonus.
-
-
@serguey123 said:
@morbiuswilters said:
It's like a salted nuclear weapon; you've taken something awful and made it a crime against humanity.
How salt can make a nuclear weapon worse?
It's not salting itself that morbius hates, but rolling out your own implementation of it.
-
@dhromed said:
@serguey123 said:
@morbiuswilters said:
It's like a salted nuclear weapon; you've taken something awful and made it a crime against humanity.
How salt can make a nuclear weapon worse?
because the salt, like, it gets in the wounds.
So it makes them more awesome?
-
@PJH said:
@Jaime said:
In a large enough number space, completely random numbers will almost certainly not collide within an application's use of them. That was the point in the beginning.So, I stand by my statement that anything that would be good at avoiding collisions would be a poor implementation of a general purpose random number generator.
Anything that avoids duplicates is most certainly not random.
-
@Sutherlands said:
@PJH said:
@Jaime said:
In a large enough number space, completely random numbers will almost certainly not collide within an application's use of them. That was the point in the beginning.So, I stand by my statement that anything that would be good at avoiding collisions would be a poor implementation of a general purpose random number generator.
Anything that avoids duplicates is most certainly not random.http://tools.ietf.org/html/rfc4122 mentions version 4 UUIDs which are randomly generated. For a 122-bit random number, the chance of collision is very low.
-
@Sutherlands said:
@PJH said:
Well if you're only selecting - say - 2 random numbers from a space of 2^32 or 2^64, may be. But once you start selecting more and more numbers the Birthday Paradox comes into play increasing the probability of a 'collision.'@Jaime said:
In a large enough number space, completely random numbers will almost certainly not collide within an application's use of them.So, I stand by my statement that anything that would be good at avoiding collisions would be a poor implementation of a general purpose random number generator.
Anything that avoids duplicates is most certainly not random.
-
@PJH said:
@Sutherlands said:
@PJH said:
Well if you're only selecting - say - 2 random numbers from a space of 2^32 or 2^64, may be. But once you start selecting more and more numbers the Birthday Paradox comes into play increasing the probability of a 'collision.'@Jaime said:
In a large enough number space, completely random numbers will almost certainly not collide within an application's use of them.So, I stand by my statement that anything that would be good at avoiding collisions would be a poor implementation of a general purpose random number generator.
Anything that avoids duplicates is most certainly not random.
-
@morbiuswilters said:
@PJH said:
Absolutely. But, if you are calling something called GenerateGUID and it happens to create a version 4 UUID, you will get back a random number that is suitable as a primary key in a distributed system. If you call something called tools.Randomizer.getNumber and use it as a primary key, you are an idiot. GUID are designed to be collision resistant, either through algorithm or keyspace. Random numbers as a class are not. Pointing out that there exist a subset of random numbers (version 4 UUIDs) that are collision resistant does little to make that false. One counter-example is not sufficient.@Sutherlands said:
The chance of collision still remains quite low.@PJH said:
Well if you're only selecting - say - 2 random numbers from a space of 2^32 or 2^64, may be. But once you start selecting more and more numbers the Birthday Paradox comes into play increasing the probability of a 'collision.'@Jaime said:
In a large enough number space, completely random numbers will almost certainly not collide within an application's use of them.So, I stand by my statement that anything that would be good at avoiding collisions would be a poor implementation of a general purpose random number generator.
Anything that avoids duplicates is most certainly not random.