Thursday, January 04, 2007

A Fast Online Dictionary



This is another Application that uses Ajax nicely. Built by Phil Crosby, it is a dictionary service that lets you query the meaning of words effortlessly. It uses Ajax; meaning your page does not refresh for every word queried.
It is at Ninjawords.com.

Be Careful what You Ask For

I saw this joke while reading Hacking - the art of exploitation, a book by Jon Erickson, today. The joke drew a hearty laughter off me so i decide to share it...




A man is walking through the woods, and he finds a magic lamp on the ground. Instinctively, he picks the lamp up and rubs the side of it with his sleeve, and out pops a genie. The genie thanks the man for freeing him and offers to grant him three wishes. The man is ecstatic and knows exactly what he wants.

"First", says the man, "I want a billion dollars."

The genie snaps his fingers, and a briefcase full of money materializes out of thin air.

The man is wide-eyed in amazement and continues, "Next, I want a Ferrari."

The genie snaps his fingers, and a Ferrari appears from a puff of smoke.

The man continues, "Finally, I want to be irresistible to women."

The genie snaps his fingers, and the man turns into a box of chocolates.

FileSystemObject::Working With Drives And Folders

If you are writing scripts for active server pages or Window scripting Host, and if you will be manipulating files and drives, then you will find yourself dealing with the filesystemobject, which enables you to carry out tasks like writing, reading and deleting of files. With the filesystemobject you also have access to drives and their properties.

I will succinctly highlight here, how to work with this object.

One thing though, since FSO is contained in the scripting type library, you must make sure that scrrun.dll is available in your working directory.

So having said that let us start. This post will cover the Object under the following subtopics:

Working with Drives
Working with Folders

Working with files will be dealt with in another post.


Working With Drives.

The first thing to do, since we want to work with FSO is to create the filesystemobject. It’s ActiveXobject functionality, so the syntax to create it is:

var myfso = new ActiveXobject("Scripting.FileSystemObject");

Since we want to work with the drive, the next thing is to get a handle on the drive we want to work on. Use the ‘GetDrive()’ method of the filesystemobject to do that. That is:

myfso.GetDrive('D:');

If I want to work with the drive D:

Having gotten a hold on the drive you want to manipulate, i.e. by writing:
var mydrive = myfso.GetDrive('D:');

you can make use of the following properties:
  • mydrive.TotalSize //gives you the total size of the drive in bytes
  • mydrive.FreeSpace //to get the free space in drive. myfso.AvailableSpace will also work.
  • mydrive.DriveLetter //to get letter assigned to drive i.e the drive without the ':'
  • mydrive.DriveType //this properties returns integers that indicates the kind of drive it is. for example, 1 is for removable, 2 is for fixed, while 4 is for CD-Rom
  • mydrive.SerialNumber //serial number of the drive
  • mydrive.IsReady //if the drive is available for use. Returns 'true' if it is
    available and 'false'if otherwise.
  • mydrive.ShareName //this returns the shared name for the drive
  • mydrive.VolumeName //gives you the volume name

Working With Folders

There are to ways to get a handle on a folder you want to work with. The first method is to create it, that is:

var myfolder = myfso.createFolder('c://geekabyte');

will create a folder named geekabyte in the root drive 'c:'

The second method is to get an handle on an existing folder, that is:

var myfolder = myfso.GetFolder('c://geekabyte');

Having had a hold on the folder, you have the availability of the following methods and properties.

  • myfso.DeleteFolder(handler to the folder);
    For example if you want to delete an existing folder named 'deathstar', first thing is to get to the folder. You do that by:

    var thefolder = myfso.getFolder('E://deathstar');

    now to delete it,just write:

    myfso.DeleteFolder(thefolder);

    or instead of going through the process of using the .getFolder() method, just write:

    myfso.DeleteFolder('E://deathstar');

  • Retrieve the name of a folder
    To get the name of a folder instead of the the path that getFolder() returns, use the '.name' property. It looks like this:
    //first get an handle on the folder
    var folder = myfso.getFolder('c://geekabyte');
    //to retrieve name...
    var name_of_folder = folder.name;

  • Finding out if a folder exist.
    You might want to check whether or not a folder exist.To do this, you use the .FolderExist() method of the filesystemobject.
    example.

    var returnval = myfso.FolderExists('c://geekabyte');

    if the folder exists, the method returns 'true' otherwise, 'false'

  • Finding out the name of a parents folder
    If you have a folder and you want to get the name of that parents folder, use:

    var parent_folder = myfso.GetParentFolderName('c://geekabyte/blog');

    This expression will assign 'geekabyte' to parent_folder.


Saturday, December 16, 2006

CSS Tab Designer


If you share the philosophy that time is a very important commodity while building applications, and that as much as possible, development time should actually go only to building the critical part of an application; the business logic, database design etc and not on mundane task or task that can easily be duplicated then you belong to my school of thought.

CSS Tab designer is a tool that enables you to maximize precious time in designing the user interface of a website/web application.

It is a software that helps in creating CSS based navigation list and tabs visually without having to spend time writing codes.

It so easy and so cool. On the fly, you are done creating the look and feel of your navigation, leaving you with time for other things.

With the CSS Tab designer you can:

  • Quickly design your list visually

  • Choose from a variety of styles/colors (60+ different designs/colors supported)

  • Generate strict xhtml compliant code



I'm sure this is a tool that you will derive a lot of utility from.
It's free so you can go and download it straight away.

Zamzar:Online file conversion


If all you want to do is convert a file from one format to another, and you don't see the sense in installing a software for just that singular purpose, then zamzar is an application you will like.

zamzar is an Ajax application that enables you to upload a file and then convert it to the format of your choice. The conversion is done on their server, meaning you don't have to install anything on your computer.

At the moment, zamzar is in beta version and currently it supports over 150 different files conversion.

And if you have being looking for a way to make those PDF's editable, why not just use zamzar and convert them to MS WORD where you can edit them? Yeah, it can do that to.

so Go try it out.

Saturday, November 25, 2006

Creating Objects Using Object Literal

This method offers a much more convenient way to create objects without first predefining a constructor function. This method could be viewed as one of JavaScript's strength because of how it makes the creation of object so easy.

The object literal is actually a list of property-value pairs enclosed in curly brackets and separated by colon.

The syntax look thus

var myvarobject = {'propert1':'value1','property2':'value2','propertyN':'valuen'};

To see this in action lets see how it is used in creating objects.
So if i want to create a monitor object with the following properties: make,screensize and color, i will write:

var mymonitor = {'make':'Dell','screensize':'19inches','color':'graphite'};
and i have my object created.
Once this is done, i could check to see if the object was successfully created.
Writing:
alert(mymonitor.make) should display 'Dell'. Other properties of the object can thus be accessed.

Saturday, November 11, 2006

Creating Objects in Javascript 1.0 using constructor function.

Javascript offers various methods of creating objects and this method I am going to share is just one of them. Javascript 1.0 has two methods: the object literal method and the function constructor method (which this post is about). Javascript 2.0 to also comes with its own method of making objects. The choice of which method to use depends on your personal preference and the JavaScript version most of your audience will be running…Having said that, lets get down to business

The constructor method


This method imitates the process of first defining a class and then afterwards instantiate an object. So the first thing we are going to do is to define the class. The syntax of creating a class is similar to what you have when defining a function. So let say we want to create a class called ‘webdevelopers’ you will then write

function webdevelopers()
{

}

Since a class is supposed to be a template that objects are created from; a list of the properties peculiar to that class must therefore be listed. To do that you write

function webdeveloper(identity,location,technologies,portfolio)
{
this.identity = identity;
this.location = location;
this.technologies = technologies;
this.portfolio = portfolio;
}


So the next thing to do is to create an object from this class. To illustrate let me use my friend who is a web developer as an example. Here are some of his characteristics;
• His name is Tim
• He stays in lagos
• Php is one of the technologies he uses
• Searchnigeria.info is part of his portfolio

So to model him as an object I will just write

var Tim = new webdeveloper(‘tim’ , ‘lagos’ , ‘php’, ‘searchnigeria.net’);

And so I have a ‘Tim’ object.

To see if the object is well created, try to access the listed properties. For example, including this:

alert(Tim.location);
Should result into an alert box with the message “lagos”

What about adding methods to your objects? That is also easy
i.e if I want a method that will write my name in an alert box, I will need to add the following code to the function that defines the webdevelopers class:

this.saymyname = function myfunction() {alert('dade');}

So whenever I call the method by writing ‘this.saymyname()’ the function ‘myfunction()’ will be executed and i will have my name shout at you from the alert box.