Firefox increase font size mouse shortcut doesn’t work

December 15th, 2007

As you may know, there’s a few shortcuts for increasing the font size in Firefox, which is a must if you want to preserve your eyesight for a lifetime of computer use.

  • One is {Ctrl =} (increase font size) and {Ctrl -}. Although the equals sign might be hard to remember, just keep in mind that there’s a plus sign on top of the equals sign on most keyboards.  You can also hold down control and use the plus and minus signs on the numeric keypad. (Be sure Number Lock is engaged).
  • The other shortcut is holding down the Control key and scrolling up or down with the middle (scroll) button on your mouse.

The problem is, holding down the left Control key and scrolling up/down with the middle button doesn’t work.  Strangely, the left Control key works with the plus/minus keys just fine.

I don’t know if this is a general Firefox bug, or just related to my setup, mouse drivers, or whatever.

UPDATE: Holding down the left Control key and scrolling with the mouse button doesn’t work in Microsoft Internet Explorer either for increasing font size.

I’m guessing that the key codes used by the middle mouse button somehow interfere with the code for the left Control key.

Anybody have a setup that works for this shortcut?

How to define constants in a PHP class

December 14th, 2007

How do you define a constant in a PHP class?

Short answer

Use the const keyword.

Long answer

Take a class (the example is from CakePHP):

/**
Model for users table
*/
class User extends AppModel {

var $name = "User";

var $validate=array(
'username'=>'/^.{6,40}$/',
'password'=>'/^.{6,40}$/',
'email'=>VALID_EMAIL
);

}

Note that the the string ‘/^.{6,40}$/’ is being used twice. It would be nice to put that into a constant so if we need to change it, it can be changed once instead of tediously editing numerous places it might be used.

define()

Our first attempt is to use the define() function, which creates a constant. We put the define call inside the class because we don’t want to pollute the global namespace.

/**
Model for users table
*/
class User extends AppModel {

var $name = "User";

define( 'VALID_MIN6_MAX40', '/^.{6,40}$/');

var $validate=array(
'username'=>VALID_MIN6_MAX40,
'password'=>VALID_MIN6_MAX40,
'email'=>VALID_EMAIL
);

}

But this gives this error:

Notice: Use of undefined constant VALID_MIN6_MAX40 - assumed ‘VALID_MIN6_MAX40′ in …

const keyword

The preferred way to set a constant in PHP5 is to use the const keyword:

/**
Model for users table
*/
class User extends AppModel {

var $name = "User";

const VALID_MIN6_MAX40 = '/^.{6,40}$/';
var $validate=array(
'username'=>VALID_MIN6_MAX40,
'password'=>VALID_MIN6_MAX40,
'email'=>VALID_EMAIL
);

}

Scope resolution

But we’re still not done. For some reason, PHP doesn’t resolve the scope for const constants, and wants you to manually do so even inside the class with the scope resolution operator (double colons — “::”). OK:

class User extends AppModel {

var $name = "User";

const VALID_MIN6_MAX40 = '/^.{6,40}$/';

var $validate=array(
'username'=>User::VALID_MIN6_MAX40,
'password'=>User::VALID_MIN6_MAX40,
'email'=>VALID_EMAIL
);

}

PHP Debugging-the bad old way

December 14th, 2007

The classic way of PHP debugging is to print out the value with an echo statement:
echo $myString
This has been superseded with integrated debugging, but, in a pinch, sometimes this is your only option. For example, setting up debugging takes a while, and you may be forced to debug a script or application with no time for debug setup.

Or the application might be on a remote server that you can’t set up for debugging.

Standard echo

Getting fancy

Krumo

Moving to PHP5

December 14th, 2007

Typo3 and a number of other PHP projects are making a commitment to support PHP5. I think it’s long past time for such a move. The problem is projects haven’t moved to PHP5 because hosts haven’t supported it, and hosts haven’t moved to PHP5 because projects aren’t supporting it.  gophp5.org is an attempt to break this Gordian knot.

So the PHP projects at gophp5.org have all agreed to require PHP5 with software released after February 2008.

Powered by ScribeFire.

Dreamhost Private Servers

September 16th, 2007

Dreamhost, one of the largest shared webhosts, is now offering private servers. These are Linux v-servers .

  • v-servers can be moved from physical machine to physical machine.
  • the CPU and memory for v-servers won’t be oversold
  • when the CPU and memory limit is hit for a given physical machine, a v-server that needs more will be moved to another machine
  • the price is $1 per 10Mhz of CPU and 10MB of RAM
  • the minimum is 150Mhz CPU and 150 RAM at $15/month (burstable to 2300 MHz / 300 MB)
  • the maximum is 2300 MHz of CPU time* and 2300 MB for $230.00/month (burstable to 2300 MHz / 4600 MB)
  • You can run (almost) what you’d like
  • You can increase or decrease the vserver’s capability level any time
  • You’re only billed for the level of usage for the amount of time for which you use it
  • Example given by Josh on the Dreamhost blog:

1 day @ 250MB => $.8333
2 days @ 2300MB => $15.3333
1 hour @ 150MB => $.0208
27 days @ 512MB => $46.0800
Total for the month: $62.27

Cons:

  • You don’t get root. This may not be a bad thing, though, depending.
  • The firewall is completely open. It would be better not to have to depend on application-level security for every running server.

Hello world!

September 15th, 2007

This is a blog about, variously, software development, system analysis, the Typo3 content management system, Java, and other topics.