Allow only numeric input or disallow spaces with Javascript

Posted on Wednesday 11 February 2009

This is a very easy way to restrict users from inputting any characters other then numbers or restrict users from entering spaces in e.g. login and password fields. You can restrict other characters by adding the charcodes to the function. You can check the charcodes at cambiaresearch.com

You can download the files below.

Usage:

Load in the javascript file and add onkeypress=“return isNumberKey(event)” in the input tag.

like so:

input type=“text” name=“numeric” id=“numeric” value=”” maxlength=“12” onkeypress=“return isNumberKey(event)” 

Read more →

Some useful mac shortcuts

Posted on Tuesday 10 February 2009

command option eject: This puts your mac fast to sleep

control shift eject: turns off your screen

command shift 4: I use this to measure pixels, but it‘s intended to make screenshots

command option d: show and hide the dock

Control Eject:Restart, Sleep, Shutdown dialog box

Control command D: Looks up a word in the dictionary. simon showed me this one. A reasonably unknown shortcut in my opinion. You can use this shortcut in any Cocoa application (Mac native) like safari and a small tooltip will appear above the word your mouse pointer is hovering. You don‘t need to have the dictionary open so you can easily use this at all times. 

Read more →

Restricting access to a directory using htaccess and generate a htpasswd file using php

Posted on Tuesday 10 February 2009

htaccess:

first make a htaccess file with the following:

AuthType Basic

AuthName “Restricted Area”

AuthUserFile path/to/.htpasswd

require valid-user

Make sure there are no extra spaces after AuthUserFile, otherwise it won‘t work. The AuthUserFile is the path to the .htpsswd file we‘ll be creating next. Apache uses the mod_auth module for basic authentication. Keep in mind that the basic Authtype is quite vulnerable because it sends the passwords and logins unencrypted as plaintext and can hereby be captured by anyone listening in. The HTTP Digest Authentication on the other hand protects your password and login information whilst being transferred by including it in a message digest that has been hashed with MD5.

htpasswd:

Now, we‘ll create a file called .htpasswd. The following lines are case-sensitive. The password has to be MD5‘d. Use aMD5 generator to do this. This is an example of a htpasswd file:

steven:5f4dcc3b5aa765d61d8327deb882cf99
seconduser:5f4dcc3b5aa765d61d8327deb882cf99

Read more →

How to remove the .php extension using htaccess

Posted on Tuesday 10 February 2009

A .htaccess file is a file located at your webserver which enables you to make changes to some of the Apache options without having to modify the httpd.conf Apache configuration file or restarting the webserver. Making changes in the httpd.conf file requires a reboot of the webserver. Most webservers allow htaccess modifictations to a certain extend. The only disadvantage of using a htaccess is, every time a http request is made, it has to read the htaccess file, resulting in a slower delivery time.

This is the htaccess file I use to remove the .php extension to create clean urls. All you have to do is create a .htaccess file. Unless hidden files are visible on your hard drive you shouldn‘t name it .htaccess at first, but rename it when you‘ve uploaded it to your web space, because all files beginning with a dot become automatically hidden. So, just leave out the dot at first.

RewriteEngine On

RewriteBase /

RewriteRule ^()$ index.php [NC,L]

RewriteCond % !(^/?.*..*$) [NC]

RewriteRule (.*)$ $1.php [NC]

Read more →

Path Finder

Posted on Saturday 7 February 2009

This program is what the Finder on Mac should be like. I just downloaded it yesterday, so I haven‘t really had the time to fully test this application, but it looks promising. Tabbed navigation is a major plus. And the path navigator, which you see on top, is a big help. I‘ve explained in another post, how to display the full path in your Finder. Path Finder also has a Quicksilver-like application. The downside is, the focus has to be on path finder to start the launcher. I hope they‘ll change this in another release. Path Finder also allows split window view. Another cool feature is the drop stack which enables you to drag files in the drop stack, go to the desired folder en dan drag and drop the files there. Normally on Mac, when you press return on a file you can rename it. With path Finder, only the return on the numpad is used to rename files. The other return button opens the file with the associated program. It takes a bit of getting used to, but in the end it‘s a logical way of working.

Read more →

Image resizing on the fly using PHP

Posted on Friday 6 February 2009

Smart Image Resizer 1.4.1

this is one of the best PHP scripts I‘ve found so far on the internet. It‘s made under the Creative Commons license. All he asks is to include a link on your website to his website when you use his script http://shiftingpixel.com. It allows you to crop or scale an image on the fly only by setting a certain width, height and if necessary a cropratio. If you, for example, change the layout of your website and the images need to be larger, you don‘t need to scale the images all over again. Just change the parameters and the images will be cropped to that size. The original images aren‘t modified in the process. I‘ve incorporated this script in the CMS from webFizz and saved me a lot of time so far. 

Read more →