颐和园一日游

由于北京市在奥运期间各个中小学校的足球场地都停止对外开放了,所以我也就把周六的时间空了出来。应老婆找地方划船的要求,我和阿廖商量之后决定去颐和园,上次去颐和园还是大二时候的事情了。于是在周日,我们顶着烈日,于上午到达颐和园,奥运前夕的景区就是不一样,人这叫一个多,票30块居然,这叫一个贵。进去之后逛了一下长廊,满足了阿廖对于长廊的怀念,不过由于人太多,气氛有点嘈杂。简单补充了写东西,我们直奔这次的主要目的地: 昆明湖,租了个6人小船,别说水上还就是凉爽,小风阵阵的,很是惬意,看着林霖都有要睡着的意思了。

下午在鼎好味千拉面的uno大战也是一日游的亮点,大家玩的不亦乐乎,我和林霖先后“引爆”了这个游戏。本来今天是刘晴的生日,阿廖要请吃老莫的大餐,可是由于众人玩的兴起,都依依不舍的,所以庆生的仪式也就由老莫改到了味千里边。我们买了个DQ的冰淇淋蛋糕(我靠,真TMD甜)简单的为刘晴庆祝了一下,然后继续uno,哈哈哈。

本次活动的照片在这里,未能亲身体验的可以感受一下。

OK, this is not about the details of how to install mod_rails on leopard, actually the process is pretty straightforward and there are already some good document on mod_rails’ website . Well, the confusing part of using mod_rails+apache on leopard is that you have to know how the default apache coming with leopard works. 

This is what I did after I installed mod_rails and copied those three lines to the httpd.conf

  1. Uncomment line 464: Include /private/etc/apache2/extra/httpd-vhosts.conf to enable the virtual host
  2. add apps.conf under /etc/apache2/other , I will place all local app that I would like to use mod_rails here
    <VirtualHost *:80>
    ServerName test.local
    DocumentRoot /Users/snow/Sites/test/public
    RailsEnv development
    </VirtualHost>
  3. adding virtual host in /etc/hosts : 127.0.0.1 localhost test.local
  4. now restart the apache, open the browser and visit redmin.local/images/logo_snap.jpg(some file I copied) and here comes the problem
  5. Forbidden

    You don’t have permission to access /images/logo_snap.jpg on this server.

After googling for a while and doing some test, I figured out the reason:

  1. If you use the default apache coming with leopard, the only places you will place your site folder should be ~/Sites . Virtual hosts whose document root are somewhere other than ~/Sites will not be able to start properly and apache will throw the Forbidden page like above. But for me, I have another place to store my rails project (~/workspace) and I would not like to copy my file to ~/Sites every time so the first choice would be create symbolic links.
  2. By default, the username.conf(in my case, snow.conf) under /etc/apache2/users looks like this by default:
  3. <Directory “/Users/snow/Sites/”>
        Options Indexes MultiViews
        AllowOverride None
        Order deny,allow
        Allow from all
    </Directory>
    In order to let symbolic links work properly, I changed my snow.conf file to 
    <Directory “/Users/snow/Sites/”>
        Options Indexes MultiViews FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
    If you don’t add FollowSymLinks in options, you will still get the permission error page.
  4. Ok, now I see my app working properly in my browser after typing http://test.local

渴望体验结对编程

看了这篇文章以后,解决我心中对于结对的一些疑惑。说实在的,作者的那些问题,有相当一部分也是我对于结对的疑惑。当然,有些自己找到了答案,而有些在看了这篇文章之后,感觉豁然开朗。希望尽早有个机会体验一下结对,以及结对带来的思想和习惯的转变。 Anyway,到了做些转变的时候了,一成不变的生活已经持续了一年半多了,是该给生活添加一些新鲜元素了。

其实结对编程对开发者的冲击最大. 把你的工作重点从与机器打交道变成了与人打交道. 把你从虚拟的机器世界拉回到现实世界. 把程序员重新变回成”人”, 练习人与人之间的交流.

总体来讲,我的理解,结对带来的并不是两个人坐在一起,一块写代码这么简单,最主要的还是一个如何与团队中的成员交流的问题。借以和团队中的不同成员共同工作,来相互交流思想,强化沟通,让团队中每个成员的技术水平和思想意思达到尽可能的统一,从而最大限度发挥团队集体工作的合力。当然,并非所有的事情都需要pair完成,那些“力气活”和初期的思考可以先独立完成。

merge delicious bookmarks into firefox

We(e-accent and jackfruitdesign) developed a small application to make merging delicious bookmarks into firefox easier, keeping delicious tags information at the same time. If you are encountering the same problem using firefox bookmarks management when trying to import your delicious bookmarks, then give it a shoot: http://delicious.e-accent.com

初稿3天的时间,后期用了3,4天,前后总共一周的时间,不得不说chinese rails社区的力量还是强大的。

可以在这里查看并下载,也可以在gdoc中查看

吃东西得趁热,学rails也不例外,chinaonrails的一个帖子将大家的积极性调动了起来,我也献了自己的一份力量,翻译了第二章 ActiveRecord,基本完成,明天还要修改一些细节。国内rails的社区力量还是很强很可爱的。

说说我使用github的经历

最近获得了好多的关注,作为tech“潮人”咱自然不能落后,看了几天,学习了不少有用的知识, 简单的谈谈使用git的过程.注册github.com帐户之类的废话就不用说了.这里我以自己下载、学习 rails-openid-kit 为例, 总结一下我使用github,并且为开源软件贡献一点力量的过程(顺便提一句,如果你希望为你的网站添加openid支持,那么openid-rails-kit是一个很好的选择)

 

  1. 在github上边找到openid-rails-kit,然后 “fork”
  2. 这个时候网站会跳转到你自己的页面,然后在你自己的帐户中copy一份openid-rails-kit项目的源代码,所以“fork”说白了就是,copy一份项目的代码,你对这份代码拥有一切权利,当然,这份fork过来的代码也会保留一切之前的log/change history .这时候你会看到 public clone url , your clone url的字样,很明显,一个是给所有人的只有读权利的地址,一个是你自己用的可以提交更改的地址。当地点击 Your clone url时候一行命令会蹦出来,copy之。
  3. 这时回到我本地,打开iterm, paste
  4. 当然了再下一步就是打开textmate,一通改。这时候你也许在纳闷,我的这个版本和原作者的版本有什么区别,我改了会不会对原作者的版本产生任何的影响呢,如果我提交了我的更改那么别人是否能够看到我都改了什么呢?呵呵,会有影响也可能没有影响,不过如果你提交了你的更改,在git里边通过git push来提交,那么所有关注这个项目的人都可以看到你的更改,过一会我们会具体演示别人怎么看到你的更改,你怎么看到别人的更改。当然了如果你使用textmate,那么git tmbundle 以及 github tmbundle 都是使用git必备的。
  5. 在git当中branch的概念无处不在,同时branch的创建, switch, delete都是非常的cheap。 我们刚刚通过git clone 生成的project 其实就是一个叫”master”的branch,我们用”master”来引用这个存储在本地的branch. 这个branch对应着你在github上的master branch,不过对于那个remote master branch,我们习惯用 origin/master来表示,origin可以认为是我们给remote repository起的一个别名. 同时当我运行 git branch new-features 的时候,git 又以我现在所在branch(master)为基础,创建了一个新的名叫new-features的branch, 通过git checkout new-features,  我们很轻松的就由master转到了new-features这个branch. 接下来就是可以放心大胆的添加我们的新功能,而不用担心破坏了master的功能。
  6. ok, 现在我们添加了新的功能,同时所有的新功能通过了测试,现在我们准备将新功能merge到master当中了。首先确认你已经提交了所有对于new-features branch的更改: (new-features branch) git commit -a -m ‘commit all my changes’; 返回到master branch当中:git checkout master . 然后 git merge new-features . 这个时候 就可以将 master push到remote:  git push 当然所有的这些命令行都可以轻松的在textmate中使用git tmbundle来完成
  7. ok, 最后回到我的github帐户,可以直观的看到我所做的更改。如果我想告诉这个项目的原作者,和所有关注这个项目的人:“我改了写东西,你们应该看看。”那么我就可以点击我帐户中这个项目旁边的 “pull request”, 注意,是我的帐户中的这个项目,因为我想让人家看我的更改。当然如果人家觉得我的更改有意义,就会merge 我的branch…

ok,这篇文章已经足够长了,至于别人如何merge我的更改,我如何merge别人的更改,咱们下次再说。8-)

 

Bye typo and hello wordpress

从这个blog开始以来,一直在适用typo,一开始还算是愉快,不过使用了一段时间以后各种各样的问题接踵而至: comments会莫名的小时,akismet不是很好用,admin的ajax功能经常失效等等,以至于到后来,blog工具的不好用已经成为自己不愿意再写blog的一个理由了,当然,这个理由非常的蹩脚…

趁着这次给阿廖搞blog的机会,我也准备彻底的弄一下现在的blog了。不得不承认Rails的blog没有那个比wordpress更为强大好用,虽然作为一个以谈论技术为主的blog,我所使用的功能非常的简单,不过我还是希望能够能试试这个非常火的blog。 作为ror的开发者,没有用ror写的blog,不过那有怎么样呢,web毕竟不是围绕着ror转的,而且不得不承认,许多优秀的软件跟ror没有什么关系。 我会尽力将原来所有的post和链接都恢复。我的朋友们,记得更新你们的rss哦!!!

Rails plugins

转一篇文章,列举一些常用的rails plugins,挺不错的。
http://jimneath.org/2008/04/25/building-a-social-network-site-in-rails/

Using GMail smtp server in rails app

由于action_mailer本身并不支持tls或者ssl的链接方式,而gmail的smtp server又要求tls或者ssl方式验证用户名和密码,所以我们需要hack action_mailer让他支持tls/ssl。在网上找到一篇很有用的文章:http://www.stephenchu.com/2006/06/how-to-use-gmail-smtp-server-to-send.html

由于有可能链接在国内没办法打开所以将内容一并转下来,以备日后reference:

Rail’s ActionMailer was simply the automatic choice, since I am building a rails app.

Turns out GMail supports only SSL SMTP mailing service, meaning if you cannot create a SSL connection to its SMTP server, you cannot send email through them. My Rails and Ruby (1.84) version do not yet support creating a SSL SMTP connection through Net::SMTP. DHH writes about how to do so through installing msmtp here, but we developers just obviously love options =)

The dynamic nature of Ruby allows me to enhance the functionality of that class. I found the following code from a couple Japanese posts here and here on the web (fairly low Google ranking). Pasting them in my /vendor/plugins as follow:

$ cat vendor/plugins/action_mailer_tls/init.rb
require_dependency ‘smtp_tls’

$ cat vendor/plugins/action_mailer_tls/lib/smtp_tls.rb
require “openssl”
require “net/smtp”

Net::SMTP.class_eval do
private
def do_start(helodomain, user, secret, authtype)
raise IOError, ‘SMTP session already started’ if @started
check_auth_args user, secret, authtype if user or secret
end

sock = timeout(@open_timeout) { TCPSocket.open(@address, @port) }
  @socket = Net::InternetMessageIO.new(sock)
  @socket.read_timeout = 60 #@read_timeout
  @socket.debug_output = STDERR #@debug_output
ensure
  unless @started
    # authentication failed, cancel connection.
      @socket.close if not @started and @socket and not @socket.closed?
    @socket = nil
  end
end
check_response(critical { recv_response() })
do_helo(helodomain)
raise 'openssl library not installed' unless defined?(OpenSSL)
starttls
ssl = OpenSSL::SSL::SSLSocket.new(sock)
ssl.sync_close = true
ssl.connect
@socket = Net::InternetMessageIO.new(ssl)
@socket.read_timeout = 60 #@read_timeout
@socket.debug_output = STDERR #@debug_output
do_helo(helodomain)
authenticate user, secret, authtype if user
@started = true
def do_helo(helodomain)
   begin
    if @esmtp
      ehlo helodomain
    else
      helo helodomain
    end
  rescue Net::ProtocolError
    if @esmtp
      @esmtp = false
      @error_occured = false
      retry
    end
    raise
  end
end
def starttls
  getok('STARTTLS')
end
def quit
  begin
    getok('QUIT')
  rescue EOFError
  end
end

So now, in your ActionMailer::Base’s server settings if you have:

ActionMailer::Base.server_settings = {
:address => “smtp.gmail.com”,
:port => 587,
:domain => “mycompany.com”,
:authentication => :plain,
:user_name => “username”,
:password => “password”
}

You call your ActionMailer::Base’s deliver method (perhaps from a custom subclass), it will send an email through GMail. Mission accomplished.

低调归来

呵呵,已经沉寂了相当长的一段时间了。最近非常的“低调”,干好本职工作的同时(最近非常的忙,多个项目同时开展,能干好本职工作已经不容易了),感觉应该回来了,同时之前错误造成的影响应该也已经消退了,所以大喊一声: 老子回来了。

旧的不去,新的不来!

跟随了我和老婆三年多的折叠小车不翼而飞了,在老婆自责愤慨的同时,我打开了google和baidu希望搜索一些关于二手自行车的信息,不过比较失望,所有的二手市场都比较远,而且看了一下评论稍微好一点的车也得3百多,考,三百多我买它干嘛。于是,我又打开了”淘宝”,期望能淘到什么便宜货。显然淘宝上边更不会有什么自行车的便宜货。不过也不是完全没有收获,由于我还是希望能够买一辆折叠小车,所以发现一个名字在搜索结果中的重复率非常之高 “Dahon-大行”。于是google之,发现其中文官方网站,感觉还不错,看了一下专卖的地址,正好在我家后边有一家,于是二话没说,起身就去看看。 到了之后,看了一下价位,和我想象的差不多,最便宜的500多,次便宜的就是760。试骑了一下,感觉还不错,非常的舒服。所以基本上锁定了760那款。

晚上了老婆一起去,提了我看上的那款YT180。回家以后发现老婆的自责情绪已经完全被新车的新鲜兴奋所取代。我们两个不约而同的感慨,这辈子还没买过这么贵的自行车呢。

变形,ko..ke..ki..ki..ki…



关于最近的offline事件

由于在之前的blog当中出现了一些不应该有的信息,其中涉及到了公司的利益问题。所以之前一段时间blog一直offline整改,在确认了blog当中已经没有什么敏感信息之后,再次将其online。在此向公司的同事们说一声抱歉,也请你们谅解,放心,类似的事件不会再发生了。

Textmate中如何添加对于新的模板文件的支持

在最近使用edge rails(rev.7167)的过程中,发现edge rails有几个显著的变化,其中最为明显的莫过于:新的generator 生成的view文件的后缀名由 rhtml 变成了 html.erb .暂且不讨论这种变化本身的意义,我第一个想到的问题就是: 我的textmate 是否能够将 html.erb 文件等同鱼rhtml处理,也就是所有的rails的snippets, templates, etc是否好用。在google了一下以后,找到了一篇blog , 里边的第五条comment给出了解决textmate对于html.erb文件支持问题的方法。在这里简单的总结一下:

  1. open textmate → Bundles → Bundles editor → Edit languages
  2. open “Rails” on the left panel list, and there should be three sub-items there.
  3. click “Ruby on Rails”, and edit the content appears on the right, changing
    “fileTypes = ( ‘rxml’);” at the second line to “fileTypes = ( ‘rxml’, ‘builder’ );”
  4. click “HTML”, and do the same thing, changing
    “fileTypes = ( ‘rhtml’);” to “fileTypes = ( ‘rhtml’, ‘html.erb’ );”

大功告成,现在html.erb 结尾的文件将和rhtml文件被同样对待。

冲破“和谐管制&quot;

什么叫”和谐管制”?就是国家信息部门采取的一种保证国人不被国内外不良信息影响的管制手段。flickr.com blogspot, 以及 wikipedia都是被”和谐管制“的典型。

至于方法吗,很简单,地球人都知道-用代理。不过如果你有一台国外的server,或者购买了dreamhost, railshost 等shared host,那么你就不用每天上google搜索免费的、不稳定的 proxy server了,通过ssh tunnel,并且借助Firefox plugin foxyproxy proxy访问,同时其他的网站不是用proxy。 方法如下:

  1. 安装Firefox foxyproxy plugin, 安装的时候他会问一些你觉得非常陌生的问题,出现一堆陌生的单词和概念,别担心,一直 continue 或者 next就可以了。
  2. 我使用mac osx, 在桌面创建ssh_tunnel.sh, chmod 777 , sh文件内容如下
#!/bin/sh
while true
do
echo "SSH Connecting"
ssh -l USERNAME -p PORTNO -a -x -N -T -D 8888 HOSTNAME
echo "SSH connection lost, try again"
sleep 15
done

其中:

USERNAME: 你用来ssh登陆remote server的用户名

PORTNO: 登陆remote server的端口号

HOSTNAME:remote server

还有8888,代表proxy server (localhost) 的端口号,你也可以使用其他的端口号,不过要于一会设置的proxy server port一致。你将在后边的文章看到更多解释。

ok, 双击sh文件,如果一切正常的话,你的ssh tunnel已经建立了。

下面我们来设置foxyproxy ff plugin :

  1. 打开Foxyproxy options – Add new proxy
  2. General – input a proxy name
  3. Proxy Details – Manual Proxy Configuration, hostname: localhost, port:8888 (或者你刚才在sh文件中设置的端口号),选择socks v5
  4. Patterns- Add new pattern ,输入pattern 名称,和url pattern,可以选择是blacklist还是whitelist,这里我们选择whitelist,即符合pattern的url使用proxy.

OK, 打开ff标签页 www.flick.com , 浏览一下,你是否看到了你久违的flickr帐户上边的照片了???

痛快的高喊一句: FREEDOM !!!!!!

My categories

本站访问量


Unique visitors?

谁在看我

Unounonew MBPiFlickriFlickriFlickriFlickr