cackphp log queries without layout

if (Configure::read('debug') == 2) {
$db = ConnectionManager::getDataSource('default');

How to get self confidence on source code you write?

Coding is primary task of every developer and we all know very well about it. But why may developers are not much confident about source code they wrote?

I do study few developers and fond following reasons.

They really don’t know/care what they wrote

They don’t like to go into further details of what they wrote. many do copy code form internet and feel they solve the issue.

They don’t try to think about every possible case

Many time they know there is potential bug but they are waiting for some one to generate  case and raise the issue. if it is found by someone they will fix it, But If no one able to identify they feel it’s ok or they wait till someone identify it.

They lack basic programming skills or believe in It’s not important

I asked may developers about basic questions of programming language they work on more then 3-5 years. for example I asked one PHP developer what are data types in PHP? and he replied “There is no need to define data type in PHP” Does it mean you no need to know about variable data types? one more example I asked on developer “what is difference between  Pass by reference and  Pass by value” and he replied “I don’t know”

So what is solution?

As per my best knowledge and experience I would like to share one of my tricks. whenever I write code I do ensure I know what  is impact of that line of code. If I don’t know about a single symbol, keyword or best practice I stop writing code and first clear my understanding and get enough knowledge. I know it is time consuming initially but It will save lots of time in future.

Windows 7 google chrome hangs when visit

When I open facebook on Windows 7 google chrome it hangs system for few seconds.

To resolve this issue open chrome.

In address bar type chrome://plugins and press Enter.

You will have list of installed plugins. click on “+ Details” button on top right side if list is not expanded.

Search for “flash” word and you will find two plugins files, one form operating system and another is from  google chrome.

Disable plugin file from google chrome.


For reference view below image. it is from mac operating system. on windows you will have similar things but only different is path of plugin file.

Screen Shot 2014-06-23 at 11.41.03 am


IOS7 PickerViewController control status bar style

Put following code in the view controller from where you present view controller.

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];


Source :

How to differentiate good code vs bad code

To differentiate between good code and bad code you must have basic knowledge of programming. If you don’t have it the following is list of things you should read about.

  1. Variable
  2. Function
  3. Class and Object
  4. Loops

Once you have idea what they are you need to check for following:

  1. Are name used for variables, functions and classes describes what they contain or how they work? If answer is yes, the code is good.
  2. is code formatting is quite consistent? If answer is yes, the code is good.
  3. is there commented code? If answer is yes, the code is bad.
  4. is file names are meaningful and folder name describes what it contains? If answer is yes, the code is good.

Above are very basic checks if you would like to differential with more details you should read programming best practice books and should learn programming language.

MySQL database best practice of choosing data types during database design

Below is list of prefered database types with lengths:

Email : varchar(254)

Domain: varchar(254)

Password: char(32)


Financial Data : decimal(10,2)

Latitude: decimal(10,8)

Longitude: decimal(11,8)

Please write comment in case above information is incorrect. Please also share more fields in comment and I will update them here. This will help newbie developer.