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-1.6.0.10
$> cd pentaho/biserver-ce
$> chmod a+x *.sh
$> ./start-pentaho.sh
$> cd pentaho/biserver-ce/administration-console/
$> ./start.sh
INFO: Console is now started. It can be accessed using http://localhost:8099 or http://127.0.0.1:8099

update admin password to "admin", reference http://wiki.pentaho.com/display/ServerDoc2x/Configuring+Security+with+Pentaho+Administration+Console:
$> cd pentaho/biserver-ce/administration-console/
$> vi resource/config/login.properties
admin: admin,server-administrator,content-administrator,admin

Restart pentaho bi server and pentaho administrator-console server.
Visit http://127.0.0.1:8099, 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

/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/

Using get_class() in superclass

<?php
abstract class bar {
public function __construct()
{
var_dump(get_class($this));
var_dump(get_class());
}
}

class foo extends bar {
}

new foo;
?>


The above example will output:

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

Reference:
http://cn.php.net/manual/en/function.get-class.php

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:
http://maven.apache.org/plugins/maven-dependency-plugin/
http://maven.apache.org/plugins/index.html

Reference:
http://groups.google.com/group/maven-zh/browse_thread/thread/20494aa10d7818ba?pli=1

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 http://xdebug.org/files/xdebug-2.0.4.tgz
$> 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/xdebug.so /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


zend_extension=/usr/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so
[xdebug]
xdebug.file_link_format="txmt://open?url=file://%f&line=%l"
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_autostart=1

$> 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.

Reference:
http://jamesangus.ucantblamem.com/programming/installing-php-xdebug-on-mac-os-x-leopard/214/
http://developers.sugarcrm.com/wordpress/2008/11/25/enabling-xdebug-under-os-x-leopard/