Load masonry after all the images are loaded

The team decided to make the homepage of Biyixia.com like Pinterest or toptenreviews.com. Challenging, but thanks to the Masonry. Masonry was working absolutely fine on localhost but on the server it looks a bit messed up.

The reason was that on slow connections Masonry was being loaded before all images gets loaded in the browser so looked a bit messed up. So I loaded masonry in the following code:

And it worked like a charm. Here is the new biyixia.com homepage:

Screen Shot 2014-12-24 at 1.07.27 pm

Please feel free to share better solutions.

No package php-pecl-memcached available.

I was trying to install memcached on a centos 6.6 machine but when I run yum install php php-pecl-memcached, I was getting the error “No package php-pecl-memcached available.” I resolved it using the following method:

  • Open yum.conf that might be available at /etc/yum.conf
  • Find the line starting with exclude=
  • Remove “php” from that line. As it is preventing any package to install that was starting with “php”
  • Save the file yum.conf.

Now run the following command again:

It was ok.

 

Drupal: Managing translations in a multisite environment.

Currently, I have been working on a complex Drupal project with around 400 subdomains and half a million nodes. All the subdomains have same codebase. The product is in Chinese language and my real issue was to translate the strings from English to Chinese but the problem was that if a string is translated in one subdomain, it has to be translated to other 399 subdomains as well, so I decided to use the translation table of one (parent) domain on all other subdomains. So I just added the following lines to the settings.php of all 400 domains:

$databases['default']['default']['prefix'] = array(
'default' => 'mysite_',
'locales_target' => 'parent_db.mysite_',
'locales_source' => 'parent_db.mysite_',
);

“parent_db” is the database of the parent subdomain. Now if you change the translation of any subdomain, it will use the table of “parent_db” and will be changed in all 400 subdomains.

Working in China

My working span in China was short. I was hired by a startup named biyixia.com as lead software engineer. I was already working with them offshore but due to long documentation process, I had to wait too long to apply for the visa. Chinese work visa process needs at least two years of work experience and I was 4 years experienced by that time so it was not a big deal.

First couple of weeks are always the toughest ones in any new culture so mine were no different. It’s really hard to adapt the life style especially food. I was used to Pakistani style food but my team only consists of chinese guys so expecting them to prepare Pakistani food for me was a big no no. I was living in Changping district in Beijing and there is hardly any Pakistani restaurant but I discovered some Muslim(Xinqiang) restaurants in the neighborhood where I usually used to eat. Otherwise I mostly rely on vegetables.

The team was so cooperative, I am always very thankful to them. They never made me realize that I am away from my family. Every evening I used to go to the Beijing Electrical Engineering University nearby for a walk. It was awesome.

Beijing is mostly hated by expats due to its bad air. The air pollution is a big issue in almost every city in China. I am from Lahore and it’s pretty much polluted but believe me Beijing is tougher than that. I always user to check pm2.5 before I go out.

Hovering around in Beijing can be complex for new comers but it has excellent public transportation especially the subway. It works just like any other subway in the world. You can travel between any two terminals for just 2 RMB. On the weekends, we used to go to the Olympic park for jogging and after that we used to go to Chaoyang to enjoy Pakistani food at Khanbaba.

It is always recommended that you should live close to your workplace if you are an expat as Subway is so crowdy in the mornings.

Chinese society is a capitalist society and you will feel that. Most of the people just have one objective, earn as much money as they can. Beijing has a lot of people coming from different regions of China so living cost is very high i.e. 3000RMB per month for a one room apartment in Changping. So most of the young guys share apartment with others to reduce the living cost.

Overall I feel very lucky that I got the chance to live in Beijing and worked with wonderful people. China, I miss you.