Créer un compte ou loggez-vous pour pouvoir ajouter, commenter et noter les snippets.

Navigation

Tags relatifs

my Symfony Plugins

Plugins demos


My bookmarks

Vous pouvez commenter/noter en utilisant le compte anonymous (mot de passe: anonymous)
You can comment/rate using the anonymous account (password: anonymous).

Snippets taggés : "command" Snippets taggés : "command"

[Ubuntu] Lister tout les fichiers d'un répertoire récursivement avec la taille - 379 view(s)

du -ha

Pour n'avoir qu'un total global par fichier / répertoire :

du -hcs *
par COil le 2008-09-29, taggé : command  du  file  ubuntu 
(1 commentaire)

[PHP] Pattern chain of command - 86 view(s)

<?php
interface ICommand
{
  function onCommand( $name, $args );
}
 
class CommandChain
{
  private $_commands = array();
 
  public function addCommand( $cmd )
  {
    $this->_commands []= $cmd;
  }
 
  public function runCommand( $name, $args )
  {
    foreach( $this->_commands as $cmd )
    {
      if ( $cmd->onCommand( $name, $args ) )
        return;
    }
  }
}
 
class UserCommand implements ICommand
{
  public function onCommand( $name, $args )
  {
    if ( $name != 'addUser' ) return false;
    echo( "UserCommand handling 'addUser'\n" );
    return true;
  }
}
 
class MailCommand implements ICommand
{
  public function onCommand( $name, $args )
  {
    if ( $name != 'mail' ) return false;
    echo( "MailCommand handling 'mail'\n" );
    return true;
  }
}
 
$cc = new CommandChain();
$cc->addCommand( new UserCommand() );
$cc->addCommand( new MailCommand() );
$cc->runCommand( 'addUser', null );
$cc->runCommand( 'mail', null );
?>
 
par COil le 2008-09-29, taggé : command  pattern  php 
Debug toolbar