Market

2011/07/31

Re-enabling Google FriendConnect gadgets

In case you see blank boxes in your Firefox, instead of Google FriendConnect (GFC) gadgets, you can try searching the configuration window of the HTTPS Everywhere add-on. For me, it was the GoogleServices option, which I had to deactivate in order to re-enable the GFC gadgets.
HTTPS Everywhere Preferences window

It took me some time and several deactivations and reactivations of my add-ons while trying to find the culprit and I found it.

2011/07/27

Show all my active WordPress plugins

Recently, I needed to get a list of every plugin that I've activated on all of my WordPress local-hosted blogs.
So, instead of going to every blog's dashboard and noting down the list of every active plugin, I decided to write a quick (and dirty, i.e. not optimized) script.

<?php
// initialize variables [you have to change them to their proper values]
$dbhost = "localhost";
$dbuser = "dbuser";
$dbpass = "dbpassword";

// connect to MySQL and get all database names
$db = mysql_connect( $dbhost, $dbuser, $dbpass)
      or die( "MySQL connection problem: " . mysql_error());

mysql_set_charset( "utf8");
mysql_select_db( "information_schema", $db) or die( mysql_error());
$sql = "SELECT SCHEMA_NAME FROM SCHEMATA";
$u0 = mysql_query( $sql, $db) or die( mysql_error());
$alldb = array();
while ($u1 = mysql_fetch_row( $u0)) { $alldb[] = $u1[ 0]; }

// select each database found and check for active plugins
foreach( $alldb as $adb) {
    $conn = mysql_select_db( $adb, $db);

    // get *_options table name
    $sql = "SHOW TABLES FROM $adb LIKE '%_options'";
    $u0 = mysql_query( $sql, $db); // or continue;
    while ($u1 = mysql_fetch_row( $u0)) {
        if ($opt = $u1[0]) {
            // get active plugins list
            $sql = "SELECT * FROM $opt WHERE option_name='active_plugins'";
            $u00 = mysql_query( $sql, $db);
            if ($u01 = mysql_fetch_array( $u00)) {
                $apj = $u01[ 'option_value'];
                if ($apj) {
                    $ap = unserialize( $apj);
                    foreach( $ap as $apv)
                        echo "Database: $adb >>> $apv\n";
                }
            }
        }
    }
}

mysql_close( $db);
?>
The output of this script is a list of all active plugins, one for each line, so it can be used in a shell script, for example one can find out how many of them are active:
php show_all_active_plugins.php | wc -l
or find out which blogs are using a certain plugin:
php show_all_active_plugins.php | grep akismet

Disclaimer: as usual, this script works for my setup and, for this reason, I'm sharing it here for everyone interested. I hope it will work for anyone else who tries it, but I cannot guarantee it for every possible situation.

2011/07/12

How to share an article from Google Reader to Google+

Just a quick tip for every Google Reader user who needs to share an interesting article with one or more of her Google+ Circles.

Given that we have the Google+ share box on the top-right corner of GReader, the simplest way I've found is:
  1. grab the URL of the article, by right-clicking on its title and select "Copy link location"
  2. click at the "Share" box (at the top-right corner of the window)
  3. click at the chain icon ("Add link") and paste the copied URL there; press the "Add" button
  4. select the people or circles you want to share it with
  5. if you want, you can comment on the text-box above the link
  6. click at the "Share" button

2011/07/05

CRON error: grandchild failed with exit status 1 [Solution]

Just after I upgraded my Ubuntu to 10.10 version, I noticed some cron-related error messages in my /var/log/syslog file, like these:

Jul  5 13:40:01 agriope2 CRON[971]: (CRON) error (grandchild #974 failed with exit status 1)
Jul  5 13:50:01 agriope2 CRON[7775]: (CRON) error (grandchild #7778 failed with exit status 1)
Jul  5 14:00:01 agriope2 CRON[14520]: (CRON) error (grandchild #14526 failed with exit status 1)
Jul  5 14:00:01 agriope2 CRON[14521]: (CRON) error (grandchild #14531 failed with exit status 1)


At first, I thought they were generated by one of my scripts, which runs via cron every 10 minutes and I wondered what happened during upgrade that caused its exit status to turn to 1 instead of 0. Unfortunately, I didn't had the time to delve deeper back then and I ignored it, since everything seemed to work as expected.

Until today, when (after one more successful system upgrade in the meantime) I decided to examine it further.
Given that nothing has changed into my script, I thought that it would be a good idea to search into /etc/cron* directories and there I found that there was the script /etc/cron.d/update-motd, which was scheduled to run every 10 minutes and tried to run /usr/sbin/update-motd. The problem is that /usr/sbin/update-motd was not present any more at its whereabouts, probably because "the functionality formerly provided by update-motd package is now integrated into pam_motd, in libpam-modules" (as the description of update-motd package says).

So, I moved /etc/cron.d/update-motd to another location, just in case I will need it again some time in the future.


Update [2011/12/25]:
In case you are running fetchmail from cron, you 'll have messages like the above whenever you have no new mail. For this situation, the solution is already in the man page of fetchmail:
If you do not want "no mail" to be an error condition (for instance, for cron jobs), use a POSIX-compliant shell and add

              || [ $? -eq 1 ]
to  the  end  of  the  fetchmail command line, note that this leaves 0 untouched, maps 1 to 0, and maps all other codes to 1. See also item #C8 in the FAQ.