View Single Post
  #1   Spotlight this post!  
Unread 24-01-2004, 18:38
echos's Avatar
echos echos is offline
Jack of all trades
#1125
Team Role: Programmer
 
Join Date: Dec 2003
Location: San Diego, CA
Posts: 61
echos will become famous soon enough
Send a message via ICQ to echos Send a message via AIM to echos Send a message via MSN to echos Send a message via Yahoo to echos
Random code snipets

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 ($names12);
 
 
//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)
__________________

Entity Hosting Staff
http://www.entityhosting.com/