January 9, 2010 - Posted by linden - 0 Comments
The root password is stored in the table user in the database. If you forgot the password, you can reset it by using mysql’s safe mode. The safe mode just allow you login to the database without password.
In Linux, you shoud execute /etc/init.d/mysql stop as root. In Windows, you can using task manager to kill the mysqld process or stop it in Service Management.
Then start mysql using mysqld_safe or mysqld_safe.exe which is under the mysql’s bin directory.
mysqld_safe --skip-grant-tables --skip-networking
Login to mysql using mysql -u your_user_name mysql
mysql> UPDATE user SET Password=PASSWORD('New_of_Your_Password') WHERE User='your_user_name';
mysql> FLUSH PRIVILEGES;
Then you can restart your normal mysql service. The new password will be valid then.
Technorati : mysql, password
December 20, 2009 - Posted by linden - 3 Comments
Heredoc and Nowdoc are two method to define a string in php. They both could define a multiple-line-style string without using \n. They make it easy to define a paragraph.But there are differences between Heredoc and Nowdoc.
The Heredoc is a multiple-line simple string. It will be parsed. All the variable in the string will be replaced by the value of the variable and the escape characters will be replaced too. Below is the exam:
<?php
$str = <<<EOD
Example of string
spanning multiple lines
using heredoc syntax.
EOD;
/* More complex example, with variables. */
class foo
{
var $foo;
var $bar;
function foo()
{
$this->foo = 'Foo';
$this->bar = array('Bar1', 'Bar2', 'Bar3');
}
}
$foo = new foo();
$name = 'MyName';
echo <<<EOT
My name is "$name". I am printing some $foo->foo.
Now, I am printing some {$foo->bar[1]}.
This should print a capital 'A': \x41
EOT;
?>
The output is as follows:
My name is "MyName". I am printing some Foo.
Now, I am printing some Bar2.
This should print a capital 'A': A
But if you use Nowdoc, the escaping characters are not be parsed.
echo <<<’EOT’
My name is ”$name”. I am printing some $foo->foo.
Now, I am printing some {$foo->bar[1]}.
This should not print a capital ’A': \x41
EOT;
The output will be
My name is "$name". I am printing some $foo->foo.
Now, I am printing some {$foo->bar[1]}.
This should not print a capital 'A': \x41
Notice:The definition end mark should be exactly as same as the begin mark which is following “<<<”. The white space ahead the mark will not be ignored.
December 16, 2009 - Posted by linden - 1 Comment
Recently, I try to use vim as my editor for php. I found these usefull tools for using to configure your vim more confortable.
First, if your installation of vim has no php syntax file, you can download php.vim from php.vim. Put the extracted file into syntax folder under vim installation directory. It might be /usr/share/vim/vim7/syntax in linux, for example.
Then you can paste following code into .vimrc under your home directory.
filetype plugin on
au FileType php set omnifunc=phpcomplete#CompletePHP
” You might also find this useful
” PHP Generated Code Highlights (HTML & SQL)
let php_sql_query=1
let php_htmlInStrings=1
Then you can use ctrl+x ctrl+o to pop up the content assistant for your editing.
December 14, 2009 - Posted by linden - 0 Comments
The ASDoc is a useful tool for creating documents for your code especially for the code that will be shipped to other develop. If you are struggling in writing documents, the ASdoc is worthy to try. This a brief introduction for using ASDoc in Eclipse and Flex Builder. If you are searching for how to add proper comments for ASDoc please see http://livedocs.adobe.com/flex/3/html/help.html?content=asdoc_1.html for details.
By default, the Flex Builder dosen’t have the entry to trigger the build of ASDoc. You can simply add an external to build the ASDoc in IDE. The steps are as follows:
- Click on the. Choose the External Tools Configurations…
- In the opened dialog, double click the item Program or select the item then click the new button. This will create an new configuration for running a program.
- Locate the asdoc.exe (asdoc in Mac). It is under the sdk’s bin folder.
- Setup working directory using ${project_loc}
- Add basic arguments:
-source-path src
-doc-sources src
- Add external lib using directive -external-library-path=…
The final configuration will be looks like

Now you can build ASDoc by just one click.