I am mikek’s Blog

I R Developer

Dealing with forms

An article discussing various pros and cons of form formatting and some ux metrics on the best place to put your labels – http://www.uxmatters.com/mt/archives/2010/01/label-alignment-in-long-forms-paper-prototyping-for-engineers.php

Filed under: development , , ,

New CakePHP has landed – 1.3.0-beta released

Today i wake to find the fantastic news that CakePHP 1.3 is now in beta. You can read more about that via cakephp.org

The bit that particularly tickles me about this new is the inclusion of something i’ve wanted since i first heard about it, virtual fields.

Virtual fields are a new feature in the Model for CakePHP 1.3. Virtual fields allow you to create arbitrary SQL expressions and assign them as fields in a Model. These fields cannot be saved, but will be treated like other model fields for read operations. They will be indexed under the model’s key alongside other model fields.

For anyone who has ever had to stitch together $firstname.’ ‘.$lastname to make $name fields and wondered why you couldn’t get that in a $this->Model->find(‘list’), this is for you.

Once again, many thanks to the fine work from CakePHP developers and contributors, especially Mark Story.

Top new year news indeed and looking forward to the full 1.3. stable release.

Filed under: development , , ,

Snow Leopard low down – my first days with 10.6

I’ve been eagerly awaiting the release of Snow Leopard – the new upgrade to Apples 10.* operating system. Now its released I’m curious about what hoops i’ll need to get my LAMP stack working again when i upgrade.

Below is a list of resources i’ve found from what others have said.

PowerbookMedic’s Snow Leopard review
http://www.powerbookmedic.com/wordpress/snow-leopard-review

Engadgets review
http://www.engadget.com/2009/08/26/snow-leopard-review/

Computer Shopper review
http://computershopper.com/software/reviews/mac-os-x-snow-leopard

PHP 5.3
http://www.brandonsavage.net/first-glance-apples-snow-leopard/

Installing macports under snow Leopard
http://forums.macrumors.com/showthread.php?t=720035

Snow Leopard Vs Windows 7 review
http://www.telegraph.co.uk/technology/microsoft/6087271/Microsoft-Windows-7-vs-Apple-Snow-Leopard.html

Getting Snow Leopards PHP 5.3 to play with CakePHP 1.3
http://dustinboling.com/blog/2009/09/cakephp-and-php-5-3-snow-leopard/

I’m heading off to our local Apple Store in Bristol today so will more than likely have a live install on my Mac by teatime.

Updated:

So I’ve run the backup onto Time Machine and also ensured that everything else got safely copied onto my usb drive. I did this just on the offchance i’d have to do a clean install. Remember to back up items you’ve told Time Machine to ignore (thanks @tomgidden). Also deregister your iTunes.

Installer has run and brought me through to the registration screen. I can’t tell you about any introduction screens as I was away from the mac when i ran it.

Things I’ve discovered about 10.6

  1. Terminal is now able to split panes so you can read what you’ve typed previously in the top pane whilst you continue to type at the bottom.
  2. I’ve got a bit of hard drive space back. Not sure how much but i’ve definitely got a few more GB back as promised.
  3. My Address Book is now working. Its been broken since 10.5.6 or so and was crashing everytime I tried to open it.
  4. Holding a Click down on Dashboard items now brings up Expose. Clicking on individual applications tiles their open windows. Pressing spacebar on a tile brings it full screen. Very nice.
  5. Time Machine is backing up quicker. I’ve shifted a GB over wireless in the last 10mins which is much faster. When i did the first 70GB backup on 10.5 i recall it took nearly a day.
  6. Mail has now got means to connect to Exchange. This means hooking up to Google Apps will be a treat which should also bring in shared Calendars for iCal.
  7. QuickTime has jumped from 7.6.* to 10.*. I’m sure this is to keep the revision in line with Windows Media Player numbers. The interface has been improved and there is no longer a distinction between Pro and non Pro versions. Apparently QuickTime 7 Pro can also be installed alongside it which is nice for those who export from it (and had paid for the upgrade). The Trim functionality is much improved and resembles the video trim interface on the iPhone 3GS which is super simple to use.

Big Win!

  1. The upgrade from 10.5.* -> 10.6 appears to have left my MacPorts intact. I’ve rebooted Apache and started my Mysql server locally and my previously working apps still do. Fantastic.

Filed under: development , , , , , ,

MySQL text limits

Today’s  discovery: MySQL TEXT fields have a limit of 65,000 bytes. If you insert anything larger than that in to a normal TEXT field mySQL will silently truncate your data without telling you (meaning software checks are probably a good idea). MEDIUMTEXT will store 16 million characters and LONGTEXT can handle over 4 trillion, but this information does not appear to be readily available in the online mySQL manual. Something to bare in mind when designing database applications.

Filed under: Uncategorized ,

A better like for searching

I’ve been using LIKE for ages which is a useful way to search for part of a word or phrase in a db field.
$conditions = array( 'TABLE.field LIKE'=>'%'.$search_term.'%');

Now i didn’t realise that this wasn’t case sensitive meaning that ‘Ultra’ returned results but ‘ultra’ didn’t.

So to make it case insensitive you can do the following:

$conditions = array('UPPER(TABLE.field) LIKE'=>'%'.strtoupper($search_term).'%');

Not much different but now a useful(UPPER) addition to the sql arsenal.

Filed under: development , , , ,

Bake path for cakephp

A super easy way to bake cakephp from anywhere in commandline is to add / append your path in .profile/ .bash_login etc.

Add /cake/cake_1.2.3.8166/cake/console or equiv location of your console directory.

ala:

export PATH=/cake/cake_1.2.2.8120/cake/console:/usr/local/bin:/opt/local/bin:/opt/local/apache2/bin:/opt/local/lib/postgresql82/bin:$PATH

Then run source .bash_login etc to enable it or log out and in again.

Filed under: Uncategorized , , ,

Useful cakephp resources

A couple of useful cakephp resources have turned up on the twittersphere which will super handy for those wanting to learn or increase their knowledge of cakephp.

Matt psuedo coder ssuper awesome cakephp tips

Chris Harjtes Refactoring Legacy Applications Using CakePHP

I’ve also been tagging cakephp related stuff on my delicious account – which you can find at http://delicious.com/brightstorm/cakephp.

Filed under: Uncategorized , ,

New cakephp release 1.2.3.8166

from gwoo at cakephp.org

I am happy to announce another release of CakePHP 1.2. CakePHP 1.2.3.8166[1] includes several bug fixes and most importantly a security fix. To understand the security issue please have a look at Ticket #6336[2]. While this may not affect every installation of Cake, we do recommend that everyone take the time to upgrade their applications. Also, note that there was a bug in Paginator related to changing directions on sorting that is now fixed. For a complete list of changes, please look at the changelog[3].

The release is available from the following link
[1] http://bakery.cakephp.org/articles/view/release-cakephp-1-2-3-8166
[2] https://trac.cakephp.org/ticket/6336

Once again, thanks to all the team at cakephp.org for an amazing product. Happy baking

Filed under: Uncategorized , ,

Exporting to a text file in mysql

Getting data out of a mysql database into a text file is pretty straight forward using mysqldump

mysqldump5 -u USERNAME -p DATABASE_NAME TABLE_NAMES > /PATH/TO/FILENAME

TABLE_NAMES are optional and need to separated by a space if you are exporting a couple.

Filed under: development , , ,

Named arguments vs cakephp sessions

Trying to capture named arguments and store them into a session in CakePHP was returning some unexpected results when I subsequently printed the session data.

My code simplified is as follows:

if( !empty($this->data)){
$params = $this->Session->read('Media.params');
pr($params);
} else {
$named = $this->params['named'];
$this->Session->write('Media.params',$named);
}

If i feed it a url as such http://testApp.com/controller/action/named1:value1/named:value2

I would expect the pr($params) to return an array as such:

array(
[named1]=>[value1]
[named2]=>[value2]
)

Except it was only returning:

array(
[named1]=>[value1]
)

Funny eh?

After a bit of fiddling, I managed to get it to work by adding an additional slash as such:

http://testApp.com/controller/action/named1:value1/named:value2/

which gave me the full named argument array.

For more about Sessions in CakePHP, visit http://book.cakephp.org/view/173/Sessions
and http://justkez.com/understanding-cakephp-sessions.

There are a few issues affecting this still, specifically if i add a namedArg to the end of a
$html->link() .

I have compensated for that as follows:
echo $html->link(__('Upload Media', true), array('controller'=> 'media', 'action'=>'upload','/article_id:'.$article['Article']['id']."/ "));
Note hacky ."/ "

When i establish whats up, I’ll post a reply here. If you know more than me, please leave a comment below.

Follow up:

The correct way to do this would be:

echo $html->link(__('Upload Media', true), array('controller'=> 'media', 'action'=>'upload','article_id:'=>$article['Article']['id']));

(thanks jon)

Filed under: development , , ,

what's hot

Flickr Photos

Monotonous greydux

Monotonous

Edwolf

More Photos

Sponsor Mike run the Bath Half marathon

mikek on twitter