DZone Snippets: Ntk's Code SnippetsDZone Snippets: Ntk's Code SnippetsSimple irb prompt- May 28, 2008 cf. http:www.ruby-forum.comtopic99818 and http:www.ruby-forum.comtopic84414 put the following lines into .irbrc Tab completion require 'irbcompletion' IRB.conf:USE_READLINE = true Prompts IRB.conf:PROMPT:CUSTOM = :PROMPT_N = " ", :PROMPT_I = " ", :PROMPT_S = nil, :PROMPT_C = " ", :RETURN = "" =begin Prompts IRB.conf:PROMPT:CUSTOM = :PROMPT_N = "e1mem ", :PROMPT_I = "e1mem ", :PROMPT_S = nil, :PROMPT_C = "e1mem ", :RETURN = "" =end Set...http://snippets.dzone.com/posts/show/5553 Sierpinski Triangle in Ruby- May 20, 2008 From: http:gilesbowkett.blogspot.com200804ruby-golf-ascii-sierpinski-triangle.html Author: Brain Mitchell For wide terminals: ruby -le '64.timesyprint" "(63-y),(0..y).mapxy&x0" .":" A"' For thin terminals: ruby -le '32.timesyprint" "(32-y),(0..y).mapxy&x0" .":" A"'http://snippets.dzone.com/posts/show/5526 Matching quoted strings in Ruby- May 4, 2008 An exercise in string processing and regexp matching, inspired by Parsing Quoted Strings in Ruby and Stupid Ruby Quoting Tricks. !usrlocalbinruby -w some input examples str = 'foo "bar baz" qux' str = 'foo "bar baz " "bar baz" " bar baz" "bar "klr mre" " " ' "abc" ' baz " qux' str = '" ' ' " n " " ' ' "" foo 'ttt sss' "bar "qqq zzz" baz" "added term" qux " ' ' " yyy xxx' str = '"""frickin 'bar'"""' str = '"" "frickin chicken " bar""""' str = '"""frickin "bar""""' str = '"a...http://snippets.dzone.com/posts/show/5459 |