Ruby 语言 思想驱动生活

Ruby,Rails,编程是一种乐趣。

19 Rails Tricks Most Rails Coders Don’t Know

编写高效好看的rails代码的tips,原文:http://www.rubyinside.com/19-rails-tricks-most-rails-coders-dont-know-131.html

fiber

关于新版本Ruby中的多线程的问题。
fiber microthread coroutine concurrency这几个名词都被使用,可能最常用的会是fiber。
fiber属于非抢占式(non-preemptive)类型。
引用msdn文档:A fiber is a unit of execution that must be manually scheduled by the application
意思就是说必须手动调度的一段可执行单元。
fiber运行在线程的上下文中,一个进程可以调度多个fiber。线程一般要依靠内核的线程调度来暂停或者重启其它线程,而fiber则自己控制自己,启动其它fiber等。
Fiber和coroutine
这两个概念非常相近,一般来说,coroutine是程序语言级别的结构,而fiber是系统级别的结构。
WIKI条目:
1 Fiber (computer science)
2 Coroutine
MSDN文档:http://msdn2.microsoft.com/en-us/library/ms682661.aspx

Rubricks an open source CMS

基于rails的开源的CMS,应该是个日本公司做的。
主页:http://rubricks.org/index_en.html
主要功能:news,toto,bbs,用户和权限管理,menu管理等。
它使用了‘Spinelz’ ,一个提供了很多AJAX功能的JAVASCRIPT库。

算是弄好了Ultimate Tag Warrior 3插件

前两天的wordpress版本比较低,装不了UTW3,只好升级到最新版本的wordpress了。
把解压缩的plugin的在控制面板里启用就可以了。
关键是要修改theme文件。
1.修改index.php,在文章列表的时候显示tag list
在适当的位置加上这句就行了。
<div class="utwtags">TAG: <?php UTW_ShowTagsForCurrentPost("tagsetcommalist") ?></div>
当然,还要修改css文件。
2.修改tags.php和tag.php
tags.php主要是用来显示所有的tag的列表,建立方法可以看UTW自带的文档,修改的主要内容是让它符合当前的theme。
tag.php主要是显示一个tag的文章列表,修改的主要内容是让它符合当前的theme。

C# 3.0中类似Ruby的语法

Java:
new Date(new Date().getTime() - 20 * 60 * 1000);
Ruby:
20.minutes.ago
c#3.0的话有Extension Methods
public static class Extenders
{
  public static DateTime Ago(this TimeSpan val)
  {
    return DateTime.Now.Subtract(val);
  }
 
  public static TimeSpan Minutes(this int val)
  {
    return new TimeSpan(0, val, 0);
  }
}
执行函数
class Program
{
  static void Main(string[] args)
  {
    Console.WriteLine(20.Minutes().Ago());
    Console.ReadLine();
  }
}
原文:http://haacked.com/archive/2007/05/24/ruby-like-syntax-in-c-3.0.aspx
Extension Methods:
New “Orcas” Language Feature: Extension Methods

Top 12 Ruby on Rails Tutorials

原文:http://www.digitalmediaminute.com/article/1816/top-ruby-on-rails-tutorials
如果是入门的话,可以看看。
这里只保留了连接。

  

Locations of visitors to this page