Go Back   Computer Forums > Welcome To Computer Forums .org > Social Lounge | Off Topic
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 12-09-2009, 03:34 PM   #1
Fully Optimized
 
rohan23's Avatar
 
Join Date: Sep 2008
Posts: 4,087
Default Competition Number 2: Coding

Talk to Root about any questions. All official entries should be entered here. Please follow his rules to the tee. Respect all members and rules please.

this is a coding competition...

post the most useful, or the most fun, or something that's a bit mischievous, piece of code, or script that you can manage...

for a length limit All the code MUST fit within 1 post.
there is no limit on the language. (so every thing from assembler to PHP, C to Java, and batch script to VBscript is allowed).
you can also run the script however you like, (for example you can use PHP as a command line interpretor, you don't have to use it as a web script).

brief description of what the code does is recommended, because not everyone will understand what the code does just by looking at the code.

it's the 9th today,
the competition will close on Christmas day (25th) at 12.00pm (that's midday) GMT.

you can post as many code samples as you like, (1, 2, 3 etc).
you can edit your code samples up to the closing date...

rules:
the close date is 12:00pm GMT 25th december (2009)
any code that doesn't run is disqualified
any code that contains errors is disqualified
any code that is posted after 12.00pm the close date is disqualified
any code that is edited after the close date is disqualified
any code contained in a post that is edited after the close date is disqualified, (because you may have altered the code).
code should be your own code, you can use library functions, you can use functions written by someone else, provided that you label it as someone else's and clearly label your own code that you've written.
All code, (including any functions borrowed) MUST fit within a single post)
the brief description of what the code does must also fit within the same post
the code MUST be ready to run, -if you have a non out-of -the-box setup you MUST describe that, (for example if you use the socket functions in PHP you must say that you need to edit the php.ini file to have the line include=php_sockets.dll or include=php_sockets.so etc...) so that other people will be able to trial and test your code.

Judging:
I don't expect that there will be a whole load of entries as this is quite specific.

each person can post as many separate code blocks/scripts as they like, but you're only allowed to take your best 2 examples forward for judging...

(so you can post 10 to get an idea of what might be popular, and then take your best/most popular script/code through to judging).

24 hours after the closing date you must have (if you've posted more than 2 code blocks/scripts), your 2 that you plan to put forward written down in the forum.

judging will hopefully start on the 26th (24 hours after the competition ends), and will be by a public vote (thread with polling options).

judging will end a week later on NYD again at midday (perhaps later if I'm too hung over to close the thread with voting).
__________________

__________________
Macook 13.3

2.13Ghz Intel Core 2 Duo-2GB DDR2 800 Mhz-500GB Western Digital Caviar Blue- Nvidia 9400M
rohan23 is offline   Reply With Quote
Old 12-09-2009, 05:03 PM   #2
Fully Optimized
 
Join Date: Nov 2006
Posts: 3,629
Send a message via AIM to ߧ∩H♠H䎀
Default Re: Competition Number 2: Coding

Dude, it's follow something to a T (Tee) not follow something to a teeth lol.
__________________

ߧ∩H♠H䎀 is offline   Reply With Quote
Old 12-09-2009, 05:21 PM   #3
Fully Optimized
 
rohan23's Avatar
 
Join Date: Sep 2008
Posts: 4,087
Default Re: Competition Number 2: Coding

Quote:
Originally Posted by ߧ∩H♠H䎀 View Post
Dude, it's follow something to a T (Tee) not follow something to a teeth lol.
You automatically lose.....
__________________
Macook 13.3

2.13Ghz Intel Core 2 Duo-2GB DDR2 800 Mhz-500GB Western Digital Caviar Blue- Nvidia 9400M
rohan23 is offline   Reply With Quote
Old 12-09-2009, 05:25 PM   #4
Site Team
 
David Lindon's Avatar
 
Join Date: Dec 2002
Posts: 15,233
Default Re: Competition Number 2: Coding

This should be very interesting.

Has anyone ever seen that obfuscate (spelling) coding competition?
__________________
[url=http://www.LNXPS.NET]LNXPS.NET - The XPS Library]
David Lindon is offline   Reply With Quote
Old 12-09-2009, 05:28 PM   #5
Site Team
 
berry120's Avatar
 
Join Date: Jul 2009
Location: England, UK
Posts: 3,425
Default Re: Competition Number 2: Coding

The obfuscated C coding contest?

...love it
berry120 is offline   Reply With Quote
Old 12-09-2009, 10:25 PM   #6
Fully Optimized
 
vampist's Avatar
 
Join Date: Oct 2008
Location: USA
Posts: 2,404
Default Re: Competition Number 2: Coding

Just tested the first part of my code.
So far so good, it fits. At the end I may have to remove my comments.
(added a lot of them so it's easier to read for people who don't know the code)
__________________
Everyone's Favorite Turd xD
ET: "Phone home!"
Geek: "ping 127.0.0.1"

"If that guy knew half the $h*t that I know, his fuzzy little head would explode. " - Matthew Farrell
vampist is offline   Reply With Quote
Old 12-10-2009, 06:17 AM   #7
Site Team
 
root's Avatar
 
Join Date: Mar 2004
Posts: 7,999
Default Re: Competition Number 2: Coding

Quote:
Originally Posted by berry120 View Post
The obfuscated C coding contest?

...love it
you can post obfuscated code if you like...
I specifically didn't suggest any rules about commenting because each person will have their own commenting style... and some might choose not to comment at all.

At the end of the competition, what we'll hopefully have is...
a small library of functions/scripts/code samples that are CFs...
A few more people in the world with an interest on being able to 'make' things with their computer.
a nice competition for Christmas...


I'm going to re-offer the 10, (or nearest number equivalent in your currency) electronic gift voucher prize again... (as before, I just want to buy the voucher on-line and PM the voucher code to the winner).

so we should also end up with a winner with a ten quid voucher to spend in the new year sales.... (I know it's not exactly a whole heap of cash... but it could be put towards something that you want).

Most of all, the competition is (as Rohans first thread suggested), hopefully a way to improve the community spirit and get a sense of energy going.

just remember it's not necessarily going to be the most complex, or the most technical that wins.
everyone has different abilities, so every bit of code is going to show different abilities. it'll be the one that's voted best that wins, and that'll be by public vote...
__________________
I didnt fight my way to the top of the food chain to be a vegetarian
Im sick of people saying 'dont waste paper'. If trees wanted to live, they'd all carry guns.
"The inherent vice of capitalism is the unequal sharing of blessings; The inherent vice of socialism is the equal sharing of miseries."
root is offline   Reply With Quote
Old 12-25-2009, 11:17 AM   #8
Fully Optimized
 
vampist's Avatar
 
Join Date: Oct 2008
Location: USA
Posts: 2,404
Default Re: Competition Number 2: Coding

I have been busy so I didn't really have time to do a lot. But I threw together two scripts.

To show it works:
http://tinyurl.com/ykpfr6c
Username: Lol
Password: cf1234

Will lock you out on 5 failed attempts.

A Login script
With the tables set up as:

+--------+
| Tables |
+--------+
| salt |
| users |
+--------+

+--------------------------------+
| users |
+--------------------------------+
| Field | Type | Null |
+--------------------------------+
| username | varchar(32) | No |
| password | varchar(32) | No |
+--------------------------------+

+--------------------------------+
| salt |
+--------------------------------+
| Field | Type | Null |
+--------------------------------+
| username | varchar(32) | No |
| salt | varchar(50) | No |
+--------------------------------+

Code:
<?php
session_start(); //Don't remove me! VERY important!
/* When logged in a session is stored with the variable $_SESSION['logged_in']=1
** Logout page is <thenameofthisfile>?logout then it will redirect to a page or link of your linking
** after 5 (five) failed login attempts the login system for that computer will lock for 
** ten minutes(default). */

######WEB SERVER SETTINGS######
$website_domain = "quicksnail.com"; //i.e. example.com, secure.example.com, etc.
$website_domain_www = 1;		   //Set to 1 if you want www. to also work
$website_https = 0; 			  //Set to 1 if you have or require SSL

$mysqli_server = "localhost";      	 //Location of the Mysql server.
$mysqli_username = "****";	//Mysql username
$mysqli_password ="****";      //Mysql Password
$mysqli_db = "cf_challenge";      //Mysql Database

$goto_false = "index.htm"; 	  //If login fails go where?
$goto_true = "index.htm"; 	 //If login passes go where?
$goto_logout = "index.htm"; //If logout go where?

$submit_button_name = "submit"; //In html you name your submit button with name="something" put the name here.
$failed_login_time = "10"; 	   // If 5 failed logins, wait this long (in minutes).
#####END OF WEB SERVER SETTINGS#### 
#*No Need to edit below this line*#

//Logout command
if(isset($_GET['logout']) AND ($_SESSION['logged_in'] == 1)) {
	session_unset();
	session_destroy();
	header("Location: {$goto_logout}");
	exit;
}
if($_POST[$submit_button_name]) {
//Lock username system
$_SESSION['login_attempt'];
$_SESSION['notice'] = "";
if($_SESSION['login_attempt'] >= 4) {
	if(isset($_SESSION['login_attempt_reset']) AND ($_SESSION['login_attempt_reset'] <= time())) {
		$_SESSION['login_attempt'] = 0;
		$_SESSION['notice'] = "";
		unset($_SESSION['login_attempt_reset']);
	}else{
		$_SESSION['login_attempt_reset'] = time() + (60 * $failed_login_time);
		$_SESSION['notice'] = "To many failed login attempts, please wait 10 minutes.<br/>Every time you continue to click login, it will reset the timer.";
		header("Location: {$goto_false}");
		exit;
	}
}
class connect {
	function database($website_domain, $website_domain_www, $mysqli_server, $mysqli_username, $mysqli_password, $mysqli_db) {
		//Make sure the server is running on the correct domain
		if ($website_domain == $_SERVER['SERVER_NAME']){
			return new mysqli($mysqli_server, $mysqli_username, $mysqli_password, $mysqli_db);
		}
		elseif (("www.".$website_domain == $_SERVER['SERVER_NAME']) AND ($website_domain_www ==1 )){
			return new mysqli($mysqli_server, $mysqli_username, $mysqli_password, $mysqli_db);
		}
		else {
			echo $website_domain;
			die("Check <b>website_domain</b> and <b>website_domain_www</b> settings");
		}
	} //End database()
} //End class connect

$connect = new connect;
$connect = $connect->database($website_domain, $website_domain_www, $mysqli_server, $mysqli_username, $mysqli_password, $mysqli_db); 
//Set connect equal to the mysqli connect command.

//check to see if running in SSL 
if (($_SERVER['HTTPS'] != "on") && ($website_https==1)) {
    header("Location: https://{$website_domain}{$_SERVER['REQUEST_URI']}");
    exit;
}
//Check to see if username is only numbers and letters
if(ctype_alnum($_POST['username'])){
	$username = md5($_POST['username']); //set username equal to the users input from the text box
}else{ //If false
	$_SESSION['login_attempt']++; //Set new number of login_attempts.
	header("Location: {$goto_false}");// If false go to the $goto_false location
}
// continue
$sql = "SELECT salt FROM salt WHERE username='$username'";
$mysqli = mysqli_query($connect, $sql) or die(header("location: {$goto_false}"));
while($n = mysqli_fetch_array($mysqli)){
	$pass = $n['salt'].$_POST['password'].$n['salt'];
}
$password = md5($pass); // md5 the value of $pass and set to $password
$sql2 = "SELECT * FROM users WHERE `password`='".$password."' AND `username`='".$username."'";
$mysqli2 = mysqli_query($connect, $sql2) or die(header("location: {$goto_false}"));
while($n = mysqli_fetch_array($mysqli2)) {$good_password = $n['password'];}

if ($password==$good_password) {
	$_SESSION['logged_in']=1;
	header("location: {$goto_true}");
	exit;
}else{ //If false
	$_SESSION['login_attempt']++; //Increase login attempts
	header("location: {$goto_false}"); //Then go to the "false" login page.
	exit;
}
}else{ //If false
	$_SESSION['login_attempt']++;  //Increase login attempts
	header("Location: {$goto_false}"); //Then go to the "false" login page.
	exit;
}
?>
__________________
Everyone's Favorite Turd xD
ET: "Phone home!"
Geek: "ping 127.0.0.1"

"If that guy knew half the $h*t that I know, his fuzzy little head would explode. " - Matthew Farrell
vampist is offline   Reply With Quote
Old 12-25-2009, 03:50 PM   #9
Site Team
 
root's Avatar
 
Join Date: Mar 2004
Posts: 7,999
Default Re: Competition Number 2: Coding

I think that the close date might need to be extended until say Monday...

so far there is only 1 entry, posts four hours after the close date...

I've got a couple of scripts.


The first is easy

Code:
Randomize()
while x<3
x=x+1
c=int(26*rnd()+65)
p=p&" "&Chr(c)
wend
x=0
while x<3
x=x+1
c=int(26*rnd()+97)
p=p&" "&Chr(c)
wend
x=0
while x<2
x=x+1
c=int(10*rnd()+48)
p=p&" "&Chr(c)
wend

msgbox p, VBOKonly, "Password"
copy the text and save it with a text file, then save the text file as password generator.vbs
it creates a random 8 character password made of upper-case, lower-case and numbers,

quite good for generating passwords to reset user passwords and such.


-edit
with regards the close date, originally I'd said close today so we could have a winner selected by new years and that winner could have a voucher code to use in new year sales.

so do we have a close date of Monday, or make this a 12 days of coding and close on 12th night?
__________________
I didnt fight my way to the top of the food chain to be a vegetarian
Im sick of people saying 'dont waste paper'. If trees wanted to live, they'd all carry guns.
"The inherent vice of capitalism is the unequal sharing of blessings; The inherent vice of socialism is the equal sharing of miseries."
root is offline   Reply With Quote
Old 12-25-2009, 04:51 PM   #10
Site Team
 
berry120's Avatar
 
Join Date: Jul 2009
Location: England, UK
Posts: 3,425
Default Re: Competition Number 2: Coding

Quote:
I think that the close date might need to be extended until say Monday...
What about new year? People are probably going to be pretty busy this weekend, so I doubt you'll see too many entries.

EDIT:
Quote:
so do we have a close date of Monday, or make this a 12 days of coding and close on 12th night?
Sorry, didn't see that bit - my vote would be for that one
__________________

berry120 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 08:01 PM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0