Microformats for WordPress Blogs

Looking to use the blog microformat with a WordPress theme?  They’re a step ahead of you, Twenty Ten already uses them.  Now for HTML5…

Enhanced by Zemanta
Advertisements

Performance overhead of using plugins and includes in WordPress

Modularity requires additional overhead.  That’s just the way it is.  If you want to semantically separate different components of your web app or theme, you have to include files, run safety checks (e.g., include_once), extend components that you only use 20% of, etc.

WordPress encourages this behaviour, if you have plugins that only effect your admin panel, the files still get included and the actions and filters still get included, the functions are still defined, for every frontend visitor page render — but they are only called into action when you’re on the backend of your site.

And lately when coding for WordPress, I’ve come to embrace and accept that it wants me to be modular and extend.   Continue reading Performance overhead of using plugins and includes in WordPress

Hosted YUI 3 CSS – Combine or Not?

Savage Chickens - Hamlet

I really really like YUI’s CSS ResetBase, and Fonts for creating a “blank slate” for new designs.  Grids, not as much — mostly I don’t find the naming conventions to be intuitive, so while they kind of make it easier to get the results I want, maintaining it is a chore and feels like work.  But I digress.

A discussion we’ve had at work a few times: should we use Google’s hosted jQuery?  (Here’s my answer.)  So I wanted to know, what about using Yahoo’s CDN -hosted YUI CSS libraries?   Continue reading Hosted YUI 3 CSS – Combine or Not?

Starting and stopping NginX / MySQL / PHP-FPM on Mac OS X

Keeping up with my local dev environment, a while back I wrote a post on Starting and stopping NginX-MySQL-PHP-FCGI on Mac OS X.  I’ve made some changes since then, and I now use a slightly different stack.

I modified MacPorts to configure PHP5 with FPM support, and added in Memcached (also Varnish, but we don’t use that at work and I haven’t been inclined to mess with it, so it’s not in my script).
Script source and changelog after the break…

Starting and stopping NginX-MySQL-PHP-FCGI on Mac OS X

As these things go, it’s super easy to get a LEMP stack up and running on Mac OS X 10.6 (Snow Leopard).  Although at that point I guess it’s a MNMP stack, but that’s an even more ridiculous mnemonic.

Starting up and shutting down each individual service, however, is a pain in the butt.  Sure, 3 services doesn’t sound like a lot now but wait until your 12th configuration tweak in the course of a few hours.  Sure, every tutorial out there has a copy-and-paste-service-script-that-only-needs-a-few-tweaks-to-get-up-and-running-on-your-system.  Forget that; I just want to sudo port install nginx mysql-server php-fcgi and rock’n’roll, bitch.

I don’t want these things running all the time, so forget setting them as startup items.  And I don’t really have the patience to make or tweak service scripts.

So here’s what I do

Helper class for Zend Framework apps

Maybe it’s because I got my ZF start from Magento, but I’m enamoured with having a static class full of global helper methods.

For example:

/**
* Get the user's real IP address through proxies
*
* @return string
*/
public static function getIpAddress() {
    // Gets the user's real IP address
    if ( isset($_SERVER['HTTP_X_FORWARDED_FOR']) && !empty($_SERVER['HTTP_X_FORWARDED_FOR']) ) {
        $ips = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
        return trim($ips[count($ips) - 1]);
    } elseif ( isset($_SERVER['HTTP_CLIENT_IP']) && !empty($_SERVER['HTTP_CLIENT_IP']) ) {
        return $_SERVER['HTTP_CLIENT_IP'];
    }
    return $_SERVER['REMOTE_ADDR'];
}

Implementation and more examples behind the cut

Case-insensitive module URLs in Zend Framework routes

I started creating modules for my application using the CamelCase module names, as I interpreted the standard ZF syntax (ex. /path/to/app/root/application/modules/User/controllers/).  Then I realised this made my urls case-sensitive as well (ex., http://www.example.com/User/).

Uppercase/CamelCase module names still make more sense to me, since the class names inherit the case.  If I used lowercase module names (ex., modules/user/) then my classnames would also be lowercase (ex., user_Model_Name) which really seems funny to me.

So I opted to make a front controller plugin to handle the conversion for me, thus making module names in the URL inherently case-insensitive.   Continue reading Case-insensitive module URLs in Zend Framework routes

Intense Debate vs. Disqus

Image representing IntenseDebate as depicted i...
Image via CrunchBase

I had the, er, privilege of spending a couple hours today comparing Intense Debate to Disqus.  This kind of thing has been covered around the web, but I just couldn’t find all the answers I needed for my particular purpose.  I ended up taking a short test drive of them both, and as you see I already use Intense Debate here on my blog.  Funny enough I found the answers to most of my questions looking under “Support” on their sites and then clicking around.

Feature-wise, they’re nearly identical.  The only real differences:

  • Intense Debate is owned by Automattic, the company behind WordPress.  Therefore they have a lot of experience to draw from, a proven talent pool and track record, and intimate knowledge of our blogging platform.  Disqus is a Y-Combinator startup, the entire team seems to have gone straight from college to founding this company.
  • Disqus has some kind of a VIP program that includes the ability to skin the Disqus comments like your site, more advanced filtering tools for comments, support, and a service guarantee.  I could not find a similar program for Intense Debate.
  • Disqus has native integration with multiple platforms (WordPress, Movable Type, and a bunch of others).  Intense Debate has native integration with WordPress and a “generic install” that you can add to any page (whether it’s a blog or not).

We had a few specific concerns and needs that we wanted to make sure were addressed.

  1. Integration with Facebook, Twitter
  2. Realtime updates
  3. User profiles (ability to see a user’s history, ideally helps prevent users from masquerading as other people)
  4. Stay in control of our data (don’t lose comments if we leave the service later)
  5. Keep data in sync — edits to comments in WordPress should propagate the edit to the comment service, and vise-versa
  6. Needs graceful fallback in case the service goes down

So how did Intense Debate and Disqus fare?

MySQL error: Manager of pid-file quit without updating file.

So I was working at home over the weekend using MySQL on my MacBook running OS X 10.6 (Snow Leopard), put my computer to sleep then came in to the office this morning and opened it back up.

At one point I had to restart MySQL (which up to this point was running fine), and received this error:

$ sudo /opt/local/share/mysql5/mysql/mysql.server start
Starting MySQL
.................................................................
ERROR! Manager of pid-file quit without updating file.

Continue reading MySQL error: Manager of pid-file quit without updating file.