Archive for July, 2007

How to dynamically update a form using javascript

Thursday, July 26th, 2007

This article shows you how you can display a box with “characters left” in your forms, you may for example use it in guestbooks or comment forms to tell the user how many characters he/she are allowed to input.
Since this is done by javascript, all we need is a .html file, with the script, and the form.
This is how the javascript looks like:

  1. function UpdateSize()
  2. {
  3. this.form.counter.value = 60 - this.form.comment.value.length;
  4. }
  5. document.onkeydown=UpdateSize;

It changes the textbox “lengde”s value to 60 minus the length of the typed text in the big textarea called “txt”. It updates every time you release a key on the keyboard.

The html form looks like this:

  1. <form method="post" name="form">   Write your text here:
  2.  
  3. <textarea onkeydown="UpdateSize();" onfocus="UpdateSize();" rows="9" cols="45" name="comment"></textarea>
  4.  
  5.  
  6. Characters left: <input size="5" value="60" type="text" name="counter" />
  7. </form>

That is the form called “form”, with the textarea called “txt” and the update box with the counter called “display_counter” .

If you put the javascript in the head tag and the form in the body tag, it would look like this:

  1.  <script type="text/javascript">
  2.  
  3. function UpdateSize()
  4.  {
  5.  this.form.counter.value = 60 - this.form.comment.value.length;
  6.  }
  7.  document.onkeydown=UpdateSize;
  8.  
  9. </script>
  10.  </head>
  11.  
  12. <form name="form" method="post" >
  13.  Write your text here:<br />
  14.  <textarea name="comment" cols="45" rows="9" onfocus="UpdateSize();" onkeydown="UpdateSize();" ></textarea>
  15.  <br />
  16.  Characters left: <input name="counter" type="text" value="60" size="5" />
  17.  </form>
  18.  </body>
  19.  </html>

kvasir top 50 search keywords at 10am

Thursday, July 26th, 2007

Kvasir is a big norwegian searchengine.

On their top 50 keywords list, i found these keywords at 10 am.

kvasir top 50 search keywords at 10am

(more…)

Simple use of cookies with php

Thursday, July 26th, 2007

With php you can set a “cookie” in a users session, which stores a small amount of data on the users computer.

Cookies can be useful to check if the user recently logged in to your webpage,
recently visited your webpage, or such.

With the use of cookies are pretty simple…

Heres how you create the cookie:

  1. <php
  2. setcookie( "user", $_SERVER[‘REMOTE_ADDR’], time()+3600 );
  3. ?>

(more…)

Princess Juliana airport at St Maarten

Friday, July 20th, 2007

This is the famous airport which the airplanes come in for landing straight above the beach!

You can see of the image how close the planes are to the beachstrip Maho beach.

There are lots of videos of this to be found at youtube.
Like this one: (more…)

Some art i made in 3ds max

Friday, July 20th, 2007

Just a small post to show you some simple small art I made in 3ds studio max.

3ds studio max is a great program for creating stuff in 2d and 3d. modelling,

creating animated movie clips and so on, amazing software from autodesk.

A kind of prison cell, with some chrome balls in the sunshine :p

Cellen (more…)

How to create and store a thumbnail in php

Thursday, July 19th, 2007

Here I will show you guys how to create a thumbnail from a larger image file ( .jpg file)

You create a new .php file, and enter this function:

  1. <?php
  2.  
  3. function thumbnail($file, $size, $save_as) {
  4.  list($width, $height) = getimagesize($file) ;
  5.  $modwidth = $width * $size;
  6.  $modheight = $height * $size;
  7.  $tn = imagecreatetruecolor($modwidth, $modheight) ;
  8.  $image = imagecreatefromjpeg($file) ;
  9.  imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
  10.  imagejpeg($tn, $save_as, 100) ;
  11.  }
  12.  
  13. ?>

then you can call the function like this:

  1. <?php
  2.  
  3. thumbnail(‘original_image.jpg’, ‘0.60′, ‘new_image.jpg’);
  4.  
  5. ?>

The last part calls the function, and tells it to create a thumbnail from the “original_image.jpg”, with 0.6 the size of the original, and store the new image as “new_image.jpg” in the same folder as the script.

Some of the code in the function is explained in this post.

Simple :)

Simple php visitor counter

Wednesday, July 18th, 2007

This shows a simple way to log number of visitors to your site, there is no need of any database, it uses flat files (plain textfiles) only.

Create an empty file named stats.txt.

Create a php file, call it counter.php or something, and put it in the same directory as the stats.txt file.

Open it in notepad and enter this php code

  1. <?php
  2. $counter_file = ("stats.txt");
  3. $visits = file($counter_file);
  4. $visits[0]++;
  5. $fp = fopen($counter_file , "w");
  6. fputs($fp , "$visits[0]");
  7. fclose($fp);
  8. echo "Visitors: $visits[0]";
  9. ?>

What the code does:

  1. Define the textfile with stats
  2. Read the stats from the file
  3. increase the stats with 1
  4. open the stats file in writing mode
  5. write to the file
  6. close the file
  7. and finally, print out the content

How to disable the “send error report” message

Tuesday, July 17th, 2007

 A big annoying feature in windows xp is the “send error report” message you get everytime a program crashes.

Here I show you how to turn off the message…

Open up the control panel, click on “system” or click on “performance and maintenance” you you use the new control panel style.

In the system settings, click on the advanced tab, click on the
error reporting button on the bottom.

Select ”disable error reporting” and you’re rid of it!…

Video and picture top sites

Tuesday, July 17th, 2007

Here I will collect a list of the best and biggest video and picture sites, It will be updated frequently with more links.

The list: 

If you have any other good sites, just post’em and i will add them to the list

How to create a shutdown shortcut for your desktop

Tuesday, July 17th, 2007

Have you ever wanted an icon on your desktop that you could use to shutdown you computer with?

It’s pretty simple, you just right click your desktop, choose New -> Shortcut and at the ”File location” screen you just type in the following command

%windir%\System32\Shutdown.exe -s -t 00

That is for running the shutdown application with the parameters “-s” for “this computer” and “-t 00″ for the time in seconds, which would be right away…

You could also use these commands: (more…)

Simple VisualBasic script

Tuesday, July 17th, 2007

This is a simple demonstration of input, output and a small calculation done in VisualBasic.

The script asks the user to input a number of days, and the script
outputs how many seconds those days are.

The code is simple, open up notepad, or your text editor, and enter this:

  1. Dim Input
  2. Input = InputBox("Enter a number of days")
  3. sek = (input * 84600)
  4. msgbox (input & " days,  are " & sek & " seconds")

(more…)

Partypoker

Tuesday, July 17th, 2007

Partypoker is an online client for card games (perhaps worlds biggest), it’s free and you can start playing in some simple steps.

  1. Download the client from their site (6 mb)
  2. Install the client
  3. When you run the client, you may log in or create a new user. Then you can play.
    Creating a new user is simple, and it says you need an email address, but they don’t email you anything, so you can register even if you don’t want to give them you email account information.

When you sign up a new account, you are given 10 000 “playchips” which is the games free currency. (more…)

Simple use of CAPTHCA on your website with php

Monday, July 16th, 2007

 First, what is CAPTCHA?

Captcha is a “Completely Automated Public Turing test to tell Computers and Humans Apart”.

In these days, Im sure you have already seen one or many versions of captcha on the internet. In forms for registering, uploading, searching or posting comments.

Captcha is used to prevent robots spamming your website with ads or such,
and to stop ”mass registering” on websites, by non-human users.

There are different methods to tell if the user is human or a bot. (more…)

9 Reasons not to get Windows Vista

Sunday, July 15th, 2007

After having tried Vista a couple of days, I just could not handle it anymore, so i had to format and install xp again…

Heres a couple of reasons why I didn’t like it, and why it’s not better than xp.

  1. It costs too much! The much cheaper Windows xp is a far better alternative. For the same amount of cash you pay for a lisence of Vista, you could get a cheap ”low-end” computer.
  2. Theres almost nothing new and special in Vista, except for the resource-using glass theme aero. Heres what Microsoft would say are news and good reasons to get vista.
  3. (more…)

Blacklist IPs from viewing your webpage

Sunday, July 15th, 2007

This is a simple small piece of code that allows you to ban visitors fro viewing your webpage, if you know their ip adresses…

This can be made much more advanced.

With the use of a database such as Mysq (or in some cases just a textfile),  you can create a management system for adding, editing and deleting blacklisted ips.

  1. <?PHP
  2. $ip = $_SERVER[‘REMOTE_ADDR’];
  3. $ban = array(
  4. "74.89.41.93",
  5. "123.40.1.63",
  6. );
  7.  
  8. if(in_array($ip, $ban)){
  9. die("Sorry, you are banned!");
  10. }
  11. ?>

(more…)