Category: 小小草

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

  • 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 的数据就达到了它的设计要求。

  • Magento compilation does not help if php is already optimised

    实测了一下,在已做了一些 Magento 速度优化措施以后,如 php opcode,memcache,mysql query cache,再启用 Magento 编译,速度并未提高,request per second 反而从 11 降为 8。

  • Fix Postfix in Virtualmin

    今天在安装 Virtualmin for Webmin 时碰到一个问题:启用 Postfix 时出错,出错信息为:

    A problem was found with your Postfix virtual maps : No map sources were found in the Postfix configuration

    解决方法是: edit the /etc/postfix/main.cf file and add:

    virtual_alias_maps = hash:/etc/postfix/virtual

  • I can dislike vtigercrm just for one little thing

    vtigercrm 早期版本安装总不顺利,最近下了 5.1.0 版,希望看到它有改进,但还是失望。

    原因是我在安装时设定的密码含有非字母数字字符,vtigercrm 也没说这样不可以,还告诉我安装成功。可我总是登录不了,一时没想到是特殊字符的原因,以为是我输入错误或其他原因,于是拆了重装了好几次,均无法登录。

    用了密码重置为 admin/admin 的办法,终于得以登录:

    update vtiger_users set user_hash=’21232f297a57a5a743894a0e4a801fc3′, user_password=’adpexzg3FUZAk’,confirm_password=’adoY/6Mlw8kqg’,crypt_type=” where user_name=’admin’;

    然后尝试着修改密码成我想要的密码,就算含有对 vtigercrm 非法的字符,vtigercrm 也没有阻止我修改,只是不让我登录,很不友好,我不喜欢。

  • Magento defect in running multi-stores

    First I want to declare – I love Magento very much!

    但再完美的东西也是有缺陷的。正是因为 Magento 接近完美,所以改正它缺陷的愿望也强烈些。Magento website – store – storeview 3-tier 的模型逻辑分明,可是 Magento 在解释模型时用词不一致,造成最终用户和开发者如果是同一人的话思维混乱:

    最终用户:website – store – storeview

    These terms are used in documentation, and designer’s guide.

    开发者:website – group – store

    These terms are used in php code, and database table/field names.

    这还是小毛病,关键是根据访问域名(或别的条件)加载不同的 website, store, storeview 时,我能看到的所有的指导都是叫我们修改 index.php,用一个条件选择 Mage:run(‘code’) 取代 Mage:run()。这样每次升级 Magento 都要特殊照顾一下 index.php,不符合 Magento 自己提倡的安全升级的原则。

    其实如果是根据 base url 决定加载不同的 website, store, storeview,database 里已有对应的资料,就不能让 Magento 自己去选择加载,何必要用 php 再写一遍?因为 Magento overwrite 规则在 index.php 和 Mage.php 以后生效,所以我不欣赏修改 index.php 和 Mage.php 任何一部分。看来看去,只有 Mage_Core_Model_App 才是切入点,要写一个 Company_Core_Model_App 才能让 Magento 自动加载不同的 website, store, storeview。

  • Make a future proof theme for Magento

    很久以前做 Magento theme,直接把 default theme 所在目录复制到另一个目录。后来才知道定制 theme 不是这么干的,正确的做法是新建一个目录,要改什么文件就拷贝什么文件过来修改。这样既能个性化,又能向后兼容(如果修改部分跟新版本的 default 不冲突的话)。

    Magento 在我做完 theme 后的某个版本开始支持 flat category 和 flat product,我一直无法垂涎这个功能,但一启用页面就是空白。知道今天才定下心来修改我的 theme 下的文件,把我没修改过的文件都删了。其实修改过的文件不多,十个左右,然后比较了新老文件(我修改的文件和对应的新版 default 文件)的差异,添加了一些 default theme 新增的语句,终于可以启用 flat category 和 flat product 啦。

    因为产品不多,只有 200 个,感觉快了 3-5%,request per second 从 11 以下跃成 11 以上,Pingdom 测试也得到一个创记录的 2.23 秒(其中 index.php 的完成时间 0.6 秒,但 Pingdom 多次测试结果之间变化较大,大概跟 Pingdom 服务器当时状态有很大关系)。虽然没有体会到 Magento 声称在 2,000 个产品时能有 40% 的速度提升,我还是很高兴。

    顺便我把 Magento 从 1.3.2.1 升级成 1.3.2.3,先用的是 magento connect 升级(以前有过一次 magento connect 升级失败的经历,这次想 give magento connect another try,考验一下它)。升级过程没有提示有错误,升级后前台也正常,可后台 system -> configure -> catalog -> frontend -> Use Flat Catalog Category / Use Flat Catalog Product 消失了, system -> configure -> admin 也不见了。只好 ssh tar 解压源文件全部覆盖了 Magento 的安装文件,终于一切回归正常。

  • top.links.phtml in Magento can be safely deleted

    Magento 的 default, modern, blank 等 templates 都带有一个文件 top.links.phtml (在 template/page/html),第一眼看上去都会认为它是页面右上角 My Account, My Wishlist, My Cart, Checkout, Log In 的模板,但其实 top links 和 footer links 用的是同一个模板,即 template/page/template/link.phtml。

    没有任何地方引用到 top.links.phtml,删了它一点事也没有;如果加载它,反而会出错。我猜 Magento core developers 原想把 top links 和 footer links 做成不同的模板,后来合并了模板,忘了删除一个废弃的文件?

  • Magento downloader remember server path

    我多次把 Magento 从一个服务器移动到另一个服务器,一直认为 Magento 不在意安装路径的改变,因为 Magento 总是在运行时检测安装位置(对比 WordPress 把 server absolute path 保存在数据库里,而且每个上传的文件都要保存一遍,不可取)。但今天我发现我错了:Magento downloader 仍保存有部分 server path 的信息,迁移 Magento 到新服务器后,Magento connect 不能正常工作。

    有人提供了以下方法查找替换 downloader 目录下所有文件里的 OLD_PATH 成 NEW_PATH:

    //shows all files with OLD_PATH element
    find . -type f -exec grep -q "OLD_PATH" '{}' \; -print
    //Replaces OLD_PATH string in all occurrences in every file to NEW_PATH
    find . -type f -print | xargs sed -i -e ’s/OLD_PATH/NEW_PATH/g’

    我试了试,查找替换是成功的,但 magento connect 还是不能工作,还是把 downloader 删了重装一遍来得干脆利落。