Monday, July 19, 2010

weekend wrap up

Lots of good and bad things happened during the past few days.
Google pulled the plug on the Nexus One after closing the web store. Steve is probably dancing away in joy right now...

Rackspace opened their excellent cloud platform. It's called OpenStack.
"open source software running on standard hardware"
That says it all. Nice move indeed. Very, very nice.

If that's too much to chew here's some AIR tips and a nifty mini game framework from Mike C.

Wednesday, June 30, 2010

on Video on Web on Moving on

A while ago Mark Pilgrim wrote a comprehensive article on the state of web video.
The article is here and from it you can pretty much understand the issue of audio and video codecs and the containers they can be delivered in. If you do not know yet what the whole flash vs html5 video debate is all about this is a must read.
The only problem with the article mentioned above is that it talks about the future.
For now here you'll find a pretty clear and to the point explanation of why flash video is here to stay for the next couple of years. That's John Harding of the YouTube API Blog.
The main reasons would be that it's been here for a while now, it works really good and it has great support.
So do we change the web because we need to change the mobile or do we leave the web as is and we figure out the optimal solution for the mobile world?
If M$ would fix IE then I think that the same efforts to support it could go in the direction of creating a mobile version for a web application.

Friday, May 28, 2010

Mea Culpa on Alarming Development

"Programming will not grow up until our culture grows up. We can only patiently and persistently do our part to elevate the level of discourse, and share what wisdom we have gained. "
[...
"If you are the only one who can understand and maintain your code, then you must realize that you can never have a vacation, get a promotion, or leave the project; so, code so that anyone can understand and maintain your code so that you are not forever chained to that one piece of code in that one project."

Thursday, May 20, 2010

the cloud Cloudkick sidekick

Man does this look delicious or what?!
And it works too!

  • The circles represent your servers
  • A server's location is based on the metrics on the axes
  • More powerful servers will be larger than less powerful ones
  • Colors are the same as on the dashboard, except
  • Red pulsing circles indicate servers in a warning/critical state
  • Flashing circles indicate a server is being updated with new data
  • Click a server to show more detailed information about it
  • Rotate the view with the arrow keys, or by clicking and dragging in an empty area
  • Rotate the view with the arrow keys, or by clicking and dragging in an empty area
Now I just need to go find my Minority Report glove :D

Wednesday, April 14, 2010

CakePHP single table inheritance implementation using class inheritance

If you have a couple of document types that you don't want to create individual db tables for you can put them all in a 'documents', have an abstract Document model class and create those document types as model classes each extending the Document class. You just need in your documents table a column named like the TYPE_COLUMN constant declared in this class.
Disclaimer: I borrowed most of the code form the ExtendableBehavior (http://bakery.cakephp.org/articles/view/extendablebehavior) but wrote the idea as an abstract class rather than a Behavior. Some people on IRC are already waiting for this to break in some unknown ways so use it at your own risk!
I will post updates if it breaks :)

Update: well it still works fine. In case you didn't catch the trick, u need to put the 'type' column in the documents table!

abstract class Document extends AppModel {
 
 const TYPE_COLUMN = 'type';
 
 var $useTable = 'documents';
 
 function beforeFind ($queryData=null) {
  if (!isset($queryData['conditions'])) {
   $queryData['conditions'] = array();
  }
  if (is_string($queryData['conditions'])) {
   if (strlen(trim($queryData['conditions']))) {
    $queryData['conditions'] = "({$queryData['conditions']}) AND ";
   }
   $queryData['conditions'] .= $this->alias. '.'. self::TYPE_COLUMN. ' = '. $this->alias;
  } elseif (is_array($queryData['conditions'])) { 
   if (!isset($queryData['conditions'][$this->alias.'.'. self::TYPE_COLUMN])) {
    $queryData['conditions'][$this->alias. '.'. self::TYPE_COLUMN] = array(); 
   }
   $queryData['conditions'][$this->alias. '.'. self::TYPE_COLUMN] = $this->alias;
  }
  
  return $queryData;
 }
 
 function beforeSave () {
  if (array_key_exists(self::TYPE_COLUMN, $this->_schema)) { 
            if (!isset($this->data[$this->alias])) {
                $this->data[$this->alias] = array();
            } 
            $this->data[$this->alias][self::TYPE_COLUMN] = $this->alias; 
        } 
        return true;
 }
}