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 .

[康復路] 試完又試

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