Archive for October, 2008

Dealing with Duplicate SQL Rows

Tuesday, October 28th, 2008

I was using the export/import functions in Wordpress to transfer stories to a new (clean) installation, and the import was causing a duplicate row problem in the wp_postmeta table which was causing the multiple authors plugin to list the importing user dozens of times for each story. My quick search yielded nothing, so I pulled out my arcane SQL knowledge and used some MySQL documentation to come up with this:

> create temporary table newmeta as select distinct post_id,meta_key,meta_value from wp_postmeta;

> truncate wp_postmeta;

> insert into wp_postmeta(post_id, meta_key, meta_value) select post_id,meta_key,meta_value from newmeta;

> delete from wp_postmeta where meta_key = ‘other_author’ and meta_value = ‘admin’;

> delete from wp_postmeta where meta_key = ‘other_author’ and meta_value = ”;

Note that you need to specify the column names that you know will reproduce the duplicate and you can’t use *. I had to do some additional cleanup because the import set ‘admin’ to be an author on every story, and produced some blank entries.

I also had to modify the multiple authors plugin due to this error that kept cropping up:

Warning: Invalid argument supplied for foreach() in
/blog/wp-content/plugins/multiple-authors.php on
line 46

Basically, I just made sure it checked that the variables it was using weren’t blank before it got to the foreach statement:

if ( $other_authors == “”) return; //INSERTED Line

foreach ($other_authors as $author) {

Pretty annoying, but not too hard to fix.

Changing Default xterm colors on OSX X11

Thursday, October 23rd, 2008

This is a question that I am asked about constantly, and it is really simple: Edit the file /usr/X11R6/lib/X11/app-defaults/XTerm and add the following:

XTerm*background: black
XTerm*foreground: white

I usually do it after the savelines option. Most other names work, too (yellow, cyan, etc). For more info, you can check the manpage on xfree86.org and Thomas Dickey’s xterm site.