ChanServ changed the topic of #ruby-lang to: Ruby 1.9.3-p125: http://ruby-lang.org | Paste >3 lines of text on http://pastie.org or use a gist
<heftig> er
<heftig> that doesn't look like valid ruby
<heftig> shouldn't it be "redirect_to:" as well?
<heftig> notice missing colon
<tom___> redirect_to is a function call
<heftig> ah, right
<heftig> got confused for a moment
<drbrain> heftig: ruby is not Smalltalk ☹
charlenopires has joined #ruby-lang
phipes has joined #ruby-lang
Synthpixel has joined #ruby-lang
wallerdev has joined #ruby-lang
byronb has joined #ruby-lang
chendo_ has joined #ruby-lang
<Brainix> drbrain: Quick question, is Ruby Smalltalk? ;-)
<drbrain> Brainix: ruby is not Smalltalk ☹
<Brainix> drbrain: Cool, thanks. :-)
* Boohbah likes to put parenthesis around method calls for clarity
<Boohbah> *parentheses
<rue> Boohbah: There's a flipside to that
<Boohbah> rue: of course, sometimes eliminating them can improve clarity
tonesfrommars has joined #ruby-lang
<rue> When you add extra stuff, the next person will in some cases do a double take to see if there's something they missed that required it
Zolrath has joined #ruby-lang
<rue> Basically you're introducing the implication of ambiguity where there is none
slaytanic has joined #ruby-lang
shevy2 has joined #ruby-lang
MDmalLION has joined #ruby-lang
wmoxam has joined #ruby-lang
takaokouji has joined #ruby-lang
seanstickle has joined #ruby-lang
mistym has joined #ruby-lang
anykey has joined #ruby-lang
Sailias has joined #ruby-lang
dous_ has joined #ruby-lang
dous has joined #ruby-lang
curtism has joined #ruby-lang
jaisoares has joined #ruby-lang
jaisoares has quit [#ruby-lang]
rking has joined #ruby-lang
jondot has joined #ruby-lang
mistym has joined #ruby-lang
Banistergalaxy has joined #ruby-lang
charlenopires has joined #ruby-lang
takaokouji has joined #ruby-lang
kvirani has joined #ruby-lang
dous has joined #ruby-lang
charlenopires has joined #ruby-lang
mattyoho has joined #ruby-lang
Clordio has joined #ruby-lang
jmontross has quit [#ruby-lang]
macmartine has joined #ruby-lang
Radium has joined #ruby-lang
nif has joined #ruby-lang
fireglow has joined #ruby-lang
mistym has joined #ruby-lang
sodani has quit [#ruby-lang]
havenn has joined #ruby-lang
Teddy2steper has joined #ruby-lang
imperator2 has joined #ruby-lang
dv310p3r has joined #ruby-lang
William has joined #ruby-lang
Cong has joined #ruby-lang
Banistertab has joined #ruby-lang
rdavila has joined #ruby-lang
Teddy2steper has joined #ruby-lang
savage- has joined #ruby-lang
fgomez has joined #ruby-lang
Banistertab has joined #ruby-lang
crudson has quit [#ruby-lang]
gix has joined #ruby-lang
neoesque has joined #ruby-lang
neoesque has joined #ruby-lang
gsav has joined #ruby-lang
macmartine has joined #ruby-lang
savage- has joined #ruby-lang
mistym has joined #ruby-lang
hagabaka has joined #ruby-lang
hagabaka has joined #ruby-lang
rohit has joined #ruby-lang
kiddorails has joined #ruby-lang
dr0id has joined #ruby-lang
mortice has joined #ruby-lang
tylergillies has joined #ruby-lang
deobald has joined #ruby-lang
VGoff has joined #ruby-lang
t has joined #ruby-lang
SpitfireWP has joined #ruby-lang
Teddy2steper has joined #ruby-lang
gnufied has joined #ruby-lang
rippa has joined #ruby-lang
senthil has joined #ruby-lang
mcmSEA has joined #ruby-lang
<kiddorails> how do I unpack "\0x08" into it's decimal equivalent -> 8 ?
<lianj> "\x08".unpack("C")[0]
<kiddorails> lianj: but, isn't C directive for 8 bit
<kiddorails> ?
<lianj> 0x08 is 8 bit long
<lianj> one byte
<kiddorails> :) thanks
<phipes> why is ruby so ugly
<kiddorails> not related to ruby. But what does uint24_be size denote?
<drbrain> sounds like 24 bit unsigned integer in big-endian order
<kiddorails> drbrain: google gave me that too. That is 'endian' order which confuses me. Am I supposed to consider only next 24 bits?
<drbrain> it's which byte of the three is the big byte
<lianj> phipes: struct.unpack("B", "\x08")[0] nicer? :|
<kiddorails> drbrain: Please explain your last line once more..
<drbrain> kiddorails: look at the chart on the wiki page ^^
<kiddorails> drbrain: In the register value is 0A0B0C0D. Is this 8 bit long or 4 bit?
<lianj> looks like 4 bytes
<phipes> wait should i go to #ruby or stay here (#ruby-lang)
<drbrain> kiddorails: that's 32 bits
<kiddorails> drbrain: 32 bits? Oh. So for 4-bit BE, it is pairing 4 bits and by MSB storing it. ?
<drbrain> kiddorails: to unpack a uint24_be, you'll want to do this:
<drbrain> a, b = "\x01\x02\x03".unpack('nC'); result = (a << 8) | b
<drbrain> kiddorails: you don't know what the fourth byte is supposed to be for
<drbrain> kiddorails: do you have some documentation?
<kiddorails> yes, wait. http://osflash.org/flv
<kiddorails> I'm trying to extract MP3 out of flv.
<kiddorails> stucked in FLV Tag.
deobald has joined #ruby-lang
<kiddorails> From FLV Header, got the Signature, version, Flag(5)
<drbrain> kiddorails: ah
<kiddorails> then skipped 4 bytes for offset.
<kiddorails> and started searching for MP3 tag (8)
savage- has joined #ruby-lang
<drbrain> kiddorails: you need to read the right number of bytes
<drbrain> so, for uint8, 1 byte
<drbrain> for uint24_be, 3 bytes, etc.
<kiddorails> yes
<kiddorails> in FLV Tag, Type is obtained at some position -> 37.
<kiddorails> I am confused from here on. BodyLength.
<kiddorails> and Body (last in FLV Tag's list)
<kiddorails> the actual mp3 is combination of both these?
<kiddorails> oh oh. perhaps not.
<kiddorails> Mp3 is from byte[Bodylength]... EOF
<kiddorails> All I've to do now is to calculate BodyLength. drbrain, help me out. :)
<drbrain> use this: a, b = three_bytes_for_BodyLength.unpack('nC'); body_length = (a << 8) | b
<drbrain> you can also read 1 + 3 + 3 + 1 + 3 = 11 bytes and unpack in one go, with the extra fixups like ^^ for the uint24_be fields
<kiddorails> wait. I'm confused of what we are doing here. :(
<kiddorails> drbrain: Why are we getting 2 numbers from a, b = "\x01\x02\x03".unpack('nC'); ?
<drbrain> kiddorails: because there's no built-in pack format for reading a uint24_be
qawsedrf has joined #ruby-lang
<kiddorails> \x01 is __ bit? -> 8, right?
<qawsedrf> there is an instance method inside a module, how do you call that instance method ?
<drbrain> so we unpack an unsigned 16 bit big-endian int and an unsigned integer
<drbrain> qawsedrf: by including the module
<drbrain> kiddorails: yes, 8 bits
<kiddorails> so "\x01\x02\x03' is then total 24 bits. So, we are extracting 16 bit BE and 8 bit integer?
<kiddorails> Right?
<drbrain> right
<qawsedrf> is it mandatory to include insdie a class ? :/
<qawsedrf> w0rx thx
<qawsedrf> :D
<kiddorails> drbrain: and body_length = (a << 8) | b does convert it in complete 16 bit!
<kiddorails> drbrain: awesome.
<drbrain> qawsedrf: there are ways around it, but not easy ones
<drbrain> kiddorails: 24 bit
<kiddorails> what is a<<8 doing?
<drbrain> kiddorails: shift left 8 bits
<kiddorails> but, why is that required here?
<qawsedrf> also learnt about module_function :meth ;)
<drbrain> qawsedrf: oh, right!
<kiddorails> drbrain: shouldn't we instead have right shit 8 bits to b and then OR operation?
<drbrain> you need to make the number bigger, not smaller
<drbrain> try it in irb
<kiddorails> tried it as soon as you gave it. a, b = "\x01\x02\x03".unpack('nC'); result = (a << 8) | b
<kiddorails> => 66051
WillMarshall has joined #ruby-lang
<kiddorails> trying to understand.
<drbrain> then you can 66051.to_s 16 to check the work
<drbrain> also, a.to_s 16 and b.to_s 16
Swimming_Bird has joined #ruby-lang
<drbrain> also, | is as good as + here
Jade has joined #ruby-lang
wallerdev has joined #ruby-lang
nofxx has joined #ruby-lang
robgleeson|mba has joined #ruby-lang
<robgleeson|mba> has anyone wrote a Ruby DSL for the Dot language?
<robgleeson|mba> looked around on Google but so far turned up nothing.
<drbrain> robgleeson|mba: like graphviz?
<drbrain> robgleeson|mba: https://rubygems.org/gems/graph
<drbrain> robgleeson|mba: and http://www.confreaks.com/videos/673
<robgleeson|mba> thanks, i'll give it a shot.
ryanf has joined #ruby-lang
<kiddorails> drbrain: Hey. After encountering mp3 tag (8) in file. The next 3 bits which I'm encountering are => "\u0000\u0000\u0000" :(
<drbrain> kiddorails: you're reading with UTF-8 encoding, you need to use binary encoding
<lianj> its bytes not bits. also read the file as binary. like File.open(.., 'rb')
<kiddorails> drbrain: def utf_it(str)
<kiddorails> str.unpack('U*').join.to_i
<kiddorails> end
<robgleeson|mba> drbrain: hm… it doesn't pass "self" to a block if I don't want to instance_eval?
<kiddorails> since the value ares \u0000 , it will give me 0 only. :(
<drbrain> kiddorails: converting to UTF-8 seems wrong for reading bytes
gokul has joined #ruby-lang
<drbrain> UTF-8 aggregates bytes into characters
<kiddorails> lianj: Oh. Trying that.
<robgleeson|mba> drbrain: ah, sorry, it does.
<robgleeson|mba> digraph does.
<drbrain> ah
<kiddorails> The next 3 bytes after mp3 tag(8) giving 0
<kiddorails> Body_length. Y U NO COME?
kitallis has joined #ruby-lang
Asher1 has joined #ruby-lang
|Vargas| has joined #ruby-lang
Indian has joined #ruby-lang
Indian has joined #ruby-lang
<lianj> oO
Joeysomo has joined #ruby-lang
Asher has joined #ruby-lang
<robgleeson|mba> drbrain: do you use macports?
<drbrain> robgleeson|mba: I use brew now
<robgleeson|mba> ah. graphviz won't build on either for me. :(
kiesia has joined #ruby-lang
MDmalLION has joined #ruby-lang
<robgleeson|mba> thanks, installed :)
<robgleeson|mba> Error: foo.png.dot:3: syntax error near line 3
<robgleeson|mba> context: >>> # <<< <Class:Webmachine::Resource>#new -> Webmachine::Resource::Callbacks#service_available?;
<robgleeson|mba> looks like i got an error, though ^
<drbrain> robgleeson|mba: I can never find that page
kiddorails has joined #ruby-lang
<drbrain> that's odd
<drbrain> what's your dot file?
<robgleeson|mba> one sec
<drbrain> you'll probably need some quoting
<robgleeson|mba> shouldn't graph handle that though?
<drbrain> probably, but I also doubt anyone has tried to put #<Class:Foo> through it before, either
<drbrain> you can file an issue here: https://github.com/seattlerb/graph/issues
<kiddorails> drbrain: Tried taking sample of another flv. Same problem. Next 3 bytes after MP3 tag (which gives body_length) is \x00
<drbrain> kiddorails: did you try lianj's code above?
<kiddorails> I got disconnected. please to paste it
<robgleeson|mba> drbrain: .map(&:to_s) did it.
<robgleeson|mba> interesting graph too.
indeterminate has joined #ruby-lang
x0F_ has joined #ruby-lang
<kiddorails> lianj: Why {|f| f.read} ?
<kiddorails> in #3
<kiddorails> oh. Got it.
Slackwise has joined #ruby-lang
nofxx has joined #ruby-lang
nofxx has joined #ruby-lang
andrewhl has joined #ruby-lang
nofxx has joined #ruby-lang
nofxx has joined #ruby-lang
nofxx has joined #ruby-lang
Clordio has joined #ruby-lang
nofxx has joined #ruby-lang
senthil has joined #ruby-lang
nofxx has joined #ruby-lang
nofxx has joined #ruby-lang
nofxx has joined #ruby-lang
nofxx has joined #ruby-lang
datanoise has joined #ruby-lang
shtirlic has joined #ruby-lang
nofxx has joined #ruby-lang
wsirc_1873311 has joined #ruby-lang
<wsirc_1873311> Hi
nofxx has joined #ruby-lang
apeiros_ has joined #ruby-lang
io_syl has joined #ruby-lang
nofxx has joined #ruby-lang
<kiddorails> lianj: drbrain : Fantastic! Now finally, I understood how it was supposed to work. Thanks a ton.
<kiddorails> Now, only need to write :audio in file.
nofxx has joined #ruby-lang
sandbags has joined #ruby-lang
nofxx has joined #ruby-lang
JohnBat26 has joined #ruby-lang
<kiddorails> Will I have to study mp3 structure now to make mp3? :O
nofxx has joined #ruby-lang
nofxx has joined #ruby-lang
wsirc_1873311 has joined #ruby-lang
nofxx has joined #ruby-lang
<wsirc_1873311> Is this the correct way to use methods in case? Should this print 'yay'? http://pastie.org/3737488
<apeiros_> no
<apeiros_> case expression when condition --> this will execute condition === expression
<apeiros_> so in your case, it'll be `(x.type == String) === x`
<apeiros_> what you probably want is: case x; when String then …
WillMars_ has joined #ruby-lang
<apeiros_> as that will be `String === x`, and Class#===(other) checks whether other is an instance of the class.
<Mon_Ouie> And if you only have one condition like that you can just use if x.is_a? String
<apeiros_> also, type is pretty deprecated
<kiddorails> drbrain: You there?
nofxx has joined #ruby-lang
Joeysomo_ has joined #ruby-lang
<Mon_Ouie> That method doesn't even exist here
<rippa> did it exist?
<apeiros_> yes
<apeiros_> it got deprecated in 1.8
<apeiros_> and removed in 1.9
<lianj> kiddorails: why not `ffmpeg -i foo.flv foo.mp3` ?
<wsirc_1873311> Thanks apeiros_. I thought that would compare its value to String rather than its type.
<kiddorails> lianj: No. No. I don't have to opt that way. :/
<wsirc_1873311> And I'm using a program that uses Ruby, not Ruby itself. That's why I can use .type
<lianj> kiddorails: ?
<kiddorails> lianj: Your program from beginning to end, reads type, tags and body length etc continuously, right? When an mp3 tag is encountered, after reading it's body length, it again iterates to find other tags.
<kiddorails> lianj: I have to make it in ruby without using ffmpeg or external libraries. Kind of instruction given to me.
<apeiros_> wsirc_1873311: you mean, you use a program that uses a really old ruby, that's why you can still use .type. use .class instead.
<apeiros_> better in case they ever move on to a newer ruby
<lianj> kiddorails: ah ok. yes, the tags are chunks, there are many audio tags
<kiddorails> after searching for mp3 tag initially, if it again finds mp3 tag.
<lianj> kiddorails: well, if you take my code, so much for the 'i have to' ;)
<kiddorails> lianj: All credits to you. :) :)
<kiddorails> Hey. I'm beginner. That's how I'll learn, alright. ;) I never saw this efficient usee of unpacking.
<kiddorails> use*
<kiddorails> mp3 mp3 mp3! HOW
<lianj> there are no mp3 tags. its an audio tag, you have to look if the codec is mp3 (soundFormat == 2)
<lianj> if so, you maybe can join these bodies all together, and put a mp3 header in front
<wsirc_1873311> apeiros_:, I will.
nofxx has joined #ruby-lang
publicvoid has joined #ruby-lang
yxhuvud has joined #ruby-lang
<lianj> kiddorails: in my local example its 10 (acc codec) and not 2 (mp3) for example
<lianj> *aac
bjensen has joined #ruby-lang
bjensen has joined #ruby-lang
<kiddorails> so, adding a mp3 (2) header in front of a file and then streaming entire :audio in it, will manage to make it mp3?
<kiddorails> lianj: ^
<lianj> i guess many flvs today dont use mp3 though
<lianj> anyhow, that was fun. commits to junk git. good night
thrcka has joined #ruby-lang
kiddorails has joined #ruby-lang
<kiddorails> lianj: got disconnected. Looking http://paste.pocoo.org/show/9EbymjWTTAEDai5tSXxI/ :)
<lianj> 10:00 < lianj> i guess many flvs today dont use mp3 though
<lianj> and good night
<robgleeson|mba> drbrain: still here?
<kiddorails> lianj: |f| f.print your_mp3_header_here o.O
<kiddorails> that header still has to be decided
nofxx has joined #ruby-lang
<lianj> well duh, do it
rolfb has joined #ruby-lang
uniqanomaly has joined #ruby-lang
<kiddorails> lianj: audio_channels, audio_bits etc are first initialized inside the until loop. No way they can decide the value for test.mp3 which is being passed in very beginning. o.O
<lianj> think of one
kitallis has joined #ruby-lang
<kiddorails> default initial values?
Asher has joined #ruby-lang
gregf has joined #ruby-lang
kitallis has joined #ruby-lang
kitallis has joined #ruby-lang
futurechimp has joined #ruby-lang
MDmalLION has joined #ruby-lang
<Defusal_> >> Time.now - (Time.now - 0.0001) => 9.9267e-05
<Defusal_> >> Time.now - (Time.now - 0.000001) => -5.110000000000001e-07
<Defusal_> what would be the best way to round these kind of numbers to a readable float when displaying very short amounts of time?
<Defusal_> while #round(5) would work for the first example, the second would return -3.394e-06
<apeiros_> "%3.3g" % float
<Defusal_> ah i guess i can use string format
<apeiros_> round gives numbers, it's not meant for representations. strings are representations. to render a number to string, you have to_s and the printf-alikes
<Defusal_> apeiros_, not sure what g is, but that wont work for such small numbers
<Defusal_> %f works ok though
<apeiros_> you don't know what it is, yet you know it doesn't work… you're still having the same issue as last time…
<Defusal_> though it still goes to -0.000001
<Defusal_> apeiros_, i have never used %g before
<Defusal_> but clearly it does not work for this
<Defusal_> >> "%3.3g" % (Time.now - (Time.now - 0.0000000001)) => "-1.78e-06"
<Defusal_> >> "%3.3g" % (Time.now - (Time.now - 0.00001)) => "8.27e-06"
<apeiros_> maybe you should specify your requirements for "work"
<apeiros_> because this is both, readable & precise
<Defusal_> i said a readable float
<apeiros_> yes. this is a float.
<Defusal_> as in natural
<Defusal_> or whatever the correct terminology is
<apeiros_> then you can't have precision.
<Defusal_> i assumed you would understand from be trying to round to 5 decimal points
<apeiros_> don't assume. specify.
<Defusal_> if i wanted precision, i wound not be trying to round it in the first place
MDmalLION has joined #ruby-lang
<apeiros_> but yes, if you don't want scientific notation, use %.5f"
pbjorklund has joined #ruby-lang
<Defusal_> i could just display it as it is
<Defusal_> as i said, %f works
<apeiros_> Defusal_: you don't understand. if you use .5f, you're settling for a maximal precision of 5 digits. scientific notation has a much higher precision with the same amount of characters.
<Defusal_> apeiros_, i understand perfectly, i have been using string format since C
<apeiros_> …
nofxx has joined #ruby-lang
<Defusal_> but it still goes to negative, which im not sure how to correct
<Defusal_> but i guess its fine
<apeiros_> what's there to correct?
<apeiros_> if you have a negative number you have a negative number…
<apeiros_> if you expect only positive numbers, then maybe your methodology to get the number in the first place is broken
<apeiros_> (the one you pasted above sure is…)
<Defusal_> ok nevermind, i must just be testing with a too small float
<Defusal_> time wouldn't actually be split that finely
<apeiros_> sign and small-ness are quite a different thing
<apeiros_> a number doesn't become negative from being too small…
<Defusal_> it does the way i was testing, clearly
<apeiros_> oh…my… god…
<apeiros_> your method to get to the number is broken. clearly.
<apeiros_> as is your understanding of math.
<Defusal_> ok, let me clarify myself
<Defusal_> i created a negative number by testing incorrectly, it should work fine with actual amounts of time
kiddorails has joined #ruby-lang
z3r00ld has joined #ruby-lang
nofxx has joined #ruby-lang
kiddorails has joined #ruby-lang
batmanian has joined #ruby-lang
fragmachine has joined #ruby-lang
woollyams has joined #ruby-lang
<fragmachine> Is there a way to return an element from an array only if it contains all the digits in the search term? Eg array.return {|el| 'el includes 1 and 2 and 3 and 4'}
<fragmachine> => [1423, 1234, 4231] etc etc
<fragmachine> I always use include? but it's no good for this
ridders24 has joined #ruby-lang
<ridders24> hey guys
<ridders24> what grep expression could I use to find patterns like these: 6486-12-SR-1-1, XYZ-11, FD-01, and LKRL-100-1
<apeiros_> *
havenn has joined #ruby-lang
<rolfb> apeiros_: having a nice day?
<rolfb> :)
<apeiros_> I'm having a day full of people who fail to express what they want…
<apeiros_> what about you, rolfb?
<bnagy> rise above it, man, embrace MINASWAN
<rolfb> i'm mildy amused by you having a day full of people who fail to express what they want
<rolfb> :)
Guest18275 has joined #ruby-lang
<bnagy> ridders24: /[A-Z0-9-]+/ ? :>
d3vic3 has joined #ruby-lang
<rolfb> apeiros_: but it's really nice of you to help them regardless
<apeiros_> rolfb: now you make me feel bad :)
<rolfb> how so?
<rolfb> that's not my intent
<rolfb> :)
<bnagy> fragmachine: only way I can think of offhand is to treat the number as a string, it's a bit of a weird problem :S
<apeiros_> well, my last response wasn't meant to help directly (since that's impossible with such a badly phrased question), but to reveal the weakness of the question. then again, I think I was too lazy in its execution…
<apeiros_> should probably have been:
<apeiros_> ridders24: /.*/, matches all your patterns. want to amend your question? (e.g. by what it should not match?)
<apeiros_> ridders24: also, those are regular expressions, not grep expressions.
<bnagy> fragmachine: ["1268","1826"].grep /[1268]/ => ["1268", "1826"] might help/
<bnagy> ohwait it will fp sorry
<bnagy> but a better regex should work
<rippa> re in grep stands for 'Regular Expression"
<apeiros_> rippa: sure. it's still not a grep expression.
<rippa> I know
<rippa> just a bit of trivia
<apeiros_> :)
Jade has joined #ruby-lang
Jade has joined #ruby-lang
<rolfb> apeiros_: it liked the subtleness of the *
<rolfb> s/it/i/
nofxx has joined #ruby-lang
<apeiros_> I think the original grep didn't use pcre either (after all, it still doesn't, unless you ask it to)
<rolfb> oh great, my irc client actually supports s/ / /
<bnagy> so does skype </trivia>
<bnagy> that surprised the hell out of me
<apeiros_> srsly?
<apeiros_> hah, fun, must try that…
<rolfb> bnagy: works the same :)
<rippa> how does it support it?
Brendan_ has joined #ruby-lang
<bnagy> edits your kast message
<bnagy> *last
<apeiros_> just tried it
<apeiros_> amazing :)
<rolfb> i didn't expect it from my irc client though
<rippa> only you see it though
<rolfb> you guys saw the s/ / ?
<rippa> so what's the point
<rippa> yes
<rolfb> great
<rolfb> rippa: the feedback told me I had it right :P
<rolfb> that's always nice
<rolfb> in skype you can edit any previous message
<rolfb> by using the context menu on the text
<ridders24> bnagy: that works for me, I'm happy with that
esad has joined #ruby-lang
<bnagy> fragmachine: a=[1,2,6,8].join; ["1268","1826","29"].grep /^[#{a}]+$/ => ["1268", "1826"]
<bnagy> anchors ftw
<fragmachine> bnagy: that's awesome. How the heck does it work?
<apeiros_> bnagy: if all digits must occur, then that pattern won't help
nofxx has joined #ruby-lang
<bnagy> no, that's true
<fragmachine> oh yea all digits have to be in there
<apeiros_> fragmachine: exactly once?
<bnagy> ok I misunderstood, sry
<fragmachine> apeiros_: that would be best
<apeiros_> that's not a usable answer
<fragmachine> yes exactly once
<apeiros_> better :)
Gekz has joined #ruby-lang
Gekz has joined #ruby-lang
<apeiros_> that's hard with regexen
<fragmachine> yea my regex skills are pitiful
<apeiros_> your array, what does it contain? integers or strings?
<fragmachine> integers
Gekz has joined #ruby-lang
Gekz has joined #ruby-lang
<fragmachine> like [5309, 5347, 5381, 5387, 5407]
<fragmachine> all four digits
<apeiros_> project euler, I guess?
<fragmachine> you got it
<fragmachine> problem 49
<fragmachine> I've been addicted to that site for the last week
<apeiros_> a naive solution: a = %w[1 2 6 8]; pattern = a.sort; numbers.select { |num| num.split(//).sort == pattern }
<rippa> that's a fun site
<apeiros_> but I guess you'd be better off going at it from the other side.
<rippa> I'd use num.chars rather than split(//)
<fragmachine> maybe I should just convert the whole array into strings
<apeiros_> oh, num.to_s.(split/chars)
<apeiros_> forgot the to_s
<fragmachine> then string.split.sort?
<apeiros_> hrm, haven't moved my PE solutions to this computer yet, as it seems…
<apeiros_> yup, 49 is one I solved. I thought I knew it
<apeiros_> also, your exactly once requirement is wrong for this
<rippa> I somehow can't solve 67
<rippa> it seems to work, but the answer is wrong
<apeiros_> you want exactly the same number of times
<fragmachine> I haven't solved that either
<fragmachine> I've given up on it for the time being
<apeiros_> :)
<fragmachine> apeiros_: you can have lik '4457'?
<fragmachine> *like
<apeiros_> yes
<apeiros_> a prime doesn't need to consist of unique digits
<apeiros_> 997 is a prime
<fragmachine> that's true I just thought for some reason the answer would be unlikely to contain doubles
<apeiros_> it contains 9 twice
<bnagy> (my internets keep dropping)
<bnagy> here's a vile one
<apeiros_> btw., getting a list of all primes in 1..10_000_000 helped me quite a lot to solve PE questions quickly.
<bnagy> a=[1,2,6,8].permutation.map(&:join); [1268,1826,29,12268].map(&:to_s).select {|e| a.include? e} => ["1268", "1826"]
<fragmachine> apeiros_: that's a good idea
<fragmachine> I just found that permutation method as well
<apeiros_> getting the subset of primes in 1_000..9_999 is a trivial task then
<rippa> Primes.take_while {|p| p<10000000}
<apeiros_> so you've reduced your set of possible numbers greatly already
<rippa> *Prime
<apeiros_> rippa: back when I did, Prime was too f'ing slow for this.
<apeiros_> is it now up to the task?
<fragmachine> it's pretty quick
<apeiros_> (I used a sieve of erastothenes with some added trickery)
<fragmachine> Prime has sieve of erastothenes inbuilt
<bnagy> what trickery can you add?
<apeiros_> fragmachine: even if it takes only 1ms per number, that's still 10'000s for 1..1_000_000, and usually time required per number grows exponentially
<apeiros_> bnagy: the trickery was mostly related to limits imposed by ruby
<fragmachine> apeiros_: true true
<rippa> 1_000_000 takes about a second
<rippa> 10_000_000 is long
<apeiros_> rippa: ok, that's a shitload faster then back then
nofxx has joined #ruby-lang
<apeiros_> took seconds for 1000 iirc
<apeiros_> but maybe prime has a LUT for the first N numbers
<rolfb> uhm, anyone have the sign out url for project euler?
<rolfb> it got stuck
<rolfb> i probably need the edit account url too ... fragmachine?
<rolfb> apparantly it has a bug if you put an email in as username :)
<rolfb> renders it unable to send you a mail
<rolfb> i found the logout link
<rolfb> but it's not working since my account isn't validated
<rolfb> good going
<rippa> apeiros_: looks like it also caches results
<apeiros_> would be nice if it let you adjust the cache
<apeiros_> would also be nice if it'd allow to dump the cache and load it again
<rippa> huh
<rippa> I found out I can do, e.g.
<rippa> Prime.each(27, &method(:puts))
<apeiros_> &:display :-p
<apeiros_> oh, display doesn't add a newline
esad has joined #ruby-lang
<rippa> apeiros_: can't dup Fixnum
<apeiros_> ?
<apeiros_> what's that got to do with dumping & reloading?
<apeiros_> Marshal.load(Marshal.dump(Prime.each(100).to_a)) # => [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
<apeiros_> funny how many palindromes are already in the primes in 10..99
ddoucette has joined #ruby-lang
takaokouji has joined #ruby-lang
srbartlett has joined #ruby-lang
mssola has joined #ruby-lang
MDmalLION has joined #ruby-lang
<rippa> apeiros_: 1.display
SPYGAME has joined #ruby-lang
<apeiros_> rippa: I'm missing context
<rippa> [14:02:17] <rippa> Prime.each(27, &method(:puts))
<rippa> [14:02:35] <apeiros_> &:display :-p
<apeiros_> yes, I also said that display doesn't add a newline (by which I meant: therefore it's not suitable, ignore what I said)
<apeiros_> but I don't get the connection to `can't dup Fixnum`
<rippa> and i added that it doesn't work at all
<apeiros_> it does
<rippa> you can't use it on fixnums
<apeiros_> yes you can
<rippa> it doesn't here
<apeiros_> then something broke your ruby
<apeiros_> ruby-1.9.3-p0:039:0>> 1.display
<apeiros_> 1# => nil
<apeiros_> try ruby -e '1.display; puts'
<apeiros_> if that works, you've something stupid loaded in your irb
<apeiros_> or pry
<rippa> hmm
<rippa> strange stuff
<apeiros_> meh, I fail at coming up with proper VM primitives :(
<apeiros_> mission.abort
zmack_ has joined #ruby-lang
<rippa> I got it
<rippa> I know what stupid i did install
<rippa> windows
<rippa> Ruby193/lib/ruby/gems/1.9.1/gems/win32console-1.3.0-x86-mingw32/lib/Win32/Console/ANSI.rb:149:in `dup'
kaiwren has joined #ruby-lang
<apeiros_> clone, patch, pull-request
<apeiros_> :)
<apeiros_> also, windows? poor lad :-p
<bnagy> fragmachine: spoiler / headstart? http://pastie.org/3738049
<bnagy> the last bit is kind of easy to brute, but I'm trying to think of something pretty
<erikh> hrm. you guys want to help me out on how to structure.... structured warnings on ruby?
<erikh> I'm going to attempt to patch it in
futurechimp has joined #ruby-lang
<erikh> I was thinking of overloading $-w to accept an array of strings
rushed has quit [#ruby-lang]
<erikh> and each string would be a warning type or '-warning' for excluding warning types
<erikh> with a module called Warnings and library called 'warnings' that would drive the editing of that array
takaokouji has joined #ruby-lang
<erikh> so something like this (sec, gisting)
<apeiros_> erikh: my suggestion at warnings (probably not feasible/within the range of effort that you want): use the exception system. have 2 toplevel exceptions: Exception and Warning. add a keyword "resume". have the toplevel `rescue Warning => w; $stderr.puts w; resume; end`
<apeiros_> (resume would go back to the point the exception was raised and continue processing there)
<erikh> exceptions are not warnings :(
<erikh> I'm talking about doing this in C.
<erikh> as a patch to ruby.
<apeiros_> warnings are useless IMO. either enforce them or don't even emit them.
srbartlett has joined #ruby-lang
<erikh> actually in the third call "warn" would be called do_warn
<erikh> anyhow
morozovm has joined #ruby-lang
<bnagy> ah ok there we are
<kiddorails> lianj: http://pastebin.com/YRn4sX2P Seems like it never enters in "audio_encoding == 2" condition at all. :(
datanoise has joined #ruby-lang
kitallis has joined #ruby-lang
<erikh> apeiros_: right regarding emitting at least -- they're useful, but this is about scoping and controlling what you know will happen regardless
<erikh> I think I'm going to attempt this as a gem first.
<erikh> after I'm done with that, then port it as a patch.
morozovm has joined #ruby-lang
morozovm has joined #ruby-lang
<kiddorails> lianj: ?
kaiwren has joined #ruby-lang
andy_ has joined #ruby-lang
Guest18275 has joined #ruby-lang
<Guest57896> Hey does any one knows what is static VALUE in ruby source code, am kinda new to programming and was going through the source code
<Asher> VALUE is the type of a ruby object
<Asher> you should take a look at README.EXT if you are looking into the C side of things
<Guest57896> oh, k thnk u
<apeiros_> hm, seems both is valid in english, "filename" and "file name". what would you say is more common?
<bnagy> filename
|Vargas| has joined #ruby-lang
|Vargas| has joined #ruby-lang
morozovm has joined #ruby-lang
gokul has joined #ruby-lang
JohnBat26 has joined #ruby-lang
<kiddorails> drbrain: Please to help me out here: http://pastebin.com/YRn4sX2P Seems like it never enters in "audio_encoding == 2" condition at all.
<lianj> because your flv has no mp3 stream at all
<kiddorails> lianj: It does have mp3.
<kiddorails> And tested on multiple flvs in case.
<lianj> how do you know?
<kiddorails> lianj: So, you are suggesting that audio behind the flv is not mp3, but of some other extension (say wav etc)
<kiddorails> ?
<lianj> mplayer -frames 0 -identify test.flv 2>/dev/null|grep ID_AUDIO_CODEC
<kiddorails> ^ No output generated
<lianj> grep "audio codec" then, or you down have mplayer installed
<lianj> *dont
<kiddorails> mplayer -frames 0 -identify test.flv 2>/dev/null
<kiddorails> MPlayer SVN-r33713-4.6.1 (C) 2000-2011 MPlayer Team
<kiddorails> Playing test.flv.
<kiddorails> Exiting... (End of file)
<kiddorails> ID_EXIT=EOF
<lianj> is your file named test.flv?
<kiddorails> yes
<kiddorails> wait.
<kiddorails> sorry
morozovm has joined #ruby-lang
<kiddorails> ID_AUDIO_CODEC=ffaac
<lianj> see, its aac. like i guessed above. most flvs dont have mp3 as codec. so you cant take it out
rohit has joined #ruby-lang
<lianj> look at http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Flash.html AudioEncoding. they can be any of these types
<lianj> VideoEncoding 1 = JPEG is fun too :D
<kiddorails> So, now I need a sample flv which actually has mp3. :)
<lianj> right, but how useful would be your code then, if it only works with rare mp3 flvs
woollyams has joined #ruby-lang
<lianj> kiddorails: ffmpeg -i test.flv -vcodec copy -acodec libmp3lame test_mp3.flv; mplayer -frames 0 -identify test_mp3.flv 2>/dev/null|grep "audio codec"
<kiddorails> ffmpeg is bit cracked in my system. complains for libmp3lame package.
morozovm has joined #ruby-lang
<lianj> feels like chewing for you
dous has joined #ruby-lang
retro|cz has joined #ruby-lang
neoesque has joined #ruby-lang
gokul has joined #ruby-lang
gokulnath has joined #ruby-lang
codewrangler has joined #ruby-lang
Georg has joined #ruby-lang
Georg has quit [#ruby-lang]
JamesLavin has joined #ruby-lang
kaiwren has joined #ruby-lang
gokul has joined #ruby-lang
mattyoho has joined #ruby-lang
kitallis has joined #ruby-lang
Natch| has joined #ruby-lang
kvirani has joined #ruby-lang
msisk has joined #ruby-lang
wmoxam has joined #ruby-lang
justinxreese has joined #ruby-lang
datanoise has joined #ruby-lang
enebo has joined #ruby-lang
neoesque has joined #ruby-lang
MDmalLION has joined #ruby-lang
headius has joined #ruby-lang
gnufied has joined #ruby-lang
dejongge has joined #ruby-lang
slyphon has joined #ruby-lang
gsav has joined #ruby-lang
MDmalLION has joined #ruby-lang
rdavila has joined #ruby-lang
<shevy> kiddorails libmp3lame should be part of lame http://lame.sourceforge.net/
tbuehlmann has joined #ruby-lang
<matti> shevy: Uh. I read libemblame.
<matti> Time for new glasses.
<shevy> lol
<shevy> libblame would be cool too
<matti> :>
<shevy> "I blame matti for bad things."
slyphon has joined #ruby-lang
<matti> Eh, you too?
<matti> You sound like my parents.
<matti> ;d
imajes has joined #ruby-lang
rolfb has joined #ruby-lang
andrewhl has joined #ruby-lang
jtoy has joined #ruby-lang
esad has joined #ruby-lang
outoftime has joined #ruby-lang
<shevy> I know
<shevy> they told me about you :(
<shevy> but since that day I know you deserve the spanking
wmoxam has joined #ruby-lang
takaokouji has joined #ruby-lang
VegetableSpoon has joined #ruby-lang
RegEchse has joined #ruby-lang
Jade has joined #ruby-lang
thrcka has joined #ruby-lang
<imperator> rspec depends on diff-lcs? that's curious
rdavila has joined #ruby-lang
gokul has joined #ruby-lang
<imperator> are all the git libraries shell wrappers? isn't there a bonafide api to interface with?
<apeiros_> I thought grit read the git files directly for a couple of things
mistym has joined #ruby-lang
<apeiros_> *the git metadata files
<apeiros_> I doubt that there's a C level API for git
<heftig> there's not
dejongge has joined #ruby-lang
<imperator> no? surprising
<heftig> git is a whole bunch of different executables working together
<imperator> oic
<imperator> cpio does the same
<shevy> typical philosophy... tie together small things, until you have a skyscraper that is built by rice corns
<heftig> at its core, git is a content-based filesystem
<heftig> you actually can manipulate that directly and use it for other things than version control
jnimety has joined #ruby-lang
jperry has joined #ruby-lang
Tick-Tock has joined #ruby-lang
AlHafoudh has joined #ruby-lang
seanstickle has joined #ruby-lang
io_syl has joined #ruby-lang
<yorickpeterse> https://github.com/postmodern/spidr/blob/master/spidr.gemspec probably the worst Gemspec I've ever seen
dous has joined #ruby-lang
JamesLavin has quit [#ruby-lang]
<Mon_Ouie> It looks like it's just generic code to load it from YAML
<shevy> cool
<shevy> this should become a new standard :)
* apeiros_ thinks gemspecs should be split into gembuild & gemspec
<apeiros_> where gemspec is some static format, e.g. yaml
<apeiros_> it's bad that you have to run code (which may break) just to retrieve meta-data
Swimming_Bird has joined #ruby-lang
kiddorails has joined #ruby-lang
<apeiros_> hm, actually… the built gem contains a plain .yaml…
<apeiros_> why do bundler and other tools use the code gemspec then? o0
<yorickpeterse> You do realize you still have to run code to use the YAML data right? :)
<apeiros_> yorickpeterse: not the gemspec code, if that's what you mean
<yorickpeterse> It was a smart ass reply, you still have to parse the YAML data :)
<yorickpeterse> So there's no benefit over either one of them
<apeiros_> you fail
<apeiros_> of COURSE there's a benefit
<apeiros_> think again
<yorickpeterse> Such as?
<apeiros_> your worst gemspecs assumptions are not part of the yaml file
<apeiros_> such as git being present etc.
<apeiros_> you can't require or shell-out in yaml.
<yorickpeterse> That's not an advantage per se, merely a restriction
<apeiros_> sometimes I'm rendered speechless…
<yorickpeterse> Besides, when the format changes people will just come up with clever ways to work around it
<apeiros_> no, no, I give up. I'm not going to explain such a bloody obvious thing.
<yorickpeterse> Then don't :)
<yorickpeterse> Not wanting to depend on Git or w/e is something I can understand and up to a certain point agree with, however merely changing a file format isn't going to fix that
<yorickpeterse> People will write things to work around those issues (lol m4) and such
<yorickpeterse> So the statement "X instead of Ruby fixes the issue of Gemspecs depending on Y" is simply invalid
<imperator> is there any advantage to doing Process.waitpid2(fork{ exec cmd }) over system(cmd) ?
<yorickpeterse> Not really, they both block
<imperator> that's what i was thinking
macmartine has joined #ruby-lang
Sailias has joined #ruby-lang
<imperator> librarian gem does that, probelmatic for windows
<apeiros_> yorickpeterse: you do realize that yaml is not executable, yes?
<apeiros_> gah, what am I doing…
<yorickpeterse> Yes, I do, but like I said people will work around that
<yorickpeterse> Take for example fictional project A
<yorickpeterse> This project does not have a gemspec in the repo
<yorickpeterse> (e.g. Nokogiri)
<yorickpeterse> In this case it doesn't matter what format it will be in, it has to be generated and thus can still rely on some other obscure tools
<yorickpeterse> I do however agree that in the event of the gemspec already existing it *would* prevent it from happening
frangiz has joined #ruby-lang
<apeiros_> yorickpeterse: either you didn't read what I wrote or you misunderstood it completely.
<apeiros_> open a .gem file (it's just a tar), open the metadata.gz - that one is just a plain yaml.
<yorickpeterse> I'm well aware of that
<apeiros_> which is what I was asking for, and now I wonder why tools like bundler rely on the .gemspec (which has lots of potential to fail) instead of relying on that metadata file.
<yorickpeterse> Like I said I get the reasoning for wanting a different format, it's just not a benefit per se
<apeiros_> (which either is valid or invalid)
<apeiros_> if you think of going from executable to plain markup was just a format-change, then you don't get it.
<apeiros_> I'm wasting my time. I should not.
<yorickpeterse> Then just ignore me, I'm not forcing you to reply or anything :)
<yorickpeterse> Saying you don't want to waste time on it only to reply isn't going to really work out :)
mattyoho has joined #ruby-lang
Jake232 has joined #ruby-lang
wallerdev has joined #ruby-lang
seanstickle has joined #ruby-lang
Teddy2steper has joined #ruby-lang
<akahn> is there an array method for splitting the array into two arrays based on the result of a block?
<apeiros_> partition
lsegal has joined #ruby-lang
<apeiros_> @ akahn ^
<akahn> great, thanks apeiros_
<akahn> ah, on enumerable, of course. just out of curiosity would there be a way to split it into an arbitrary number of arrays based on the result of a block?
<apeiros_> chunk
<apeiros_> there was another one…
<apeiros_> slice_before
<akahn> neat! thanks
Indian has joined #ruby-lang
datanoise has joined #ruby-lang
mv has joined #ruby-lang
Radium has joined #ruby-lang
<Guest1583> Hi all. I have a strange behaviour with rails 3.1/ruby 1.9.3p125 : { 'x' => [1,2,3] }.to_json transforms the array into a hash. the problem does not exist with ruby 1.9.3p0.
<shevy> { 'x' => [1,2,3] }.to_json # => "{"x":[1,2,3]}"
<shevy> I get this on 1.8.7
<shevy> I am not sure what you mean with array into a hash
<shevy> because {} in ruby is a hash, right?
andrewhl has joined #ruby-lang
<Guest1583> shevy : I get the same output with 1.8;x. But with 1.9.3 I get the following : "{\"x\":{\"1\":null,\"2\":null,\"3\":null}}"
<shevy> hmm
<Guest1583> I mean 1.9.3p125
<shevy> looks funny
<mistym> Guest1583: Hm, on 1.9.3p125 I'm seeing the correct result. What json library are you using?
<Guest1583> mistym : json-1.6.6
savage- has joined #ruby-lang
MrPunkin has joined #ruby-lang
<MrPunkin> Trying to use gsub to escape ! so that it reads \\\! but when using the back reference syntax in the replacement string I can't prefix it with more slashes or else it no longer is a valid backreference
bjensen has joined #ruby-lang
frangiz has joined #ruby-lang
z3r00ld has joined #ruby-lang
<yorickpeterse> Guest1583: Did you by any change dump the string to the console?
<yorickpeterse> Because if so, that you're seeing is correct
<Guest1583> yorick : no, it's the output from rails console. And and the other end, the user brower does not see the incoming JSON as an array.
<yorickpeterse> Anybody in here used Celluloid? I wonder if it has advantages over EventMachine assuming the applications are written in a similar fashion
Chris__ has joined #ruby-lang
<yorickpeterse> Guest1583: that's what I meant
<yorickpeterse> That's correct behavior
<Guest1583> I just recreated a new rails project, and I get the correct behaviour with an empty Gemfile.
<yorickpeterse> #to_json() returns a string containing JSON. Due to this string being displayed as double quotes all double quotes in it are escaped
<yorickpeterse> That way it remains valid Ruby if you want to copy-paste it
<apeiros_> he's not complaining about that yorickpeterse
<robgleeson|mba> yorickpeterse: he's getting a totally different data type :p
<yorickpeterse> Guest1583: http://pastebin.com/Vv0CwqnB
<yorickpeterse> oh
<yorickpeterse> haha, I missed that
<Guest1583> yorick : what I mean as a problem is the { 1:null, 2:null, 3:null} hash instead of [1,2,3]
<yorickpeterse> woops
<yorickpeterse> Hm, that is odd indeed
<apeiros_> buggy to_json
<yorickpeterse> Does it work in vanilla Ruby?
<Guest1583> It works as expected with a new Rails project. so it's indeed related to an additional gem.
mrsolo has joined #ruby-lang
Hydrogen has joined #ruby-lang
<yorickpeterse> What does `1.to_json` result in?
butchanton has joined #ruby-lang
frangiz_ has joined #ruby-lang
<Guest1583> 1.to_json => "1"
<Guest1583> [1,2,3].to_json => "[1,2,3]"
<yorickpeterse> dafuq
<Guest1583> I'll review all the additional JSON-related gems the project uses. Thanks all for your help, it pointed me in the right direction :)
<Guest1583> take care.
<yorickpeterse> good luck
Teddy2steper has joined #ruby-lang
H2H has joined #ruby-lang
msisk_ has joined #ruby-lang
z3r00ld has quit [#ruby-lang]
curtism has joined #ruby-lang
curtism has joined #ruby-lang
Hydrogen has joined #ruby-lang
Radium has joined #ruby-lang
MDmalLION has joined #ruby-lang
krz has joined #ruby-lang
RORgasm has joined #ruby-lang
kyrylo has joined #ruby-lang
kyrylo has joined #ruby-lang
rippa has joined #ruby-lang
MrPunkin has quit [#ruby-lang]
hagabaka has joined #ruby-lang
hagabaka has joined #ruby-lang
kiddorails has joined #ruby-lang
m3nd3s has joined #ruby-lang
wdperson has joined #ruby-lang
geekfactor has joined #ruby-lang
geekfactor has joined #ruby-lang
Radium_ has joined #ruby-lang
savage-_ has joined #ruby-lang
slaytanic has joined #ruby-lang
benanne has joined #ruby-lang
nofxx has joined #ruby-lang
t_ has joined #ruby-lang
headius has joined #ruby-lang
nofxx has joined #ruby-lang
Nisstyre has joined #ruby-lang
curtism has quit ["Live Long and Prosper"]
nofxx has joined #ruby-lang
gnufied1 has joined #ruby-lang
Sailias has joined #ruby-lang
RORgasm has joined #ruby-lang
gregf has joined #ruby-lang
jasmim has joined #ruby-lang
jasmim has quit [#ruby-lang]
jtoy has joined #ruby-lang
bglusman has joined #ruby-lang
mssola has joined #ruby-lang
achiu has joined #ruby-lang
JohnBat26 has joined #ruby-lang
senj has joined #ruby-lang
justinxr_ has joined #ruby-lang
Axsuul has joined #ruby-lang
crudson has joined #ruby-lang
Karmaon has joined #ruby-lang
acuozzo has joined #ruby-lang
colinta has joined #ruby-lang
<colinta> is there a way to convert a proc into a (named) method?
<colinta> e.g. m = lambda {|x| puts x } ; self.bind(m, 'othername') ; self.othername "hi!" # => puts "hi!"
chessguy has joined #ruby-lang
headius has joined #ruby-lang
Karmaon has joined #ruby-lang
Clordio has joined #ruby-lang
slaytanic has joined #ruby-lang
<apeiros_> colinta: see define_method and define_singleton_method
<colinta> looking at those now... not clear that I can assign a block (e.g. define_method :othername, m)
<colinta> doesn't "just work" in irb, working in the top-level space, and
<colinta> class Object ; define_method :othername, m ; end
<TTilus> colinta: its define_method :othername, &m
<colinta> NameError: undefined local variable or method `dict' for Object:Class
<colinta> 'dict' is 'othername' in my example here
<colinta> NameError: undefined local variable or method `othername' for Object:Class # i mean
gorsuch has joined #ruby-lang
<TTilus> colinta: you need to tell define_method that m is the block param, thats what the & is for
nofxxx has joined #ruby-lang
fgomez has joined #ruby-lang
heftig has joined #ruby-lang
Boohbah has joined #ruby-lang
Weems has joined #ruby-lang
Weems has joined #ruby-lang
thrcka has joined #ruby-lang
achiu has joined #ruby-lang
deception_ has joined #ruby-lang
bjensen has joined #ruby-lang
heftig has joined #ruby-lang
Beryllium has joined #ruby-lang
deception_ has quit [#ruby-lang]
rolfb has joined #ruby-lang
divoxx has joined #ruby-lang
jstemmer has joined #ruby-lang
slyphon has joined #ruby-lang
msisk has joined #ruby-lang
Karmaon has joined #ruby-lang
postmodern has joined #ruby-lang
CoverSlide has joined #ruby-lang
<owen1> how to find the location of my gem? i can't figure out how to remove a gem...
<owen1> nevermind. fount it
<owen1> found
andrewhl has joined #ruby-lang
<drbrain> gem uninstall
<drbrain> ?
<shevy> owen1 look at directories like /usr/lib/ruby/gems/1.8/cache/ etc...
voker57 has joined #ruby-lang
<lianj> gem which rack
flgr has joined #ruby-lang
kiddorails has quit [#ruby-lang]
colinta has joined #ruby-lang
divoxx_ has joined #ruby-lang
<shevy> gem this rack
divoxx has joined #ruby-lang
Skif has joined #ruby-lang
bglusman has joined #ruby-lang
tonesfrommars has joined #ruby-lang
outoftime has joined #ruby-lang
morozovm has joined #ruby-lang
morozovm has quit [#ruby-lang]
jtoy has joined #ruby-lang
nif has joined #ruby-lang
colinta has quit [#ruby-lang]
Brainix has joined #ruby-lang
shachaf has joined #ruby-lang
rushanuk has joined #ruby-lang
<ironcamel> is there a way to gem install a certain version of a module?
<cschneid> "ABCDEF" => "AB BC DE F" is there an easy way to do that transform, .scan(/../).join(" ") almost works
<cschneid> but drops the last value, since it doesn't match ..
<apeiros_> ironcamel: you can't install modules, you can only install gems with gem
<ironcamel> nevermind, i figured it out
<apeiros_> and yes, see gem help install
<apeiros_> ok
<apeiros_> cschneid: gsub
<ironcamel> pretty straightforward
<apeiros_> gsub(/..(?=.)/, '\0 ')
<cschneid> zero width lookaheads?
<cschneid> tricky
<cschneid> :)
<cschneid> thanks
<Brainix> Hi, guys. I'm new to Ruby. When is it appropriate to use a class, and when is it appropriate to bundle a collection of methods in a module (or in nested modules)?
<canton7> is i just me, or do neither cschneid's or apeiros_'s methods produce the output which cschneid said he's expecting?
<cschneid> canton7: because I typoed my original
<cschneid> I just want spaces in between each 2 chars
<canton7> ah, type in the expected, of course
<cschneid> :)
<canton7> "AB
* apeiros_ became a master of expectation decryption on irc
<cschneid> hah, and it's friday afternoon, when I become an expert in typos
<apeiros_> but this one I actually simply missed :)
<canton7> * "ABCDEFG".scan(/..?/).join(' ') or "ABCDEFG".gsub(/..?/, '\0 ') both work for me
<apeiros_> gsub is one less method call!!!!!!1!1!
<cschneid> canton7: your gsub one leaves a floating space at the end
<cschneid> and my real problem has 4 per grouping, not 2. So the scan one with the ? operator is harder
<canton7> true, that. Also, .scan.join is quicker :P
<canton7> not by that much
<apeiros_> cschneid: well, just make the scan with {1,4}
<apeiros_> instead of ?
<apeiros_> quantifiers ftw!
<cschneid> hmm, I tried that first time, and it didn't work. Presumably because I screwed up
<canton7> that, or /..?.?.?/ :P
<canton7> ^^ messy
<apeiros_> …eeew
<cschneid> "ABCDEFG".scan(/.{1,4}/).join(' ')
<cschneid> => "ABCD EFG"
<cschneid> worked fine. I swear that's what I had originally
<apeiros_> heisenbug
<apeiros_> you looked to close at it!
<apeiros_> wait, or was that the schroedenbug? I think so…
<cschneid> dunno, but after squishing, the bug's velocity is 0
<canton7> heisenbugs are the ones that disappear the second you try and analyse them
<apeiros_> or only occur when you look for them
<apeiros_> cschneid: right, AND you know the bugs position!
<apeiros_> you solved heisenbergs problem!
* canton7 spent 2 weeks finding a race condition in a comms protocol between two micros
<canton7> precisely because of that damn bug type
<apeiros_> your debugging caused different timing, causing the bug to disappear, I assume?
gregf has joined #ruby-lang
<canton7> precisely
nif has joined #ruby-lang
slyphon has joined #ruby-lang
FiXato has joined #ruby-lang
nif has joined #ruby-lang
Rich_Morin_ has joined #ruby-lang
thone_ has joined #ruby-lang
nif_ has joined #ruby-lang
<Rich_Morin_> I'd like some help with an SSL error Mechanize is giving me - http://pastie.org/3741003
burgestrand has joined #ruby-lang
nif__ has joined #ruby-lang
y3llow has joined #ruby-lang
s0ber has joined #ruby-lang
<shevy> hey
<shevy> is this http://raa.ruby-lang.org/ dead?
<shevy> it lists things from 2011 in "new arrivals" :(
<apeiros_> raa is pretty much dead, yes
andrewhl has joined #ruby-lang
<apeiros_> or rather, became an archive/museum
y3llow has joined #ruby-lang
<shevy> hehe
jaisoares has joined #ruby-lang
<drbrain> Rich_Morin_: does mechanize.agent.http.reuse_ssl_sessions = false change anything?
<shevy> "museum of dead ruby code"
<shevy> ah well, one less entry on my link collection of ruby links then
<drbrain> Rich_Morin_: can you post a script I can use to reproduce?
y3llow has joined #ruby-lang
<Rich_Morin_> Let me try the suggestion - failing that, I'll try to produce a test script.
<drbrain> Rich_Morin_: it's my lunchtime, if you can create a ticket or paste into #seattle.rb I won't lose it
<Rich_Morin_> drbrain: I think I may not be using your suggestion properly -
<Rich_Morin_> @agent = Mechanize.new
<Rich_Morin_> @agent.http.reuse_ssl_sessions = false # per drbrain
<Rich_Morin_> undefined method `http' for #<Mechanize:0x1020366e8> (NoMethodError)
<apeiros_> Rich_Morin_: I'd say @agent.agent.http…
<apeiros_> (only guessing from what drbrain said - I haven't used mechanize)
<Rich_Morin_> seems to have resolved the issue - now I'll try disabling the cert code
<Rich_Morin_> tnx!
Brainix_ has joined #ruby-lang
rdavila has joined #ruby-lang
thrcka has joined #ruby-lang
burgestrand1 has joined #ruby-lang
gregf has joined #ruby-lang
uniqanomaly has joined #ruby-lang
mattyoho has joined #ruby-lang
babinho has joined #ruby-lang
Kero has joined #ruby-lang
H2H has joined #ruby-lang
philtr has joined #ruby-lang
philtr has quit [#ruby-lang]
rolfb has joined #ruby-lang
rolfb has joined #ruby-lang
Beryllium has joined #ruby-lang
Swimming_Bird has joined #ruby-lang
heftig has joined #ruby-lang
jammi has joined #ruby-lang
<ironcamel> i'm writing a bash script that needs to determine if a ruby gem is installed. what is the best way to do that?
<matled> ironcamel: I'd run ruby and try to require it. for example ruby -rfoobar -e 'exit 0'.
<ironcamel> matled: that doesn't seem to work. probably i am doing something wrong
<ironcamel> what is a gem that is for sure installed?
<lianj> not all gems have the same require name than their gem name
<ironcamel> ah
<lianj> gem list gives you a list of all installed gems
<matled> ruby -rrubygems -e 'exit 0' should always work if rubygems is installed
<ironcamel> that's the one i need to check
<ironcamel> matled: yeah, that worked
<ironcamel> for rubygems
<matled> depending on your ruby version you might have to setup your environment so that rubygems is actually required before you try to require your gem
<lianj> gem list | grep torpedo; is slow but works
<ironcamel> lianj: thanks
<ironcamel> that works
<matled> lianj: and error prone
<ironcamel> matled: what is a better way?
<lianj> matled: not more than -rfoo
<matled> lianj: well, I'll name a gem nuclear_torpedo
<lianj> then do something like grep "^name (" then
<ironcamel> matled: the problem is that -rtorpedo doesn't work for this gem
<matled> ironcamel: the script trying to use the gem will have problems too in this case
<matled> you could try -rrubygems -rtorpedo
<lianj> matled: gem names not always equel their require name
rue has joined #ruby-lang
rdavila has joined #ruby-lang
<matled> lianj: but typically you know the name to require
mistym has joined #ruby-lang
<drbrain> Rich_Morin_: can you give me the host you're connecting to?
<drbrain> the one that had the issue, I'd like to fix the problem properly
<Rich_Morin_> http://sketchup.google.com/3dwarehouse/ - but the specific page is probably past a login, etc.
<Rich_Morin_> I may be able to help if you need to contact someone in authority there.
<ironcamel> matled: the torpedo gem just installs a script, nothing then requires it
<lianj> ironcamel: ruby -rubygems -e 'Gem::Specification.find_by_name("rack")' 2> /dev/null
<erikh> openstack!
<erikh> I've been meaning to setup a little openstack cluster at home here.
<erikh> ironcamel: how do you like it so far?
<ironcamel> erikh: like what?
<erikh> openstack
<ironcamel> it's fine
<ironcamel> it's my job to work on it
<erikh> neat
<ironcamel> the community is python devs who are closed minded about anything not python
<ironcamel> that is what i don't like about it
<erikh> oh, that's not good
<drbrain> Rich_Morin_: the bug is (likely) on my side
<drbrain> Rich_Morin_: I'd need the HTTPS url you're hitting, since the error comes from an SSL connection
solars has joined #ruby-lang
<Rich_Morin_> sure - I'll put in a trace.
<drbrain> Rich_Morin_: just the host should be enough
streetlife has joined #ruby-lang
<streetlife> wach wach
crudson has quit [#ruby-lang]
streetlife has quit [#ruby-lang]
Skif has joined #ruby-lang
<Rich_Morin_> drbrain: izzis what you need? - http://pastie.org/3741003
jperry has joined #ruby-lang
<drbrain> Rich_Morin_: perfect!
<Rich_Morin_> cool
<drbrain> Rich_Morin_: I created an issue if you wanted to follow along: https://github.com/drbrain/net-http-persistent/issues/23
<Rich_Morin_> Cool. I'll keep my hacked-up version available in case you need any more traces, etc.
<Rich_Morin_> Feel free to email me at rdm@cfcl.com
<drbrain> Rich_Morin_: the easy way to log in mechanize is @agent.log = Logger.new $stderr
enebo has joined #ruby-lang
butchanton has joined #ruby-lang
rking has joined #ruby-lang
kiesia has joined #ruby-lang
mistym has joined #ruby-lang
RORgasm has joined #ruby-lang
fgomez has joined #ruby-lang
Karmaon has joined #ruby-lang
sheela1 has joined #ruby-lang
headius has joined #ruby-lang
countskm has joined #ruby-lang
fgomez has joined #ruby-lang
<countskm> just curious about naming conventions for class inheritance - I have a Host and then I have a LinuxHost - does that sound right to Append the Subtype to the beginning?
<countskm> LinuxHost < Host
<countskm> i guess whats bugging me is in an ls the related classes are not ordered - probably thinking about this too much :-)