Category: 小小草

IT 技术领域学海无涯。其实任何领域都学海无涯,无非 IT 发展太快了,让我有更多嘘唏。希望我掌握的技术有如小小草,虽然渺小,却有旺盛的生命力。

  • My review of Mybookworld 2TB

    尽管我很清楚数据备份的重要性,尽管我脑袋里有数据备份的方案,但数据灾难还是时有发生,因为这么多年来缺乏一个数据存放的终极地点,数据备份方案过于复杂,执行不便,落实不力。

    我所有可以动用的存储介质容量加起来估计会超过2TB,足够把我所有的数据备份好几遍,但我还是狠了狠心,购入了 WD My Book World Edition 2TB。

    打开包装,首先发现 WD My Book World Edition 2TB 不带 USB 接口,无法用 USB 以外置硬盘方式与主机相连。网络硬盘的存取速率太慢,我原想要一个与 Ethernet 连接同时使用的 USB 连接。我嫌麻烦,也不打算因为不带 USB 接口就去退货,期待它的网络存取速率能有改进。开机后一试,果然,相对我公司一年多购入的 WD My Book World Edition 1TB,现在的 2TB 网络存取速率快了近一倍,但也只有可怜的 5.8 MB/s。

    远程共享根本用不着 Mionet 的服务,所以我一来就禁用了它,以免它占用 My Book World 本来就不强大的 CPU。然后我逛了逛 Web 管理界面,感觉不错,比 1TB 多了很多功能。我原本设计了一套基于命令行管理文件的方案,补足 1TB Web 管理界面不足之处,现在看来要调整一下,充分利用 2TB 自带的 Web 管理界面——直观的就是美的。

    还没来得及仔细试用 WD My Book World Edition 2TB,不过第一印象还不错(比预期的好),我估计它的 CPU 要优于 1TB 的,内存也会更大一些(128M?)。

  • Google Docs defects

    个人感觉 Google Docs 不如 Google Mail 用得那么流畅。不过可以体谅,文档处理比电子邮件处理要复杂,难免有没考虑周全的地方。

    主要有两个地方用得不顺手:

    一是 Shared Folder within domain users。一旦域内某用户共享他的文件夹,共享用户应该能在”Folders shared with me”看到它,但事实上看不到,只能凭 owner 告知该文件夹的 url 才能访问,非常不方便。

    二是 Spreadsheet 中文输入不太好用。我用的是 Fedora 下 Python Pin Yin,在单击选中单元格时无法输入中文(但可以输入英文),非得双击进入单元格才能输入中文。不过,这不一定是 Google Docs 单方面的原因,或许是 Fedora 下 Python Pin Yin 的问题。

  • Get rid of annoying VirtualBox usbfs warning

    VirtualBox 升级到了 3.0.10,在启动 VirtualBox 时就有一个 Warning:

    VirtualBox Usbfs Warning
    VirtualBox Usbfs Warning

    研究了一下,原来是以前版本为了在 GuestOS 启用 USB 设备而在 /etc/fstab 里增加的一行

    none /sys/bus/usb/drivers usbfs devgid=???,devmode=774 0 0

    现在成了累赘,把它删了 Warning 就没了。

  • Magento module vs Zend Framework module

    Magento 和 Zend Framework 都有 module 这个概念,我觉得这两者在设计思路略有区别,不能拿 Zend Framework module 去套 Magento module,反之亦然。

    简单点说,Magento module 是功能模块,Zend Framework module 是物理模块。Magento 把系统分割为十几个子系统,每个子系统各司其职,相对独立,但在整个 Magento 框架下,相对独立的子系统也能非常方便地与其他子系统通信,调用其他子系统中的功能。Zend Framework module 着眼逻辑分层,从 module 到 controller 再到 action。Zend Framework 并没有为 module 之间的通信作过多的考虑,如果用户有此需求,需要自行考虑,比如借鉴 Magento 的做法,在 Zend Framework 上再套一个框架。

  • Solved my Fedora PC hangs at boot

    我的一台装有 Fedora 的电脑有个启动后无法进入图形界面的老毛病:每次有软件包升级以后,Fedora 都会以最新的一个内核版本启动。电脑陆续被安装了三个内核版本2.6.29.5,2.6.30.8,2.6.30.9。可是只有最老的内核才能把电脑启动起来,如果以新内核启动,提示信息是:

    virbr0: Starting userspace STP failed, starting kernel STP

    有人说是 libvirt 的 bug 造成的,有人说这个 bug 已解决。不管怎么样,我看卸载 libvirt 对我没什么影响,先 remove 再说——可问题依旧,但提示信息变了变:

    r8169: eth0: link up

    实在不知所云,我一直以为是虚拟机软件造成的问题。Google 了好一阵子,才发现可能是 nvidia 驱动有问题,解决办法是

    yum install kmod-nvidia

    只此一招就搞掂,虽然搞掂了也不知道那玩意干啥用的。

  • Magento: Pass values from Block to template

    There are many ways in Magento to pass values from Block to template. I think these two ways are neat:

    Method 1:

    in Block, $this->setVariableName($value);
    and in template, $this->getVariableName();

    Method 2:

    in Block, $this->assign(‘variableName’, $value);
    and in template, $variableName is ready to use.

  • Zend Framework in Magento

    The library of Zend Framework included in Magento under lib folder is not the genuine Zend Framework. Although I don’t know why Magento did that, I do know:

    • If I replace Magento lib/Zend with genuine ZF, Magento throws errors.
    • If I put geninue ZF in php include_path, Magento appends it to its own include_path, and Magento runs into fussy status. I notice email facility stops working. There may be more functionalities affected.
    • I have loads of code extending Zend_Form. I was intended to reuse them in Magento without rewriting. However, Zend_Form depends on Zend_View, which is not handy in Magento.

    As one of caveats I’ve got from Magento, is whenever possible, avoid touching Zend classes directly.

  • Magento database fetch mode

    I was used to write $modelName->column_name to get attribute value in database. It requires $resource->_getReadAdapter()->setFetchMode(Zend_Db::FETCH_OBJ);.

    However, it is not Magento’s default fetch mode (default is Zend_Db:FETCH_ASSOC). Whenever fetch mode is changed, it must be changed back to the default after using it. Otherwise, method getCollection() of ALL models will stop working. There may be other side effects if you leave the adapter’s fetch mode changed.

  • Surcharge on card payment in Magento

    I just searched for a solution to surcharge customers for a certain PSP in Magento. The only thing I could find a module which priced at USD 49. I also found a lot of argument about whether card payment surcharge is illegal or against PSP’s policy, to which I do not care. What I do care is a free and easy solution to do the job.

    Looking at Promotions -> Shopping Cart Price Rules, we can give discount for some kinds of payment method. But the discount can not be minus, which makes it work as surcharge. However, Magento only validates discount must be positive when saving a shopping cart price rule to database. It does not validate again when applying this rule. Therefore, we can make up a rule, enter discount with a positive value, then change the value to minus in database. That’s all you need to do to surcharge customers.

    By the way, I think Magento validation on discount limits its usability. Why not use the salesrule module for both promotions and surcharges? I really like to see the menu Promotions be replaced by Sales Rules. (The word salesrule is already being used as table name and in script.)

  • Cross-browser CSS

    Today I did something CSS cross-browser testing. Here are some of my findings today.

    • Validate Xhtml / Html before styling. I put form element between table and tr element which make it an invalid xhtml document and cause CSS rendering in a strange way in IE. (IE is generally bad in W3C standards but this time it is good – it reminds me to validate xhtml.)
    • -webkit-border-fit:lines

      is for Sarifi and Chrome only, making elements “shrink”, even block elements.
      > selector can’t be understand by IE6 and under.

    • Few people are using IE5.5 or under, so I decide not to bother about layout in IE5.5 or under.
    • Block elements have overflow by default to show in IE6, So if I want to set the height of a block element, I need also set
      overflow:hidden
    • Cleaning elements with
      clear:both

      to clear floating elements above better be placed inside the same parent element of floating elements, otherwise in IE6, the elements after cleaning elements will not align nicely. for example:

      
      <div class="parent-element">
          <div class="floating-element">...</div>
          <div class="floating-element">...</div>
          <div class="cleaning-element">&nbsp;</div>
      </div>