Blog

  • June 05,2008 22:49, Rails

    Git 简明操作指南

    * 创建Git Repository

    1.在本地创建

    mkdir new_repository
    cd new_repository
    git init-db

    2.从已存在的Repository获取

    git clone /path/to/exist/repository

    * 添加文件

    git add /path/to/filename # 添加单个文件

    git add filename [filename] # 添加多个文件

    git add /path/to/directory # 添加文件夹

    git add ./ # 添加当前文件夹

    * 提交文件

    1.提交本地更新

    git commit -m "commit message is here"

    OR

    git commit -a -m "commit message is here"

    2.提交更新至远端

    git push /path/to/repository

    * 更新文件

    1.更新本地文件

    git checkout -f

    2.更新远端文件

    git pull /path/to/repository

    * 创建分支

    创建自己的工作分支,以避免对Master Branch 的影响

    git branch raecoo # 成功创建了名为raecoo的分支

    git checkout raecoo # 将当前工作切换至raecoo分支

    * 删除分支

    git-branch -D branch-name

    * 合并分支

    git checkout master # 切换当前分支到master

    git merge "merge message is here" HEAD raecoo # 将raecoo分支与master分支合并

    OR

    git checkout master #效果与上相同

    git pull . raecoo

    read more...

    (0) comment

  • May 26,2008 23:14, merb

    Merb之所见 -- 方法的区别

    Merb在一些常用方法的调用方式与命名上与Rails有了很大的区别,以下记录的是我现在已经发现并用到的

    Filter
    before_filter and after_filter => before and after
    :except => :exclude
    redirect_to => redirect

    Routes
    url_for, route_url and route_path => url

    Helper
    content_tag => tag
    tag => open_tag
    content_for => throw_content
    javascript_include_tag => js_include_tag
    stylesheet_include_tag => css_include_tag
    render :partial=>'post' => partial "post"

    read more...

    (0) comment

  • May 26,2008 15:04, Rails

    find latest record in rails

    class Topic < ActiveRecord::Base   
    def self.find_latest(time = nil)
    r = %w( hour day week month year )
    if r.include?(time)
    self.find :all, :conditions => ['created_at > ?', 1.send(time).ago]
    else
    self.find :all
    end
    end
    end

    read more...

    (0) comment

  • May 24,2008 11:18, merb

    Merb,Faster, Lighter, More Agile.

    Merb is an MVC framework that is ORM-agnostic, JavaScript library agnostic, and template language agnostic, preferring plugins that add in support for a particular feature rather than trying to produce a monolithic library with everything in the core. In fact, this is a guiding principle of the project, which has led to third-party support for the ActiveRecord, DataMapper, and Sequel ORMs.

    In addition, it means that the core code in Merb is kept simple and well organised. This has multiple benefits. It means it’s faster for one thing. It’s also easier to understand, maintain and extend.

    最近看了些相关Merb的资料,感觉这才是我真正喜欢的框架,高扩展性,强大的灵活性,i like, :)
    当然,短时间内还是会以Rails做为主要开发框架,毕竟Merb还是比较年青,需要时间验证,不过我个人感觉Ezra Zygmuntowicz比DHH的开发经验丰富很多,希望Merb能够越来越好用

    read more...

    (0) comment

  • May 18,2008 23:08, Linux

    在Ubuntu中使用Ngix+PHP

    今天试了下Nginx,感觉部署上是比Lighttpd方便不少,据说性能也不错,找机会测试一下
    今天在搞FastCGI和PHP配置时因为配置耽误了点时间,在此把配置文件帖出来,方便以后使用
    server {

    listen 80;
    server_name localhost;

    access_log /var/log/nginx/localhost.access.log;

    location / {
    root /var/www;
    index index.php index.html index.htm;

    if (-f $request_filename/index.html){
    rewrite (.*) $1/index.html break;
    }
    if (-f $request_filename/index.php){
    rewrite (.*) $1/index.php;
    }
    if (!-f $request_filename){
    rewrite (.*) /index.php;
    }
    }

    #error_page 404 /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    root /var/www/nginx-default;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #proxy_pass http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #fastcgi_pass 127.0.0.1:9000;
    #fastcgi_index index.php;
    #fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
    #includefastcgi_params;
    #}

    location ~ \.php$ {
    include /etc/nginx/fastcgi_params;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #deny all;
    #}
    }

    read more...

    (0) comment

  • May 15,2008 23:08, default

    转:社会性软件的构成要素

    转一篇很不错的文章

    原文作者:Gene Smith
    译者:Ray Phoenix
    我们能看到很多的对于社交软件(social soft)的定义,从古板严谨的(“能让人通过计算机的连接作为媒介互相沟通的软件”)到实用主义的(“内容被分发了”)。

    在为最近的一个研讨会昨研究准备的时候,我无意中发现了一个有用的社会性软件(social software)的元素清单,它包括七个元素。这七个组成部分——身份,状态,关系,交流,小组,名誉,分享——给社交网络软件下了个不错的定义。同时,又是我们思考社交网络软件如何工作的有力的依据和基石。

    这个模型是延续自Stewart Butterfield和 Matt Webb对社会性软件元素的思考。这里是这些元素的简要定义:

    *身份(Identity) - 如何在系统里识别一个人的唯一身份

    *状态(Presence) - 知道某人在线,可用,以及其他的状态信息的方式

    *关系(Relationships) - 描述两个用户在系统里面建立和发生关系的方式(在flickr里面,大家可以互相链接,成为一个大家庭里面的兄弟)

    *交流(Conversations) - 通过系统与其他人交流的方式

    *小组(Groups) - 在网络上形成团体的方式

    *名誉(Reputation) - 知道别人在系统中的地位的方式(谁是好公民,谁值得信任)

    *分享(Sharing) - 分享对于参与者来说意味深长的东西(例如照片或者视频)

    不是每个社会性软件和社会性网络都包含了以上所有的元素,但是他们之中的绝大多数都有三个或者更多的元素。同时,最受欢迎的那些社区站点都实现了多数的元素,但是,他们会把精力集中在其中一或两个元素的应用上。举例说明:

    *flickr ——分享图片
    *slideshare ——让你能够分享并在网上播放ppt
    *twitter ——目标对准了“状态”
    *IM软件,如AIM和MSN是用来交流的
    *linkedin ——追踪关系

    为了这个研讨会,我借用了Peter Morville 的“ 用户体验分蜂巢模型”去制作了一个社会性软件的蜂巢模型。我把“身份认证”——任何一个社会性软件的最基本的需求——放在蜂巢中央,其它元素则围绕在它的周围。



    在图片的下部,有三个社交网站以及他们如何去组建自己的元素模块作为示例。深绿色的六边形,是这个网站所专注的应用,浅绿色的六边形是辅助性的元素。

    在你深入的去研究 Digg, Flickr, Slideshare 和 Twitter的时候,你会发现他们在每一个元素的具体实现上面都是不同的。而且不止是不同,一些细微的差别会对系统整体的体验起到决定性作用。举个例子,如果你去观察 Digg自己的用户在群游现象(swarming)中的那种交互作用是如何的轻松,你会觉得非常的有意思。


    对设计一个群组来说,最有挑战性的事情是这样一个事实:人们为了满足其自身的社会性需要,都会屈服于“工具”。我发现这些社会性软件要素的蜂窝结构,对我们理解一个社会性软件来说是一个很好的概念性框架。有了这些作为工具,我们就可以观察人们如何用这些系统去享受他们的私人以及社会化的生活。

    read more...

    (0) comment

  • May 15,2008 22:43, Rails

    多字段模糊查询

    今天在项目里做多字段查询时Google到了一个不错的方法,记录一下
    conditions = []
    [:title, :description].each { |attr| conditions << Topic.send(:sanitize_sql, ["#{attr} LIKE ?", "%#{params[:keywords]}%"]) if params[:keywords] }
    conditions = conditions.any? ? conditions.collect { |c| "(#{c})" }.join(' OR ') : nil

    read more...

    (0) comment

  • May 15,2008 22:41, Rails

    按日期对集合进行分组显示

    <% @articles.group_by(&:day).each do |day, articles| %>
    <div id='day' style="padding: 10px 0;">
    <h2><%= day.to_date.strftime('%y年%m月%d日') %></h2>
    <%= render :partial => 'article', :collection => articles %>
    </div>
    <% end %>

    这段代码比较有用,最典型的应用场景常常可以在博客的日志归档里看的到

    read more...

    (0) comment

  • May 15,2008 22:10, Rails

    My First Rails plug-in ActsAsMessages Released

    刚才抽空把前两天写的那个站内信插件整理了一下,现在正式发布出来
    如果有需要的朋友可以直接到以下的链接去下载

    http://actsasmessages.googlecode.com/files/acts_as_messages-0.1.tar.gz

    或者通过SVN直接Checkout

    svn checkout http://actsasmessages.googlecode.com/svn/trunk/ actsasmessages-read-only

    又申请了一个RubyForge的仓库,
    script/plugin install svn://rubyforge.org/var/svn/actsmessage

    read more...

    (0) comment

  • May 14,2008 22:11, Rails

    Redmine基于Rails的开源项目管理软件

    Redmine http://www.redmine.org/
    是一个基于Ruby on Rails开发的项目管理软件,最早关注它时还是0.4版本时,那时的功能还比较简陋
    最近抽空上官网上看了下,0.7版的改进还比较大,下载了一份试用了一下,感觉真是比以前强大很多,正如官网上的介绍一样

    * Multiple projects support
    * Flexible role based access control.
    * Flexible issue tracking system
    * Gantt chart and calendar
    * News, documents & files management
    * Feeds & email notifications.
    * Per project wiki
    * Per project forums
    * Simple time tracking functionality
    * Custom fields for issues, projects and users
    * SCM integration (SVN, CVS, Mercurial, Bazaar and Darcs)
    * Multiple LDAP authentication support
    * User self-registration support
    * Multilanguage support
    * Multiple databases support
    相信这个开源软件不但方便做项目管理使用,而且更为我们使用Rails开发的同志们带来了很宝贵的代码学习经验,想要了解更多的朋友还是上官网看看吧

    read more...

    (0) comment