橫幅廣告

2017年9月28日 星期四

為文字上Highlight,但是排除HTML Tag內容,並且保持文字大小寫


(?!<[^>]*?)"+Pattern.quote(search)+"(?![^<]*?>)


text = text.replaceAll("(?!<[^>]*?)("+Pattern.quote(search)+")(?![^<]*?>)", "<span style='display:inline; background-color: yellow;'>$1</span>");

2017年3月7日 星期二

[心得] 台灣大哥大 網路漫遊預付卡 日本北海道4G無線上網吃到飽 (有網路測試圖)

我與老婆基本上都算得上重度上網族群,為了今年二月能夠跟老婆有一個高品質的北海道蜜月之旅,上網研究了很久的網路漫遊,大致上比較了幾家的優缺點,最後我們選擇了台灣大哥大網路漫遊預付卡,最後也證明了我們的選擇沒錯! 希望PO出來能夠對大家有一點幫助。

2015年4月8日 星期三

Let your PHP calls JAR of JAVA (Windows)

Set the identity of executor for Apache

Before run your php program.

You have to set the identity of executor for Apache.


  1. Go to "Service"

  2. Change the executor (use your log-in account)


Write a toy program

// Set Enviromental Variable
$JAVA_HOME = "C:\\\"Program Files\"\\Java\\\"jre1.8.0_20";
$PATH = "C:\\\"Program Files\"\\Java\\\"jre1.8.0_20\"\\bin";
putenv("JAVA_HOME=$JAVA_HOME");
putenv("PATH=$PATH");

//run your jar program
echo shell_exec("java.exe -version 2>x.txt");


Finally, execute PHP program

2014年4月7日 星期一

MySQL利用console介面匯出/匯入資料

匯出:

可以利用mysqldump來達到匯出
mysqldump -u root -p 資料庫名稱 資料表名稱 < 要存成的檔案名稱 (xx.sql)
如果是遠端的資料庫,可以加"-h IP位置"

如果遇到command denied.....when using LOCK TABLES,代表可能是因為權限不足(無法鎖定table)
可以在最後面再加上一個參數--skip-lock-tables或--skip-add-locks 
另外,可以使用 --default-character-set=UTF8 來指定編碼



匯入:
登入MySQL之後,選好資料庫(use 資料庫名稱;)
輸入source c:\xxx\ooo\xx.sql; 即可開始匯入

2013年11月19日 星期二

Don't assign an array type value to URLOPT_POSTFIELDS in curl

If you are not planing to upload a file, don't to assign an array type value to URLOPT_POSTFIELDS in curl.

Today, I got a problem about using curl to do a login action.
Something happened. The system didn't work because the first character in the password was a @ character.

See the reference: http://php.net/manual/en/function.curl-setopt.php , and please find the statement of CURLOPT_POSTFIELDS section.

You will find a statement as following:
If value is an array, the Content-Type header will be set to multipart/form-data. As of PHP 5.2.0, value must be an array if files are passed to this option with the @ prefix. As of PHP 5.5.0, the @ prefix is deprecated and files can be sent using CURLFile.

So, you/me should use String type rather than Array type assigning values to URLOPT_POSTFIELDS  if you aren't planing to upload a file.

The solution can be found in this web page: http://www.brandonchecketts.com/archives/array-versus-string-in-curlopt_postfields

Hope it also help you.

2013年10月6日 星期日

Buy a prepaid phone from SoftBank online shop


Finally, I got my phone and completed the setting.

Actually, I do not even speak Japanese.

In most situations, I used the google translator to translate SoftBank's web...


There are some conditions here for the people who would like to buy a prepaid phone.

If you would like to a prepaid phone in Japan, you have to satisfy some conditions as follows:

  1. You have your own resident card.
  2. The resident card have filled out your residence address.
  3. Find a SoftBank shop that sells prepaid phone and prepaid sim card OR buy them form SoftBank online shop. (
    1. If you want to only buy a prepaid sim card, you have already had a SoftBank Phone, which had not contracted currently.
    2. Most of the SoftBank shops do not sell the prepaid phone.
    3. Most of the SoftBank shops do not provide English service.
  4. If you are like me bought the phone from online shop, you have to carefully fill out your order information.
    1. Your residence address in the order have to identical to the address in your resident card. Any different is not allowed. If any different here, SoftBank will ask you to contact him by using a call for checking your information (some people told me they provided English in their toll-free number).
    2. You have to use a credit card for payment.
    3. You have also to upload or mail a copy of your resident card (two sides) and your passport.
  5. After you gotten your prepaid phone, you have to activate your prepaid sim card. Otherwise, the prepaid sim card will be out of service. 
    1. There is the address for activating prepaid sim card: http://online-shop.mb.softbank.jp/ols/html/manual/explanation/setting_pri.html.
    2. In the process, you have to fill out the application number, your email, and a password (4 numbers set by you)
  6. Finally, you can login SoftBank web site to register your phone.
  7. You can use your credit card to recharge: http://mb.softbank.jp/en/prepaid_service/recharge/credit_card.html 

    1. You can also check the expired time and balance in the web side. It is very important to me because I do not understand what they say in the 1400 call.



Finally, I apologize for my bad English.


2012年11月15日 星期四

Joomla redirect with message

If you want to use redirect function with a message to display message on screen, we can use as following codes:

JFactory::getApplication()->redirect(JRoute::_('PATH'), 'your message');