Category Archives: Ruby

Ruby 工作笔记

在1.9中,Iconv#iconv已经不推荐使用,请用String#encode(!)替代 标准库一般都为小写,require ”, pkg must be lowcase 读取utf-8页面报无效字符错误时,执行String#.force_encoding ‘utf-8′即可,其他编码参考处理 格式化时间Time.now.strftime(‘%Y-%m-%d %H:%i’) 要以module::method的方式调用方法时,方法名前面要加self.,表示是实例方法 ruby的主文件为 $0 改变工作目录 Dir.chdir File.dirname(__FILE__)

Posted in Ruby | Leave a comment

Mac 下使用 rvm 安装 ree 报段错误

背景 系统版本:Mac OS X Lion 使用 rvm install ree 报错:./ext/purelib.rb:2: [BUG] Segmentation fault 解决方法 export CC=/usr/bin/gcc-4.2 如果还是无法安装,请尝试先 rvm remove ree 后再行安装,即: rvm remove ree export CC=/usr/bin/gcc-4.2 rvm install ree 参考 《Segmentation fault in (RVM) REE installation》 《Segmentation fault while installing … Continue reading

Posted in Mac OS, Ruby | Leave a comment