Monday, June 27, 2011

Mysql Problems with error 1100: Table ... was not locked with LOCK TABLES

When you use LOCK TABLES, you must lock all tables that you are going
to use in your queries. Because LOCK TABLES will not lock views, if
the operation that you are performing uses any views, you must
also lock all of the base tables on which those views depend.
While the locks obtained with a LOCK TABLES statement are in effect,
you cannot access any tables that were not locked by the statement.
Also, you cannot use a locked table multiple times in a single
query. 

Reference                           
  1. http://hi.baidu.com/kennlee/blog/item/e839db66246e0520aa184c25.html 
  2. http://forums.mysql.com/read.php?21,134450,144180#msg-144180

Tuesday, June 21, 2011

When using a PHP function that requires a callback, how do we pass a custom parameter to the callback?

class Callback
{
    public $parameter;

    public function handle($matches)
    {
        return $matches[1] . ($matches[2] + $this->parameter);
    }
}

$instance = new Callback();
$instance->parameter = 99;
echo preg_replace_callback("|(\d{2}/\d{2}/)(\d{4})|", array($instance, 'handle'), $text);

Reference 
  1. http://stackoverflow.com/questions/1502626/when-using-a-php-function-that-requires-a-callback-how-do-we-pass-a-custom-param

Saturday, June 18, 2011

止咳嗽

陈皮, 黑豆,蜜枣,瘦肉

1.浸陈皮
2. 2个蜜枣,黑豆煮瘦肉
3.  后下陈皮

Friday, June 17, 2011

How to configure apache for a new website

//For Linux

1. go /etc/apache2/sites-available/ and create a file for your site
2. run command "a2ensite [yoursite]"
3. reload apache by command "/etc/init.d/apache2 reload"
4. configure hosts file /etc/hosts



//For Mac

1. go /etc/apache2/other/ and create a file for your site
2. restart apache
3. configure hosts file to point you website to 127.0.0.1 /etc/hosts


//To include website configuration files into httpd.conf

add this line to the bottom

Include /private/etc/apache2/other/*.conf


//To make .htacces file work

So I opened up my http.conf file and went down to line 378, and sure enough this is what I saw:

<directory>
Options Indexes FollowSymLinks
AllowOverride None
</directory>

In order to get .htaccess files working in the new version, I just had to change None to All, restart the server, and everything worked normally. Just thought I would share in case anyone else runs into this problem.

<directory>
Options Indexes FollowSymLinks
AllowOverride All
</directory>

Reference:                      
So You Want to Use .htaccess files with MAMP?
http://trevordavis.net/blog/use-htaccess-files-with-mamp

Thursday, May 26, 2011

Eclipse Error: The builder launch configuration could not be found.

Errors during build.
Errors running builder "Integrated External Tool Builder" on project project.
The builder launch configuration could not be found.
Errors running builder "Integrated External Tool Builder" on project project.
The builder launch configuration could not be found.
Errors running builder "Integrated External Tool Builder" on project project.
The builder launch configuration could not be found.
Errors running builder "Integrated External Tool Builder" on project project.
The builder launch configuration could not be found.
Errors running builder "Integrated External Tool Builder" on project project.
The builder launch configuration could not be found.
************************


1.Select the right project
2.Choose "project"on the tool bar -> Properties
3.Click "Builders" in the menus of the popped up window
4.Remove the missing builders

Reference                                      
  1. http://dy.f.blog.163.com/blog/static/60711476200941824126555/

Wednesday, May 11, 2011

Passing parameters to a function called with setTimeout

When creating my news ticker plugin, I came across a slight complication when using setTimeout() to calling a function which needed parameters passed to it. Not having had much call to use setTimeout in the past, I simply put:

setTimeout(myFunction(parameter),myTimeout);


but that doesn’t work. An apparent solution (until tried in Internet Explorer) is:

setTimeout(myFunction,myTimeout,parameter);

It wasn’t as easy as I expected to find out how to get around this, but it turns out that all is needed is a “closure”:

setTimeout(function(){myFunction(parameter)},myTimeout);

Reference:                                                                                                      
  1. http://www.makemineatriple.com/2007/10/passing-parameters-to-a-function-called-with-settimeout