PHP : Find script execution time

If you are a PHP developer chances are many that you need to find how much time it took to execute a piece of code. Using the script below you can find how much time it took to execute your php code.


$time_start = microtime(true);

// execute your tasks here

$time_end = microtime(true);
$time = $time_end - $time_start;

echo "Code executed in $time seconds\n";

You can try these examples


$time_start = microtime(true);

// execute your tasks here
phpinfo();

$time_end = microtime(true);
$time = $time_end - $time_start;

echo "Code executed in $time seconds\n";

Another example


$time_start = microtime(true);

// execute your tasks here
sleep(1); // wait for 1 second

$time_end = microtime(true);
$time = $time_end - $time_start;

echo "Code executed in $time seconds\n";

ASP and C# version of the code can be found here

Check Javascript version here

Posted in PHP | Tagged | 3 Comments

WordPress : How to change blog title to image or logo?

After you install wordpress by default the blog title appears in the header . Using the below method you can change the blog title or name to you company logo or to a custom image.

Login to admin console of your website.

  1. Goto Appearance->Editor
  2. Click to editĀ HeaderĀ (header.php) from the right side of page.
  3. Navigate to code which looks like this
    <span>
    
    <a href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a>
    
    </span>
    
  4. First lets comment the blog title
    Comment like this, or you can remove this line.

    <?php //bloginfo( 'name' ); ?>
    
  5. Next we need to add logo or image
  6. Insert image like this
    <img src="http://einternals.com/images/einternals-logo.gif" width="260" height="48" />
    
  7. So the full code will look like
    <span>
    
    <a href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><img src="http://einternals.com/images/einternals-logo.gif" width="260" height="48" /><?php //bloginfo( 'name' ); ?></a>
    
    </span>
    

Now the image or company logo you added will be displayed in the blog header.

Posted in CSS, PHP, Wordpress | Tagged , , | 8 Comments

WordPress : How to remove page title only from a single page

Do this if you don’t want to show the page title on top of a page in wordpress.

Method 1 : (will not work if you save the post in Visual editor mode)

Add this style below the content in HTML editor.

<style>.entry-title {display:none;}</style>

Make sure the editor mode is HTML, NOT Visual

Method 2 (editing the CSS style sheet)

First you need to get the ID of your page.

How to find the ID of the page

  1. Preview or publish your page.
  2. View html source of your page (Ctrl+U in Google Chrome and Mozilla Firefox, Top menu->View->Source in Internet Explorer )
  3. Search for body tag. The page ID will be shown in the body tag.
    In this case the page ID is 40
  4. Now go to Appearance->Editor in WordPress admin
  5. Edit style.css
  6. Add this style
    #post-40 .entry-title
    {
       display:none;
    }
    

    Change 40 to your page ID.

  7. Save the file.
  8. Now check the page. You will not see the title of the page.
  9. For hiding page title in multiple pages add style like this
    #post-40 .entry-title,
    #post-41 .entry-title,
    #post-42 .entry-title
    {
       display:none;
    }
    

    In this case page title will not be shown in pages which has ID 40,41,42

Posted in CSS, Web development, Wordpress | Tagged , , | 12 Comments

Bhuvan – Indian version of Google Earth

Bhuvan

ISRO today launched a service called Bhuvan which is similar but more superior than Google Earth.

The new site is released a beta version. The address of the site is http://bhuvan.nrsc.gov.in/

From the site
A Geoportal of Indian Space Research Organisation showcasing Indian Imaging Capabilities in Multi-sensor, Multi-platform and Multi-temporal domain. The portal gives a gateway to explore and discover virtual earth in 3D space with specific emphasis on Indian region.

The new mapping service Bhuvan is a Sanskrit word of earth. It will allow users to have a closer look at any part of the subcontinent. Bhuvan will provide the pictures of objects as small as a car on the road to build three-dimensional map of the world via ISRO’s seven remote sensing satellites.

For accessing Bhuvan you have to first Register in the site. After that you have to login and download a browser plugin. The size of the plugin will be about 10.76MB

Posted in Technology | 3 Comments

Disable right click menu in Flash (swf files)

There are times when you have to disable the default right click menu on flash files on your webpages.

Uza has a suggested a method to completely disable the flash right menu.
Check the article link at his website http://www.uza.lt/blog/2007/08/solved-right-click-in-as3
and the Demo here http://www.uza.lt/rightclick/

You can also download the project files from the Google code
Project website:
http://code.google.com/p/custom-context-menu/

Posted in Flash/Flex | Tagged , , , , , | 4 Comments