lime icon

Phosphorus and Lime

A Developer's Broadsheet

This blog has been deprecated. Please visit my new blog at klenwell.com/press.
Farewell
In the course of human events, to paraphrase a famous document, it is sometimes necessary to say goodbye. And I'm saying goodbye to Blogger. For this blog anyway. I'm finally moving to WordPress.

Blogger is a solid platform with many user-friendly (not to mention, spammer-friendly) features. It has continued to improve steadily since Google acquired it. But you're still at the mercy of Google's sometimes inconsistent censorship policies.

Beyond the control it affords the blogging developer, WordPress is a really impressive platform. It has rich features and, in spite of this, an easy intuitive interface.

This blog will continue to exist as an archive, so long as Google is gracious enough to host it. But beginning with the New Year, all futures posts will be posted to my new Klenwell blog. Hope to see you there.
PHP4 and PHP5 on the Same Apache Server
This post has been updated. Please see: http://www.klenwell.com/press/2009/02/php4-php5-one-server/


My goal seemed pretty simple: put PHP4 and PHP5 on my local Apache server so that I can easily test a couple applications that still need to work with PHP4. This is for Ubuntu.

I found a pretty good guide here:
http://www.howtoforge.com/apache2_with_php5_and_php4

The only problem is that php4-cgi is no longer in the Ubuntu repositories.

The solution turned out to be pretty easy in the end. Just add one of the old repositories that still has it to your sources list. But it took me the better part of an evening to hunt down that solution.

So here's my step-by-step guide to installing PHP4 to run along side PHP5 on my Apache server on Ubuntu 7.10:

# add breezy to sources
$ sudo gedit /etc/apt/sources.list

# added the following lines
deb http://old-releases.ubuntu.com/ubuntu/ breezy-updates main restricted
deb http://old-releases.ubuntu.com/ubuntu/ breezy-security main restricted
deb http://old-releases.ubuntu.com/ubuntu/ breezy main restricted
deb http://old-releases.ubuntu.com/ubuntu/ breezy universe
deb http://old-releases.ubuntu.com/ubuntu/ breezy-security universe

$ apt-get update

# back up apache2 config file
$ sudo cp apache2.conf /tmp/apache2.conf

# install php4-cgi
$ sudo apt-get install php4-cgi

# install php4 packages
$ sudo apt-get install php4-curl php4-domxml php4-gd php4-imap php4-ldap php4-mcal php4-mcrypt php4-mhash php4-mysql php4-odbc php4-snmp php4-xslt curl libwww-perl imagemagick

# edit apache2 config
$ /etc/apache2/apache2.conf.

# replace line:
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml

# with:
DirectoryIndex index.html index.htm index.shtml index.cgi index.pl index.php index.php4 index.xhtml

# And add lines:
AddHandler php-script .php4
Action php-script /cgi-bin/php4

# enable mods and restart
$ sudo a2enmod actions
$ /etc/init.d/apache2 restart


If you need to deviate from this, I probably won't be much help. But I hope it saves someone a little precious time.

Labels: , ,

Troubleshooting Your AT&T/Yahoo DSL Connection
Once every few months, my internet connection disappears. I don't have a lot of interest in networking, so it's one of those things I just want to work without thinking about too much and without having to call tech support and go through one of those god-damned automated phone trees.

Anyway, today was one of those morning. There was a big thunderstorm last night (rare around here) and the power went out briefly. So maybe it was connected to that. Whatever the case, the modem (a Speedstream 4100B) was on, but the internet light was out, like this:



So after calling tech support and taking care notes, this is my new recommended guide to fixing your internet connection yourself.

1. Login to Modem
This is what ultimately solved the problem for me this time. So try this first. Open a browser, connect to the modem at http://192.168.0.1/. And login with your AT&T or SBC or Yahoo account, or whatever it is.

According to what the tech told me, when the internet light is out, it means the modem can't connect out to the AT&T upstream node (i.e., the internet) and the likely cause, if the network is up, is that the modem is not providing the proper credential. Doing this may fix that.

2. Power Cycle (Reboot)
Turn off modem
Unplug router*
Turn off computer
-- Wait 30s --
Start modem -> wait 10s
Start router -> wait 10s*
Turn on computer
*If you have a router

If either of the above succeeds, your modem should now look like this:



If not, proceed to step 3:
3. Call AT&T Tech Support
1-877-722-3755

Good luck!
Creating Custom Behaviors in CakePHP
The CakePHP manual leaves a lot to be desired on this topic. Here's one important tip that I couldn't find mentioned on the site:

Every method in your behavior class must have a reference to the model passed as its first argument.

Another tip:

If calling another method from within your behavior class, you must include the model reference as your first argument.

I've added a gratuitous example to the test method below.

A simple behavior class that can be used as a template:

<?php

class NormalizerBehavior extends ModelBehavior {

public $name = 'Normalizer';

/*
Initiate behaviour for the model using specified settings.
*/
function setup(&$Model, $settings = array())
{
}

/*
Run before a model is saved.
*/
function beforeSave(&$Model)
{
}


function normalize_date(&$Model, $date_str)
{
return date('Y-m-d', strtotime(trim($date_str)));
}


function test(&$Model)
{
$date = $this->normalize_date($Model, date('Y-m-d'));
printf('testing behavior %s for model %s on %s', __CLASS__, $Model->name, $date);
}
}

?>


If I discover any other noteworthy tips, I'll add them here.

Labels: