Category: 小小草

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

  • Open Office惨不忍睹

    虽然我是 open source 的拥护者,但有人说 Open office 惨不忍睹,我也不得不承认。

    在 Open Office Writer for Linux 下,按下 Ctrl + C 企图拷贝“邮编”这两个字,程序就死了。我试了好几次,Open Office 每次都死。这种毛病也真稀奇。

  • How Google group conversation is a mystery

    我用一个 Google 邮箱 pop 另一个 Google 邮箱的1139封会话。Pop 结束后,接收方显示只有 1125封会话。当时我以为是某些会话没有 Pop 成功。经过一番核对,发现老邮箱里独立的某些会话,在新邮箱里被合并成一个会话。

    于是我对 Google 合并会话的条件算法产生了兴趣,又经过一番搜索,发现 Google 对此算法讳莫如深。其实这算法有很大缺陷,Feature request 讨论组里对手工分拆和合并会话的呼声就很高。我也很想要这个功能。

  • Half constructed Magento objects

    Magento 对象有个半构造状态。称之为半构造或许不恰当,但我一时找不到更合适的词来表达。

    先说一个我以前碰到的问题:为什么在产品列表里的产品取不到自定义属性的值?因为此时产品处于半构造状态,半构造状态默认不加载自定义属性。只有在某产品所在的那一产品页,该产品才处于全构造状态。Magento 对象半构造主要是照顾速度。

    再说另一个问题:甲产品是一个 bundled product,bundled items 里只有一个 option,该 option 里只有一个 selection,该 selection 是 20 件乙产品。我不明白 Magento 创造这么多名词干嘛,又是 option,又是 selection,暂且不管它,就按 Magento 层层 wrapper 来办。在甲产品的产品页上,要取得捆绑数量(20),可以这么办——

    $_product = $this->getProduct(); //$_product is 甲产品
    $_option = current($_product->getOptions());  //because only one option
    $_selection = current($_option->getSelections()); //because only one selection
    $_qty = $_selection->getSelectionQty(); 
    

    如果甲产品是乙产品的相关产品,在乙产品的产品页上,要取得相关产品甲产品的捆绑数量,就无法按上述思路办,这是因为此时甲产品处于半构造状态。那么换个思路,这么来——

    $_product = Mage::getModel('catalog/product')->loadByAttribute('sku',$sku); //$_product is 甲产品
    $_productType = $_product->getTypeInstance();
    $_optionCollection = $_productType->getOptionsCollection();
    $_selectionCollection = $_productType->getSelectionsCollection($_productType->getOptionsIds());
    $_option = current($_optionCollection->appendSelections($_selectionCollection));
    $_selection = current($_option->getSelections());
    

    以上代码微妙之处就在$_option = current($_optionCollection->appendSelections($_selectionCollection));,它把半构造状态的甲产品进一步prepare,于是就有了selections。

  • SERVER_NAME vs HTTP_HOST

    If server_name is something like “*.mydomain.com”, $server_name is exactly “*.mydomain.com”. If $server_name is passed on to fastcgi_param as SERVER_NAME, in the program, for example, php $_SERVER[‘SERVER_NAME’] will be exactly “*.mydomain.com”. However, _SERVER[“HTTP_HOST”] shows the value most of us would expect, i.e. the host name in the address bar.

    In Nginx, I have set up a mechanism to install some popular scripts once, and use in multiple websites. I do not want people to find these websites are run under one roof. But if I write multiple websites in one line:

    
    server_name domain1.com domain2.com domain3.com;
    
    

    $_SERVER[‘SERVER_NAME’] is always assigned domain1.com no matter the host is domain2.com or domain3.com.

    To avoid that, I have to break three websites into three server block in nginx.

    $_SERVER[‘HTTP_HOST’] is always the host. But I can not control how people write the script. Breaking hosts into separate server blocks is recommended.

  • Nautilus mount

    Nautilus is quite good, easy to use in regards to its mount feature. It can automatically “mount” Windows Share via smb:// protocol. However, some software, e.g. FileZilla (now 3.2.4.1) can not read from or write to smb:// protocol. A genuine Linux mount is more helpful than Nautilus mount.

  • Problem with newly created accounts at Google Apps Mail

    I had a very bad day yesterday with Google Apps Mail. This service is good overall, but this time was exception.

    I newly set up a Google Apps account and created several user accounts last Friday. I used my administrator account to login and did some settings. Yesterday when other users wanted to login Google Apps Mail, they encountered this error:

    The page isn’t redirecting properly

    Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

    * This problem can sometimes be caused by disabling or refusing to accept
    cookies.

    The symptom was – Google was jumping between www.google.com and mail.google.com in an endless loop. I tried various browsers on different machines and had the same problem. Only Google Apps Mail was affected, while Google Apps Calendar, Documents and Sites were all right. And only user accounts created last Friday but never login until Monday were affected, while my account and newly created test account on Monday were all right.

    I tried all suggested solutions in vain –

    • clear cookies
    • restart browser, even machines
    • disable and re-enable Mail, Docs service
    • login as a mobile user
    • change “passive” and “rm” parameters in redirecting url

    I tried to report this problem to Google but found nowhere to report (just because it is a free standard account?) I suppose it was a synchronisation problem among Google millions servers, which could be solved by itself giving time. However I was not sure of the time scale, so the final solution came up at the cost of losing incoming emails during weekends –

    I deleted user accounts and re-create them. (Here comes another episode – Google won’t allow a newly deleted account being created within 5 days. The workaround is creating another user account and aliasing the old one.)

  • Fpmforge causes depsolving problems

    我其中一个  Fedora 安装有很多 repositories,不能用 yum update 很久了,update 时总是出错。今天静下心来看看,其实太简单了,其中一个错误提示里就指出

    perl-DBD-mysql-4.012-1.el5.rf.x86_64 from rpmforge has depsolving problems

    我以前怎么就没仔细读呢,这里不是指出就是 rpmforge 导致依赖解析问题嘛,把它删了就没事了。我记不得以前为什么要加 rpmforge 进 yum repositories,反正现在用不着了。终于见到久违的——

    Transaction Summary
    ================================================================================
    Install     11 Package(s)
    Update     293 Package(s)
    Remove       0 Package(s)

    Total download size: 580 M
    Is this ok [y/N]: y

  • I do not like Apple

    我不喜欢 Apple,原因太多了:

    1. 不能接受 Apple 的海盗逻辑。很早以前看到的介绍 Apple 的文章,说 Apple 总部挂海盗旗倡导一种独立独行的风格。独立独行有多种理解,但在 IT 行业搞独立独行就是不遵守标准,给用户带来不便,我看 Apple 也自讨苦吃,独立独行打不开市场份额。
    2. 鼠标只有一个键。因为用户搞不清楚该按哪个键?那也把用户想得太傻了,是不是微波炉、电视机也造一键式?
    3. 性能算高端,但贵得离谱。我不会把钱花在时装上,同样不会花在 Apple 的设计上。
    4. 东西可用性太差。老婆不听我劝告,买了 iphone,用过才说不好用。我想我一直说 Apple 的东西不好,但没有调查就没有发言权,所以既然有了 iphone,我有时也借来玩玩,就算调研吧。你不要说我说一套做一套,我真的不喜欢 iphone,但家里只有那一个玩意可以在厕所里上上网(我的手机两年没升级了,没法连接 WPA2),尽管用起来不方便,总好过没得用吧。
    5. 老婆跟我提过,iphone 装了 skype,在 3G 网络中无法用,只有在 wifi 中用。我以为是她没设置妥当,但实在没兴趣去折腾 iphone,昨天看新闻,才知道 iphone 本身就限制 voip 在 3G 中使用。那新闻还提到,Apple 没批准 Google Voice 进入 Apple App Store,理由一大堆。在我看来,Apple 就是怕开放应用。就让它怕去吧,就如独立独行一样,越怕越限制就把路越走越窄。

    P.S.  新闻提到,Apple 规定至少2人 review 一个 app,现有 40 fulltime app reviewers,已经 review 了 200,000 个 app。我就想不通了,Apple App Store 出来没几年吧,平均每人 review 了 10,000 个app?什么 review 质量啊。

  • Google Apps Mail alternative

    There is not an alternative to Google Apps Mail, which is free, configurable, and powerful.

    Currently the only way of swapping primary domain of Google Apps is – remove the alias domain and re-setup as new.

    In order to keep receiving emails during swapping primary domain, I have to find another email service provider for the transmission period. I am not surprised I can not find any. Google is good, which is why I am using it, but its uniqueness is not a cheerful thing for business. I have never practised on a mail server just because google apps mail is taking care of everything.

    It challenged me finding another email service provider, and finally I gave up. I used email forward service from my domain registrars and forwarded incoming emails to another google apps account.

    Google offer 50 users apps as standard for free. When my business grow over this figure, I prefer my own mail server(s) rather than paying google. It is a shame to be pushed to pay someone.

  • Intranet transport via internet ip address

    我有两台机子处于同一个内网,都有独立外网 IP。A 机用 http://ip_address/file 访问 B 机,如果 ip_address 为内网 IP,下载速度接近硬盘的读写速度极限;如果 ip_address 为外网 IP,下载速度为 2MByte/s,远低于内网速度,但又远高于 internet 速度(我用的是 2Mb 下行、0.5Mb 上行的 ADSL)。

    想来想去,我只好做以下解释:ip_address 为外网 IP 时,数据流经过 router,但不经过 internet,小小的 router 数据处理能力有限,每秒只能中转 2MB 的数据。这是个 ADSL2+ router,设计能力就是为了应付 24 Mb 二代ADSL,所以能处理 2MB/s 的数据就达到了它的设计要求。