Plesk: How many ColdFusion sites?

A customer asked how many ColdFusion sites they had on their Plesk server. Ordinarily, the following query would make this easy to answer:

# mysql psa -e "select count(*) as 'Coldfusion Enabled' from hosting where coldfusion = 'true'"
+--------------------+
| Coldfusion Enabled |
+--------------------+
|                159 |
+--------------------+

In their case, however, they had ColdFusion support enabled for all sites, so we needed to find out how many domains actually had ColdFusion content. Here’s a quick&dirty one-liner:

# find /var/www/vhosts/ -type f | grep -i "\.cfm" | cut -d/ -f5 | sort | uniq | wc -l
   150

Mac OS X Sleep Modes

There are two ways that computers sleep (a.k.a. being suspended). One way is to keep the RAM powered on, and turn the rest of the computer off (suspend to RAM). This allows the computer to wake almost instantly. The disadvantage is that if your computer loses power – say, the battery runs out – you lose your session, and your computer will boot up normally when you turn it on.

The second way is to write the contents of RAM to the hard disc, and turn the computer off completely (suspend to disc). This way you can unplug it or disconnect the battery, and you won’t lose your session. The disadvantage is, it takes longer to sleep and to wake. The more RAM you have, the longer it takes. Current MacBook Pros can have 16GB of memory, which can take a couple of minutes to write to and read from disc.

Recent versions of OS X, at least from 10.5, possibly earlier, ships with its sleep mode configured to do both of the above. This works great! You get fast wake-up times, but if your battery runs out, you don’t lose your session either. On older MacBooks/MacBook Pros this means that you can swap out the battery, and still have your session in tact.

The sleep modes are configured by the ‘hibernatemode’ directive, and you can check yours as follows:

$ pmset -g | grep hibernatemode

	hibernatemode  3

The hibernate modes are as follows:

0: Suspend to RAM. RAM remains powered on while sleeping, safe sleep is disabled, wake is instant.
1: Suspend to disc, a.k.a safe sleep. RAM contents is written to disk, computer shuts down completely. Slower to wake up.
3: RAM is powered on while sleeping, but RAM contents are also written to disk before sleeping.
5: Same as mode 1, but for using secure virtual memory.
7: Same as mode 3, but for using secure virtual memory.

Of course, mode 3 still means that your shiny MacBook is spending a fair bit of time writing to disc every time you close the lid. Even my 2008 vintage MacBook Pro can go about a month in mode 0 or 3 before the (now 5 year old) battery runs out. So for all practical purposes, suspend to disc is completely unnecessary. To set it to 0, do the following:

$ sudo pmset -a hibernatemode 0

Once you’ve set it to 0, you can free up some space by removing the RAM image:

$ sudo rm /var/vm/sleepimage

Konsole and the console font

After doing some updates on my Debian Lenny workstation, I noticed that KDE’s Konsole is no longer able to find the “Console” font, and upon trying to install it, I’m greeted with an error saying:

Could not install console8x16.pcf.gz into fonts:/Personal/

Fortunately, this is easily fixable. As root, run the following:

# dpkg-reconfigure fontconfig-config

Choose the default option to all but the question about bitmap fonts – choose YES here. This will enable support for bitmap fonts. Then do:

# dpkg-reconfigure fontconfig

This will update the font cache. Now restart your Konsole, and your fonts should be back to normal.

Update 2009/03/07:   I had this happen to me again today (did a dist-upgrade to Squeeze) and after running the above fix, only one of the two missing fonts returned.   I found that removing the contents of ~/.fontconfig/ does the trick.

Update 2009/07/25:   I got a new PC at work, and this time did a clean install of Squeeze, which meant getting dumped into KDE4.  Again, the font was missing, and the font installer wouldn’t see the pcf file.  I had to do the above, and then, using the font installer, had to type *.pcf  in the filter field – this installed the font.  I also had to set font anti-aliasing to “enabled” instead of “system settings” in the System Settings panel –> Appearance –> Fonts.