cool
感觉就那本 元编程吧
rails 是永远运行的,所以加个 loop do 吧 :
hello
loop do
sleep 1
end
或这样:
hello
sleep 9999999999999999
对,过了年
优雅的写法:
module M1
CT = "ok"
end
class C1
CK = "ck"
include M1
def self.method1
puts self
puts "#{CK} in method1"
puts "#{CT} in method1"
end
end
class C1
def self.method2
puts self
puts "#{CK} in method1"
puts "#{CT} in method2"
end
end
C1.method1
C1.method2
小数点后面这么长,这点误差,实际使用中,只要 round(2) 就没事了。
(1.9+18.99).round(2)
用 round 就 ok 了
ruby 里面,多继承反而不实用吧。
加个退出判断
hello
loop do
sleep 1
exit if Thread.list.count < 2
end
rand(999999999) + 999999999
ruby 教程列表 .
Ruby QuickRef http://www.zenspider.com/Languages/Ruby/QuickRef.html .
漫画教程 Why's (Poignant) Guide to Ruby http://mislav.uniqpath.com/poignant-guide/book/chapter-3.html .
RUBY 语言入门教程.PDF http://download.csdn.net/detail/Sevk/659363 .
RUBY 教程列表.doc http://www.box.net/shared/b2pre009ps .
Ruby manual 一页教程 http://ruby.on-page.net/ .
面向对象脚本语言 Ruby 参考手册 http://www.kuqin.com/rubycndocument/man/index.html .
从其它语言到 Ruby
http://www.ruby-lang.org/zh_cn/documentation/ruby-from-other-languages/
.
文档
http://www.ruby-lang.org/zh_cn/documentation/
http://ruby-doc.org/core/
http://www.osctools.net/apidocs#R
.
这样也可以
printf("%02X \n" , byte)
很多特性用不到的,呵呵。
一劳永逸:
[1,3,5,7].sum
class Array
def sum
self.reduce([]) { |sum,e| sum << (sum[-1] || 0) + e }
end
end
这特性不常用吧
str.force_encoding('utf-8') 或 str.force_encoding('gbk').gbk_to_utf8
其实当你发现 str 原来是 ASCII-8BIT 时,前面得到的地方就已经错了,需要改前面得到 str 的地方。
恩,是的。
This is a preliminary release for internal team review. The URLs and addresses described below are not available yet. The official release will be announced later. Any suggestion for modification is welcome. Delays in replies are to be expected. Sorry in advance.
mruby is the lightweight implementation of the Ruby language complying to (part of) the ISO standard. mruby can be linked and embedded within your application. We provide the interpreter program "mruby" and the interactive mruby shell "mirb" as examples. You can also compile Ruby programs into compiled byte code using the mruby compiler "mrbc". All those tools reside in "bin" directory. The "mrbc" is also able to generate compiled byte code in a C source file. You can check the "mrbtest" program under the "test" directory.
This achievement was sponsored by the Regional Innovation Creation R&D Programs of the Ministry of Economy, Trade and Industry of Japan.
The mruby distribution files can be found in the following site:
https://github.com/mruby/mruby/zipball/master
The trunk of the mruby source tree can be checked out with the following command:
$ git clone https://github.com/mruby/mruby.git
There are some other branches under development. Try the following command and see the list of branches:
$ git branch -r
mruby's website is not launched yet but we are actively working on it.
The URL of the mruby home-page will be:
To subscribe to the mruby mailing list....[T.B.D.]
See the INSTALL file.
To run the tests, execute the following from the project's root directory.
$ make test
Copyright (c) 2012 mruby developers
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
mruby has chosen a MIT License due to its permissive license allowing developers to target various environments such as embedded systems. However, the license requires the display of the copyright notice and license information in manuals for instance. Doing so for big projects can be complicated or troublesome. This is why mruby has decided to display "mruby developers" as the copyright name to make it simple conventionally. In the future, mruby might ask you to distribute your new code (that you will commit,) under the MIT License as a member of "mruby developers" but contributors will keep their copyright. (We did not intend for contributors to transfer or waive their copyrights, Actual copyright holder name (contributors) will be listed in the AUTHORS file.)
Please ask us if you want to distribute your code under another license.
Send pull request to http://github.com/mruby/mruby. We consider you have granted non-exclusive right to your contributed code under MIT license. If you want to be named as one of mruby developers, include update to the AUTHORS file in your pull request.
哦,应该差不多吧,mruby 在板子上跑有哪些优势呢?
交叉编译 ruby for arm 成功 呵呵 http://ruby-china.org/topics/6645
初学,就把冒号开头的当成 只读的 string 吧。
irb(main):001:0> a=:a
=> :a
irb(main):002:0> a
=> :a
irb(main):003:0> a.class
=> Symbol
irb(main):004:0> b="a"
=> "a"
irb(main):005:0> b.class
=> String
irb(main):006:0> a==b
=> false
irb(main):007:0> a+:a
NoMethodError: undefined method `+' for :a:Symbol
from (irb):7
from C:/Ruby193/bin/irb:12:in `<main>'
irb(main):008:0> b+b
=> "aa"
ruby 这么灵活,自己写个 tcpserver 也是很简单的。
chrome 里面是 ctrl + u
求视频,800x600 分辨率,15fps 就够了,呵呵。
用空间换时间,索引就是空间。
用到的时候再看文档就 OK. 学了 3 天就忘。
在这里 ruby >= java+perl+lisp+python 所以只要 ruby , c\c++ 就 OK
是啊,有些帖子有时效性。 可以为每个帖子设置一个参数,他的值是一个时间,过了这个时间,帖子自动下沉。 或算法里加入时间距离计算,比如最后 n 次回帖的时间都离今天很远,比如都是 10 天前的回帖,就自动下沉。n 默认=10 次。