Archive for April, 2008

Updating DNS Entries while Minimizing the Downtime

If you ever need to update the DNS records for your servers, make sure that you set the TTL value to few seconds first. This will minimize your downtime to a few seconds.
TTL (or time to live) is the amount of time for which other computers or DNS servers will cache your IP address. Suppose [...]

Trim Last Character(s) from a String in Javascript

Today, I had a need to join comma separated strings in Javascript which turned out to be very easy. I wrote something similar to this
for(var i=0; i < length; i++){
string=string+labels[i]+”,”
}
where string was defined as a var and labels as array.
The difficult part was to remove the last comma. After googling for fifteen minuted, I decided [...]

Create .htaccess file in Vista

I enjoy using command line, especially for things that I cannot do using GUI. Today, I spent good 15 minutes trying to create .htaccess file in c:\xampp\htdocs directory on my Vista machine. I guess Vista expects a file name before the period and therefore kept saying ‘You must type a file name’. This DOS command [...]

Check if Password is Alphanumeric – PHP

A couple of weeks ago, I spent several hours trying to figure out how to check if a password is alphanumeric or not. Following is a function that worked along with explanation.
1 function checkPasswordIsAlphaNumeric($password1){
2 $pattern1 = “/[a-zA-Z]+/”;
3 $pattern2 = “/[0-9]+/”;
4 return ((preg_match($pattern1, $password1)) && (preg_match($pattern2, $password1)));
5 }
Line 1 is simple. We declare a function ‘checkPasswordIsAlphaNumeric’ [...]