Jun16
2009

Some clever one-liners that print a neatly organised version of your MySQL configuration file without all the comments:

Perl
$ perl -ne 'm/^([^#][^\s=]+)\s*(=.*|)/ && printf(”%-35s%s\n”, $1, $2)’ /etc/my.cnf

Awk
$ awk '! /^#/ && ! /^$/ {if($1 ~ /^\[/ ){gsub("\[","\n[",$1) };printf("%-35s%s %s\n",$1, $2, $3)}' /etc/my.cnf

Grep
$ egrep -v '^$|^#' /etc/my.cnf

Source: MySQL Performance Blog

Nov25
2008

I’ve always found it a real pain to quickly and easily insert Irish/French/Hungarian (or other) language characters (i.e. vowels with fadas over them) into documents on Microsoft Windows, then let there be pain no more. A simple matter of pressing the Alt Gr key whilst also pressing the desired vowel does the trick very nicely.

I’m sure this may be well known to some/many of you but it was news to me and will save me a good bit of time as a number of colleagues have names with Irish/Foreign letters in them.

Credit goes to John Mernin for alerting me to this.

Nov18
2008

We have a number of Ubuntu Linux systems and I regularly find myself wanting to find out which specific distribution I have installed on a given system. While the trusty uname -a command is useful most of the time, it is unfortunately too generic in this instance and only reports version information about the Linux kernel.

However, today I discovered the lsb_release -a command which does precisely what I want. The description of this command in the man page says:

The lsb_release command provides certain LSB (Linux Standard Base) and distribution-specific information.

Here is a sample of the type of output it provides on a recently installed Ubuntu Server 8.10 system:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 8.10
Release:        8.10
Codename:       intrepid

Nov07
2008

I recently helped a family member to import some archived Microsoft Outlook Express folders from a CD and was aghast at how difficult it was to do, and how disruptive it was to their existing email folder structure. As a non-regular computer user, they expected that simply double-clicking on the relevant (.dbx) files on the CD would automatically open them in Outlook Express. Of course I knew this would not work but to be fair, it is a perfectly reasonable expectation that most casual Windows users would share, and is in fact how it should work. But then again, this is Microsoft we’re dealing with.

Anyway, to cut a long story short, here is how to do it:

  1. Launch Outlook Express and locate the current directory where your mail folders are being stored by selecting Tools, Options, Maintenance tab and clicking on the Store Folder button.
  2. Make a note of the directory listed and exit Outlook Express
  3. Now copy the folders you are trying to import from to this folder (using Windows Explorer or another file manager)
  4. Then delete the file named Folders.dbx from this directory and restart Outlook Express.
  5. Your archived folders should now be available once more but unfortunately, since the file you deleted above was where your folder structure was stored, the structure of your folders will have been lost (flattened) and will have to be re-created by hand.

This is a pretty woeful user experience in my opinion, but if you are really stuck, it does work Thankfully, it is a lot easier in the non-Express versions of Outlook but is such a shame that the lions share of Outlook Express users are those who would benefit more from how Outlook operates.

Oct15
2008

A colleague of mine just sent me this hugely useful MySQL command for seeing which users have privileges in a database, and from which host. It prints a list of other MySQL commands which can then be used to show more precisely what privileges that user has been granted.

SELECT DISTINCT CONCAT('SHOW GRANTS FOR ''',user,'''@''',host,''';') AS query FROM mysql.user;

Prior to this, I found myself having to connect to the database from the appropriate (remote) MySQL client and issue a SHOW GRANTS from there.

Thanks to Mate Racz for this one.