Category Archives: Chỉ dẫn lập trình

MySQL grant and revoke

mysql -uroot -pRooTIsmE -h mysqlServer

create user special@’%’ identified by ‘password’;
grant all on *.* to special@’%’ identified by ‘password’;
revoke drop, delete on *.* from special@’%’ identified by ‘password’;
flush privileges;
show grants for special@’%’;
exit;

mysql -uspecial -ppassword
create database huypv;
drop database huypv;
#ERROR 1044 (42000): Access denied for user ‘special’@’%’ to database ‘huypv’

How to write a simple WordPress Plugin

Create new text file: simple-plugin.php
Enter following content:

This entry is posted by XXX – Thank you for reading’;
}

add_filter(‘the_content’, ‘modifyPostContent’);

Zip it and upload to server to install new plugin. Access your single page and see at end of post.

If you want to use class, you change your code

class YourClassName {
function modifyPostContent($content) {
return $content . ‘
This entry is posted by XXX – Thank you for reading’;
}
}

add_filter(‘the_content’, array(‘YourClassName’, ‘modifyPostContent’));

Xử lý lỗi server error 500 trên toàn site

Vừa nãy bị, vào cPanel thì vẫn okie. Thử /zzz.txt cũng thấy phun ra 500.
Xem qua access log thì thấy bị từ chiều.
Quái, có làm éo gì đâu, hỏi bác support server phát.

abc xyz

Xóa bố thằng .htaccess đi xem nào
F5, reload lại trang. Ơ, đúng thật, mình có thay đổi gì file .htaccess đâu nhỉ. Quái, biết thế đã.

Call function ConversionRate from Web-service

<?php    
    $wsdl = 'http://www.webservicex.net/CurrencyConvertor.asmx?WSDL';
    $func = 'ConversionRate';
    $params = array(
        'FromCurrency' => 'USD',
        'ToCurrency' => 'VND',
        );
    
    $client = new SoapClient($wsdl, array('trace' => 1));
    $return = $client->__call($func, array('xxx' => $params));
    
    #var_dump($client->__getLastRequest());
    echo '1USD = ' . number_format($return->ConversionRateResult) . 'VND';

SVN How to revert a bad commit

Ever made that commit that messed up your repository and spent some time wondering how to undo, or revert a bad commit? In subversion you really can’t go back a revision, but you can merge your copy with the previous repository version and then commit the changes to correct your mistakes:

cd /home/huypv/domain

svn co [repository_url] phungvanhuy.net

svn log | more

svn merge -r [current_version]:[previous_version] [repository_url]

svn ci -m "Reverting previous commit and going back to revision [previous_version]."

This is a life saver.