From the category archives:

Programming

The goal of a signup form is to quickly convert visitors into registered users. The easiest way to increase your sign up form’s conversion rate is to lower the amount of time it takes to complete.

One way to do that, is to add a “check username availability” feature. Users will often choose conflicting usernames, especially on large community websites.

Rather than reporting the error on the next page, give the user a quick and easy way to check their username availability. This will speed up the sign up process.

As always, start with your interface. A simple form with a text box, a div, and a “Check Availability” button is all that’s needed. You can copy the HTML from the demo.

Check username availability

Using the prototype javascript library, we will send an AJAX request to a seperate checkuser.php page, which will print either 1 for “available”, or 0 for “not available”. Our javascript function will print the appropriate message in our div, then highlight the textbox with green (available), or red (not available).

Here is the checkUser() javascript function. Don’t forget to include the Prototype Javascript file.


function checkUser(user)
{

  var url = encodeURIComponent('checkuser.php');
  var params = 'user=' + escape(user);

  new Ajax.Request(url, {
    method: 'get', parameters: params,
    onSuccess: function(transport) {
      if(transport.responseText == 1){
        $('userstatus').innerHTML = 'Your username is available.',
        $('user').style.backgroundColor = '#caffd5'
      }else{
        $('userstatus').innerHTML = 'Sorry, that username is already taken.',
        $('user').style.backgroundColor = '#ffd4ca';
      }}});
}

View the Demo.

This is only a small way you can increase the effectiveness of your sign up form. I will be writing about other methods in the near future.

{ 0 comments }

So your project is nearly finished, now all you need is a website to get the word out. PownceUnfortunately this stage of the project is often neglected, which is understandable. Programmers want to work on the actual application rather then the website. However, your visitors aren’t going to download your application if they can’t find the download page.

As a developer (and as a consumer), I see lots of software websites that could be improved. Here are a few tips for making a good application website.

  • Show a screenshot of your application on the homepage

    Most of the time, this is what I look for first. At a quick glance I can see if the application is going to do the job I want. I often download software based solely on the screenshot.

  • Make sure the user can get to the download/purchase page within 1 click

    Firefox has done this part right. Nothing works better than an eye-catching “Download Now” button. The goal of your website is to convert visitors into downloads, so it’s wise to get your users to the downloads page as soon as possible.

  • Explain in 2-3 sentences what your program is and how it helps people

    This should be the first thing your visitor reads. Make it short and to the point. Crimson editor has an excellent description on it’s homepage…

    “Crimson Editor is a professional source code editor for Windows.This program is not only fast in loading time, but also small in size (so small that it can be copied in one floppy disk). While it can serve as a good replacement for Notepad, it also offers many powerful features for programming languages such as HTML, C/C++, Perl and Java.”

  • Host a demo of the application or the application’s admin section

    Dont make your visitors type ‘admin’ and ‘demo’ on the demo login form, it’s annoying, auto fill the fields.

  • Don’t use bad stock photography

    Personally, I prefer software websites without any photos. But if you have to use them, don’t include cliche photos of people in suits or talking on cell phones.

    People associate these type of photos with faceless corporations.

  • Include a news bit

    Often one of the first things I do when looking at an application’s website is scan for the latest news to see how active the project is.

  • Screenshots and gallery

    If possible, have a screenshots page with at least 5 – 10 good screenshots of your application.

{ 0 comments }

Javascript Window

A window is essentially just a floating div. We can make the div draggable using the Script.aculo.us Javascript library.

First, we need to create the window div. Here is the CSS I used.


.window {
  background: #d8e7fe;
  position: absolute;
  top: 200px;
  left: 200px;
  width: 350px;
  padding: 1px;
  -moz-border-radius: 7px;
  border: 2px solid #21416d;

}
.window h1 {
  -moz-border-radius-topleft: 5px;
  -moz-border-radius-topright: 5px;
  padding: 6px;
  display: block;
  background-color: #9cc6ff;
  font-size: 13px;
  margin: 0px;
}

And here is the HTML markup.


<div id="mywindow" class="window">
  <h1>Example Window</h1>
  <p>Click and drag this window around the webpage.</p>
</div>

I’ve used ‘-moz-border-radius‘ for rounded corners because I’m lazy. You’ll need to use corner images if you want rounded corners that work in more than one browser.

Now all that’s left to do is the javascript. As I said before, we’ll use the Script.aculo.us library which includes a handy Draggable function. Theres a quick guide on how to install the library here.

Once you’ve got the library installed, add this short Javascript snippet to the head section of your document.


<script type="text/javascript">

function init(){
  new Draggable('mywindow');
}

Event.observe(window, 'load', init, false);

</script>

When the page loads, the init() function is called, which tells the library to make the div ‘mywindow’ draggable!

View the finished product.

{ 1 comment }

Password Strength Meter

July 25, 2007

Making a password strength meter is simple, there’s no tricky Javascript or AJAX needed, just a simple function and a few divs.

Password Strength Meter
Click to view demo.

I’ve decided to design the function around a scoring system, the stronger the password the higher the score. We can accomplish this with just a few simple IF statements.

function passwordStrength(pass)
{

var score = 0;

if(pass.length > 2)
score++;

if(pass.length > 4)
score++;

if(pass.length > 8)
score += 2;

if(/w/.test(pass) && /d/.test(pass))
score++;

return score * 2 * 10;

}

The code is fairly self explanatory, the last IF statement checks if the password contains both characters and symbols. The function returns a percentage of the password’s score out of 5, which is the maximum score it can be awarded.

Next, we need a form with a text box and 2 divs for our meter.


<input type="text" onkeyup="document.getElementById('passmeter').style.width = passwordStrength(this.value) + '%';" />
<br />
Password Strength:<br />
<div id="passmeterbg"><div id="passmeter"></div></div>

The ‘onkeyup’ event calls the passwordStrength() function every time a key is pressed. The ‘width’ property of our meter div is then given the password’s score.

Finally, we need some CSS to style the meter…


#passmeter {
width: 0px;
background: #629d48;
height: 3px;
}

#passmeterbg {
height: 3px;
background: #f1f1f1;
width: 200px;
}

View the finished product.

{ 0 comments }

Creating a Process in C

July 17, 2007

I won’t list reasons why every programmer should know C because there have already been numerous discussions on the subject.

As a programmer, you can decide for yourself whether learning C will benefit your career.

I’ve chosen to start writing a small project in C so I can get a better knowledge of pointers, structs and memory allocation.

I’m going to share a small snippet of code which creates a process in Unix. You might find this interesting if you’ve never seen C code before.

Processes are created using the fork() function, which basically makes a copy of the existing process running and assigns a new process id (PID) to the child process. The rest of the code is fairly self explanatory.


#include <stdio.h>

/* the main() function is automatically executed… */

int main()
{

/* fork the process */

int p_id = fork();

/* this is the code the child process will execute */

if(p_id == 0)
{

/* endless loop */

for(;;)
{

printf(“Im a child processn”);
sleep(10);

}

}

/* close the parent process */

exit(0);

}

Save and compile the code using gcc (gcc process.c -o process). The process should now be listed in the process list (type ps -aux in unix).

psaux

{ 0 comments }

I’ve been experimenting with 2D game development in the last few weeks. It’s fun because it let’s me combine my love for code and art into one project.

When I first became interested, it took some time gathering information about best practices and methods for creating games. So I’m writing this article for people who are interested but aren’t sure where to start.

The Tools You Need

I recommend C++ for game development. It is widely used and there are thousands of tutorials/recources available on the net. It’s object-oriented, so it’s perfect for modeling real world objects you might see in a game, e.g. paddle.moveUp().

For C++ development on Windows, I recommend Bloodshed Dev-C++, which is bundled with the Mingw compiler.

Raptor

You can of course develop your game in almost any language, it really depends on how complex your game needs to be.

If you’re after extreme speed and efficiency, you might chose to develop your game in assembly language (not for the faint hearted). If you just want to make a simple hang man game, you could use visual basic.

Python is also a good language for game development.

Learning C/C++ is quite easy if you’re proficient in PHP, Ruby, Python or any other OO language. Cplusplus.com has a great introductory tutorial for beginners.

If you’re coming from PHP and you’re not used to event driven programming, you might find game development a bit unnatural at first. Stick with it, you’ll get used to it within a few hours.

SDL code

Getting started

SDL (Simple DirectMedia Layer) is a development library which makes using animation and audio very easy. Handling user input with SDL is also a walk in the park. My first “hello world” application was compiled and running within 2 minutes.

For a quick guide on getting started, have a look at “Setting up SDL in Dev C++”. Once everything is set up, start working your way through these great tutorials.

Inspiration

If you want to make a game but don’t have any concept ideas, check out the following sites for some inspiration.

If you’re looking for a fun way to learn C/C++, developing a small 2D game is perfect. My first game was Pong, which only took a few hours to complete…

Pong

{ 0 comments }