2014年9月26日 星期五

[Windows] Redirect domain to different IP

C:\Windows\System32\drivers\etc\hosts

Add the following lines:
XX.XX.XXX.XXX       www.thedomainname.com
XX.XX.XXX.XXX       thedomainname.com

2014年9月23日 星期二

2014年8月9日 星期六

[Save Brain Cells] [JS] Check All and Uncheck All by 5 Lines of JS Codes

http://injerry.pixnet.net/blog/post/6477885-%E4%BA%94%E8%A1%8C%E6%90%9E%E5%AE%9Acheckbox%E5%85%A8%E9%81%B8%E6%88%96%E5%85%A8%E4%B8%8D%E9%81%B8

Having examples right away:
http://www.wowbox.com.tw/blog/article.asp?id=2923

<script type="text/javascript">
function check_all(obj,cName)
{
    var checkboxs = document.getElementsByName(cName);
    for(var i=0;i<checkboxs.length;i++){checkboxs[i].checked = obj.checked;}
}
</script> 

 
<body> 
<p><input type="checkbox" name="all" onclick="check_all(this,'c')" />全選/全不選</p> 
<p><input type="checkbox" name="c" value="" /></p> 
<p><input type="checkbox" name="c" value="" /></p> 
<p><input type="checkbox" name="c" value="" /></p> 
<p><input type="checkbox" name="c" value="" /></p> 
</body> 

2014年8月6日 星期三

[Next Level Challenge!] How to Present Your System to New Users

[ This is written based on my personal experience. And this is my first attempt! ]

Task Oriented Approach
 - give them some instructions, then have a little assignment / task for them to accomplish.
 - try to make the first task as simple as possible, so that they will not be afraid of it at the first sight.

Do not provide them too much information at the first moment. That can scare the new users. Teach only some key concepts relating to the task.

Have some attractive diagrams to present the fundamental concepts. This can make the explanation much easier.







How to start writing a user manual for completely new users

Preface

1. what the system is for
2. what is the difference between the new system and the other existing systems
3. How the system model is constructed [ Some simple diagrams ]
4. How does the above relating to other systems [ Diagram of the relationship between system model drawn above and the models of the existing systems ]
5.

2014年8月2日 星期六

[Linux Datetime] Synchronize Server Datetime

NTP Server - We need a Network Time Protocol Server to do the time synchronization task.
Example Domain: time.stdtime.gov.tw, stdtime.gov.hk
http://www.vixual.net/blog/archives/5
http://www.hko.gov.hk/nts/ntimec.htm

Run these commands:
ntpdate -s stdtime.gov.hk
hwclock --systohc

ntpdate : set server clock time
hwclock - set hardware clock time

2014年7月17日 星期四

[Database Design Idea] Designs user table id by unique code rather than by auto_incrementing

Someone designs the appuser table as follows:

appuser_id
candy
abigail
florance
simon
peter
...

rather than
appuser_id
1
2
3
4
5
...

to save the effort on table joining and retrieving. For reference.

2014年6月30日 星期一

[NAS] Some Reminders on Adding an NAS to Network


  • RAID 5 - needs at least 3 HDs
  • Either one among 3 is down, data can be recovered; for two, nothing can be done.
  • Using Reserved IP from DHCP is better, since when network is down, plugging NAS to another network with simple setting (DHCP giving random IP) and NAS can be used immediately
  • Setting Reserved IP requires the device's MAC address. Need to check the given IP and its MAC address from router
  • In windows, NAS drive can be searched by typing \\TheNASName\TheFolderCreated.
  • Only Disk Quota can be set. Cannot set a quota for a created folder. Thus the users can share the resources among a disk, but not a folder. If allocation for different users is needed, created different disks.

2014年6月11日 星期三

How to schedule the execution of a PHP script on the server side?

On Linux/Unix (including Mac OSX), create a cron job.

# minute (0 - 59) 
# hour (0 - 23)
# day of month (1 - 31)
# month (1 - 12) OR jan,feb,mar,apr ... 
# day of week (0 - 6) (Sunday=0 or 7)  OR sun,mon,tue,wed,thu,fri,sat 
# *  *  *  *  *  command to be executed
30 3  *  *  *  php /home/scripts/do_something.php
30 3  *  *  *  wget your.domain.com/do_something.php

 http://stackoverflow.com/questions/1194857/how-to-schedule-the-execution-of-a-php-script-on-the-server-side

2014年5月31日 星期六

[CakePHP] saveMany() and saveAssociated()

http://book.cakephp.org/2.0/en/models/saving-your-data.html

saveMany()
$data = array(
    array('title' => 'title 1', 'Assoc' => array('field' => 'value')),
    array('title' => 'title 2'),
);
$data = array(
    array(
        'Article' => array('title' => 'title 1'),
        'Assoc' => array('field' => 'value')
    ),
    array('Article' => array('title' => 'title 2')),
);
$Model->saveMany($data, array('deep' => true));
saveAssociated()
$data = array(
    'Article' => array('title' => 'My first article'),
    'Comment' => array(
        array('body' => 'Comment 1', 'user_id' => 1),
        array(
            'body' => 'Save a new user as well',
            'User' => array('first' => 'mad', 'last' => 'coder')
        ),
    ),
);
$Article->saveAssociated($data, array('deep' => true));


2014年5月26日 星期一

[Catering System] Catering Business Operational Form Samples

Weekly Purchase Order Form for one Supplier
http://www.kitman.com/wos.pdf

Daily Purchase Order Form for one Supplier
http://www.kitman.com/po.pdf

Food Cost Report for one Dish
http://www.kitman.com/ccc.pdf

Stock Take Form for one Supplier
http://www.kitman.com/st.pdf

Stock Cost Summary for all Suppliers
http://www.kitman.com/str.pdf

Revenue Forecast for a Week
http://www.kitman.com/forecast.pdf
Revenue Forecast for a Week ( Simplified )
http://www.kitman.com/fsml.pdf

Sales Forecast for a Week
http://www.kitman.com/t1.pdf

Purchase Forecast for a Week
http://www.kitman.com/t2.pdf

A Reading about Catering Operation

http://www.icac.org.hk/filemanager/en/content_1031/33.pdf

A document provided by ICAC ( Independent Commission Against Corruption ), describing how a catering company operates and suggesting some good practices of running a catering business legally, securely and sensibly.

Chapters include Procurement Practice, Food Purchase, Stores Management, etc. Talks about what should be done when suppliers delivered short goods, what to do with inactive suppliers, how to be fair to bidders, and so forth.

2014年5月22日 星期四

Haven't Ever Thought of this: [CakePHP CMS] CakePHP based CMSes

http://www.serverfocus.org/5-cakephp-cmses-reviewed

http://blog.dreamcss.com/content-management-system/cakephp-based-cms/

If WordPress does not quite suit for your customized project (esp. when needed to link to other built systems), you may look for these CMSes with CakePHP as its framework backend if you are familiar with CakePHP .

2014年5月20日 星期二

[CakePHP] Wizard Component - Skip steps or not? Trick

http://bakery.cakephp.org/articles/jaredhoyt/2010/09/10/wizard-component-1-2-1

Set $autoAdvance to false, and the pages is forced to be navigated step by step.
Set $autoAdvance to true, then pages will jump to the last completed page after clicking 'next'.

2014年5月12日 星期一

[Home Cleansing] Natural Cleansers - Baking Soda and Vinegar



Source: http://www.hket.com/eti/article/913472db-26f6-465a-b643-c5daaba82f4b-406134?category=green_news&source=print&printable=true

輕鬆家事:清潔先生──梳打粉

一般人清潔家居,多會使用化學清潔劑,可是這些清潔劑除了污染空氣外,對身體亦有潛在的危險。事實上,天然物品也有同樣的清潔效能;梳打粉(Baking soda)又稱「蘇打粉」正是最好又最便宜的天然清潔劑 ,名副其實的「清潔先生」。

* 將梳打粉加入半桶水內,可用以清潔瓷磚地。
* 將一小盒的梳打粉置放在冰箱,可去除臭味。(每四至六個月便需要更換一次)。
* 將少量梳打粉放在垃圾桶底,可防止嗅味散發。
* 如廚櫃台面或煮食用具沾有頑固污漬,可用梳打粉加水開成糊狀,用布輕擦即可清除;但切記勿用此法於non-stick的易潔器具上。
* 燒有異味焦食物的鍋或鑊,灑上梳打粉再加入熱水浸透一小時,污漬自會容易清除。
* 如不想棄掉內有異味的膠手套,不妨洒入少量梳打粉便可除臭。同樣,處理一些有異味的膠容器,亦可用梳打粉加醋浸隔夜,臭味全消!
* 在瓶內/壼內加入熱水和一茶匙梳打粉浸泡數小時,便可清潔熱水瓶及咖啡壼內的氣味。
* 用沾上少量食用梳打粉的濕布拭抹,即可除去杯內的茶漬或咖啡漬。
* 如家中用的是硬水,你會發現水喉與瓷盆之間會出現一層厚厚啡色硬漬,可用梳打粉灑在該處,再用浸過醋的布去擦,硬漬便會清除。
* 爐頭上少不免都會有難去除的污垢,同樣將梳打粉洒在污漬面,數小時後便很容易清除。

Source: http://www.baby-kingdom.com/forum.php?mod=viewthread&tid=1291351


油污殺手 梳打粉
梳打粉實為碳酸氫鈉,呈弱鹼性,可以自然地分解,而且不含毒性,絕不會污染環境,更不會刺激皮膚。梳打粉大致可分為藥用、工業用及食用三類,而進行家居清潔用途的則選用食用梳打粉就可以了。
煮食時產生的油煙籠罩着整個廚房,無論是窗戶還是廚具器皿都變得立黐黐,無一倖免!只需要梳打粉和水就可以打造出一支特效去污劑!
梳打水製作法:
將一湯匙梳打粉加入250毫升的暖水中,拌勻後放入噴壺即可。
Tips如果要清走頑固油污,可以直接將梳打粉倒在油污上,再用濕海綿擦一擦,油污即刻無晒!
去漬雙打 梳打粉+白醋
洗衣機幫大家洗衣服,但你又有沒有為家中的洗衣機定時清洗呢?長期處於潮濕狀態的洗衣機,再加上衣物上的污垢和洗潔精的殘餘物,都會滋生大量細菌,成為病毒的溫牀。
Step 1:將洗衣機入滿水,並放入一杯(約120克)梳打粉。
Step 2:開動洗衣機攪動5分鐘後,讓梳打粉水靜待1小時。這有助軟化水質,避免水中的鈣、鎂離子與殘存在洗衣槽的肥皂形成不溶於水又難以清洗的污垢。
Step 3:將污水排走後,以空機進行洗衣程序。
Step 4:污漬清走後,下一步便要消毒。同樣在機內放滿水,再加入約300cc白醋,讓洗衣機攪動10分鐘後浸泡至少30分鐘,再以清水清洗一次即可。
膠製器皿經常有一陣令人倒胃的異味,用梳打粉加白醋浸上一個晚上,奇怪的氣味從此消失。

Source: https://metrohk.com.hk/?cmd=detail&id=179146




2014年5月8日 星期四

[Linux] Start-up a VirtualBox VM ; Synchronize Two MySQL Databases ; Crontab Schedule MySQL Database Backup

To list out all the running VMs:
VBoxManage list runningvms

To start-up a virtualBox VM:
VBoxManage startvm {The VM Name, e.g. CateringSys, Case-sensitive} --type headless
The correct response:
Waiting for VM "{The VM Name}" to power on...
VM "{The VM Name}" has been successfully started

To Synchronize Two MySQL Databases
(Override A with B - Override (database to be updated) with (The most updated database) )

On the most updated server(B), run the following command:
mysqldump -u {The MySQL username} --password={The password} {The database name} | mysql -u {The remote MySQL's username} --password={The remote MySQL's password} --host={The remote host's IP, e.g. 192.168.1.40 or external IP} {The remote database name}
So as to synchronize data to the remote server (A).

Schedule database backup:
crontab -e

# Inside the crontab file
# * Output a .sql backup file
# Say, do the following at 3:00 a.m. daily
# Note that slash is needed for escaping character '%', and ':' in the file name is prohibited
0 3 * * * mysqldump -u {The MySQL username} --password={The password} {The database name} > {The directory path for storing the backup .sql file, e.g. [/home/me/mysql_backup/]}{file name, e.g. [mysql_backup_`data +\%Y=\%m-\%d_\%H=\%M-\%S`.sql]} 2>&1 

# * Synchronize to the other database
# Say, do the following at 4:00 p.m. daily
0 16 * * *  mysqldump -u {The MySQL username} --password={The password} {The database name} | mysql -u {The remote MySQL's username} --password={The remote MySQL's password} --host={The remote host's IP, e.g. 192.168.1.40 or external IP} {The remote database name} 2>&1

Save the file. Done.

For more details about crontab, please read http://linux.vbird.org/linux_basic/0430cron.php .

2014年2月17日 星期一

[HTML Table] HTML Table Generator

http://www.tablesgenerator.com/

This web app might help you to generate simple html table code, thus simplify your development process

2014年2月12日 星期三

[HTML Form] 5 Free Online HTML Form Builders

Using tools to build HTML form can catalyze the form building process. It helps you not to get your hands dirty in the preliminary stage.

http://www.hongkiat.com/blog/free-form-builders/

2014年2月7日 星期五

[Fact and Truth] [Salary Calculation] 3 Inspiring Stories about Your Salary

[Fact and Truth] High Salary Job Does Not Imply You Are Wiser about Life

[In Traditional Chinese]
http://blog.xuite.net/dizzy03/murmur/66674579

[Original(?!) - In Simplified Chinese]
http://www.xinli001.com/info/4380/

What a wise thought.

Your life formula underneath your salary calculation given from your employee:

Salary != Amount on your Pay Slip (Basic amount + OT + bonus + 13th-month + bla bla bla)

but

= your hourly wage + possibility + health + life + good mood + family + pressure level ( accord. to the article)

Consider how you prioritize yours for YOUR life.


So, the question comes, what is MY priority? What about yours?



[PHP trick] A Magical Method to print_r() an Array with Indentation in PHP

Change this:
print_r($i_am_an_array);
To this:
echo '<pre>', print_r($i_am_an_array, true), '</pre>';

And the array will be magically indented right after you press 'F5' in browser.
(Wow! It looks so pretty! <3)

* Note that the 2nd argument of print_r(first_arg, second_arg) equals true means it forces to return the array as a string. But seems this is not a necessity, depending on your case.

2014年2月5日 星期三

[What? Some Random Thoughts] Unrelenting is an extreme; permissive is another

Unrelenting:
      ADJ 不顾一切的;不留情面的
      If you describe someone's behaviour as unrelenting, you mean that they are continuing to do something in a very determined way, often without caring whether they hurt or embarrass other people.

Permissive:
      adj 1: not preventive [ant: {preventative}, {preventive}]
      2: granting or inclined or able to grant permission; not strict
         in discipline;


Some thoughts about these two words.
If unrelenting is not a good practice, neither is permissive. One is ruthless, the other is lack of discipline.
How to strike a balance? Wow, that is the wisdom and such a long way to go.

[English / Latin] Word of this Hour - Ad hominem / Condescension

Ad hominem

  • A kind of Fallacy
  • 對人不對事

  • 褒義定貶義?

[Blogger] My Blog is suffering from Referrer Spam

The symptom of my blog disease : Sudden unusual high page view count.

Way to treat: In no way.

Here is some of the blogger doctor's advice, talking about the causes and what to do (very informative and in-depth):


To sum up:
  • Never click on the links in your page view statistics which look suspicious ( I have tried once and I can tell, never, never should you do that! )
  • Never help them by advertising them ( do not post any link of them, or you are helping them to spread :[ )
  • Though we have no way prohibiting their malicious acts, work on the blog content and gain real readers. Then their influences will become less significant.

2014年1月24日 星期五

[CakePHP] Pros and Cons of using cakePHP

http://www.bootstrappist.com/archives/to-cakephp-or-not-to-cakephp-should-you-use-it-or-dump-it/

To sum up from the article,

PROS:
  • Shortens dev. time
  • more secured
  • pretty coding
  • widely supported
  • trend (?!) - many people talk about it
CONS:
  • Not for complex issue
  • Not always necessary
  • Not really a "native PHP" training

[Apache + PHP] php_mbstring.dll missing

Wanna install 'Bake' for CakePHP. In cmd, when trying 'bake', an error prompts out like below (with solution included) :


http://aaron1102.pixnet.net/blog/post/51096054-%5B%E6%9E%B6%E7%AB%99%E6%9C%8D%E5%8B%99%5D%E9%A1%AF%E7%A4%BA%E9%81%BA%E5%A4%B1php_mbstring.dll%E7%9A%84%E8%A7%A3%E6%B1%BA%E6%96%B9%E6%A1%88

[Eclipse] Change Default Text File Encoding in Eclipse

Window -> Preferences -> General -> Workspace : Text file encoding

[CakePHP] Better Performance – Speeding Up Your CakePHP Website

http://doctorfox.wordpress.com/2013/08/20/better-performance-speeding-up-your-cakephp-website/

2014年1月22日 星期三

[Project Management] Drupal Case Studies

So, the story begins ... We want a online shopping website but we don't know what framework or tools can catalyze the development progress. The time frame is around 1 to 2 months. WordPress is good for layout process, but not good for customizing for our needs. Custom-made proprietary website likes our old one ... ya it is custom-made but wow, seems much work to do ...

All in a sudden we came up with a question: how about ... Drupal?

Found that several comprehensive project case studies have been put on Drupal, which can be brilliant reference sources for the newbies like us, I recommend this to you also to understand if Drupal suits your project needs.


We have selected some main points to glance through in our preliminary phase, which might help for your decision making if you are in the same situation:
  • Why Drupal was chosen
  • Team Size
  • Time Spent
This is what our rough result found:
  • Drupal should be suitable for more likely the medium or large sized project
  • One of the impressive features for Drupal is taxonomy, which seems more relevant to journal-related, news-related or story-related projects
  • It requires skills and trials for us the Drupal newbies before the "real" development
  • Roughly the projects take about a year or more for a small team size
As seems the findings above do not benefit much for our aim, thus, the idea of using Drupal is ABANDONED in our case.  



[Tomcat] An Introduction to Tomcat Catalina

Just notice that Catalina is very useful tool for taking logs of the server, thus wondering what Catalina in Tomcat is ...

https://www.mulesoft.com/introduction-tomcat-catalina

2014年1月21日 星期二

[ClouSE][EC2] What is ClouSE? What is EC2?

http://www.oblaksoft.com/documentation/

Something relates to MySQL, Cloud, EC2 and storage stuff?

So, what is EC2, more precisely, Amazon EC2?

http://blog.soft.idv.tw/?p=823

  • What is Cloud Computing?
  • -> What is SaaS (Software as a Service)?
  • -> What is PaaS (Platform as a Service)?
  • -> What is IaaS (Infrastructure as a Service)?
  • What is Amazon Web Services (AWS)?
  • -> What is S3 (Simple Storage Service)?
  • -> What is EC2 (Elastic Compute Cloud)?
  • -> What is SQS (Simple Queuing Service)?
  • -> What is VPC (Virtual Private Cloud)?
  • How to get my AWS?


http://blog.soft.idv.tw/?p=824

  • What is VPS (Virtual Private Server) and VM (Virtual Machine)?
  • What are the differences between VPS and VM?
  • What can EC2 do?
  • How to get start with my EC2?
  • How to use my EC2?

[Discussion on Framework] Pros and Cons of using Framework

http://www.1stwebdesigner.com/design/pros-cons-frameworks/

http://themetaq.com/articles/the-pros-and-cons-of-using-a-front-end-framework

Summing-up on using Framework:

PROS

  • Development Efficiency
  • Less Decisions Required
  • More widely Tested
  • Minimized Cost
  • Documentation and Community Support
CONS
  • Less Underneath Skills Trained
  • Less Flexibility
  • Virus-spreading Medium
  • Performance
  • Update Issues / Outdated Issues
  • Collaborations on Customization
BEST solution never exists and BETTER solution depends on the situation. Discuss and know your needs. Stay open-minded in your discussions.

[WordPress] Custom Functionality Plugin for WordPress

Why and How to Create Custom Functionality WordPress Plugin
http://www.onextrapixel.com/2012/06/26/custom-functionality-plugin-for-wordpress-pros-and-cons/

Discussion on WordPress MVC Compliance
http://stackoverflow.com/questions/2857143/is-wordpress-mvc-compliant

MVC Framework Plugin for WordPress
http://wpmvc.org/

2014年1月10日 星期五

[WordPress] Some PHP Code Standards stated by WordPress

http://make.wordpress.org/core/handbook/coding-standards/php/

Some Highlights:

Indentation 
Rule of thumb: Tabs should be used at the beginning of the line for indentation, while spaces can be used mid-line for alignment.
Comma of Array
Note the comma after the last array item
Regex
It’s most convenient to use single-quoted strings for regular expressions 
End of Line / End of File 
Remove trailing whitespace at the end of each line of code. Omitting the closing PHP tag at the end of a file is preferred.
SQL Formatting
$wpdb->prepare() is a method that handles escaping, quoting, and int-casting for SQL queries. 






[Unrelated] Extension Reading on Programming Jargon:
http://www.codinghorror.com/blog/2012/07/new-programming-jargon.html

[Wordpress] Some Code Function References

To interact with Wordpress database using PHP codes:

Insert Post
http://codex.wordpress.org/Function_Reference/wp_insert_post

Set Post Terms ( Tag or Category )
http://codex.wordpress.org/Function_Reference/wp_set_post_terms

Add Post Meta Field Data
(May be needed after added some plugins and would like to be compatible with them)
http://codex.wordpress.org/Function_Reference/add_post_meta

Create Post Category
http://codex.wordpress.org/Function_Reference/wp_create_category

2014年1月9日 星期四

[Version Control] The Art of Commit Messages

http://coenjacobs.me/art-commit-messages/

Compare this two:
  1. “Fixes bug described in #20″
  2. “XYZ_Class test() method visibility to public to fix errors in #20″

[康復路] 試完又試

見了醫生,因為血色素又變低了,醫生想檢查是否「缺鐵」為成因,檢查又檢查…… 感覺有些麻煩……又抽血,又要留樣本…… 令我回想起當日入院的時光,因為一些原因,留樣本只需留一次,免卻留三次的麻煩;現在每天都要留一次,連續三天。每天早上就要跑醫院一趟再上班。 幸好也完成了。 第二次抽血...