Sunday, January 31, 2010

PHPUnit recursive test runner

You can run php unit tests by pointing it at a directory:

phpunit MyTestFolder

What I did not realize is that the test files have to end in "Test.php" (I am used to a test prefix instead).  No big deal now that I know it!

Apache Caching and Compression

For caching, enable mod_expires and use the following config:

   
    ExpiresActive On
    ExpiresByType image/gif "access plus 1 week"
    ExpiresByType image/png "access plus 1 week"
    ExpiresByType image/jpg "access plus 1 week"
    ExpiresByType image/jpeg "access plus 1 week"
    ExpiresByType image/x-icon "access plus 1 week"
    ExpiresByType application/x-shockwave-flash "access plus 1 week"
    ExpiresByType text/html "access plus 1 hour"
    ExpiresByType text/css "access plus 1 day"
    ExpiresByType text/javascript "access plus 1 day"
   


This will cache even PHP pages.  So add the following before session_start:
   session_cache_limiter("nocache")

This way authenticated users (who are presumably using the dynamic features) are not cached, but others are.  CSS and images are still cached for everyone, of course.  One limitation is that if a user changes from logged off to logged in, and he keeps visiting the same pages that he had seen before when he had not yet logged in, he will still see the logged off version.

For compression, this can be enabled for specific types like this:
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript

(and enable mod_deflate)

There is a sample config on http://httpd.apache.org/docs/2.0/mod/mod_deflate.html that shows how to enable it in general and limit it for specific browsers.

Saturday, January 30, 2010

Smart Shopper

New comparison shopping tool for Blackberry - Smart Shopper.

Saturday, January 23, 2010

Blackberry simulator log

Use this flag in the simulator:


"/app-param=JvmDebugFile:E:\Java\BB-Log.txt"

It will log the stuff that is normally accessible through the on-device log. E.g. stuff wrote to System.err.

Thursday, January 21, 2010

Set LVM volume permissions via UDEV

I needed to set up the permissions on an LV for my user in order to use it for VirtualBox. This is what I did (on Arch Linux):

In /etc/udev/rules.d/zz-vmdmsetup.rules:


SUBSYSTEM=="block", \
KERNEL=="dm-*",\
ACTION=="add|change", \
PROGRAM="/etc/udev/get-lv-name.sh %M %m", \
RESULT=="vm*", \
GROUP="nico", MODE="0660"

What this does - for "dm" devices, it will check the name via the get-lv-name.sh program, and if it starts with "vm", puts it in my user group and change the permission to g+rw.

Here is the get-lv-name.sh script:


#!/bin/sh

# Usage: get-lv-name.sh $MAJOR $MINOR
# Outputs the corresponding logical volume name

/sbin/dmsetup info -j $1 -m $2 |
/bin/grep Name |
/bin/cut -d '-' -f 2-

Finally to add it to VirtualBox:


vboxmanage internalcommands createrawvmdk
-filename /home/user/.VirtualBox/HardDisks/w7rc.vmdk
-rawdisk /dev/vg0/vm1 -register