Hui WANG's Blog

One will, One way

Month: August, 2009

rndc: connect failed: 127.0.0.1#953: connection refused

I have installed bind9 in ubuntu 9.04. This error arises when I try to restart bind9 after some configurations.

To find out what is preventing bind9 from getting started,  your can use this command

named -g -p 53

18-Aug-2009 22:43:35.631 starting BIND 9.5.1-P2 -g -p 53
18-Aug-2009 22:43:35.632 found 1 CPU, using 1 worker thread
18-Aug-2009 22:43:35.632 using up to 4096 sockets
18-Aug-2009 22:43:35.642 loading configuration from ‘/etc/bind/named.conf’
18-Aug-2009 22:43:35.642 /etc/bind/named.conf.options:17: expected IP address near ‘{‘

18-Aug-2009 22:43:35.643 loading configuration: unexpected token
18-Aug-2009 22:43:35.643 exiting (due to fatal error)

Everything becomes fine after I change the expected IP to one contained /etc/resolv.conf.

Good luck.

Duplicate Post Name In WordPress

In WordPress 2.8.4,  from the function wp_unique_post_slug in line 1730 in wp-include/post.php, we can see that the post_name is not allowed to be duplicated.

Given the desired slug and some post details computes a unique slug for the post.

For instance,(the idea comes from perfectlyclear)

2008/07/dress-of-the-day.html is a page that exists and is viewable on the site

but if I try to add a new post of the same title (note the different dates)
2009/08/dress-of-the-day.html the moment you hit “update post” the URL would changes to

2009/06/dress-of-the-day-1.html

and if you have lots of posts entitled dress-of-the-day.html, then the increments keep getting larger i.e. -2 -3 etc.

So to achieve our goal,  we have to  trim the suffix before it is written to the database while updating or adding a post with a duplicated name.

In this case, I’d like to introduce you the conception of filter in WordPress.

Filters are functions that WordPress passes data through, at certain points in execution, just before taking some action with the data (such as adding it to the database or sending it to the browser screen). Filters sit between the database and the browser (when WordPress is generating pages), and between the browser and the database (when WordPress is adding new posts and comments to the database); most input and output in WordPress passes through at least one filter. WordPress does some filtering by default, and your plugin can add its own filtering.

Please see further explanation in the following short code.

1
2
3
4
5
6
7
8
9
10
11
<?php
add_filter( 'wp_insert_post_data' , 'wh_duplicat_post_name' , '99' );
function wh_duplicate_post_name( $data)
{
 
  $wh_post_name=$data['post_name'];
  if(substr($wh_post_name, -2)=="-2")
  $data['post_name']=substr($wh_post_name, 0, -2);
  return $data;
}
?>

To get the code executed, you just simply add it the function.php file in your current theme root directory.

Hopefully it works for you!

English as a Second Language Podcast

For those who are learning English as a second laugange, I am willing to share with you a wonderful podcast web site eslpod.com.

Who is ESLPod.com?
ESLPod.com is run by a team of experienced English as a Second Language professors with over 30 years of high school, adult, and university ESL teaching experience. Dr. Lucy Tse writes scripts and story ideas for the podcasts, and records many of the dialogs and stories. The host for the podcast is Dr. Jeff McQuillan, who helps read the scripts and provides explanations for them.

What attracts me most is not only we can learn lots of vocabularies and expressions there but also the pure Aemrican culture. In every episode, a dialogue is repeated twice of which the first time is made in a slower speed and the second one normal. The explanation is very clear and impressive. 

During the whole episode, you will  be reminded of the learning guideline which doesn’t come  free as the podcast does.  I think that’s a main reason why the podcast could get updated every two or three days with a very good quality.

Many thanks for Dr.Lucy Tse and Dr. Jeff McQuillan. And hopefully, you will like it.

How to Change PHPMyAdmin Password

At the moment of writing this tutorial, I am working as an intern on the integration of an old database into the one of WordPress 2.8.3. In order to protect my private password which I have set for the MySQL root, I want to change it as a simple public one through PHPMyAdmin panel. Unluckily, I didn’t make it. But after a glance at the PHPMyadmin documents, I got hwo tho change PHPMyAdmin  Password.

In fact, When a user logs in to phpMyAdmin, that username and password are passed directly to MySQL. phpMyAdmin does no account management on its own (other than allowing one to manipulate the MySQL user account information); all users must be valid MySQL users.

So, to change the PHPMyAdmin login password, change it in MySQL.

1) Login to mysql server, type following command at shell prompt:

$ mysql -u root -p

2) Use mysql database (type command at mysql> prompt):

mysql> use mysql;

3) Change password for root:

mysql> set password = password("yournewpassword");

or for user “whuisonline“:

mysql> update user set password=PASSWORD("NEWPASSWORD") where User='whuisonline';

4) Reload privileges:

mysql> flush privileges;
mysql> quit

We get it!

Share your Delicious on Twitter

As the most popular bookmarks sharing service provider,  Delicious now give us the possibility to publish our favorites web urls on Twitter. The biggest  advantage of this approach is that we could see what people are saying about the shared bookmarks.

Delicious give more explanations in their blog.

Once you get connected on your delicious account, go to settings, in the bookmarks column, you will find a filed called sharing, “Share your bookmarks with Twitter”. However, today when I try to connect with twitter by following this link, an error show up.

delicious-on-twitterHope it works in the near future.

You can drop dockable dialogs here

In this short tutorial, I will share with you about how to get rid of  the annoying phrase ,”You can drop dockable dialogs here”, which will show in the tool box of Gimp if you happen to close the dockable tab.

My gimp is at version 2.6.  Depending on your system, you can find respectively  the “tool option” in file->dialog->tool option under MS Windows and windows->dockable dialogs->tool option under Linux.

Click the small triangle in the tool option dialog as shown in the following picture and make sure the checkbox,”lock tab to dock”  is unchecked.

small triangle

lock to the dock

Then hover you mouse on the tab name which is ” Rectangle select”  in this example. Left click  it and hold , drop it to the lower part of  tool box. Release it when that lower area changes its color.

hover on tab

drap tab

tab release

It’s done.