Posts

PHP Profiling Using Xdebug and Kcachegrind

Xdebug's Profiler is a powerful tool that gives you the ability to analyze your PHP code and determine bottlenecks or generally see which parts of your code are slow and could use a speed boost. The profiler in Xdebug 2 outputs profiling information in the form of a cachegrind compatible file. This allows you to use the KCacheGrind tool (Linux,) to analyse your profiling data.  Xdebug profiler is incorporated in the Xdebug tool. Therefore you first need to download, install, and enable Xdebug itself and after that enable the profiling functionality within it. Install x-debug through apache sudo apt-get install php5-xdebug Enabling Xdebug integration with the PHP engine Once xdebug is installed, you can enable the xdebug(profiler) to work with PHP by adding following lines at the end of  php.ini  file. [xdebug]   zend_extension= "/usr/lib/php5/20121212/xdebug.so"    ;path to xdebug.so xdebug.profiler_append = 0 xdebu

missing mcrypt – Fatal Error: Undefined function mcrypt_encrypt()! in Ubuntu 13.10/14.04

I came across this problem when I upgraded my Ubuntu to 14.04. I have used php-mycrypt in one of my project which was working fine until my ubuntu got upgraded and now when I try to access my project I get this Fatal Error Fatal Error: Undefined function mcrypt_encrypt() The solution looks simple but it took me ages to figure out and after a lot of googling around (most of the solution provided didn't help me at all ) so I thought I will share this hoping that you guys end up here quickly and don't have to spend much of your time (like I did ) :):) and hoping this will help you guys. So, without wasting much of your time. Let me begin, First thing to do is see if you have installed php5-mcrypt (like everyone does), you can do that by: sudo apt-get install php5-mcrypt It should install mycrypt and if already installed, you will get the following message: Reading package lists... Done Building dependency tree Reading state information... Done php5-mcrypt is alre

jQuery Best Pratices

 jQuery Files a) Try to use Jquery CDN where possible.                  <script type= "text/javascript"   src= "//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js" ></script> <script>window.jQuery || document.write( '<script src="js/jquery-2.1.1.min.js" type="text/javascript"><\/script>' )</script>     Implement a fallback to locally hosted jQuery file of same version in-case CDN is not working.(as above)  b) DO NOT use jQuery version 2.x if you support Internet Explorer 6/7/8. c) If you are using other libraries like Prototype, MooTools, Zepto etc. that uses `$` sign as well, try not to use `$` for calling jQuery functions and instead use `jQuery` simply or use `$.noConflict()`.    jQuery Variable a) Better to start with  `$`  while  naming jQuery variable so it will be easy to understand and later on manipulate. var $someDiv = $( "#someDiv" );  //