How-to

PDF to OCR in Linux

SWMBO has a pile of PDF documents to process and extract information from, and over 50 of them are scanned which means -- NO COPY/PASTE! Unless we rescan with OCR of course. On Windows, she'd probably just use Acrobat, but on Linux...

eAccelerator and PHP closures don’t mix

I struck an odd problem recently with some code using closures. I use closures extensively for WordPress filter and action hooks when building custom plugins and themes for websites, and all usually works well on any version of PHP from 5.3 up. But I was finding that my closures weren't being called on some PHP 5.4 websites. The problem was eAccelerator.

Overview of building custom fields for Gravity Forms

Gravity Forms is a great way to build all sorts of forms in WordPress. It can be so simple that non-programmers can easily build their own basic forms. It's also incredibly flexible so programmers can extend it in myriad ways, even by adding some complex custom fields of their own. But as usual, there's a trade-off -- ease of use for non-programmers means lots of hoops to jump for programmers. Here's an overview of how I built some fairly complex compound fields for a custom application using Gravity Forms.

Stop turning off CURLOPT_SSL_VERIFYPEER and fix your PHP config

As Pádraic Brady points out in a recent article about PHP security, there's a whole lot of misinformation about how to deal with the error "SSL certificate problem, verify that the CA cert is OK" from curl. Nearly everyone advises that you turn CURLOPT_SSL_VERIFYPEER off (in fact, countless comments on the PHP manual page for curl_setopt tell you this). This is bad, because it allows your nice, encrypted stream of confidential data to be silently highjacked by a bad guy. Don't do that! Instead, just fix your PHP installation so that it doesn't get that error.

Different thumbnail sizes for NextGEN Galleries

Ok, so we're allowed to have one (1) size option for thumbnails in all galleries, and they can be either cropped square, or not. This is my only option? But what if I want to have a gallery page of all of the lovely staff for my clients website, and their photos have been sensibly taken in portrait format, I do NOT want the thumbnails for this gallery to be cropped, that would be just wrong. And then there is to be a page with a photo gallery of the staff picnic where people have enjoyed taking happy snaps in both landscape AND portrait formats because that is what suits, so I need these thumbnails cropped.

Running QEMU with port redirection through libvirt

Like many developers these days, I use a bunch of different virtual machine images to give me access to multiple development and test environments without having a room full of computers. My VM of choice is QEMU KVM, the kernel-based virtual machine bundled with Fedora. I've always used simple shell scripts to start my VMs, which has allowed me great flexibility, but yesterday I set one up using the nice Virtual Machine Manager (VMM) GUI application. And remembered why I wasn't using it: there's no way to tell it how to do TCP port redirection! But now, there is a way...