All posts by Arvind Kumar

Foundation 6 Block Grid Media list is here

I was looking for this for a while and then finally found it here after having some trouble with search. Posting it here hoping for a someone to land up here before they could find the actual page in organic search. ;)

Needless to say foundation people need to do some ground work in order to make documentation more user friendly and easily available. I am really enjoying it with CakePHP 3. :)

<div class=”row small-up-2 medium-up-3 large-up-4″>

<div class="column column-block">
<img src="//" class="thumbnail" alt="">
<div class="column column-block">
<img src="//" class="thumbnail" alt="">
<div class="column column-block">
<img src="//" class="thumbnail" alt="">
<div class="column column-block">
<img src="//" class="thumbnail" alt="">
<div class="column column-block">
<img src="//" class="thumbnail" alt="">
<div class="column column-block">
<img src="//" class="thumbnail" alt="">

Using Cake Bake Console with both CakePHP 2.x and 3.x

I got started with my new CakePHP 3.x project today. As usual I wanted to create a few scaffold using cake bake command. As I already had a CakePHP 2.x setup in my machine. I still needed it and its cake bake commands to run to create any thing while working on the cakephp 2.x project. So is there a way I could use both cake bake consoles for CakePHP 2.x and 3.x respectively, at the same time?

Answer is YES. All we need to do is make some tweaks in order to run them both. Here are what I did.

  • I actually went back into the CakePHP 2.x installation and renamed the cake and cake.bat to cake2 and cake2.bat respectively. There are located in  C:\wamp\www\mycakephp2app\lib\Cake\Console.
  • This step actually was to set path environmental variable manually for CakePHP 3 as I already had set it up for CakePHP 2.x on my windows machine. I actually need them both. So I would add them like this C:\wamp\www\mycakephp2app\bin;C:\wamp\www\mycakephp2app\lib\Cake\Console;(for cakephp 3 it is set automatically.

    If you installed Cakephp 2 after CakePHP was installed you have to set the environmental variable path accordingly)

  • As you might have noticed that I renamed cake and cake.bat shell scripts to cake2 and cake2.bat  respectively I need to run cake2 bake in order to invoke CakePHP baker.


Optimize Images to save Space and Make Website Loading Faster!!

This is an email I wrote to one of my clients to ask him to optimize images before uploading. This client was hosting his website on my hostgator reseller account.

Hello Xyz,

Today I received an Excessive Resources Usage warning from HostGator hence I went into my hosting manager cPanel to investigate whether which site was using what size of space. Although may not be the most over-weighted website, during the process I found that was using Non-Optimized images which are unnecessarily addting to space usage. It would have been avoided without affecting the quality of images uploaded. Let me show an example.

You have uploaded xyz.png weighing 567KB which is 1200×628 pixels in size/dimension while you merely needed to use in this size on the website. Even if you needed to use this dimension if could be optimized to 42KB while keeping moderate or same quality. I would have resized it to 600×314 pixels if I was showing it in on a web page or even to 500x or less if I wanted to use it just as a featured image. You no way needed to upload it as an PNG image. Always keep image in JPG format unless you want a transparent image (PNG) or an animation (GIF)

Please check How to Optimize Images using Adobe Photoshop if you want to know how to optimized images with Adobe photoshop.

The following image Illustrates the difference of quality and weight of same sized images in PNG and JPEG formats respectively.
how-to-make-website-loading-speed-fasterIronically some themes such as popular Newspaper Theme create 25 different sized versions of one image. Because of this fact this single image of yours has resulted into 5.09MB of size. To prevent this I may have to make a change into the file which generates 25 versions of single image. Ref

I am attaching all the versions so you may compare them to see the difference.

How one can optimize images to help with hosting and website?

In addition to deeming it as an effective measure to avoid unnecessary increase of space on a web server, it is always a good  practise to optimize images to keep your web page light-weight in size so that it loads faster. Loading of images plays a vital role in the loading speed of a web site so turn/keep/optimize images to be low in size and your website will load many folds faster than ever!

To optimize images please re-upload the images some of which are very large in weight and dimension or size. Here’s how you could do it.

  1. Download the original image using your Media manager(WordPress) or FTP.
  2. Optimize it using software like Adobe Photoshop or online tools like
  3. Permanently Delete the old image from Media Manager or through FTP and reupload optimized image with same name.
  4. Make any necessary changes to the post(s) in which you are using this. Generally deleting an image from a monthly archive and re-uploading it won’t need any further changes to be done.

Let me know if you want me to do it for you at my end. Just send me the user/pass to admin end and/or FTP. I may have to charge a very reasonable (data entry) fee for the time spent.

I hope it makes sense.

A simple way to debug a php application in production mode

How to Get Start & End dates of a Week by given Date

A simple way to debug a php application in production mode

The following function gets start and end date of a week for a given date supplied in valid date string format. In the following function $week is the number of week in the year. For example the current week is week number 43. In the following function $year is year in YYYY format. For example, current year which is 2016. Here is the function to get start date and end date by a given date. For example

function _getWeekStartEndDatesByDate($current_date) {
$week = date('W', strtotime($current_date));
$year = date('Y', strtotime($current_date));
return _getWeekStartEndDatesByWeekAndYear($week, $year);

function _getWeekStartEndDatesByWeekAndYear($week, $year) {
$dto = new DateTime();
$result['start'] = $dto->setISODate($year, $week, 0)->format('Y-m-d');
$result['end'] = $dto->setISODate($year, $week, 6)->format('Y-m-d');
return $result;

I hope someone finds it helpful.

How to add or remove a git submodule?

While a git sub module could be added with a single line command such as:

git submodule add foldernameofrepository

it can be cumbersome to remove a submodule. There are various steps involved such as given in the next paragraph.

To remove a submodule you need to:

  1. Delete the relevant section from the .gitmodules file.
  2. Stage the .gitmodules changes git add .gitmodules
  3. Delete the relevant section from .git/config.
  4. Run git rm --cached path_to_submodule (no trailing slash).
  5. Run rm -rf .git/modules/path_to_submodule
  6. Commit git commit -m "Removed submodule <name>"
  7. Delete the now untracked submodule files
    rm -rf path_to_submodule

To update all submodule within a repository one would do:

git submodule foreach git pull origin master

Taken from Stackoverflow page, answered by John Douthat

How to set Cakephp paginator url for custom Route

I was making a url route like this:

Router::connect('/ca/assets', array('plugin' => 'file_manager', 'controller' => 'file_manager', 'action' => 'assets', 'ca'));

It worked alright with normal urls as- /ca/assets. However when i used paginator in view as

echo $this->Paginator->numbers();

it generates url as- /assets/ca/page:2

I tried different things and at the end, as a work around to this problem I figured out that the following trick works. So make some heck in the $this->Paginator->options() function as the following:

'url'=>array('controller' => 'ca', 'controller'=>'action', 'plugin'=>false)