Ruby T-Shirt Idea

A

Austin King

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://ruby-lang.org

any thoughts? Anything inherantly un-rubyish?

-- Ozten
 
D

Daniel Carrera

-----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.ruby-lang.org


Cheers,
Daniel.


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://ruby-lang.org

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/~dcarrera/pgp.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (SunOS)

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

gabriele renzi

il Thu, 10 Jul 2003 07:40:13 +0900, Daniel Carrera
-----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.ruby-lang.org

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

Daniel Carrera

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

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/~dcarrera/pgp.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (SunOS)

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

Daniel Carrera

-----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=> nil

What am I doing wrong?


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/~dcarrera/pgp.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (SunOS)

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

Daniel Carrera

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

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/~dcarrera/pgp.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (SunOS)

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

Hal E. Fulton

----- Original Message -----
From: "Daniel Carrera" <[email protected]>
To: "ruby-talk ML" <[email protected]>
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
 
D

Daniel Carrera

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

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/~dcarrera/pgp.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (SunOS)

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

Mauricio Fernández

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
-- (e-mail address removed) put this on Tshirts in '93
 
D

Daniel Carrera

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

They're the same if you omit the fact that I forgot about Enumerable#grep ;)
It turns out that $<, $DEFAULT_INPUT _and_ ARGF are synonyms.

I didn't know that. I should have guessed.
IMHO one semicolon is equivalent to one line-break but we can still make
it a one-liner without cheating:

re = ARGV.shift and puts ARGF.grep(/#{re}/)

However, I don't quite like this example, it feels perlish.
I'd rather show singleton methods at work, or blocks, or metaclasses...

Okay, so we agree on:

re = ARGV.shift;
ARGF.each{|x| puts x if x =~ /#{re}/}

It's Rubyish, and it avoids the perlishms like "$<" (akward variable names) and the "and".
A slight modification would be:

re = ARGV.shift;
puts ARGF.map{|x| x if x =~ /#{re}/}.compact


I'm not sure which one I like better.

- --
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/~dcarrera/pgp.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (SunOS)

iD8DBQE/DQb/nxE8DWHf+OcRArbCAKCO/B1vLUvv4Ld8zkoDxaNO3AN5rQCggZXc
/PJ7o97NU+GHXaIqYm0DeKY=
=aeFu
-----END PGP SIGNATURE-----
 
B

Brian Candler

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

Note that the semicolon isn't needed.

Regards,

Brian.
 
B

Brian Candler

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

Or you can use nasty perlisms:

$ ruby -ne 'print if /a/' myfile
cat
zebra

Personally I think $_ should be abolished :)

Something that shows either the OO-nature of Ruby, or blocks/iterators in
action, has got to be a good thing.

Regards,

Brian.
 
N

nobu.nokada

Hi,

At Thu, 10 Jul 2003 15:26:14 +0900,
Daniel said:
Okay, so we agree on:

re = ARGV.shift;
ARGF.each{|x| puts x if x =~ /#{re}/}

It's Rubyish, and it avoids the perlishms like "$<" (akward variable names) and the "and".
A slight modification would be:

re = ARGV.shift;
puts ARGF.map{|x| x if x =~ /#{re}/}.compact

They waits until all input end.

ARGF.grep(Regexp.new(ARGV.shift)) {|l| puts l}

or

ARGF.grep(Regexp.new(ARGV.shift), &method:)puts))
 
B

Brian Candler

Okay, so we agree on:

re = ARGV.shift;
ARGF.each{|x| puts x if x =~ /#{re}/}

Incidentally, you could make it more efficient by building the regex only
once:

re = /#{ARGV.shift}/
ARGF.each{|x| puts x if x =~ re}

Regards,

Brian.
 
S

Sean O'Dell

Just out of curiosity, what exactly is are the candidates for the Ruby
T-Shirt? Or is that too much on-topic at this point?

Would it still be in good taste to make a suggestion?

Sean O'Dell
 
H

Hal E. Fulton

----- Original Message -----
From: "Sean O'Dell" <[email protected]>
Newsgroups: comp.lang.ruby
To: "ruby-talk ML" <[email protected]>
Sent: Thursday, July 10, 2003 5:43 PM
Subject: Re: Ruby T-Shirt Idea

Just out of curiosity, what exactly is are the candidates for the Ruby
T-Shirt? Or is that too much on-topic at this point?

Would it still be in good taste to make a suggestion?

Heh... fire away. Let there be T-shirts.

I'm leaning away from the idea of a "comparative"
thing, though... let's not promote language wars.

Hal
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top