Tuesday, June 21, 2011

Revert all modified files in an SVN repo

svn st | grep -e '^M' | awk '{print $2}' | xargs svn revert

Friday, June 10, 2011

Replace in string : preg_replace

        $pattern = '/(\d+),(\w+)/i';
        $replacement = '<strong>${1}</strong>,$2';
        return  Mage::log( $this->getQuote()->getStore()->formatPrice($price , true) );
        return preg_replace($pattern, $replacement, Mage::log( $this->getQuote()->getStore()->formatPrice($price , false) ) );



Thursday, March 31, 2011

Find folder

find / -name "test_*" -type d -print


Friday, February 18, 2011

Symbolic link

ln -s /etc/apache2/sites-available/phpmyadmin.domain.net /etc/apache2/sites-enabled/phpmyadmin.domain.net

Thursday, January 20, 2011

[PHP] Difference betwen tow date

    public function _getDiffInHours( $date ){
        $usDate = str_replace ( "/" , "-" ,$date);
        $now = strtotime("now");
        $nextDate = strtotime ( $usDate );
        if(! is_numeric( $nextDate ) || ! is_numeric( $now ) || $nextDate <  $now ){
            return 0;
        }
        return floor( ($nextDate-$now) / (60*60));
    }

Friday, January 7, 2011

Log in other file that system.log

    public function _log($msg){
        $nameFile = 'other-file-'.date ( "Y-m-d-H" ).'.log';
        Mage::log($msg, null, $nameFile );
    }

Wednesday, January 5, 2011

Replace accented characters

    public function normaliza ($string){
        $a = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ';   
        $b = 'aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr';
        $string = utf8_decode($string);   
        $string = strtr($string, utf8_decode($a), $b);
        $string = strtolower($string);
        return  utf8_encode($string) ;
    }     
Powered by Blogger.