Archive

Archive for March, 2009

Go-to-root bookmarklet

March 23rd, 2009 No comments

Found this one over at michaelhoney.com – a bookmarklet that directs you to the root of whatever site you’re currently browsing. Just drag it to your bookmark bar:

Goto root

Categories: Uncategorized Tags: ,

Browser caching with SSL

March 18th, 2009 No comments

I’m using several SSL-enabled sites daily, and since browsers traditionally refuse to cache anything negotiated through an SSL connection on disk, performance has a tendency to suffer. I notice this every time I visit Fogbugz, and I have to wait for my browser to load all the neat little icons they use. Fortunately, according to James Henstridge, it’s possible to make Firefox 3+ cache these files now.

Basically he suggests to go to about:config and change the setting browser.cache.disk_cache_ssl to true. There have been issues prior to Firefox 2, but these should be fixed in Firefox 3.

If you’re running a webserver, adding the header value Cache-Control: Public will allow most browsers to automatically cache server files. If you’re paranoid, you should only add this header to scripts, images and stylesheets. Here is an example for Apache that allows browsers to cache a selected fileset for up to one week:

# Cache-control: Public activated disk-caching for HTTPS
<FilesMatch “\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$”>
Header set Cache-Control “max-age=604800, public”
</FilesMatch>
Categories: Uncategorized Tags: , , , ,

WordPress StatPress

March 16th, 2009 1 comment

.. has the database table definitions from hell! Just take a look at this:

+--------------+--------------+------+-----+---------+----------------+
| Field        | Type         | Null | Key | Default | Extra          |
+--------------+--------------+------+-----+---------+----------------+
| id           | mediumint(9) | NO   | PRI | NULL    | auto_increment |
| date         | text         | YES  |     | NULL    |                |
| time         | text         | YES  |     | NULL    |                |
| ip           | text         | YES  |     | NULL    |                |
| urlrequested | text         | YES  |     | NULL    |                |
| agent        | text         | YES  |     | NULL    |                |
| referrer     | text         | YES  |     | NULL    |                |
| search       | text         | YES  |     | NULL    |                |
| nation       | text         | YES  |     | NULL    |                |
| os           | text         | YES  |     | NULL    |                |
| browser      | text         | YES  |     | NULL    |                |
| searchengine | text         | YES  |     | NULL    |                |
| spider       | text         | YES  |     | NULL    |                |
| feed         | text         | YES  |     | NULL    |                |
| user         | text         | YES  |     | NULL    |                |
| timestamp    | text         | YES  |     | NULL    |                |
+--------------+--------------+------+-----+---------+----------------+

This is horrible database design, and since this table quickly grows in size, this is something to be fixed immediately:

mysql> ALTER TABLE wp_statpress CHANGE date date VARCHAR(8);
mysql> ALTER TABLE wp_statpress CHANGE time time VARCHAR(8);
mysql> ALTER TABLE wp_statpress CHANGE ip ip VARCHAR(16);
mysql> ALTER TABLE wp_statpress CHANGE nation nation VARCHAR(8);
mysql> ALTER TABLE wp_statpress CHANGE timestamp timestamp INT(10) UNSIGNED;
mysql> ALTER TABLE wp_statpress CHANGE user user VARCHAR(32);
mysql> ALTER TABLE wp_statpress CHANGE urlrequested urlrequested VARCHAR(255);
mysql> ALTER TABLE wp_statpress CHANGE referrer referrer VARCHAR(255);
mysql> ALTER TABLE wp_statpress CHANGE browser browser VARCHAR(255);
mysql> ALTER TABLE wp_statpress CHANGE searchengine searchengine VARCHAR(64);
mysql> ALTER TABLE wp_statpress CHANGE spider spider VARCHAR(64);
mysql> ALTER TABLE wp_statpress CHANGE feed feed VARCHAR(255);
mysql> ALTER TABLE wp_statpress CHANGE agent agent VARCHAR(255);
mysql> ALTER TABLE wp_statpress CHANGE search search VARCHAR(255);
mysql> ALTER TABLE wp_statpress CHANGE os os VARCHAR(64);

If you’re using MySQL 5+, you might consider changing the VARCHAR(255) definitions to VARCHAR(1024).

The new definition looks like this:

+--------------+------------------+------+-----+---------+----------------+
| Field        | Type             | Null | Key | Default | Extra          |
+--------------+------------------+------+-----+---------+----------------+
| id           | mediumint(9)     | NO   | PRI | NULL    | auto_increment |
| date         | varchar(8)       | YES  |     | NULL    |                |
| time         | varchar(8)       | YES  |     | NULL    |                |
| ip           | varchar(16)      | YES  |     | NULL    |                |
| urlrequested | varchar(255)     | YES  |     | NULL    |                |
| agent        | varchar(255)     | YES  |     | NULL    |                |
| referrer     | varchar(255)     | YES  |     | NULL    |                |
| search       | varchar(255)     | YES  |     | NULL    |                |
| nation       | varchar(8)       | YES  |     | NULL    |                |
| os           | varchar(64)      | YES  |     | NULL    |                |
| browser      | varchar(255)     | YES  |     | NULL    |                |
| searchengine | varchar(64)      | YES  |     | NULL    |                |
| spider       | varchar(64)      | YES  |     | NULL    |                |
| feed         | varchar(255)     | YES  |     | NULL    |                |
| user         | varchar(32)      | YES  |     | NULL    |                |
| timestamp    | int(10) unsigned | YES  |     | NULL    |                |
+--------------+------------------+------+-----+---------+----------------+

You won’t believe this, but they didn’t add any indexes. To prevent your system from going into a coma when doing household on hit data, add at least an index on date:

ALTER TABLE wp_statpress ADD INDEX(date);
Categories: Uncategorized Tags:

VMWare vs Paranoia

March 10th, 2009 No comments

As a website developer, I unfortunately need to test everything in Microsoft’s dreaded Internet Explorer. For this, I’ve got a Windows XP running on an installation of VMware® Workstation on my Linux desktop. It works like a charm, except when the kernel is updated.

Aside from being a website developer, I’m also a paranoid system administrator. One of the first thing I add to my login scripts, is umask 077 – the command that sets the permission mask for newly created files. Setting this to 077 prevents anyone but the current user from being granted any rights – read, write or execution. It’s a sane thing to do, but unfortunately a lot of scripts fail to explicitly grant access to other users, especially when installing RPM packages or – in this case – running VMWare after a kernel upgrade to build new VMWare-specific kernel modules.

In this specific case, VMWare kernel modules were built by the root user, and ended up in /lib/modules/2.6.27.19-170.2.35.fc10.x86_64/misc/ which was created by the build process. Read permissions were not explicitly granted to everyone, so when running vmware as a mortal user, it was unable to actually read and verify the newly built kernel modules. The natural response to the user wasn’t “Unable to read kernel module files”, but instead “You need to build kernel modules for your specific kernel”. Makes a lot of sense, eh? :-)

Manually granting read and execution rights on the /misc directory and the files in it fixed the issue.

Categories: Uncategorized Tags: , , ,

Moving

March 6th, 2009 No comments

After having been a employer sponsored free-hosting initiative, Spind.net has now officially become a part of my own company. During the next weeks, domains, e-mail and websites will be relocated to our new servers at Leaseweb‘s environmentally aware EvoSwitch facility in Amsterdam.

We’re currently leasing a couple of entry level servers, and we’ve named them after one of the two first big accomplishments in space history: the first orbiting satellite, the Russian Sputnik-1 and the first spaceship bringing a human being – Yuri “Kedr” Gagarin – into space, the Russian Vostok 3KA.

Categories: Uncategorized Tags: