WordPress Automatic Upgrade on NearlyFreeSpeech.NET Hosting

It’s been a long time since I’ve updated this site so I figured I should give it some attention. First on my list was to switch web hosts; the site was loading incredibly slow on a lifetime account at TextDrive (now Joyent). A while ago I set a friend of mine up at NearlyFreeSpeech.NET and they’ve been great so far, not to mention cheap. So I opened an account and transferred my site without any problems.

Then, when I tried to automatically upgrade WordPress (which I hadn’t done in a long time) I got a load of errors. First, I couldn’t get WordPress to connect to my hosting account. I added the code below to wp-config.php and that problem was fixed (which I found here).

define('FS_METHOD', 'direct');
define('FTP_BASE', '/public/');
define('FTP_CONTENT_DIR', '/public/wp-content/');
define('FTP_PLUGIN_DIR ', '/public/wp-content/plugins/');
define('FTP_USER', 'your-username');
define('FTP_HOST', 'ssh.phx.nearlyfreespeech.net:22');
define('FTP_PASS', 'your-password');

Once I got that out of the way I hit another snag. I was getting a couple temporary file permissions errors. Evidently it’s a side-effect of NFS’s hosting setup (PHP safe_mode, etc). A few web searches later and I had an answer.

  1. SSH into the server
  2. chgrp -R web ./public
  3. find ./public -type f -exec chmod 664 {} \;
  4. find ./public -type d -exec chmod 775 {} \;

After making those changes it was smooth sailing. And as expected, the site is loading much faster now.

Binary Search for Javascript Arrays

If you need to search through a large array, or you search arrays frequently in your Javascript code, or if you do both, chances are a binary search will give you better performance than a linear search (read: for loop). One caveat, however, is that binary search algorithms only work on sorted arrays. Here is a binary search function I sometimes use in my code:

Read more

A Better HAProxy Health Check For Dynamic Websites

Nobody wants their website to go down, or worse, for users to notice the site is down. Because of this most larger websites will run on multiple servers to provide some level of high availability. In a multi-server architecture there is typically a load balancer (or cluster of load balancers) to distribute the load among a pool of web servers. When a server goes down it’s taken out of the pool until it is once again ready to handle requests. HAProxy (a software load balancer) has the ability to perform this task by doing periodic health checks on all the servers in a cluster. The default settings, though, could give false positives in some cases, and thus create a bad user experience by allowing ill application servers to continue receiving requests.

Read more

Recursive Find and Replace With grep and Perl

I thought it might be a nice idea to start posting useful little commands and bits of code every now and then–ones I’ve found to be particularly useful. So here’s the first one, recursive find and replace. A masterfully crafted regular expression paired with this command can save you hours of tedious work.

Read more

Taking The Pain Out Of Domain Hunting

Trionym Screenshot

Coming up with a suitable name for a business, product, or website is something I do on a fairly regular basis. In brainstorming a name I often make lists of words I’d like to use, like adjectives and nouns than relate the product. Then I start combining the words to create a unique name and check to see if the related domain is taken or not. The problem is that even though I may have come up with a name I really like, if the domain name is taken, it isn’t worth keeping.

Read more

Next Page →