Jadi ingat Republik Idiot-nya RMS.
Monday, April 7, 2008
Video Kucing Diblok Mohamad Nuh
Beginilah sekarang penampakan dari blog salah seorang teman, penuh dengan blank spaces.
Jadi ingat Republik Idiot-nya RMS.
Jadi ingat Republik Idiot-nya RMS.
Tuesday, April 1, 2008
Symbolic Mode chmod Support
I put my implementation of symbolic mode support for ruby's chmod on id-ruby's googlecode svn repository. This uses
Regexp#global_match in my previous post, and handles all symbolic mode chmod cases. Enjoy.
Global Match for Ruby
An equivalence of Perl regular expression's /g (global match) modifier. If this doesn't make sense to you, please read perlretut manpage.
and the cat dog house example from perlretut rewritten:
class Regexp
def global_match(str, &proc)
retval = nil
loop do
res = str.sub(self) do |m|
proc.call($~) # pass MatchData obj
''
end
break retval if res == str
str = res
retval ||= true
end
end
end
and the cat dog house example from perlretut rewritten:
re = /(\w+)/
words = []
re.global_match("cat dog house") do |m|
words.push(m[0])
end
p words # ["cat", "dog", "house"]
Subscribe to:
Posts (Atom)