<kalleth>
its new years day and i'm hungover and that code breaks my brain
<kalleth>
so i'd love to help but its more complicated than I can understand right now :p
<kalleth>
any reason why factor_count = {} has to be inside the .each block rather than witht he rest of the definitions?
<kalleth>
i'd probably move those out to constants outside the method bodies
thone_ has joined #ruby-lang
<kalleth>
sec
<kalleth>
let me see what my brain can do
thone has quit [Read error: No route to host]
<anannie>
kalleth: factor_count is over written each time a new number comes by
serhart has joined #ruby-lang
<kalleth>
ok
<anannie>
I think this could be solved elegantly with some recursion
<anannie>
but I'm not sure that would be idiomatic
<kalleth>
yeah, i'm first trying to simplify a bit whilst keeping the output the same so i can understand the problem better
<anannie>
It's the solution to Project Euler's problem #5
slyphon has quit [Ping timeout: 245 seconds]
<kalleth>
meh, i'm refactoring it a little bit and getting the same output but not sure if i'm handling all cases
<kalleth>
there's probably a reasony ou're using a while() rather than an each_with_index, right?
<anannie>
Yes there is as I'm checking the condition each time
<kalleth>
mmm, i get the same output without that check, but its probably just that its not getting triggered by the input data you've supplied
<kalleth>
https://gist.github.com/0ff10d9b5d5c97a7ed42 thats how far i got before i decided i need to read up on the project description and go in the shower to wake up, sorry I can't actually _help_ :(
<anannie>
That's okay kalleth
Peg-Leg has joined #ruby-lang
<kalleth>
you could also replace your factor_count = declaration with
holgerno has joined #ruby-lang
<kalleth>
factor_count = TOTAL_FACTOR_COUNT.dup
<kalleth>
rather than using the same details twice
<anannie>
Wouldn't that point to the same memory location?
<kalleth>
nope, as .dup creates a copy
<kalleth>
so factor_count = a new object that starts out as a duplicate of TOTAL_FACTOR_COUNT
<anannie>
Ah I see
nignaztic has quit [Quit: plz die k thx]
nazty has quit [Remote host closed the connection]
* bubonicpestilenc
looking for something like php's is_numeric
<bubonicpestilenc>
i'll re-write parser to scan for "numbers only" and auto-covert to Fixnums )
<cirwin>
bubonicpestilenc: you'll regret that :)
glebm has joined #ruby-lang
<bubonicpestilenc>
why?
<andrewvos>
bubonicpestilenc: Check for ^\d+$
<bubonicpestilenc>
regex will be slower
<andrewvos>
bubonicpestilenc: Do you care?
<cirwin>
bubonicpestilenc: a general pattern I've noticed with dynamic languages is that you always want the return type of a function to be determinable from the input type of a function
<cirwin>
if your parser takes a string and returns an array of strings, but sometimes an array of ints
<bubonicpestilenc>
i'm thinking about something like: d = d.to_i if d.to_i.to_s == d
<cirwin>
it's easy to introduce bugs
<bubonicpestilenc>
generally
<andrewvos>
generally
<cirwin>
yeah :)
<cirwin>
that said, rails gets away with it
<bubonicpestilenc>
my "parse" method takes 1 line of string with different # of field, separated by |
<cirwin>
so you can too :)
<andrewvos>
bubonicpestilenc: Use a csv parser?
* cirwin
crashes all your rails apps by putting ?id[]=1&id[]=2 in the url
<bubonicpestilenc>
ok, i'll explain deeply
<bubonicpestilenc>
we have...
<bubonicpestilenc>
packet from network with serialized "character" object
<bubonicpestilenc>
123|bubonic|23|1
holgerno has joined #ruby-lang
<bubonicpestilenc>
id|name|level|type
<andrewvos>
csv
holgerno has quit [Client Quit]
<cirwin>
def parse; id, text, foo, bar = line.split("|"); [id.to_i, text, foo.to_i, bar.to_i]; end
mistym has quit [Remote host closed the connection]
<bubonicpestilenc>
member:cirwin why not: id, name, level, type = data.split("|").map { |e| next e.to_i if e.to_i.to_s == e; e }
<bubonicpestilenc>
?
<cirwin>
bubonicpestilenc: because if someone puts a number in field 2
<cirwin>
it'll be a Number not a String
<cirwin>
and so if you try and do anything to it, you'll crash
<bubonicpestilenc>
oh, you're right
<bubonicpestilenc>
got it
<bubonicpestilenc>
if name == "123" then fail :)
<cirwin>
yeah
<andrewvos>
In more ways than one.
emocakes has quit [Quit: emocakes]
<bubonicpestilenc>
thanks guys :)
<andrewvos>
pleasure brohan
<andrewvos>
Whoa did not realise I can just use a normal wireless apple keyboard with the ipad!
srbaker has joined #ruby-lang
JoelMcCracken has joined #ruby-lang
richardburton has joined #ruby-lang
<andrewvos>
Sweet!
<andrewvos>
This is so much better than typing on that stupid screen!
havenn has joined #ruby-lang
davidbalber|away is now known as davidbalbert
Swimming_Bird has quit [Quit: ["Textual IRC Client: www.textualapp.com"]]
havenn has quit [Ping timeout: 255 seconds]
levifig has quit [Ping timeout: 260 seconds]
sailias has quit [Quit: Leaving.]
levifig has joined #ruby-lang
kurko_ has joined #ruby-lang
wallerdev has joined #ruby-lang
Rarrikins has quit [Ping timeout: 245 seconds]
Rarrikins has joined #ruby-lang
srbaker has quit [Quit: Computer has gone to sleep.]
<cirwin>
andrewvos: besides, you can then see the entire scren while typing
gaveen has quit [Ping timeout: 245 seconds]
meatballhat has joined #ruby-lang
meatballhat has joined #ruby-lang
meatballhat has quit [Changing host]
dvanduzer has joined #ruby-lang
richardburton has left #ruby-lang [#ruby-lang]
richardburton has joined #ruby-lang
gaveen has joined #ruby-lang
gaveen has quit [Changing host]
gaveen has joined #ruby-lang
drbrain has joined #ruby-lang
<andrewvos>
cirwin: CMD+TAB is a fail though.
drbrain has quit [Ping timeout: 255 seconds]
wallerdev has quit [Quit: wallerdev]
kith_ has joined #ruby-lang
kith has quit [Read error: Connection reset by peer]
kith_ is now known as kith
wallerdev has joined #ruby-lang
sepp2k has quit [Ping timeout: 260 seconds]
ebouchut_ has quit [Quit: This computer has gone to sleep]
ebouchut has joined #ruby-lang
wallerdev has quit [Quit: wallerdev]
srbaker has joined #ruby-lang
<dvanduzer>
I'm running two reasonably similar CentOS 6 VMs with rvm-installed ruby-1.9.3-p327. One calls futex / clock_gettime every few seconds, the other 10,000+ times a second: https://gist.github.com/45f592f979d4341bd5c5
<dvanduzer>
It's the resque component of a gitlab installation. The most likely culprit I've found is a leap second insertion issue, but my VM provider for the problematic host tells me they've reset the clock as per: https://lkml.org/lkml/2012/7/1/19
banisterfiend has joined #ruby-lang
<dvanduzer>
I found this discussion http://www.ruby-forum.com/topic/192255 which points out that this is expected behavior, and since I do see a futex timeout in both cases, it's clearly not just the timeout causing the problem. The futex timeout is clearly expected, just not 10k times a second. Other than clock / leap seconds, does anyone have any suggestions on how to proceed?
sepp2k has joined #ruby-lang
goshakkk has quit [Quit: Computer has gone to sleep.]
tbuehlmann has joined #ruby-lang
srbaker has quit [Quit: Computer has gone to sleep.]
srbaker has joined #ruby-lang
Rarrikins_h has joined #ruby-lang
srbaker has quit [Client Quit]
Rarrikins has quit [Ping timeout: 244 seconds]
srbaker has joined #ruby-lang
wallerdev has joined #ruby-lang
ebouchut has quit [Quit: This computer has gone to sleep]
Rarrikins_h has quit [Ping timeout: 240 seconds]
Rarrikins has joined #ruby-lang
karasawa has quit [Ping timeout: 265 seconds]
karasawa has joined #ruby-lang
anannie has quit [Changing host]
anannie has joined #ruby-lang
havenn has joined #ruby-lang
stonerfish has quit [Quit: Leaving.]
<yorickpeterse>
rking: pong
* rking
pong-redirects to zzak
<rking>
Bankshot!
* zzak
swish
<rking>
LOL
<yorickpeterse>
oh derp
<yorickpeterse>
zzak: so yeah, pong
<zzak>
i fubar'd your patch this morning
<zzak>
but thanks for that
<yorickpeterse>
I noticed it :)
goshakkk has joined #ruby-lang
<zzak>
there were a few style changes, but otherwise it was good to me
<yorickpeterse>
Thinking about it it's not just Hash#merge's docs that need to be fixed
<zzak>
style is less important
<zzak>
how so?
drbrain has joined #ruby-lang
<yorickpeterse>
I'm fairly certain there are more of these cases where the docs don't mention everything as clear
<yorickpeterse>
I however don't have the time at the moment to go through all that, might take a look at that this weekend
leopard_me has quit [Quit: Computer has gone to sleep.]
<zzak>
well, i agree with eregon, my first thought was "user doesnt care"
<zzak>
but i think more detail couldn't hurt and so i applied it not fully reviewing the implementation
<zzak>
it's my fault for not reading into it more, i guess i trusted you were right ;)
<yorickpeterse>
Well, the user does care since it leads to unexpected behaviour
<zzak>
its out of scope though
<yorickpeterse>
How so?
<zzak>
documentation is really geared towards the class
<zzak>
i tried to find an example of your behavior with another hash method, but i wasnt able to
drbrain has quit [Ping timeout: 245 seconds]
<zzak>
gotcha's and behaviour elements should go into a separate guide imo
<zzak>
maybe syntax
<yorickpeterse>
that makes zero sense
<yorickpeterse>
It only makes it harder for people to find those gotcha's
<yorickpeterse>
Even the line "This method creates a shallow copy" would be a lot better than not mentioning it at all
<yorickpeterse>
A veteran might understand it, and I do now as well, but newcomers most likely will have zero clue about it
<yorickpeterse>
Not to mention they probably can't be fucked finding "gotchas.md" or whatever file you'd put it in
<zzak>
why would a new person know what a shallow copy is? or even what it implies?
<yorickpeterse>
The term "shallow copy" might not be the clearest but I'm sure you understand what I'm getting at
<yorickpeterse>
At least, I hope
<yorickpeterse>
brb, idnner
<yorickpeterse>
* dinner
<zzak>
i understand your point, but my concern is adding all of this implementation specific doc to one method sort of takes it out of context where it is applied
cirwin1 has joined #ruby-lang
<zzak>
in most cases all the user needs to know is, "when i give it A, B, or C then i should get X, Y, or Z"
<zzak>
your example was including a method from an entirely separate class that had a side effect on the original argument
cirwin has quit [Ping timeout: 245 seconds]
<dvanduzer>
Any particular #ruby-lang specific question reposting etiquette? Wondering if anyone has any not-leap-second related suggestions for my 13,000 futex() calls per second problem.
meatballhat has quit [Ping timeout: 244 seconds]
<zzak>
yorickpeterse: at any rate, core docs, especially hash, string and array are tough and i think your on the right track. so please ignore my rambling and continue to submit patches :D
<lupine>
don't worry it's *fast* ^^
emocakes has joined #ruby-lang
mpan has joined #ruby-lang
<zzak>
oh, and copies vs. references: array uses +self+ all over the place and suffers from the same lack of context
<zzak>
like how many people will understand right away that +self+ means the original array argument
<zzak>
it's sort of confusing
karasawa has quit [Ping timeout: 255 seconds]
richardburton has quit [Quit: Leaving.]
richardburton has joined #ruby-lang
<yorickpeterse>
zzak: I wasn't planning on documenting the inner workings such as what algorithm Array#sort uses by default. I was more thinking of something short like "When you use method X you should keep Y in mind" or something along those lines
<yorickpeterse>
But I first have to spend some more time investigating the C code before I figure out a nice way of doing that
<zzak>
yorickpeterse: np, i love that you are helping
<zzak>
i am learning with you :)
richardburton has quit [Quit: Leaving.]
meatballhat has joined #ruby-lang
meatballhat has quit [Changing host]
meatballhat has joined #ruby-lang
<zzak>
yorickpeterse: like you can pass a block to merge
<zzak>
but there isn't any example for how it really works
<zzak>
and i think the description of the block is confusing
richardburton has joined #ruby-lang
meatballhat has quit [Ping timeout: 245 seconds]
tbuehlmann has quit [Ping timeout: 244 seconds]
cirwin1 is now known as cirwin
cirwin has quit [Changing host]
cirwin has joined #ruby-lang
srbaker has quit [Quit: Computer has gone to sleep.]