<asahi1>
I just ran some ruby and it was using 2 gigs of RAM, grinding my machine to a halt. how can I prevent this from happening?
<zenspider>
don't do that
<asahi1>
what would cause a ruby script to use a lot of ram?
shevy has joined #ruby-lang
<_tca>
probably by putting a lot of data in ram
<zenspider>
asahi1: you're asking such huge abstract questions that we can't possibly help you
<zenspider>
"a" * 2**3**4
<zenspider>
that must be what did it
<_tca>
gave me an error, liar
<asahi1>
I'm looping through data while performing calculations on it
<zenspider>
well there you go. if you don't loop or perform calculations, you won't have this problem
jfelchner has joined #ruby-lang
<zenspider>
see?
<zenspider>
we can't help with this line of questioning
<_tca>
how much data asahi1
<zenspider>
oh! I know. double your ram! then at least it won't grind to a halt
<zenspider>
asahi1: the best way to ask a question is to have a very specific question with enough data/context that we can understand ... using pastie.org and providing actual code would be a first step
<zenspider>
I'm an idiot... container = Hash.new 0
<zenspider>
it wasn't using a lot of memory
<zenspider>
it's just in need of improvement
<zenspider>
I assume this is railsy code
<asahi1>
yeah it is
nif has joined #ruby-lang
<zenspider>
you're pulling in all comments for a given category, and then asking for all the tags on each of the comments
<zenspider>
there are at least 3 things that can blow up there
<zenspider>
the tag.name values might be huge
<zenspider>
category.comments might be huge
<zenspider>
and comments.includes(:tags) might be huge
<zenspider>
I'm not even sure what that last one is
<_tca>
wpi;dm
<zenspider>
I thought you'd normally do something more like: category.comments :include => tags
<zenspider>
but again, that pulls in everything all at once
<asahi1>
nothing here is bigger than maybe 15bytes
<asahi1>
and my whole db is no bigger than 100mbs
<zenspider>
I'll bet you're wrong :)
<erikh>
just curious, are you on a mac?
<asahi1>
yes, I am
<erikh>
how far are you into swap?
<asahi1>
think it said 4gb of swap
<erikh>
not saying it's your problem, but it's probably significantly slowing you down.
<erikh>
esp. if you're doing database work.
<zenspider>
I'd look at the logfile to see how many times you're pulling from the db... I'd guess that you're doing it a lot more than you think you are.
<zenspider>
and that second line is still suspect to me
<erikh>
yeah, good idea. also check the slow query log if you're on mysql.
<asahi1>
zenspider: that second line is how rails does it. I'll try those other suggestions
<asahi1>
erikh: i'm on postgres
<asahi1>
thanks
<zenspider>
asahi1: it does it many ways. the one I gave above will pull the comments and tags in one fell swoop and you won't have an extra copy sitting around in a local variable for no reason
<zenspider>
also, for god's sake, use better variable names
<zenspider>
container and a SUCK as names
<zenspider>
also... can't you just do this via the count method?
<zenspider>
or sum
<erikh>
he's summing each tag as I read it
<asahi1>
.includes(:tags) does the same thing as :include => :tags. they both perform joins
<erikh>
but there's #max, and while I don't think arel can express the sql required, the sql for it is not particularly complicated.
<asahi1>
I don't see how I can do this with a simple counter method
<erikh>
select max(count(foo)) etc
<zenspider>
I would think that a group & sum would do this on the db side straight up
<erikh>
well he wants the top value
<erikh>
but yes, you're probably correct
<seanstickle>
count and order and first
petercooper has joined #ruby-lang
<erikh>
asahi1: regardless of which approach, the point here is to let the DB do the hard work.
<zenspider>
it doesn't need to work on all... it needs to work on his
<zenspider>
I hate that argument
<asahi1>
okay, got it. thank you for the suggestions. i'll try to get the db to do it
<seanstickle>
What argument? Unless you know if it works on his, it's a pretty iffy suggestion.
<zenspider>
it isn't remotely iffy as-is AND he uses postgres... nothing in that example is rocket surgery
<seanstickle>
Per the PostreSQL docs, "When GROUP BY is present, it is not valid for the SELECT list expressions to refer to ungrouped columns except within aggregate functions, since there would be more than one possible value to return for an ungrouped column."
<seanstickle>
Is all I'm saying
dv310p3r has joined #ruby-lang
<zenspider>
pedant much?
<seanstickle>
When it comes to database programming? Yes.
<zenspider>
yeah. well... have fun with that.
<seanstickle>
Dealt with too much shit left behind by code monkeys who think varchars are a good place to store numbers.
<zenspider>
which has absolutely no relevance to anything going on here...
<zenspider>
so take your emotional baggage elsewhere
<seanstickle>
Sloppy database programming?
<zenspider>
or actually help out.
<seanstickle>
Sounds the same to me.
<zenspider>
again... personal problem. move on. get therapy. something.
<erikh>
it has recursive queries too. this isn't that complicated.
igotnolegs has joined #ruby-lang
bryancp has joined #ruby-lang
<erikh>
and if you bust out recursive queries you probably know that already.
<zenspider>
UGH ruby has a fucking ugly grammar... this is going to be the death of me
<heftig>
what's not to like?
<zenspider>
sooo much
<zenspider>
current example is that there is now a lambda node... for no good reason.
<zenspider>
it's only created if you use -> , not lambda, not Proc.new, not proc...
<heftig>
for the stabby, i assume
<zenspider>
otherwise, it's mostly the same
<heftig>
stabby is ugly, i agree there
<zenspider>
and the block arg syntax / semantic changes are a bitch to deal with
SkramX has joined #ruby-lang
<zenspider>
the new optional arg syntax is semantically different from optional arg values...not sure how I should map that
tr-808 has joined #ruby-lang
m3nd3s has joined #ruby-lang
krzkrzkrz has joined #ruby-lang
fgomez has joined #ruby-lang
fgomez_ has joined #ruby-lang
Sailias has joined #ruby-lang
felipe__ has joined #ruby-lang
Joeysomo has joined #ruby-lang
publicvoid__ has joined #ruby-lang
fgomez has joined #ruby-lang
Z33K|Lux has joined #ruby-lang
jobicoppola has joined #ruby-lang
<slyphon>
argh
<slyphon>
fuck C
<slyphon>
fuck pthreads
* slyphon
overturns a table
<shevy>
hehehe
<drbrain>
slyphon: you mean:
* drbrain
(╯°□°)╯︵ ┻━┻
<slyphon>
:D
<_tca>
upvoted
<slyphon>
yes, yes i did
<slyphon>
argh, such a pain in the ass
<slyphon>
esp considering that ^C does *nothing*
tomzx has joined #ruby-lang
asahi1 has quit [#ruby-lang]
mistym has joined #ruby-lang
ilyam has joined #ruby-lang
mbriggs has joined #ruby-lang
ttilley has joined #ruby-lang
ttilley has joined #ruby-lang
gnufied1 has joined #ruby-lang
brianpWins has joined #ruby-lang
indeterminate has joined #ruby-lang
m10zart has joined #ruby-lang
fgomez has joined #ruby-lang
<m10zart>
how can i input utf-8 in a ruby program without it being modified? Like when I input "\n\u001C\u0018\t\u001C" it automatically converts it to "\\n\\u001C\\u0018\\t\\u001C"
<m10zart>
when i do gets.
<m10zart>
it works on the irb just fine. but not when i do it from running a .rb file
Weems has joined #ruby-lang
<drbrain>
m10zart: did you add the magic encoding comment?
<drbrain>
# coding: UTF-8 at the very top of your file (or after #! line)
rdavila has joined #ruby-lang
x0F has joined #ruby-lang
<m10zart>
ty ill look to see if it works. im a beginner in ruby. thank you
petercooper has joined #ruby-lang
<WillMars_>
What's the shortcut for converting an integer to something like 0004
<WillMars_>
4.to_something == "0004"
<drbrain>
WillMars_: sprintf
<drbrain>
ruby -e 'puts "%04d" % 4'
<WillMars_>
Cheers
<drbrain>
% is another way to sprintf
dankest has joined #ruby-lang
slaytani1 has joined #ruby-lang
dr0id has joined #ruby-lang
dr0id has joined #ruby-lang
<m10zart>
the magic encoding comment did not work. i know that my file can understand utf-8 encoded characters but for some reason, when I input a utf-8 format as a string to the program from the command line after doing ruby "filename", it reads it differently. "\n\u001C\u0018\t\u001C" to "\\n\\u001C\\u0018\\t\\u001C".
hagabaka has joined #ruby-lang
<bnagy>
it's probably just displaying \ as \\
<bnagy>
check the length of the string
<m10zart>
it reads it as a longer string
<m10zart>
or a longer utf-8 input for that matter.
<bnagy>
wait, you're typing that stuff in? You're probably feeding the program '\' 'n' not \n
<bnagy>
anyway, flight boarding, 'luck
dhruvasagar has joined #ruby-lang
achiu has joined #ruby-lang
mbriggs has joined #ruby-lang
t has joined #ruby-lang
Doobie has joined #ruby-lang
savage- has joined #ruby-lang
rippa has joined #ruby-lang
m10zart has quit [#ruby-lang]
ramonmaruko has joined #ruby-lang
ramonmaruko has joined #ruby-lang
Radium_ has joined #ruby-lang
ilyam has joined #ruby-lang
cdnz has joined #ruby-lang
jakko has joined #ruby-lang
dhruvasagar has joined #ruby-lang
asahi1 has joined #ruby-lang
asahi1 has quit [#ruby-lang]
fragmachine has joined #ruby-lang
<fragmachine>
Hey how can I use self in my class methods? For example if the Foo class bar method is 'puts self', how can I do "foo = Foo.new; "says this".foo.bar"
<fragmachine>
or even better "say this".bar
Radium_ has joined #ruby-lang
rohit has joined #ruby-lang
fattastic has joined #ruby-lang
tonesfrommars has joined #ruby-lang
jxie has joined #ruby-lang
mksm has joined #ruby-lang
TheMoonMaster has joined #ruby-lang
Rizzle has joined #ruby-lang
yxhuvud has joined #ruby-lang
rohit has joined #ruby-lang
JohnBat26 has joined #ruby-lang
kitallis has joined #ruby-lang
gouthamvel has joined #ruby-lang
gouthamvel has quit [#ruby-lang]
brushbox has joined #ruby-lang
rohit has joined #ruby-lang
Raul-Duke has joined #ruby-lang
<Raul-Duke>
hello
<Raul-Duke>
Есть тут кто живой?
achiu has joined #ruby-lang
fgomez has joined #ruby-lang
hahuang65 has joined #ruby-lang
deobald_ has joined #ruby-lang
x0F_ has joined #ruby-lang
apeiros_ has joined #ruby-lang
francisfish has joined #ruby-lang
andrewhl has joined #ruby-lang
solars has joined #ruby-lang
yibe has joined #ruby-lang
dhruvasagar has joined #ruby-lang
memonservices has joined #ruby-lang
IPGlider has joined #ruby-lang
apeiros_ has joined #ruby-lang
JackNorris has joined #ruby-lang
workmad3 has joined #ruby-lang
dc5ala has joined #ruby-lang
sandbags has joined #ruby-lang
sandbags has joined #ruby-lang
sandbags has joined #ruby-lang
dhruvasagar has joined #ruby-lang
achiu has joined #ruby-lang
ttilley has joined #ruby-lang
kings has joined #ruby-lang
<Defusal>
i wonder if anyone actually uses em-websocket
michael_mbp has joined #ruby-lang
<michael_mbp>
hi all
<michael_mbp>
I've got a SuperHero class that's including a module SuperPowers. #<SuperHero:0x007fdb8c96a838; @alias="Batman", @energy=100, @name="Bruce Wayne", @powers="powerless"> // how can I setup a class method in SuperPowers to deplete the energy of all SuperHeros? I've got SuperHero.die returning "foo" for now.
jstemmer has joined #ruby-lang
dhruvasagar has joined #ruby-lang
achiu has joined #ruby-lang
<drbrain>
michael_mbp: define #initialize in SuperPowers and have it register the superhero in a class-level list
<drbrain>
or, have ::new in SuperHero add each instance to a list and have SuperPowers use it
apeiros_ has joined #ruby-lang
<michael_mbp>
oh awesome one sec
<drbrain>
if it's only to harm superheros it seems like SuperHero is a better place for it than SuperPower
<drbrain>
especially if a SuperVillian has SuperPowers
<michael_mbp>
hah yeah I'm going that way :)
<michael_mbp>
thing is this
<michael_mbp>
what I'm having trouble seeing is how a class can store information, well until you suggested 'define #initialize in SuperPowers and have it register the superhero in a class-level list'
<michael_mbp>
I'm seeing it as only instantiated objects hold info via their attributes
<drbrain>
classes are instantiated objects too
<apeiros_>
drbrain: you take the whole magic out of it… :( ;-)
<michael_mbp>
hmm good point
Kero has joined #ruby-lang
<michael_mbp>
so I can setup attr_reader/writer on the class too and initialize it
<michael_mbp>
how does '::new in SuperHero' work ?
dhruvasagar has joined #ruby-lang
<drbrain>
you use super just like for instance methods
<michael_mbp>
ah
<drbrain>
class SuperHero; @super_heros = []; def self.new(*args, &block); super_hero = super; @super_heros << super_hero; super_hero end; end
<michael_mbp>
hmm
<michael_mbp>
so new is a class method in SuperHeros.
<michael_mbp>
I have to add attr_accessor for :super_heros
<apeiros_>
class << self; attr_reader :super_heroes; end
<michael_mbp>
ah of course
<michael_mbp>
I was adding it to instance objs.
nofxxx has joined #ruby-lang
toretore has joined #ruby-lang
<michael_mbp>
hmm.
<michael_mbp>
SuperHero.super_heros still getting ndefined method `super_heros' for SuperHero:Class
<anildigital_work>
How to know how much CPU % is being used from Ruby?
<anildigital_work>
and also memory
<michael_mbp>
top
<michael_mbp>
and filter the ruby processes
<andrewvos>
jodufry is a better name. Sorry judofyr
<ddfreyne>
I like judofry personally
<anildigital_work>
michael_mbp: filter?
<michael_mbp>
hit h
<michael_mbp>
and you can choose what attrubut
<michael_mbp>
*attributes you want to filter by
apeiros_ has joined #ruby-lang
<apeiros_>
yay, balloon hero @ railsberry
<apeiros_>
awesome :D
srbartlett has joined #ruby-lang
rohit has joined #ruby-lang
<judofyr>
andrewvos: I know, I know
<judofyr>
andrewvos: I was young and silly
mattyoho has joined #ruby-lang
mattyoho has joined #ruby-lang
m3nd3s has joined #ruby-lang
PhilCK has joined #ruby-lang
seanstickle has joined #ruby-lang
stu314 has joined #ruby-lang
flgr_ has joined #ruby-lang
dv310p3r has joined #ruby-lang
<stu314>
hi. ruby_1_9_3-r35412 segfaults once upon a time in one of the thread tests (bootstraptest/test_thread.rb): http://pastie.org/3822208 here is a backtrace: http://pastie.org/3822188 i can provide more information.
<darix>
stu314: 2 questions 1. it looks like it crashes in libc. 2. are you in low memory situations when it crashes?
<stu314>
darix: no, this is a 8 GB RAM desktop computer, so it has a lot of free memory. the system is NetBSD, amd64.
codewrangler has joined #ruby-lang
virunga has joined #ruby-lang
m10zart has joined #ruby-lang
jondot_ has joined #ruby-lang
<darix>
stu314: but as i said ... it could be a libc bug
<stu314>
darix: sure. i'll try to ask on a netbsd maillist. thanks.
<darix>
stu314: bt full might be interesting
<darix>
and if possible
tbuehlmann has joined #ruby-lang
<darix>
get the libc with debugsymbols or the debugsymbols for the libc
<darix>
so one can see the params for the calls in it
<stu314>
darix: i've compiled everything with "-g", is that not enough? (not sure)
morozovm has joined #ruby-lang
<darix>
see frames 0-2 and 5-6 in the backtrace
mattyoho has joined #ruby-lang
<darix>
the information in the () is missing
<darix>
unlike for the ruby parts
<stu314>
darix: ok, i'll try to do something about it.
jtoy has joined #ruby-lang
x0F_ has joined #ruby-lang
nofxxx has joined #ruby-lang
m10zart has joined #ruby-lang
mistym has joined #ruby-lang
<Ratyof>
Omfg.
dv310p3r has joined #ruby-lang
hynkle has joined #ruby-lang
PhilCK has joined #ruby-lang
gouthamvel has joined #ruby-lang
gouthamvel has quit [#ruby-lang]
sockmonk has joined #ruby-lang
jondot_ has joined #ruby-lang
<sockmonk>
are there any guides listing changes between ruby 1.9.2 and 1.9.3 that would force code changes? i.e., updated or removed syntax, that sort of thing?
<wwalker>
How to tell ruby to stop being stupid and use the FULL match that is there instead of a non-existent partial match it pulled out of a crack pipe?
<singpolyma>
::Etc
<wwalker>
I can use ::Etc.getpwnam('bar') but I shouldn't have to
<wwalker>
singpolyma: :-) thank you
zmack has joined #ruby-lang
<wwalker>
that indicates that in order to have deterministic calling of ruby class methods, one would have to Always use ::Foo::Bar.methodname
<singpolyma>
just not in the way you prefer in this case, that doesn't make it nondeterministic
mattyoho has joined #ruby-lang
<singpolyma>
you have to use :: when you live inside a module named the same as the module you're trying to reach
<TTilus>
wwalker: its just like paths
bryancp has joined #ruby-lang
<TTilus>
wwalker: absolute paths start with ::
<TTilus>
wwalker: otherwise they are relative
thone_ has joined #ruby-lang
ericmuyser has joined #ruby-lang
jbwiv has joined #ruby-lang
mark_locklear has joined #ruby-lang
<shevy>
hmm
<shevy>
anything that forces you to do require 'foo-etc' should be removed anyway simply because it includes a '-'
dejongge has joined #ruby-lang
jperry has joined #ruby-lang
michael_mp has joined #ruby-lang
futurechimp has joined #ruby-lang
michael_mbp has joined #ruby-lang
<wwalker>
TTilus: so it tries to fit in the current namespace, then each parent till it hits the top?
<wwalker>
Because I was in Foo::Bar::Bim namespace when I called Etc.getpwnam() and was told that Foo::Etc.getpwnam didn't exist
<sockmonk>
if so, then relative naming would be fragile. you might get away with just Foo::Bar at first, until a parent module added its own Foo, thus later forcing you to use ::Foo::Bar to get the right module
<wwalker>
sockmonk: that is my problem. Code in Foo::Bar::Bim called Etc.getpwnam. Later Foo::Etc was created, so now Etc.getpwnam fails :(
kvirani has joined #ruby-lang
bglusman has joined #ruby-lang
m10zart has joined #ruby-lang
rdavila has joined #ruby-lang
<sockmonk>
hmm. could use :: consistently and avoid relative class names altogether.
<sockmonk>
or (much worse probably), something like class Foo::Etc; def getpwnam; ::Etc.getpwnam; end; end
<shevy>
sounds like a fragile module
petercooper has joined #ruby-lang
IPGlider has joined #ruby-lang
replore_ has joined #ruby-lang
Radium has joined #ruby-lang
grin has joined #ruby-lang
_Andres has joined #ruby-lang
hagabaka has joined #ruby-lang
hagabaka has joined #ruby-lang
m3nd3s has joined #ruby-lang
cdnz has joined #ruby-lang
rdavila has joined #ruby-lang
alexkane has joined #ruby-lang
Psyche^ has joined #ruby-lang
Z33K|Lux has joined #ruby-lang
Rich_Morin_ has joined #ruby-lang
retro|cz has joined #ruby-lang
rippa has joined #ruby-lang
kiddorails has joined #ruby-lang
rolfb has joined #ruby-lang
jxie has joined #ruby-lang
<Rich_Morin_>
I've been wondering about ways to code in a more modern style than Google SketchUp's embedded 1.8.6 interpreter allows. backports might let me use some 1.9ish methods, but that doesn't address syntactic issues. Are there any projects to do 1.9.x->1.8.6 code translation?
macmartine has joined #ruby-lang
<shevy>
Rich_Morin_ hehehehe
<shevy>
for the most part there is not much syntax difference
<shevy>
but some people write in 1.9.x exclusively style
<shevy>
not quite sure why you need 1.9ish methods btw, if it is ruby code, it works in 1.8.6 unless it specifically uses things like foo: "bla"
<Rich_Morin_>
It's not that I _need_ 1.9ish methods, just that it's becoming annoying to have half of my Ruby development stuck in an old version.
andrewhl has joined #ruby-lang
butchanton has joined #ruby-lang
savage- has joined #ruby-lang
<shevy>
I am still on ruby 1.8.7 (2012-02-08 patchlevel 358) [x86_64-linux]
<shevy>
most of my code works on 1.9.x as-is too
<shevy>
save some annoying warnings
dejongge has joined #ruby-lang
rockpapergoat has joined #ruby-lang
<Rich_Morin_>
Yep; forward compatibility isn't much of a problem.
crackity_jones has joined #ruby-lang
t has joined #ruby-lang
robbyoconnor has joined #ruby-lang
r0bby has joined #ruby-lang
Mikoangelo has joined #ruby-lang
z3r00ld has joined #ruby-lang
guns has joined #ruby-lang
rippa has joined #ruby-lang
francisfish has joined #ruby-lang
brianpWins has joined #ruby-lang
judofyr has joined #ruby-lang
lchi has joined #ruby-lang
zmack has joined #ruby-lang
<wwalker>
shevy: which module? Foo::Bar::Bim should not be affected because Foo::Etc comes into existence I would understand if it was grabbing Foo::Bar::Bim::Etc, but not Foo:Etc
replor___ has joined #ruby-lang
<shevy>
wwalker that 'foo-etc' thing you are using
m3nd3s has joined #ruby-lang
Rich_Morin_ has quit [#ruby-lang]
Zolrath has joined #ruby-lang
divoxx has joined #ruby-lang
flgr_ has joined #ruby-lang
<singpolyma>
What's the best/popular Markdown library these days?
<andrewvos>
singpolyma: Use tilt
<singpolyma>
andrewvos: seems a bit heavy when I just need Markdown support, no?
<Mon_Ouie>
You can just use Kramdown
<singpolyma>
also, even if I use tilt, I have to choose a Markdown backend to install for it to use :)
mrsolo has joined #ruby-lang
fvollero has joined #ruby-lang
<andrewvos>
meh, go to the tilt page and you'll see all the markdown parsers
r0bby has joined #ruby-lang
<singpolyma>
Yeah, Kramdown looks pretty good
<singpolyma>
mostly, I'm using BlueCloth, but it sucks a bit
<ged>
singpolyma: How so?
<singpolyma>
ged: well, last I checked, it doesn't support 1.9 encodings at all
RegEchse has joined #ruby-lang
<singpolyma>
it just forgets what encoding the string had and the output gets set to binary
<drbrain>
anildigital: because you access @actors_array without a mutex
<anildigital>
drbrain: hmm..
<anildigital>
drbrain: isn't there any way to write threadsafe class without mutex?
<anildigital>
drbrain: is it because it's Singletone?
<drbrain>
you could use monitor instead of mutex
<judofyr>
hehe
<anildigital>
/s/Singletone/Singleton
<drbrain>
I meant mutex as short for "mutual exclusion"
<anildigital>
drbrain: :D
<anildigital>
I want to initialize some data at Rails startup .. so that my app can use it..
<anildigital>
is that right way to initialize data.. I had to use Singleton class...
<anildigital>
so that it returns me same data?
<anildigital>
but now my requirement is that this should be threadsafe too
hagabaka has joined #ruby-lang
hagabaka has joined #ruby-lang
<Defusal>
drbrain, thanks, i guess that could work
<drbrain>
anildigital: the Singleton in ruby provides thread-safe initialization but does not provide thread-safe access in instance variables in methods besides #initialize
<drbrain>
if you rename get_actors_array to initialize, fine
<drbrain>
Defusal: I'm only guessing
<anildigital>
drbrain: hmm.. initialize in Singleton?
<Defusal>
judofyr, hows fast is that?
<anildigital>
it's disabled right
<drbrain>
you should be sure to benchmark against File.read or reading a file in chunks
<drbrain>
anildigital: it will only be called once
<judofyr>
Defusal: dunno, but probably pretty fast
<anildigital>
drbrain: okay.. but how to read data back..
<mistym>
OK, I see where you're getting the error from.
<mistym>
So your Find.find is looping through every directory and file in E:\ and C:\, then copying to a temporary directory in C:\tmp. Right?
Ethan has joined #ruby-lang
<ridders24>
correct
<mistym>
So take a look at the cp_r error. What is it complaining about?
<mistym>
(PS - I see that you upgraded to Ruby 1.9. Good call!)
<ridders24>
thanks. its complaining about the block?
<mistym>
Do you know how to grok the stack trace?
raph_io has joined #ruby-lang
<ridders24>
I have no idea what that means
<mistym>
OK. Basically, an error message can be traced back through multiple layers of code, since code is typically made up of small pieces ("methods") calling each other.
srbaker has joined #ruby-lang
PhilCK has joined #ruby-lang
<mistym>
That's why there are multiple levels of errors - it's starting from the error itself, then tracing it back to each level at which it was called.
<mistym>
In this case, we want to focus on the very first line, which is the immediate error. It's an easy one to understand, so you don't need to trace it back to where you called it in your code to understand.
<mistym>
It tells you the type of error (ArgumentError), which lets you understand what *kind* of error it is; it provides a specific error message ("same file: C:/tmp/1010/LKRL-24-2 and C:/tmp/1010/LKRL-24-2"); and it tells you on what line of code the error occurred.
<mistym>
So. What this tells you is that there is something wrong with the argument you passed to cp_r - note what the error message is. Do you understand the problem?
<ridders24>
that would make sence as in this instance E and C are indentical regarding the files and dir
<mistym>
Even more so, actually - note the two filenames given.
<ridders24>
i was testing the copying and didnt bother to alter the dirs, but should it just overwrite the other one?
<ridders24>
ooo?! its found a C:/tmp/1010/LKRL-24-2?, ohh i know why
<ridders24>
becuase its going through C where the tmp dir is
<ridders24>
ahh ok
Muz has joined #ruby-lang
<ridders24>
i didnt think of that
<ridders24>
in practical use it wont be copying to the same dir as where it is
<mistym>
You should make sure to guard against that though!
<ridders24>
okay
<ridders24>
how?
gouthamvel has joined #ruby-lang
gouthamvel has quit [#ruby-lang]
Radium_ has joined #ruby-lang
<ridders24>
I still have the problem too, that its repeating some of the Dir's. So for example I have 1234/ABC-1-2 dir in the root of tmp, and then it repeats ABC-1-2 in tmp
<mistym>
ridders24: That's because Find.find iterates through every subdirectory and file!
lsegal has joined #ruby-lang
<ridders24>
mistym: what should i use instead?
<ridders24>
mistym: dir.glob ?
<mistym>
You have two options here: a) if there's only one place or a set of places files come from, you probably want something other than Find.find. b) If you do need to search anywhere, you should make sure Find stops looking deeper into a directory after you copy it.
<judofyr>
current status: str.gsub(%r|(</?)super(super)*textarea\b|, '\1\2textarea')
<drbrain>
ridders24: hint: Find.prune
<matti>
apeiros_: I not sure.
futurechimp has joined #ruby-lang
<matti>
apeiros_: I moved from Poland long time ago ;]
<matti>
s/I/I am/
<ridders24>
mistym: I doesnt like Find.prune instead of Find.find. I get an error.
<mistym>
ridders24: Find.prune is a method you should use inside the Find.find block.
<andkerosine>
Content-Length of 0 makes POST pretend to be GET?
fukushima has joined #ruby-lang
<drbrain>
andkerosine: per spec, I can't pipeline POST by default at all
<drbrain>
it doesn't matter if there's no content or not
datanoise has joined #ruby-lang
<andkerosine>
But that... does pipeline POST, no?
<drbrain>
andkerosine: no, each request will wait for a response before continuing with the next request
<andkerosine>
Ah.
nif has joined #ruby-lang
<drbrain>
pipeline is "make requests without waiting for responses" then "process responses as they come back"
Indian has joined #ruby-lang
<drbrain>
andkerosine: the spec says that POST may be pipelined if the client has proper knowledge of the application-specific behavior
dankest has joined #ruby-lang
fgomez has joined #ruby-lang
<andkerosine>
drbrain: Pipelining GETs that POST is probably frowned upon, huh?
<drbrain>
I don't understand
<drbrain>
GET is (should be) idempotent by default
<drbrain>
if you change server state based on a GET you're doing it wrong
<erikh>
some caching tools will ... not play well with that
<erikh>
also robots.
<drbrain>
robots clicking your GET links that change data caused data loss in rails apps some time back
<drbrain>
DHH wrote a blog post about how google was breaking stuff but got educated
<drbrain>
it was rails' fault, not google's
<judofyr>
drbrain: do you know how to use Racc?
<drbrain>
andkerosine: if can GET GET GET POST GET GET
<drbrain>
oops, "if you ..."
<andkerosine>
It's a GET, a POST, then 100 POSTS before starting again...
<drbrain>
andkerosine: net-http-pipeline does: GET GET GET, wait for responses, POST, wait for response, GET GET, wait for responses
<drbrain>
judofyr: it's like yacc or bison
<judofyr>
drbrain: I was thinking more in running the compiler etc.
postmodern has joined #ruby-lang
<judofyr>
I just setting basic things up
<judofyr>
and*
<drbrain>
judofyr: … ditto ☺
<drbrain>
judofyr: try race -v -l -o out.rb out.y
<drbrain>
oops, racc
<drbrain>
lunch time for me
<judofyr>
"If you have not use yacc, also racc is too difficult."
hynkle has joined #ruby-lang
Hakon|mbp has joined #ruby-lang
burgestrand1 has joined #ruby-lang
divoxx has joined #ruby-lang
<Harzilein>
*sigh*
<Harzilein>
is there any good rake example code for how to recursively make one directory from another one? (what i'm trying to do is make a doc directory for a collection of puppet modules)
<andkerosine>
Harzilein: Would Dir.entries + File.mkdir_p not suffice?
<Harzilein>
andkerosine: uhm, it's about adding puppetdoc tasks for the individual manifests after scanning the directory
<Harzilein>
andkerosine: and then depending on them
<Harzilein>
andkerosine: rake doc should depend on a generated file for every manifest
stu314 has quit [#ruby-lang]
<Harzilein>
andkerosine: currently i'm just unconditionally rebuilding all docs, that's not something i want in a make-like system :)
<drbrain>
dontbecold_: a problem I've run across personally is with using Net::SMTP
<drbrain>
dontbecold_: when you're delivering a mail if there's a Timeout you have to ditch the connection and create a new one
<drbrain>
dontbecold_: you can't trust that the timeout didn't corrupt the internal state of Net::SMTP
kish has joined #ruby-lang
<drbrain>
andrewhl: that final example is not a good example of a use of inject
<dontbecold_>
drbrain: Hmm, OK, what I'm trying to do is close a Socket object after a timeout of 5 minutes, would Timeout be OK for that?
<drbrain>
andrewhl: if you want to continue with it, start_from in the final example code is your clue
<drbrain>
dontbecold_: yes
<drbrain>
dontbecold_: since you're closing the socket upon timeout you won't be able to corrupt state
<drbrain>
dontbecold_: another option is to use IO.select to implement the timeout
<dontbecold_>
drbrain: that looks a tad complex, but I suppose it's better than having enough threads to knit a jumper with
<drbrain>
dontbecold_: but using #gets with IO.select may still cause you to block
<drbrain>
you'd need to do your own buffering to ensure you got to the newline
phlipper has joined #ruby-lang
kish has joined #ruby-lang
<andrewhl>
drbrain: the example uses integers, but i'm dealing with strings. Do I need to use a regex or something to indicate the start of the line? /^/ or something like that?
<dontbecold_>
drbrain: OK, thank you for the advice
<drbrain>
here's a skeleton for using IO.select: readers, = IO.select [io], nil, nil, 5; buffer << readers.first.read_nonblock
<freedrull>
ok i tried using GC::Profiler, and I'm pretty sure I have a 'memory leak'. I'm basically looping over some objects and the number of Total Objects to get larger and larger...is there any more detailed memory profiling available for 1.9 so I can figure out what is causing this?
<drbrain>
dontbecold_: often it's easier to start by using threads
replore has joined #ruby-lang
<drbrain>
andrewhl: if you're summing a list of numbers, what is a number you can start with that won't affect the total?
<andrewhl>
0...
<dontbecold_>
drbrain: OK, thank you
<drbrain>
andrewhl: if you're creating a string, what is a string you can start with that won't affect the result?
<dontbecold_>
phlipper: the same phlipper who works/worked for Appoxy?
<andrewhl>
but inject(0) gives me: String can't be coerced into fixnum