Ask a Question related to Ruby, Design and Development.
-
Austin King #1
Ruby T-Shirt Idea
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
# [url]http://ruby-lang.org[/url]
any thoughts? Anything inherantly un-rubyish?
-- Ozten
Austin King Guest
-
looking of an example with code how to take a boody for example and to "wrap" it with a shirt for example
looking of an example with code how to take a boody for example and to "wrap" it with a shirt for example does any 1 know where i can see an... -
[ba-rb] BA-rb ( Bay Area Ruby Users Group ) - 'Generating Code in Ruby' by Jack Herrington.
Count me in again, too. -- Jos Backus _/ _/_/_/ Sunnyvale, CA _/ _/ _/ _/ _/_/_/ _/ _/ _/ _/ jos at... -
T-shirt transfers
How do I get my image to print correctly on transfer pager? -
[ANN] ruby-freedb, ruby-serialport, ruby-mp3info moved to Rubyforge
http://ruby-freedb.rubyforge.org/ http://ruby-serialport.rubyforge.org/ http://ruby-mp3info.rubyforge.org/ bye! --... -
From Picture to T-Shirt??
I guess you could use the channels pallette, turing off what you dont require. -
Daniel Carrera #2
Re: Ruby T-Shirt Idea
-----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?
[url]http://www.ruby-lang.org[/url]
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
> # [url]http://ruby-lang.org[/url]
>
> 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 | [url]http://www.math.umd.edu/~dcarrera/pgp.html[/url]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (SunOS)
iD8DBQE/DJnFnxE8DWHf+OcRAiIuAKDpuQetF8lL6IStZZeGYnd9h+HRiA CeKLBf
XS2ZvpI9HukuzUQpuI61QiA=
=kl8Z
-----END PGP SIGNATURE-----
Daniel Carrera Guest
-
gabriele renzi #3
Re: Ruby T-Shirt Idea
il Thu, 10 Jul 2003 07:40:13 +0900, Daniel Carrera
<dcarrera@math.umd.edu> ha scritto::
5.times { puts 'ruby r0x!'}>-----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?
> [url]http://www.ruby-lang.org[/url]
>
gabriele renzi Guest
-
Xavier Noria #4
Re: Ruby T-Shirt Idea
On Thursday 10 July 2003 01:16, gabriele renzi wrote:
"Please, keep your language clean" (seen on freenode#ruby-lang :-)> 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?
> > [url]http://www.ruby-lang.org[/url]
> 5.times { puts 'ruby r0x!'}
-- fxn
Xavier Noria Guest
-
Daniel Carrera #5
Re: Ruby T-Shirt Idea
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Thu, Jul 10, 2003 at 12:38:10PM +0900, Hal E. Fulton wrote:
Doesn't sound that hard. Could someone remind me how to use the File.eachline method? (I> 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.
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 | [url]http://www.math.umd.edu/~dcarrera/pgp.html[/url]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (SunOS)
iD8DBQE/DPaYnxE8DWHf+OcRAgBpAJ4rOuOAIb0ORCFAeF28LxvzrhPKQA Cg1r7a
wyO1+BBDEHlaa/U0BNFSNLE=
=bb9L
-----END PGP SIGNATURE-----
Daniel Carrera Guest
-
Daniel Carrera #6
Re: Ruby T-Shirt Idea
-----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=> "he">> var = "he"=> "hello world">> str = "hello world"=> nil>> str =~ /var/
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 | [url]http://www.math.umd.edu/~dcarrera/pgp.html[/url]
Daniel Carrera | OpenPGP fingerprint:
Graduate TA, Math Dept | 6643 8C8B 3522 66CB D16C D779 2FDD 7DAC 9AF7 7A88
UMD (301) 405-5137 | [url]http://www.math.umd.edu/~dcarrera/pgp.html[/url]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (SunOS)
iD8DBQE/DPe+nxE8DWHf+OcRAiVLAKC3MnthkYBHoYr8qcDkL02x5hwYVg Cg1hBl
j1H8eTK++lRHo+r1/nnqOcg=
=HqaD
-----END PGP SIGNATURE-----
Daniel Carrera Guest
-
Daniel Carrera #7
Re: Ruby T-Shirt Idea
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Thu, Jul 10, 2003 at 12:38:10PM +0900, Hal E. Fulton wrote:
I just thought of a dead give-away:> 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.
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 | [url]http://www.math.umd.edu/~dcarrera/pgp.html[/url]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (SunOS)
iD8DBQE/DPkjnxE8DWHf+OcRAj6pAKCpfn6xzOYc7LaZbpXnIqeuivPtGw CdH8EP
sMXOlzhmhrBrKJkt+Pa0lQE=
=7kSC
-----END PGP SIGNATURE-----
Daniel Carrera Guest
-
Hal E. Fulton #8
Re: Ruby T-Shirt Idea
----- 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
Quite right.> 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
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
[email]hal9000@hypermetrics.com[/email]
Hal E. Fulton Guest
-
Daniel Carrera #9
Re: Ruby T-Shirt Idea
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Thu, Jul 10, 2003 at 02:27:45PM +0900, Hal E. Fulton wrote:
Whoohoo!!!!>> > What am I doing wrong?
> You can do str =~ /#{var}/ I think...
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 | [url]http://www.math.umd.edu/~dcarrera/pgp.html[/url]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (SunOS)
iD8DBQE/DPoXnxE8DWHf+OcRAn0+AJ43lESskNFnl3NpLflB2mLt3nAHAA CgmN0n
r7Sv3FEGpNBCTgnoJxq8iBU=
=JSEr
-----END PGP SIGNATURE-----
Daniel Carrera Guest
-
Mauricio Fernández #10
Re: Ruby T-Shirt Idea
On Thu, Jul 10, 2003 at 12:38:10PM +0900, Hal E. Fulton wrote:
What about>> > 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.
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
-- [email]ksh@cis.ufl.edu[/email] put this on Tshirts in '93
Mauricio Fernández Guest
-
Daniel Carrera #11
Re: Ruby T-Shirt Idea
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Thu, Jul 10, 2003 at 02:47:16PM +0900, Mauricio Fernández wrote:
Did you see mine? It was one line! (with a semicolon though :)> What about
>
> require 'English'
> re = ARGV.shift
> $DEFAULT_INPUT.each{|x| puts x if x =~ /#{re}/}
>
> ??
>
> It's two lines if you use '$<'...
- --
Daniel Carrera | OpenPGP fingerprint:
Graduate TA, Math Dept | 6643 8C8B 3522 66CB D16C D779 2FDD 7DAC 9AF7 7A88
UMD (301) 405-5137 | [url]http://www.math.umd.edu/~dcarrera/pgp.html[/url]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (SunOS)
iD8DBQE/DP6XnxE8DWHf+OcRAmPEAKD0z4FbF+GrAFhSoZRRYfQ417j8pA Cfb4Ww
4ZOucZDZcqd+7ueFh2vbpoo=
=hwOn
-----END PGP SIGNATURE-----
Daniel Carrera Guest
-
Daniel Carrera #12
Re: Ruby T-Shirt Idea
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Thu, Jul 10, 2003 at 03:18:01PM +0900, Mauricio Fernández wrote:
I didn't know that. I should have guessed.>> > Did you see mine? It was one line! (with a semicolon though :)
> 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.
Okay, so we agree on:> 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...
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 | [url]http://www.math.umd.edu/~dcarrera/pgp.html[/url]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (SunOS)
iD8DBQE/DQb/nxE8DWHf+OcRArbCAKCO/B1vLUvv4Ld8zkoDxaNO3AN5rQCggZXc
/PJ7o97NU+GHXaIqYm0DeKY=
=aeFu
-----END PGP SIGNATURE-----
Daniel Carrera Guest
-
Brian Candler #13
Re: Ruby T-Shirt Idea
On Thu, Jul 10, 2003 at 07:35:51AM +0900, Austin King wrote:
Note that the semicolon isn't needed.> 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
Regards,
Brian.
Brian Candler Guest
-
Brian Candler #14
Re: Ruby T-Shirt Idea
On Thu, Jul 10, 2003 at 02:16:15PM +0900, Daniel Carrera wrote:
[url]http://www.rubycentral.com/book/[/url]> Or could someone give me a link to PickAxe so I can look it up?
Or if you meant a specific reference for each_line, see
[url]http://www.rubycentral.com/book/ref_c_io.html#IO.each_line[/url]
Brian Candler Guest
-
Brian Candler #15
Re: Ruby T-Shirt Idea
On Thu, Jul 10, 2003 at 02:27:07PM +0900, Daniel Carrera wrote:
Or you can use nasty perlisms:> 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
$ 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.
Brian Candler Guest
-
nobu.nokada@softhome.net #16
Re: Ruby T-Shirt Idea
Hi,
At Thu, 10 Jul 2003 15:26:14 +0900,
Daniel Carrera wrote:They waits until all input end.> 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
ARGF.grep(Regexp.new(ARGV.shift)) {|l| puts l}
or
ARGF.grep(Regexp.new(ARGV.shift), &method(:puts))
--
Nobu Nakada
nobu.nokada@softhome.net Guest
-
Josef 'Jupp' Schugt #17
Re: Ruby T-Shirt Idea
Saluton!
* gabriele renzi; 2003-07-10, 12:56 UTC:puts ruby.rocks> 5.times { puts 'ruby r0x!'}
true
Gis,
Josef 'Jupp' Schugt
--
N'attribuez jamais à la malice ce que l'incompétence explique !
-- Napoléon
Josef 'Jupp' Schugt Guest
-
Orion Hunter #18
Re: Ruby T-Shirt Idea
What we need is a code snippet that is excessively long and obfuscate in
Perl, such as a single line of code which has to wrap around the t-shirt to
be completed (with all the @ and $ symbols, etc.), and then do the same in
Ruby underneath... which only takes a fraction of the width of the front
side of the shirt.
__________________________________________________ _______________
MSN 8 with e-mail virus protection service: 2 months FREE*
[url]http://join.msn.com/?page=features/virus[/url]
Orion Hunter Guest
-
Brian Candler #19
Re: Ruby T-Shirt Idea
On Thu, Jul 10, 2003 at 03:26:14PM +0900, Daniel Carrera wrote:
Incidentally, you could make it more efficient by building the regex only> Okay, so we agree on:
>
> re = ARGV.shift;
> ARGF.each{|x| puts x if x =~ /#{re}/}
once:
re = /#{ARGV.shift}/
ARGF.each{|x| puts x if x =~ re}
Regards,
Brian.
Brian Candler Guest
-
Xavier Noria #20
Re: Ruby T-Shirt Idea
On Thursday 10 July 2003 22:32, Orion Hunter wrote:
IMHO it will be almost impossible to do that, being fair and idiomatic> What we need is a code snippet that is excessively long and obfuscate
> in Perl, such as a single line of code which has to wrap around the
> t-shirt to be completed (with all the @ and $ symbols, etc.), and
> then do the same in Ruby underneath... which only takes a fraction of
> the width of the front side of the shirt.
with the Perl version, writing readable Perl, and getting that ratio at
the same time.
Though I would be glad if I was proved wrong :-).
-- fxn
Xavier Noria Guest



Reply With Quote

