Browsed by
Category: Programming

Speed Up WordPress on Dreamhost Using Custom MySQL Server

Speed Up WordPress on Dreamhost Using Custom MySQL Server

I run all of my services on a Dreamhost VPS instance.  I have even upgraded to the newer VPS with 1GB of RAM. Yet, my WordPress instances have become stupid slow.  Like 2-3 seconds to load a page slow.

I had chalked this up to the complexities of WordPress and the various plugins that I had installed.  However, eventually I became so frustrated I tried disabling each all plugins and discovered that this had little effect.

After more poking around, I installed a query monitor plugin and discovered that my SQL queries were taking more time that I would have anticipated.

Frustrated, I installed the MySQL server on my local VPS, and then copied over my database.  Viola!  All of the slowness disappeared.  I went from having 3 second load times to less than half second load times.  The following is a chart from Google showing the load times each time it crawled my site.  You can clearly see the date when I switched over.


The moral of this story is that the shared MySQL server that comes with a Dreamhost VPS account is absurdly slow.  Stupidly so.  Luckily, there is plenty of RAM on a VPS instance to run a MySQL instance.

Disable Dreamhost Panel Management on VPS

Disable Dreamhost Panel Management on VPS

A Dreamhost VPS is nearly indistinguishable from a dedicated server.  Dreamhost allows users full root access to the VPS servers, so you are free to manage them as you see fit.

However, certain configuration files related to users, and web servers, are completely overwritten whenever a Panel change is made.  Plus, there may be other instances in which Dreamhost will overwrite your changes.  As a result, if you want to manage these features on your server, you need to exclude Dreamhost from managing them.

Danger Lies Beyond This Point

It is self evident, but if you elect to exclude Dreamhost from managing your server, you are responsible for making sure things don’t break.

Get Root Access

To get root access find the following section in the panel:ssh menu


and add a new key.

Details on how to make or use SSH Keys are well covered on the internet.  If you don’t already know how to work with SSH Keys, you may want to consider if you are really prepared to handle the management of your server.

Once the SSH Key has been installed, log in as root to your VPS.  Once there run the following command:

mv /root/.ssh/authorized_keys2 /root/.ssh/authorized_keys2.disabled

Dreamhost will no longer be able to access your server.  You can still use the Dreamhost Panel to adjust the memory and disk space allotments for your VPS.  However, adding domains, user, one-click installs, and all other related items will no longer work.

Dreamhost VPS Disable Jabber

Dreamhost VPS Disable Jabber

Even with Jabber disabled in the VPS configuation, you will still see jabber processes running on your VPS.  They eat up about 30 MB of RAM, but very little processing power.

You can easily disable them by running the following either as root or through sudo:

/etc/init.d/ejabberd stop;
update-rc.d -f ejabberd remove;
World Sunlight Map with Real Cloud Data and Accurate Seasons

World Sunlight Map with Real Cloud Data and Accurate Seasons

earth For a long time I have used an image similar to this one as the background on my phone.  The image accurately represents the current cloud formations and sunlight regions on the planet.  I came up with the idea from the following page:  There is a good explanation on how to do this at, so I won’t repeat it here.

If you want to purchase an expensive wall hanging version of this map amazon will sell you one for $3000+, Boardroom Sunlight Map.  Although it seems to me that you could purchase a Flat Screen TV and a Raspberry Pi and save yourself $3000, but hey, that is just me.

For a few years, I have used a Tasker profile on my Android phone to download a copy of this image once an hour.  Tasker then updated the background on my phone.  I find the image to be both beautiful and at least marginally functional.  Plus I enjoy the nerdiness of it.

A few months back I switched to a Nexus 4 and discovered that the image available from was lower resolution that my phone.  This gave my the impetus to “roll my own” customized version.

I doing so I discovered the beautiful series of Blue Marble images that NASA has made available.  The The Blue Marble: Land Surface, Ocean Color and Sea Ice image was by far my favorite, but I noticed that NASA has since added monthly images that more accurately represent the snow pack and foliage for each month of the year.  Unfortunately, these images seem darker, and less vibrant than my favorite image.  Specifically, the greens and browns of the land masses looked very dull.  Additionally, the ocean was much more black and devoid of any character.

Luckily NASA aligns the images very precisely.  I first downloaded each monthly image and tweaked it in darktable.  I increased the exposure value to make them brighter, and increased the color saturation of the greens, browns and oranges.  The resulting images were much more vibrant.  Then to fix the ocean, I simply placed my favorite image into Gimp and overlayed the new images with a mask for the ocean over them.  The results were spectacular.

Then I simply added 12 different config files for xplanet and made 12 different cron jobs depending on the month.  Now I have my own custom World Sunlight Map with more accurate seasonal representation of the land mass.

A Temperature Controlled Whole House Fan with MisterHouse

A Temperature Controlled Whole House Fan with MisterHouse

MisterHouse Web Interface for a Temperature Controlled Whole House FanThe main feature of MisterHouse that sets it apart from other home automation systems is the ability to customize practically every aspect of the system.  The following example is a perfect demonstration of this.

I recently purchased a whole house fan, basically a giant fan that sucks hot air out from the highest point in my house. They are great if you live in a climate with cool nights.

The controls for my fan were very basic, an on/off switch and a two-speed setting.

With Misterhouse, I created an “auto” mode which will only turn on the fan if both the indoor temperature is above a defined threshold and the outdoor temperature is 5 degrees below the indoor temperature.

This is how I did it.

Starting Materials
– A Whole House Fan
– 2 IOLincs, (1 for on/off, 1 for fan speed)
– A MisterHouse enabled indoor temperature sensor (I used my Insteon Thermostat)
– A MisterHouse enabled outdoor temperature sensor (I used data from a neighbor’s weather station through weatherunderground)

I created the following items in my mht file:

GENERIC, house_fan, HVAC|WHF_Group
GENERIC, house_fan_temp, HVAC|WHF_Group
GENERIC, house_fan_setpoint, HVAC|WHF_Group
GENERIC, house_fan_ambient, HVAC|WHF_Group

I also had the following items already setup:

$upstairs_thermo_temp #the temperature upstairs
$w_temp #the outside temperature

First, I set the available states for my generic objects:

$house_fan->set_states('on', 'off', 'auto');
$house_fan_speed->set_states('high', 'low');
$house_fan_temp->set_states('cooler', 'warmer');

Then I tied my generic items to my Insteon Devices:

$house_fan->tie_event('$whf_main->set("on")', "on");
$house_fan->tie_event('$whf_main->set("off")', "off");
$house_fan_speed->tie_event('$whf_speed->set("on")', "high");
$house_fan_speed->tie_event('$whf_speed->set("off")', "low");

Then I tied my Generic temp item to my Generic setpoint item, and inserted some custom code:

sub house_fan_temp_change {
	my ($state) = @_;
	if ($state eq "warmer"){
		$house_fan_setpoint->set(int($house_fan_setpoint->state) + 1);
	} elsif ($state eq "cooler") {
		$house_fan_setpoint->set(int($house_fan_setpoint->state) - 1);

By doing this, I can have a nice cooler and warmer button in the web panel.

Finally, every minute I check to see if the device is in “auto” mode and whether or not it should turn on:

if ($New_Minute){ 
	if($house_fan->state eq 'auto') {
		if (int($upstairs_thermo_temp->state) > int($house_fan_setpoint->state) &&
		(int($upstairs_thermo_temp->state) - 5) > int($w_temp->state)) {
			if ($whf_main->state eq 'off') {
				::print_log("[] Auto: Turning on fan");
		} else {
			if ($whf_main->state eq 'on'){
				::print_log("[] Auto: Turning off fan");

The result, is a temperature controlled whole house fan.  The image above is a screen shot from my web interface.

PHP: Get date for nth occurrence of weekday

PHP: Get date for nth occurrence of weekday

I looked quickly and did not see any code out there to determine the nth occurrence of a specific day of the week in a month.  For example Thanksgiving is the 4th Thursday in November.  So I designed the following

$year = 2012; 
//Pick your year
$interval = 4; 
//Week number, in this case the 4th week
$dayofweek = 4; 
//Day of week 0=Sun, 1=Mon. . .
$month = 11; 
//Month 1=Jan, 2=Feb

$firstday = jddayofweek(gregoriantojd($month, 1, $year), 0);
if($firstday <= $dayofweek){
  $date = (($interval * 7)-6) + ($dayofweek - $firstday);
  $date = (($interval * 7)-1) + (6 - $firstday);
echo date("n/j/Y", mktime(0, 0, 0, $month, $date, $year));

It looks a little messy, but it works perfectly.



So apparently as bad as this looks it works too:

Read More Read More

Integrating Google Talk with Roundcube

Integrating Google Talk with Roundcube

Sorry I don’t have much time at the moment to write up a whole entry about this, but I am very excited about this.

I am a big fan of roundcube but I have always wanted the ability to integrate some instant messaging into it.  Well google finally released a gtalk gadget that allows you to integrate gtalk/gchat into any page you want.  Although, google has done a very poor job of announcing this and I don’t think most people know about it.

Anyways, it is a very simple single line <iframe> code.  I just quickly added it to the roundcube template and made a few changes to the CSS code and it works perfectly.

Click the image above to see a larger screen shot.  I will write up the code for this later when I have some free time.

How to Resurrect Procmail and Spamassassin on Dreamhost

How to Resurrect Procmail and Spamassassin on Dreamhost

Admittedly I have been very annoyed with Dreamhost since they announced that users would no longer be able to use procmail.

How to get procmail Back

After reading the most recent entry I realized that it is possible to still use both procmail and spamassassin.  However, this solution is not elegant.

Currently Dreamhost has a rudimentary Mail Filter system that is accessible by all mail users.  This system is due to be upgraded soon.  Dreamhost also allows regular shell users to access and run procmail as well as spamassassin.  In fact, shell users can install their own custom install of spamassassin.  Lastly, shell users can also receive email, although there is no imap or pop service for this mail.

Read More Read More

Bug in BlackBerry Repeat Rule, MONTH_OF_YEAR Deincrements 1 Month

Bug in BlackBerry Repeat Rule, MONTH_OF_YEAR Deincrements 1 Month

I have noticed a bug in javax.microedition.pim.RepeatRule, when I tried to set a an event to repeat every second sunday of may I would get an event that repeated every second sunday of april. I determined that this was being caused by MONTH_OF_YEAR being deincremented by 1 month after the event was committed.

I worked around the problem by setting the value one month forward. However obviously, this does not work for december. I tried increasing the value of the MONTH_OF_YEAR setting, however java balks at any unknown value. Currently I am unable to set an event to occur on the second sunday in december. If anyone figures out a work around I would be greatful.

RIM has recognized that this is a bug, but who knows when the bug will be fixed. I attached a copy of the email I received from RIM:

Read More Read More

Improved Funambol Blackberry Plugin

Improved Funambol Blackberry Plugin

As promised I made significant improvements to the Funambol Blackberry Client, while the improvements are geared towards better functionality with, they should benefit individuals who use other SyncML servers as well.

The Improvements in include:

  • Ignore milliseconds in date, fixes duplication on
  • Properly display entities such as quotes and ampersands
  • Allday events now show up on week and month view
  • Multiday Allday events are no longer short one day
  • All day events no longer duplicate on SlowSync
  • Accept basic ISO 8061 dates
  • Fixed error message that popped up whenever sending an email
  • Removed configuration section relating to email since Schedule World does not support email
  • Altered default settings in configuration to match Schedule World settings
  • Added AutoSync Feature - The client will query the server for changes every X hours.

Read More Read More