Posterous theme by Cory Watilo

Keith Yau

Keith Yau

Keith Yau Follow yubis_keithyau on Twitter

I am currently working in Capgemini as a technical lead on a Forutune 500 Drupal project.

Was worked in ecVision, leading supply chain management software company, focus on providing open source IT Solutions, Drupal professional. Specialist in Drupal scaling & system integration. Degree in CUHK information Engineering,1 year with HSBC iSeries server performance team. Keith is interested in technology and self-motative to learn new IT skills. Especially on Linux, networking & virtualization. With experience in IT technical areas, he was invited by HK productive Council, Hong Kong college of Technology and IBDS to organize courses about online marketing, networking & Security, open source strategy for SME and eCommerce.

Email pipe

Hi all,

If you have a email server on Linux server, you can pipe email to a backend script easily.
This allows you to parse email or control server in email.

Take an example for PHP

echo 'test: "php -q |/your/script.php"' >> /etc/aliases

This command will need php cli support, in Ubuntu, enter

sudo apt-get install php5-cli

And then create a file called script.php start with #!

  1. #!/usr/bin/php
  2. <?php
  3. // read in email from stdin
  4. $fd = fopen("php://stdin", "r");
  5. $email = "";
  6. while (!feof($fd)) {
  7. $email .= fread($fd, 1024);
  8. }
  9. fclose($fd);

The email content will be in $email, you can do whatever you like

If you are thinking of email command, add a line like

  1. exec ($email);

If you are thinking of calling Drush without managing drupal init externally, you can 

  1. exec ("drush your-custom-command " .$email);

Of coz, it needs certain privilege.

Enjoy ~

Keith

Drupal Adding apache solr index for field-collection

If images / content are bounded by field collection module, you can try approach below to index to solr

enjoy

 

//Index product images

$field_collection_items = field_get_items('node', $node, 'field_image_set');

$field_collection_item_ids = array();

$i = 0;

foreach ($field_collection_items as $field_collection_item){

$field_collection_item_ids[$i] = $field_collection_item['value'];

$i++;

}

$field_collection_item_fields = entity_load('field_collection_item', $field_collection_item_ids);

$image_fields = array();

$i = 0;

foreach ($field_collection_item_fields as $field_collection_item_field){

$image_fields[$i] = field_get_items('field_collection_item', $field_collection_item_field, 'field_image');

$i++;

}

 

$i = 0;

foreach ($image_fields as $image_field){

foreach ($image_field as $image)

$path = file_create_url($image['uri']);

$document->setMultiValue('sm_field_image_'.$i++, $path); //Set multiple field_image values

}

 

Adding index to apache solr by Drupal apache solr hook

1. Add index by setMultiValue

function scp_solr_search_apachesolr_update_index(&$document, $node){
$document->setMultiValue('sm_field_xxxx',
$node->field_xxxx['und'][0]['value']);

2. Add modify query

function scp_solr_search_apachesolr_modify_query(&$query, $caller){
$query->params['fl'] .= ',sm_field_xxxx';

3. update solr and done ~!


* scp_solr_search is my module name Enjoy

Online marketing in China

Recently, I met my friend's cousin. She comes from ShangHai - A first class city in China. I went to ShangHai two times and really feels opportunity out there. I believe many people are headache about getting into China market. It is harsh to setup retail business or making any sales. Due to the great firewall, social network services & many online marketing stuffs are blocked.

BTW, with my friend's cousin - Nico, she is an online marketer in China who responses to brand New balance / North Face, I start to realize how to make things works in China. Firstly, we should make a mapping on SNS

Foreign SNS China SNS Description
Facebook renren.com More on college students
Twitter t.sins.com.cn (微博) More on superstars, feel link up with other websites
MySpace www.kaixin001.com (開心網) For all people
Linkedin www.wealink.com (若領) More on mainland jobs
Posterous *Still have room for competiton
YouTube tudou.com (土豆) Many anime, do not have copyright at all

All knows technology are the same

You will find China SNS and foreign SNS nearly take no difference on technology behind. But, content has big different.
Since nearly no foreign people in China SNS, the culture is China only while foreign SNS is a global mixture. Unlike foreign SNS, China people take very serious on making online friends. They  afraid of be traded, advertisement, fake good .... etc. Don't ever think to make friends like twitter - Follow some people, like others' post, find common interest / expertise .... Spirit communication not that useful at all. 

If you are making online business

Everything in kaixin need money, commonly like facebook group/page, it need money to create. No free advertising even you have many collections. The budget in China online marketing should be higher than using twitter / facebook.

The only way is to ask your China friend to share his/her network 

I have to say, if you can add friends in China SNS you already know, it will be much better. In China, online or offline, like you find a job, you cannot find a job about your good experience but making good friends matter. This culture goes on to Internet. Just like twitter followers -- Provided that your followers are famous, you must have great power of influence.

Not many management tools available

I don't know the reason, TweetDesk not supporting kaixin / t.sina or you are going to make one !

It is really slow ...

I'm talking about the network, especially overseas... If you are remote control like in US / UK, you better have an proxy ! You may left your message and I get one for you.

How to make things work?

Other than hiring China writers, SNS operators ... you still need to make good decisions in a very very rapid changing market... Further, A China law said foreign business should be cooperate with local business in order to setup in China. Frankly speaking, it cannot be done on your own, since you don't have time to understand, to learn and to pay for the totally different China culture. It is hard for me even I am a Hong Kong 80afters. Not kidding, left your message and I introduce Nico to you, you will safe your life.

Update

When I get more understanding, I will come back and share about how to deal with China people over Internet ~

Thanks