Monday, March 16, 2009

Test take place of print

[Martin Fowler]: Whenever you are tempted to type something into a print statement or a debugger expression, write it as a test.

Tuesday, March 10, 2009

pentaho2 install in ubuntu

$> export JRE_HOME=/usr/lib/jvm/java-6-sun-
$> cd pentaho/biserver-ce
$> chmod a+x *.sh
$> ./
$> cd pentaho/biserver-ce/administration-console/
$> ./
INFO: Console is now started. It can be accessed using http://localhost:8099 or

update admin password to "admin", reference
$> cd pentaho/biserver-ce/administration-console/
$> vi resource/config/
admin: admin,server-administrator,content-administrator,admin

Restart pentaho bi server and pentaho administrator-console server.
Visit, and use admin/admin login administratation console(old username/password is admin/password)

Sunday, March 08, 2009

String compare trap in php

If string compare with an integer, php will evaluate string to integer intval() and compare it with that integer.

if('test' != 0) {
echo "true";
} else {
echo "false"; // return false
if('0test' != 0) {
echo "true";
} else {
echo "false"; // return false
if('1test' != 0) {
echo "true"; // return true
} else {
echo "false";

Regular expression of ip4


Using get_class() in superclass

abstract class bar {
public function __construct()

class foo extends bar {

new foo;

The above example will output:

string(3) "foo"
string(3) "bar"


Thursday, March 05, 2009

Howto maven2 download java source jar package

$> mvn dependency:sources -Dsilent=true filename
dependency:sources tells Maven to resolve all dependencies and their source attachments, and displays the version.

maven plugins lists page:


Firefox3 keyboard shortcuts on macbook

function key (fn) + option (alt) + left arrow key (<-) = HomePage

Command-D = Add bookmark
Command-Backspace = Back
Command-B = Bookmarks
F7 = Caret Browsing
Command-W = Close Tab
Command-F4 = Close Tab
Command-Shift-W = Close Window

Option-F4 = Close Window
Shift-Return = Add .net to address bar
Command-C = Copy
Command-X = Cut
Command-- = Shrink text
Delete = Delete
Shift-Delete = Delete Individual Form AutoComplete Entry
Command-J = Downloads
Command-G = Find Again
F3 = Find Again
‘ = Find As You Type Link
/ = Find As You Type Text
Command-Shift-G = Find Previous
Shift-F3 = Find Previous
Command-F = Find in This Page
Shift-Backspace = Forward
Command-Enter = Forward
Down Arrow = Scroll Down
Up Arrow = Scroll Up

Command-H = History
Option-Home = Go to your homepage
Command-+ = Enlarge text
F6 = Move to Next Frame
Shift-F6 = Move to Previous Frame
Command-M = New Mail Message
Command-T = New Tab
Command-Option-Tab = Next Tab
Command-Page Down = Next Tab
Command-N = New Window
Command-O = Open File
Command-Return = Activate selected hyperlink
Shift-Return = Open Link in New Window
Option-Return = Open address in address bar in a new tab
Command-I = Page Info
Command-U = Page Source
Command-V = Paste
Command-Shift-Tab = Previous Tab
Command-Page Up = Previous Tab
Command-P = Print
Command-Shift-Z = Redo
F5 = Refresh
Command-R = Refresh
Command-F5 = SuperRefresh (refreshes the page even if no changes have been made to the page since you last loaded it)
Command-Shift-R = SuperRefresh (refreshes the page even if no changes have been made to the page since you last loaded it)
Command-0 = Restore text size
Command-S = Save Page As
Option-Return = Save target of selected hyperlink as
Command-A = Select All
Command-L = Select Location Bar
Down Arrow = Select Next AutoComplete entry in textbox
Up Arrow = Select Previous AutoComplete entry in textbox
Command-Down Arrow = Select Next Search Engine in Search Bar
Command-Up Arrow = Select Previous Search Engine in Search Bar
Command-1 = Select first tab
Command-2 = Select second tab
Command-3 = Select third tab
Command-4 = Select fourth tab
Command-5 = Select fifth tab
Command-6 = Select sixth tab
Command-7 = Select seventh tab
Command-8 = Select eighth tab
Command-9 = Select ninth tab (select last tab)
Escape = Stop loading a page
Command-Z = Undo
Command-K = Web Search

Installing PHP XDebug on Mac OS X Leopard

$> curl -O
$> tar zxvf ./xdebug-2.0.4.tgz
$> cd ./xdebug-2.0.4/xdebug-2.0.4
$> phpize
$> MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe" CXXFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe" LDFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -bind_at_load" ./configure --enable-xdebug
$> make
$> sudo make install
$> sudo cp modules/ /usr/lib/php/extensions/no-debug-non-zts-20060613/
$> sudo cp /etc/php.ini.default /etc/php.ini
$> sudo vi /etc/php.ini
; append below lines to file bottom of /etc/php.ini


$> php -m
You should see xdebug module in list.
$> sudo apachectl restart

phpinfo will output xdebug module.
After xdebug installed, then install PDT for eclipse, or download MacGDBp, php can debug using bleakpoint.