Wednesday, December 19, 2007

PHP filters

Gone are days of writing a validation class for vaildating different user inputs.
Gone are days of writing secure functions for validating URL, email address,etc.
In october 2005, first version of Filter package was released by PECL and within 1 year and 5 more releases PECL released final version 0.11 of Filter pack

You can download filter package from here
All you need is Php5.0 or higher and PEAR installer.
Installation steps are simple just write this in your console
$ pecl install filter

Usage Documentation.
Although filter functions are documented in (, I find these documentation incomplete.
While doing some googling I found a good link which described different usages of Filter functions in a simple manner.
The Link is :

I won't provide you with entire usage as it would be a waste of time when I already have good link doing the same for me.
I will only provide a snapshot to show you the power of PHP filters

Filter IP Address

Following on from validation of URLs, we often find we need to validate an IP Address. Of course, and IP address may be of different formats for ipv4 and ipv6. An IP address may also need to be within a range of private or reserved ranges. The filter extension makes it possible to discern these differences and to validate an IP address to fit most needs. In its simplest form the validation of a url will look like this.

/*** an IP address ***/
$ip = "";

filter_var($ip, FILTER_VALIDATE_IP) === FALSE)
"$ip is not a valid IP";
"$ip is valid";

As we have supplied the above with a valid IP address it validates and all is well. But now we may wish to validate an IPV6 address or an address with a private range. The IP filter has several flag with which to validate an IP address with. Listed here.


Starting at the top we will check to see if an IP is a valid IPV4 address.

/*** an IP address ***/
$ip = "192.168.0";

/*** try to validate as IPV4 address ***/
"$ip is not a valid IP";
"$ip is valid";

In the above example the IP address has failed to validate as it is not a complete IPV4 address. It would need to be of the form of the example that preceded it, to validate. This is fine, but growth of the net has seen us run out of IPV4 addresses and so we need to validate against IPV6 addresses also.

Please visit the above link, read carefully and start saving time by using the above

Friday, November 16, 2007

Checking Apache Runtime Status

mod_status provides information on your apache server activity and performance.
This tutorial will show you how to enable this feature in such a way that only requested issued from localhost will be accepted and served.

Setting mod_status up

By default, server status report is commented so you can not access it. To enable it, you need to uncomment from /etc/apache2/apache2.conf or /usr/local/apache/conf/httpd.conf :

SetHandler server-status
Order deny,allow
Deny from all
Allow from

This is a default setting, and will not work out of the box. What is said here is: server status will be acessible at location http://servername/server-status, access will be denied to everybody but people connecting from domain and any sub-domain from

We want the server status to be provided only to people connected directly from the host running the apache server. Therefore we are going to deny access to /server-status to everybody except for people connecting from localhost, in the end the setting will look like:

SetHandler server-status
Order deny,allow
Deny from all
Allow from

Note: You could be using localhost instead of, but keep in mind that if the directive HostnameLookups is turned to Off, apache won't let you access to http://localhost/server-status .

OK, now that everything is set up, check that there is no error in your configuration by using:

$apache2ctl -t or $ /usr/local/apache/bin/apachectl configtest

if everything is fine, reload apache2 configuration with:

$sudo /etc/init.d/apache2 reload or $ /usr/local/apache/bin/apachectl restart

Accessing Apache Status

To access apache status and activity, you need to request the page http://localhost/server-status, you could use text mode navigators such as elinks or links in order to connect through a console using ssh.

Now, you can access information such as server start time, server uptime, number of requests being processed, number of slots available .... The different keys are explained just under the server activity.
A neat feature of server-status is the ability to refresh every X seconds, in order to get up-to-date activity, by calling:

elinks http://localhost/server-status?refresh=2

In the previous example, the status will be updated every 2 seconds.

Getting more from Apache Server-status

If you want to get more information from your server activity, you can add the directive:

ExtendedStatus On

just above the directive. But keep in mind that this cannot be set on a per virtualhost basis and will use more resources.
But in another hand, you will be able to access more informations such as:
  • Total accesses
  • CPU usage
  • number of requests/sec, Bytes/sec and Bytes/request
  • See the different clients connected to your server, on which virtual host as well as the page there are requesting, you can even access the time it took to request a specific page as well as the resources required.

References :

Thursday, November 15, 2007

Web Developers Link Farm

Recently I found this cool link [ ] which displays all useful links that can be referred during Web Development. Its a resourceful link farm.
Some of the link categories of this farm contains are listed below:
  • Ajax
  • Firefox Plugins
  • Ruby
  • Traffic / SEO
  • Flash
  • Design

Go here

Friday, October 26, 2007

Steps to Improve Front End

  1. With reference to my last post that Front End Performance are more important than Back End performance I have finally managed to find a nice descriptive article stating how to exactly achieve it.
The below are some of the common steps taken at Yahoo to improve performance of Yahoo Products.
All the points are covered in this link

  1. The Importance of Front-End Performance
  1. Make Fewer HTTP Requests
  2. Use a Content Delivery Network
  3. Add an Expires Header
  4. Gzip Components
  5. Put Stylesheets at the Top
  6. Put Scripts at the Bottom
  7. Avoid CSS Expressions
  8. Make JavaScript and CSS External
  9. Reduce DNS Lookups
  10. Minify JavaScript
  11. Avoid Redirects
  12. Remove Duplicate Scripts
  13. Configure ETags
  14. Make Ajax Cacheable

In addition to these Yahoo also provides developers with their custom FireFox extension which finds out what components of your page are slow and what can be done for improvement.
download Page :

Wednesday, October 24, 2007

Reduce your page load time

Ever wondered why your page loads slowly even when your database queries execute at lightning speed.
Ever wondered why Super sites like Yahoo, AOL, etc load faster than your site.

If you are still wondering than this small article and the link mentioned at the bottom may help you reduce your page load time.

In any optimization effort it's critical to profile current performance to identify where the greatest improvement can be made. It's clear that the place to focus for fast web pages is the front end:

1. There is more potential for improvement by focusing on the front end. Making the back-end twice as fast reduces response times by 5-10%, whereas making the front end twice as fast saves 40-45%.
2. Front end improvements typically require less time and resources than back-end performance projects.
3. Focusing on front end improvements has proven to work. Over fifty teams at Yahoo! have reduced their end-user response times by following the best practices described here.

As web applications evolve to contain more functionality and content, these best practices are expected to have an even bigger impact.

Results Php Benchmark tests:

The above link serves only the programming aspect of PHP.
There is still lot of improvement you can do in JavaScript and DOM.
So keep googling you might end up with what you exactly want.

Friday, August 31, 2007

Send Header without error

One of the common errors a web developer often gets is "Headers already sent" error.This happens when we render some text/characters /space in the browser and then try to redirect the page using header function of php.
For long I always thought that header function will only work when there is nothing rendered before the header call.
But recently I discovered(ofcorse with help of google) that we can render anything before the header call and still redirect the page.

Normal Usage with error is

echo "This will give error"

echo "This will NOT give error";
header("refresh:0; url:");

Here refresh:0 means the page will load after 0 seconds(which is instantly).
Basically this can be used when we want to have delay the page loading say we want to load yahoo after 2 seconds.
In this case the code will be

header("refresh:2; url:");

So start using this header call and redirect the page anytime during page execution.

Saturday, August 18, 2007

Store procedure usage in PHP

Stored routines (procedures and functions) are supported in MySQL 5.1. A stored procedure is a set of SQL statements that can be stored in the server. Once this has been done, clients don't need to keep reissuing the individual statements but can refer to the stored procedure instead.

A stored routine is either a procedure . Stored routines are created with CREATE PROCEDURE statements. A procedure is invoked using a CALL statement, and can only pass back values using output variables. Stored routines may call other stored routines.
A stored procedure or function is associated with a particular database.

Procedures can be created using CREATE PROCEDURE command of mysql.
To know the exact syntax visit Online MySql documentation.

Once the procedure is created we have to use it in php code for this PHP's mysqli extension allows you to access the functionality provided by MySQL 4.1 and above

In order to have these functions available, you must compile PHP with support for the mysqli extension(MySQL Improved Extension).

To install the mysqli extension for PHP, use the --with-mysqli=mysql_config_path/mysql_config configuration option where mysql_config_path represents the location of the mysql_config program that comes with MySQL versions greater than 4.1.

mysqli functions are similar to mysql functions, there is substitute for each mysql functions in mysqli.
For e.g.

mysqli_query() has to be used instead of mysql_query()

using mysqli_query() the stored procedure query can be called and its result can be fetched.

Note: if you have to use any of mysqli functions then you will have to use mysqli functions throughout the current mysql connection
i.e. from mysqli_connect() to mysqli_close() all intermediate functions used must be of mysqli and not mysql.


Thursday, August 9, 2007

Control Flow Functions of MySQL

While doing web programming many times you fetch data from database and depending on the value fetched, the user is shown something or other.
In case of optional fields in table it is quite likely that the value may be NULL or something default that you have set.
Take for example and option field called product awards which lists all awards bagged by that product.

When you write query
SELECT pro_id, pro_awards FROM products

This will give info regarding all the awards bagged by products.
However since pro_awards is optional many records will contain value NULL.

To tackle this NULL value you check in php whether the fetched value is NULL, if yes you display "No awards bagged by this product".

You can also do this checking at database level to reduce some load on webserver.
And as Databases are configured at their optimum level the processing time is much faster than your php / any script.

This can be done this way:
SELECT pro_id, IF(pro_awards IS NULL,'No awards bagged by this product', pro_awards) as pro_awards
FROM products
Above was use of if-else construct in MySQL

You can also make use of Switch-case construct effectively.
SELECT pro_id, CASE WHEN pro_awards IS NULL THEN No awards bagged by this product' ELSE pro_awards END FROM products

Above examples are very simple to understand, I am sure you can come out with difficult situations and use these Control flow functions of MySQL effectively to reduce script execution time.


Saturday, July 14, 2007

Backward Incompatible Changes

Although most existing PHP 4 code should work without changes in PHP5, you should pay attention to the following backward incompatible changes:

  • There are some new reserved keywords.
  • strrpos() and strripos() now use the entire string as a needle.
  • Illegal use of string offsets causes E_ERROR instead of E_WARNING. An example illegal use is: $str = 'abc'; unset($str[0]);.
  • array_merge() was changed to accept only arrays. If a non-array variable is passed, a E_WARNING will be thrown for every such parameter. Be careful because your code may start emitting E_WARNING out of the blue.
  • PATH_TRANSLATED server variable is no longer set implicitly under Apache2 SAPI in contrast to the situation in PHP 4, where it is set to the same value as the SCRIPT_FILENAME server variable when it is not populated by Apache. This change was made to comply with the » CGI specification. Please refer to » bug #23610 for further information, and see also the $_SERVER['PATH_TRANSLATED'] description in the manual. This issue also affects PHP versions >= 4.3.2.
  • The T_ML_COMMENT constant is no longer defined by the Tokenizer extension. If error_reporting is set to E_ALL, PHP will generate a notice. Although the T_ML_COMMENT was never used at all, it was defined in PHP 4. In both PHP 4 and PHP 5 // and /* */ are resolved as the T_COMMENT constant. However the PHPDoc style comments /** */, which starting PHP 5 are parsed by PHP, are recognized as T_DOC_COMMENT.
  • $_SERVER should be populated with argc and argv if variables_order includes "S". If you have specifically configured your system to not create $_SERVER, then of course it shouldn't be there. The change was to always make argc and argv available in the CLI version regardless of the variables_order setting. As in, the CLI version will now always populate the global $argc and $argv variables.
  • An object with no properties is no longer considered "empty".
  • In some cases classes must be declared before use. It only happens if some of the new features of PHP 5 (such as interfaces) are used. Otherwise the behaviour is the old.

§ get_class(), get_parent_class() and get_class_methods() now return the name of the classes/methods as they were declared (case-sensitive) which may lead to problems in older scripts that rely on the previous behaviour (the class/method name was always returned lowercased). A possible solution is to search for those functions in all your scripts and use strtolower().

This case sensitivity change also applies to the magical predefined constants __CLASS__, __METHOD__, and __FUNCTION__. The values are returned exactly as they're declared (case-sensitive).

  • ip2long() now returns FALSE when an invalid IP address is passed as argument to the function, and no longer -1.
  • If there are functions defined in the included file, they can be used in the main file independent if they are before return() or after. If the file is included twice, PHP 5 issues fatal error because functions were already declared, while PHP 4 doesn't complain about it. It is recommended to use include_once() instead of checking if the file was already included and conditionally return inside the included file.
  • include_once() and require_once() first normalize the path of included file on Windows so that including A.php and a.php include the file just once.


Thursday, July 5, 2007

Boolean Full-Text Searches

Full-text searching is performed using MATCH() ... AGAINST syntax. MATCH() takes a comma-separated list that names the columns to be searched. AGAINST takes a string to search for, and an optional modifier that indicates what type of search to perform. The search string must be a literal string, not a variable or a column name.

Interesting Full Text searches for web developers can be Boolean Full-Text Searches

The following examples demonstrate some search strings that use boolean full-text operators:

'apple banana'
Find rows that contain at least one of the two words.

'+apple +juice'
Find rows that contain both words.

'+apple macintosh'
Find rows that contain the word “apple”, but rank rows higher if they also contain “macintosh”.

'+apple -macintosh'
Find rows that contain the word “apple” but not “macintosh”.

'+apple ~macintosh'
Find rows that contain the word “apple”, but if the row also contains the word “macintosh”, rate it lower than if row does not. This is “softer” than a search for '+apple -macintosh', for which the presence of “macintosh” causes the row not to be returned at all.

The + and - operators indicate that a word is required to be present or absent, respectively, for a match to occur. Thus, this query retrieves all the rows that contain the word “MySQL” but that do not contain the word “YourSQL”.

reference :

Friday, June 15, 2007

Ajax Loader Generator

Well, I have been bit lazy these days by not posting regularly...well actually earlier i was quite busy and now i m very free on a leave from office so dont feel like Starting my PC.

Some weeks ago i found this interesting stuff for all you guys for whom AJAX has become a norm in your web applications...

Got bored of simple "loading..." text or also bored of simple circular loader...then its time to check this site out.

Here you can use/customize any loading image based on your web apps design.

I wont please speak much bout it coz this site is really very useful ;P

Saturday, June 2, 2007

IE DOM Issue

Recently I had an issue wherein I had to create new HTML element via DOM.And these HTML elements needed to have some properties as well HTML events like onClick(), onMouseOver(), etc.

While doing so my code worked perfectly fine in FireFox, but in IE the new elements created did not behaved in desired manner.
After a bit research I found that setAttribute() function doesnt work always in IE (actually it is suppose to not work at all ;)..).

Substitue for using setAttribute() is to use innerHTML
eg.TR1.innerHTML = "";

In my case innerHTML didnt worked as i had too many parameters to pass wherein I was out of combinations for using single and double quotes.

Below were the different ways I tried.
Not one of the following examples worked in IE:

TD1.setAttribute('onclick', 'doThis(' + param + ');');
TD1.onclick = 'doThis(' + param + ');';
TD1.onclick = new Function('doThis(' + param + ');');
TD1.onclick = function() { doThis(param); };
TD1['onclick'] = 'doThis(' + param + ');';
TD1['onclick'] = new Function('doThis(' + param + ');');
TD1['onclick'] = function() { doThis(param); };

The hack for making onClick work for you in IE via DOM

TD1.onclick = function() {
var temp = new Function("dostuff('"+myvar+"')");

The above code works well with both IE and Mozilla.
The same technique is to be used for calling any function for any HTML Events(onMouseOver).

NOTE: The above code can be simplified only when the function you are calling (dostuff) does not have any parameters to pass.

TD1.onclick = function() { dostuff(); }

Some more interesting hacks for making your DOM work in IE are


blah.className = 'myCSS'; <-- This line needs to be added

blah.setAttribute('valign', 'top'); This wont work as IE is case-sensitive
blah.setAttribute('vAlign', 'top');

Reference: Why IE Sucks

Wednesday, May 30, 2007

JavaScript Conditional Compilation.

Below are few inbuilt JS variable using which we can know some details of Client machine.

Predefined conditional compilation variables
for JavaScript
Variable Description
@_win32 Returns true if running on a Win32 system, otherwise NaN.
@_win16 Returns true if running on a Win16 system, otherwise NaN.
@_mac Returns true if running on an Apple Macintosh system, otherwise NaN.
@_alpha Returns true if running on a DEC Alpha processor, otherwise NaN.
@_x86 Returns true if running on an Intel Processor, otherwise NaN.
@_mc680x0 Returns true if running on a Motorola 680x0 processor, otherwise NaN.
@_PowerPC Returns true if running on a Motorola PowerPC processor, otherwise NaN.
@_jscript Always returns true.
@_jscript_build The build number of the JScript scripting engine.
@_jscript_version A number representing the JScript version number in major.minor format.

IE4 supports JScript 3.x
IE5.x supports JScript 5.5 or less
IE6 supports JScript 5.6

The version number reported for JScript .NET is 7.x.

@_debug Returns true if compiled in debug mode, otherwise false.
@_fast Returns true if compiled in fast mode, otherwise false.

In most cases, you probably will be limited to just using @_win and @jscript_build:

@if (@_win32)
document.write("OS is 32-bit. Browser is IE.");
document.write("OS is NOT 32-bit. Browser is IE.");

User defined Variables

You can also define your own variables to use within the conditional compilation block, with the syntax being:

@set @varname = term

Numeric and Boolean variables are supported for conditional compilation, though strings are not. For example:

@set @myvar1 = 35
@set @myvar3 = @_jscript_version

The standard set of operators are supported in conditional compilation logic:

  • ! ~
  • * / %
  • + -
  • << >> >>>
  • < <= > >=
  • == != === !==
  • & ^ |
  • &amp;amp;& |

You can test if a user defined variable has been defined by testing for NaN:

@if (@newVar != @newVar)
//this variable isn't defined.

This works since NaN is the only value not equal to itself.


Friday, May 25, 2007

JavaScript No click links

No-click-links are link which you don't have to click.
While Googling for Eazy no click links, I found a Javascript code which enables us to navigate without clicking.
The example is given here

Other than no Clicks, there quite good number of other examples also like
  • mulitselect without control button use,
  • Visual Passwords,
  • Instant Form Validation,
  • etc. ;)
btw myself hoping to see a revolution in Web Navigation by use of more No click links and Visual passwords.

Thursday, May 24, 2007

Browser-Specific selectors (CSS)

These selectors are very useful when you want to change a style in one browser but not the others.

IE 6 and below

* html {}

IE 7 and below

*:first-child+html {} * html {}

IE 7 only

*:first-child+html {}

IE 7 and modern browsers only

html>body {}

Modern browsers only (not IE 7)

html>/**/body {}

Recent Opera versions 9 and below

html:first-child {}


html[xmlns*=""] body:last-child {}

To use these selectors, place the code in front of the style. E.g.:

#content-box {
width: 300px;
height: 150px;

* html #content-box {
width: 250px;
} /* overrides the above style and changes the width to 250px in IE 6 and below */

Get First Buisness day of Month- PHP

I have written a small function which calculates if given date is first buisness day of that month.
This can be set in cron job and run every day to check if this is first buisness day.
This can be useful for sending newsletters / promotional offers , etc on first buisness day of every month.

function definition is given below

* Function which checks if current date passed is a first buisness day of any month or NOT.

* Description - First it checks if given date is 01 if yes then check if its not sat/ sun / public holidays.
if 01st is nonbuisness day then ignore return false.
In this case when the function will be called again on 02, here it will check if 02 is buisness day, if yes then if 01 was non buisness day then 02 is definitely first buisness day of the month.
This check will be done until 06 of every month.

* @param integer $year year in YYYY format
* @param integer $month Month in MM format
* @param integer $day day in DD format
* @param mixed $non_buisness_days array containing all non buisness days values will be in format Sat, Sun, Tue
* @param mixed $public_holidays An array containing list of all holidays for given year, the dates should be in YYYY-MM-DD format
* @return bool true if given date is first buisness day else otherwise false.
* @author VN (02/05/2007)

function is_first_buisness_day($year,$month,$day,$non_buisness_days='',$public_holidays='')
$tmpstamp = mktime(1,1,1,$month,$day,$year);
//echo $year,$month.$day."
$ymd = date('Y-m-d',$tmpstamp);

if($public_holidays == ''){
$public_holidays = array();
if($non_buisness_days == ''){
$non_buisness_days = array();

$d = date('d',$tmpstamp);
$day = date('D',$tmpstamp);
$month = date('m',$tmpstamp);
$year = date('Y',$tmpstamp);

$previous_d = $d-1;
$previous_day = date('D',mktime(1,1,1,$month,$previous_d,$year));

$tp_first_day = mktime(1,1,1,$month,01,$year);
$day_first_day = date('D',$tp_first_day);
$day_first_ymd = date('Y-m-d',$tp_first_day);

if(($d == 01 && (!in_array($day,$non_buisness_days) && !in_array($ymd,$public_holidays)))
($d != 01 && (in_array($day_first_day,$non_buisness_days) in_array($day_first_ymd,$public_holidays)) &&
(!in_array($day,$non_buisness_days)) && (!in_array($ymd,$public_holidays)) &&amp;amp;
($d <=5 && (in_array($previous_day,$non_buisness_days) (in_array($day_first_ymd,$public_holidays)))))){ $return_value = true; } else { $return_value = false; } unset($d); unset($day); unset($month); unset($year); unset($non_buisness_days); unset($previous_d); unset($previous_day); unset($tp_first_day); unset($day_first_day); unset($public_holidays); return $return_value; }


$pb = array('2007-05-01','2007-12-25');
$dt = $_GET['getdate'];;
$dt = explode('-',$dt);

$non_buisness_days = array('Sat','Sun');

echo "Non Buisness days array:
foreach($non_buisness_days as $i => $v){
echo "'".$v."'";
echo " ";
echo "

echo "Public holiday array:
foreach($pb as $i => $v){
echo $v;
echo "
echo "


$bool = is_first_buisness_day($dt[0],$dt[1],$dt[2],$non_buisness_days,$pb);

echo 'YES
'.$_GET['getdate'].' is a first buisness day of Month '.date('F - Y',mktime(1,1,1,$dt[1],$dt[2],$dt[0]));
echo 'NO
'.$_GET['getdate'].' is not a first buisness day of Month '.date('F - Y',mktime(1,1,1,$dt[1],$dt[2],$dt[0]));

Wednesday, May 23, 2007

Navigation Without Mouse Clicks

Have you ever wondered how Surfing would be without mouse-clicks.
Still thinking what I mean.
Let me make it straight then.
lets Say there exist a "Link". Now inorder to view this page, people would normally click it.
Navigating without mouse clicks is that -all we need to do is just do mouseover on it and the link will be clicked and we will be taken to the desired page.

This is very much possible and many research projects are made online based on No-Click Idea.
If this idea is accepted by Internet Users then there would be no sound of mouse clicking while surfing internet,it would be a Quite expedition and number of people complaining of finger pains due to mouse clicks will also gradually decrease ;).

One such research project is here .

I would strongly recommed you all to visit it so as to get that weird-nice experience while navigating this site.

I thoroughly enjoyed my experience and even played few games there.

Monday, May 21, 2007

Search Engines

These days most search engines will automatically index your web page.But if you are interested to do it manually, here is a list of few popular search engines wherein you can feed in your web page address ;)

Search Engines that will accept your URL


Web Glossary

This is a short glossary list for some commonest and few lesser known terms used over www.

Web Glossary

A web technology for streaming movies from a web server to a web client. Developed by Microsoft.

A programming interface (API) that allows web browsers to download and execute Windows programs.

An open source web browser editor from W3C, used to push leading-edge ideas in browser design.

A computer program to locate files on public FTP servers.

API (Application Programming Interface)
An interface for letting a program communicate with another program. In web terms: An interface for letting web browsers or web servers communicate with other programs.

Banner Ad
A (most often graphic) advertisement placed on a web page, which acts as a hyperlink to an advertiser's web site.

The number of symbols per second sent over a channel.

Clickthrough Rate
The number of times visitors click on a hyperlink (or advertisement) on a page, as a percentage of the number of times the page has been displayed.

Information from a web server, stored on your computer by your web browser. The purpose of a cookie is to provide information about your visit to the website for use by the server during a later visit.

Web development software for most platforms (Linux, Unix, Solaris and Windows).

Dynamic IP
An IP address that changes each time you connect to the Internet.

A computer program for transferring (and reformatting) data between incompatible applications or networks.

The number of times a web object (page or picture) has been viewed or downloaded.

Trojan Horse
Computer program hidden in another computer program with the purpose of destroying software or collecting information about the use of the computer.

Addressing a web page or an e-mail with a false referrer. Like sending an e-mail from a false address.

Web Spider
A computer program that searches the Internet for web pages. Common web spiders are the one used by search engines like Google and AltaVista to index the web. Web spiders are also called web robots or wanderers.

A computer virus that can make copies of itself and spread to other computers over the Internet.

Exhaustive list of glossary is available

Thursday, May 17, 2007

Label / Tag Cloud for Blogger

After a bit googling, I finally managed to find a good piece of code for making my own tag cloud.
This person "phydeaux3" has made it so simple that even a kindergarten kid can do all by his own.
Hats off to this person.I wont speak much about it here, you should better check out here, If you like it, go ahead and praise phydeaux3.

For those who couldn't find the link here it is once again

Wednesday, May 16, 2007

SEO Types

Types of SEO

SEO techniques are classified by some into two broad categories: techniques that search engines recommend as part of good design, and those techniques that search engines do not approve of and attempt to minimize the effect of, referred to as spamdexing. Professional SEO consultants do not offer spamming and spamdexing techniques amongst the services that they provide to clients. Some industry commentators classify these methods, and the practitioners who utilize them, as either white hat SEO, or black hat SEO. Different hat colors do not necessarily imply differences in ethics as much as differences in business models. White hats tend to produce results that last a long time, whereas black hats anticipate that their sites will eventually be banned once the search engines discover what they are doing.

White hat

An SEO tactic, technique or method is considered white hat if it conforms to the search engines' guidelines and involves no deception. As the search engine guidelines are not written as a series of rules or commandments, this is an important distinction to note. White hat SEO is not just about following guidelines, but is about ensuring that the content a search engine indexes and subsequently ranks is the same content a user will see.

White hat advice is generally summed up as creating content for users, not for search engines, and then making that content easily accessible to the spiders, rather than attempting to game the algorithm. White hat SEO is in many ways similar to web development that promotes accessibility,although the two are not identical.

Spamdexing / Black hat

Black hat SEO attempts to improve rankings in ways that are disapproved of by the search engines, or involve deception. One black hat technique uses text that is hidden, either as text colored similar to the background, in an invisible div, or positioned off screen. Another method redirects users from a page that is built for search engines to one that is more human friendly. A method that sends a user to a page that was different from the page the search engined ranked is black hat as a rule. The black hat practice of serving one version of a page to search engine spiders and another version to human visitors is called cloaking.

Search engines may penalize sites they discover using black hat methods, either by reducing their rankings or eliminating their listings from their databases altogether. Such penalties can be applied either automatically by the search engines' algorithms, or by a manual site review.

One infamous example was the February 2006 Google removal of both BMW Germany and Ricoh Germany for use of deceptive practices.Both companies, however, quickly apologized, fixed the offending pages, and were restored to Google's list.

Saturday, May 12, 2007

Google bomb

A Google bomb (also referred to as a 'link bomb') is Internet slang for a certain kind of attempt to influence the ranking of a given page in results returned by the Google search engine, often with humorous or political intentions. Because of the way that Google's algorithm works, a page will be ranked higher if the sites that link to that page use consistent anchor text. A Google bomb is created if a large number of sites link to the page in this manner. Google bomb is used both as a verb and a noun. The phrase "Google bombing" was introduced to the New Oxford American Dictionary in May 2005. Google bombing is closely related to spamdexing, the practice of deliberately modifying HTML pages to increase the chance of their being placed close to the beginning of search engine results, or to influence the category to which the page is assigned in a misleading or dishonest manner.

Life Cycle of a Bomb
A Google bomb begins as a webmaster prank. A website manager convinces fellow website managers to put on their sites a hyperlink to the target site containing the desired search words. If enough of those links appear in the various sites on the web, Google's algorithms will recognize that site as being a potential search result for those keywords. Eventually, the site may work its way to the top of the search results.
Google bombs often end their life by becoming too popular or well known: they typically end up being mentioned in multiple well-regarded websites, which themselves then knock the bomb off the top spot. Wikipedia, a notable example, has beaten many Google bombs to the top just by mentioning them in this and other articles.

Friday, May 11, 2007

Whack your Boss

Time to Whack your Boss.
Its PayBack time....
(this is how u embed games in a webpage)


About Pit

True source of inspiration to start this blog were these two adages
  • Knowledge without sharing is worthless.
  • Knowledge without sharing is as a stagnant water so Experience Learning with Sharing.

This is called Web Developers Pit. Hence all articles / news and every damn thing related to web will be published here. Yeah you can mine this pit to any level.

Contact Me

I would love to hear what you have to say about my writing and what I do. If you have any positive or negative feed back, please take a moment of yours to give back to me, so I can help give you and everyone else a lot more.

If you come across anything that you think would interest me and it can feature on my blog, let me know I would love to publish something that our readers like especially if it matches our site's content.

You can contact me at sinless dot hypocrite at gmail dot com

Thursday, May 10, 2007

Google Logo's

Google Logo's

Well call it googlogy or googleX. I just can't stop exploring google. Google has provided so many tools / pages / features to its users, just to prevent them moving out of and invite more new users.

One of its steps in doing so was to connect with peoples emotions and google did it with logo's.

Initially Google developers mostly Larry Page customised Google logos just to represent mood @ google center but later they played it quite often and it assumed a big time role.Now google represents all global, unbiased days like remembering Man's first step on moon, thanks giving, Edvard Munch's Birthday etc.

Louis Braille's Birthday - January 4, 2006

Happy Halloween - October 31, 2006

They have now got their own team of Creative designers who regularly keep designing new logos for Google.

You can view all official and unofficial logos of google at

Official Logos

Holiday Logos

Fan Logo's

Enjoy and be creative to send ur version of google logo to Google Team

Google and You = iGoogle

Google and You = iGoogle

Google has transformed its rather plain-sounding Google Personalized Homepage into the new, (hopefully) sexier iGoogle. Apparently it's something of an old idea; according to Marissa Mayer, Google's VP of search products and user experience, iGoogle was floated as a name for the Personalized Homepage back in 2005 when the service was being assembled. Google then decided to offer Personalized Homepage as a feature rather than a distinct product, however, and intentionally went with the mundane title. Now, two years later, Google has slapped an "i" on the front, intending it to represent a personalized Google experience—I Google, you Google, etc. Either that, or the Google CEO's tenure on Apple's Board of Directors is showing.

One of the major new features of iGoogle is the ability to build gadgets without any prior programming experience. In Google parlance, a gadget is a feature you can design and send to a friend or a family member. Examples of current gadgets include photos, GoogleGrams, YouTube channels, a quote-of-the-day, and a handy personalized anniversary (or other holiday) reminder.

Gadgets can also be set to update automatically, so that your friends and family receive a new one every day. Given just how much most people love getting their "Joke of the Day" from
Santa Banta JOkes.

iGoogle, Google is trying to push the concept of Google as more than just a search engine, while allowing users to selectively incorporate the additional data they see rather than simply throwing it at them a la Yahoo. Encouraging users to create personal spaces at iGoogle not only increases the amount of time users spend on Google's site, it also opens additional advertising and promotional opportunities, all of which the company would welcome as it continues to look beyond its search engine for additional revenue sources.

Thursday, April 26, 2007

Google results Incomplete

While playing around with Google, I found that although Google claims it has returned lakhs of entries for your search it never shows more than 1000 entries.
check this link out
this is the last page of the results for search keyword google.
and at the bottom it shows
If the above link is clicked to fetch omitted results, google doesn't shows all those records instead it repeats the same query and displays only till 1000 entries.
Strange fact is all the other search engines like Yahoo, ninemsn, ask, msn, etc all behave the same as Google. Nobody displays all the records.

Friday, April 20, 2007

String Manipulation . explode string

exploding string at each component character

the below mentioned preg_Split() function is very useful in exploding entire string for each of its characters;

$str = 'Mumbai';
$chars = preg_split('//', $str,-1, PREG_SPLIT_NO_EMPTY);

[0] => M
[1] => u
[2] => m
[3] => b
[4] => a
[5] => i

Thursday, April 19, 2007

JS 3d arrays

To use multi-dimensional arrays in js, we have to define it as an array at each dimension. -

abc['test1'] = new Array();
abc['test1'][test2'] = new Array();
abc['test1'][test2']['test3'] = new Array();

foreach() substitute in JavaScript JS

JavaScript For...In Statement
The statement is used to loop (iterate) through the elements of an array or through the properties of an object.
The code in the body of the for ... in loop is executed once for each element/property.
for (variable in object)
code to be executed
The variable argument can be a named variable, an array element, or a property of an object.
Using to loop through an array:

var x
var mycars = new Array()
mycars[0] = "Saab"
mycars[1] = "Volvo"
mycars[2] = "BMW"
for (x in mycars)
document.write(mycars[x] + "

appendchild issue in IE

While Working in one of my applications I had to create new row dynamically on click of a button.

The below code worked fine with Mozilla, however nothing happened in IE also no errors were shown
var theTable = document.getElementById(tableId);
var rowIdAttribute = i+1;
var newRow = document.createElement('tr');

newRow.setAttribute("id", rowIdAttribute); theTable.appendChild(newRow );

I found that IE does not support appendChild to add new rows in the table
So I added a container element to place the new row and append that container element.
Correct code is as shown below which works fine both in IE and Mozilla

var theTable = document.getElementById(tableId);
var newtbody = document.createElement('TBODY');
var rowIdAttribute = i+1;
var newRow = document.createElement('tr');

newRow.setAttribute("id", rowIdAttribute);