123
 123

Thu 12 February, 2009

Click here to bookmark this link.Channel Image15:59 YouTube - Star Trek as The Love Boat» Joey Gibson's Blog
YouTube - Star Trek as The Love Boat. That is 1:35 of PURE WIN!
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image06:34 Rails实例世界(No 4):REST_in_Place on Rails编辑器» 天天红玉世界
REST_in_Place on Rails编辑器
使用REST_in_Place命令和代码清单
rails demo_rest-in-place && cd demo_rest-in-place
ruby script/plugin install git://github.com/janv/rest_in_place.git
wget -O public/javascripts/jquery-1.2.6.min.js http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js
ruby script/generate scaffold user name:string
vim app/views/layouts/users.html.erb
# 在users.html.erb增加下面所有代码
<title>Users: <%= controller.action_name %></title>
<%= stylesheet_link_tag 'scaffold' %>
<%= javascript_include_tag "jquery-1.2.6.min" , "jquery.rest_in_place" %>
<script type="text/javascript">
rails_authenticity_token = '<%= form_authenticity_token %>'
</script>
vim app/controllers/users_controller.rb
# 在users_controller.rb增加一行代码
def show
@user = User.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @user }
format.js { render :json => @user }
end
end
vim app/views/users/show.html.erb
# 在show.html.erb增加下面所有代码
<div id="<%= dom_id @user %>">
ID: <%= @user.id %><br />
Name: <span class="rest_in_place" attribute="name"><%= @user.name %></span>
</div>
rake db:drop && rake db:migrate && rake db:fixtures:load
ruby script/server
open http://localhost:3000/users/<show_id>

add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl

Wed 11 February, 2009

Click here to bookmark this link.Channel Image02:07 The State of the Wiki» Riding Rails - home

The new and revitalized Rails Wiki launched about two weeks ago, so it’s time for a progress report back to the Rails community. The short answer: things are going well. We’ve had nearly a hundred edits, dozens of topics put in place, and an active discussion on the wiki mailing list. Translators are already at work making the wiki content available in multiple languages. For topics ranging from a first Rails application walkthrough to handling timezones, the new wiki is already a spot to go for quality Rails content.

The wiki team has applied lessons learned from the old Rails wiki, which has gone from being a comfortable spot to find out a few things to a cluttered mess over the years. They started out by defining an overall structure and figuring out what warranted coverage in the wiki. Then they protected a few pages from edits and set up a login system to encourage accountability. The result, so far, is a very promising start at an information resource that can benefit all Rails developers.

But there’s plenty more to do. If you take a look at the new wiki home page you’ll find a bunch of topics in red with dashed underlines. Those are topics that we want, but that no one has written yet. If you have a few minutes to give back to the community, why not drop by? Whether it’s drafting a new topic from scratch, revising an existing topic to be more clear or correct, adding links to high-quality external resources, or translating the wiki into another language, there’s plenty left to do – and just about every Rails developer should be able to contribute.


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl

Tue 10 February, 2009

Click here to bookmark this link.Channel Image12:56 Apple/Ruby世界:Ruby和Rails技术词典» 天天红玉世界
Ruby和Rails技术词典
  • 安装方法
    • wegt http://www.priithaamer.com/files/Ruby.dictionary.zip
    • unzip Ruby.dictionary.zip
    • mv Ruby.dictionary ~/Library/Dictionaries
      或者
      mv Ruby.dictionary /Library/Dictionaries
  • 配置方法
    • open /Applications/Dictionary.app
    • 菜单 >> 设置偏好 >> 把Ruby技术词典移到最上面
  • 使用方法一
    • Apple键+Space >> 例如搜索函数”exists?” >> 点击“定义”>> 即会出现上图。
  • 使用方法二
    • Apple + Control + D >> 弹出窗口 (in TextMate or Safari, iChat, Mail etc.) >> 点击“定义”>> 即会出现上图。

add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image05:17 Apple世界:一场官司是否决定Mac的命运?» 天天红玉世界
一场官司是否决定Mac的命运?
  • 说明:
    • 美国法院 表示,如果 Psystar 可以证明自己的辩词,那么Psystar和其它厂商就可以合法地销售安装Mac OS X的计算机。”
    • Mac克隆机也在 欧洲 出现: PearC
    • Mac克隆机在中国呢?巨大的商机在吗?你还记得IBM兼容机?Apple商业条款是否存在漏洞?你以为呢?

add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl

Mon 09 February, 2009

Click here to bookmark this link.Channel Image10:27 aposiopesis: A sudden break...» Projectionist
ap•o•si•o•pe•sis
[ap-uh-sahy-uh-pee-sis]noun
A sudden breaking off of a thought in the middle of a sentence, as though the speaker were unwilling or unable to continue.

add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl

Sun 08 February, 2009

Click here to bookmark this link.Channel Image14:11 Hello,V8» 梦想风暴

V8是一个开源的JavaScript引擎,它和Chrome一起来到世人面前,凭借着优异的性能表现让几大浏览器掀起了新一轮JavaScript引擎竞争。

构建V8

了解V8的第一步自然是获取V8的代码,SVN上的代码基本上可以体现出V8的最新的进展。

  svn checkout http://v8.googlecode.com/svn/trunk/ v8

V8是用C++编写的,按照通常的思路,完成获取的过程后,就该打开对应的目录,准备make。对不起,这里没有Makefile,V8是用SCons管理其构建过程的。所以,除了基础的开发工具之外,我们需要额外安装SCons。因为SCons是用Python编写的,所以,Python也是不可获取的。如果你和我一样用的是Ubuntu,安装变得很简单:

  sudo apt-get install scons

万事俱备,开始构建:

  scons

运气够好的话,就会顺利生成一个库:libv8.a。

这里介绍的只是最简单的构建过程,如果有兴趣了解更多的话,可以参考V8的文档《Download and Build》。

和V8打招呼

下面这段代码来自V8起步文档

#include <v8.h>

using namespace v8;

int main(int argc, char* argv[]) {
    HandleScope handle_scope;
    Persistent<Context> context = Context::New();
    Context::Scope context_scope(context);

    Handle<String> source = String::New("'Hello' + ', V8!'");
    Handle<Script> script = Script::Compile(source);
    Handle<Value> result = script->Run();

    context.Dispose();

    String::AsciiValue ascii(result);
    printf("%s\n", *ascii);
    return 0;
}

正如前面提到的,V8是一个JavaScript引擎,我们所需要做的就是为它提供一段JavaScript,source起到的就是这个作用。对于程序语言实现而言,拿到输入的源码之后,就是对其进行编译(Script::Compile)编译之后的结果自然就是运行了(script->Run()),这就是这段代码的主要内容。

当然这里还牵扯到一些其它内容,按照起步文档中的说法:
* handle表示一个对象指针,所有V8对象的访问都依赖于handle,按照V8垃圾收集器的运作机制,这是必需的。
* scope可以看作一个容纳任意数目handle的集合。当你用完了自己的handle,你只要删除scope,而无需一个个地删除handle。
* context是一个执行环境,它让一个单独的V8实例可以运行独立、无关的JavaScript代码。必须显式指定JavaScript运行所需的context。

我们看到了前面V8构建的结果是生成了一个库,那我们只要在自己程序中使用这个库就好了。按照通常编写C/C++程序的习惯,我们把include里面的v8.h放到我们工程的include目录下,把libv8.a放到lib目录下,通过-I指定include的目录,-L指定库目录。

  g++ -Iinclude -Llib -oHelloV8 src/HelloV8.cpp -lv8 -lpthread

好了,是时侯,让V8和我们打招呼了。

  ./HelloV8

我们会看到

  Hello, V8!






add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl

Sat 07 February, 2009

Click here to bookmark this link.Channel Image19:26 Rails世界:CnRails成员超过500人» 天天红玉世界

Fri 06 February, 2009

Click here to bookmark this link.Channel Image23:48 This Week in Edge Rails» Riding Rails - home

January 31, 2009 – February 6, 2009

The big news in edge Rails this week, of course, is the release of Rails 2.3.0 RC1. There’s been a fair amount of activity in the days since that happened, much of it concerned with tidying things up and fixing bugs based on early adopter issues and feedback. Thanks for all the testing, and by all means keep it up!

Nested Form Support in Active Record and Action Pack

This one is big enough that it got a whole blog entry of its own (the version that was committed has minor changes from what you’ll see there). There are two main parts to this commit. First, Active Record can now update the attributes on nested models directly, provided you tell it to do so:


class Book < ActiveRecord::Base
  has_one :author
  has_many :pages

  accepts_nested_attributes_for :author, :pages
end

Turning on nested attributes enables a number of things, including automatic (and atomic) saving of a record together with its associated children, and child-aware validations. But the big visible one is nested form support. Provided the parent model accepts nested attributes for the child objects, you can create nested forms using form_for and field_for. These forms can be nested arbitrarily deep, allowing you to edit complex object hierarchies on a single view without excessive code. For example, given this model:


class Customer < ActiveRecord::Base
  has_many :orders

  accepts_nested_attributes_for :orders, 
    :allow_destroy => true
end

You can write this view in Rails 2.3:


<% form_for @customer do |customer_form| %>
  <div>
    <%= customer_form.label :name, 'Customer Name:' %>
    <%= customer_form.text_field :name %>
  </div>

  <!-- Here we call fields_for on the customer_form builder instance.
   The block is called for each member of the orders collection. -->
  <% customer_form.fields_for :orders do |order_form| %>
    <p>
      <div>
        <%= order_form.label :number, 'Order Number:' %>
        <%= order_form.text_field :number %>
      </div>

  <!-- The allow_destroy option in the model enables deletion of
   child records. -->
      <% unless order_form.object.new_record? %>
        <div>
          <%= order_form.label :_delete, 'Remove:' %>
          <%= order_form.check_box :_delete %>
        </div>
      <% end %>
    </p>
  <% end %>

  <%= customer_form.submit %>
<% end %>

For more information, see Ryan Daigle’s excellent What’s New in Edge Rails: Nested Object Forms.

commit

Rails Guides Rework

The Rails Guides have switched from using AsciiDoc markup to using Textile markup. This has a couple of benefits: first, it makes it easier to contribute to a guide. Second, it means that we can dispense with the compiled HTML versions of the guides in the Rails tree, because we can assume any developer can build from Textile. There’s a spiffy new look for the Guides web site too – check it out at the beta site.

commit

Scaffolding Changes

There were some cleanups to the code produced by script/generate scaffold – nothing too major, but they bring the controller and views more into line with current Rails best practices. Along the same lines, the “Riding the Rails” index.html page generated in new Rails applications now includes a link to the Rails Guides.

commit commit commit


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image04:17 This Week in Rails 3.0» Riding Rails - home

Now that Rails 2.3 has hit the release candidate phase, some of the development effort is turning to Rails 3.0. With that activity heating up, it’s time to start keeping you all informed as to happenings on the 3.0 version of the Rails source. I’ll still be posting separate “This Week in Edge Rails” information focused on Rails 2.3, so you can keep straight which changes are ready now and which still lie in the relatively distant future.

The Vision

The Rails 3 vision is based on the announcement that was made in December: we’re bringing in the key ideas from Merb to Rails, including:

  • A more modular Rails core, so you can run applications with less than the full Rails stack
  • Performance optimizations
  • Framework agnosticism with sensible defaults
  • A tested and documented API for extensions

Rails 3 promises to substantially advance the state of the art in Ruby web frameworks, while still providing migration paths from Rails 2.x and Merb 1.x.

The Source Code

The Rails 3.0 branch in the main Rails project on GitHub is the place to be to see what’s going on:


git clone git://github.com/rails/rails.git
git checkout 3-0-unstable

As the branch name might tell you, this is still a fairly experimental place to be: you probably don’t want to roll this out for production applications just yet. But it is tested code (and it’s using continuous integration to stay that way), and it already includes substantial changes from Rails 2.x thanks to the efforts of Yehuda Katz, Joshua Peek, and others. The changes so far are focused on cleaning up and improving Rails internals, rather than on adding new features.

Action Dispatch

Action Dispatch is a new Rails component which lives in Action Pack (along with Action Controller and Action View). Action Dispatch is responsible for all the processing involved with dispatching requests: request and response handling, HTTP status codes, file uploads, URL and parameter parsing, session storage, and so on.

Action View Reorganization

There are substantial changes in the Action View internals. The overall goal was to clean up a bunch of special cases and extra hooks that had built up over the years, and to leave all callers into Action View using a single unified entry point. The code cleanup has been coupled with some rearrangement of the Action View source to make it easier to find bits of functionality. This was a substantial effort; if you’re interested in a detailed look at the refactoring, you can read up on it at Yehuda’s blog

Callback Optimizations

A new method of handling callbacks removes the need for iterating through the callback list at runtime, and provides a substantial speed improvement in this area of the code. Though this is a micro-optimization that may not have much effect by itself, the hope is that by carefully optimizing as many hot spots as possible we can get a visible overall speedup in page creation and delivery – which, after all, is the point of a web framework.

What’s Next?

Obviously, there’s a long distance between where we are today and the Rails 3.0 vision. We’re fortunate to have an excellent team of core programmers devoting substantial time to making that journey. The interim goal is still to have a beta version of Rails 3.0 out in time for RailsConf in May. You can help in the same ways as with earlier versions of Rails: download the source, start testing it with your applications, and submit your own ideas and patches to the Rails Lighthouse. Rails has been a joint effort of thousands of developers over the years, and Rails 3.0 will be no different in that regard.


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl

Wed 04 February, 2009

Sources