'how to' Tag

  • Zf2 Doctrine 2 Log Every Entity Change

    September 18, 2015

    In this article I will show a simple way to log every change to doctrine 2 entity. This one will not be copy / paste. Just check out the code and help yourself. 1. Create event service /** * @developer Ivan Gospodinow */ namespace Application\Service; use Application\Entity\DbLogEntity; use Application\Entity\AbstractEntity; use Doctrine\Common\Persistence\Event\LifecycleEventArgs; use \DateTime; class DoctrineLogChangesService […]

  • How to create google login on my site with openid in 5 min

    August 21, 2013

    As always we go straight to coding. Download how-to-create-google-login-on-my-site-with-openid-in-5-min.zip

  • How to read csv file into array ?

    June 16, 2013

    function csvToArray($file){ $rows = array(); $headers = array(); if(file_exists($file) && is_readable($file)){ $handle = fopen($file, 'r'); while (!feof($handle) ) { $row = fgetcsv($handle, 10240); if(empty($headers)) $headers = $row; else if(is_array($row)) $rows[] = array_combine($headers, $row); } fclose($handle); } else { throw new Exception($file.' doesn`t exist or is not readable.'); } return $rows; } Simple as that. Suggestions […]

  • php how to calculate system processor/s load in percent

    February 7, 2013

    This simple function will allow us to control php performance at level we need. /** * Calculates the processor load in % * @see sys_getloadavg * @author Ivan Gospodinow * @site ivangospodinow.com * @date 07.02.2013 * @param int $coreCount * @param int $interval * @return float */ function systemLoadInPercent($coreCount = 2,$interval = 1){ $rs = […]

  • Change layout template based on controller in Zend Framework 2

    January 18, 2013

    In Zend Framework 2 , layout can be easily changed from module based on controller(name).   Step 1. Add in module.config.php file 'controller_layouts' => array( 'MyControllerName' => 'layout/MyControllerName', ), and 'view_manager' => array( //more options 'template_map' => array( 'layout/MyControllerName'=> PATH_TO_TEMPLATE ), ), Step 2. Add in module.php $e->getApplication()->getEventManager()->getSharedManager() ->attach('Zend\Mvc\Controller\AbstractActionController', 'dispatch', function($e) { $controller = $e->getTarget(); […]

  • How to destroy all dojo widget nodes

    November 26, 2012

    Simple and working solution. ThisĀ  code snippet will help you to destroy all dojo widgets. window.widgetsDestroy = function(){ require(['dijit/registry','dojo/query'],function(registry,query){ query('*[id]').forEach(function(node){ var widget = registry.byId(node.id); if(undefined !== widget){ widget.destroy(); } }); }); } Use it with : window.widgetsDestroy(); Suggestions or problems ? Write a comment.

  • Running multiple wordpress blog copies from different locations.

    September 30, 2012

    This is something that was bugging me for a while. How can multiple developers work on same wordpress without messing up the code ? The answer came from two wordpress variables : WP_SITEURL and WP_HOME. If the two variables are set , wordpress blog do not get them from the database. Step 1. Adding this […]

 
Powered by Wordpress and MySQL. Theme by Shlomi Noach, openark.org