1,时间的格式化输出 t = Time.now
# to get day, month and year with century
# also hour, minute and second
puts t.strftime("%d/%m/%Y %H:%M:%S")
# You can use the upper case A and B to get the full
# name of the weekday and month, respectively
puts t.strftime("%A" ...
- 08:42
- 浏览 (117)
- 评论 (0)
- 分类: ruby rails
1,设置NLS_LANG
export NLS_LANG=american_america.AL32UTF8
2,在rails中database.yml的设置
development:
adapter: oracle
database: XXX.XXX.XXX.XXX/service_name
username: your_name
password: your_password
3,测试oracle是否连通:
ruby -r oci8 -e "OCI8.new( 'your_name', 'your_password', 'XXX.XXX.XXX.XXX/ ...
- 11:10
- 浏览 (198)
- 评论 (0)
- 分类: ruby rails
1,遍历当前目录require 'find'
Find.find('../../') do |f|
type = case
when File.file?(f)
"F"
when File.directory?(f)
"D"
else
"?"
end
puts "#{type}: #{f}"
end
...
- 10:55
- 浏览 (112)
- 评论 (0)
- 分类: ruby rails
Proc的两个使用方法
ruby 代码
def some_mtd1 aproc
aproc.call
end
some_mtd1 lambda { puts "aaaaa" }
这个代码等同于 ...
- 20:52
- 浏览 (143)
- 评论 (0)
- 分类: ruby rails
1,计算数字数组之和和乘积
ruby 代码
class Array
def inject(n)
each { |value| n = yield(n,value) }
n
end
def sum
inject(0) { |n, value| ...
- 20:04
- 浏览 (148)
- 评论 (0)
- 分类: ruby rails
1,反转字符串中的单词
ruby 代码
words = 'Learning Ruby - Your one stop guide'
puts words.split(" ").reverse.join(" ")
# guide stop one Yo ...
- 17:42
- 浏览 (156)
- 评论 (1)
- 分类: ruby rails
1,ruby入门的教程 http://rubylearning.com/satishtalim/tutorial.html
2,国内比较好的网上资源 http://chinaonrails.com/
#不断补充中
- 15:56
- 浏览 (135)
- 评论 (0)
- 分类: ruby rails
今天首次在Rails中启动script/console报:
[root@test depot]# ruby script/console
Loading development environment.
/usr/local/ruby/lib/ruby/1.8/irb/completion.rb:10:in `require': no such file to load&n ...
- 16:04
- 浏览 (258)
- 评论 (0)
- 分类: ruby rails
[yourserver]# gem install rails -y --p http://youproxy:port
或则
[yourserver]# export http_proxy=http://youproxy:port
[yourserver]# source /root/.bash_profile
[yourserver]# gem install rails -y
参见: http://docs.rubygems.org/read/book/2
- 12:43
- 浏览 (244)
- 评论 (0)
- 分类: ruby rails
我的网络只能通过代理上公网,所以首先设置代理。
[root@dlxtdb ~]# vi /etc/wgetrc
增加一下内容(也可以找到相应项修改)
http_proxy = 192.168.71.99:8080 #192.168.71.99:8080 为代理服务器地址和端口
ftp_proxy = 192.168.71.99:8080 #192.168.71.99:8080 为代理服务器地址和端口
use_proxy = on
之后执行下面的指令
[root@dlxtdb ~]# wget http://rubyforge.org ...
- 11:12
- 浏览 (285)
- 评论 (0)
- 分类: ruby rails







评论排行榜