Search This Blog

Tuesday, February 9, 2010

is_a is deprecated in php

When we try to put E_STRICT in error reporttin we will get an error in xajax.inc.php for "is_a" in line 658 which is because of deprecation in 5.3 so replace the line which the line below
i.e we can use instanceof instead of is_a to check the object is of the specific class

    if ($sResponse instanceof xajaxResponse) {
}
-- 

sorting in postgresql


When I was working on a query I wrongly typed the where condition as order by then i found it accepts and gives result by sorting on the order of values i have given check below , We can use this cool feature for sorting columns like month week days etc., instead of storing print order we can use this (after checking the performance factor)
Example : 

SELECT leather_type_id as a,leather_type_name from _mleather_type order by leather_type_id in (200795,200794,200796) desc;
   a    | leather_type_name
--------+-------------------
 200795 | Goat
 200796 | Pig
 200794 | Cow
 200797 | Sheep
 202082 | Reptile
 200190 | Hair Sheep
 203319 | touchleather
 203320 | cow touch leather
 200193 | Others
 200793 | Buffalo

Sixth Sense By Pranav

http://www.pranavmistry.com/projects/sixthsense/#VIDEOS

Thursday, February 4, 2010

Add Repo to the Kubuntu Source list

Open file /etc/apt/sources.list on vi or any text editor with sudo

ex sudo vi /etc/apt/sources.list

Add the following lines at the end of the file

'deb http://ppa.launchpad.net/ubuntu-mozilla-daily/ppa/ubuntu jaunty main'
'deb-src http://ppa.launchpad.net/ubuntu-mozilla-daily/ppa/ubuntu jaunty main'

Run this command on konsole

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 247510BE

open start->system settings->computer administration->add or remove software
on the search box type firefox-X.x

Select the package from the list below to install and enjoy :)

Wednesday, February 3, 2010

KcacheGrind Profiling for PHP -Speed up Your Scripts

To check the time taken to execute a query we can use \timing on the psql prompt with Analyze and Verbose
To check the render engine we can use fire bug and firephp with YSlow,Jiffy etc., (even we can debug javascript and go for line by line execution of all the client side script )

For PHP code

While we write a code or test a code we are not able to clearly check how much time it will take for executing part of code (loops,functions) , How many times each function are called etc., to track this we have many tools like APD,XDebug

Herewith I am giving the steps to install and check the efficiency of code using XDebug



Installation and configuring(XDebug)

1) sudo pecl install xdebug

2) zend_extension =/usr/lib64/php5/extensions/xdebug.so
or
zend_extension =/usr/lib/php5/extensions/xdebug.so
xdebug.profiler_enable=1
xdebug.profiler_output_dir=[/home/myhome/apdtrace/]

3) sudo httpd restart

Now try to view the output of your phpinfo() function. If you find xdebug word in that then it means you have successfully installed xdebug.

Install kcachegrind
option 1
use YAST->software Management->Search->kcachegrind
accept the proposal
option 2
sudo apt-get -y install kcachegrind (for debian Systems)

Add these Lines on your code(recommended) or php.ini
ini_set('xdebug.collect_vars', 'on');
ini_set('xdebug.collect_params', '4');
ini_set('xdebug.dump_globals', 'on');
ini_set('xdebug.dump.SERVER', 'REQUEST_URI');
ini_set('xdebug.show_local_vars', 'on');

execute your code on browser you will get a file named cachegrind.out. on your output directory
open the file with your kcachegrind now you can clearly dissect your code and remove unnecessary code and loops and check the speed again