/home » workblog

Why Cube Farms are a Bad Idea

Campaign Monitor’s blog has a post about their new office space, and in it they write about several reasons why private offices are necessary for programmers, including this quote from Paul Graham:

“After software, the most important tool to a hacker is probably his office. Big companies think the function of office space is to express rank. But hackers use their offices for more than that: they use their office as a place to think in. And if you’re a technology company, their thoughts are your product. So making hackers work in a noisy, distracting environment is like having a paint factory where the air is full of soot.”

Troubleshooting Slow MySQL Queries

Ian Gilfillan’s article on using indexes in MySQL has a good explanation of how to use the EXPLAIN statement to analyze a query, and what to look out for. You can also check out Jesse Farmer’s optimization tips for a primer on more advanced techniques.

Updating OpenDNS With a Dynamic IP From an Endian Firewall

The Endian router/firewall appliance comes with a Dynamic DNS client that supports the major DDNS providers, but it doesn’t support updating OpenDNS, which is necessary for any custom settings on your OpenDNS account to be applied to the traffic you pass through their servers.

It’s possible to configure this yourself, though. There’s a helpful post at the OpenDNS forums that describes how to configure ddclient on an Endian to automatically update an OpenDNS account whenever your dynamic IP address changes.

Here are a few additional notes that may help:

  • You don’t need to query an external website for your IP address, since the Endian box already knows it. Set ddclient.conf with “use=if, if=eth0″ (or whichever NIC is your red zone).
  • It won’t work if you set “ssl=no”, so you have to leave it set to yes and install the two Perl SSL modules listed in the post.
  • Endian doesn’t have an SMTP server installed, so ddclient can’t send you status e-mails. Comment out the “mail” and “mail-failure” lines to avoid errors.
  • Make sure you don’t have any spaces in the OpenDNS network label or ddclient conf file.

To test if it’s working, you’ll need to get a new dynamic IP.

  • Turn off your cable or dsl modem.
  • Spoof the MAC address on the Endian.
    • On your PC, open a command prompt and type “ipconfig /all”. Copy the value of the Physical Address line. It will look something like 00-4D-B7-D3-5F-03.
    • Go to the Network Configuration wizard on the Endian.
    • In step 4, enter your PC’s MAC into the “Spoof MAC address with” field. Change the dashes to colons so that it looks like 00:4D:B7:D3:5F:03.
  • Shut down the Endian.
  • Turn the modem back on. Wait 15 seconds.
  • Turn the Endian back on.

Once you’ve verified it’s working, you can remove the spoof setting by repeating the steps.

Z-Index Stacking Contexts

One important thing to keep in mind while working with z-index is that multiple stacking orders are created based on the markup hierarchy. This means that an element with a z-index of 30 can actually appear below an element with a z-index of 20, if the z-index of the original element’s parent is 10.

Paolo Lombardi explains this well in his article on stacking context, and includes this helpful diagram:

Example of multiple=

Troubleshooting IIS 400.x Access Denied Errors

David Wang writes about troubleshooting 400.x “Access Denied” errors in IIS. The first step is to pull the substatus code out of the logs, which will give you more information on what’s going wrong and narrow down the list of causes.

Alternatives to Select/Multiple

Ryan Cramer details some of the problems with select/multiple and a few good alternatives. It’s useful in certain circumstances, but unintuitive and error-prone. Instead, you can create a list of checkboxes inside an element with overflow:auto set, or use a jQuery plugin he developed.

Automated FTP Uploads/Downloads

ISINC has a writeup on how to pass a batch file of commands to Window’s command line FTP client. You can then create a Scheduled Task to automate them.

CSS Selector Browser Compatbility

kimblim.dk has a chart showing browser support for various CSS selectors, including pseudo selectors. It includes CSS versions 1 through 3 and all of the major browser versions.

PHP Error Logs with Virtuozzo

Virtuozzo sets domains up to have PHP’s display_errors flag turned off by default, so that you’ll only see a blank page when there are critical errors. This is a good thing in production environments because it avoids potential security issues, but it can also be annoying when you’re trying to debug something.

Instead of displaying the errors, you can configure PHP to log them and then use the logs for debugging. For a Linux environment, you’ll need to create a file named vhost.conf inside the domain’s conf directory, /var/www/vhosts/domain.name/conf.


<Directory /var/www/vhosts/domain.name>
php_value error_log /var/www/vhosts/domain.name/statistics/logs/php-errors.log
php_flag display_errors off
php_value error_reporting 6143
php_flag log_errors on
</Directory>

Then create the file and assign it the right permissions


cd /var/www/vhosts/domain.name/statistics/logs/
touch php-errors.log
chown apache php-errors.log

And the last thing is to tell Apache to reread the updated conf file


/usr/local/psa/admin/sbin/websrvmng -a

Troubleshooting htaccess

If you’re troubleshooting an htaccess file and aren’t seeing any changes, no matter what you put in the file, make sure that you have permissions to execute the directives you’re using. Check Apache’s conf file to see if AllowOverride None is set for your site or directory. If it is, add the directives that you want to use, or just set AllowOverride All. You’ll need to restart the Apache service after changing the conf file. If it still isn’t working, try checking Apache’s error log.