Month: August 2010

  • Install Zend Server with Plesk

    据说 Zend 正在跟 Plesk 探讨怎么让他们的产品相互兼容。

    我没那么高深,无法让 Zend Server 完全兼容 Plesk,但可以做到——

    前台用上 Zend Server 版的 php (Plesk 前后台使用两个安装的 php),尽管 Plesk 后台误认为 php module not installed。我强行修改了 psa 数据库里的数据,改了什么我不记得了。说实话,把 Zend Server 和 Plesk 跑在一起意义也不大。

    Parallels Installed Components
    Parallels Installed Components
    Parallels with php 5.3.2 from Zend Server
    Parallels with php 5.3.2 from Zend Server
    Parallels php not installed
    Parallels php installed but showing as not installed
  • A support class to pluralise English words in Magento

    我写这个类更多地是为了补习一下英文。顺便说一下,我会逐渐把更多的 support classes 归于 Msdk module,意思是 Magento SDK.

    An ideal way to learn IT and English as a foreign language at a time.

    
    <?php
    class Qian_Mdsk_Helper_Plural extends Mage_Core_Helper_Abstract
    {
    /**
    * auto is a wrapper. it calls another method by language settings
    * @param int $nr
    * @param string $singularWord
    * @return string
    */
    public static function auto($nr, $singularWord) {
    //if english
    return self::english($nr, $singularWord, 's');
    }
    
    public static function english($nr, $singularWord, $pluralSuffix = 's') {
    if (abs($nr) == 1) {
    return "$nr $singularWord";
    }
    
    $no = Mage::helper('corex')->__("No");
    //If a word has more than one form of plural, and if the commonly used form is regular, the word will not be included in this dictionary.
    //e.g. roof => roofs (irregular) or rooves (regular)
    $dictionary = array(
    //sh rule exception
    'fish' => 'fish',
    
    //o rule exception
    'canto' => 'cantos',
    'homo' => 'homos',
    'piano' => 'pianos',
    'portico' => 'porticos',
    'pro' => 'pros',
    'quarto' => 'quartos',
    'kimono' => 'kimonos',
    'zoo' => 'zoos',
    'igloo' => 'igloos',
    'kangaroo' => 'kangaroo',
    'kniazhestvo' => 'kniazhestva',
    
    //x rule exception
    'matrix' => 'matrices',
    'vertex' => 'vertices',
    
    //s rule exception
    'alumnus' => 'alumni',
    'corpus' => 'corpora',
    'focus' => 'foci',
    'genus' => 'genera',
    'prospectus' => 'prospecti',
    'radius' => 'radii',
    'syllabus' => 'syllabi',
    'viscus' => 'viscera',
    'fungus' => 'fungi',
    'terminus' => 'termini',
    'uterus' => 'uteri',
    'Atlas' => 'Atlantes',
    
    'species' => 'species',
    'series' => 'series',
    'blues' => 'blues',
    'axis' => 'axes',
    'testis' => 'testes',
    
    //y rule exception
    'Germany' => 'Germanys',
    'Harry' => 'Harrys',
    
    //f rule exception
    'staff' => 'staff',
    'flagstaff' => 'flagstaffs',
    'proof' => 'proofs',
    
    //other exception
    //singular and plural are identical
    'people' => 'people',
    'deer' => 'deer',
    'moose' => 'moose',
    'sheep' => 'sheep',
    'bison' => 'bison',
    'salmon' => 'salmon',
    'pike' => 'pike',
    'trout' => 'trout',
    'swine' => 'swine',
    'aircraft' => 'aircraft',
    'head' => 'head',
    'stone' => 'stone',
    'benshi' => 'benshi',
    'otaku' => 'otaku',
    'samurai' => 'samurai',
    'Māori' => 'Māori',
    'marae' => 'marae',
    'waka' => 'waka',
    
    //very irregular exception
    'child' => 'children',
    
    'alumna' => 'alumnae',
    
    'mouse' => 'mice',
    'louse' => 'lice',
    
    'tooth' => 'teeth',
    'foot' => 'feet',
    'goose' => 'geese',
    
    'automaton' => 'automata',
    'criterion' => 'criteria',
    'phenomenon' => 'phenomena',
    'polyhedron' => 'polyhedra',
    
    'addendum' => 'addenda',
    'agendum' => 'agenda',
    'consortium' => 'consortia',
    'corrigendum' => 'corrigenda',
    'datum' => 'data',
    'medium' => 'media',
    'memorandum' => 'memoranda',
    'millennium' => 'millennia',
    'symposium' => 'symposia',
    
    'stigma' => 'stigmata',
    'stoma' => 'stomata',
    'schema' => 'schemata',
    'dogma' => 'dogmata',
    'lemma' => 'lemmata',
    
    'beau' => 'beaux',
    'château' => 'châteaux',
    'tableau' => 'tableaux',
    
    'Inuk' => 'Inuit',
    'inukshuk' => 'inukshuit',
    
    'phalanx' => 'phalanges',
    
    );
    
    if (isset($dictionary[$singularWord])) {
    $pluralWord = $dictionary[$singularWord];
    }
    else {//some clever conversion
    $end = substr($singularWord, -3);
    if ($end == 'man') { //checking last 3 characters
    $pluralWord = substr($singularWord, 0, -3) . 'men';
    }
    elseif ($end == 'sis') {
    $pluralWord = substr($singularWord, 0, -3) . 'ses';
    }
    else {
    $end = substr($singularWord, -2);
    if ($end == 'ch' || $end == 'sh') {
    $pluralWord = $singularWord . 'es';
    }
    elseif ($end == 'fe') {
    $pluralWord = substr($singularWord, 0, -2) . 'ves';  //e.g. knife => knives, wife => wives
    }
    else {
    $end = substr($singularWord, -1);
    if (strpos('sxo', $end) === false) { //checking last character
    $pluralWord = $singularWord . 'es';
    }
    elseif ($end == 'f') {
    $pluralWord = substr($singularWord, 0, -1) . 'ves'; //e.g. half => halves
    }
    elseif ($end == 'y') {
    $secondLast = substr($singularWord, -2, 1);
    if (strpos('aeiou', $secondLast) === false) {
    $pluralWord = substr($singularWord, 0, -1) . 'ies'; //e.g. lady => ladies
    }
    else {
    $pluralWord = $singularWord . $pluralSuffix; //e.g. boy => boys
    }
    }
    else { //last rule
    $pluralWord = $singularWord . $pluralSuffix;
    }
    }
    }
    
    }
    
    if ($nr == 0) {
    return "$no $pluralWord";
    }
    else {
    return "$nr $pluralWord";
    }
    }
    
    }
    
    
  • What does -in:inbox mean to Gmail?

    In Gmail, type “-in:inbox” or “!in:inbox” in search box and click “Search Mail”,what emails will show up? All emails not in inbox? Not exactly.

    You know Gmail delivers conversions instead of emails as search result, so let’s use terminology conversion. Does “-in:inbox” come up with all conversions not in inbox? No, again.

    The collection of “-in:inbox” is all conversions not in inbox plus those conversions originated by me or to which I responded.

  • Ftp user chroot setting on CentOS

    在 CentOS 上,怎么把 linux user ftp 登录后限制在它的 home directory?很久以前我设置过一次,知道是很简单的一个设置,今天需要同样的事情再做一次,竟然怎么也想不起来。要命的是,google 了好几个小时都不得要领。

    可以说半天时间是浪费掉的。最后当然是重新找到了办法,赶紧记下来:

    Edit /etc/proftpd.conf, add

    DefaultRoot ~

    当然前提预装有 proftpd。如果还预装 plesk,则更简单,/etc/proftpd.conf 已含有

    DefaultRoot ~ psacln

    只要把新建的用户归入 secondary group psacln 即可。