I used to think that the hardest part of scaling a website from one webserver to two webservers was sharing the sessions between the machines to keep the users logged in whichever machine they were served by. I was pleasantly surprized that it is possible to accomplish sharing sessions between two servers by changing only 5 lines in the php.ini file (the session.save_handler and session.save_path).

Here is a solution for RHEL 5.5:

Read on…

Wordpress Logo

In WordPress 3.0, my WordPress logo image (on the left) broke. So I opened a bug and six weeks and 100 bug comments later, I have upgraded to 3.01 and it is working again. Thanks guys!

The reason why the logo image was broken was quite interesting(?)… In v3.0 WordPress automatically started auto-correcting Wordpress to WordPress (i.e. Word-lowercase-p-ress to Word-uppercase-P-ress) and because my image file name was called “WordpressLogo_blue-m.png”, the auto-correction was breaking the link. Auto-correction shouldn’t cause links to break and it seems that v3.01 fixes it.

The filter function that does this auto-correction is called “capital_P_dangit” – The WordPress guys are obviously pretty frustrated by this spelling mistake!

Old filter (v3.0):

function capital_P_dangit( $text ) {
       return str_replace( 'Wordpress', 'WordPress', $text );
}

New filter (v3.01):

function capital_P_dangit( $text ) {
        // Simple replacement for titles
        if ( 'the_title' === current_filter() )
                return str_replace( 'Wordpress', 'WordPress', $text );
        // Still here? Use the more judicious replacement
        static $dblq = false;
        if ( false === $dblq )
                $dblq = _x('“', 'opening curly quote');
        return str_replace(
                array( ' WordPress', '‘Wordpress', $dblq . 'Wordpress', '>Wordpress', '(WordPress' ),
                array( ' WordPress', '‘WordPress', $dblq . 'WordPress', '>WordPress', '(WordPress' ),
        $text );
}

Screenshot of problem with too big tag

On this WordPress theme, the sidebar is quite small (only 220px) and the default WordPress tag cloud widget was producing tags that were clipped in a ugly manner. By default, the WordPress tag cloud widget has a maximum font size of 22px so I was looking for a way to reduce it.

Note: If you are not a theme editor, you might find it easier to just install a suitable tag cloud plugin, e.g. Configurable Tag Cloud (CTC).

The WordPress tag cloud widget already allows you to specify various options including the largest font size, e.g. <?php wp_tag_cloud('largest=18'); ?> so we only need to create a new widget that overrides the default widget and then unregister the default widget so there aren’t two widgets with the same name in the “Available Widgets” dashboard page. We can register our own widget using register_sidebar_widget and we can unregister the default tag cloud widget using unregister_widget('WP_Widget_Tag_Cloud');.

This is the code you need – put it in the functions.php file in your WordPress theme folder:

add_action("widgets_init", array('Tag_cloud_withLimitedFontSize', 'register'));

/** Widget - Override the default WordPress tag cloud BUT cap the largest font size to 18 (instead of 22)\
 because at 22 some tags don't fit in the sidebar. */
class Tag_cloud_withLimitedFontSize
{
  function widget($args){
    echo $args['before_widget'];
    echo $args['before_title'] . 'Tags' . $args['after_title'];
    echo wp_tag_cloud('largest=18');
    echo $args['after_widget'];
  }

  function register()
  {
    register_sidebar_widget('Tag Cloud', array('Tag_cloud_withLimitedFontSize', 'widget'));
    unregister_widget('WP_Widget_Tag_Cloud');
  }
}

If there’s a better way to do this, please let me know.

Microchip as a bug

A website that I was working on suddenly started crashing Firefox 3.6 on my PC (Ubuntu 9.10, 64bit). I’m talking a full out hang with 100% CPU usage and a frozen mouse and keyboard and the only way to recover is to remote login from a 2nd PC and kill the Firefox process.

I found the cause of the crash and it was a single line of recently added CSS code at the top of the websites stylesheet: body { opacity: 0.9999; }

So, if you run a website, be careful of non-100% opacity when it affects many elements. I have hosted a page that reproduces the issue and found a bug that tracks the issue: #279890. This CSS is also a problem on Windows – it causes text to blur horribly in IE 7 in some situations.

What is that CSS for anyway? Firefox 2.0 on Macs used to have a problem where text could dim or get bold or flicker when a animated effect that changed the opacity of an element was used. It was caused because the use of a opacity filter triggered the Gecko rendering engine to switch from the operating system’s method of anti-aliasing to its own internal method. Whenever opacity dropped below 100% the mode switched and resulted in a defect such as a flicker or blink. The fix was simple – all that was needed was to add body { -moz-opacity: 0.9999; } to the stylesheet because it would force Firefox to use a consistent text rendering method.

Hack == Bug

Wordpress LogoA typical use case for a hidden page might be so you can store your website licensing agreement or image attribution links without having it explicitly in the main navigation links – most folk link to their licensing agreement in the footer.

If you want to have a page on your self-hosted WordPress website that is accessible via a URL but not directly linked or advertised on the site, you have several options:

  1. Use a plugin such as “Exclude Pages“.
  2. If your pages are displayed via a sidebar widget, you can go to the widget settings page in the WordPress admin section and use the “exclude” field to hide a page ID.
  3. Save the page as a “draft” but never publish it. Even though it’s not live, you can still access the page if you type the direct URL to the page. e.g. http://yourblogurl/?page_id=69.
  4. Modify the wp_list_pages function in your current theme:
    • If you know you don’t use any sub-pages on your site, you can hide any page you want by making it a sub-page of the homepage and then display your menu using: <?php wp_list_pages('depth=1'); ?>
    • To exclude a page with id 69, use: <?php wp_list_pages('exclude=69' ); ?> If you do this you can automatically hide additional pages by making them a sub-page of the hidden page.
  5. Create a new file in the theme directory. It will be accessible via http://yourblogurl/wp-content/themes/yourthemename/yoursecretpage.php. If you want to use regular wordpress functions in the secret page, include the following on line 1: <?php require_once(dirname(__FILE__) . '/../../../wp-blog-header.php'); ?>

Note: WordPress does have a “Private” checkbox that you can tick in the visibility section of the publish options. However, private pages will not be accessible via any URL.

The following list is 10 favourite pieces of software which I’m thankful for every single day:

  1. 10. Meld file difference viewer
  2. 9. JQuery javascript framework
  3. 8. Trac project management platform
  4. 7. MythTV digital video recorder
  5. 6. Gimp image manipulation program (I know this is part of GNU but hey ho)
  6. 5. WordPress publishing platform
  7. 4. Firefox web browser
  8. 3. Ubuntu operating system
  9. 2. Linux kernel
  10. 1. GNU projectGnome Desktop (but also all the rest: e.g. gcc, glibc, gtk, emacs and the GPL)

Butterfree

The hardware behind Bitvolution is called “Butterfree“, he’s based in Germany (www.hetzner.de):

Specs:

  • CPU: Intel® Core™ i7-920 Quadcore incl. Hyper-Threading Technology.
  • RAM: 8 GB DDR3.
  • Disk: 2 x 750 GB SATA II (Software-RAID 1).

Features:

  • LAMP – Full root access.
  • 24h reset service via Web interface
  • 92 GBit bandwidth with unlimited traffic usage (but the connection speed is restricted to 10 MBit/s if more than 2000 GB/month are exceeded).
Ubuntu Logo 200x52

If you have a font file with a “ttf” extension you can easily install it in Ubuntu (v9.04) and use it in applications such as the Gimp. Essentially, all you have to do is drop it in the correct folder:

  1. cd /usr/local/share/fonts
  2. If the truetype/custom directory doesn’t exist already: sudo mkdir truetype sudo mkdir truetype/custom
  3. sudo cp where_you_downloaded_the_new_font/fontname.ttf /usr/local/share/fonts/truetype/custom
  4. sudo chown root.root /usr/local/share/fonts/truetype/custom/fontname.ttf
  5. fc-cache – Otherwise, the font will disappear at the next reboot.

The following text was created in the Gimp: It uses 3 free fonts, the “B” is Heavy Data, the “it” is Sans Bold and the “volution” is Ballpark:

ttf font demo