Apr 14, 2011

Iphone Code Complete

1. how to count time.

CFAbsoluteTime time = CFAbsoluteTimeGetCurrent();


beware that the CFAbsoluteTime is a Double.


2. How to open a URL

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"your url here"]];



Apr 2, 2011

install ssh on ubuntu

I didn't use apt for a long time, so...first I updated apt...

> apt-get update

then,
> apt-get install openssh-server

after ssh get installed..

> /etc/init.d/ssh start

done!!
pretty simple, right?

Apr 1, 2011

About error messages and locales

Localization
1. create file for localization
/protected/messages/
/en/default.php
/cn/default.php
/jp/default.php

2. specific a lang
Yii::app()->language = "en"
: this means your en folder under /protected/messages.

3. in your default.php, write things as follows,

return array(
'name' => 'xing ming',
'required' => 'bu neng wei kong',
);
?>

4. anywhere you want to use the localized name, write,
Yii::t('default', 'name');

custum error message.
1. in your model/Model.php, find function rules.
return array(
array('name, mail', 'required', 'message' => Yii::t('default', 'required'); ),
);

2. This tag will show all the form errors in a block.
The second param is the title of the block.
Here I leave it blank.
errorSummary($model, ""); ?>