Capturing Screen Shots on Mac OS X

I’ve had reason to capture rather a lot of screen shots in recent weeks and find the following Mac keyboard shortcuts very useful:

Shortcut Description
Command-Shift-3 Captures entire desktop (saved as PNG file on desktop)
Command-Ctrl-Shift-3 Copies entire desktop (saved to your paste buffer)
Command-Shift-4 Captures portion of desktop (saved as PNG file on desktop)
Command-Shift-4 + Spacebar Captures current window (saved as PNG file on desktop

There are lots of other variations on the above, which are described nicely  here.

How to reduce the size of a PDF file on a Mac

This one’s been bugging me for several weeks so finally got around to finding a proper solution. Basically, if someone sends you a PDF file with some photos in it, the chances are they didn’t think of reducing the picture quality (in the original document) before creating the PDF. As a result, the PDF file can end up being enormous, for no obvious reason to the reader.

While I managed to find out how to tackle the problem from inside the likes of Microsoft Word (better options in Office 2011), I am often without the original document, so what to do there (on a Mac)?

Well, as it happens, Mac Preview does have a way of doing this which I found out about here, and while it worked well for me (PDF files were mostly text with 2-3 pictures anyway), I have seen comments on the above article questioning the quality of the resulting file. Still, it may work for you too.

HOWTO: Flush DNS cache on Mac OS X

Had some strange behaviour with DNS on Mac OS X earlier today. Made a change inside DNS and waited the required amount of time for the TTLs to expire. Then verified that the new IP address was resolving (using both dig and nslookup).

However, my system was still trying to use the old IP address when I tried a simple ssh or telnet command.

In the end, I discovered how to flush my local DNS cache, which fixed the problem. You can do this as follows:

$ dscacheutil -flushcache

HOWTO: Show a summary of data used by all MySQL tables

Here is a useful MySQL command that shows (an approximation of) the amount of storage (disk and memory) consumed by each table in a MySQL database.

SELECT
 TABLE_NAME,
 TABLE_ROWS,
 DATA_LENGTH / (1024*1024),
 INDEX_LENGTH / (1024*1024),
 (DATA_LENGTH + INDEX_LENGTH) / (1024*1024) as total
FROM
 information_schema.TABLES
WHERE
 TABLE_SCHEMA = (SELECT DATABASE())
GROUP BY
 TABLE_NAME
ORDER BY
 total;

Please bear in mind that the data returned will be an approximation, but should still show you a reasonable enough split which of your tables are consuming most of the resources.

Removing email addresses from Thunderbird’s auto-complete list

Like most email clients, Mozilla Thunderbird has a very useful auto-complete function which allows you to choose from previously-used email addresses when composing a new message. However, removing entries from this list is not as easy (or obvious)  in Thunderbird as it is in Microsoft Outlook, for example, where all you have to do is press the DEL key when the auto-complete list pops up.

Instead, Thunderbird seems to store the auto-completion list in a section of the Address Book called Collected Addresses. To remove an entry you have to:

  1. Click the large Address Book button in the main (Mail Filter) toolbar
  2. Select the Collected Addresses group
  3. Locate and delete the desired addresses from there

Source: mozillaZine Forums

How to insert Irish characters on Microsoft Windows

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.

Ubuntu Distribution Information

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

Recovering archived Outlook Express folders

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.

MySQL Grants List Revealed

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.