Latest Entries

PHP APC Potential Cache Slam Averted for Key

This server uses PHP 5.3 with PHP-FPM (FastCGI Process Manager) patch and APC opcode cache. Several minutes after activating APC, I noticed that some pages stopped loading. Turns out it was because of an APC timebomb bug which is when all cache writes got locked because of expiring cache entries and new writes happening at the same time. The temporary solution is to add apc.write_lock = 1 in php.ini.

Moving Away from MediaTemple

Excuse the mess while I’m moving away from MediaTemple. It feels so good to be home in Latvia on a speedy VPS.

There is a handy little WordPress feature that I had not used before:

define('RELOCATE', true);

which allows you to set up a temporary domain name while your new name server records are spreading across the internets. For example, if you changed the NS record for example.com, you could use new.otherdomain.com to access the site you’re moving. Normally WordPress would try to redirect you to example.com (which is it’s site_url).

Coincidence

[Y]ou can’t ascribe great cosmic significance to a simple earthly event. Coincidence — that’s all anything ever is. Nothing more than coincidence. [...] There are no miracles. There is no such thing as fate. Nothing is meant to be.

(500) Days of Summer

Notes on the 2010 WordPress Theme

Here are some of my random thoughts after going through the files of the new TwentyTen (2010) theme which will be introduced in WordPress 3.0.

header.php isn’t poetry at all

The content of the <title> should be generated within functions.php by using the wp_title filter, so that plugins and users can overwrite it. In header.php we would have only:

<title><?php wp_title('|', true, 'right'); ?></title>

and in functions.php something like:

add_filter('wp_title', 'twentyten_title', 10, 2);
function twentyten_title($title, $sep) {
	global $post;
	$title = wptexturize($title);
	$page_no = get_query_var('paged');
	if (is_front_page())
		$title = get_bloginfo('title') . ' ' . $sep . ' ' . get_bloginfo('description');
	elseif (!is_feed())
		$title .= ' ' . get_bloginfo('title');
	if ($page_no > 1)
		$title .= ' (page ' . $page_no . ')';
	return $title;
}

Theme’s stylesheet style.css should be loaded after the wp_head() call, so that users can overwrite styles added by the plugins. Read more »

Remove index.html from the URL

Some servers seem to automatically append index.html to all HTTP requests, which you can remove by placing this at the beginning of .htaccess:

RewriteEngine On # remove this, if you have it already
RewriteCond %{REQUEST_URI} index\.html
RewriteRule ^(.*)index\.html$ /$1/ [R=301,L]

I used this technique for a site that I built — ichomesforsale.com which is hosted at Godaddy.

The Magic of Software (Licensing)

Henry Birdseye: “Is it getting to the point where the software is going to cost as much as the machine?”

Unknown: “I think it will get to that, yes.”

Birdseye: “So, if something like that can cost so much. Why not just make your copy?”

Bill Gates: “If you don’t get a legitimate copy, you won’t be… came aware of the improvements, and… overall the impact that type of ripoff is going to have is that people won’t write quality packages.”

Unknown: “It takes time to write software. We haven’t found any way to really reduce that time. It takes time to define the problem. It takes time to write the software.”

Henry Birdseye: “But increasingly, as you begin to (medal?) with the prepackaged things and get a little experience, you just can’t resist the temptation to do some of your own programming. And people are gonna be doing that.”

Bill Gates: “There’s a lot of people who are forcasting that there’ll be software stores just like there are record stores today and that there’ll be thousands and thousands of those, and I think I have to agree with that.”

And yet, 86-DOS — the operating system which Bill Gates, Steve Ballmer and Paul Allen pitched and later licensed to IBM — was actually written by Tim Paterson and called QDOS (Quick and Dirty Operating System). Read more »

The Unspoken Heroes of Web Design

While playing with the typography of this blog, I couldn’t appreciate enough the simplicity and elegance of Tahoma, it’s wider sister Verdana and beauty serif Georgia. All of those fonts were designed by one guy — Matthew Carter, English type designer born 1937, living in Cambridge, Massachusetts, US.

Portrait of Matthew Carter

Matthew Carter

Thomas Rickner

While you have probably heard of Matthew Carter, it’s unlikely that you’ll know Tom Rickner who hinted these fonts making them so easy to read at sizes with very few ink dots available to form their shape and guide the eye.

In the summer of 1994 Microsoft commissioned Carter and Rickner to design a new system font for Windows 95 which we now know as Tahoma. Here is the story of Verdana.

Once you’ll discover where the names of those fonts come from, you’ll never look at them the same way.

Smarter Cleaner Gallery

Justin Tadlock’s Cleaner Gallery plugin fixes the semantics of the WordPress built-in gallery feature by placing all of the gallery related CSS in an external file instead of the inline CSS produced by WordPress core.

However, the problem is that this CSS file is loaded on every page request. Therefore, until WordPress supports combining all CSS files into one, here is a quick way to hide this CSS file on all pages that don’t contain a gallery (line 128 of cleaner-gallery.php):

Note: this will add cleaner-gallery.css only on single post and page views (not indexes or archives).

add_action('wp_head', 'cleaner_gallery_head', 0);
function cleaner_gallery_head() {
	global $post;
	if (strstr($post->post_content, '[gallery'))
		wp_enqueue_style( 'cleaner-gallery', CLEANER_GALLERY_URL . '/cleaner-gallery.css', false, 0.7, 'all' );
}

Hopefully, Justin can incorporate this into the next release of this handy plugin.