Open source for a purpose

我花了一年多时间写了一个 branded made to order 的程序。整个结构多次变化,经历了多次从繁到简,再到繁,再到简。直到今天,结构变得非常简单、却能应付不预知的复杂行业。 刚开始写时,我也没想要写一个行业无关的程序,只想有一个能用在我所在的行业就可以了;我也没想结构可以重构得如此简单,如果跳过过程看结果的话,10 分钟(不夸张)就可以读懂结构,只有我自己知道这样的结构是凭无数次的灵感堆积起来的。 言归正传,这个程序设计成 magento module,最初我也想开源发布的。但时至今日,我想敝帚自珍了。我本身非常崇尚开源,这是我第一个不想开源的程序,为什么我有这样的想法?我演绎了一下: 开源项目都有使用门槛,人人会用的项目就不开源了; 就如,谁都预测不了彩票,所以才有这么多的彩票预测公司。

xls is the best data import format for phpmyadmin

尽管我挺不愿意看到这个结果,但事实是 xls (Excel 97-2003 XLS Workbook) 是在 phpmyadmin 中导入大量数据的最佳选择。xls 优于 csv 和 ods (Open Document Spreadsheet) 格式,尤其是在行数据差异比较大时(比如有 empty cell)。 尽管我用 Open Office Calc 生成原始数据,但保存为 Open Office 嫡出的 ods 格式再导入时,数据变得参差不齐。我正绝望时,试着保存为 xls 格式再导入,一切 OK。 回想 microsoft 所出的各种应用程序,确实有它强大的地方,至少有一点无人能及——在各应用程序间流畅地拷贝、粘贴。

Manifest module for Magento

Manifest module for Magento is developed for a Chinese takeaway restaurent to produce a manifest with order items’ product name in a language recognizable by chefs, no matter what languages store front are using. Manifest module utilises Magento valuable multiple-website-storegroup-store structure. It is easy to use as long as you have precedent knowledge of implementing… Continue reading Manifest module for Magento

phpMyAdmin 2002 error

最近把家里的测试服务器 Zend Server php 5.2 卸载了,重新安装了 5.3。phpMyAdmin 随着 5.2 卸载也被卸载了。我用 yum install phpMyAdmin 重新安装了 phpMyAdmin。在 config.inc.php 设置了必要的参数,但 phpMyAdmin prompted: #2002 – The server is not responding (or the local MySQL server’s socket is not correctly configured) 我浪费了很多时间检查了所有可能的错误,却解决不了问题。最后在 phpmyadmin.net 下载了源码,使用同样的 config.inc.php,顺利登录!

Access denied with my own google documents

如果 google 帐号和 google app 帐号同时登录时,无法查看app docs,除非 app docs 给 google 帐号访问权限,换句话说 google 帐号的登录状态会掩盖 google app 帐号的登录状态。 如果多个 google app 帐号同时登录,最先登录的域会阻止进入其他域(可以 retrieve docs list,但有时不能打开文档),有些情况下阻止,有些情况下不阻止,情况比较微妙,实在没空多研究。

Solve media type differencing after VirtualBox upgrade to 3.2.8

我在 VirtualBox 升级到 3.2.8 以后发现其中的 Windows XP Guest OS 无法启动,其他 Guest OS 正常。Windows XP Guest OS 用到的两个 harddisk 文件也显示 inaccessible,而且也 release 不了它们,强行访问还给一个错误信息。 Medium type of ‘/path/to/harddiskfile’ is differencing but it is not associated with any parent medium in the media registry (‘/path/to/.VirtualBox/VirtualBox.xml’). 我也没怎么上心,觉得是 VirtualBox 升级版中的 bug,指望在后续版本中把它修复。可是好久没见 Oracle 出更新,只好 google 求帮助。 我发现跟我有同样遭遇的人还不少,原因或许是 Host OS 使用了 ext4… Continue reading Solve media type differencing after VirtualBox upgrade to 3.2.8

CSS styling without images

I am quite surprised with the styling effect achieved by pure CSS without the help of images. I can round corner and rotate html elements without creating any background images. See the result I get. And this is the ONLY product image in this CSS styling demo: Although the effect is comprehensive, but with the… Continue reading CSS styling without images

SSL, Nginx and Magento

SSL, Nginx and Magento 这三件东西对我都不陌生。但三件全排在一起,着实挑战了我一下,发生错误是 secure page redirect loop。 原因是 $_SERVER[] 里缺少 HTTPS directive,需要在 fastcgi_params 里添加一行 fastcgi_param HTTPS on; 以 Magento 1.4.0.1 为例深究一下—— 在 $_SERVER[‘HTTPS’] 缺失时 app/code/core/Mage/Core/Model/Store.php 的 isCurrentlySecure() 返回值 false,所以 Magento 不停地重定向到 secure url 而不知道当前 url 已经是 secure 了。 我一直觉得用 php 探测当前 protocol 是否为 https 的算法比较“土”,曾经以为会有更好的探测办法,目前看来是没有。不光是没有,而且不可能有。就如有个小秘负责拆信,然后把有用的信纸交给 CEO 阅读,所以 CEO 不可能知道某封信是拿什么信封装的。

Magento layout rendering mystery

今天碰到个问题百思不得其解。起因是我在改进 Magento rcah module 时,想在 category/index/view 输出前修改 head block 里其中一个 item: link_rel。 具体说来,我想调用 $headBlock->removeItem()->addLinkRel() 把修改过的 link_rel 添加到 head block 的 $_data[‘items’]。由于调用在 renderLayout() 之后,所以 head 在输出时仍然是修改前的 link_rel。这本不奇怪;奇怪的是,我观察到 $headBlock->getCssJsHtml() 在整个过程中只执行了一次,而且是在 $headBlock->removeItem()->addLinkRel() 之后,$headBlock->getCssJsHtml() 应该是跟 html 输出直接相关,为什么在 $headBlock->getCssJsHtml() 看来 link_rel 还是原值? Layout rendering 机制对我来说还比较神秘。我只能暂时这么解释: renderLayout() 时把所有 block 的状态记住了,所以此后再怎么修改 block 的状态都无济于事。到了输出 html 阶段,所有的输出都是以 renderLayout() 时的 block。 BTW,在 rcah 模块中,我找到一个非常巧妙的办法来修改 link_rel… Continue reading Magento layout rendering mystery