Well he does say that the System Idle process took up all his resources which I hoped he meant Memory and not cycles. It shouldn't take any memory other than its tiny footprint. If he did mean cycles... well... he should try killing the process to speed up his system :)
DrJames
@DrJames
Best posts made by DrJames
Latest posts made by DrJames
-
RE: The most resource intensive program ever
-
RE: Double Trouble?
@Manni said:
DrJames: The concept he's using with the random numbers is familiar to me. Check it out:
The random number he generates will be between 0 and 7 inclusive, because I don't think you'll ever get 8 with that calculation. If you have four choices you want randomly chosen, then you'd break it up into sections that are two numbers wide. If it's 0 or 1, choose one background. If it's 2 or 3, choose this one, and so on. All the I think he was going for something like this:
if (cur < 2)
backgr = backgr1;
elseif(cur < 4)
backgr = backgr2;
elseif(cur < 6)
backgr = backgr3;
else
backgr = backgr4;
But no matter how you look at it, he cocked it up. It's still just as many WTFs as you counted.
Correct me if I'm wrong but since Math.Round is not specified as ceiling or floor, I'm assuming its rounding to the "closest integer" which would mean that I was wrong in saying from 1-8, it's actually from 0-8.
I still don't get why you would break it into two number sections... just do Math.Floor(4*random) which will give you 0-3, then do
switch (randomnumber)
case 0: do this; break;
case 1: do that; break;etc.
-
RE: Double Trouble?
Here's my list:
- background 4 is never usered
- the specify the full page for each image instead of something like "path"+cur+".jpg"
- they choose a random number from 1-8 and then divide by 2...
- he defaults the background to 4 and then overwrites it two lines later with background 1
- the naming of the method indicated the background has already been chosen
- The path indicates an intranet image... is the intranet open to the public?
6 that's all I got... 6 wtf's for 11 lines of code... not a bad ratio!
-
RE: Double Trouble?
More code from the above site:
function choseBg() {
var backgr1="/intranet/groups/pubweb/documents/unity_image/unity_bkimage01.jpg";
var backgr2="/intranet/groups/pubweb/documents/unity_image/unity_bkimage02.jpg";
var backgr3="/intranet/groups/pubweb/documents/unity_image/unity_bkimage03.jpg";
var backgr="/intranet/groups/pubweb/documents/unity_image/unity_bkimage04.jpg";
var cur=Math.round(8*Math.random());
backgr=backgr1;
if (cur<=2) backgr=backgr1;
else if (cur<=4) backgr=backgr2;
else if (cur<=6) backgr=backgr3;
return backgr;
}I'll let you figure out the "oddness" going on there!
-
Double Trouble?
I noticed this javascript at http://www.unityhealth.com and I was confused, perhaps someone can enlighten me:
function reDoIE(){
if(is.ns6) {
available_width = innerWidth;
available_height = innerHeight;
} else if(is.ie4 || is.ie5 || is.ie55 || is.ie6) {
available_width=document.body.clientWidth;
available_height=document.body.clientHeight;
}
var imBG = document.getElementById("bgImage");
imBG.width = (available_width * 1.00);
imBG.height = (available_height * 1.00);
}
Last I checked multiplying a number by 1 returns the same number! The only "benefit" I can think of is maybe they needed to cast to a double for some strange absurd reason -
RE: Hi Satan, did you just call me?
<FONT style="FONT-SIZE: 11pt" color=#000000>PCP/IP = Transmission Control Protocol/Internet Protocol. </FONT>
<FONT style="FONT-SIZE: 11pt" color=#000000>It facilitates communication between different types of computers.</FONT>
-
RE: C# is numeric styles
hmmm well there's my wtf, posted a reply as a new thread by accident.
-
C# is numeric styles
Not that I'm getting involved or anything, just thought for informations sake:
c#
System.Double.TryParse
or you could do a basic:
System.Text.RegularExpressions.Regex.IsMatch(val,"^\-?\d*(\.\d*)?$")
and System.Char has a IsNumeric (don't ask why string doesn't). You could always roll your own
internal static bool IsNumeric(string numberString)
{
foreach (char c in numberString)
if (!char.IsNumber(c))
return false;
return true;
}