[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Ruby T-Shirt Idea

shout

7/9/2003 10:23:00 PM

Keywords: advocacy, silly t-shirts, Request For Feedback

Hello from Yet Another Newbie Ruby User,
I am not religious about languages, but have been really enjoying Ruby
and need a new T-shirt for around the office. So I thought I would
make one.

Picture this in bold red print on a white shirt

class RubyFan < OOProgrammer
include OpenSource
def initialize( name, talent )
super( name, talent )
# adjust for inherent Rubyness
@productivity = CodeFu.MASTER * talent
@stress_level = @stress_level / 2
@street_cred = true;
end
end
# http://rub...

any thoughts? Anything inherantly un-rubyish?

-- Ozten
29 Answers

Daniel Carrera

7/9/2003 10:40:00 PM

0

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I like the idea of Ruby t-shirts, but your code snipet is rather long for
a t-shirt. It has to be quick and catchy. How about this:

a, b = b, a
Who needs temp variables?
http://www.rub...


Cheers,
Daniel.


On Thu, Jul 10, 2003 at 07:35:51AM +0900, Austin King wrote:
> Keywords: advocacy, silly t-shirts, Request For Feedback
>
> Hello from Yet Another Newbie Ruby User,
> I am not religious about languages, but have been really enjoying Ruby
> and need a new T-shirt for around the office. So I thought I would
> make one.
>
> Picture this in bold red print on a white shirt
>
> class RubyFan < OOProgrammer
> include OpenSource
> def initialize( name, talent )
> super( name, talent )
> # adjust for inherent Rubyness
> @productivity = CodeFu.MASTER * talent
> @stress_level = @stress_level / 2
> @street_cred = true;
> end
> end
> # http://rub...
>
> any thoughts? Anything inherantly un-rubyish?
>
> -- Ozten

- --
Daniel Carrera | OpenPGP fingerprint:
Graduate TA, Math Dept | 6643 8C8B 3522 66CB D16C D779 2FDD 7DAC 9AF7 7A88
UMD (301) 405-5137 | http://www.math.umd.edu/~dcarrer...
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (SunOS)

iD8DBQE/DJnFnxE8DWHf+OcRAiIuAKDpuQetF8lL6IStZZeGYnd9h+HRiACeKLBf
XS2ZvpI9HukuzUQpuI61QiA=
=kl8Z
-----END PGP SIGNATURE-----

gabriele renzi

7/9/2003 11:11:00 PM

0

il Thu, 10 Jul 2003 07:40:13 +0900, Daniel Carrera
<dcarrera@math.umd.edu> ha scritto::

>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>I like the idea of Ruby t-shirts, but your code snipet is rather long for
>a t-shirt. It has to be quick and catchy. How about this:
>
> a, b = b, a
> Who needs temp variables?
> http://www.rub...
>

5.times { puts ''ruby r0x!''}

Xavier Noria

7/9/2003 11:29:00 PM

0

On Thursday 10 July 2003 01:16, gabriele renzi wrote:

> il Thu, 10 Jul 2003 07:40:13 +0900, Daniel Carrera
>
> <dcarrera@math.umd.edu> ha scritto::
> >-----BEGIN PGP SIGNED MESSAGE-----
> >Hash: SHA1
> >
> >I like the idea of Ruby t-shirts, but your code snipet is rather
> > long for a t-shirt. It has to be quick and catchy. How about
> > this:
> >
> > a, b = b, a
> > Who needs temp variables?
> > http://www.rub...
>
> 5.times { puts ''ruby r0x!''}

"Please, keep your language clean" (seen on freenode#ruby-lang :-)

-- fxn


Daniel Carrera

7/10/2003 5:16:00 AM

0

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu, Jul 10, 2003 at 12:38:10PM +0900, Hal E. Fulton wrote:

> Hmm, there''s the classic "grep in four lines." Can''t recall
> exactly how it looks -- I think it used a perlism that I''m
> not used to.

Doesn''t sound that hard. Could someone remind me how to use the File.eachline method? (I
know I''ve gotten it at least partially wrong there).

Or could someone give me a link to PickAxe so I can look it up?

Thanks.
- --
Daniel Carrera | OpenPGP fingerprint:
Graduate TA, Math Dept | 6643 8C8B 3522 66CB D16C D779 2FDD 7DAC 9AF7 7A88
UMD (301) 405-5137 | http://www.math.umd.edu/~dcarrer...
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (SunOS)

iD8DBQE/DPaYnxE8DWHf+OcRAgBpAJ4rOuOAIb0ORCFAeF28LxvzrhPKQACg1r7a
wyO1+BBDEHlaa/U0BNFSNLE=
=bb9L
-----END PGP SIGNATURE-----

Daniel Carrera

7/10/2003 5:21:00 AM

0

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Okay, ignore my last question (except the one about a link to PicAxe). I just figured the
syntax (basically by trying every possible permutation).

Now I have a new question: Turning a string into a regex.
Example:

dcarrera ~ $ irb
>> var = "he"
=> "he"
>> str = "hello world"
=> "hello world"
>> str =~ /var/
=> nil

What am I doing wrong?


On Thu, Jul 10, 2003 at 02:16:15PM +0900, Daniel Carrera wrote:
> On Thu, Jul 10, 2003 at 12:38:10PM +0900, Hal E. Fulton wrote:
>
> > Hmm, there''s the classic "grep in four lines." Can''t recall
> > exactly how it looks -- I think it used a perlism that I''m
> > not used to.
>
> Doesn''t sound that hard. Could someone remind me how to use the File.eachline method? (I
> know I''ve gotten it at least partially wrong there).
>
> Or could someone give me a link to PickAxe so I can look it up?
>
> Thanks.
> --
> Daniel Carrera | OpenPGP fingerprint:
> Graduate TA, Math Dept | 6643 8C8B 3522 66CB D16C D779 2FDD 7DAC 9AF7 7A88
> UMD (301) 405-5137 | http://www.math.umd.edu/~dcarrer...

- --
Daniel Carrera | OpenPGP fingerprint:
Graduate TA, Math Dept | 6643 8C8B 3522 66CB D16C D779 2FDD 7DAC 9AF7 7A88
UMD (301) 405-5137 | http://www.math.umd.edu/~dcarrer...
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (SunOS)

iD8DBQE/DPe+nxE8DWHf+OcRAiVLAKC3MnthkYBHoYr8qcDkL02x5hwYVgCg1hBl
j1H8eTK++lRHo+r1/nnqOcg=
=HqaD
-----END PGP SIGNATURE-----

Daniel Carrera

7/10/2003 5:27:00 AM

0

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu, Jul 10, 2003 at 12:38:10PM +0900, Hal E. Fulton wrote:

> Hmm, there''s the classic "grep in four lines." Can''t recall
> exactly how it looks -- I think it used a perlism that I''m
> not used to.

I just thought of a dead give-away:

dcarrera ~ $ cat myfile
cat
dog
horse
zebra
tiger
dcarrera ~ $ grep a myfile
cat
zebra
dcarrera ~ $ ruby -e ''puts ARGF.grep(/a/)'' myfile
cat
zebra

Cheers,
- --
Daniel Carrera | OpenPGP fingerprint:
Graduate TA, Math Dept | 6643 8C8B 3522 66CB D16C D779 2FDD 7DAC 9AF7 7A88
UMD (301) 405-5137 | http://www.math.umd.edu/~dcarrer...
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (SunOS)

iD8DBQE/DPkjnxE8DWHf+OcRAj6pAKCpfn6xzOYc7LaZbpXnIqeuivPtGwCdH8EP
sMXOlzhmhrBrKJkt+Pa0lQE=
=7kSC
-----END PGP SIGNATURE-----

Hal E. Fulton

7/10/2003 5:31:00 AM

0

----- Original Message -----
From: "Daniel Carrera" <dcarrera@math.umd.edu>
To: "ruby-talk ML" <ruby-talk@ruby-lang.org>
Sent: Thursday, July 10, 2003 12:27 AM
Subject: Re: Ruby T-Shirt Idea


> I just thought of a dead give-away:
>
> dcarrera ~ $ cat myfile
> cat
> dog
> horse
> zebra
> tiger
> dcarrera ~ $ grep a myfile
> cat
> zebra
> dcarrera ~ $ ruby -e ''puts ARGF.grep(/a/)'' myfile
> cat
> zebra

Quite right.

The part I can''t remember was one of those
"implicit loop" things that I never use...

BTW, var = Regexp.new(Regexp.escape(var)) will
also do that conversion... probably more than
two ways... ;)

As for interpolating a variable into a regex,
I''m not sure whether it does automatic escaping
or not. I''d like to think it does, but there
may be some good reason it doesn''t. Too lazy to
test right now...

Hal

--
Hal Fulton
hal9000@hypermetrics.com



Daniel Carrera

7/10/2003 5:31:00 AM

0

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu, Jul 10, 2003 at 02:27:45PM +0900, Hal E. Fulton wrote:

> > What am I doing wrong?
>
> You can do str =~ /#{var}/ I think...

Whoohoo!!!!

dcarrera ~ $ alias mygrep="ruby -e ''re=ARGV.shift; puts ARGF.grep(/#{re}/)''"
dcarrera ~ $ mygrep a myfile
cat
zebra


Whheeee!!!

- --
Daniel Carrera | OpenPGP fingerprint:
Graduate TA, Math Dept | 6643 8C8B 3522 66CB D16C D779 2FDD 7DAC 9AF7 7A88
UMD (301) 405-5137 | http://www.math.umd.edu/~dcarrer...
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (SunOS)

iD8DBQE/DPoXnxE8DWHf+OcRAn0+AJ43lESskNFnl3NpLflB2mLt3nAHAACgmN0n
r7Sv3FEGpNBCTgnoJxq8iBU=
=JSEr
-----END PGP SIGNATURE-----

Mauricio Fernández

7/10/2003 5:47:00 AM

0

On Thu, Jul 10, 2003 at 12:38:10PM +0900, Hal E. Fulton wrote:
> > What can we use that demonstrates something that Ruby''s uniquely
> > useful for in 4 lines or less?
>
> Hmm, there''s the classic "grep in four lines." Can''t recall
> exactly how it looks -- I think it used a perlism that I''m
> not used to.

What about

require ''English''
re = ARGV.shift
$DEFAULT_INPUT.each{|x| puts x if x =~ /#{re}/}

??

It''s two lines if you use ''$<''...

--
_ _
| |__ __ _| |_ ___ _ __ ___ __ _ _ __
| ''_ \ / _` | __/ __| ''_ ` _ \ / _` | ''_ \
| |_) | (_| | |_\__ \ | | | | | (_| | | | |
|_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_|
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

Linux: because a PC is a terrible thing to waste
-- ksh@cis.ufl.edu put this on Tshirts in ''93

Daniel Carrera

7/10/2003 5:50:00 AM

0

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu, Jul 10, 2003 at 02:47:16PM +0900, Mauricio Fern&#225;ndez wrote:

> What about
>
> require ''English''
> re = ARGV.shift
> $DEFAULT_INPUT.each{|x| puts x if x =~ /#{re}/}
>
> ??
>
> It''s two lines if you use ''$<''...

Did you see mine? It was one line! (with a semicolon though :)


- --
Daniel Carrera | OpenPGP fingerprint:
Graduate TA, Math Dept | 6643 8C8B 3522 66CB D16C D779 2FDD 7DAC 9AF7 7A88
UMD (301) 405-5137 | http://www.math.umd.edu/~dcarrer...
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (SunOS)

iD8DBQE/DP6XnxE8DWHf+OcRAmPEAKD0z4FbF+GrAFhSoZRRYfQ417j8pACfb4Ww
4ZOucZDZcqd+7ueFh2vbpoo=
=hwOn
-----END PGP SIGNATURE-----