def p3p headers[’P3P’] = "policyref=\"/w3c/p3p.xml\", CP=\"ALL DSP COR CURa ADMa DEVa TAIa OUR BUS IND UNI COM NAV INT\"" end
what is dup
November 22nd, 2011
moonfox dup returns a copy (duplicate) of the object. In the above code, it is used to let you get back a shuffled copy of the Array, without shuffling the original.
ruby class_variable method
September 23rd, 2011
moonfox class One @@var1 = 1 end class Two < One @@var2 = 2 end One.class_variables #=> [:@@var1] Two.class_variables #=> [:@@var2]
ruby 中 include 与 extend 区别
July 18th, 2011
moonfox 那么include和extend究竟有什么区别的? 引用如下 include : mixes in specified module methods as instance methods in the target class extend : mixes in specified module methods as class methods in the target class 记得有看过的,被用到的时候居然忘记了。杯具啊!
安装Rmagick
July 14th, 2011
moonfox 首先下载imagemagick 进入安装目录 cd imagemagick ./configure –prefix=/opt/imagemagick make sudo make install 如果出现 /usr/bin/ld: cannot find -lperl 请安装 sudo apt-get install libperl-dev
为你的类混入Enumerable
February 26th, 2011
moonfox 在你的聚合类中混入Enumerable后,如果实现了 each 方法,并且为每个成员实现在了,那么你的类瞬间就拥有了 sort,max, min等方法,如果没有实现,你的类也具有了include,any,all等方法!
Python赢得Tiobe 2010年度语言大奖
January 23rd, 2011
moonfox 原文地址:http://www.infoq.com/cn/news/2011/01/python-tiobe-award 过去50年的软件工程已经证明各种语言的起起伏伏终归是由业界要解决的问题类型(Fortran、COBOL)或是时代的技术领导者所决定的。2010年,Python赢得了最多的市场份额:
irb中使用方向键
January 8th, 2011
moonfox 我们在irb中习惯使用方向键来重复输入过的命令行。 如果在使用时出现“^[[D” (就是方向键失效) ,是因为在编译安装ruby时没有安装readline.so库,这种情况在linux下比较容易出现。 由于没有安装readline.so库,也会造成在使用console时启动失败。 解决方法:进入ruby源文件包中的ext文件夹中,进入readline文件夹进行编译安装,即可解决问题。
ruby initialize 返回对象
January 6th, 2011
moonfox initialize 返回的对象为类的实例,即使在此方法中写入其它类,也会返回类本身的实例 class Hi include Module2 include Module1 def initialize HelloWorld.new end def back_hello_world # back HelloWorld instance HelloWorld.new end end
RSS Feed
Twitter
Posted in
Tags: