Mike November

Phonetic alphabet for my initials, k?

Viewing entries posted in January 2011

Some handy git config bits and pieces

Posted by Marcus Nyeholt on 11 January 2011 | 0 Comments

Tags:

Have finally updated to Ubuntu 10.10, taking the opportunity to completely clean out. Of course, this means reconfiguring everything - these two git settings are the ones that I most missed

The following adds an indication on your command-line as to the branch you are currently on. Massively helpful.


parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' } export PS1="\[\033[00m\]\u@\h\[\033[01;34m\] \w \[\033[31m\]\$(parse_git_branch) \[\033[00m\]$\[\033[00m\] "

The next simply sets a global config for colours when doing things like diff and status


git config --global color.ui "auto"

0 comments | Read the full post

Dependency Injector update

Posted by Marcus Nyeholt on 5 January 2011 | 0 Comments

Tags:

I've been playing around adding some dependency injection to SilverStripe off and on recently. One of the problems is where to actually put the configuration you need, and how to ensure the loading of the services occurs in the expected order.

The default mechanism in SilverStripe is to put things in the _config.php file for a given module. Rather than come up with something new, I decided to stick with the same methodology. However, that presents a new issue - if you specify a service configuration there that is meant to override a service configuration defined in another module, the other module might actually load AFTER yours, meaning it will take that specification. One way to enforce a module to appear first is to provide a 'priority' alongside the service spec.

    $config = array(
        array(
            'src' => TEST_SERVICES.'/SampleService.php',
            'priority' => 10,
        )
    );

    $injector->load($config);

    $config = array(
        array(
        'src' => TEST_SERVICES.'/AnotherService.php', 
        'id' => 'SampleService',
        'priority' => 1,
        )
    );

    $injector->load($config);

In this example, previously the injector would have used the AnotherService class whenever SampleService was referred to. However, because we've explicitly stated that a priority of > 10 is needed to replace it, it will NOT have its definition changed.

0 comments | Read the full post