<shevy>
but for usability, as a user giving feedback to a project, I just love github issues the most: https://github.com/pry/pry/issues
<shevy>
that was when I was thinking of something like integrating that into a whole ecosystem of ruby projects and inter-connecting them better
curtism [curtism!~curtis@bas11-montreal02-1128531121.dsl.bell.ca] has joined #ruby-lang
igotnolegs [igotnolegs!~igotnoleg@75-162-83-166.slkc.qwest.net] has joined #ruby-lang
cyri__ [cyri__!~cyri_@jem75-1-87-88-118-80.dsl.sta.abo.bbox.fr] has joined #ruby-lang
mikeric [mikeric!~mike@96.49.104.11] has joined #ruby-lang
fayimora [fayimora!~fayimora@109.175.187.154] has joined #ruby-lang
ndch [ndch!~ndch@c-69-181-107-222.hsd1.ca.comcast.net] has joined #ruby-lang
dous [dous!~dous@unaffiliated/dous] has joined #ruby-lang
wmoxam [wmoxam!~wmoxam@pdpc/supporter/active/wmoxam] has joined #ruby-lang
rdavila [rdavila!~rdavila@190.236.47.17] has joined #ruby-lang
dr0id [dr0id!~andy@unaffiliated/dr0id] has joined #ruby-lang
jxie_ [jxie_!~jxie@115.197.81.59] has joined #ruby-lang
srbartlett [srbartlett!~srbartlet@124-148-144-116.dyn.iinet.net.au] has joined #ruby-lang
x0F_ [x0F_!~x0F@unaffiliated/x0f] has joined #ruby-lang
cyri_ [cyri_!~cyri_@jem75-1-87-88-118-80.dsl.sta.abo.bbox.fr] has joined #ruby-lang
skinnymuch [skinnymuch!~skinnymuc@c-68-36-123-133.hsd1.nj.comcast.net] has joined #ruby-lang
Defusal [Defusal!DeFi@dsl-240-236-177.telkomadsl.co.za] has joined #ruby-lang
Defusal [Defusal!DeFi@unaffiliated/ecnerifed] has joined #ruby-lang
niklasb [niklasb!~codeslay0@p5B310C95.dip0.t-ipconnect.de] has joined #ruby-lang
skinnymuch [skinnymuch!~skinnymuc@c-68-36-123-133.hsd1.nj.comcast.net] has quit [#ruby-lang]
artOfWar [artOfWar!~artofwar@108.205.201.30] has joined #ruby-lang
Rakko [Rakko!~rakko@96-42-31-132.dhcp.mdsn.wi.charter.com] has joined #ruby-lang
cyri_ [cyri_!~cyri_@jem75-1-87-88-118-80.dsl.sta.abo.bbox.fr] has joined #ruby-lang
looopy [looopy!~looopy@pool-141-156-51-14.washdc.btas.verizon.net] has joined #ruby-lang
looopy_ [looopy_!~looopy@c-68-34-92-100.hsd1.md.comcast.net] has joined #ruby-lang
savage- [savage-!~savage-@c-67-180-11-89.hsd1.ca.comcast.net] has joined #ruby-lang
AndChat| [AndChat|!~AndChat@222.153.223.43] has joined #ruby-lang
twittard [twittard!~twittard@cpe-76-169-74-39.socal.res.rr.com] has joined #ruby-lang
JosephRuby [JosephRuby!~joseph@46.33.39.19] has joined #ruby-lang
headius [headius!~headius@71-210-151-185.mpls.qwest.net] has joined #ruby-lang
jasox [jasox!~jasox@178.239.26.139] has joined #ruby-lang
<shevy>
hmm
<shevy>
is there an
<shevy>
array.include_any? 'foo','bar'
<shevy>
I am kind of trying a ...
<shevy>
if ! array.include? 'write' and ! array.include? 'bla'
<wmoxam>
array.any? {|s| %w{ write bla }.include?(s) }
<robgleeson>
if array.none? { |e| e == 5 || e == 6 }
<robgleeson>
if you want to keep it simple, and avoid !.
<robgleeson>
use && :)
<wmoxam>
I like that better :D
<shevy>
.none? exists really?
<robgleeson>
yup
<shevy>
whoa
<shevy>
cool :)
<shevy>
not sure yet what I'll use... any? or none? ... but I sure dont want to use multiple ! and "and"
<shevy>
hehe
jxie [jxie!~jxie@115.197.88.225] has joined #ruby-lang
<robgleeson>
maybe this is the most simple to comprehend: [1,2,3,6].none? { |e| [4,5].include?(e) }
<shevy>
it's odd for me right now, I did not see .none? before
neoesque [neoesque!~neoesque@210.59.147.226] has joined #ruby-lang
<robgleeson>
I can't wait for the store to open...
<shevy>
I really should have found ruby earlier
<shevy>
and then looked when Enumerable came to live
jxie [jxie!~jxie@115.198.175.95] has joined #ruby-lang
takaokou_ [takaokou_!~takaokouj@220.110.223.220] has joined #ruby-lang
terrence [terrence!~terrence@123.234.184.170] has joined #ruby-lang
Banistergalaxy [Banistergalaxy!~AndChat@222.153.223.44] has joined #ruby-lang
slyphon [slyphon!~weechat@unaffiliated/slyphon] has joined #ruby-lang
srbaker [srbaker!~srbaker@184.66.82.213] has joined #ruby-lang
vmatiyko [vmatiyko!~vmatiyko@178.121.196.169] has joined #ruby-lang
vmatiyko [vmatiyko!~vmatiyko@178.121.196.169] has quit [#ruby-lang]
Banistergalaxy [Banistergalaxy!~AndChat@222.153.223.43] has joined #ruby-lang
r0bby [r0bby!~wakawaka@guifications/user/r0bby] has joined #ruby-lang
jmeeuwen_ [jmeeuwen_!~kanarip@white.kolabsys.com] has joined #ruby-lang
wasnotrice [wasnotrice!~wasnotric@174-143-152-175.static.cloud-ips.com] has joined #ruby-lang
ahs3- [ahs3-!~ahs3-@adsl-065-005-193-158.sip.rdu.bellsouth.net] has joined #ruby-lang
threedaymonk [threedaymonk!~threedaym@surimi.vm.bytemark.co.uk] has joined #ruby-lang
rtl [rtl!~rtl@monothorpe.com] has joined #ruby-lang
<necromancer>
would xmpp4r be okay to use with eventmachine?
<necromancer>
i know some gems use blocking which defeats the purpose of EM
<necromancer>
but uh...that's about as far as i know :-)
Carmivore [Carmivore!~carmivmor@ec2-174-129-124-31.compute-1.amazonaws.com] has joined #ruby-lang
gnufied [gnufied!~gnufied@122.172.246.117] has joined #ruby-lang
any-key [any-key!~eric_wood@tacs.cs.tamu.edu] has joined #ruby-lang
jayne [jayne!~jayne@freenode/staff/jayne] has joined #ruby-lang
twittard [twittard!~twittard@cpe-76-169-74-39.socal.res.rr.com] has joined #ruby-lang
headius [headius!~headius@71-210-151-185.mpls.qwest.net] has joined #ruby-lang
<twittard>
If I want to load a file and evaluate its contents, with the context of an instance, how do I do so and have the backtrace not suck? Just foo.instance_eval(File.read(filename), filename, 1) ??
<twittard>
It seems like I should just be able to do foo.instance_exec { load(filename) }
<twittard>
Is there a nicer shorthand?
<twittard>
SO LONELY
mdel [mdel!~mdel@pool-71-175-17-16.phlapa.fios.verizon.net] has joined #ruby-lang
<twittard>
I'm sure the likes of zenspider know. Hum.
jasox [jasox!~jasox@178.239.26.139] has joined #ruby-lang
<gnufied>
twittard: usually it is a bad idea
<twittard>
gnufied: what is?
<gnufied>
evaluating content of files like that.
<twittard>
gnufied: How should you evaluate a file that is, start to finish, a DSL?
<gnufied>
also instance_eval does take two additional parameters, __FILE__, __LINE__+1
<twittard>
Or, rather -- uses a DSL
<twittard>
Right
<gnufied>
well, you require the file.
<gnufied>
or load it.
<twittard>
I just wish there was a nicer way to evaluate something within a context
<gnufied>
why you want to instance_eval it?
<twittard>
gnufied: But you have to define the DSL within the Global namespace
<twittard>
If you do that
<twittard>
Right?
<twittard>
You can't load within the context of an instance, right?
<twittard>
I'd love it if you could -- and I may have misled myself.
<twittard>
Given how many DSLs are written in Ruby, it seems like that'd be a valuable addition to the core library.
thone [thone!~thone@g225086216.adsl.alicedsl.de] has joined #ruby-lang
<twittard>
So I know how to eval a file and set the positioning info.
<twittard>
I'm just curious if there's A Better Way
<twittard>
gnufied: For context, the backtrace info sucks balls for the etl library. I did a big re-write of portions of it, and am now starting to dive into other bits of refactoring.
<twittard>
One of them is to make the backtrace something other than "infuriating"
<twittard>
Simple goal -- But that led me to wonder if I've missed some part of ruby's internals
<gnufied>
I can imagine, how backtrace will suck if you are trying to load via eval
<twittard>
gnufied: I don't think the etl lib is setting the positioning info.
<gnufied>
even __FILE__, __LINE__ won't be of help
<twittard>
gnufied: So that's easy to solve. But again, just wondering if I there's a nicer way
<gnufied>
what is etl lib?
mikeric [mikeric!~mike@96.49.104.11] has joined #ruby-lang
<twittard>
Extract Transform Load.
nofxx_ [nofxx_!~nofxx@unaffiliated/nofxx] has joined #ruby-lang
<twittard>
I renamed ActiveWarehouse-ETL to ETL
<twittard>
aeden's library
<twittard>
ye olde
<twittard>
gnufied: So you're saying I need to pollute the global namespace and just load the files? lame.
<twittard>
Again, I'm just now attacking this problem seriously. So I haven't explored the nuances of file-evaling.
<gnufied>
hmm
<twittard>
I'm aware of the dangers of eval in general, etc.
<twittard>
I guess I'll screw around a bit more and fix the backtrace, then ask of there's A Better Way.
<twittard>
gnufied: Thanks for looking.
<gnufied>
well, you can get away by defining the methods that your DSL requires in main object and rest of the implementation can be encapsulated in classes.
<gnufied>
you will have to choose lesser of evils. but if I were you, I wouldn't bother with cleaning up backtrace and such hackery.
<gnufied>
for one, it will not work across various ruby implementations.
<twittard>
Which is what I knew to do. I just find the redundancy to be grating.
<robgleeson>
twittard: I wrote a library for that
<robgleeson>
twittard: it temporarily injects the calling scope
<robgleeson>
then removes the methods
<robgleeson>
and state
<robgleeson>
and all I learnt from that is that it is better to stay within the constraints of 'normal' Ruby :-P
<twittard>
robgleeson: You mean, load/require and knock it off with the DSL?
<twittard>
robgleeson: I mostly dislike DSLs that overreach, but I think the style of the ETL library is appropriate. I suppose the over-verbose eval'ing is a sound penalty.
<robgleeson>
twittard: my library? it would extend the calling scope with methods from a module (temporarily, for the duration of a block call) then when the block is done, it'd remove those methods (Module#remove_method).
<robgleeson>
twittard: so, after that experience, I'd say a "empty" Context class like you have is okay, _OR_, yield a parameter to the block & keep the calling scope.
<robgleeson>
I'd provide both options
<twittard>
robgleeson: ohhh, I get what you're saying. So, define the DSL in the global namespace, load a file, then undefine?
<robgleeson>
sometimes the calling scope is important to keep
<twittard>
oh wait I read it wrong
<robgleeson>
twittard: DSL belonged in its own module, I'd just extend the calling scope (binding.eval("self"))
<twittard>
ahhh
<twittard>
ok
<robgleeson>
but, for this project I had, it was super important to keep the calling scope, because you could say "share :variable_name" (in the DSL), then I'd need to look up the value of the variable via its binding
<robgleeson>
anyway yeah, it wasn't a good idea, I still use it for that one project but it had a lot of drawbacks (non-thread safe without #dup, #ancestors would be permanently dirty)
<twittard>
robgleeson: So why didn't you fall back to doing something like instance_eval, instead?
<twittard>
I'm just curious about the way you solved it / why you kept it that way :)
<twittard>
I've written DSLs, but haven't explored the "DSL in a file" much. So now I'm playing with some other bits of Ruby's internals.
<robgleeson>
the way I solve it and going forward, I provide two options: 1) instance_eval in a empty MyLib::Context class, or 2) yield 'self' as a block param.
<robgleeson>
i provide both options
<robgleeson>
for that project, it isn't possible (unless I yield, the beauty of the DSL would be totally lost)
<robgleeson>
https://github.com/robgleeson/barney <= the project, I need to have access to the 'shared variable', so I need to use binding#eval, and with instance_eval the binding would change.
<twittard>
in general, I stick with instance_eval / instance_exec. I believe instance_exec was backported to 1.8.
<twittard>
instance exec if a block was given.
<twittard>
ahhh ok
<twittard>
neat
<twittard>
:)
<robgleeson>
i definitely wouldn't do it unless I had to ;)
<twittard>
robgleeson: Oh cool, that DSL shares ruby objects between forks?
<robgleeson>
yep
<robgleeson>
and fork is 'extended' onto the calling scope
<robgleeson>
so when that Barney block exits
<robgleeson>
it goes to Kernel#fork
<robgleeson>
so kinda like a temporary monkey-patch
<robgleeson>
in the Barney block, it goes to Barney::Process#fork
<twittard>
And your library might be a neat addition
<twittard>
Mostly for fun. The ThreadPoolServer works fine.
<robgleeson>
not sure, I've only used Barney for toys
<twittard>
I guess I would just share a "die_kill_die" variable if I wanted to nuke the forks.
<twittard>
Hum
<twittard>
fun times :). Thanks for the info. Looks like a fun library to write.
<robgleeson>
ya it was fun
michael_mbp [michael_mbp!~Marin@203.189.189.65] has joined #ruby-lang
bintut [bintut!~bintut@cm61.sigma15.maxonline.com.sg] has joined #ruby-lang
gnufied [gnufied!~gnufied@122.172.246.117] has joined #ruby-lang
shevy [shevy!~shevy@93-82-80-58.adsl.highway.telekom.at] has joined #ruby-lang
guns [guns!~guns@c-98-228-72-208.hsd1.il.comcast.net] has joined #ruby-lang
jensn [jensn!~Jens@ip237-172.wireless.lu.se] has joined #ruby-lang
tla [tla!~tla@toelboell-lund.dk] has joined #ruby-lang
amerine [amerine!~mturner@bc171197.bendcable.com] has joined #ruby-lang
postmodern [postmodern!~postmoder@71.237.178.98] has joined #ruby-lang
<erikh>
shevy: bugzilla is at least customizable; we had a short form for requirements people
<erikh>
not to say it's perfect or anything -- it's quite far from that
<erikh>
but it was certainly flexible
Locke23rus [Locke23rus!~quassel@128-70-119-37.broadband.corbina.ru] has joined #ruby-lang
arthurlockhart [arthurlockhart!~cinch@60-242-128-8.static.tpgi.com.au] has joined #ruby-lang
AlHafoudh [AlHafoudh!~textual@dsl-static-173.212-5-200.telecom.sk] has joined #ruby-lang
michael_mbp [michael_mbp!~Marin@203.189.189.65] has joined #ruby-lang
cyri_ [cyri_!~cyri_@jem75-1-87-88-118-80.dsl.sta.abo.bbox.fr] has joined #ruby-lang
Carnage\ [Carnage\!~carnage@84-75-163-211.dclient.hispeed.ch] has joined #ruby-lang
adambeynon [adambeynon!~adambeyno@82-69-1-211.dsl.in-addr.zen.co.uk] has joined #ruby-lang
cyri__ [cyri__!~cyri_@jem75-1-87-88-118-80.dsl.sta.abo.bbox.fr] has joined #ruby-lang
tychobrailleur [tychobrailleur!~sebastien@176.61.72.130] has joined #ruby-lang
michael_mbp [michael_mbp!~Marin@203.189.189.65] has joined #ruby-lang
workmad3 [workmad3!~workmad3@cpc1-bagu10-2-0-cust81.1-3.cable.virginmedia.com] has joined #ruby-lang
vmatiyko [vmatiyko!~vmatiyko@178.121.196.169] has joined #ruby-lang
vmatiyko [vmatiyko!~vmatiyko@178.121.196.169] has quit [#ruby-lang]
michael_mbp [michael_mbp!~Marin@203.189.189.65] has joined #ruby-lang
tekin [tekin!~tekin@cpc8-with5-2-0-cust208.1-4.cable.virginmedia.com] has joined #ruby-lang
yxhuvud [yxhuvud!mongo@h-209-13.a212.priv.bahnhof.se] has joined #ruby-lang
thrcka [thrcka!~thrcka@ip-89-102-34-33.net.upcbroadband.cz] has joined #ruby-lang
thrcka_ [thrcka_!~thrcka@ip-89-102-34-33.net.upcbroadband.cz] has joined #ruby-lang
michael_mbp [michael_mbp!~Marin@203.189.189.65] has joined #ruby-lang
<Gekz>
how can I set attributes dynamically with datamapper on an object
<Gekz>
preferably with a hash
<Gekz>
it seems setting foo.attributes = {:my_field => "whatever"} doesnt actually set :my_field as expected
<Gekz>
as foo.save doesnt trigger a create
<Gekz>
other than "with default values"
krz [krz!~foobar@unaffiliated/krz] has joined #ruby-lang
<manveru>
Gekz: usually it's something like foo.update(my_field: "whatever")
<manveru>
well, in sequel at least ^^;
<Gekz>
I'm trying to do it programmatically, in the sense that I don't have the convenience of specifying the key AND the value
<manveru>
so?
<manveru>
i'm just passing an hash to update
<Gekz>
you're not passing a {} though
<Gekz>
is it equivalent?
<manveru>
>> p(foo: "bar")
<manveru>
{:foo=>"bar"}
<manveru>
see, hash :)
<Gekz>
so they are equivalent
<Gekz>
I overthought it
<Gekz>
damn you ruby
<manveru>
heh
<Gekz>
bah, it's still screwing with me
* Gekz
has a sadface
<Gekz>
datamapper is by far the most confusing ORM I've used, and I've used a few.
<manveru>
i only used it a bit a few years ago
<manveru>
since i used og in 2005-2006, it's been sequel all the time
<Gekz>
so it turns out it's not saving.
<Gekz>
and I can't work out how to debug why
<Gekz>
/opt/local/lib/ruby1.9/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/resource.rb:1196:in `assert_save_successful': Clasrip::SQL::Classification#save returned false, Clasrip::SQL::Classification was not saved (DataMapper::SaveFailureError)
<Gekz>
good output there.
<Gekz>
telling me there was an error
<Gekz>
it was a data length issue, oh lawd
lele [lele!~lele@fangorn.windmill.it] has joined #ruby-lang
uniqanomaly [uniqanomaly!~ua@dynamic-78-8-90-77.ssp.dialog.net.pl] has joined #ruby-lang
fayimora [fayimora!~fayimora@109.175.187.154] has joined #ruby-lang
davidw [davidw!~davidw@adsl-ull-196-118.51-151.net24.it] has joined #ruby-lang
tbuehlmann [tbuehlmann!~Tobias@unaffiliated/tovias] has joined #ruby-lang
jasox [jasox!~jasox@178.239.26.139] has joined #ruby-lang
Peg-Leg [Peg-Leg!Peg-Leg@79.119.191.226] has joined #ruby-lang
robotmay [robotmay!~robotmay@5ad8f1da.bb.sky.com] has joined #ruby-lang
nofxx_ [nofxx_!~nofxx@unaffiliated/nofxx] has joined #ruby-lang
yibe [yibe!~yibe@163.43.161.140] has joined #ruby-lang
ezkl` [ezkl`!~ezkl@dynamic-acs-24-144-206-131.zoominternet.net] has joined #ruby-lang
dejongge [dejongge!~jonke@pD9E0C9BF.dip0.t-ipconnect.de] has joined #ruby-lang
benanne [benanne!~rijdier@234.141-241-81.adsl-dyn.isp.belgacom.be] has joined #ruby-lang
tokumine [tokumine!~kunio@82-69-174-54.dsl.in-addr.zen.co.uk] has joined #ruby-lang
beiter [beiter!~beiter@manz-5f74bc35.pool.mediaWays.net] has joined #ruby-lang
RomD [RomD!~Roman@nrbg-4d070fe7.pool.mediaWays.net] has joined #ruby-lang
QaDeS [QaDeS!~mklaus@frbg-5f7338e7.pool.mediaWays.net] has joined #ruby-lang
enikar [enikar!~gil@cl-140.mrs-01.fr.sixxs.net] has joined #ruby-lang
sendnoflowers [sendnoflowers!~sendnoflo@redounding.playing.volia.net] has joined #ruby-lang
Keva161 [Keva161!~Keva161@78.32.156.143] has joined #ruby-lang
vmatiyko [vmatiyko!~vmatiyko@178.121.196.169] has joined #ruby-lang
vmatiyko [vmatiyko!~vmatiyko@178.121.196.169] has quit [#ruby-lang]
jsaak [jsaak!~jsaak@catv-89-134-200-70.catv.broadband.hu] has joined #ruby-lang
savage- [savage-!~savage-@c-67-180-11-89.hsd1.ca.comcast.net] has joined #ruby-lang
brainopia [brainopia!~brainopia@223.204.112.100] has joined #ruby-lang
fayimora [fayimora!~fayimora@95.175.159.12] has joined #ruby-lang
<brainopia>
hi, fork on linux with 1.9 creates two process one of which is intermediate (sh -c ruby) and fork returns pid of intermediate process - https://gist.github.com/34ae5c007ab43de960e2, am I correct in interpretation?
<brainopia>
hm, this intermediate process shows up only when fork+exec is used, not when they are by one
<brainopia>
i'm probably missing something obvious, so who will be my knight in shining armor and tell me what is it :)
<brainopia>
zenspider for sure knows the answer, but probably does not have time or don't want to help with such newb question? :)
<brainopia>
rue, raggi in the same company :)
<brainopia>
oh, whitequark - the man, you're surely read ruby sources for breakfast and know the answer too :)
<Mon_Ouie>
I only see one process when I try that here (Linux too)
<Mon_Ouie>
Which is what I'd expect
uniqanomaly [uniqanomaly!~ua@dynamic-78-8-82-48.ssp.dialog.net.pl] has joined #ruby-lang
<brainopia>
yeah, I was expecting it too
<brainopia>
but foreman wasn't picking up correct processes to kill, so I've tried and found this anomaly
<brainopia>
the fun part is exec'ed ruby process also reports the value of intermediate process as PID, even though killing it does not force actual ruby process to be killed :(
<enikar>
i think that the other process is a ruby thread...
workmad3 [workmad3!~workmad3@cpc1-bagu10-2-0-cust81.1-3.cable.virginmedia.com] has joined #ruby-lang
<brainopia>
enikar: I didn't use any flags for ps to show threads, so it's different processes
<brainopia>
and when 1.9 is told to have m:n model for threads, it means m system thread to n green, not m system processes :)
<brainopia>
bougyman: yeah, i know - but ruby reports it pid
<brainopia>
and fork returns its pid
<brainopia>
instead of actual ruby process
<brainopia>
that's my problem
<brainopia>
that's why I can't close ruby processes which were fork'ed and exec'ed
<enikar>
this is because ruby use 'sh -c' to exec when the exec is too complex.
<brainopia>
may be runit uses different workflow in which it can't be seen (foreman previously used a different workflow also and there wasn't any problem)
<brainopia>
enikar: well, are you sure? because it does not use sh -c for this code on mac
<bougyman>
that same line of code doesn't use sh on my ruby.
<bougyman>
on 1.9.2, trying 1.9.3 now
<enikar>
brainopia: i'm almost sure...
<workmad3>
brainopia: you should really either wait on or detach the children too
<enikar>
try to use exec('ruby', '-e',...)
<bougyman>
is foreman a supervisor written in ruby?
<brainopia>
bougyman: what platform are you using? it does not reproduce in mac for me, only on ubuntu on 1.8.7, 1.9.2 and 1.9.3
<brainopia>
bougyman: something along those lines
<bougyman>
Linux pzero 3.1.5-1-ARCH #1 SMP PREEMPT Sat Dec 10 14:43:09 CET 2011 x86_64 Intel(R) Core(TM) i7 CPU Q 740 @ 1.73GHz GenuineIntel GNU/Linux
<brainopia>
workmad3: what do you mean? I don't want to wait on forked process and I can't wait on exec'ed process
<bougyman>
brainopia: doesn't happen here at all.
<brainopia>
bougyman: well Mon_Ouie couldn't reproduce it either
Jake232 [Jake232!~textual@5e0ef036.bb.sky.com] has joined #ruby-lang
<bougyman>
this has to be an ubuntism
<bougyman>
trying on ubuntu now.
<workmad3>
brainopia: I suspect the execed process is already waiting... so maybe you want Process.detach(fork{}) so that the forked process won't become a zombie
<brainopia>
but I've reproduced it on two different ubuntu's
<bougyman>
bougyman 6901 0.0 0.0 4012 564 pts/5 S 08:17 0:00 sh -c ruby -e "sleep 30"
<bougyman>
not on arch nor debian nor centos, though
<brainopia>
workmad3: good idea, let me check
<bougyman>
this is on an old ubuntu, too
<enikar>
brainopia: i'll try with : ruby -e "pid = fork { exec('ruby', '-e', 'sleep 30') }; p pid"
<brainopia>
workmad3: nope, it's still there
<bougyman>
with 1.8.7
<brainopia>
enikar: sorry, missed your message
<enikar>
and there was only one process
<brainopia>
enikar: i confirm
<workmad3>
brainopia: doubt it will have an effect on what you're seeing though... that just looks like an oddity with how exec is working on your ruby in ubuntu
<brainopia>
enikar: good catch, though strange
<workmad3>
brainopia: I'm just installing ruby-head, seeing if that's any different on my mac compared to 1.9.3-p0
<workmad3>
brainopia: as I notice you have a 1.9.3dev version there
<enikar>
brainopia: i just remember that perl has the same behaviour
<brainopia>
workmad3: yeah, but it was reproducible on 1.8 and 1.9.2
<workmad3>
brainopia: but only on ubuntu?
<brainopia>
workmad3: yep
<workmad3>
brainopia: I wonder if it's something about sh on ubuntu then ;)
<brainopia>
workmad3: it would be logical to assume so, still I needed a way to workaround :)
<brainopia>
thanks to enikar I have for my simple example
<brainopia>
but in foreman it's not exhibited in this simple manner, so I'm not sure if it will be applicable
<enikar>
this is not only on ubuntu, i use debian(sid) and this is the same.
<bougyman>
brainopia: looking at foreman.
dhoss [dhoss!~dhoss@bruticus.dhoss.net] has joined #ruby-lang
<enikar>
brainopia: what are the others linux distribution you have tried for this test ?
alindeman [alindeman!~adml@pudge.ithought.org] has joined #ruby-lang
thrcka [thrcka!~thrcka@ip-89-102-34-33.net.upcbroadband.cz] has joined #ruby-lang
dr0id [dr0id!~andy@unaffiliated/dr0id] has joined #ruby-lang
Skif [Skif!~Skif@72.1.92.57] has joined #ruby-lang
shachaf [shachaf!~shachaf@ip24.67-202-82.static.steadfastdns.net] has joined #ruby-lang
Luthraz [Luthraz!~Luthraz@68.179.172.242] has joined #ruby-lang
naz [naz!~n@70.44.2.190.res-cmts.bus.ptd.net] has joined #ruby-lang
irk3z [irk3z!~irek@78.47.187.53] has joined #ruby-lang
zvrba [zvrba!96456@diamant.ifi.uio.no] has joined #ruby-lang
xsdg [xsdg!~xsdg@SIPB-VM-99.MIT.EDU] has joined #ruby-lang
mahlon [mahlon!mahlon@martini.nu] has joined #ruby-lang
tpope [tpope!tpope@maeby.tpope.net] has joined #ruby-lang
phaedrix [phaedrix!~phaedrix@c-24-22-86-235.hsd1.or.comcast.net] has joined #ruby-lang
<bougyman>
enikar: tested centos, archlinux, and ubuntu (karmic) here, also opensuse and debian stable.
<brainopia>
I don't have much, only aforementioned :)
<bougyman>
only happens on karmic
shachaf [shachaf!~shachaf@ip24.67-202-82.static.steadfastdns.net] has joined #ruby-lang
dr0id [dr0id!~andy@unaffiliated/dr0id] has joined #ruby-lang
<workmad3>
brainopia: on my debian, sh seems to link to a shell called 'dash'
<workmad3>
brainopia: but on my mac, sh is linked to bash
<bougyman>
brainopia: would you like to see the equivalent app run non-foreman?
<bougyman>
oh yeah, ubuntu and newer debians use dash for sh
<bougyman>
instead of bash
<bougyman>
or ash?
<bougyman>
either dash or ash, let's see.
<bougyman>
it's dash, here.
<bougyman>
hah
<bougyman>
change your symlink from dash to bash and it stops happening.
<bougyman>
nice catch, workmad3
mitchty [mitchty!~mitchty@ec2-50-19-41-37.compute-1.amazonaws.com] has joined #ruby-lang
<brainopia>
woah, interesting
<brainopia>
good catch indeed
<workmad3>
probably not a good idea to replace your sh symlink to bash btw
<bougyman>
t's a perfectly good idea
<bougyman>
but use the alternatives system for it.
<workmad3>
ah, that would make sense :)
<workmad3>
what would be better IMO would be if you could get exec to use bash explicitly though
<brainopia>
bougyman: my friend once tried it
<brainopia>
bougyman: his ubuntu stopped loading after replacing sh with bash :)
<bougyman>
once tried what?
<brainopia>
he symlinked sh to bash :)
<bougyman>
oh right, systemd is coupled to it, right?
<brainopia>
yeah :)
<enikar>
workmad3: oh, very nice !
<bougyman>
wait, no
<bougyman>
upstart is not tied to dash
<bougyman>
your friend did something weird.
<brainopia>
system started, but gui not
<bougyman>
i just rebooted that box and it's fine.
<brainopia>
he fixed it back through console
<bougyman>
oh, iono about a gooey
<bougyman>
i'm remote to that thing
<brainopia>
so you can't test it then (i'm not sure if effects are visible on x11 or vnc) :)
<workmad3>
brainopia: could you use system() instead of exec()? system uses a subshell rather than replacing the process like exec()
<brainopia>
no, unfortunately pid of original shell is needed to track process
<brainopia>
that's why fork+exec is used :)
<bougyman>
brainopia: sounds like foreman needs to move to exec(*args)
<bougyman>
which is the right way to do exec, anyway.
<bougyman>
instead of the string version you used.
malev [malev!~malev@190.55.218.52] has joined #ruby-lang
<brainopia>
bougyman: they can't use *args, because strings are given as part of yaml config :)
<bougyman>
i know, i see that
<workmad3>
brainopia: you could fork + system surely?
<bougyman>
workmad3: this is foreman, a process supervisor he's using that does this
<bougyman>
you give it a little config and it tries to keep them running.
<bougyman>
i can't stand ones like this (and monit)
<bougyman>
i prefer the ones like perpd and runit which maintain a running parent on their process trees.
<workmad3>
ah, I looked at foreman when I played around with heroku cedar...
<brainopia>
brainopia: Sure, but then how would I know the pid of process running through the system
<bougyman>
i use runit for everything
<brainopia>
workmad3: ^^^
<workmad3>
not exactly used a massive amount of it yet though
senthil [senthil!~senthil@99-51-1-6.lightspeed.snjsca.sbcglobal.net] has joined #ruby-lang
<senthil>
what's the best way to clean \t,
<senthil>
, \r, \n in a string
<bougyman>
what do you mean clean?
<bougyman>
get rid of?
<senthil>
Yes
<bougyman>
let's test.
<senthil>
I'm using plain old gsub, but there must be a better way
<bougyman>
#tr would do, but #gsub can probably handle.
<brainopia>
#delete
<bougyman>
i think he'd want to replace with a space though, no?
<senthil>
yes
<brainopia>
oh, then tr
<bougyman>
tr("\t\r\n","\s")
<senthil>
awesome, thanks
Manhose [Manhose!~Manhose@bl17-1-218.dsl.telepac.pt] has joined #ruby-lang
Indian [Indian!~Indian@unaffiliated/londonmet050] has joined #ruby-lang
<workmad3>
senthil: or .squeeze(' ') but not sure if that will catch tabs, newlines, etc
<workmad3>
ah, no, it won't
jxie [jxie!~jxie@115.198.175.95] has joined #ruby-lang
wmoxam [wmoxam!~wmoxam@pdpc/supporter/active/wmoxam] has joined #ruby-lang
senthil [senthil!~senthil@99-51-1-6.lightspeed.snjsca.sbcglobal.net] has quit [#ruby-lang]
Spooner [Spooner!~Miranda@host-78-144-139-130.as13285.net] has joined #ruby-lang
frangiz [frangiz!~frangiz@user26.77-105-206.netatonce.net] has joined #ruby-lang
wmoxam [wmoxam!~wmoxam@pdpc/supporter/active/wmoxam] has joined #ruby-lang
Locke23rus_ [Locke23rus_!~quassel@128-70-111-50.broadband.corbina.ru] has joined #ruby-lang
ryez [ryez!b49d0926@gateway/web/freenode/ip.180.157.9.38] has joined #ruby-lang
frangiz_ [frangiz_!~frangiz@user26.77-105-206.netatonce.net] has joined #ruby-lang
<ryez>
in ruby 1.9.2, the doc of Array.index says 'If neither block nor argument is given, an enumerator is returned instead', looks like the resulted enumerator is for each array element, not for each array index, very confusing to me
<ryez>
why not just index?
<Mon_Ouie>
Because the index methods yields each object, not each index
shaneee [shaneee!shane.fr@2.123.101.84.rev.sfr.net] has joined #ruby-lang
<ryez>
right, my test also prove that,
<ryez>
my point is just the inappropriate name
<Mon_Ouie>
How is it inappropriate?
<Mon_Ouie>
It yields each object, and returns the index of the first that matches a requirement
<ryez>
yielding each element is already the job of `each`, `index`, as the name indicate should yield every index
<Mon_Ouie>
No, that's the job of each_index
<shaneee>
hi all, im new to pastie. if i say hi here will the bot reply me?
<Mon_Ouie>
No, just create the pastie and paste the link here
<ryez>
no, in this case there's no requirement, since we're talking about when no argument nor block given
<shaneee>
hi mon_ouie, thanks for replying. in my case i have the link with me. do i just paste it here without any other commands?
<Mon_Ouie>
A block will eventually be given when the method will actually be called
<Mon_Ouie>
e.g. [4, 3, 2, 1].find_index.with_index { |obj, i| obj == i } #=> 2
<Mon_Ouie>
Same with about all the other methods that return an Enumerator when no block was given
<ryez>
what if I do something else with the returned enum, e.g. map/reduce? will that be the same case you're talking about?
<Mon_Ouie>
shaneee: Just ask your question and paste the link with your code, there's no need for a bot to do anything
<deryl>
can someone tell me a real world case (brevity is fine) where adding and calling a method on a Class object (class can be any class) rather than an instance is used? I'm reading The Well Grounded Rubyists, and David is explaining about Class being an object and adding methods to the class object (as opposed to an instance of that class). I don't see a real purpose for that, but I'm wagering thats my inexperience.
<shaneee>
ok thanks a lot, appreciate it!
frangiz [frangiz!~frangiz@user26.77-105-206.netatonce.net] has joined #ruby-lang
<Mon_Ouie>
ryez: Yes, except there's no reason to do that since you won't get the result of the #index method, which is why you call it in the first place
<deryl>
i uncerstand that Class(es) are objects just like instances of those classes, I just don't understand the usability of calling methods on a Class rather than on the object (instance) of that class.
<deryl>
can't seem to wrap my beady little head around that
<ryez>
deryl: think about find_by_xxx in rails
darkf [darkf!~darkf_dix@unaffiliated/darkf] has joined #ruby-lang
<deryl>
thats just reading the table associated witht he Model and and auto creating a find_by_<column> isn't it?
<deryl>
and isn't that actually not the class object of whatever Model, b ut rather ActiveRecord just reading the columns, and autocreating the find_by?
<deryl>
not arguing, just trying to sharpen and identify the differences. (I'm really having difficulty with this part so forgive me)
<Mon_Ouie>
You mean any example of class methods? There are all the methods that don't operate on an instance, but rather create an instance
<Mon_Ouie>
e.g. Time.parse, Time.at, etc.
frangiz_ [frangiz_!~frangiz@user26.77-105-206.netatonce.net] has joined #ruby-lang
<deryl>
ohh. i thought those were defined in the class but as instance methods (eg. not done as def Time.parse but as def parse)
<deryl>
thanks Mon_Ouie gives me something to look up as a reference for this behaviour.
<deryl>
Mon_Ouie: hrmm. *is* parse a class method (rather than defined as an instance method) becuase its defined as def parse(date, now=self.now) wouldn't it be def Time.parse(date, now=self.now) for a class method? (feel free to school me if I'm totally wrong)
<Mon_Ouie>
It is a class method, otherwise you wouldn't be able to call it like that (you'd need an instance of Time, and Time is not one)
<Mon_Ouie>
There are at least two ways of defining a method on an object: def some_expression.method; …; end and class << some_expression; def method; …; end; end
<deryl>
that 2nd one I'm not familiar with yet (syntax) - thanks. I'll mark it in the margins to revisit that.
<deryl>
Mon_Ouie: again, thank you
<Mon_Ouie>
It's used to access the singleton class of an object
<rue>
Many talks
<deryl>
oh wait. singleton classes are really just anonymous classes? (class with no name)
<cek>
#21 is the "outside" , #36 where "inside" is called
<cek>
the idea is to provide user with easily accessible data method/var in #69
vmatiyko [vmatiyko!~vmatiyko@178.121.196.169] has joined #ruby-lang
vmatiyko [vmatiyko!~vmatiyko@178.121.196.169] has quit [#ruby-lang]
prsimp [prsimp!~prs@manifestland.com] has joined #ruby-lang
<prsimp>
new to ruby and trying to optimize a set of nested for-loops, any tips?
<rue>
Don't
<rue>
cek: foo = 1; l = ->() { p foo }
<prsimp>
ha, well if I could figure out a better way to do the comparison I wouldn't :)
<rue>
prsimp: You should be using Enumerable, and nested structures often imply the data isn't structured the best way. Maybe you can massage the data, maybe you need more objects
<prsimp>
rue: mind if I pm?
<rue>
Yes, just ask on the channel, please
<rue>
You can use gist or pastie
<rue>
If you've a larger example
<cek>
rue, that's what i'm running from. i'm trying to rebind the context
<prsimp>
rue: ok. I'm gonna do some reading on Enumerable first and see what I can figure out.
<rue>
cek: Just pass in the data
<rue>
prsimp: :thumbsup:
<cek>
noah, that ain't cool. i've seen cases when you pass your own block and can access hell lot of local vars or what appears to be local vars inside that block without passing any arguments
<cek>
i guess they just inject all sort of stuff inside the callers context
frangiz [frangiz!~frangiz@user26.77-105-206.netatonce.net] has joined #ruby-lang
enebo [enebo!~enebo@75-168-50-253.mpls.qwest.net] has joined #ruby-lang
frangiz [frangiz!~frangiz@user26.77-105-206.netatonce.net] has joined #ruby-lang
srbaker [srbaker!~srbaker@184.66.82.213] has joined #ruby-lang
<prsimp>
rue: I'm having trouble seeing how to use enumerable to compare an every element to every other element of the array
tomzx [tomzx!~tomzx@70.52.27.16] has joined #ruby-lang
srbaker [srbaker!~srbaker@184.66.82.213] has joined #ruby-lang
<TTilus>
rue: permutation takes order into account, combination does not
<prsimp>
TTilus: and cities would be something I've generated?
<rue>
Right
<prsimp>
using the coordinates and populations
<TTilus>
prsimp: something that represent your cities
aroop [aroop!~aroop@50.46.157.247] has joined #ruby-lang
<TTilus>
prsimp: cities would be an array of your cities
<TTilus>
prsimp: the cities variable in the example
<prsimp>
ok - let me work my way through that and see what I can come up with
<prsimp>
thanks for your help so far everyone
<TTilus>
prsimp: .combination(2), as suggested by mksm too, gives you all the possible pairs (combinations of two) of your cities
<rue>
It'd be [coordinate, population], essentially
<prsimp>
right
<TTilus>
prsimp: what rue suggested is a good point to start
<TTilus>
prsimp: if you wanna extend the functionality, at some point you'd wanna make a class to represent the city
<prsimp>
and then map just iterates over them with each combo becoming city1 and city2, correct?
<TTilus>
prsimp: exactly!
<prsimp>
calling the block on each
<TTilus>
prsimp: you are getting the grips of it
<prsimp>
block being calculate_cable_needed(city1, cit2)
<TTilus>
prsimp: and let the .reduce(:+) part be the home excercise =D
<prsimp>
ha
<TTilus>
well, its easy to guess what it does based on the problem at hand, but go find out how it works
<prsimp>
yeah - the :+ represents a symbol, yes?
<prsimp>
telling ruby to sum?
<TTilus>
thats what it does
<prsimp>
interesting.
robgleeson [robgleeson!~rob@subtle/contributor/robgleeson] has joined #ruby-lang
r0bby_ [r0bby_!~wakawaka@guifications/user/r0bby] has joined #ruby-lang
mikeric [mikeric!~mike@96.49.104.11] has joined #ruby-lang
dejongge [dejongge!~jonke@pD9E0C9BF.dip0.t-ipconnect.de] has joined #ruby-lang
hagabaka [hagabaka!~hagabaka@unaffiliated/hagabaka] has joined #ruby-lang
workmad3 [workmad3!~workmad3@cpc1-bagu10-2-0-cust81.1-3.cable.virginmedia.com] has joined #ruby-lang
<prsimp>
hmm - got it working but it is actually slower than the loops
fonziec [fonziec!~ac1507@cpe-98-14-140-6.nyc.res.rr.com] has joined #ruby-lang
<TTilus>
prsimp: might very well be
<TTilus>
prsimp: the thing is, you really can't avoid having to generate and loop all the combinations of your cities
<prsimp>
true
<prsimp>
using the combination and map is just more the ruby way, right?
<TTilus>
yes
<TTilus>
if you write nested loops like you did you need to explain people what you do
<TTilus>
map reduce like suggested just plain reads better
<TTilus>
and thus is likely to be more maintainable
fonziec [fonziec!~ac1507@cpe-98-14-140-6.nyc.res.rr.com] has joined #ruby-lang
looopy [looopy!~looopy@c-68-34-92-100.hsd1.md.comcast.net] has joined #ruby-lang
jensn [jensn!~Jens@c-83-233-145-148.cust.bredband2.com] has joined #ruby-lang
dbussink [dbussink!dirkjan@elle.fallingsnow.net] has joined #ruby-lang
<theconartist>
http://pastie.org/3145200 <- if anyone wants to check and tell me if i'm doing somethign horribly wrong (other than re-inventing the wheel)
fonziec [fonziec!~ac1507@cpe-98-14-140-6.nyc.res.rr.com] has joined #ruby-lang
dv310p3r [dv310p3r!~dv310p3r@c-98-203-41-91.hsd1.fl.comcast.net] has joined #ruby-lang
<epitron>
theconartist: "tries to stay the same width"?
<epitron>
like, you want each page to fill up the browser window without scrolling?
alessio_rocco [alessio_rocco!~alessio@94.165.137.130] has joined #ruby-lang
<theconartist>
what no
<theconartist>
its just pagination links, tries to list n pages
<theconartist>
but obviously if pages < n it has to be smaller
<epitron>
ah
<epitron>
that seems like a lot of code for that
dbussink [dbussink!~dbussink@elle.fallingsnow.net] has joined #ruby-lang
<theconartist>
unless there is some special math i am missing i think it's the smallest possible
cyri_ [cyri_!~cyri_@jem75-1-87-88-118-80.dsl.sta.abo.bbox.fr] has joined #ruby-lang
skinnymuch [skinnymuch!~skinnymuc@c-68-36-123-133.hsd1.nj.comcast.net] has joined #ruby-lang
<epitron>
could be :)
<epitron>
so you want to show first page, last page, and a window of size-2 pages around the current pgae?
<epitron>
+page?
<theconartist>
yea
lsegal [lsegal!jinx@modemcable249.109-177-173.mc.videotron.ca] has joined #ruby-lang