What will happen to your online life after you die?

Its off topic but the concept is so great I could not resist blogging it. A traditional business model implemented over the web in these Web2.0 times which is sure to succeed.

Before you die or any unfortunate incident occurs in your life, you make sure that all your assets, property goes into right hands. To take care of it, you make a will and assign a beneficiary to pass your assets to the correct person. Now try mapping it with the web. You have an online life. Don’t you? You exist on Gmail, Hotmail, FaceBook, Twitter and numerous other services. You have some personal pictures stored on flickr, some lovely mails on your Yahoo or Gmail account which you would not want to go into any other hands. Ever wondered what will happen to your all these accounts in case you die or something happens to you?

Here comes Legacy Locker. Legacy Locker is a service that will store your credentials to mail services, social networks and other important services on the web and will pass them to a caretaker chosen by you in event of your death. It is kind of protecting your online life after death.

The service is not available yet and will be opening in April 2009. Of course there will be money charged for the service .The pricing is kept at $300 which can be paid as one time fee of $300 or yearly payments of $30.

The list of sites/networks that Legacy Locker has already covered is impressive. The list already includes Gmail, Flickr, Facebook, Paypal, Yahoo! Mail, Ebay, iTunes, ING, Snapfish, YouTube, AOL, Amazon, Kodak Gallery, WordPress, GoDaddy, Hotmail, Netflix, Blogger, LinkedIn, Photobucket, 12seconds, Box.net, Friendster, TypePad, Party Poker, Mint, Twitter and many other sites.

The service seems to be useful. Let’s see how many users consider it for managing their online identities after death.

Give thisĀ  article a Thumbs-up on Stumbleupon if you liked it.

Celebrate Pi Day

Pi fans will be celebrating Pi Day all over the world on 14th March. As you already know Pi is a mathamatical constant. Its value is the ratio of any circle’s circumference to its diameter
Today at 1:59 date time will read 3 14 1 59 which is the value of Pi upto 5 decimal places i.e 3.14159. It is observed by the majority of people at 1:59pm though some celebrate at 1:59am too.

Official website for Pi Day – http://www.piday.org/

How to rename files in a directory with php

Recently I came across a situation where I needed to rename more then 100 mp3 files. For some reason I had to remove first 4 characters from each file name. Rather then renaming each file manually, I thought of writing a small php script that renamed all these files for me.
I would like to share that with you, so here goes the code.

$dir = "F:\\Music\\php_test";
$fileType = "mp3";
$charsToTrim = 4;
if($handle = opendir($dir)) 
    $count = 1;
    while (false !== ($file = readdir($handle))) // read files in directory one by one
		$extension = substr(strrchr($file,"."),1);// get the extension
		if(strcasecmp($fileType,$extension) == 0)// proceed only if it matches with the extension we have provided
			$newName = substr($file,$charsToTrim); // generate new name for file
			$success = rename($dir."\\".$file, $dir."\\".$newName); // rename the file
				echo $file." renamed to ".$newName;
				echo "
"; $count++; } else { echo "Cannot rename ".$file. " to ".$newName."
"; echo "
"; } } } } echo $count." files renamed"; } closedir($handle);

You will have to set these 3 parameters:
$dir – Location of directory in which files are placed.
$fileType – Extension of files that you want to rename(mp3 or txt or doc any other)
$charsToRemove – How many characters do you wish to remove from the filename.

Set these and you are ready to rename. Remember that this script will only trim characters from start of the file name.
This means if you have set $charsToRemove = 5, a file with name “abcd_Plateau” will be renamed to “Plateau”.

Waiting for comments and suggestions.

Create tinyurls in PHP using tinyurl.com API

For all those unfamiliar with tinyurl, it is a service thats lets you convert long urls into short ones. It is very popular and gets about 1.5 billion hits per month. Use of tinyurl can be seen hugely in applications like twitter. As twitter limits users to enter 140 character messages, long urls are a pain to post. Tinyurl reduces them to 25-30 characters. Then they can be posted easily along with other message.

Although it is not mentioned anywhere on TinyURL site, it has an API using which you can write a utility in PHP to create your own tiny urls.

The API can be found at


It expects a parameter url which is the URL you wish to convert into tiny url. Return value is the generated tiny url in case of success, error otherwise.

Here is the php code:

$url = "http://vijayjoshi.org";
$tiny = file_get_contents("http://tinyurl.com/api-create.php?url=$url");
echo 'Original url : '.$url;
echo '
'; echo '
'; echo 'TinyURL (Click to test) : '.$tiny.'';

In the above case it will output

Pretty straightforward. $url contains the url you wish to convert. Then we pass it along with the API url and finally use php function file_get_contents to get the output.

Go ahead and give it a try.

Give thisĀ  article a Thumbs-up on Stumbleupon if you liked it.

FAQ : How to toggle visibility of an html element by javascript

In my previous post, I discussed how we can change the style and/or css class of any html element by JavaScript. We can take advantage of this feature to add functionality where visibility of elements can be toggled. That means clicking a button will change the state of that element from visible to invisible and vice-versa.

The css property that we will manipulate to achieve this behavior is “display”. Below is the html we will use for the example.

<title>Toggle elements</title>
<script type="text/javascript" language="javascript">
<div style="border:2px solid;">
<p><input type="button" onClick="toggleMe('toggleHolmes');" value="Click to toggle"/></p>
<p id="toggleHolmes" style="display:block;">
I consider that a mans brain originally is like a little empty attic, and you have to stock it with such furniture as you choose. A fool takes in all the lumber of every sort that he comes across, so that the knowledge which might be useful to him gets crowded out, or at best is jumbled up with a lot of other things, so that he has a difficulty in laying his hands upon it.<br/>
-Sherlock Holmes (A Study in Scarlet - Part 1,chap. 2)
<div style="border:2px solid;">
<p><input type="button" onClick="toggleMe('toggleNietzsche');" value="Click to toggle"/></p>
<p id="toggleNietzsche" style="display:block;">
God is dead. God remains dead. And we have killed him. How shall we comfort ourselves, the murderers of all murderers? What was holiest and mightiest of all that the world has yet owned has bled to death under our knives: who will wipe this blood off us? What water is there for us to clean ourselves? What festivals of atonement, what sacred games shall we have to invent? Is not the greatness of this deed too great for us? Must we ourselves not become gods simply to appear worthy of it?<br/>
-"The Madman" (Thus Spoke Zarathustra by Friedrich Nietzsche)


There are 2 paragraphs with ids “toggleHolmes” and “toggleNietzsche” which contain some text. Above each of them is a button. Onclick of each of those buttons we have called a function toggleMe which accepts the id of the element which is to be toggled as its parameter.
Now include the following JavaScript code between the script tags in above html.
Continue reading FAQ : How to toggle visibility of an html element by javascript