Jun 25, 2011

apache and htaccess

1. in your Directory

DirectoryIndex index.php index.html
Options Indexes FollowSymLinks MultiViews
AllowOverride All ##### this should be All
Order allow,deny
allow from all


2. in your /var/www/xxx folder, add file .htaccess
Options +FollowSymLinks
IndexIgnore */*

RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php

Jun 11, 2011

Cocos2D Complete

■CCLabelTTF Font List:
  List of iOS Fonts available in iOS 3.1 and above
  • Family name: AppleGothic
  • Font name: AppleGothic
  • Family name: Hiragino Kaku Gothic ProN
  • Font name: HiraKakuProN-W6
  • Font name: HiraKakuProN-W3
  • Family name: Arial Unicode MS
  • Font name: ArialUnicodeMS
  • Family name: Heiti K
  • Font name: STHeitiK-Medium
  • Font name: STHeitiK-Light
  • Family name: DB LCD Temp
  • Font name: DBLCDTempBlack
  • Family name: Helvetica
  • Font name: Helvetica-Oblique
  • Font name: Helvetica-BoldOblique
  • Font name: Helvetica
  • Font name: Helvetica-Bold
  • Family name: Marker Felt
  • Font name: MarkerFelt-Thin
  • Family name: Times New Roman
  • Font name: TimesNewRomanPSMT
  • Font name: TimesNewRomanPS-BoldMT
  • Font name: TimesNewRomanPS-BoldItalicMT
  • Font name: TimesNewRomanPS-ItalicMT
  • Family name: Verdana
  • Font name: Verdana-Bold
  • Font name: Verdana-BoldItalic
  • Font name: Verdana
  • Font name: Verdana-Italic
  • Family name: Georgia
  • Font name: Georgia-Bold
  • Font name: Georgia
  • Font name: Georgia-BoldItalic
  • Font name: Georgia-Italic
  • Family name: Arial Rounded MT Bold
  • Font name: ArialRoundedMTBold
  • Family name: Trebuchet MS
  • Font name: TrebuchetMS-Italic
  • Font name: TrebuchetMS
  • Font name: Trebuchet-BoldItalic
  • Font name: TrebuchetMS-Bold
  • Family name: Heiti TC
  • Font name: STHeitiTC-Light
  • Font name: STHeitiTC-Medium
  • Family name: Geeza Pro
  • Font name: GeezaPro-Bold
  • Font name: GeezaPro
  • Family name: Courier
  • Font name: Courier
  • Font name: Courier-BoldOblique
  • Font name: Courier-Oblique
  • Font name: Courier-Bold
  • Family name: Arial
  • Font name: ArialMT
  • Font name: Arial-BoldMT
  • Font name: Arial-BoldItalicMT
  • Font name: Arial-ItalicMT
  • Family name: Heiti J
  • Font name: STHeitiJ-Medium
  • Font name: STHeitiJ-Light
  • Family name: Arial Hebrew
  • Font name: ArialHebrew
  • Font name: ArialHebrew-Bold
  • Family name: Courier New
  • Font name: CourierNewPS-BoldMT
  • Font name: CourierNewPS-ItalicMT
  • Font name: CourierNewPS-BoldItalicMT
  • Font name: CourierNewPSMT
  • Family name: Zapfino
  • Font name: Zapfino
  • Family name: American Typewriter
  • Font name: AmericanTypewriter
  • Font name: AmericanTypewriter-Bold
  • Family name: Heiti SC
  • Font name: STHeitiSC-Medium
  • Font name: STHeitiSC-Light
  • Family name: Helvetica Neue
  • Font name: HelveticaNeue
  • Font name: HelveticaNeue-Bold
  • Family name: Thonburi
  • Font name: Thonburi-Bold
  • Font name: Thonburi

May 27, 2011

iOS4.2 Bug with UINavigationViewController

Everytime when I left the top view, I set the topView's title to @"TOP";
When I came back to the TOP, I would set the topView's title to @"", for that I had a backgroud image to be displayed as the title.
The problem was, with iOS4.2,the second time I left TOP view controller and went to a second level view controller, the back item in the NavigationBar disappeared.
"DISAPPEARED"!!!!!!!!!有木有!!!!!!!!!
I couldn't go back to the TOP!!!!!!!!!!!!!!
I got rejected by GREE for this f**king problem!!!!!!!

But, there's always a but!
I love but(this statement is still true by replacing the t with a double t)!

I came out with a solution.

1. set the top's title to @"TOP", don't set it back to @"";
2. every time you go back to the top , do this:
self.navigationItem.titleView = [[UIView alloc] initWithFrame:CGRectMake(0,0,1,1)];

Now, the problem disappeard!!!!
"DISAPPEARED"!!!!!!!!!有木有!!!!!!!!!

May 25, 2011

Weird problem with CCSprite

I added a CCSprite(with an image) as the background, the fps jumped to 30.0.
when I remove it or change the scale to less than 1.0, the fps would return to 60.0.
Now I am going to find out what's going on here.

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, ""); ?>



Mar 18, 2011

connect to remote mysql

1. if there is a firewall
sudo /sbin/iptables -A INPUT -p tcp -d 0/0 -s 0/0 --dport 3306 -j ACCEPT

2. in my.cnf, set
bind-address = your IP

Mar 12, 2011

memcached can't link to libevent.so

> ldd /usr/bin/memcached
> LD_DEBUG=libs /usr/bin/memcached -v
> sudo ln -s /usr/lib/libevent-2.0.so.5 /lib64/libevent-2.0.so.5

Mar 10, 2011

Install Git

install git on a plain CentOS 5.5 64bit machine:

you may not have these three libraries, so install them first.
> yum install openssl-devel.x86_64
> yum install curl-devel.x86_64
> yum install expat-devel.x86_64


now , go to your git source directory, and hit the following command,

> make
> make install

you shall now find the git commands as bellow,

/root/bin/git*

Jan 24, 2011

Yii - default timezone

1.set default timezone
Encountered an error which was described here:
http://php.net/manual/en/function.date-default-timezone-set.php
I added the following line to the index.php
date_default_timezone_set("Asia/Tokyo");

2.Gii

'modules'=>array(
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'123456',
'ipFilters'=> array('localhost', '127.0.0.1', '192.168.2.249'),
),
),



3. Gii
"CDbConnection failed to open the DB connection: could not find driver"
I didn't get the proper pdo_php support.
I re-configured php using the following command:
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-pdo-mysql

...fixed now