HOWTO count words in JavaScript

Here is a handy JavaScript function for counting words: String.prototype.countWords = function(value) { // remove html tags var cleanedText = this.replace(/< .[^]*?>/g, ' ') // remove numbers and punctuation .replace(/[–—.(),;:!?%#$‘’“”'"_+=\/\-]*/g, '') // remove/coalesce space chars .replace(/(&nbsp;|&#160;|[ ])+/gi, ' '); // don't split "" into words, as you'll get 1 ([""]) if (cleanedText === "") { …

HOWTO set up IMAP email for Yahoo

A few weeks ago, I was helping my cousins set up their new iMac. Once everything was up and running, she inquired about adding their Yahoo account to Mail. The conventional wisdom says you can’t do this. Yahoo charges for POP access. IMAP? Unavailable. But then she hands me her new iPod touch…with her Yahoo …

HOWTO setup multistage deployment with Capistrano

These instructions are outdated. They were written for Capistrano 2.x. As of March 2016, Capistrano 3.x is current. When I wrote about deploying PHP sites with Capistrano, step 6 was a bit of a throwaway — hey, here's a quick hack for handling multistage deployment. I'd been using variants of that technique for quite some …

Fixing iChat Google Talk login failures

I was helping a friend set up her new iBook MacBook yesterday, and we were unable to get iChat to log in to her Google Talk account. We kept seeing this error: iChat can’t log in to talk.google.com because your login ID or password is incorrect. And this XMPP error was logged to Console: iChatAgent[33567] …

WordPress batch upgrade

If you run a web server and have multiple installations of WordPress, upgrading them all is a pain. Wouldn’t it be nice if you could update a dozen WP installs at once? Wouldn’t it be even better if you could update the Akismet plugin at the same time? (WordPress releases independently of Akimset, and their …

How to solve the “undefined method `deep_symbolize_keys’ for nil:NilClass” error in Rails

I was trying to migrate a table in my Rails app and got this error: undefined method `deep_symbolize_keys’ for nil:NilClass It’s a strange error, and there weren’t very many hits on Google. A lighthouse ticket provided a clue. The problem wasn’t one of my plugins or gems — it was i18n itself. Upgrading from 0.4.1 …

HOWTO install the rjb gem on Ubuntu and Mac OS X

Here’s how to install the Ruby Java Bridge (rjb) gem on Ubuntu Linux and Mac OS X: Ubuntu Linux (10.10) # aptitude install openjdk-6-jre-headless openjdk-6-jdk # JAVA_HOME=/usr/lib/jvm/java-6-openjdk gem install rjb Mac OS X 10.6.4 # JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home gem install rjb Note: rjb 1.3.2 requires the Java for Mac OS X 10.6 Update 3 Developer Package. If …