Cassandra in Action with Twitter's Ruby Client
有一个全新的项目,因为考虑到将来的数据扩展性能,所以考虑用Cassandra做数据存储,前端用Lighttpd + FastCGI + Rails。在使用Cassandra的时候,觉得有一些东西可能大家都需要,就写了一个简单的指南。因为内容比较长(16页),就弄了个PDF文件给大家下载。
Cassandra in Action with Twitter's Ruby Client.pdf
如果下载链接有问题,请给我邮件:spanzhang@gmail.com。需要说明一下的是,这个指南是用英语写的,不过都是些很简单的句子,相信有四级英语就可以毫不费力的看明白。下面把文章的引文放这里,供大家参考,你可以看看适不适合你的需要:
Okay, let me get something straight. I’m not going to persuade you to use Cassandra. I just assume you have already chosen Cassandra as your storage solution. Maybe you know the basic things, the underneath mechanisms, about Cassandra or maybe not. Anyway, I assume you don’t care what makes Cassandra outstanding and you just want to use it. If that’s the case, this tutorial is going to help you, in these 3 aspects:
1) to set up the environment correctly,
2) to understand how to model you data in a Cassandra way,
3) to understand and use Twitter’s Cassandra Ruby client.
After reading this tutorial, you should have a working environment and can start your project with a good understanding of doing your job in a very Cassandra way. Here we go!
相关文档:
我们知道ruby中对于整数的[],[]=,<<,>>操作是针对于二进制的值来运算的。
我现在写一个针对十进制数操作的类,拥有整数的所有方法,如下:
class InterEx
def initialize(val=0)
@val=val
end
def to_s
@val.to_s
end
def [](idx)
self.to_s[idx].to_i
end
d ......
下面介绍Ruby form的两种写法。
Ruby form写法一:使用form_for
< % form_for :order, :url => { :action => :save_order } do |form| %> < p> < %= label :order ......
ruby常规访问access数据库的方法应该是使用DBI库
:
require 'dbi'
DBI.connect("DBI:ADO:Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db.mdb;")
可是
简单尝试之后没能成功,提示找不到驱动器ADO,懒得再试,遂找其他方法。
一番搜索之后,发现可以用WIN32OLE来访问access,写一个简单的类包装之:
......
http://www.robertsosinski.com/2008/12/21/understanding-ruby-blocks-procs-and-lambdas/
Understanding Ruby Blocks, Procs and Lambdas
Blocks, Procs and lambdas (referred to as closures
in Computer Science) are one of the most powerful aspects of Ruby, and
also one of the most misunderstood. This ......
下文转自:
http://www.cnblogs.com/watir/archive/2009/04/25/1443440.html
ruby文件从命令行中接收参数
在命令行方法执行ruby文件时,需要从命令行中传入参数,可以使用全局变量:ARGV
如有ruby 文件test.rb,内容如下:
1 def hello(a)
2 puts a
3 end
4
5 ......