category archive: tech

Trying out Chrome as a Replacement for Firefox (Ubuntu 10.04)

I’m a big fan of Firefox and the Mozilla Foundation as a beacon of free software goodness, but its memory management issues have driven me to try out Google’s Chrome browser. I’m liking it a lot. When it first came out, there were a lot of behaviors and missing features that ruled it out for me, but it has come around.

Memory Usage

To be fair to Firefox, maybe my extensions are to blame, but whatever the cause, it will steadily chew up memory and slow down until I’m forced to restart the thing every few days, which is a pain when you have all your windows arranged just so and 10-50 tabs open across multiple instances.

It would be okay up to about a gigabyte of memory usage, but then things started bogging down more and more as it approached …

Ad Location in Google Custom Search Engine (Problems and Solutions)

I got an email from Google warning me to upgrade to their Custom Search Engine (CSE) on my site because the old site search I was using is going away. I’m using Google’s “AdSense for search,” where you can display search results on your own site using an iframe. To get this convenience and nifty feature, you have to accept Google ads as part of the bargain.

I ran into a couple of issues while making the changes and thought it might be helpful to share what I learned for future searchers. I’m using WordPress, but this isn’t a WordPress-specific issue.

Problems

The form for generating the search engine and associated html/javascript code won’t let you enter “width of the results area” less than 795. Which is a problem when my main content (and search results) column is only 550 pixels …

Easy binary/decimal (denary) conversions in Python 2.6+

In searching how to do conversions recently, I found some nice code for this, using bit shifting: [...] But then I learned there is now a built-in bin function included in 2.6: [...] And now in 2.6, the binary literal (0b) removes the need for a function at all: [...] I was interested to find Guido Van Rossum’s comment opposed to a bin function, from a 2006 posting: [...] Which is sensible, but I still like having the bin function and I’m glad they added it anyway.

arranging windows from the gnu/linux command line with wmctrl

A reboot of my computer recently caused me several hours of work. Nothing went wrong; the machine and Ubuntu started fine. No, I had to spend the time to save time. I was just trying to make things easier and more efficient, you see.

I rarely restart my home computer. If an occasional software update wants me to do it, I mentally cringe because it will mean several minutes of starting and arranging windows. I always have a collection of terminal, editor, and browser windows open and arranged just so. Things are coordinated between left and right monitor and a double-decker taskbar list. I can quickly move between windows and have everything lined up conveniently side by side and top and bottom, and all is well with the world. But then comes the reboot.

More frequently there is the need …

WordPress Plugin: Post Revision Display

I guess July is WordPress plugin month here at movingtofreedom.org, because here comes another one. This one was instigated by another Scott.

Scott Rosenberg wrote last week about the “mutability of online content” and the challenges news organizations face in handling changes and corrections to stories, and concluded that versioning made sense in journalism as a way to build trust. Readers can see all of the changes since publication so that there’s no sense of something being swept under the rug. The Drupal CMS has modules for making revisions publicly viewable, and of course this is a key feature of Wikipedia.

Scott noted that WordPress already stores revisions, and suggested a plugin could make old versions accessible to visitors. Looking to demo the idea on his blog, he later asked if any WordPress developers …

WordPress Plugin: The French Archives

The French are a fine people, but you should be aware that this plugin has nothing to do with France or the French.

Month Grid Archive

I wanted to be able to display my monthly archives in a grid:

WordPress Month Grid Archive

With post counts for each month, but wasn’t finding a plugin for it. I did find Rob Marsh’s Compact Archives plugin which gave me a good starting place. (Thanks Rob!)

Along the way, it seemed like it would be nice to have post count totals for each year and a grand total. I think this table gives readers a nice snapshot of posting activity over the years.

It’s simple to use: put the_french_archives.php in your plugin dir, activate it, and put <?php month_grid_archive(); ?> in your template file.

You can optionally specify the month header …

WordPress Plugin, YARQ v3.0: Yet Another Random Quote

This is a plugin/widget to show random quotes on your blog. Frank van den Brink originally created it and Christian Beer has also contributed. The wordpress.org homepage is here: Yet Another Random Quote.

I like this plugin, even if very few people around here can be bothered to actually click on a link to see my random quotes. Really, it’s okay. It’s just fine if you care not one bit about my collected pearls of wit, wisdom, and pop culture ephemera. (You probably won’t care to read my old YARQ post either.)

It appeared that the plugin hadn’t been actively maintained, but through the miracle of free software I was able to make my own fixes and enhancements, and now I can share them with you and the world. (And I did get in contact with …

findr: a GNU/Unix ‘find’ helper

I’ve been more aggressive lately about creating helper scripts and aliases for common tasks, and I liked this find helper enough to want to share it. I find that I often do filename searches like this:

find -iname “*some_word*”

That’s not so bad to type, but why not make it even easier for my, and maybe your common usage? We might prefer to do something like this:

findr some_word

And assume that we’re looking for a case-insensitive, substring match. And since we love regular expressions, we can work with find’s regex options:

–regextype posix-egrep -iregex

Which is just begging for a helper to do the work for us in standard situations.

Before we look at the script and some examples, here are a few more considerations for our findr command:

With the -iregex option, the match is against …

Python Sequence Generator

Updated, 11 December 2010

Here’s some code to generate an arbitrary unique sequence of any combination of numbers, letters, or any character other than whitespace. (See also “Old Post” below for more on the what and why.)

I turned this into a class that implements the iterator protocol, and added a unit test module. I may have went overboard with the unit testing, but I looked at it as a learning exercise, and it’s kind of rewarding in a deep and meaningful way to be able to press a button and put a module through its paces. Final code counts:

sequence_generator.py180 lines
sequence_generator_test.py317 lines

The code is now released with the GNU GPL license v3:

sequence_generator.tgz (16K)

It’s written for Python 2.6, but I ran the files through the 2to3 tool with an eye to an easy conversion to Python 3.

The constructor takes …

Python CSS Shrinker for WordPress

This isn’t really specific to WordPress, but it preserves the first comment for WordPress theme management, WordPress is awesome, and I’m specifically using this for WordPress style sheets, so I’m making the connection.

I wrote this script to condense my style sheets into smaller files for faster download times. I’m all about customer service here.

And it’s pleasing to me to distill the CSS into a purer essence and reduce network overhead. (Not that the throngs of visitors to this site are noticeably plugging the tubes.)

One benefit of using compression this way is that I can be more liberal in my stylesheet comments, knowing they won’t burden the “production” .css file delivered to my patrons.

I didn’t go for maximum shrinkage, but this provides sufficient minification for my tastes. Read below for additional commentary and …