Author: 芳草苑主

  • Fedora services command line restart

    To restart some services of Fedora linux using command line –

    apache: /etc/init.d/httpd restart
    named: /etc/init.d/named restart
    mysql: /etc/init.d/mysqld restart

    To turn on and off firewall –

    off: /etc/init.d/iptables save
    /etc/init.d/iptables stop

    on: /etc/init.d/iptables start

  • Crontab file does not accept variables

    我建了一个每日自动备份的cron job,备份文件的文件含有系统日期`date +%m%d%y`,但发现crontab file里command不接受变量,导致crontab file这一行被忽略。

    我只好把含变量的command专门建一个bash文件,command间接由crontab file调用。

  • Magento new version notification is annoying

    It is exciting to see Magento new versions keep coming out once after a while. Magento notify administrator upon login, and administrator upgrades it, then Magento should stop notifying until another new version is available. The logic should be as simple as that.

    However, currently Magento message is always active even after upgrading. It only disappears when administrator marks it read or deletes it. Very annoying, isn’t it?

  • PayPal问题多多

    在使用paypal越来越深入时,我和同事们发现了paypal存在着很多问题,有些问题还算是低级错误,所以给我们的感觉是paypal对business用户(特别是美国以外的business用户)照顾得不周到。可能paypal名声在外,原来在我心目中是一个非常好用的payment solution,期望值高了,失望也大。平心而论,这些问题还不是nightmaire,如果发生在其他的payment service provider,我也不会有那么大感慨。

    目前我碰到的最大的问题是:paypal download history下载来的交易记录不能直接拿来做帐用,我专门写了个转化程序,用于正规化交易记录。从paypal download history中,可以下载到好几种交易记录,我主要关心两种:all activities和balance affecting payment。前者确实包含了所有的交易活动,但后者包含了一些不影响余额的交易。

    说到余额,记录中balance那一栏只能参考,很多时候它并不是真正的余额,搞得bookkeeper很头痛,这也是我写转化程序的直接动机。迄今为止,我遇到14种交易类型(type):

    1. eBay Payment Sent
    2. Payment Received  (仅用于money request)
    3. Pre-approved Payment Sent (paypal月费)
    4. Refund
    5. Shopping Cart Item (paypal cart模式,excluding VAT)
    6. Shopping Cart Payment Received (paypal cart模式,including VAT)
    7. Temporary Hold (dispute时,paypal暂扣款)
    8. Update to eCheque Received
    9. Update to Payment Received (虚拟终端模式,accept transaction)
    10. Update to Reversal (dispute结束后,paypal释放暂扣款)
    11. Virtual Terminal Transaction
    12. Web Accept Payment Received
    13. Web Accept Payment Sent
    14. Withdraw Funds to a Bank Account

    通过对比all activities交易记录和balance affecting payment交易记录,以下三种记录包含在all activities里,但被balance affecting payment剔除:

    1. Virtual Terminal Transaction with Status “Pending”
    2. Virtual Terminal Transaction with Status “Refused” (若accept transaction,会有两条记录,type分别为Virtual Terminal Transaction 和 Update to Payment Received;若refuse transaction, 只有一条记录,type仍是Virtual Terminal Transaction,只是Status为Refused)
    3. Web Accept Payment Received if payment by eCheque (upon being paid, not cleared)

    但实际上,仅剔除以上三种记录远远不够。比如:

    Shopping Cart Item 是 Shopping Cart Payment Received 同笔交易,excluding VAT的记录不应该和including VAT的记录同时进入数据表;

    Virtual Terminal Transaction 如果有accept transaction,就会有Update to Payment Received,同笔交易决不该有两条记录affacting balance。

    正因为paypal 对balance affecting 逻辑不清,balance那一栏的数据就很乱套。光看paypal net 和 balance那两栏,很多人会认为上一条记录的balance 加当前记录的net 应该等于当前的balance,但paypal balance不是这么算的,谁也不知道paypal的逻辑,搞得bookkeeper说paypal有时会就一笔交易重复收费。

    事实上,说paypal重复收费也冤枉了paypal。我转化程序的验证balance和paypal的最终余额还是完全吻合的。只能怪paypal提供的原始记录没有逻辑。

  • Workaround to row cannot be located for updating

    用ADO + ODBC操作Mysql database,用起来总不顺手。经常有莫名其妙的错误,其中不乏connector bugs。这些bugs不是我等能解决的,只有尽量不去触发bugs才是上策。

    比如,我今天在使用recordset.update时被提示”Row cannot be located for updating. Some values may have been changed since it was last read.” 我排错了好久,最后总结出以下best practices:

    • 避免使用”SELECT *”来查询,用到哪些字段就SELECT那些字段;
    • 如果SELECT中的字段中,某些值没有改变,recordset.update 可能会出错(也就是说,所有字段值都被改变后才能update)
    • Connector/ODBC Application Specific Tips特别提到Access can’t always handle the MySQL DATE column properly. If you have a problem with these, change the columns to DATETIME.
    • Float或double类型字段值,避免用Float或Double运算后的值直接去更新,应该保留必要精度后的值去更新。例如,x和y都是double类型,total字段也是double类型,不要用x+y去更新total字段,若total只要保留两位小数,就用formatnumber(x+y, 2)去更新total。

    综上,为了简单起见,如果要update a record,干脆先删除这条record,再recordset.addnew,赋予新值。对于新鲜记录的更新,以上四种可能的错误均没有出现。

  • I give up Godaddy’s DNS servers

    When I first started with Godaddy, I used to use my dedicated server as a DNS server for my domains. At that time, I could only use Godaddy’s Simple Control Panel (Turbopanel in another name) to edit DNS settings. Simple Control Panel did not have export and import facility, which meant editing multiple domains’ DNS settings was time consuming. Over a period of time, I discovered Godaddy domain management GUI was so powerful, but I must use Godaddy’s DNS servers, e.g. mns01.domaincontrol.com, etc. I knew these DNS servers were slower than average (probably they are overloaded), but I really need a facility like export and import DNS settings. Godaddy domain management GUI could let me export and import DNS settings, so I was quite relaxed using Godaddy’s DNS servers for a long time.

    Not until recently had I compared one of my websites using and not using Godaddy’s DNS servers. The benchmark score as per webceo report is 2 vs 6 (0 is the worst, 10 is the best). Using Godaddy’s DNS servers, the website DNS lookup time is extremely longer than if not. When DNS lookup is slow, connection, ping, and download are all slow.

    Reading these reports, I decided to relaunch my own dedicated server as a DNS server. However, I do not like use Simple Control Panel to manage DNS settings. I spend quite some time research Godaddy Fedora server structure. Finally I find the named conf files are stored at /var/named-chroot/etc/name-turbopanel.conf and /var/named-chroot/var/named/forward.mydomain. So I can edit these files to achieve the efficiency as using export and import.

  • Find more software, use good software

    最近在找一些开源的面向业务的解决方案,一时还没找到,倒是又发现不少以前不知道的软件,有的开发得很精致,让人叹为观止。

    同时又看到一些很垃圾的、但名气又很响的、让不懂行的人趋之若鹜的商业软件,想想很不服气——凭什么让这么多人上当?

    找着找着,脑袋里突然冒出冰心老人说过的话:多读书、读好书(全句是读书好、多读书、读好书)。我想套用一下:多找软件、用好软件!

  • Host Opentaps on Godaddy Deluxe shared hosting

    今天发现 Godaddy Deluxe share hosting packaging 竟然支持SSH了。这下可以试着把Opentaps装上去看看效果如何。

  • Call another bat in bat

    又学了一回DOS命令。

    因为我要重命令4个子目录下432个文件(4 x 108个文件,是4个一组,共108组),我写了一个ren4.bat执行4条ren命令重命名一组文件,然后又写了一个renall.bat执行 ren4.bat 108次。

    一开始我直接在renall.bat写ren4 [old name] [new name] 108行,结果renall.bat只执行了一行就中止了,google了一下才知道要在一个批处理文件调用多个批处理,得用call ren4 [old name] [new name] 无论多少行。

  • 女儿一岁了

    英国人做的蛋糕太硬,只会用icing,不好吃。所以特意去伦敦买了个中国蛋糕来庆生。