Archive for January, 2010

Spam Mail

昨晚求助另外一个 Google Discussion Group, 依然是用的德国镜像,想来是猜错了一个按钮的意思,原本想要发帖结果搞成了订阅所有邮件,今早发现我的主力邮箱被几百封讨论组的垃圾邮件淹没了,更倒霉的是目前还没找到如何退订。

这三天依然效率低下,拦路虎是开源框架中的插件,本来 Cakephp 也算是两大主流框架之一, 就算有问题基本还是能找到答案的,坏就坏在它内置了 Prototype 而不是 jQuery 才引发一系列的麻烦。 基本上我就是在费力的把各种乱七八糟的 plugin, fix, add-on 都揉的一块去,在高度定制化的情况下可想而知会有很多不兼容的问题。而一旦出现问题就比较难解决了,因为这些插件相对来说比较偏门,Mister Google 也无能为力了。

今天算是把主体功能很粗糙的都实现了,接下去就做细化工作,还尝试了一下 Firebug,真是 Firefox 下的神兵利器, 可以洞悉一切。

Leave a comment

20 / 80 principle

大概估算了一下,我真正用来开发有用功能的时间只有20%,大量的时间被迫浪费在 CSS Layout 调整,修复 Javascript,解决浏览器兼容这些乱七八糟的事情上,很琐碎又不能回避. 我发现自己根本就不是 UI Design 的料,好在我的 Google Search 功底还不错,不管多偏门的东西总都还能解决。不管怎么说这两天进展不错。

为了从这种繁重的体力活中解脱出来,又找到了 Firefox 有个插件叫 Firebug, Debug 这些乱七八糟的东西很有帮助。

Leave a comment

Prototype to JQuery

过去一直用很好很强大的 Prototype, 直到最近才叛变转向号称 Prototype Killer 的 JQuery.

Cakephp 中也正是整合了 Prototype 来做 AJAX Helper. 结果不小心就惹出大麻烦,花了一整天时间才发现 Prototype 和 JQuery 有严重冲突,不可同时使用,偏偏这次在 IE 下到没有问题, 只有 Firefox say no.

浪费了很多时间,还好发现了一个 JQuery 版本的 AJAX Helper for Cakephp, 可以实现无缝转移,唯一的差别就是不能更新多个 DIV, but who cares?

开发都是业余时间做做,可是现在游泳健身打球都占用了我大部分的业余时间,进度很成问题了。

Leave a comment

Static Map API

The following example contains the URL of a static map image of downtown New
York City, which is displayed below:

# You can copy the URL from the image below, however.
# For clarity, we don't write the actual API key in use.
#
http://maps.google.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=14&size=512x512
&maptype=roadmap&markers=color:blue|label:S|40.702147,-74.015794
&markers=color:green|label:G|40.711614,-74.012318
&markers=color:red|color:red|label:C|40.718217,-73.998284&sensor=false&key=MAPS_API_KEY

Query Limit: 1000 unique (different) image requests
per viewer per day (not per key).

If a user exceeds the limit as proscribed above, the following image will be displayed indicating
that the quota has been exceeded:


Leave a comment

Resizing Google Map InfoWindow (Speech Bubble)

Olmec Sinclair’s solution for infowindow resize:

The
code examples included here have been simplified somewhat as my working
system had complexities specific to the application that would not
exist normally.

To resize the infoWindow just call the resizeInfoWindow function and pass in the Id to the element that contains the content.

function resizeInfoWindow(contentElementId) {
    // Get the current open infowindow from the map
    var infoWindow = map.getInfoWindow();
   
    // Get the point this infowindow belongs to
    var point = infoWindow.getPoint();
   
    // Get the size of the content block so to make the info window the correct size to hold it
    var contentBlock = document.getElementById(contentElementId);
    var width = contentBlock.getElementWidth();
    var height = contentBlock.getElementHeight();
    infoWindow.reset(point, null, new GSize(width,height));
}

Object.prototype.getElementWidth = function() {
    if (typeof this.clip !== "undefined") {
        return this.clip.width;
    } else {
        if (this.style.pixelWidth) {
            return this.style.pixelWidth;
        } else {
            return this.offsetWidth;
        }
    }
}

Object.prototype.getElementHeight = function() {
    if (typeof this.clip !== "undefined") {
        return this.clip.height;
    } else {
        if (this.style.pixelHeight) {
            return this.style.pixelHeight;
        } else {
            return this.offsetHeight;
        }
    }
}

3 Comments

翻墙二三技

翻墙之术,雕虫末技也,基本都是围绕 https 或者镜像来做文章的.

1. 镜像大法 (It works like a charm)
有的苦主有好几个分身,斩杀了一个还有几个后来人,比如我最爱上的 Google Group, 主站被封,但是可以上其他国家镜像啊,内容是一样的,只是标签变成了德文,法文。。。看不懂? 可以猜啊,很简单。所以只要把 groups.google.com 换成 groups.google.de 就可以了,凭着对界面的熟悉,笑傲八国语言。喜欢 Google Group 里面牛人多如牛毛,各种疑难杂症半个小时内就有方案出来了,经常还会碰到偶像级牛人为你解答。

2. https
大多数的小网站就没有那么雄厚的实力去建多国镜像了,但是很可能有用安全协议,于是把 http 换成 https 说不定有些就能访问了。不行的话再换翻墙工具上
Web online 翻墙: 不计其数,但是可以用的还真不多,这个北美服务器代理还可以用下 – http://www.daili.my/
桌面程序: 轮子的无_界好像再也用不了了,但是又有很多后起之秀,比如 Puff 什么的,问题是如果本身已经用过一次代理就不好使了,还不如之前的网页版代理。

其实无非我就是要查点和政治色情毫无关系的资料而已,为什么要弄的这么麻烦??????
装回文青, 借用 Charles Dickens 的名言发泄一下: "It was the best of times, it was the worst of times; it was the age of wisdom, it was the age of foolishness; it was the epoch of belief, it was the epoch of incredulity; it was the season of Light, it was the season of Darkness; it was the spring of hope, it was the winter of despair; we had everything before us, we had nothing before us; we were all going directly to Heaven, we were all going the other way."

1 Comment

Tuning Cakephp Performance

这几天开发进度很慢,因为被 IE 的兼容问题弄得头大,好不容易解决了又发现了 performance issue, CakePHP 似乎慢的让我吐血。所以有人说不要轻易去用什么框架还是有点道理的。

关于 CP 的优化我只能想到三点:
1. Optimise database calls to return only the data necessary.
2. Use memcache instead of file cache.
3. Use an opcode cache like APC.

加了 Cache 以后页面还是比较慢,发现原来是装载 Google 的 Javascript 需要两秒左右延迟,通尝说来 JS 都是放在头部加载,其实可以反过来放到尾部,有点 lazy loading 的味道,这样装载页面就不用等待 JS 下载了。

也可以使用 Google 的 Ajax APIs. 所有的 Google Service 都可以通过 JSAPI 来动态加载,不用 block 页面 loading.

<script type="text/javascript" src="http://www.google.com/jsapi?key=ABCDEFG"></script>
<script type="text/javascript">
google
.load("maps", "2");
google
.setOnLoadCallback(function() {
   
// Your logic goes here.
   
// It will be run right after the maps module was loaded.
});
</script>

1 Comment

网球

本周打球三次,把附近的场子都去了一遍。

莲花的场地最好,进行过重大比赛,而且有6片场地。

高尔夫里的场地环境也不错,价格贵点,博林诺富特酒店赛点环境很好,场地一般。

今天上午两个小时,下午三个小时,刚刚找回一点感觉。

需要改进的地方: 拍头过低容易打高,应该水平挥拍发力向前,最后加旋压低。引伸有所改进,但是还是没有用到腰部力量,所以只能打借力球,也就是遇强则强,遇弱则弱,碰到软球就无法主动发力。另外球拍需要换线了。。。

2 Comments

邪恶的 IE 伤感的 Google

这几天自己做了点开发,再次感叹 IE 是天下最恶心的软件,随便列举几条:

1. 不遵循CSS规范,好端端的样式,到了IE那里就全变样了,乱七八糟的需要一堆补丁, 比如臭名昭著的PNG图片透明度问题。

2. 内存泄露问题, 很多FF看的好好的网站,用IE就会发现机器越来越慢,我下了一个叫 Drip 的东西来测试地图装载内存泄露问题,随着地图的自动刷新,内存使用以一种恐怖的斜率不断攀升(股票要这么牛就好了),最后直接把测试软件给干掉了。

3. Failed to open HTTPS site, 已经尝试了所有 fix 都无解,本来换着用 FF 就好了,可惜 IE 内置绑定,自己垮了不算,把所有用到 HTTPS 的软件也全部拖下水了,于是 MSN, 网上银行全部 Over…

话说回来如今的世界还就是垃圾横行,流氓当道, 所以 Google 只能默默地选择离去,剩下百度腾讯之流瞎折腾。理想和金钱往往是对立的,要想挣钱就得向百度腾讯学习,抹下脸皮走草根路线,旗帜鲜明的向低俗进军。离开也好,反正 Google 在中国也是受尽了压迫,旗下的 Picasa, Blog, Groups 全部都被封杀了,外交部的回应说中国的互联网是开放的,还有比这更不要脸的吗?我看连 MSN Space 迟早也要被 Great Fire Wall 干掉的。

1 Comment

破手机

三天前吃中饭后把手机漏在餐桌上,今天再去居然还找到了捡手机的清洁阿姨,被告知手机给他老公拿去了。

等我拿回来手机的时候发现一个好消息和一个坏消息:

坏消息是他们把我手机重置了,所有信息被清空。

好消息是前几天我把它摔花屏了,这么一重置反而彻底好了。

4 Comments