Random Number: The Mersenne Twister
24/04/2006
The Mersenne Twister is a new random number generator, invented/discovered in 1996 by Matsumora and Nishimura.

MT is a twisted GFSR(624,397), similar in spirit to R250 and in my tests it's comparable in speed to R250 (slightly slower than R250 alone, but faster than R250/521 combined). It takes up more space than R250 or R521, but less than the two combined. MT has an amazing period of 2^19937-1.

source
 
Random Number: R250/521
24/04/2006
R250 is what's known as a generalized feedback shift register, or GFSR. GFSRs are determined by two parameters, a length and an offset. R250 is actually GFSR(250,103), indicating a length of 250 and an offset of 103. R250 has a period of almost 2^250

source
span style="color: #008080; font-style: italic;">/*
        Establish linear independence of the bit columns
        by setting the diagonal bits and clearing all bits above
        */
PHP Use Config ini
15/10/2005
use a .ini file to store your config data, for example the following file could be saved as config.ini:
;my configuration file
"example site"
[database]
    host =  "my_db_host"
    db = "my_db"
    user = "my_db_user" 
    pass = "mypassword"

Then load the config with the following code:
span style="color: #ff0000;">'config.ini'

You can access the values with:
span style="color: #ff0000;">'database']['host'];

Open the CD tray
08/06/2005
Does what it says on the tin

span style="color: #808080;">"VBScript""WMPlayer.OCX.7"' cdrom
 

Using MySQLi Prepared Statements
03/06/2005
Prepared statements provide the ability to create queries that are more secure, have better performance, and are more convenient to write.

The bound parameters do not need to be escaped.
span style="color: #ff0000;">"localhost", "user", "password", "world""Connect failed: %s\n"/* prepare statement */"SELECT Code, Name FROM Country WHERE Code LIKE ? LIMIT 5""s", $code);
    $code = "C%"/* bind variables to prepared statement *//* fetch values */"%s %s\n", $col1, $col2);
    }
 
    /* close statement */
    $stmt->close();
}
/* close connection */

Convert age to dog years
01/06/2005
Converts human years to dog years.
### get the original age
"Enter your age (in human years): "# print a blank line
 
### do some range checking, then print result
"Negative age?!?  I don't think so.""Frankly, I don't believe you.""That's", age*7, "in dog years."
 
### pause for Return key (so window doesn't disappear)
 
Like Usage in SQL
28/04/2005
Searches for any occurence of bob
span style="color: #ff0000;">`death``bats``name`'%bob%';
PHP Short If Statment
28/04/2005
Short if syntax:
condition ? true : false
span style="color: #ff0000;">"num is 1" : "num isn't 1"
Form Return Value
22/04/2005
To get a form to return a value

call:
span style="color: #008080; font-style: italic;">// OK, do something with the password.
"The password entered was: "

Dialog: