Archive for March, 2010

Meth – A global helper function

I use functions like this a lot during development. I tuck them into a prepend file so they’re only available on my local machine. My first was shout()

function shout() {
    echo "<pre>";
    foreach(func_get_args() as $var) {
        print_r($var);
    }
    echo "<\/pre>";   # (sic)
    die();
}

Great for looking at data.

But I very often found myself wanting to see the API for an object without having to look it up. So I wrote meth()

function meth($obj, $method_name = null) {
    $ref = new ReflectionClass($obj);
    echo "<pre>";
    foreach ($ref->getMethods() as $method) {
        if(!$method_name || $method_name == $method->name) {
            echo $method;
        }
    }
    echo "<\/pre>";   # (sic)
    die();
}
 
meth($this->Session, 'read');
 
# /**
#  * Used to read a session values for a key or return values for all keys.
#  *
#  * In your controller: $this->Session->read('Controller.sessKey');
#  * Calling the method without a param will return all session vars
#  *
#  * @param string $name the name of the session key you want to read
#  * @return mixed value from the session vars
#  * @access public
#  */
# Method [  public method read ] {
#   @@ C:\web\kbya\dev\src\cake\libs\controller\components\session.php 150 - 156
# 
#   - Parameters [1] {
#     Parameter #0 [  $name = NULL ]
#   }
# }

Pretty handy so far.

Oh ya, and here’s the VHost line

php_value auto_prepend_file "/home/kev/web/prepend.php"

The Anorexic Startup

The term Lean Startup has become a battle cry against the archetype of the ego-pumping dot-com executive flexing his Web 2.0 buzz words at an audience of Venture Capitalists and PR mavens. It has come to represent the antithesis of the multi-million dollar hail mary. But is this sense of the word really accurate?

The lean startup movement is essentially just a collection of interlocking disciplines, but the term `lean startup` has taken on this second meaning far from its roots in lean manufacturing and lean software development. To qualify a startup as `lean` now often implies that said startup operates with a heightened measure of scrutiny over its self-image.

The greatest truth the wisest man will ever know is that he knows nothing. That’s the heart of lean.

  1. Think of something you can’t already do.
  2. Write a test.
  3. Fulfill the test.
  4. Release the code.
  5. Engage your audience.
  6. Distill their feedback.
  7. GOTO 2.

The only difference between Agile Software Development and a Lean Startup is 5 and 6.

Agile Manufacturing iterates on the efficiency of the production system as a whole through Process Engineering.
Agile Software Development iterates on the structure of the software as a whole through Software Engineering.
Lean Startups iterate on the product offering itself through Customer Development Engineering.

It is entirely possible to practice agile software development within a non-agile organization, but it is much much harder to practice non-agile methodologies within an agile organization. The cycle times of a lean startup’s release and discovery schedule are just too short for waterfall project plans. Like trying to trim a bonzai with a riding lawn mower.

For this reason, taking a company lean requires the cooperation of everyone involved. The smaller the organization, the easier it is to keep everyone in flow. You probably won’t see anyone throwing around the term Lean Enterprise any time soon.

But does this necessarily mean that a Lean Startup’s small size leaves it afflicted with a neurosis of diminished optimism?

I would say that it does not.

I would say that a Lean Startup is a startup with a realistic understanding of the current and potential viability of its product, achieved through an unyielding acceptance of uncertainty.

CakePHP session error : User-Agent must be consistent

I noticed some erratic behavior with CakePHP sessions and finally tracked down the error. I have FireBug installed with an extension called FirePHP. When FireBug is enabled, I noticed that my User-Agent tends to vary.

Sometimes my browser’s user agent reads :

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.8) Gecko/20100202 Firefox/3.5.8 FirePHP/0.4

Sometimes it reads :

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.8) Gecko/20100202 Firefox/3.5.8

Whenever the User-Agent changes, CakePHP resets the session. This means that I can’t view 3-4 pages on the site before being logged out.

This is the firebug extension that caused the problem.
https://addons.mozilla.org/en-US/firefox/addon/6149

Here’s a link to an error report on FirePHP’s forums
http://n2.nabble.com/FirePHP-and-CakePHP-Session-Reset-tp4671294ef842658.html

This is a great add-on called HTTPFox I used to track down this error.
https://addons.mozilla.org/en-US/firefox/addon/6647