Sunday, February 7, 2010

Eclipse 3.4 on Arch Linux

2 Problems when trying to run Eclipse 3.4.2 on Arch Linux x64 (eclipse 3.5 runs great):
  • xulrunner error - was resolved by compiling an older version of xulrunner (I used 1.9.0.17) and passing parameter specifying its path in eclipse.ini:
-Dorg.eclipse.swt.browser.XULRunnerPath=/usr/local/lib/xulrunner-1.9.0.17
  • some buttons seemed to "stick", this was resolved with: export GDK_NATIVE_WINDOWS=1

Wednesday, February 3, 2010

OpenID and Mobile Devices

When I first started sailfish.mobi I wanted to make OpenID the only login option... the idea being that users would more likely not want to provide a password to yet another site.  However I was very unhappy with the experience on the mobile device - there is no address bar displayed, so no quick way for the user to confirm that they are indeed giving their password to Google.com and not to some cleverly disguised phishing site.

There is a way to go through the options to see the page address but it is a few clicks away and even there you have to parse out the domain which is not as clearly visible on the tiny blackberry screen. 

IMHO the page's domain should be displayed in an obvious fashion when submitting to an SSL site.  With maybe an option to hide it for certain domains.

In the meantime I have just added a plain old email/password option to the site (I might put the ability to associate an openid to such a login in the future... but not sure there would be much interest, I mean if you already went through the trouble of creating a password you might as well use it)

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