web 3.0 come

August 3rd, 2009

微博客越来越火,围绕 twitter 已经成为了一个美丽的生态系统,感觉到 web 3.0 时代要来了。

看了一些相关资料,做了些对比:

Web 1.0 - as an information portal

- be the first to own the content
- divide www info useable directories
- everyone has their personal corner in the cyberspace
- lacks: context, interaction, scalability

Web 2.0 - as a platform

- focus on the power of community to create & validate (UGC, collaboration)
- tagging organization
- setting up “hooks” for future integration (RSS, API)
- lacks: personalization, true portability, interoperability

Web 3.0 - is semantic web

- HTML describes documents, while RDF describles things
- specs: RDF (FOAF, DOAP), GRDDL, W3C, microformats
- instances: Google, Twine, Swicki, Powerset, Wink, Twitter, FOAF, OpenSocial, Beacon, Joost, Netflix, Slingbox, iPhone, Andriod etc

个人总结是:
web1.0 是资源互联(text, video, music, pictures etc)
web2.0 是人互联(social graph, life streaming)
web3.0 是数据互联 (系统可以更智能的理解数据之间的关联和用户表达的含义,从而更准确的给出用户想要的东西)

2 keypoints of semantic web

July 29th, 2009
  1. add semantics to today’s web, rather than create a future web
  2. human first, machine second

i18n your website with google translate

July 22nd, 2009

在 Google Translate 上面有个很实用的 browser bookmark,实际上是一段 js 脚本,用它可以将当前网页用 Google Translate 翻译成各种语言。

这段 js 一样可以用在你的网站中,这样就能给网站添加一个简化的多语言版本了,最大的问题也就是你网站的界面设计可能不适应翻译过来的语言。

如果想让翻译的页面在新窗口中打开,可以参考这篇博客

方式就是将 location.href = 改成 window_name = window.open(…)

use current_user in Model

July 10th, 2009

我所有的项目几乎都用 restful_authentication 做了用户管理这部分,应用中经常要在 model 中调用 current_user,而这个是 session 相关的信息,在 Model 中不应直接读到,Google 到一个比较不错的办法,是 Beast 的作者提供的。

首先在 User Model 中加入一个类变量:

class User < ActiveRecord::Base
  cattr_accessor :current_user
  ...
end

之后在 ApplicationController 中用 before_filter 给刚才的类变量赋值:

class ApplicationController < ActionController::Base
  include AuthenticatedSystem
  before_filter { |c| User.current_user = c.current_user }
end

看似完美,测试报错,说 current_user 方法是 protected,不能调用。看看 lib/authenticated_system.rb,果然 current_user 方法是 protected,为了不破坏 restful_authenticated plugin 的结构,对 controller 里面的方法做个修改:

class ApplicationController < ActionController::Base
  include AuthenticatedSystem
  before_filter :set_current_user

  protected
  def set_current_user
    User.current_user = self.current_user
  end
end

–EOF–

how to merge individual commit in git

July 9th, 2009

在用 git 开发的过程中,通常不同的 feature 会在不同的 branch 中开发,再 merge 到 master branch 中。但有时候会需要从某个 branch 中合并几个文件或某个 commit 进来,方法有两种:

1、合并几个文件(参考链接
git checkout source_branch <paths>…

2、合并某个 commit(参考链接
git cherry-pick <commit id>

issue about install SCIM on OLPC

May 27th, 2009

好朋友有台 OLPC 刚升级了 image,装不上中文输入法。今天下午我也一起看了一下,发现是 package dependencies 的问题。

SCIM 需要一个 libgnomecanvas 的包,它依赖与另外一个 libglade2,系统上装的是一个 2.6.2-5 的版本,升级无效,直接下载了一个 rpm,用 rpm 装不上,但是 yum localinstall 显示安装成功,我就真的以为成功了。

然后继续安装 SCIM,问题依旧,显示 libglade2 还是老版本。下载 libglade2 然后重装,问题依旧。

后来发现一个可能是线索的提示,说 libglade2 安装成功,但是缺少 public key,查了一下可能是下的那个 rpm 的 publisher 不能被 OLPC 验证。

问题最终还没解决,有遇到类似情况的朋友请指教。

update: 发现类似问题 http://www.olpcnews.com/forum/index.php?topic=4130.0