Challenge: 30 Euler problems in 100 days

This is a self challenge to solve 30 problems in next 100 days.

Here is the Code repo:

1. May 23rd: Summation of primes

2. May 24th: Largest Product in a Grid

3. May 27th: Highly divisible number

4. May 29th: Large Sum

5. June 6th: Power Digit Sum

6. June 7th: Lattice Paths

7. June 18th: Maximum path sum

8. June 19th: Factorial digit sum

9. June 19th: Amicable numbers

10. June 21st: Names scores

11. July 2nd: Non-abundant sums

12. July 3rd: N-digit Fibonacci number

13. July 13: Reciprocal cycles


















Halal Expat in Bangkok, Thailand (where to get what?)

I got a job at Agoda a couple of months ago and the first two months were really exciting. I transferred to Bangkok with my wife and son. I literally brought nothing from my home and I regretted it as few things are difficult to find here. Agoda provides a very decent relocation package with one month residence plus airport transfers and one way flight but still it sometimes gets a bit difficult to find muslim (halal) food and grocery (especially in Bangkok central areas). OK, straight to the point, where to get what?

Daily Food Grocery

Go to (I have no connections with this business). This is a small business operated by an Indian guy and he is very efficient, the only challenge here is that you have to order a min of 700 Baht. The guy usually delivers Grocery within 1 to 2 days.


Well, we learned the hard-way. you can buy Halal meat(Chicken, Beef, Mutton) from BigC, Tesco Lotus or Gourmet (Phrompong or Siam) but that is expensive (very expensive). For example Mutton is around 960 Baht/KG. So what we did? We found a Muslim restaurant that serves Halal BBQ. We went there, asked the guys and they said there are a few meat shops nearby Bangkok Mosque(see below the map).

How to go there? Take BTS to Siam Paragon and then use Uber (at least this is what I do).

This is a small market with many Indian/Pakistani grocery and meat shops. All shops have halal meat. Following are the rates here in today’s date:

  • Mutton: 340Baht/KG
  • Paya: 160/8pcs
  • Chicken: 100 Baht/KG
  • Wheat Flour: 70/KG

Pottery(Tawa, Chimta etc.)

So to cook chappatis/rotis, you need special pottery. That’s a bit expensive here, or may be I didn’t research much. Just go to Siam Paragon (Electronics and Kitchen section). You can find most of the pottery you need there.

Important: Please note that these might not be the optimal rates I found in Bangkok for grocery and other items, if you know a better options, please feel free to comment.

To Be Continued!

Centos, Varnish, NGINX, Drupal

As an experiment this week I upaecided to change the web server of a site to NGINX, the existing web server was Apache. I would like to share the steps required to setup NGINX with Varnish to make your Drupal site run at a blazing speed.
Centos 6
Quadcore processor.
Install NGINX
yum install nginx
Configure NGINX
Open /etc/nginx/nginx.conf
Add the following lines at the bottom of “http” block:

It will look something like:

Add host
Create two directories sites-available and sites-enabled

Create a file named “” under sites-available and paste the following contents:

Please note that the port number is “81” as varnish will run at port 80 and will behave like content server.

Create a symlink and remove the default configuration:

Please note that default.conf’s location can be different based on different platforms.

Change owner of the web directory

Install Varnish

Configure Varnish

Open /etc/sysconfig/varnish, replace the following values:

Keep all other values as it is.

Open /etc/varnish/default.vcl and update “backend default” block to the following:

Install PHP FPM

I am also using php fpm for faster php processing. Here is the command for that, simple simple

Restart servers:

Configure Varnish with Drupal

Install Drupal’s varnish module
Add the following lines to your settings.php:

Go to varnish configuration: admin /config /development /varnish

Set Varnish control terminal:
Set Varnish Control key from/etc/varnish/secret
Please make sure the “Varnish running” is ticked.
Awesome, you are done. Enjoy the faster response times of your site.
Please comment if you have any feedback

Drupal – Run AJAX command after success of another JS command.

With ajax_command_invoke, I was getting error: Uncaught TypeError: Cannot read property ‘apply’ of undefined — ajax.js


After banging my head for like 4 hours with ajax_command_invoke, I am finally able to do it. Here is an example code.

Here is the full code.

Customizing a vagrant box

Recently, I got to know an excellent ready virtual machines solution known as Vagrant. The solution I was looking for was that I can create a custom virtual machine and install my development environment on that e.g. LAMP or MEAN so that new developers can easily download that machine and can start work on that straight away.

If we follow default vagrant instructions, we will end up having and Ubuntu virtual machine. My target was to have a Centos 7 machine with Apache, PHP and MySQL.

So I installed a basic Centos 7 virtual machine, the instructions are available on Instead of “hashicorp/precise32″, I choose serveit/centos-7. After adding the box, I installed the required tools, now my machine is ready so it’s time to export my VM as a vagrant box, it is so simple:

We can package a box using command:

That’s it, the above command will will create a VM for virtual box. Now you can delete the existing box using:

Delete the Vagrantfile and can use this new box with the following command:

You can add your distribution to vagrant repo if you want.