I've been working on some perty usless code that are more for fun than anything else, but oh well.
Feel free to post some of your own.
Here they are...
Find Pi
Code:
unsigned double float pi;
void main(void)
{
pi = 1;
for(count = 0, top = 2, bottem = 1; count < 10000; count++)
{
pi *= top/bottem;
bottem += 2;
pi *= top/bottem;
top += 2;
}
printf ("pi = %f", pi*2);
}
Random Signature
PHP Code:
<?php
header("Content-type: image/png");
//read folder
$folder = opendir(".");
while ($file = readdir($folder))
$names[count($names)] = $file;
closedir($folder);
//sort file names in array
sort($names);
//remove any non-images from array
$tempvar = 0;
for ($i = 0; $names[$i]; $i++)
{
$ext=strtolower(substr($names[$i],-4));
if ($ext == ".png")
{
$names1[$tempvar] = $names[$i]; $tempvar++;}
}
//random
srand ((double) microtime() * 10000000);
$rand_keys = array_rand ($names1, 2);
//random image from array
$im = imagecreatefrompng($names1[$rand_keys[0]]);
imagepng($im);
?>
Create a directory on your server and put this script there along with any png images. It will select one randomly and then output it to display image. This the exact code that I use for mine. (hit F5 a couple of times to watch it change)