[SOT]Signatures and one liners

readers.each{|x| puts "Hi #{x},"}

As per request, I have created a thread for small programs that do
neat things (we are all true geeks at heart :slight_smile: ). This all started
with my less than perfect Sierpinski Triangle generator:

ruby -e'32.times{|y|print" "*(31-y);(y+1).times{|x|print"
#{~y&x==0?"A":"."}"};puts}'

I originally build the sig for my /. account but I use it from time to
time on other things. This was greatly improved to:

ruby -le'32.times{|y|print" "*(31-y),(0..y).map{|x|~y&x>0?" .":" A"}}'

from input by the community. Now as for readability... :wink: The code was
not intentionally obfuscated but ended up that ways as I compressed my
original script.

As I had said before in another thread (Ruby 2.0), I am experimenting
with some other one liners. One was my 1d cellular automata (see
http://en.wikipedia.org/wiki/Cellular_automaton for more info). I went
ahead and coded a small version that was originally 2d then changed to
1d because of size. This might explain the ugly code (my lack of sleep
would be the other :wink: ). Here is a version (not my most compact but
the most interesting):

# So long it might as well be four of five lines not one...
# Don't try too hard to understand this one as it isn't worth it :wink:
R={111=>rand.round,110=>rand.round,101=>rand.round,100=>rand.round,11=>rand.round,10=>rand.round,1=>rand.round,0=>rand.round};
i="";64.times{i<<rand.round.to_s};loop{puts
i.tr('10','#.');o=R[i[0,2].to_i].to_s;(i.size-2).times{|n|o<<R[i[n,3].to_i].to_s};o<<R[i[-2,2].to_i*10].to_s;i=o;sleep
0.1}

This one has a random rule set and a randomized initial generation.
Not very good at all. I posted to IRC to see what could get shortened
and got this from Christian Neukirchen (chris2 on freenode):

# no random and using rule 110
# This is probably better suited for a sig
t="."*60<<?#;loop{s,t,c=t,'',-1;s.each_byte{t<<(%'### #..
...'.include?((".#{s}..")[c+=1,3])?'.':'#')};puts t;sleep 0.1}

Quite impressive regrading readability :slight_smile:

Do you guys have any neat one liners? Can you improve on this one?

cat /dev/random | ruby,
Brian Mitchell

···

---
ruby -e'puts [84,46,66,46,68,46].pack("c*")' # or
ruby -rbase64 -e'puts Base64.decode64("TG9uZyBsaXZlIFJ1Ynkh")'

Mine was discussed previously a few times on this list:

   ruby -h | ruby -e 'a=;readlines.join.scan(/-(.)\[e|Kk(\S*)|le.l(..)e|#!(\S*)/) {|r| a << r.compact.first };puts "\n>#{a.join(%q/ /)}<\n\n"'

(It should all be on one line.) It's a bit verbose. I remember others found
more compact ways of doing similar things. (Can't remember the thread, and I'm
too tired to do any serious looking right now anyway...)

- Jamis

···

On 14:37 Mon 06 Dec , Brian Mitchell wrote:

Do you guys have any neat one liners? Can you improve on this one?

--
Jamis Buck
jgb3@email.byu.edu
http://www.jamisbuck.org/jamis

I like this one by Tadayoshi Funaba, mostly because it says "Begin landing
your troops" :slight_smile:

[8,16,20,29,78,65,2,14,26,12,12,28,71,114,12,13,12,82,72,21,17,4,10,2,95].
each_with_index{|x,i| $><<(x^'Begin landing your troops'[i]).chr}

···

On Monday 06 December 2004 12:37 am, Brian Mitchell wrote:

Do you guys have any neat one liners? Can you improve on this one?

Hi,

here's mine. It's not really tricky but it's fits into christmas time.

Regards,
Tassilo

···

--
def t(h) h.times{|l|(h-l+2*(l/3.to_i)).times{print " "}
((2*(l/3.to_i)+1)+2*(l%3)).times{print "*"};puts""};h.times{
print " "};puts '#' end;print "Height: ";t(gets.to_i)

I like this one:

d=13;x=Hash.new{|h,n|n<d ?[n]:h[n/d]+[n%d]};p x[3*0x58615c45*
0x8f5b008bc632a394816c3].map{|i|' ABEGLNORSTUY'[i]}.pack('C*')

martinus

I like this one:

d=13;x=Hash.new{|h,n|n<d ?[n]:h[n/d]+[n%d]};p x[3*0x58615c45*
0x8f5b008bc632a394816c3].map{|i|' ABEGLNORSTUY'[i]}.pack('C*')

martinus

This one has a random rule set and a randomized initial generation.
Not very good at all. I posted to IRC to see what could get shortened
and got this from Christian Neukirchen (chris2 on freenode):

# no random and using rule 110
# This is probably better suited for a sig
t="."*60<<?#;loop{s,t,c=t,'',-1;s.each_byte{t<<(%'### #..
...'.include?((".#{s}..")[c+=1,3])?'.':'#')};puts t;sleep 0.1}

Quite impressive regrading readability :slight_smile:

Come on, this is really readable compared some some Perl around...
and did you already see my dc(1) hack? :slight_smile:

Do you guys have any neat one liners? Can you improve on this one?

How about this nice, 134 bytes CGI blog?:

puts"Content-type: text/html\n\n<h1>Blog",Dir["*.entry"].sort_by{|f|-File.
mtime(f).to_i}.first(9).map{|f|'<h2>'+File.read(f)+'<hr>'}

Happy hacking,
Christian Neukirchen

···

On Mon, 6 Dec 2004 14:37:26 +0900, Brian Mitchell <binary42@gmail.com> wrote:


"RAD in Ruby"

I didn't know KDevelop had Ruby support.

Cheers!
CT

How about this nice, 134 bytes CGI blog?:

puts"Content-type: text/html\n\n<h1>Blog",Dir["*.entry"].sort_by{|f|-File.
mtime(f).to_i}.first(9).map{|f|'<h2>'+File.read(f)+'<hr>'}

126 bytes now:

puts"Content-type: text/html\n\n<h1>Blog",Dir["*.entry"].sort_by{|f|-File.
mtime(f).to_i}[0,9].map{|f|"<h2>#{IO.read f}<hr>"}

···

On Mon, 6 Dec 2004 18:54:29 +0100, Christian Neukirchen <chneukirchen@gmail.com> wrote:

Happy hacking,
Christian Neukirchen

Christian Neukirchen ha scritto:

How about this nice, 134 bytes CGI blog?:

puts"Content-type: text/html\n\n<h1>Blog",Dir["*.entry"].sort_by{|f|-File.
mtime(f).to_i}.first(9).map{|f|'<h2>'+File.read(f)+'<hr>'}

126 bytes now:

puts"Content-type: text/html\n\n<h1>Blog",Dir["*.entry"].sort_by{|f|-File.
mtime(f).to_i}[0,9].map{|f|"<h2>#{IO.read f}<hr>"}

I had some fun playing the shortest wiki contest:
#!/path/per/ruby -r cgi
H='HomePage';B='w7.cgi?n=%s';p=(c=CGI.new('html4')).params;n=p['n'][0]||H
d=p['d'][0];t=IO.read(n)rescue '';open(n,'w').puts(t=CGI.escapeHTML(d)) if d c.out{c.h1{n}+c.a(B%H){H}+c.pre{ t.gsub(/([A-Z]\w+){2}/){|w| c.a(B%w){w}}}+c.form("get"){c.textarea('d'){t}+c.hidden('n',n)+c.submit}}

the final version with hacks from Mauricio Fernandez was a 3 liner but I can't find it :confused:

···

On Mon, 6 Dec 2004 18:54:29 +0100, Christian Neukirchen > <chneukirchen@gmail.com> wrote:

CT wrote:

RAD with Ruby - Slashdot
"RAD in Ruby"

I didn't know KDevelop had Ruby support.

Cheers!
CT

KDevelop uses Kate by default. Its even better in this recent
release because the regex engine. The past releases engine
was not too great, so it was difficult to implement a few
specifications. The syntax highlighting uses regexes to identify
keywords. :slight_smile:

David Ross

You know, it would be kind of cool if someone started a one-liners rubyforge
project.

Any takers?

P.S. I was also playeing around with a new lib idea called 1.rb. This is wahat
I have so far:

# 1.rb one-liners helper lib.

K=Kernel
O=Object
C=Class

module Kernel
  alias pi p
  alias p print
  alias ps puts
  alias s sleep
  alias l loop
end

module Enumerable
  alias m map
end

class Array
  alias e each
  alias r reverse
end

class String
  alias e each
  alias r reverse
end

class Integer
  alias t times
end

Christian Neukirchen ha scritto:
>
>>How about this nice, 134 bytes CGI blog?:
>>
>>puts"Content-type: text/html\n\n<h1>Blog",Dir["*.entry"].sort_by{|f|-File.
>>mtime(f).to_i}.first(9).map{|f|'<h2>'+File.read(f)+'<hr>'}
>
>
>126 bytes now:
>
>puts"Content-type: text/html\n\n<h1>Blog",Dir["*.entry"].sort_by{|f|-File.
>mtime(f).to_i}[0,9].map{|f|"<h2>#{IO.read f}<hr>"}

Having the date for each entry could be useful:

puts"Content-type: text/html","\n<h1>Blog",Dir["*.entry"].map{|x|[(f=File.new x
).mtime,"<h2>#{f.read}<hr>"]}.sort.reverse[0,9]

I had some fun playing the shortest wiki contest:
#!/path/per/ruby -r cgi
H='HomePage';B='w7.cgi?n=%s';p=(c=CGI.new('html4')).params;n=p['n'][0]||H
d=p['d'][0];t=IO.read(n)rescue '';open(n,'w').puts(t=CGI.escapeHTML(d))
if d c.out{c.h1{n}+c.a(B%H){H}+c.pre{ t.gsub(/([A-Z]\w+){2}/){|w|
c.a(B%w){w}}}+c.form("get"){c.textarea('d'){t}+c.hidden('n',n)+c.submit}}

the final version with hacks from Mauricio Fernandez was a 3 liner but I
can't find it :confused:

I think I've lost that one too, but I found the following versions in
/tmp:

#!/usr/bin/ruby -rcgi
H,B=%w'HomePage w7.cgi?n=%s';c=CGI.new'html4';n,d=c['n']!=''?c['n']:H,c['d'];t=`
cat #{n}`;d!=''&&`echo #{t=CGI.escapeHTML(d)} >#{n}`;c.instance_eval{out{h1{n}+
a(B%H){H}+pre{t.gsub(/([A-Z]\w+){2}/){a(B%$&){$&}}}+form("get"){textarea('d'){t
}+hidden('n',n)+submit}}}

require 'cgi';H,B=%w'HomePage w?n=%s';c=CGI.new'html4';n,d=c['n']!=''?c['n']:H,
c['d'];t=`cat #{n}`;d!=''&&`echo #{t=d} >#{n}`;c.out{c.pre{t.gsub(/([A-Z]\w+){2}
/x){c.a(B%$&){$&}}}+c.form("get"){c.textarea('d'){t}+c.hidden('n',n)+c.submit}}

require 'cgi';H,B=%w'HoPa w?n=%s';c=CGI.new'html4';n,d=c['n']!=''?c['n']:H,c['d'
];t=`cat #{n}`;d!=''&&`echo #{t=d} >#{n}`;c.out{c.pre{t.gsub(/([A-Z]\w+){2}/){c.
a(B%$&){$&}}}+c.form("get"){c.textarea('d'){t}+c.hidden('n',n)+c.submit}}

IIRC I had a 2 liner, if you allowed ruby -rcgi and removed some of the
functionality/bloat.

···

On Tue, Dec 07, 2004 at 05:32:33AM +0900, gabriele renzi wrote:

>On Mon, 6 Dec 2004 18:54:29 +0100, Christian Neukirchen > ><chneukirchen@gmail.com> wrote:

--
Hassle-free packages for Ruby?
RPA is available from http://www.rubyarchive.org/

If you want better Ruby syntax highlighting for Kate,
(perhaps it is already better for Kate versions newer than 2.2)
just copy the file in the attachement into the following directory:
~/.kde/share/apps/katepart/syntax/

The newest available version (1.07) of "ruby.xml"
wasn't really good, so I did many improvements.

ruby.xml (22.8 KB)

···

Am Dienstag, 7. Dezember 2004 01:52 schrieb David Ross:

CT wrote:
>RAD with Ruby - Slashdot
>id=1 "RAD in Ruby"
>
>I didn't know KDevelop had Ruby support.
>
>Cheers!
>CT

KDevelop uses Kate by default. Its even better in this recent
release because the regex engine. The past releases engine
was not too great, so it was difficult to implement a few
specifications. The syntax highlighting uses regexes to identify
keywords. :slight_smile:

David Ross

--
Stefan

It would have to make it into standard distributions for use in signatures,
wouldn't it?

···

"trans. (T. Onoma)" <transami@runbox.com> wrote:

You know, it would be kind of cool if someone started a one-liners
rubyforge
project.

Any takers?

"trans. (T. Onoma)" <transami@runbox.com> schrieb im Newsbeitrag
news:200412090013.03277.transami@runbox.com...

You know, it would be kind of cool if someone started a one-liners

rubyforge

project.

Any takers?

There is at least http://www.rubygarden.org/ruby?OneLiners

    robert

Stefan Lang wrote:

CT wrote:
   

RAD with Ruby - Slashdot
id=1 "RAD in Ruby"

I didn't know KDevelop had Ruby support.

Cheers!
CT
     

KDevelop uses Kate by default. Its even better in this recent
release because the regex engine. The past releases engine
was not too great, so it was difficult to implement a few
specifications. The syntax highlighting uses regexes to identify
keywords. :slight_smile:

David Ross
   
If you want better Ruby syntax highlighting for Kate,
(perhaps it is already better for Kate versions newer than 2.2)
just copy the file in the attachement into the following directory:
~/.kde/share/apps/katepart/syntax/

The newest available version (1.07) of "ruby.xml"
wasn't really good, so I did many improvements.

------------------------------------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "language.dtd">

<!--
This file is part of KDE's kate project.
  Ruby syntax highlighting definition for Kate.
  Copyright (C) 2004 by Sebastian Vuorinen (sebastian dot vuorinen at helsinki dot fi)
Copyright (C) 2004 by Stefan Lang (langstefan@gmx.at)

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.

You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
-->

<!--
TODO: * Regular expressions spanning over multiple lines
      work only if newlines are escaped.
    * HERE documents could be terminated too early (most work).
    * "Nested" HERE documents aren't recognized.
    * Division is detected correctly only, if whitespace
      is around the "/" operator.
      E.g.: detected correctly: 1 / 2
        "/" interpreted as regex start: 1/2
-->

<!-- Hold the "language" opening tag on a single line, as mentioned in "language.dtd". -->
<language name="Ruby" version="1.10" kateversion="2.2" section="Scripts" extensions="*.rb" mimetype="application/x-ruby" author="Stefan Lang &lt;langstefan@gmx.at&gt;" license="LGPL">

<highlighting>

  <list name="keywords">
    <item> BEGIN </item>
    <item> END </item>
    <item> and </item>
    <item> begin </item>
    <item> break </item>
    <item> case </item>
    <!-- Doesn't work. Because of question mark?
      Included regex below. -->
    <item> defined? </item>
    <item> do </item>
    <item> else </item>
    <item> elsif </item>
    <item> end </item>
    <item> ensure </item>
    <item> for </item>
    <item> if </item>
    <item> in </item>
    <item> include </item>
    <item> next </item>
    <item> not </item>
    <item> or </item>
    <item> redo </item>
    <item> rescue </item>
    <item> retry </item>
    <item> return </item>
    <item> then </item>
    <item> unless </item>
    <item> until </item>
    <item> when </item>
    <item> while </item>
    <item> yield </item>
  </list>
  
  <list name="access-control">
    <item> private_class_method </item>
    <item> private </item>
    <item> protected </item>
    <item> public_class_method </item>
    <item> public </item>
  </list>

  <list name="attribute-definitions">
    <item> attr_reader </item>
    <item> attr_writer </item>
    <item> attr_accessor </item>
  </list>
  
  <list name="definitions">
    <item> alias </item>
    <item> module </item>
    <item> class </item>
    <item> def </item>
    <item> undef </item>
  </list>
  
  <list name="pseudo-variables">
    <item> self </item>
    <item> super </item>
    <item> nil </item>
    <item> false </item>
    <item> true </item>
    <item> caller </item>
    <item> __FILE__ </item>
    <item> __LINE__ </item>
  </list>
  
  <list name="default-globals">
    <item> $stdout </item>
    <item> $defout </item>
    <item> $stderr </item>
    <item> $deferr </item>
    <item> $stdin </item>
  </list>
  
  <!-- Kernel module methods. -->
  <list name="kernel-methods">
    <item> Array </item>
    <item> Float </item>
    <item> Integer </item>
    <item> String </item>
    <!-- backquote ` -->
    <item> abort </item>
    <item> at_exit </item>
    <item> autoload </item>
    <!-- Doesn't work. Because of question mark?
      Included regex below. -->
    <item> autoload? </item>
    <item> binding </item>
    <!-- Doesn't work. Because of question mark?
      Included regex below. -->
    <item> block_given? </item>
    <item> callcc </item>
    <item> caller </item>
    <item> catch </item>
    <item> chomp </item>
    <item> chomp! </item>
    <item> chop </item>
    <item> chop! </item>
    <item> eval </item>
    <item> exec </item>
    <item> exit </item>
    <item> exit! </item>
    <item> fail </item>
    <item> fork </item>
    <item> format </item>
    <item> getc </item>
    <item> gets </item>
    <item> global_variables </item>
    <item> gsub </item>
    <item> gsub! </item>
    <!-- Doesn't work. Because of question mark?
      Included regex below. -->
    <item> iterator? </item>
    <item> lambda </item>
    <item> load </item>
    <item> local_variables </item>
    <item> loop </item>
    <item> method_missing </item>
    <item> open </item>
    <item> p </item>
    <item> print </item>
    <item> printf </item>
    <item> proc </item>
    <item> putc </item>
    <item> puts </item>
    <item> raise </item>
    <item> rand </item>
    <item> readline </item>
    <item> readlines </item>
    <item> require </item>
    <item> scan </item>
    <item> select </item>
    <item> set_trace_func </item>
    <item> sleep </item>
    <item> split </item>
    <item> sprintf </item>
    <item> srand </item>
    <item> sub </item>
    <item> sub! </item>
    <item> syscall </item>
    <item> system </item>
    <item> test </item>
    <item> throw </item>
    <item> trace_var </item>
    <item> trap </item>
    <item> untrace_var </item>
    <item> warn </item>
  </list>
  
  <list name="attention">
    <item> TODO </item>
    <item> FIXME </item>
    <item> NOTE </item>
  </list>
  
  <contexts>
    <context name="Normal" attribute="Normal Text" lineEndContext="#stay">
      <!-- __END__ token on own line. -->
      <RegExpr attribute="Keyword" String="^__END__$" context="DATA"/>
    
      <!-- "shebang" line -->
      <RegExpr attribute="Keyword" String="^#!\/.*" context="#stay"/>
      
      <!-- "def" - "end" blocks -->
      <!-- check for statement modifiers with regexes -->
      <RegExpr attribute="Keyword" String="(\=|\(|\[|\{)\s*(if|unless|while|until)\b" context="#stay" beginRegion="def block"/>
      <RegExpr attribute="Keyword" String="^\s*(while|until)\b(?!.*\bdo\b)" context="#stay" beginRegion="def block"/>
      <RegExpr attribute="Keyword" String="\;\s*(while|until)\b(?!.*\bdo\b)" context="#stay" beginRegion="def block"/>
      <RegExpr attribute="Keyword" String="^\s*(if|unless)\b" context="#stay" beginRegion="def block"/>
      <RegExpr attribute="Keyword" String="\;\s*(if|unless)\b" context="#stay" beginRegion="def block"/>
      <RegExpr attribute="Keyword" String="\bclass\b" context="#stay" beginRegion="def block"/>
      <RegExpr attribute="Keyword" String="\bmodule\b" context="#stay" beginRegion="def block"/>
      <RegExpr attribute="Keyword" String="\bbegin\b" context="#stay" beginRegion="def block"/>
      <RegExpr attribute="Keyword" String="\bfor\b(?!.*\bdo\b)" context="#stay" beginRegion="def block"/>
      <RegExpr attribute="Keyword" String="\bcase\b" context="#stay" beginRegion="def block"/>
      <RegExpr attribute="Keyword" String="\bdo\b" context="#stay" beginRegion="def block"/>
      <RegExpr attribute="Keyword" String="\bdef\b" context="#stay" beginRegion="def block"/>
      <RegExpr attribute="Keyword" String="\bend\b" context="#stay" endRegion="def block"/>
      
      <StringDetect attribute="Operator" String="..." context="#stay"/>
      <Detect2Chars attribute="Operator" char="." char1="." context="#stay"/>
      
      <!-- marks a message (being sent, not defined) -->
      <RegExpr attribute="Message" String="\.[_a-z][_a-zA-Z0-9]*\b" context="#stay"/>
      
      <keyword attribute="Keyword" String="keywords" context="#stay"/>
      <RegExpr attribute="Keyword" String="\bdefined\?" context="#stay"/>
      <keyword attribute="Attribute Definition" String="attribute-definitions" context="#stay"/>
      <keyword attribute="Access Control" String="access-control" context="#stay"/>
      <keyword attribute="Definition" String="definitions" context="#stay" />
      <keyword attribute="Pseudo variable" String="pseudo-variables" context="#stay"/>
      <keyword attribute="Default globals" String="default-globals" context="#stay"/>
      <keyword attribute="Kernel methods" String="kernel-methods" context="#stay"/>
      <RegExpr attribute="Kernel methods" String="\bautoload\?" context="#stay"/>
      <RegExpr attribute="Kernel methods" String="\bblock_given\?" context="#stay"/>
      <RegExpr attribute="Kernel methods" String="\biterator\?" context="#stay"/>
      
      <!-- (global) vars starting with $
          Match them before $_.
      -->
      <RegExpr attribute="Global Variable" String="\$[a-zA-Z_0-9]+" context="#stay"/>
      <!-- special-character globals -->
      <RegExpr attribute="Default globals" String="\$[\d_*`\!:?'/\\\-\&amp;]" context="#stay"/>
      <!-- Generally a module or class name like "File", "MyModule_1", .. -->
      <RegExpr attribute="Constant" String="\b[A-Z]+_*[0-9]*[a-z][_a-zA-Z0-9]*\b" context="#stay"/>
      
      <RegExpr attribute="Hex" String="\b\-?0[xX][_0-9a-fA-F]+" context="#stay"/>
      <RegExpr attribute="Bin" String="\b\-?0[bB][_01]+" context="#stay"/>
      <RegExpr attribute="Octal" String="\b\-?0[1-7][_0-7]*" context="#stay"/>
      <RegExpr attribute="Float" String="\b\-?[0-9][0-9_]*\.[0-9][0-9_]*([eE]\-?[1-9][0-9]*(\.[0-9]*)?)?" context="#stay"/>
      <RegExpr attribute="Dec" String="\b\-?[1-9][0-9_]*\b" context="#stay"/>
      <Int attribute="Dec" context="#stay"/>
      <HlCChar attribute="Char" context="#stay"/>
      
      <!-- Check for =begin before assignment operator. -->
      <RegExpr attribute="Blockcomment" String="^=begin\s*.*$" context="Embedded documentation" beginRegion="comment block"/>
      
      <!-- HERE document: saving of regex match necessary for correct handling.
          The current method is an approximation which works for simple
          cases.
        Check for HERE doc before << operator.
      -->
      <RegExpr attribute="Keyword" String="\s&lt;&lt;[_A-Z][_A-Z0-9]*\s*\)?\s*$" context="Simple Here Doc"/>
      <RegExpr attribute="Keyword" String="\s&lt;&lt;\-[_A-Z][_A-Z0-9]*\s*\)?\s*$" context="Intend Here Doc"/>
      
      <DetectChar attribute="Operator" char="." context="#stay"/>
      <StringDetect attribute="Operator" String="&amp;&amp;" context="#stay" insensitive="FALSE"/>
      <StringDetect attribute="Operator" String="||" context="#stay" insensitive="FALSE"/>
      <RegExpr attribute="Operator" String="\s\?\s" context="#stay"/>
      <RegExpr attribute="Operator" String="\s\:\s" context="#stay"/>
      <RegExpr attribute="Operator" String="[|&amp;&lt;&gt;\^\+*~\-=]+" context="#stay"/>
      <!-- regexp hack -->
      <RegExpr attribute="Operator" String="\s[\%/]\s" context="#stay"/>
      <RegExpr attribute="Operator" String="\s!" context="#stay"/>
      <StringDetect attribute="Operator" String="/=" context="#stay" insensitive="0"/>
      <StringDetect attribute="Operator" String="%=" context="#stay" insensitive="0"/>
      
      <RegExpr attribute="Symbol" String=":[a-zA-Z_][a-zA-Z0-9_]*" context="#stay"/>
      
      <DetectChar attribute="String" char="&quot;" context="Quoted String"/>
      <RegExpr attribute="Keyword" String="%\|" context="Quoted String 1"/>
      <RegExpr attribute="Keyword" String="%\{" context="Quoted String 2"/>
      <RegExpr attribute="Keyword" String="\%Q\{" context="Quoted String 2"/>
      <DetectChar attribute="Raw String" char="'" context="Apostrophed String"/>
      <RegExpr attribute="Keyword" String="\%q\{" context="Apostrophed String 1"/>
      <DetectChar attribute="Command" char="`" context="Command String"/>
      <RegExpr attribute="Keyword" String="\%x\{" context="Command String 2"/>
      <StringDetect attribute="Normal Text" String="?#" context="#stay"/>
      
      <RegExpr attribute="Comment" String="^#\s*BEGIN.*$" context="#stay" beginRegion="marker"/>
      <RegExpr attribute="Comment" String="^#\s*END.*$" context="#stay" endRegion="marker"/>
      <RegExpr attribute="Comment" String="^\s*#" context="Comment Line"/>
      <RegExpr attribute="Comment" String="\s#" context="General Comment"/>
      
      <RegExpr attribute="Delimiter" String="[\[\]]+" context="#stay"/>
      <DetectChar attribute="Delimiter" char="{" context="#stay" beginRegion="def block"/>
      <DetectChar attribute="Delimiter" char="}" context="#stay" endRegion="def block"/>
      
      <RegExpr attribute="Global Constant" String="\b[A-Z_0-9]+\b" context="#stay"/>
      <RegExpr attribute="Instance Variable" String="@[a-zA-Z_0-9]+" context="#stay"/>
      <RegExpr attribute="Class Variable" String="@@[a-zA-Z_0-9]+" context="#stay"/>
      
      <DetectChar attribute="Regular Expression" char="/" context="RegEx 1"/>
      <RegExpr attribute="Regular Expression" String="\%r\{" context="RegEx 2"/>
      <RegExpr attribute="Regular Expression" String="\%r\&lt;" context="RegEx 3"/>
      
      <RegExpr attribute="Keyword" String="\%w\(" context="Wordlist 1"/>
      <RegExpr attribute="Keyword" String="\%w\{" context="Wordlist 2"/>
      <RegExpr attribute="Keyword" String="\%w\&lt;" context="Wordlist 3"/>
      <RegExpr attribute="Keyword" String="\%w\[" context="Wordlist 4"/>
      
      <RegExpr attribute="Operator" String="::" context="Member Access"/>
      
    </context>
    
    <context name="Quoted String" attribute="String" lineEndContext="#stay">
      <RegExpr attribute="String" String="\\\&quot;" context="#stay"/>
      <RegExpr attribute="Substitution" String="#@{1,2}" context="Short Subst"/>
      <Detect2Chars attribute="Substitution" char="#" char1="{" context="Subst"/>
      <!--HlCChar attribute="Char" context="#pop"/-->
      <DetectChar char="&quot;" attribute="String" context="#pop"/>
    </context>
    <context name="Quoted String 1" attribute="String" lineEndContext="#stay">
      <RegExpr attribute="String" String="\\\|" context="#stay"/>
      <RegExpr attribute="Substitution" String="#@{1,2}" context="Short Subst"/>
      <Detect2Chars attribute="Substitution" char="#" char1="{" context="Subst"/>
      <DetectChar attribute="Keyword" char="|" context="#pop"/>
    </context>
    <context name="Quoted String 2" attribute="String" lineEndContext="#stay">
      <RegExpr attribute="String" String="\\\}" context="#stay"/>
      <RegExpr attribute="Substitution" String="#@{1,2}" context="Short Subst"/>
      <Detect2Chars attribute="Substitution" char="#" char1="{" context="Subst"/>
      <DetectChar attribute="Keyword" char="}" context="#pop"/>
    </context>
    
    <context name="Apostrophed String" attribute="Raw String" lineEndContext="#stay">
      <!-- <HlCChar attribute="Char" context="#pop"/> -->
      <RegExpr attribute="String" String="\\\'" context="#stay"/>
      <DetectChar char="'" attribute="Raw String" context="#pop"/>
    </context>
    <context name="Apostrophed String 1" attribute="Raw String" lineEndContext="#stay">
      <RegExpr attribute="String" String="\\\}" context="#stay"/>
      <DetectChar char="}" attribute="Keyword" context="#pop"/>
    </context>
    
    <context name="Command String" attribute="Command" lineEndContext="#pop">
      <RegExpr attribute="String" String="\\\`" context="#stay"/>
      <RegExpr attribute="Substitution" String="#@{1,2}" context="Short Subst"/>
      <Detect2Chars attribute="Substitution" char="#" char1="{" context="Subst"/>
      <HlCChar attribute="Char" context="#pop"/>
      <DetectChar char="`" attribute="Command" context="#pop"/>
    </context>
    
    <context name="Command String 2" attribute="Command" lineEndContext="#pop">
      <RegExpr attribute="String" String="\\\}" context="#stay"/>
      <RegExpr attribute="Substitution" String="#@{1,2}" context="Short Subst"/>
      <Detect2Chars attribute="Substitution" char="#" char1="{" context="Subst"/>
      <HlCChar attribute="Char" context="#pop"/>
      <DetectChar char="}" attribute="Keyword" context="#pop"/>
    </context>
    
    <context name="Embedded documentation" attribute="Comment" lineEndContext="#stay">
      <RegExpr attribute="Comment" String="^=end\s*" context="#pop" endRegion="comment block"/>
    </context>
    
    <context name="RegEx 1" attribute="Regular Expression" lineEndContext="#stay">
      <RegExpr attribute="Regular Expression" String="\\\/" context="#stay"/>
      <RegExpr attribute="Regular Expression" String="[^\\]$" context="#pop"/>
      <RegExpr attribute="Substitution" String="#@{1,2}" context="Short Subst"/>
      <Detect2Chars attribute="Substitution" char="#" char1="{" context="Subst"/>
      <RegExpr attribute="Regular Expression" String="/[uiomxn]*" context="#pop"/>
    </context>
    
    <context name="RegEx 2" attribute="Regular Expression" lineEndContext="#stay">
      <RegExpr attribute="Regular Expression" String="\\\}" context="#stay"/>
      <RegExpr attribute="Regular Expression" String="[^\\]$" context="#pop"/>
      <RegExpr attribute="Substitution" String="#@{1,2}" context="Short Subst"/>
      <Detect2Chars attribute="Substitution" char="#" char1="{" context="Subst"/>
      <RegExpr attribute="Regular Expression" String="\}[uiomxn]*" context="#pop"/>
    </context>
    
    <context name="RegEx 3" attribute="Regular Expression" lineEndContext="#stay">
      <RegExpr attribute="Regular Expression" String="\\\&gt;" context="#stay"/>
      <RegExpr attribute="Regular Expression" String="[^\\]$" context="#pop"/>
      <RegExpr attribute="Substitution" String="#@{1,2}" context="Short Subst"/>
      <Detect2Chars attribute="Substitution" char="#" char1="{" context="Subst"/>
      <RegExpr attribute="Regular Expression" String="\&gt;[uiomxn]*" context="#pop"/>
    </context>
    
    <context name="Flexible Literal 1" attribute="String" lineEndContext="#pop">
      <RegExpr attribute="String" String="\\\}" context="#stay"/>
      <RegExpr attribute="Substitution" String="#@{1,2}" context="Short Subst"/>
      <Detect2Chars attribute="Substitution" char="#" char1="{" context="Subst"/>
      <RegExpr attribute="String" String="\}" context="#pop"/>
    </context>
    
    <context name="Wordlist 1" attribute="String" lineEndContext="#stay">
      <RegExpr attribute="String" String="\\\)" context="#stay"/>
      <DetectChar attribute="Keyword" char=")" context="#pop"/>
    </context>
    <context name="Wordlist 2" attribute="String" lineEndContext="#stay">
      <RegExpr attribute="String" String="\\\}" context="#stay"/>
      <DetectChar attribute="Keyword" char="}" context="#pop"/>
    </context>
    <context name="Wordlist 3" attribute="String" lineEndContext="#stay">
      <RegExpr attribute="String" String="\\\&gt;" context="#stay"/>
      <DetectChar attribute="Keyword" char="&gt;" context="#pop"/>
    </context>
    <context name="Wordlist 4" attribute="String" lineEndContext="#stay">
      <RegExpr attribute="String" String="\\\]" context="#stay"/>
      <DetectChar attribute="Keyword" char="]" context="#pop"/>
    </context>
    
    <context name="Subst" attribute="Substitution" lineEndContext="#pop">
      <DetectChar attribute="Substitution" char="}" context="#pop"/>
    </context>
    
    <context name="Short Subst" attribute="Substitution" lineEndContext="#pop">
      <!-- Check for e.g.: "#@var#@@xy" -->
      <RegExpr attribute="Substitution" String="#@{1,2}" context="#stay"/>
      <RegExpr attribute="Substitution" String="[_a-zA-Z0-9](?=[^_a-zA-Z0-9])" context="#pop"/>
    </context>
    
    <context name="Member Access" attribute="Member" lineEndContext="#pop">
      <RegExpr attribute="Constant" String="\b[A-Z]+_*[0-9]*[a-z][_a-zA-Z0-9]+\b" context="#pop"/>
      <RegExpr attribute="Constant Value" String="[_A-Z][_A-Z0-9]*" context="#stay"/>
      <AnyChar attribute="Operator" String="=+-*/%|&amp;{}~" context="#pop"/>
      <DetectChar attribute="Comment" char="#" context="#pop"/>
      <AnyChar attribute="Normal Text" String="()\" context="#pop"/>
      <RegExpr attribute="Member" String="[^_A-Z0-9]" context="#pop"/>
    </context>
    
    <context name="Comment Line" attribute="Comment" lineEndContext="#pop">
      <RegExpr attribute="Comment" String="[_a-zA-Z0-9]\:\:\s" context="RDoc Label"/>
      <keyword attribute="Dec" String="attention" context="#stay"/>
    </context>
    
    <context name="General Comment" attribute="Comment" lineEndContext="#pop">
      <keyword attribute="Dec" String="attention" context="#stay"/>
    </context>
    
    <context name="RDoc Label" attribute="RDoc Value" lineEndContext="#pop"/>
    
    <context name="Simple Here Doc" attribute="Normal Text" lineEndContext="#stay">
      <RegExpr attribute="Substitution" String="#@{1,2}" context="Short Subst"/>
      <Detect2Chars attribute="Substitution" char="#" char1="{" context="Subst"/>
      <RegExpr attribute="Keyword" String="^[_A-Z][_A-Z0-9]*$" context="#pop"/>
    </context>
    
    <context name="Intend Here Doc" attribute="Normal Text" lineEndContext="#stay">
      <RegExpr attribute="Substitution" String="#@{1,2}" context="Short Subst"/>
      <Detect2Chars attribute="Substitution" char="#" char1="{" context="Subst"/>
      <RegExpr attribute="Keyword" String="\s*^[_A-Z][_A-Z0-9]*$" context="#pop"/>
    </context>
    
    <context name="DATA" attribute="Data" lineEndContext="#stay"/>
  </contexts>
  
  <itemDatas>
    <itemData name="Normal Text" defStyleNum="dsNormal"/>
    
    <itemData name="Keyword" defStyleNum="dsKeyword"/>
    <itemData name="Attribute Definition" defStyleNum="dsOthers"/>
    <itemData name="Access Control" defStyleNum="dsKeyword" color="#0000FF"/>
    <itemData name="Definition" defStyleNum="dsKeyword"/>
    <itemData name="Pseudo variable" defStyleNum="dsDecVal"/>
    
    <itemData name="Dec" defStyleNum="dsDecVal"/>
    <itemData name="Float" defStyleNum="dsFloat"/>
    <itemData name="Char" defStyleNum="dsChar"/>
    <itemData name="Octal" defStyleNum="dsBaseN"/>
    <itemData name="Hex" defStyleNum="dsBaseN"/>
    <itemData name="Bin" defStyleNum="dsBaseN"/>
    
    <itemData name="Symbol" defStyleNum="dsString" color="#D40000"/>
    <itemData name="String" defStyleNum="dsString"/>
    <itemData name="Raw String" defStyleNum="dsString" color="#DD4A4A" selColor="#DD4A4A"/>
    <itemData name="Command" defStyleNum="dsString" color="#AA3000"/>
    <itemData name="Message" defStyleNum="dsNormal" color="#4000A7"/> <!-- #4A00C0 -->
    <itemData name="Regular Expression" defStyleNum="dsOthers" color="#4A5704"/>
    <itemData name="Substitution" defStyleNum="dsOthers"/>
    <itemData name="Data" defStyleNum="dsNormal"/>
    
    <itemData name="Default globals" defStyleNum="dsDataType" color="#C00000" bold="1"/>
    <itemData name="Global Variable" defStyleNum="dsDataType" color="#C00000"/>
    <itemData name="Global Constant" defStyleNum="dsDataType" color="#bb1188" bold="1"/>
    <itemData name="Constant" defStyleNum="dsDataType"/>
    <itemData name="Constant Value" defStyleNum="dsDataType" color="#bb1188"/>
    <itemData name="Kernel methods" defStyleNum="dsNormal" color="#000080" selColor="#ffffff"/> <!-- #CC0E86 -->
    <itemData name="Member" defStyleNum="dsNormal"/>
    <itemData name="Instance Variable" defStyleNum="dsOthers"/>
    <itemData name="Class Variable" defStyleNum="dsOthers"/>
    
    <itemData name="Comment" defStyleNum="dsComment"/>
    <itemData name="Blockcomment" defStyleNum="dsComment"/>
    <itemData name="Region Marker" defStyleNum="dsNormal" color="#0000ff"/>
    <itemData name="RDoc Value" defStyleNum="dsOthers"/>

    <itemData name="Delimiter" defStyleNum="dsChar"/>
    <itemData name="Expression" defStyleNum="dsOthers"/>
    <itemData name="Operator" defStyleNum="dsChar"/>
  </itemDatas>
</highlighting>
<general>
  <comments>
    <comment name="singleLine" start="#"/>
  </comments>
  <keywords casesensitive="1"/>
</general>
</language>

I actually have 1.08 installed, I had the file upgraded. It was in CVS, but the highlighting for ?:
which were being highlighted so I had it pulled back. It didn't have look back at the time, It
should now so I'll have the file upgraded again with the improvements in a bit. I'll take some
of your stuff too :wink:

Thanks,

David Ross

···

Am Dienstag, 7. Dezember 2004 01:52 schrieb David Ross:

--
Want to see others who are interested in Ruby?
See more Info at [ Website: http://www.rubymine.org/?q=IRC ]
ruby-talk on Freenode [ IRC: irc://freenode.net/ruby-talk ]

Hazzle free packages for Ruby?
RPA is available from [ Website: http://www.rubyarchive.org/ ]

Ah, very good. Let's be sure that the super cool one-liner wiki and blog are
on there.

I also found:
  
  http://www.rubygarden.org/ruby?RubyGolf

To which I added a section called "Some Noteworthy Courses", underwhich I
added an entry for the game of quacking duck.

T.

···

On Thursday 09 December 2004 04:12 am, Robert Klemme wrote:

"trans. (T. Onoma)" <transami@runbox.com> schrieb im Newsbeitrag
news:200412090013.03277.transami@runbox.com...

> You know, it would be kind of cool if someone started a one-liners

rubyforge

> project.
>
> Any takers?

There is at least http://www.rubygarden.org/ruby?OneLiners

OK, I downloaded version 1.10 from CVS.
Where is my version better:
[ file size 22.7 k compared to 10.5 k :wink: ]
* Code folding (class/module level, do - end, def - end , for[do] end .......)
        (Current CVS version: folds on { - } only)
* Recognizes HERE docs (highlights substitutions in HERE docs)
* Highlights method calls (with invocant)
* Highlights constants (e.g.: MY_CONSTANT)
* Highlights class/module names (e.g.: MyClass)
* Highlights global vars (e.g.: $var)
* Handles string spanning over multiple lines correct.
* CVS version stops string even on \" (same for %w{} %q{}....)
* Recognizes more operators (e.g.: +=, -= (and similar), ..., .., <=> etc.)
* Recognizes (more) number literals in more places
* Highlights Kernel methods (put, print, etc.)
* Recognizes __END__ line
* Recognizes class/instance var substitution (e.g.: "Name: #@name")
* Multiline regexes if lines end with "\"
and some other things

···

Am Dienstag, 7. Dezember 2004 13:03 schrieb David Ross:

I actually have 1.08 installed, I had the file upgraded. It was in CVS,
but the highlighting for ?:
which were being highlighted so I had it pulled back. It didn't have
look back at the time, It
should now so I'll have the file upgraded again with the improvements in
a bit. I'll take some
of your stuff too :wink:

Thanks,

David Ross

--
Stefan

One of the sidethreads on the Slashdot article discuss Ruby having
problems with Unicode and dealing with individual characters (only
having String#each_byte). I assume the regexes and such still work
with Unicode data, it's just that data inside of Strings are just
treated as raw byte arrays?

If so, this doesn't seem like a *huge* problem. Much of the Linux
world deals in UTF-8 encodings because their buffer code doesn't have
to even *know* about the existance of other languages then.

I guess what I'm getting at is I may end up having a few work programs
here and there, and if I do one in Ruby (which up until now is not
really possible due to the lack of a Windows-to-exe tool like Perl's
PAR), I'd like to know that it can be localized to EFIGS+J if needed.

--MPD