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

OmniGraffle’s stencil library at Graffletopia.com

I reluctantly bought a copy of OmniGraffle for Mac some weeks back, purely to do some updates to diagrams originally created with Visio on Windows (which is not available for Mac). At first, I thought the selection pre-made images (stencils to use their technology) was quite poor and very much lacking from those available for Visio. However, that was before I discovered Graffletopia.

Nice, very nice!

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.

Recovering an Amazon instance with a corrupted SSH configuration

One of our test Amazon EC2 instances decided to go for a holiday last week (reason still under investigation), and as part of the attempted recovery process we tried the eventual obligatory “system reboot”. Unfortunately, this failed to fix the problem, and we then also discovered that an unsupported setting previously added to the OpenSSH configuration (/etc/ssh/sshd_config) actually prevented the SSH daemon from starting at all (we found this out from “View System Log” option in the AWS Management Console).

In any case, as you may know, SSH is pretty much the only way to gain administrative access to an Amazon instance (there is no Unix/Serial console or Remote Desktop to speak of), so if you mess up your SSH configuration, you really are in big trouble!

Actually, that’s not entirely true. As it happens, if your instance is EBS-backed (i.e. uses an EBS volume for its root/system partition), you can actually detach the root partition from the broken instance, attach and mount it on another running instance, fix the erroneous configuration setting, re-attach to the broken instance, and reboot again. Voila, Problem solved!

This is all very reminiscent of that call from a family member saying their computer won’t boot any more, whereupon you remove their hard disk and insert it as a second drive in your own PC in order to get a copy of all the files they invariably haven’t backed up.

For the record we found the solution on the Amazon Forums, and also uncovered another useful command in the process:

sshd -t

Very much like the “apachectl -t” command, this will syntax-check your SSH configuration files for you. You should run this command every time you make a change to your SSH configuration settings.

Samsung Galaxy Tab: First Thoughts

I got the opportunity to borrow a brand new Samsung Galaxy Tab for a day this week. Nice!

The extra screen real estate really make a lot of difference when you’re trying to stay in contact with the office, and I setting up my Google account on it was a complete breeze (as it us on it’s aby brother, the Galaxy S). The absence of the physical buttons across the bottom on the front screen took a little getting used to but the power button on the side began to work better for me as the day wore on. They’ve also put a little more thought into the quick access icons which are easier to use.

Samsung Galaxy Tab

If I had any criticism really, it would be that removing my Google account settings from the device after I was finished with it was not very straightforward. In fact I had to do a complete factory reset of the device to do so, losing all the installed apps and configuration settings in the process. Now I know there are ways to speed us the recovery process here (AppBrain, for example) and that it’s probably not a very common thing to want to do with a portable device (certainly not with a mobile phone).

However, the increased screen size on this tab (and other pads) might tempt some small companies to buy a shared one for ad-hoc travelling employees to share, so perhaps it’s not that unreasonable after all.

In any case, it’s a really great device and did exactly what I needed it to on the day.

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

Hyperlinks to external URLs in Redmine

This one had caught me out on more than one occasion recently, and it relates to adding links to external websites to issues (Wiki posts) in the Redmine issue tracking system. The syntax used to cite links to other pages on the same site seems reasonably straightforward (and largely standard):

[[Some Text|Some_Other_Page]]

However, to insert a hyperlink to an external website, you need to do the following:

"SomeText":http://www.example.com

To be clear, you need to add double-quotes around the text, then insert a colon between the closing quotes and the hyper link (with no spaces in between). I kid you not!

Source: Redmine Wiki Formatting

Using Spark IM client with Google Apps

I’ve been using the Spark IM client for a number of years now and, whilst it has not been updated for quite some time, it still does the job I need it to. I recently helped a friend move to Google Apps on one of their domains, but who also happened to be a Spark user. Setting up a Gmail account in Spark is reasonably well documented but there are some subtle differences in this setup when it comes to Google Apps accounts.

So here is how to configure Spark IM to work with a Google Apps account (taking fred@example.com as the use case).

  1. On the main Spark login page, enter the following details:
    • Username: fred
    • Password: *****
    • Server: example.com
  2. Then click the Advanced button:
    • Uncheck the “Automatically discover host and port” option, and enter
    • Host: talk.google.com
    • Port: 5223
    • Tick the “Use OLD SSL port method”
  3. Click OK and login in as normal

The only slightly odd part is that, for most other things, your username is the full fred@example.com but in Spark (and some other IM clients), you need to split this apart and use the domain portion as the server name instead. It may not be perfect but this is what worked for me!