Getting A+ SSL on

Just follow this tutorial

If having problems creating ssl, refer to

Drop all mysql tables without permission to delete and create new database

In mysql, the simplest way to flush all tables is to delete the db and create a new one. However, one might not have permission to do that. So we need a script to list all tables and delete it.



mysqldump -u$USER -p$PASS -h$HOST --no-data --add-drop-table $DB | grep ^DROP | mysql -v -u$USER -p$PASS -h$HOST $DB

How to check if ssl is installed correctly

To check ssl is installed correctly, run in command line

openssl s_client -debug -connect yourwebsite.comhistory:443


If you are getting any errors, ssl installation is wrong.

Normally you would get the crt from the intermediate CA. convert it to pem

openssl x509 -inform DER -outform PEM -in server.crt -out server.crt.pem

remember to nginx -t before restarting.

Debugging GTM in IOS devices

Let’s face it, debugging gtm in devices other than desktop is hard. Debugging in IOS is harder because gtm debugger toolbar doesn’t work on it.

The tip to help debugging IOS is to be able to debug it from desktop

Let us use the ios webkit proxy debugger

Follow the installation instructions. However this debugger doesn’t let you inject js when debugging.

We will need another tool like – just follow the installation instructions. then go to

http://localhost:8080/Main.html?ws=localhost:9222/devtools/page/1 and you can start debugging as if you have the dev tools.

Sample Test for Backend Developer

This is a question that I came up with based on real hands-on project and experience. The question is not really testing on someone’s ability to know the code syntax. but rather the approach to solving a common day-to-day technical problem. The questions do require backend knowledge and the open ended questions will allow candidates to show off their object oriented skills if they want.


1. Test candidate’s ability to understand complex and vague briefs which happens a lot.
2. Test candidate’s analytical and problem solving skills
3. Test candidate’s attention to details.
4. Test candidate’s understanding of web standards.
5. Test candidate’s proactiveness to suggest ideas and think out of the box.

The Brief:

A client approached us to create a social media campaign for the launch of their new energy drink. Let’s call the drink “powerhouse”. The client also advised they are on a limited budget.

The creatives met up with the client and came up with an idea.

The idea is to build a really simple competition webpage within the client’s website that encourages people to spread the news about the new product. Users arrive at the page and sign up a form. After a successful sign up, they get one entry for the competition. At that point, they also have an option to share the sign up link. Every successful sign up referred via the link will give extra competition entries to the original link poster. There is no limit to the number of entries that a person can enter. So the idea is: The more entries you have, the higher your chance to win the prize.

The prize is 100 bottles of powerhouse drink.

The top 10 person with the most entries will win the prize.


1. The new webpage is to be launched 3 months from today.
2. The duration of the competition will be 1 month from the day it is launched. After that, the webpage will be removed.
3. The webpage will consists of text, graphical elements and a sign up form.
4. The sign up form will consists of the following compulsory fields: First name, Last name, Mobile Number and Email Address.
5. When the form is submitted, the user will receive an EDM (Electronic Direct Mail) with an option to post a special link to the competition page from his/her facebook or twitter account.
6. When people arrive to the competition page via the special link and signs up the form. The original poster will get one more extra entry for the competition.
7. After the competition has expired, provide a list of winners to the client.

An Example:

1. Bob goes to the competition page and signs up the form. Bob gets 1 entry to the competition.
2. Bob receives an EDM encouraging him to share to his friends. Bob posts the news in facebook via a link from the edm.
3. Jane sees the news in facebook and clicks on the competition link.
4. Jane arrives at the competition page and signs up the form.
5. Now, Bob gets 2 entries and Jane gets 1 entry to the competition.


As a backend developer, write down your thoughts and/or provide pseudocode/diagrams if necessary.

1. What are your considerations to implement a secure form.
2. How would you trigger an EDM upon a successful form submit?
3. How would you track referrer form submissions as described in the requirements?
4. How would you provide a list of winners to the client at the end of the competition?
5. Describe how you would implement the form and all the backend logic associated with it. Feel free to suggest any tools or services that would help you to achieve that.
6. Do you foresee any problems with this competition prior launch? Do you think if there is anything in the requirements that deserves clarification?
7. Can you provide a rough estimate on how much time you will need to implement a workable backend solution based on the requirements?

phpstorm useful plugins and shortcuts

Useful Shortcuts

1. to open up preferences, “command + ,”

2. show file in project tree or anywhere, “fn + shift + f1”

3. code completion, “ctrl + space”

4. search everything, “shift + shift”

5. search class, “command + o”

6. navigate to line, “command + l”

7. generate getters and setters, “command + n”

Useful plugins

1. symfony plugin, php annotation, markdown viewer, liveedit, ideavim

Resize image upload into proportional dimensions using GD library

sometimes you want to manipulate images uploaded. A good way to do it is to resize the image to the max width or height, fill the background with transparency and yet keeping the same original width to height ratio. lets say we want a 300 x 300 pixel image.

$canvas = imagecreatetruecolor(300, 300);
            imagesavealpha($canvas, true);
            $alpha_channel = imagecolorallocatealpha($canvas, 0, 0, 0, 127);
            imagecolortransparent($canvas, $alpha_channel);
            imagefill($canvas, 0, 0, $alpha_channel);
            // process image width and height
            $old_x = imageSX($image);
            $old_y = imageSY($image);
            $thumb_x = 0;
            $thumb_y = 0;
            // say max width and height is 300px.
            if($old_x > $old_y)
                $thumb_w =   300;
                $thumb_h =   $old_y*($thumb_w/$old_x);
                $thumb_y = abs(300 - $thumb_h) / 2;
            if($old_x < $old_y)
                $thumb_h =   300;
                $thumb_w =   $old_x*($thumb_h/$old_y);
                $thumb_x = abs(300 - $thumb_w) / 2;
            if($old_x == $old_y)
                $thumb_w    =   300;
                $thumb_h    =   300;
            imagecopyresampled($canvas, $image, $thumb_x, $thumb_y, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y);

            // Move the file to the directory where logos are stored
            $logosDir = $this->container->getParameter('kernel.root_dir').'/../web/uploads/logos/';
            // write to file
            $fileName = md5(uniqid()).'.'.$file->guessExtension();
            imagepng($canvas, $logosDir.$fileName);

symfony adding file image constraints to form

let’s say you want to constraint what people are uploading and you don’t want to use assert statements in the entity. you can do it in the formbuilder

use Symfony\Component\Validator\Constraints\File;
$form = $this->createFormBuilder($entity)
            ->add('logo', FileType::class,
                    'label' => false,
                    'attr' => array(
                        'accept' => "image/jpeg, image/png"
                    'constraints' => [
                        new File([
                            'maxSize' => '2M',
                            'mimeTypes' => [
                            'mimeTypesMessage' => 'Please upload a JPG or PNG',

Drupal 8 quickstart using composer

There are benefits of using installing drupal via composer.

composer create-project drupal-composer/drupal-project:8.x-dev myproj
cd myproj
# you can now add the required plugins eg
composer require drupal drupal/devel:8.*

Forget about drush, let us use the drupal console to install the site. This is the symfony way.

# let us configure the drupal command line
ln -s /path_to_myproj/vendor/drupal/console/bin/drupal /usr/local/bin/drupal
cd web
drupal site:install