Archive for August 2008

 
 

Apple sheep

I don’t understand what people see in Apple products.

I do understand a huge part of Apples sales are driven by the hype they & others create.

I’m always amused when I notice how dumb people act in such circumstances. If you read the article above (which I don’t recommend) you’ll of course notice how Apple-minded the writer is: you have an Apple product and then you have other brands which should -try- to be as good as the former. Well… it’s the subject of that blog of course, but it can count as a general example.
It’s because of people like him that others follow. Most of us are really like sheep.

Personally I want to buy stuff that works or has features that are functional. Not things that sell by their looks. Stuff that make things easier for me. And if they have unexpected features that prove to be useful that will make me even more happy. In this specific case Nokia is making robust and user friendly phones for ages, but everyone “needs” an iPhone.

The same applies to Mac computers & their OS: they do not have loads of features that make competitors fade away. On the contrary.
It’s even worse if you think about the comparison of first iPods against other MP3 players (of which some of them were probably available on the market months or years before the iPod). They didn’t only have more useful functions, they also did not depend on software like iTunes.

Let’s just hope companies like Nokia and Asus keep making great products! :-)

Edit: @stijn: I still like to be friends with you!

PHP at FrOSCon

Although I’ve only been at FrOSCon one day I was happy to attended some interesting talks. Especially the ones by Sebastian Bergmann about PECL, PHP 5 and future PHP versions.

The most important new feature for the next PHP version will probably be Traits: a possible solution for multiple inheritance (although some may argue that they provide the same functionality & problems). I do wonder if people will actually ever use it as much as they talk about it…

I now also know what Aspect-oriented programming is.

Thanks guys for the great conference!

Zend_Log wrapper for Propel

Although Doctrine has its advantages, I still like Propel. It does its job and it does it fairly well.
If you integrate Propel with Zend Framework, you basically only need a Zend_Log wrapper that implements the BasicLogger interface Propel requires. This lets you use Zend_Log as the only log class in your application instead of creating one especially for Propel.

/**
 * Wrapper for Zend_Log for use as Propel log
 * @author Sam Hauglustaine
 */
class strictlyPHP_Propel_Log extends Zend_Log implements BasicLogger
{
    /**
     * Log
     * @var Zend_Log
     */
    private $_log;

    /**
     * Constructor
     * @param Zend_Log $log
     */
    public function __construct(Zend_Log $log) {
        $this->_log = $log;
    }

    /**
     * Log message of specified severity
     * @param string $message
     * @param int $severity
     */
    public function log($message, $severity = null) {
        $this->_log->log($message, $severity);
    }

    public function emergency($message) {
        $this->log($message, Zend_Log::EMERG);
    }
    public function alert($message) {
        $this->log($message, Zend_Log::ALERT);
    }
    public function crit($message) {
        $this->log($message, Zend_Log::CRIT);
    }
    public function err($message) {
        $this->log($message, Zend_Log::ERR);
    }
    public function warning($message) {
        $this->log($message, Zend_Log::WARN);
    }
    public function notice($message) {
        $this->log($message, Zend_Log::NOTICE);
    }
    public function info($message) {
        $this->log($message, Zend_Log::INFO);
    }
    public function debug($message) {
        $this->log($message, Zend_Log::DEBUG);
    }
}

(the Zend_Log priority constants nicely match their Propel equivalents.)
You then need to extend the main Propel class to do the wrapping:

/**
 * Wrapper for Propel
 * @author Sam Hauglustaine
 */
class strictlyPHP_Propel extends Propel
{
    /**
     * Set Propel log (required)
     * @param mixed $log
     * @return void
     */
    public static function setLog($log)
    {
        if($log instanceof Zend_Log)
            $log = new strictlyPHP_Propel_Log($log);

        parent::setLogger($log);
    }
}

That’s all. You can then call your Propel wrapper’s static methods in your bootstrap or a front controller plugin (I implemented that last option for a brand new project, a directory for stallion owners):

strictlyPHP_Propel::setLog($myLog);
strictlyPHP_Propel::init($myConfig);

Of course the bigger part is using the Propel class generator itself but that’s something for another post.

Uppercase first letter of a string with MySQL

I just searched for a MySQL clone of the ucfirst(string) PHP function which converts the first letter of a string to a capital, but couldn’t find one.
Just to save you some work – I used this:

UPDATE `table` SET
`field` = CONCAT(UPPER(LEFT(`field`, 1)), SUBSTRING(`field`, 2))

and if you want to have all other characters lowercased:

UPDATE `table` SET
`field` = CONCAT(UPPER(LEFT(`field`, 1)), LOWER(SUBSTRING(`field`, 2)))

Be more productive – part 1

Install and use Enso. You’ll know why after a day.
Edit: also install Enso Media Remote Control.
Edit 2: navigate to WINDOWS_DIR/system32/drivers/etc/hosts and give Enso the command learn as open hosts.

Drag maximized windows with nVidia nView

Like many people today I can’t code without a dual display setup but I also belong to the ones that feel the force to upgrade drivers and other software on a perfectly working system.

After upgrading my nVidia display drivers to the latest version (175.19) I was losing huge amounts of time dragging maximized windows from one screen to the other. On most systems (as with these latest drivers) this is only possible by first unmaximizing the application and remaximizing it once dragged onto the other screen. However, for some reason I have always been able to just drag maximized windows in the past.

After loosing much more time searching for a solution and trying other options (keyboard shortcuts, nView buttons) I went for the best solution so far: I uninstalled the new drivers and installed older ones again (which I found on the graphics card manufacturers website – version 91.47 to be precise).
The good thing is that everything works like it did before and I can drag maximized windows again.

Hopefully you don’t suffer from the same window maximizing autism like me but please let me know if you do and have a better solution.

It’s all about the combinations

Wouldn’t it be great to have a place where you can look for people that use the same combination of technologies like you are?

Let’s say that you’re working with ExtJs and Zend Framework: it sounds extremely useful to be able to look at a list of people who also combine those and possibly contact them or post in some kind of related forum. I can imagine there are lots of people out there that would at least be happy to find best practices or examples on the stuff that they are combining. The combinations cause things to differ from the manuals/forums/groups of each separate (in this case) technology.

Basically this can apply to combining anything: .NET + MySQL, Windows Vista + Photoshop, Ubuntu + VirtualBox, Dell notebook + Vodaphone,… Or how about business in India + United States?

Let’s hope I didn’t just invent the next social network? If this proves to be the case: please don’t forget me! ;-)

Famous bikinis

Last month I developed an online bikini store for a design company based on Zend Framework and some jQuery widgets. It wasn’t only a fun subject – the site also performs very well. Both on organic search and on conversions.

One thing that I found to be a life saver: use caching for Zend_Currency.

$cache = Zend_Cache::factory('Output',
                             'File',
                             $configFrontend,
                             $configBackend);
Zend_Currency::setCache($cache);

Or another caching mechanism of course – this will visibly speed up page loading.
Edit: also do this for Zend_Translate but you could have thought of that yourself.

Besides that the finishing touch is a local touch: Clickini loves your country (if they are shipping to you that is). Thanks to my flexible hosting company (who installed Maxminds PHP GeoIP extension) & the world’s favorite icons, that was easy to accomplish.

That last character is the first

Let’s dive right into it:

About a week ago I put on the JavaScript text-typing mode and developed a CMS with ExtJs and Zend Framework. Thanks to FireBug life is great. At least, until that last final test in that other browser. Ouch.

One thing that solves almost all issues: watch your JavaScript object notation (JSON) values separator. FireFox doesn’t complain about that last comma before the closing } or ] but Internet Explorer isn’t so keen on that.
Well… maybe that is a good thing.

Perhaps an easy way out is validating the stuff you type.