Relocating to America from Pakistan on H1B

I got a job offer from Yelp around April 2017. That means I had to relocate to San Francisco Bay Area. Today marks my 7th month since my first in the US and so far it’s been a roller coaster ride. It was my second relocation after we relocated to Thailand from our homeland Pakistan. The reason to write this blog post is to help my country mates who will arrive in the US on H1B visa.

I relocated with my wife and son. With H1B, you can usually arrive 10 days before your petition start date so I arrived in states on September 22nd, 2017. Thanks to Yelp for giving me a healthy relocation bonus that helped be getting settled but there were still a few challenges those I would love to list:

Temporary housing challenge

The difference between my first relocation and this one was that we were not provided with temporary housing instead we got a relocation bonus so we either had to stay in a hotel or Airbnb for the first few weeks. Since I am lucky to have a wife who loves to cook and feed us home cooked food everyday, I preferred airbnb with a kitchen and never regretted that decision. We took an airbnb for almost 10 days in San Francisco considering it will give us enough time to get permanent housing but we were wrong, terribly wrong :). That led us to get another airbnb that we took for 15 days in Oakland, CA. To tell you the truth, Oakland time was a bit difficult because it was in downtown that gets a bit sketchy and noisy in the night. We found housing by then but the move in date was November 15th so we had to find another apartment for a month. Thanks to airbnb that helped us again to get a 1Bedroom apartment in San Francisco near Dolores park. On November 15th, after almost 7 weeks of my first entry to the US, I got a permanent house in East Bay and loving it so far. One important thing to note is that you can’t get a house without Social Security number so apply for one as soon as you can.

Food Challenge

This challenge didn’t hit us that badly. Apparently, most of the Americans love IndoPak food so it’s easy to find a Halal food restaurant in almost every block of San Francisco(although the food quality varies a lot). Secondly, there were various grocery shops where you can easily find Halal Meat, Pakistani masalas and almost every type of dessert. It’s even easier in Eastbay where there is an Indian or Pakistani grocery store in almost every market.

Healthcare Challenge

American health care system took us sometime to completely understand. The countries where we live, having a healthcare plan before going to the hospital is not required. But here in the US, you have to have a healthcare plan if you don’t want to cost yourself thousands of dollars in case of emergency. Fortunately Yelp provides us with pretty good health care options that made the things a lot easier. Must check these things with your employer before signing a contract. Usually there are two types of plan PPO (where you have to pay some amount out of your own pocket and you can consult any doctor within the insurance company’s network) and HMO(where you have to choose a primary care physician(PCP) and you cannot consult any other physician without the recommendation from your PCP). PPO usually costs you more than HMO so I would recommend study about these two options before arriving to the US.

Tax challenge

I lived in Pakistan most of my life where tax percentage was between 7 to 10 percent. In Thailand, it was around 15% but here in the US, it’s much more than that(make sure to check your bracket before accepting an offer). Secondly, please note that if you are married, your tax rate will almost be 10% lower than single dudes. But… you can’t change your status to married until you become a resident alien(that happens after 183 days of your first date of entry in states). So first 6 months will be tough in terms of taxation but after you file your first returns(between January to April every year) and get a refund, things will get easier.

Things to do after arriving to the US

There are a few things you need to do before you can enter in the system.
Get a Social Security number as soon as you can. Please note that there is no limit on number of days on this. I applied after 2 days of arrival and I got it within a week. You need Social Security number if you want to get a house, healthcare plan, life insurance, a bank account, internet connection even a mobile phone plan.
Get a bank account as soon as you can. I have a Wells Fargo one and it’s good so far. You usually need a proof of employment, an identity or any other debit/credit card for any other bank in the world.
Start looking for housing as soon as you land here. Bay area is a bit expensive. In Eastbay you can expect $2000 to $2800 rent for 1Bedroom apartment and $2600 to $3400

All in all great experience so far. Highly recommended area for relocating.

Special thanks to my friend and mentor Zaki Shaheen for all the support he gave us.

Challenge: 20 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

14. August 12: Multiples of 3 and 5

15. August 12: Even Fibonacci numbers

16. August 12: Largest prime factor

17. August 12: Largest palindrome product

18. August 12: Smallest multiple

19. August 12: Sum square difference

20. August 12: 10001st prime

21. August 12: Largest product in a series

22. August 12: Special Pythagorean triplet

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 decided 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.