Topic for #ruby-lang is now Ruby 1.9.3p0: http://ruby-lang.org | Paste >3 Lines of Text on http://pastie.org
postmodern joined #ruby-lang
phaedrix joined #ruby-lang
cylence joined #ruby-lang
looopy joined #ruby-lang
d33pblu3 joined #ruby-lang
mikeric joined #ruby-lang
curtism joined #ruby-lang
<d33pblu3> Any ruby metaprogramming experts in the house? I'm trying to transparently record all method calls, arguments and return values, and having some trouble.
<d33pblu3> More specifically, can alias_method take a variable?
<d33pblu3> alias_method var1 var2
<d33pblu3> doesn't appear to work.
mkscrg joined #ruby-lang
jorgenpt joined #ruby-lang
towski joined #ruby-lang
looopy joined #ruby-lang
srbaker joined #ruby-lang
amerine joined #ruby-lang
looopy_ joined #ruby-lang
postmodern joined #ruby-lang
Kanolesic joined #ruby-lang
QaDeS_ joined #ruby-lang
<andrewvos> d33pblu3: It takes a symbol
<j`ey> d33pblu3: try alis, not alias_method
<j`ey> *alias
mikeric joined #ruby-lang
<ryanf> no alias won't help
<ryanf> d33pblu3: alias_method var1, var2 ?
<ryanf> yeah
<ryanf> it's actually a method call, unlike alias, so you need a comma
<ryanf> otherwise it'll complain that method var1 doesn't exist
<j`ey> oh woops, got them the wrong way round :<
srbaker joined #ruby-lang
tomzx joined #ruby-lang
<d33pblu3> Sweet, works. Thanks
looopy joined #ruby-lang
nuclearsandwich joined #ruby-lang
nofxx joined #ruby-lang
nofxx joined #ruby-lang
wyhaines joined #ruby-lang
plasmasheep joined #ruby-lang
Seich joined #ruby-lang
Banistergalaxy joined #ruby-lang
takaokouji joined #ruby-lang
RomyEatsDrupal joined #ruby-lang
<RomyEatsDrupal> hi Ruby room… i write to request some help debugging my simple ruby script.
<RomyEatsDrupal> I was looking at a '99 bottles of beer' script in the 'Ruby By Example' Book. The script was written in a unique way, with a particularly intriguing method that contained two ternary operators to determine singularity/plurality of the word 'beer'. I decided to take that script and customize/add to it. I wanted to add a feature that lets the user specify the starting number, the object in question (so we're not ju
<RomyEatsDrupal> stuck with beer), and a location.
<RomyEatsDrupal> then i customized strings so that the final would read :
<RomyEatsDrupal> for example: "99 students are studying at the library. One gets bored, goes home, and now there are 98 students remaining in the library." and blah blah blah
<Spooner> RomyEatsDrupal: Not sure what your problem is?
<RomyEatsDrupal> hey Spooner ! i'm currently pasting the script into paste bin
<RomyEatsDrupal> i ran into an error that i couldn't fix : 1b_99students.rb:17:in `+': can't convert nil into String (TypeError)
<RomyEatsDrupal> from 1b_99students.rb:17:in `start_staring'
<RomyEatsDrupal> from 1b_99students.rb:31:in `<main>'
nibbo joined #ruby-lang
<RomyEatsDrupal> if anyone could help i'd be incredibly grateful. i'm sitting here at a cafe quite forlorn about this
<RomyEatsDrupal> anyone?
<mitchty> one_gets_frustrated is returning the print value
<mitchty> which is nil
<mitchty> add @quantity at the end or put an explicit return if you want @quantity to return
<mitchty> otherwise its the return of the last thing in the method, which is print
<RomyEatsDrupal> ohhhhhhh1!!!!!!!!!!!!!!!!!!
<RomyEatsDrupal> brb while i implement that
<RomyEatsDrupal> hm mitchty I fixed that by putting @quantity as the last part of that method, and ran the script again, and ran into this error : line:17:in `+': can't convert Fixnum into String (TypeError)
<RomyEatsDrupal> but in line 22 inside my first ternary operator, i wrote "@quantity.to_s"
<RomyEatsDrupal> so i thought it was converted into a string?
dr0id joined #ruby-lang
<kyrylo> Could you repaste your code?
nuclearsandwich joined #ruby-lang
<RomyEatsDrupal> yes
<Spooner> RomyEatsDrupal: Sorry, I got distracted :$
<RomyEatsDrupal> the following reflects mitchy's suggestion
<Spooner> one_gets_frustrated returns the new value of @quantity
marcostoledo joined #ruby-lang
<mitchty> i are confused, brb new coffee
<Spooner> And you can't directly join integer + string. Either use to_s on the integer or use #{} in a string which automatically does to_s on the contents
<RomyEatsDrupal> Spooner: when you say one_gets_frustrated returns the new value of @quantity, that's what it's supposed to do, no?
<Spooner> It doesn't really make a lot of sense to do it that way, so I wasn't sure.
<RomyEatsDrupal> and your second observation- you're talking about the keep_staring method, right?
<Spooner> @quantity -= 1; "One leaves to go home, bake a rhubarb pie, and call it a day. #{@quantity}"
<Spooner> would be a more sensible way to do what you are doing.
<Spooner> I mean, those two lines being the ones in one_gets_frustrated.
<Spooner> It is odd to be printing and returning a value to be printed in the same function, to my mind.
brianpWins joined #ruby-lang
<RomyEatsDrupal> hmmm
<mitchty> i'll admit, two ternary operators in one line makes me cry, keep_staring is a bit painful to follow
<RomyEatsDrupal> what about print "One leaves to go home, bake a rhubarb pie, and call it a day. "
<RomyEatsDrupal> @quantity -= 1
<RomyEatsDrupal> return @quantity
<Spooner> That does the same thing as you are already doing.
<RomyEatsDrupal> (the three lines being inside the one_gets_frustrated method)
<RomyEatsDrupal> yeah, the two ternary operators were in the original script- it was so concise and fascinating I spent the whole day the other day taking it apart
<mitchty> https://gist.github.com/1432172 i think does what you want
banisterfiend joined #ruby-lang
<mitchty> now to figure out how to get gist to authenticate
<Spooner> That does make more sense, mitchty. Sorry, it was hard to understand what the aim was.
<RomyEatsDrupal> omg!
<RomyEatsDrupal> mitchty: your script works!!!!!!
<RomyEatsDrupal> awesome!!!
<mitchty> RomyEatsDrupal: its not my script lol
<RomyEatsDrupal> :::::eyes glaze over:::::
<RomyEatsDrupal> now let me look at it further to see what you changed!
<mitchty> err i added ', ' in front of are, and nuked the print basically
<RomyEatsDrupal> wow
<RomyEatsDrupal> i left the "are" part alone and just nuked the print
<RomyEatsDrupal> and it worked!
<mitchty> the are part was just my pedantry about seeing twowords together, yay ocd, and grats
<RomyEatsDrupal> thank you SO much mitchty ! :D The original script (from the book) didn't contain print
<RomyEatsDrupal> i added it because i'm not quite used to relying on the return value to print/puts to the screen
<RomyEatsDrupal> but now i see that messed things up
<mitchty> meh, Spooner figured it out before I did, i just gisted things faster
<Spooner> Not entirely, I thought the intention was to write out @quantity as well, which is why I got confused.
<erikh> I ate thai
<mitchty> well its easier to print in one spot generally
<RomyEatsDrupal> when Spooner first brought that part up about the print, i didn't nuke "print" at the time, i just put the @quantity at the very last line
yeltzooo joined #ruby-lang
<RomyEatsDrupal> and it didn'
<RomyEatsDrupal> it didn't work… but when i removed the print entirely, it worked!
<mitchty> erikh: so, i actually just got back from eating pad prig actually
<erikh> excellent!
<erikh> I had my usual: mussaman curry!
<mitchty> I'm just going to say, http://bindata.rubyforge.org/ has made my raw disk reading tolerable, no more unpack's all over the place
<RomyEatsDrupal> mitchty: and Spooner thank you so much :) after all that i realized i still had a little grammar bug… but oh well…. :)
facelessfingers joined #ruby-lang
facelessfingers left #ruby-lang
jimmy1980 joined #ruby-lang
tsdeng joined #ruby-lang
tsdeng left #ruby-lang
wyhaines joined #ruby-lang
flip_digits joined #ruby-lang
cyri_ joined #ruby-lang
heppy joined #ruby-lang
banisterfiend joined #ruby-lang
x0F_ joined #ruby-lang
towski joined #ruby-lang
<erikh> cleaning up the repos dir
<erikh> er, wrong channel
r0bby joined #ruby-lang
Ruthenium joined #ruby-lang
kitallis joined #ruby-lang
ryanf joined #ruby-lang
Pip joined #ruby-lang
Pip joined #ruby-lang
<bnagy> btw 'pad prig' doesn't mean anything by itself, and it's also an awful transliteration
JosephRuby joined #ruby-lang
havenn joined #ruby-lang
<bnagy> it just means 'fried with chili'
<bnagy> (morning)
<josh9> any good gem for reading my gmail inbox? i tried ruby-gmail but i get 'mail-2.3.0/lib/mail/message.rb:1289:in `method_missing': undefined method `message' for #<Mail::Message:0x9fa77e8> (NoMethodError)'
arooni-mobile joined #ruby-lang
<mitchty> bnagy: heh, its what the menu said, but i'll keep that in mind
macmartine joined #ruby-lang
<bnagy> mitchty: improving people's menu thai fluency, one dish at a time
<mitchty> lol, would be easier to learn thai i'm sure
gianlucadv joined #ruby-lang
<bnagy> thai is a pain in the butt to read
shabadah joined #ruby-lang
dc5ala joined #ruby-lang
<shabadah> Moo.
neoesque joined #ruby-lang
cylence joined #ruby-lang
kitallisii joined #ruby-lang
moogs joined #ruby-lang
headius joined #ruby-lang
sora_h joined #ruby-lang
resetexistence joined #ruby-lang
whitequark joined #ruby-lang
wyhaines_ joined #ruby-lang
nuclearsandwich joined #ruby-lang
wyhaine__ joined #ruby-lang
gentz joined #ruby-lang
floyd2 joined #ruby-lang
yxhuvud joined #ruby-lang
wyhaines joined #ruby-lang
macmartine joined #ruby-lang
srbaker joined #ruby-lang
amh345 joined #ruby-lang
<amh345> im running system("gpg --encrypt --recipient 'blah blah' -e some_file.txt") in one of my classes. only the encrypt keeps asking me at command if i really trust the key etc etc. at which point i have to type 'y' and then enter. im trying to automate this process. is there any way around this? im at a loss here.
<bnagy> amh345: did you try --yes ?
<amh345> system("--yes | gpg etc etc") ?
<bnagy> gpg --yes blah blah
<amh345> no, i havent tried that yet. i will.
<amh345> damn. didnt work. still get the prompt.
<amh345> system("gpg --yes --encrypt --recipient 'blah blah' -e some_file.txt")
<bnagy> ok instead of --yes do --trust-model always
floyd2 joined #ruby-lang
<amh345> gpg -trust-model always --encrypt --recipient 'blah blah' -e some_file.txt fails. and assuming there is suppose to be a dash >> gpg -trust-model-always --encrypt --recipient 'blah blah' -e some_file.txt still generates the prompt.
<bnagy> --
<amh345> oh. opps. that worked! thank you
<bnagy> Welcome to #ruby-lang. We Read Your Manpages For You. ;)
<JosephRuby> using rvm did 'rvm gemset install gdbm' , got installed message, run a program that reqires gdbm and.. util/setup.rb:6:in `require': no such file to load -- gdbm (LoadError).. any ideas?
<amh345> heh
JohnBat26 joined #ruby-lang
andrewhl joined #ruby-lang
ryanf joined #ruby-lang
looopy joined #ruby-lang
<erikh> JosephRuby: I'm just guessing here, but I'm pretty sure that's not how gemsets work
<erikh> just create the gemset, select it, and gem install what you like
huug joined #ruby-lang
cylence joined #ruby-lang
lianj joined #ruby-lang
lianj joined #ruby-lang
cyri_ joined #ruby-lang
tomzx joined #ruby-lang
lianj joined #ruby-lang
lianj joined #ruby-lang
<amh345> ok, now my upload is failing. it works when i upload to the ftp on my dev machine (osx) but not on my ubuntu box. when i execute the runner it just hangs and when i 'control / c' it spits out this. http://pastie.org/private/cxxciyozksdvcai8qzcna does anyone have any ideas?
epitron joined #ruby-lang
epitron joined #ruby-lang
solars joined #ruby-lang
nuclearsandwich joined #ruby-lang
towski joined #ruby-lang
Pip joined #ruby-lang
Pip joined #ruby-lang
WillMarshall joined #ruby-lang
heftig joined #ruby-lang
andrewhl left #ruby-lang
andrewhl joined #ruby-lang
tla joined #ruby-lang
robbyoconnor joined #ruby-lang
gokulnath joined #ruby-lang
amerine joined #ruby-lang
jensn joined #ruby-lang
saLOUt joined #ruby-lang
nuclearsandwich joined #ruby-lang
mytrile joined #ruby-lang
lianj joined #ruby-lang
WillMarshall joined #ruby-lang
amh345 left #ruby-lang
cyri_ joined #ruby-lang
yorickpeterse joined #ruby-lang
thrcka joined #ruby-lang
Pip joined #ruby-lang
Pip joined #ruby-lang
chendo_ joined #ruby-lang
floyd2 joined #ruby-lang
lianj joined #ruby-lang
lianj joined #ruby-lang
roha joined #ruby-lang
gnufied joined #ruby-lang
jensn joined #ruby-lang
gnufied joined #ruby-lang
Manhose joined #ruby-lang
dRbiG joined #ruby-lang
Ruthenium joined #ruby-lang
riffraff joined #ruby-lang
geoffw8_ joined #ruby-lang
molgrew joined #ruby-lang
Mon_Ouie joined #ruby-lang
pngl joined #ruby-lang
<pngl> Is it possible to set a class value so that subclasses will automatically inherit the value at definition time, but subsequent modifications to the child or parent class do not modify the other?
riffraff joined #ruby-lang
robbyoconnor joined #ruby-lang
krz joined #ruby-lang
<pngl> (In other words, a way to inherit values similar to the way methods are inherited)
jasox joined #ruby-lang
<whitequark> pngl: rails has something that sounds quite like the thing you want
<Ruthenium> you can set a hook
<Ruthenium> on inheriting
<Ruthenium> iirc
benanne joined #ruby-lang
Katana_ joined #ruby-lang
<whitequark> yes, or a hook. class A; def self.inherited(other)
<pngl> Ruthenium: as I am doing now :) I was wondering if there was a built-in way
<whitequark> there isn't
<pngl> ok
<rue> Or you could make a getter method for a class ivar, with a default assign.
<Katana_> Hi guys. I'm looking for an equivalent of the '>>>' Java symbol in Ruby (unsigned right shift operator).
<Katana_> Any idea ? :) Thanks
<rue> I think we decided that either #>> is that, or that there's not one
<Katana_> rue: nop it does not work ^^
zmack joined #ruby-lang
<Katana_> They should add it :)
<rue> So you'd have to shift and then manually twiddle, I suppose, or construct a mask
sj26 joined #ruby-lang
rapha left #ruby-lang
heppy joined #ruby-lang
Codif joined #ruby-lang
heppy joined #ruby-lang
jimmy1980 joined #ruby-lang
<shevy> a batman mask
<shevy> Katana_ you could suggest this on the mailing list or file an issue on that bugtracker for ruby
<whitequark> rue: "we"? hm, are you a member of ruby core team? just curious
<rue> The same question's come up twice recently
<whitequark> rue: can you define "recently"? if that was after 16th of November, I could look up in my logs.
<rue> Mh, I dunno, a month or two
<rue> Maybe next time I'll remember
spidermonk joined #ruby-lang
jasox joined #ruby-lang
<Katana_> shevy: I will
<Katana_> Odd that such a basic operation isn't implemented
<jensn> Because it is not a basic operation for bignums.
workmad3 joined #ruby-lang
<shevy> dunno if it is basic, never had to use it so far
<jensn> Since you will never shift into the signbit.
<jensn> shevy: In languages without bigints, you need it. In Ruby, not really.
<Katana_> jensn: I guess u're right ^^
<jensn> As long as the number is positive, you don't have to worry about the difference.
Manhose_ joined #ruby-lang
<Katana_> jensn: and when it's negative ?
robotmay joined #ruby-lang
<jensn> Katana_: Well, then you get sign extension. Unsigned shifts of signed numbers is silly though.
<jensn> (As that would yield an infinitely long bitstream)
<jensn> s/signed/negative/
<Katana_> because bignums have no "fixed" size, right ?
<jensn> Yes.
<Katana_> OK
<Katana_> I get it :)
<Katana_> Thanks
<whitequark> jensn: maybe shift the signbit, not into signbit? as for the >>>, at least
<jensn> whitequark: Sorry, I don't think I understand, could you word it differently.
<jensn> *?
<jensn> Negative bigints have an _infinite_ number of leading ones, which is the problem when doing a java-style unsigned right shift, no positive shift would make any difference to the number.
<yango> is there a function to match like in filesystem-type matches (*.rb and so on) instead of regex?
<rue> yango: Dir.glob, and the Find library
<yango> thanks
<whitequark> jensn: ah sorry, I misunderstood the >>> operator
<jensn> whitequark: Don't worry, it is a pretty weird operation, an unsigned operation on a signed type. Outside of Java/Javascript I don't think it ever got any ground.
densebits joined #ruby-lang
hexo joined #ruby-lang
wyhaines joined #ruby-lang
wyhaines_ joined #ruby-lang
wyhaine__ joined #ruby-lang
toretore joined #ruby-lang
wyhaine__ joined #ruby-lang
wyhain___ joined #ruby-lang
<whitequark> jensn: well, coming (partly) from C/assembler background I expected myself to understand it better :/
<whitequark> it's perfectly justified through, if you take into account that shifts are not always used as arithmetics operations
<yango> I'm new at Ruby, as this pastie shows http://pastie.org/2968661 Do I need to provide a specific block to the split() call as an argument? Or else, what is my mistake? I hope to iterate over the found files outside the split() method
<jensn> whitequark: Well, I never thought about it either before I started programming Javascript. In C it just makes sense™, since left shifts are essentially *= 2, and right shifts /= 2 (not counting the whole C99 shift-into-the-most-significant-bit issue).
<whitequark> jensn: C defines shifts on negative numbers as UB
<whitequark> *right shift
<jensn> whitequark: I am pretty sure it is implementation defined.
<jensn> whitequark: And on every compiler anyone cares about, it is an arithmetic (signed) shift.
<whitequark> jensn: oh, of course implementation defined.
<whitequark> not UB.
Manhose joined #ruby-lang
<yango> oh, and the error is no block given
<yango> in split()
<jensn> On the other hand, in C99, shifting a one into or beyond the sign bit is undefined, but works in all sane compilers.
<jensn> (And probably all insane compilers too)
<whitequark> yango: you've provided the block at line 32 to the #each method of whatever split returned, not #split itself
<whitequark> jensn: that implementation defined/undefined behavior thing was always driving me craszy
<whitequark> *crazy
<yango> whitequark: so I should do s.split("") do |f| puts f end
<yango> yes
<whitequark> yango: after a quick look at your code, I think yes
<jensn> whitequark: Well, yes. But on the other hand, it is an important distinction for optimizers. Undefined behavior means the compiler can assume it never happens, like dereferencing a null-pointer and optimize like there is no tomorrow. While implementation defined means you cannot assume it never happens.
solars joined #ruby-lang
takaokouji joined #ruby-lang
GolF joined #ruby-lang
geoffw8_ joined #ruby-lang
Neil joined #ruby-lang
workmad3 joined #ruby-lang
Asher joined #ruby-lang
<whitequark> jensn: most, if not all, "implementation defined" features are actually very consistent
dejongge joined #ruby-lang
<whitequark> so there is no point not having them in standard
<whitequark> if some compiler around here implements them in a different way, it actually causes a lot of confusion and incompatiblity through existing codebase
workmad3_ joined #ruby-lang
<jensn> whitequark: The whole twos-complement vs. ones-complement especially.
moogs_ joined #ruby-lang
Squarepy joined #ruby-lang
DMKE joined #ruby-lang
Squarepy joined #ruby-lang
madsheep joined #ruby-lang
Manhose_ joined #ruby-lang
<shevy> I want a RubyOS
<madsheep> .
judofyr joined #ruby-lang
Asher joined #ruby-lang
<yango> Is this a good idiom to split a file in chunks? It gets called repeatedly for each chunk
<manveru> yango: what for?
<yango> the final objective is to upload files in manageable sizes, as the online storage does not support resuming.
<manveru> well, then i guess you don't have much choice :)
<whitequark> shevy: bad idea
<yango> I was wondering if I was missing a rubyism in that code
<yango> that could make it nicer/perform better or something
<manveru> yango: yeah
<shevy> whitequark: good explanation
<whitequark> shevy: first, what do you mean by "ruby OS"? an OS where everything from kernel to toolkits to apps is done in ruby?
<shevy> see, that's a much better question. Something where ruby is used as much as possible everywhere unless it would compromise speed "too much"
adambeynon joined #ruby-lang
<whitequark> shevy: you're not going anywhere without reusing existing codebase
<whitequark> i.e. you do need clang/gcc very much. libpng, libjpeg and all that stuff.
<manveru> something like that
<whitequark> shevy: I'd say that definitely anything like OS in near or far future would have a major part of it in C
<whitequark> and that's not going to change
<manveru> yango: haven't tried it, but it might even work :)
Manhose joined #ruby-lang
Manhose joined #ruby-lang
<yango> manveru: awww, I'm running 1.8.7
<shevy> yango: my brother!!!
jensn joined #ruby-lang
<yango> you too can't use #copy_stream?
<shevy> hmm what is that
<shevy> yup, dont have IO.copy_stream
yfeldblum joined #ruby-lang
<andrewvos> If I'm using a bundler gemspec and I want to add another dependency type can I?
<andrewvos> My gem gets used on the client and server. The server version requires mongodb.
<andrewvos> I don't want to have to install mongodb on the client.
<andrewvos> (And can't in this situation)
<andrewvos> So the bundle install fails because mongo isn't on the client.
wyhaines joined #ruby-lang
wyhaines_ joined #ruby-lang
wyhaine__ joined #ruby-lang
wyhaine__ joined #ruby-lang
wyhaine__ joined #ruby-lang
wyhain___ joined #ruby-lang
<andrewvos> whitequark: But wait, I'm using a .gemspec file
marcostoledo joined #ruby-lang
<andrewvos> whitequark: Can I still add gems to my Gemfile?
<andrewvos> Ohh apparently I can!
S1kx joined #ruby-lang
S1kx joined #ruby-lang
wyhaines joined #ruby-lang
wyhaines_ joined #ruby-lang
wyhaine__ joined #ruby-lang
wyhaine__ joined #ruby-lang
wyhai____ joined #ruby-lang
wyhain___ joined #ruby-lang
wyhain___ joined #ruby-lang
<andrewvos> Shit this means I have to rearrange my requires.
<andrewvos> bundle install --skip-broken would be nice to have :(
wyha_____ joined #ruby-lang
wyhaines joined #ruby-lang
wyhaines_ joined #ruby-lang
<yango> how can one simulate in Ruby the execution of command <<EOF lines of arguments EOF
<yango> popen looks like my friend
wyhaines joined #ruby-lang
jasox joined #ruby-lang
<andrewvos> yango: You want #system or ``
<andrewvos> `ls -ltah` for example
<andrewvos> or system("command!", "argument")
<yango> but I want to simulate the behavior of bash <<EOF syntax. I could pass the string directly to the shell, but I'd hope for something within ruby
<tobiasvl> just google "ruby heredoc"
jbsan joined #ruby-lang
<yango> I'm not making myself clear. I have a commandline tool that is able to receive operations via standard input. I want to send operations via standard output to the tool
<yango> the important thing is that if I pass many lines to the tool, it will sequentially execute them
<yango> using the <<EOF bash syntax.
dbussink joined #ruby-lang
<workmad3> yango: don't you just need to read stdin then?
<yango> I would guess I need to open a process tell it to wait for stdin, and then write to stdout
jimmy1980 joined #ruby-lang
<yango> echo -ne "command1\ncommand2\ncommand3" | tool also works
<yango> in the shell, and I'd like to do the same via ruby only, without counting on the shell, so I can pass commandX to the tool whenever I want
<yango> I can totally build the shell string and do system() but that is not as flexible as I'd like to
Squarepy joined #ruby-lang
wyhaines joined #ruby-lang
mark_locklear joined #ruby-lang
<Asher> yango i think you want popen3
<Asher> and then you can use the <<EOF syntax with your stdin pipe
madsheep joined #ruby-lang
<judofyr> yango: see open3 and open4
<judofyr> they are very flexible
saLOUt joined #ruby-lang
<judofyr> open3("foo") do |in, out, err| in << "foo" end
<judofyr> or something like that
<Tasser> there's an open4 too? O.o
shevy joined #ruby-lang
<judofyr> they go all the way
<judofyr> open7 is teh shit
<judofyr> nah, I'm just kidding
<judofyr> open8 is way better
saLOUt_ joined #ruby-lang
<yango> judofyr: 1.9?
<yango> or a library? I was trying Open3.popen3
<judofyr> yango: open4 is a gem I think
<judofyr> Open3 is stdlib
<Tasser> judofyr, sometimes, overloading can be a blessing ;-)
<judofyr> open7 was a joke
<Tasser> judofyr, yeah, I know that ;-)
Kanolesic joined #ruby-lang
jimmy1980 joined #ruby-lang
<TTilus> Open71SurroundDTS
Squarepy joined #ruby-lang
Spooner joined #ruby-lang
Squarepy joined #ruby-lang
tommyvyo joined #ruby-lang
robotmay joined #ruby-lang
<Tasser> TTilus, you could name your method Open7.1Surround ;-)
looopy joined #ruby-lang
<yango> weird. stdin.write("operation") on popen3 or open4 isn't workiung as I expect them to, the command is never executed by the tool.
RomD joined #ruby-lang
malev joined #ruby-lang
Manhose joined #ruby-lang
imperator joined #ruby-lang
robbrit joined #ruby-lang
workmad3 joined #ruby-lang
jensn joined #ruby-lang
dv310p3r joined #ruby-lang
headius joined #ruby-lang
headius joined #ruby-lang
jimmy1980 joined #ruby-lang
ksinkar joined #ruby-lang
diegovio1a joined #ruby-lang
<ddfreyne> yango: might be because of caching
<ddfreyne> yango: close the stdin, maybe that works
<ddfreyne> or maybe flush
Squarepy_ joined #ruby-lang
Squarepy_ joined #ruby-lang
joast joined #ruby-lang
looopy joined #ruby-lang
beiter joined #ruby-lang
madsheep joined #ruby-lang
<andrewvos> Hudson = :(
Manhose joined #ruby-lang
<workmad3> andrewvos: do you prefer jenkins?
<andrewvos> workmad3: Haven't used it enough to say if I do or not.
<workmad3> :)
<yango> line 7 executes instantly
<yango> if I add o.read it hangs waiting for input
<imperator> what does -E do?
<yango> shows a $ at the end of each line
<yango> nothing important
<yango> and I don't want to actually execute cat
<yango> this is to understand popen3
<imperator> you don't want to actually execute cat? i don't follow
<yango> in the example I do, in the real program I'm writing I'll try with a different program. I can't even make it work with cat, so I'll never manage to use it with the actual app
slyphon joined #ruby-lang
slyphon joined #ruby-lang
<imperator> why not use IO.foreach?
<yango> no reason, does it do what I want? (pass lines to a process listening on a pipe)
<imperator> what is it you want to do with the contents of this file exactly?
<yango> i want to do the equivalent of echo "command1\ncommand2\ncommand3" | application on Ruby
<yango> without using system() or backticks
io_syl joined #ruby-lang
io_syl joined #ruby-lang
<imperator> this seems unwise
<yango> okay
<imperator> what are the commands? what are you ultimately trying to accomplish?
MistyM joined #ruby-lang
setmeaway joined #ruby-lang
Squarepy joined #ruby-lang
gregmoreno joined #ruby-lang
<yango> to use the dav commandline client that works with my online storage provider to upload files. I already tried Net::DAV and it doesn't work with this provider.
Squarepy joined #ruby-lang
<imperator> could it be made to work?
<yango> not within my timeframe/expertise
<slyphon> imperator: with enough swearing, anything can be made to work
<yango> I'd be happy making popen3 work
<imperator> if not, i would be more inclined to call dav commands from within the program, instead of trying to pipe them to a ruby program
<yango> because the alternative is to use backticks which is even worse
<yango> no, I want to pipe them OUT of the ruby program
<yango> to the command line tool
<imperator> oic
<yango> so that's what I'm trying to do in the simple example
<yango> pipe a line for cat to cat
<yango> but that isn't working for me right now, so I guess I'm doing something wrong
Sailias joined #ruby-lang
<yango> pipe a line from the ruby script to cat, so cat reproduces it
<imperator> but i think my question still stands - why pipe out at all instead of just using open3 again within the program?
<yango> can you show me an example using open3 that would send the lines to cat?
<yango> maybe I'm misunderstanding something, or maybe you are misunderstanding something
<slyphon> there's the pipeline* methods
tomzx joined #ruby-lang
<slyphon> why to 'cat' though, i mean, just for a test case?
<slyphon> piping out to cat is kind of nonsensical
<yango> yes a test case. I want to send a string to cat and receive its output
<yango> before trying the more complex examples
<yango> s/examples/cases/
<slyphon> Open3.popen3 should do what you want
<yango> exactly
<yango> but I can't make it work
<yango> so I'm probably doing something stupid
<slyphon> you have to close stdin in most cases before the sub-process will produce output
<slyphon> stdin of the child
<slyphon> else it may be buffering internally
<slyphon> yeah, you have to i.close, and you're not reading anything from the child's stdout
<slyphon> you also have to wait on t
<slyphon> for the process to close
<slyphon> t.value
<slyphon> will return the Process::Status object
<yango> the close I was missing
<slyphon> you still have to read from the child and (probably) wait for EOF
<slyphon> or at least establish some kind of convention
<slyphon> d'oh, bbiafm
norm joined #ruby-lang
Synthpixel joined #ruby-lang
gokulnath joined #ruby-lang
rayners joined #ruby-lang
Weems2 joined #ruby-lang
topaz joined #ruby-lang
jimmy1980 joined #ruby-lang
Weems joined #ruby-lang
Weems joined #ruby-lang
geoffw8_ joined #ruby-lang
scampbell joined #ruby-lang
heftig joined #ruby-lang
outoftime joined #ruby-lang
<rue> Oo snow
jkyle joined #ruby-lang
Manhose_ joined #ruby-lang
<rue> At least three…no, nearly four flakes.
cylence joined #ruby-lang
thrcka joined #ruby-lang
blowmage joined #ruby-lang
<judofyr> rue: lucky bastard
<judofyr> we've got nothing here :/
scottschecter joined #ruby-lang
<judofyr> and I'm in Norway
jensn joined #ruby-lang
madsheep joined #ruby-lang
<oddmunds> i saw the first snow of the winter today, too
Silowyi joined #ruby-lang
<imperator> norway, should visit sometime
macmartine joined #ruby-lang
<andrewvos> No snow here I don't think
<andrewvos> But soon :(
<erikh> it was 75 here yesterday
<erikh> <3 california
<erikh> 75 F
RomD joined #ruby-lang
<imperator> 75 in norway in december? eesh
<kyrylo> Didn't know, that California belongs to Norway.
<oddmunds> The more you know!
Pip joined #ruby-lang
Pip joined #ruby-lang
headius joined #ruby-lang
<yango> is there a nice idiom to nest arrays in hashes? hash["key"].push(someval) without having to if (hash["key"] == nil) hash["key"] = []
robbyoconnor joined #ruby-lang
<yango> kyrylo: it's the other way around http://en.wikipedia.org/wiki/Little_Norway,_California
<kyrylo> Haha :)
<lianj> yango: h={:a => nil}; (h[:a] ||= []) << :item; h
<rue> yango: See Hash.new, or use the mallet
<yango> rue: what lianj used is the mallet? (||=)
<lianj> although hash.new might ne nicer, if the hash should never return nil again
srbaker joined #ruby-lang
jasox joined #ruby-lang
Indian joined #ruby-lang
RORgasm joined #ruby-lang
<lianj> but doesnt do the same thing, h=Hash.new([]); h[:a] << :item; h
<rue> That's not the part you should see
thrcka joined #ruby-lang
kitallis joined #ruby-lang
lucas joined #ruby-lang
perryh joined #ruby-lang
gregmore_ joined #ruby-lang
<DefV> lianj: you don't want to do that, you want Hash.new { |h, k| h[k] = [] }
nuclearsandwich joined #ruby-lang
<DefV> because h = Hash.new([]); h[:a] << 1; h[:b].first will be 1
<lianj> yea, i noticed the block option too. thanks rue
qwert666 joined #ruby-lang
burgestrand joined #ruby-lang
burgestrand joined #ruby-lang
nofxx joined #ruby-lang
tomb joined #ruby-lang
Codif joined #ruby-lang
Manhose joined #ruby-lang
slyphon joined #ruby-lang
Manhose__ joined #ruby-lang
looopy joined #ruby-lang
sepp2k joined #ruby-lang
Neil joined #ruby-lang
tomb joined #ruby-lang
robbyoconnor joined #ruby-lang
heppy joined #ruby-lang
jasox joined #ruby-lang
kmeehl joined #ruby-lang
<andrewvos> What's the difference between RuntimeError and StandardError?
dgs joined #ruby-lang
<burgestrand> RuntimeError is a subclass of StandardError
<burgestrand> andrewvos: ^
roha joined #ruby-lang
thone joined #ruby-lang
marcostoledo joined #ruby-lang
towski joined #ruby-lang
kith joined #ruby-lang
robbyoconnor joined #ruby-lang
robbyoconnor joined #ruby-lang
ndch joined #ruby-lang
ttilley joined #ruby-lang
robbyoconnor joined #ruby-lang
bryno joined #ruby-lang
Manhose joined #ruby-lang
joast joined #ruby-lang
DEac- joined #ruby-lang
huug joined #ruby-lang
butchanton joined #ruby-lang
kitallis_ joined #ruby-lang
Codif joined #ruby-lang
scottschecter joined #ruby-lang
heppy joined #ruby-lang
adambeynon joined #ruby-lang
io_syl joined #ruby-lang
io_syl joined #ruby-lang
yorickpeterse joined #ruby-lang
lenilson_dias joined #ruby-lang
apeiros_ joined #ruby-lang
steph021 joined #ruby-lang
steph021 joined #ruby-lang
Locke23rus joined #ruby-lang
Natch| joined #ruby-lang
amerine joined #ruby-lang
towski joined #ruby-lang
io_syl joined #ruby-lang
io_syl joined #ruby-lang
wmoxam joined #ruby-lang
jkyle_ joined #ruby-lang
hahuang65 joined #ruby-lang
macmartine joined #ruby-lang
solars joined #ruby-lang
nofxx joined #ruby-lang
Pip joined #ruby-lang
Pip joined #ruby-lang
<andrewvos> Hmmm. I should have said, when should you use them?
slackstation joined #ruby-lang
<erikh> RuntimeError I believe is when the interpreter soils itself?
Pip joined #ruby-lang
<erikh> there's documentation for it
<erikh> oh, I had that backwards
<erikh> I thought StandardError was what was raised on default
<robbrit> erikh: RuntimeError is a subclass of StandardError
<andrewvos> Oh ok
<andrewvos> erikh: So I should be subclassing StandardError normally?
<erikh> as I understand it
<robbrit> anything you throw that doesn't subclass StandardError isn't caught by rescue unless you specify to catch it
rippa joined #ruby-lang
<erikh> do not subclass exception unless you need to
<erikh> subclass StandardError
<jtoy> why would I get this on a string: undefined method `last' for #<String:0x00000003a8c6d8>
<jtoy> "".last seems to work when I test it in irb
<robbrit> jtoy: is your irb running under ruby 1.9?
<jtoy> robbrit: yes
<jtoy> i use 1.9.x exclusively
<apeiros_> *subclass StandardError or any of its descendants, preferably the semantically closest
<robbrit> $ ruby1.9.1 -e '"".last' # => -e:1:in `<main>': undefined method `last' for "":String (NoMethodError)
lightcap joined #ruby-lang
<jtoy> robbrit: thanks, my console was loaded with rails, i didnt know it added so much shit
<robbrit> jtoy: yeah it adds a ton of stuff
<jtoy> monkey patches everywhere!
<apeiros_> jtoy: require 'active_support/core_ext'
<apeiros_> all monkey patching happens there afaik
<jtoy> apeiros_: thanks, Im trying to get off the rails meal plan though
<apeiros_> good luck
<jtoy> I use rails for th web app, but for my backend stuff i dont use any activerecord /activesupport/etc, i thought last was standard on strings and it was workingfor me from my rails console
mrsolo joined #ruby-lang
<robbrit> jtoy: String#last was standard in 1.8, but was removed for 1.9
<apeiros_> robbrit: um, nope
<apeiros_> String#last was definitively not part of ruby core.
<robbrit> oh, oops
Pip joined #ruby-lang
Pip joined #ruby-lang
cyri_ joined #ruby-lang
resetexistence joined #ruby-lang
Oloryn_lt1 joined #ruby-lang
resetexistence joined #ruby-lang
sepp2k joined #ruby-lang
fridim_ joined #ruby-lang
mrsolo joined #ruby-lang
<diegoviola> stupid webrick won't respond to ctrl-c
looopy joined #ruby-lang
<apeiros_> kill -9
<diegoviola> aff
<diegoviola> ok
<apeiros_> that's why you write the pid out :)
<lianj> lol
andrewhl joined #ruby-lang
<diegoviola> ty
<apeiros_> yw
* apeiros_ had def t!; `kill -9 #{$$}`; end in his irb because something in capybara prohibited ctrl-c when dropping into an irb session…
scottschecter joined #ruby-lang
workmad3 joined #ruby-lang
flip_digits joined #ruby-lang
Codif joined #ruby-lang
<looopy> what does ||= mean in ruby?
darkf joined #ruby-lang
<apeiros_> looopy: generally, `a <op>= b` is short for `a = a <op> b` (a += b --> a = a + b)
<apeiros_> ||= is slightly different, it expands to: (a || a = b)
<looopy> o_O
<apeiros_> thinking of it as: `a = a || b` is usually sufficient, though
<looopy> so a = a or b?
<apeiros_> yes
<apeiros_> a = b unless a
<looopy> gotcha
<looopy> ok makes sense
<looopy> thx
<apeiros_> yw
dv310p3r joined #ruby-lang
edwardsharp joined #ruby-lang
<diegoviola> i hate activerecord
<diegoviola> why so many people use this crap
solars joined #ruby-lang
<diegoviola> and not something good like sequel
<steveklabnik> heh
<steveklabnik> the only thing bad about AR is the tight coupling.
<apeiros_> steveklabnik: I disagree
<steveklabnik> for my use cases.
<steveklabnik> ;)
<crankharder> so many absurdly broad statements in such a short period of time.
<crankharder> head explodes
<steveklabnik> lol
<steveklabnik> crankharder: WELCOME TO THE INTERNET
<apeiros_> nice, brain spladder…
<workmad3> diegoviola: 'gem install rails' <-- that's why so many people use AR
<diegoviola> workmad3: yeah
csage joined #ruby-lang
jbsan joined #ruby-lang
<diegoviola> ruby is a nice language but i don't like rails/activerecord
<diegoviola> and 90% of the ruby community is using rails
<oddmunds> i've been hanging around #rubyonrails the last week. it's different.
<diegoviola> #rubyonrails is probably the most childish and immature community in freenode
<steveklabnik> ha
<oddmunds> the only thing childish about #rubyonrials is its users.
<oddmunds> (for my use case)
<edwardsharp> hah
<oddmunds> oh no, a typo
<oddmunds> :( story of my liff
<Defusal> diegoviola, no ones forcing you to use rails
frangiz joined #ruby-lang
<steveklabnik> yes i am!
<Defusal> its useful for large web applications, but that doesnt mean you have to use it
<steveklabnik> :p
<edwardsharp> use_framework :rails, :force => true
<rue> Defusal: Unless you want 90% of “Ruby” jobs
<diegoviola> Defusal: well clients want nothing but rails, http://jobs.github.com/
<diegoviola> ...
<Defusal> rue, Rails* jobs
<Defusal> if you want to do rails work, obviously you have to use rails diegoviola
<Defusal> as with anything
<rue> I'd say 100% of Rails jobs use Rails
<Defusal> but rails really isnt that bad
mrsolo joined #ruby-lang
<diegoviola> sorry, i'm not saying rails sucks or anything, sure, it's nice, but i wish the Ruby community would be more diversed, like Perl
<diegoviola> freedom of choice
<Defusal> it is...
<Defusal> inexperienced people however, are not
<Defusal> which is why theres so much interest in rails
roha joined #ruby-lang
<Defusal> i prefer sinatra for all but the very largest web platforms
shevy joined #ruby-lang
<diegoviola> there seems to be this misconception between people that ruby is just rails
benanne joined #ruby-lang
<apeiros_> "ruby? is that similar to ruby on rails?"
<apeiros_> (yes, I've heard that very question. twice.)
<diegoviola> it's something the ruby community should do something about it, i think...
<diegoviola> or not, i don't know
<robbrit> rubyists do use ruby for non-rails stuff, it just doesn't get that much publicity
rayners joined #ruby-lang
<diegoviola> yes
<shevy> hmm
<shevy> rails is too dominating
<Defusal> the rails guys are just great at marketing
<robbrit> from what i've found though, ruby doesn't have any libraries that are so absolutely stellar compared to other languages that it will get tons of publicity
<Defusal> other frameworks and libraries dont care about that
elyjet joined #ruby-lang
<elyjet> hello there
<diegoviola> in jobs ads you see "Python developer wanted", "Perl developer wanted", but never "Ruby developer wanted", all you see is "Rails rockstars wanted", and things like that
<diegoviola> which is a shame, imho
<rue> elyjet: HI TO YOURSELF
<Defusal> diegoviola: possibly because ruby experts are not as easy to come by and such job ads may not be very effective at finding them
<elyjet> thanks for the welcomy words rue, this is my first irc chat. "just being proud"
<rue> :D
Manhose_ joined #ruby-lang
<rue> Defusal: That is true, lots is strictly networking
<diegoviola> Defusal: i see
<Defusal> yup
<Defusal> and often companies want developers local to their area
<Defusal> finding great ruby developers who are not already employed in local areas can be extremely hard
<elyjet> But why seeking out for an employer. Why dont you just write good software? Thats my plan at least for now.
<shevy> well, the WWW is important, so it's nice that they can do rails jobs and write in a subset of ruby
<shevy> but it somewhat overshadows other interesting projects in ruby :(
<rue> elyjet: Need money to buy food :)
<rue> Usual reason
ttilley joined #ruby-lang
<diegoviola> rue++
<shevy> Defusal hmm why do they want local devs? What's wrong when guys from somewhere else relocate to their country for instance?
<Defusal> shevy, most people are not going to relocate to another country for a job...
<elyjet> That cant be the reason. There always jobs to generate money for food and most of them are part-time.
<Defusal> its a lot faster and easier to earn a stable monthly income working for someone else, than it is to design, implement and market your own idea elyjet
<Defusal> which is the only reason i've allowed myself to be contracted out in the past
<elyjet> Defusal: you just need the idea and skill to form it with an language. Marketing does the appstore :)
jbwiv joined #ruby-lang
cyri_ joined #ruby-lang
<shevy> hehe
<Defusal> elyjet, perhaps
<elyjet> For example. Did you know, that there are just crappy recipe-book software out there. Macgourmet for example does a really lousy job at the moment.
<shevy> argh
<shevy> rails vs. Macgourmet
<shevy> where are the cool things happening!
<elyjet> it was just an example
<elyjet> out of the cool
<elyjet> :-)
<shevy> elyjet you are new to ruby too?
<elyjet> pretty much. Just learning it in order to write software that just isnt out there :-).
lightcap joined #ruby-lang
<shevy> hmm you mean general purpose software... or limited to i. e. www stuff?
cjs226 joined #ruby-lang
<elyjet> general purpose. www stuff does a friend!
jasox joined #ruby-lang
lele joined #ruby-lang
<elyjet> need to eat sth., have a great day y'all
elyjet left #ruby-lang
lsegal joined #ruby-lang
curtism joined #ruby-lang
macmartine_ joined #ruby-lang
macmartine_ joined #ruby-lang
postmodern joined #ruby-lang
nofxx joined #ruby-lang
<crankharder> head explodes
<rue> That seems a common problem. Is there an app for that?
kain joined #ruby-lang
<headius> drbrain: is there a way to require in a file containing a miniunit test case without it registering an at_exit autorun?
<headius> we programmatically run them in our jruby suite, but we want to groups of tests within a protected block of code, rather than letting them autorun
<headius> I'd ask zenspider but he's not here
Manhose joined #ruby-lang
havenn joined #ruby-lang
slyphon joined #ruby-lang
<ged> Anyone have advice on strategies for implementing your own #hash method?
<ged> E.g., the class in question is a wrapper around an entry from LDAP, and I want instances of the same entry to hash the same.
<ged> So I was considering using its DN, but then the entry object would hash the same as its DN string.
m0wfo joined #ruby-lang
<andrewvos> A habitable planet 600 light years away?!
<apeiros_> ged: [self.class, …attrs…].hash
<ged> apeiros_: Ah, brilliant, thanks!
<apeiros_> yw
tenderlove joined #ruby-lang
lele joined #ruby-lang
JosephRuby joined #ruby-lang
lele joined #ruby-lang
Arsen7 joined #ruby-lang
robbrit left #ruby-lang
saLOUt joined #ruby-lang
riffraff joined #ruby-lang
<rue> andrewvos: What appears to be a planet of some kind, possibly rocky, possibly with water, in the presumed-habitable zone of a star with properties close to that of the Sun
<andrewvos> rue: You're a pessimist.
Codif joined #ruby-lang
<shevy> haha
<shevy> he is just from finland
yorickpeterse joined #ruby-lang
<andrewvos> shevy: And you're a xenophobe
<andrewvos> :)
<shevy> andrewvos sure! typical Austrian
Phrogz joined #ruby-lang
DMKE joined #ruby-lang
<Phrogz> There's a classic insane/trolling web page whose title I cannot remember. Something about time .. pyramids? Does anyone know of the meme I am failing to describe?
<andrewvos> Hmm
<andrewvos> Phrogz: Need more information
<Phrogz> time cube! I think.
<andrewvos> Phrogz: What's that about?
<Phrogz> Thanks, andrewvos ;)
<manveru> ah, the classics
dabradley joined #ruby-lang
stamina joined #ruby-lang
<Phrogz> I feel like timecube.com used to be slightly more sane. Or at least use a smaller font size.
<MistyM> Timecube had the crazy giant font back in the 90s/early 2000s. I remember stumbling on it the first time.
<andrewvos> Phrogz: TL;DR
jimmy1980 joined #ruby-lang
<Phrogz> MistyM: OK then, perhaps my memory just downsized it to fit in my head, then.
<Phrogz> andrewvos: Don't you know that time is a simultaneous 4 corner square? Are you an eccentric caught in your ONEist single-corner knowledge, befuddled by the word illusion of failed education?
<drbrain> Phrogz: LOL
<andrewvos> Phrogz: I think my answer is yes, but not very sure :|
Aengus joined #ruby-lang
looopy joined #ruby-lang
Arsen7 joined #ruby-lang
<Phrogz> OK, sorry for the digression. Back to Ruby.
<andrewvos> Erm... good a place as any to ask. Any way Ican get my camera on my iphone visible on my mac?
<Phrogz> andrewvos: Like, tether via USB and have the iPhone camera act as a webcam?
<andrewvos> Phrogz: Yarp
<Phrogz> Good question; I don't know the answer, but would be interesting. (I have the opposite, app the streams the camera output from mac laptop onto iphone.)
QaDeS joined #ruby-lang
livinded joined #ruby-lang
<andrewvos> My family asked me to send a pic of my beard so I ended up trying to tether my phone to my mac and then using photo booth to make funny faces.
gix joined #ruby-lang
<mksm> I did not know timecube
<Asher> that's b/c you have been educated stupid
fenicks joined #ruby-lang
<Asher> :)
<fenicks> hello
<mksm> :D
Manhose_ joined #ruby-lang
nofxx joined #ruby-lang
butchanton joined #ruby-lang
flip_digits joined #ruby-lang
lightcap joined #ruby-lang
poga joined #ruby-lang
elijahc joined #ruby-lang
ivanoats joined #ruby-lang
workmad3 joined #ruby-lang
<elijahc> hey everbody! i've got a little puzzle i'm trying to solve and i haven't quiet been able to figure it out. does anyone have a second?
crankharder joined #ruby-lang
<elijahc> is there a better channel to ask?
<mksm> elijahc I grant you the power to ask
<elijahc> haha...thanks mksm.
<mksm> np
<elijahc> i need to generate an array that has 256 values, starting from 00 and ending in ff.
Axsuul joined #ruby-lang
<elijahc> they all need to be within the acceptable hex range, ie...the first character is 0, the last character is f
<drbrain> Array.new 256 do |i| i end
<drbrain> oops
havenn joined #ruby-lang
<drbrain> oh, no that's fine
Pupeno joined #ruby-lang
<elijahc> drbrain, i need to generate only these values: http://pastebin.com/WwzKdGnv
<drbrain> elijahc: you want a random array?
<drbrain> of integers or strings?
<drbrain> 0xff == 255
<elijahc> strings
<elijahc> not random, but comprehensive
<drbrain> look at #to_s
nuclearsandwich joined #ruby-lang
<drbrain> ordered?
<elijahc> none of the values in that pastebin URL can be excluded.
<elijahc> i don't care how the array is ordered
<dreinull> elijahc: Array.new 256 do |i| i.to_s(16) end
<elijahc> dreinull: that's really close, but it generates some single character values
headius joined #ruby-lang
<drbrain> elijahc: try String#% then
<drbrain> aka sprintf
<dreinull> elijahc: ok, i see
kyrylo joined #ruby-lang
<elijahc> hmm
lenilson_dias joined #ruby-lang
<elijahc> hey dreinull do you think i should take the resulting array from Array.new 256 do |i| i.to_s(16) end, and search for values that have only one character, and then prefix a 0 to those values?
<elijahc> or is there a more efficient way to do this?
<drbrain> elijahc: no, use sprintf
<drbrain> sprintf instead of to_i
<andrewvos> Not seen banisterfiend around lately.
<drbrain> andrewvos: I think I banned banister for posting porn
<drbrain> at least, the nick had a username that related to banister
hagabaka joined #ruby-lang
hagabaka joined #ruby-lang
<dreinull> elijahc: i'm trying to figure out how string#% works :)
<andrewvos> drbrain: wth?
<drbrain> andrewvos: yeah
<elijahc> me too! i figured out how to produce the exact same content as to_s, though
<elijahc> Array.new 256 do |i| sprintf("%x", i) end
<drbrain> elijahc: between % and x you can add two things
<drbrain> elijahc: a) the prefix digit for empty space (defaults to ' ')
<drbrain> elijahc: b) the number of spaces the output should consume
<drbrain> elijahc: hint: try "%2x"
<drbrain> (you can add more than that, but that irrelevant for your problem
<steveklabnik> "%x" % i
<steveklabnik> :D
<elijahc> looks like this does the trick
<elijahc> Array.new 256 do |i| sprintf("%02x", i) end
<drbrain> elijahc: :)
<dreinull> oh
<elijahc> thanks drbain and dreinull!
<elijahc> and steveklabnik
<dreinull> I got as far as Array.new 256 do |i| "%02x" % i.to_s(16) end
<drbrain> dreinull: yeah, you've got to trade to_i for sprintf since they both perform the same task
<dreinull> drbrain: I got a bit lost on the shorthand
<drbrain> dreinull: yeah, there's lots of options to get lost in
<dreinull> so Array.new 256 do |i| "%02x" % i end would have been fine.
<dreinull> but thats the method I have missed at least twice in the last four weeks or so.
<musl> elijahc: This is sortof tangential, but you could also specify a range: (0..256).map { |i| '%02x' % i }
<drbrain> musl: that creates two arrays, though
<lianj> and one item more
<elijahc> change the range from 0..255
<elijahc> i love how there's so many ways to skin a cat
<elijahc> thanks musl
outoftime joined #ruby-lang
<musl> lianj: thanks - should've used (0...256) or (0..255)
<elijahc> musl: what does three dots mean in ruby?
<lianj> drbrain: does times create 2 arrays too?
<musl> elijahc exclusive upper bound
<elijahc> versus inclusive. got it, thanks!
<drbrain> lianj: actually, I was wrong Range#map doesn't create an extra Array
<lianj> ah, nice
<drbrain> times doesn't create one either
<drbrain> my mind injected a #to_a into there for some reason
<lianj> hehe
perryh_ joined #ruby-lang
ndch joined #ruby-lang
ivanoats joined #ruby-lang
<musl> drbrain: I was worried that I missed something in the docs. :)
<drbrain> musl: no, it's just me
lightcap joined #ruby-lang
imperator joined #ruby-lang
reset joined #ruby-lang
amerine joined #ruby-lang
zenspider joined #ruby-lang
jasox joined #ruby-lang
cjs226 joined #ruby-lang
jimmy1980 joined #ruby-lang
woollyams joined #ruby-lang
Guest64586 joined #ruby-lang
jensn_ joined #ruby-lang
Carnage\ joined #ruby-lang
tomzx joined #ruby-lang
corsican joined #ruby-lang
<andrewvos> Has anyone looked at the capybara code? It's a bit scary.
<andrewvos> Well, intimidating.
<andrewvos> Not scary
<zenspider> scary
<steveklabnik> meh.
<steveklabnik> i havent found it to be toooo bad.
<steveklabnik> but i've only dived two or three times.
<andrewvos> I'm not one to complain though. I've been changing programming styles, and in the process producing the shittest code ever.
<steveklabnik> oh yeah? changing from what to what?
<andrewvos> steveklabnik: Mockist to classic
<steveklabnik> nooooooooooooooooooooooooooooo
<steveklabnik> :)
<andrewvos> haha why?
<zenspider> yay!
<steveklabnik> mocks are teh best.
<steveklabnik> what would programming be without teams? ;)
* zenspider grabs a sword and shield and faces off against steveklabnik
<steveklabnik> zenspider, you're the only person I know that has reasonably fast tests and doesnt' mock. you don't count.
<andrewvos> steveklabnik: Oh and also I've been naming classes like this: https://github.com/BBC/Wally/blob/master/lib/wally/parses_features.rb
<zenspider> me. drbrain. tenderlove. there are many in my clan
<steveklabnik> sure, yes, you three.
<tenderlove> I mock all the time. lol
<andrewvos> steveklabnik: I name any class with a responsibility by it's responsibility; unless it's a model. Model = noun
<steveklabnik> sure.
<zenspider> fine. barnette, bilkovich... and everyone else we've infected
<zenspider> tenderlove: different sort of mocking
<steveklabnik> hahaha.
<andrewvos> And the mixture of that and not mocking has caused mayhem.
<zenspider> almost all my classes are nouns across the board
kvs` joined #ruby-lang
<zenspider> it's one of my gripes against the lispy oo crowd... they don't understand the power of "noun verb"
<steveklabnik> yep.
<zenspider> (verb noun args) just doesn't work for me
<andrewvos> zenspider: I like this naming approach. When I ask "what does this class do" the answer comes in the name of the class.
jbsan joined #ruby-lang
<andrewvos> What is this class responsible for? It ParsesFeatures.
<andrewvos> etc.
<zenspider> that's gross
<zenspider> no_idea_what_to_call_this = ParsesFeatures.new
<steveklabnik> pf
<steveklabnik> ;)
<andrewvos> zenspider: Yeah I've been getting that a lot. But, try it a while and your world becomes a happier place :)
<andrewvos> zenspider: parses_features = ParsesFeatures.new?
<zenspider> verb.verb == meh
<zenspider> andrewvos: thanks, but no thank you
<andrewvos> When you name classes with nouns you often end up with a description of a class that's backwards.
<zenspider> no... YOU often do :P
<erikh> ugh
<andrewvos> hehehe
<erikh> BlowMartinFowler.new
<zenspider> haha
<andrewvos> harsh
<steveklabnik> ouch
<zenspider> come to think of it... I had my OO epiphany 20 years ago pretty close to the day... I think
<erikh> the great thing about experts is that there are so many of them, and they all disagree
<erikh> so you can take what you like from lots of them
<zenspider> and for 20 years... Nouns have worked well for me
<steveklabnik> an entire kingdom of nouns!
scottschecter joined #ruby-lang
<zenspider> andrewvos: why ParsesFeatures and not FeatureParser?
<zenspider> you're seriously fucking up one of the best things about ruby imhfo
<andrewvos> imhfo hahah
<zenspider> :P