Go to Post The most important part of successfully solving the problem is to understand what the problem is. Elegance in engineering comes from "optimizing" your solution, not solving problems that don't really exist. Fulfill your requirements, meet your goals... - JVN [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #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/
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
What is your most prefered programming language? Hailfire Programming 156 19-01-2005 21:42
InfraRed autonomous code ... mtrawls Programming 1 11-01-2004 00:25
Does your team use the Default code. Jeff McCune General Forum 2 09-01-2003 14:46
How random is random???? archiver 1999 0 23-06-2002 21:59
Patent source code? Kyle Fenton Chit-Chat 3 20-10-2001 17:53


All times are GMT -5. The time now is 21:18.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi