
I’ve come across a few articles on how to optimize WordPress performance (all of the following links come from the first linked story in the list below):
WordPress is by far my favorite content management system, but I opted to use Movable Type over at Born Geek, mainly because it uses static HTML pages (which load faster). Considering the content in the above guides, I may eventually switch from Movable Type to WordPress.
Taking a screenshot of an application is a simple task: the “Print Screen” key can be used alone (to grab the entire screen), or one can use the “Alt + Print Screen” key combination to take a snapshot of only the active window. But taking a screenshot of the active window, while an application menu is opened, is a little tougher. Sure you could use a third-party solution to do it, but suppose you don’t want to (or cannot) use such a tool. What is one to do?
One option, which isn’t very appealing, is to take a screenshot of the entire screen (using the “Print Screen” key) and then crop out the active window using some image editor. Again, this involves using a third-party application to do the cropping (although Microsoft Paint can be used to some minimal effect).
The better answer, as I accidentally discovered myself, is very simple. Any application worth its salt uses keyboard accelerators (access keys, to be exact) to allow keyboard users to access application menus. The problem is that most applications make use of the “Alt” key to invoke these access keys. For example, “Alt + F” in Windows Explorer will open the File menu. Suppose I want to take a screenshot of a highlighted menu item within the File menu. If I open the menu and press “Alt + Print Screen” to take the screenshot, the menu is dismissed, since the application thinks I’m trying to invoke another menu. But we can work around this limitation!
Voila! An active-window screenshot with a highlighted menu item, using no third-party application. Here’s an example:

While working on my photo album software, I ran into an interesting SQL problem. I wanted to be able to display information about my photo albums, along with the number of images in each album. The problem is that my data is broken up into two tables: an albums table and an images table. My goal was to use exactly one SQL query to access all of the data, including the count of images. And I wanted empty albums (no images) to also show up in the query’s results. But try as I might, I couldn’t get the query to return the data I wanted. I finally found a solution that works, and I present an example below.
Let’s suppose we have two MySQL tables: one that represents directories, and another that represents files. The directories table has the following columns:
And the files table has the following columns:
The Parent_ID field in the files table corresponds to the ID field in the directories table. In order to select both the count of files in each directory, as well as all of the directory information, we do a simple join. But here’s the trick: the order of your tables matters! Here’s the query that works for this scenario:
SELECT d.*, Count(f.ID) AS Count FROM directories d LEFT JOIN files f ON f.Parent_ID = d.ID GROUP BY d.ID
When the tables are reversed in the JOIN, only tables with 1 or more entries show up in the results. What a subtle change! Hopefully someone will find this tip useful. It sure took me a while to get this working.
Here’s a handy tip for all you WordPress 2.x users out there. The inline uploading feature of the “Write Post” administration page was completely useless to me. I never have, nor will I ever, upload files to my web server using the WordPress interface (that’s what we have SCP and SFTP for). What irritated me most, however, was that I couldn’t turn this feature off, thereby hiding the iframe that contained the uploading controls. It took up a large amount of space on the admin page, and it looked ugly. But I’ve figured out how to “disable” it. Here’s what I did:
In the wp-admin/ folder, I opened up the file named edit-form-advanced.php. Doing a search for the word upload yielded a block of code controlled by the following conditional expression:
if(current_user_can('upload_files'))
I simply commented out this block (including the conditional) with some c-style comments. I did the exact same thing for the edit-page-form.php file. VoilĂ : no more inline upload! I’m so glad I’ve been able to reclaim that wasted screen real estate.
After graduating from school with a bachelor’s degree of computer science, I must admit that I knew virtually nothing about developing *NIX based applications (that’s UNIX / Linux based applications for the non-geeks out there). Granted, I did do a little bit of non-Windows based programming while in school, but it was always incredibly basic stuff: compiling one or two source files, or occasionally writing a make-file for larger projects (three or four source files). Having never had a Linux or UNIX box to play with outside of school, I just never got a chance to get my feet wet. Thankfully, my job at IBM has changed that.
Over the past few weeks, I’ve been doing a great deal of Linux programming, thanks to the cross-”platformedness” of one of the projects I’m working on. And this project is way more complicated than your typical school assignment. I’m now horsing around dynamically linked libraries, also known as “shared objects” in Linux land, like nobody’s business. Not only that, the project itself is essentially a multi-threaded shared object, making it all the more exciting. I’ve learned more about g++, ld, and ldd in the past few weeks than I ever knew before.
Unfortunately, debugging multi-threaded shared objects is easier said than done. The debugging tools in Linux (at least the ones I’ve played with) all suck so horribly. They make you really appreciate the level of quality in Microsoft’s Visual Studio debugger, or better yet, in WinDBG (this thing is hard core, and it’s what the MS developers actually use in practice). Fortunately, printf() always saves the day.
One cool trick I recently employed to debug a library loading problem I was having, is the LD_DEBUG environment variable. If you set LD_DEBUG to a value of versions, the Linux dynamic linker will print all of the version dependencies for each library used for a given command. If you have a Linux box, try it out. Set the LD_DEBUG environment variable, then do an ls. You’ll be amazed at the number of libraries that such a simple command involves.
Although Linux development can be frustrating at times, I’ve already learned a great deal and consider my experiences a great success. If I come across any more useful tips (like LD_DEBUG above), I’ll try my best to post them here (as much for my sake as for yours). Until then, you’ll find me knee-deep in my Linux code. I’ve got a few more bugs to squash.
Here’s a small but handy Firefox tip for “safekeeping” your bookmarks. It also lets you share your bookmarks across multiple profiles!
You can use this trick in multiple profiles, allowing them to all point to the same bookmarks file. Additionally, it helps to safeguard against possibly losing your bookmarks if your profile becomes corrupt.
The “Open Command Window Here” power toy for Windows XP is an excellent tool that I use all the time. I run Windows 2000 at work, however, so I don’t have access to this excellent computer aid. But I recently found this article, which discusses how to add the feature to any flavor of Windows. Method number 3 was my preferred choice, and I will reproduce the steps I took below.
Once you perform the above steps, you’ll be able to right click a folder and select the “Command Prompt” menu item to open a command window. How cool is that?