Topic for #ruby-lang is now Ruby 1.9.3p0: http://ruby-lang.org | Paste >3 Lines of Text on http://pastie.org
yfeldblum [yfeldblum!~Jay@c-98-218-48-253.hsd1.md.comcast.net] has joined #ruby-lang
<shevy> pbjorklund but applying .strip on "Something something " will remove the ' '
<shevy> the last one
<manveru> shevy: he just said it doesn't
<drbrain> manveru: I have a doubt that "Something something " is pbjorklund's actual string
<pbjorklund> drbrain: .ord = 160. Is that http://en.wikipedia.org/wiki/Non-breaking_space ?
<drbrain> try string.sub(/\p{Space}\z/, ''
<manveru> that's probably part of a multibyte encoding
<drbrain> manveru: ord returns the code point for the encoding of the string
<manveru> string.bytes.to_a
<drbrain> assuming string.valid_encoding? returns true
<pbjorklund> drbrain: incompatible encoding regexp match (ASCII-8BIT regexp with UTF-8 string) - Got that when exploring another solution as well
<drbrain> pbjorklund: make # coding: utf-8 be the first line of your file
<pbjorklund> drbrain: Made no difference, and valid_encoding? returns true for all strings with that problem
<manveru> string.bytes.to_a
<manveru> or paste the actual string
<drbrain> pbjorklund: like this: http://paste.segment7.net/py.html
<drbrain> ?
<manveru> fiddling with doubly invisible stuff is no way to solve problems
<pbjorklund> "NORTHSPACE "
<pbjorklund> [84, 101, 108, 105, 97, 83, 111, 110, 101, 114, 97, 32, 83, 118, 101, 114, 194, 160]
<manveru> thanks
<manveru> drbrain: why do you use # coding instead of # Encoding ?
<drbrain> manveru: it's two letters shorter and doesn't matter
<manveru> just curious, i see it's being used in core too
<manveru> heh
<drbrain> ruby allows for both
<manveru> obviously
<shevy> so is his problem solved! I am curious, I can't sleep if the 160 isn't explained!
<pbjorklund> drbrain: Thank you. As always you helped me solve the problem and made me feel oddly stupid ;) Thanks manveru also
<shevy> oooh
<drbrain> pbjorklund: "TeliaSonera Sver" is your string?
<pbjorklund> drbrain: Woops, one-off-line-error there
<drbrain> (the answer should be "no")
dejongge1 [dejongge1!~jonke@pD9E0C9BF.dip0.t-ipconnect.de] has joined #ruby-lang
<manveru> shevy: yeah, it's the &nbsp;
<drbrain> pbjorklund: if I use NORTHSPACE with my example I get:
<matti> manveru: :)
<matti> drbrain: :)
<drbrain> note the 6th and 7th hex column of the third line
<drbrain> that's 194 160 in decimal
<pbjorklund> drbrain: yeah... that tells me nothing.. :-)
<matti> Haha
<drbrain> so, if you have your encodings right, string.sub(/\p{Space}\z/, '') will trim your trailing whitespace
<pbjorklund> drbrain: Yes, it did. Thats what I meant with the thanks earlier
<drbrain> oh! ha
<drbrain> ok then
<manveru> hm
<manveru> .gsub(/\A\p{space}|\p{space}\z/, '')
<manveru> as replacement for strip
<manveru> now i just have the crazy urge to bench whether two subs would be faster :P
* manveru gets back to work
<matti> manveru: Hah.
tokumine [tokumine!~kunio@82-69-174-54.dsl.in-addr.zen.co.uk] has joined #ruby-lang
jaemin-kr [jaemin-kr!~jaemin-kr@50.8.93.223] has joined #ruby-lang
jensn [jensn!~Jens@c-83-233-145-148.cust.bredband2.com] has joined #ruby-lang
dv310p3r [dv310p3r!~dv310p3r@adsl-65-3-161-18.mia.bellsouth.net] has joined #ruby-lang
dv310p3r [dv310p3r!~dv310p3r@adsl-65-3-161-18.mia.bellsouth.net] has joined #ruby-lang
takaokouji [takaokouji!~takaokouj@220.110.223.220] has joined #ruby-lang
Skif [Skif!~Skif@72.1.92.57] has joined #ruby-lang
sora_h [sora_h!~sora_h@mayfield.privs.net] has joined #ruby-lang
virunga [virunga!~virunga@151.64.4.53] has joined #ruby-lang
Gekz [Gekz!~gekz@159.253.5.25] has joined #ruby-lang
Gekz [Gekz!~gekz@unaffiliated/gekz] has joined #ruby-lang
setmeaway [setmeaway!~setmeaway@119.201.52.190] has joined #ruby-lang
skinnymuch_ [skinnymuch_!~skinnymuc@c-68-36-123-133.hsd1.nj.comcast.net] has joined #ruby-lang
tla [tla!~tla@toelboell-lund.dk] has joined #ruby-lang
looopy [looopy!~looopy@c-68-34-92-100.hsd1.md.comcast.net] has joined #ruby-lang
spuk [spuk!~spuk@187.65.176.82] has joined #ruby-lang
amerine [amerine!~mturner@bc171197.bendcable.com] has joined #ruby-lang
flip_digits [flip_digits!~textual@c-71-199-243-97.hsd1.fl.comcast.net] has joined #ruby-lang
srbaker [srbaker!~srbaker@184.66.82.213] has joined #ruby-lang
moos3 [moos3!~rgenthner@cpe-72-224-121-41.maine.res.rr.com] has joined #ruby-lang
<moos3> how can i reload a file on change ? basic i have zone files if modified i want to reload them automatically
fritzek__ [fritzek__!~fritzek@p5DDB714C.dip.t-dialin.net] has joined #ruby-lang
rdavila [rdavila!~rdavila@190.236.47.17] has joined #ruby-lang
Banistergalaxy [Banistergalaxy!~AndChat@222.153.223.46] has joined #ruby-lang
wmoxam [wmoxam!~wmoxam@pdpc/supporter/active/wmoxam] has joined #ruby-lang
<shevy> hmmm
<shevy> now if github ruby projects could be interconnected better ...
<erikh> in what sense?
looopy [looopy!~looopy@pool-141-156-51-14.washdc.btas.verizon.net] has joined #ruby-lang
<Banistergalaxy> Hey erikh
<erikh> Banistergalaxy: ohai
<Banistergalaxy> Sup
jasox [jasox!~jasox@178.239.26.139] has joined #ruby-lang
<erikh> not much really, just idling, waiting for a holla from a friend
<Banistergalaxy> Many sad tweets from you
<Banistergalaxy> Are you unhappy
<erikh> oh? I should stop using that infernal thing
<erikh> it's silly.
<Banistergalaxy> Hehe
<erikh> I haven't been sleeping particularly well, it's probably not helping my impulse control
dous [dous!~dous@unaffiliated/dous] has joined #ruby-lang
<andrewvos> Is that an unbanned banister?
<Banistergalaxy> Still banned, just phone
<andrewvos> oh :(
wimplash [wimplash!~Adium@wireless.sit-co.net] has quit [#ruby-lang]
<erikh> i'mma let you finish, but banister`fiend was the best troll of all time
SuperTaz_work [SuperTaz_work!~supertaz_@38.99.52.59] has joined #ruby-lang
<andrewvos> Indeed. It's boring without banisterfiend here.
looopy [looopy!~looopy@pool-141-156-51-14.washdc.btas.verizon.net] has joined #ruby-lang
<erikh> ok, time to go. have fun john
<shevy> erikh well, hard to describe what I meant with that. But, for instance, one key insight I had when I used "Issue" for the first time at github
<shevy> I thought "Boy, this is so much nicer to use than Sourceforge or Bugzilla"
<shevy> I hate logging into the latter two, especially Bugzilla
<shevy> redmine tracker is ok, you get at least a nicer overview, like http://bugs.ruby-lang.org/projects/ruby-trunk/issues?set_filter=1&tracker_id=1
<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
<gnufied> can you show me your dsl, sample?
<twittard> sec
<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
<robgleeson> calling scope is kept
<twittard> robgleeson: I have a ProcessPoolServer version of this guy in the works (https://github.com/sgonyea/thrift/blob/trunk/lib/rb/lib/thrift/server/mutexable_thread_pool_server.rb)
<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 :)
<bougyman> brainopia: perhaps you're doing something wrong
<bougyman> we use runit for all our ruby processes and never run into this, on linux.
<brainopia> bougyman: i'm pretty sure I am
<bougyman> 'foreman' sounds like a runit-alike
<enikar> brainopia: theird, i ran a simple test, and when i fork, there were only two process, the parent and the child, as i expect
andrewhl [andrewhl!~andrewhl@out-pq-133.wireless.telus.com] has joined #ruby-lang
<bougyman> it just makes itself the parent, right?
<enikar> oops, s/theird/weird/
<brainopia> enikar: I can reproduce it only when I combine fork+exec and only on linux (latest ubuntu)
<bougyman> brainopia: show an example
<brainopia> bougyman: yeah, foreman can be though as runit for an app
<enikar> i'll try to exec some process...
<bougyman> brainopia: i use runit for apps.
<brainopia> bougyman: I've shown in a gist https://gist.github.com/34ae5c007ab43de960e2
<bougyman> that first process is bash, brainopia
<bougyman> well, sh
<bougyman> it's not ruby
<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> bougyman 6902 0.0 0.0 18812 2112 pts/5 S 08:17 0:00 ruby -e sleep 30
<bougyman> it's an ubuntu thing
<bougyman> I can replicate it on ubuntu
<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
<brainopia> bougyman: does runit include per app config which can be bundled with app :)
<workmad3> I need to look at monitors and the like a bit more... I'll probably go with runit though seeing as that seems quite easy to do with chef :)
<bougyman> brainopia: yes
<brainopia> bougyman: woah, nice - can you show an example if it's not much trouble?
<bougyman> note the env dir
<bougyman> that env dir is the 'config file' for the services.
<bougyman> the previous article explains how that works.
<bougyman> here the app has 3 processes that run.
<workmad3> hmm... my nagios setup isn't sending out emails correctly
<bougyman> tcc_innate is the web front-end, fs2ws is the websockets publisher, an queue_reporter is a freeswitch dialplan listener.
<workmad3> just randomly checked, and I have a host down that it didn't tell me about :/
<brainopia> pretty sweet, very flexible therefore powerful, but the cost is verbosity :)
<bougyman> yep
<bougyman> once you've done some that goes away, though
<bougyman> and really if you look at the 'run' files in those service directories, they're mostly the same.
<chris2> bougyman: great article, thanks
<brainopia> yeah, thanks for the article
<chris2> bougyman: but $(<file) is a bashism i think
enebo [enebo!~enebo@75-168-50-253.mpls.qwest.net] has joined #ruby-lang
jensn [jensn!~Jens@c-83-233-145-148.cust.bredband2.com] has joined #ruby-lang
frangiz [frangiz!~frangiz@user26.77-105-206.netatonce.net] has joined #ruby-lang
niklasb [niklasb!~codeslay0@p5B310140.dip0.t-ipconnect.de] has joined #ruby-lang
Peg-Leg [Peg-Leg!Peg-Leg@79.119.191.226] has joined #ruby-lang
Peg-Leg [Peg-Leg!Peg-Leg@79.119.191.226] has joined #ruby-lang
<brainopia> btw, there is a sweet posix-spawn (and ruby wrapper https://github.com/rtomayko/posix-spawn) to replace fork+exec
<bougyman> chris2: i believe it is.
<bougyman> chris2: i abuse a few bashism
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)
<deryl> sorry, reading http://www.devalot.com/articles/2008/09/ruby-singleton after googling "whare are singleton classes in ruby". thats how he's explaining.
<rue> No, that's not the same thing
<deryl> lot of terminology i seem to need to pick up hehe
<rue> wee = Class.new # Anonymous class
Keva161 [Keva161!~Keva161@78.32.156.143] has joined #ruby-lang
<rue> class << someobj; self; end # Singleton- or eigenclass
confounds [confounds!~confounds@CPE78cd8e667600-CM78cd8e6675fd.cpe.net.cable.rogers.com] has joined #ruby-lang
frangiz [frangiz!~frangiz@user26.77-105-206.netatonce.net] has joined #ruby-lang
looopy [looopy!~looopy@pool-151-200-236-103.washdc.btas.verizon.net] has joined #ruby-lang
krz [krz!~foobar@182.16.234.9] has joined #ruby-lang
krz [krz!~foobar@unaffiliated/krz] has joined #ruby-lang
aarkerio [aarkerio!~aarkerio@201.141.111.212] has joined #ruby-lang
savage- [savage-!~savage-@c-67-180-11-89.hsd1.ca.comcast.net] has joined #ruby-lang
frangiz_ [frangiz_!~frangiz@user26.77-105-206.netatonce.net] has joined #ruby-lang
frangiz [frangiz!~frangiz@user26.77-105-206.netatonce.net] has joined #ruby-lang
queeway [queeway!~queequeg@c-71-202-152-67.hsd1.ca.comcast.net] has joined #ruby-lang
skinnymuch [skinnymuch!~skinnymuc@static-173-61-113-6.cmdnnj.fios.verizon.net] has joined #ruby-lang
skinnymuch [skinnymuch!~skinnymuc@static-173-61-113-6.cmdnnj.fios.verizon.net] has quit [#ruby-lang]
jasox [jasox!~jasox@178.239.26.139] has joined #ruby-lang
Carmivore [Carmivore!~carmivmor@ec2-107-22-135-197.compute-1.amazonaws.com] has joined #ruby-lang
wyhaines [wyhaines!~wyhaines@65.39.118.15] has joined #ruby-lang
virunga [virunga!~virunga@151.64.38.182] has joined #ruby-lang
Newbs [Newbs!~textual@host-78-147-55-216.as13285.net] has joined #ruby-lang
frangiz [frangiz!~frangiz@user26.77-105-206.netatonce.net] has joined #ruby-lang
desireco_ [desireco_!~textual@108-217-153-195.lightspeed.cicril.sbcglobal.net] has joined #ruby-lang
Silowyi [Silowyi!~silowyi_d@99-26-202-35.lightspeed.snantx.sbcglobal.net] has joined #ruby-lang
wimplash [wimplash!~Adium@wireless.sit-co.net] has joined #ruby-lang
Pip_ [Pip_!~Pip@176.214.15.128] has joined #ruby-lang
Pip_ [Pip_!~Pip@unaffiliated/pip] has joined #ruby-lang
flip_digits [flip_digits!~textual@c-76-122-14-228.hsd1.fl.comcast.net] has joined #ruby-lang
wimplash [wimplash!~Adium@wireless.sit-co.net] has quit [#ruby-lang]
wyhaines_ [wyhaines_!~wyhaines@65.39.118.15] has joined #ruby-lang
tokumine [tokumine!~kunio@82-69-174-54.dsl.in-addr.zen.co.uk] has joined #ruby-lang
imperator [imperator!~Daniel@63-225-247-192.hlrn.qwest.net] has joined #ruby-lang
looopy [looopy!~looopy@pool-151-200-236-103.washdc.btas.verizon.net] has joined #ruby-lang
tekin [tekin!~tekin@cpc8-with5-2-0-cust208.1-4.cable.virginmedia.com] has joined #ruby-lang
<muzone> At https://gist.github.com/1566053 - to make maintaining ID3 tags in large music collections a breeze - what would you do next?
frangiz [frangiz!~frangiz@user26.77-105-206.netatonce.net] has joined #ruby-lang
<lianj> add code
<rue> Hmm, I think I'd write a prayer calculator!
<lianj> rue: haha
<chris2> :D
<muzone> lianj: what sorta code? :)
<lianj> thats up to you
saLOUt [saLOUt!~rriemann@91-65-223-29-dynip.superkabel.de] has joined #ruby-lang
workmad3 [workmad3!~workmad3@cpc1-bagu10-2-0-cust81.1-3.cable.virginmedia.com] has joined #ruby-lang
MistyM [MistyM!~MistyM@50.72.70.192] has joined #ruby-lang
<imperator> well, chrome isn't liking file download links on my osx box now :(
<rue> I think, if you want to go CLI, a fuzzy matcher + tag would be good
<rue> E.g. $ 1d3tag /nirvana/ /nevermind/ +grunge +90s -classic_rock
malev [malev!~malev@190.55.218.52] has joined #ruby-lang
boxmo [boxmo!~box@177.106.57.50] has joined #ruby-lang
<Eising> I really have one of those days where ruby just amazes me in its simplicity
looopy [looopy!~looopy@c-68-34-92-100.hsd1.md.comcast.net] has joined #ruby-lang
<rue> Ah, every day
hagabaka [hagabaka!~hagabaka@unaffiliated/hagabaka] has joined #ruby-lang
fayimora [fayimora!~fayimora@95.175.159.12] has joined #ruby-lang
Pip_ [Pip_!~Pip@176.214.15.128] has joined #ruby-lang
Pip_ [Pip_!~Pip@unaffiliated/pip] has joined #ruby-lang
frangiz_ [frangiz_!~frangiz@user26.77-105-206.netatonce.net] has joined #ruby-lang
tokumine [tokumine!~kunio@82-69-174-54.dsl.in-addr.zen.co.uk] has joined #ruby-lang
<Eising> rue: some days more than others, also I don't usually code
<Eising> :)
<rue> That's unpossible!
<Eising> but once in a while I make a webapp or two, usually to automate something
<rue> Ah
<necromancer> are there any good metaprogramming screencasts or tutorials i can read online?
<necromancer> i'm trying to productively procrastinate on reading Metaprogramming Ruby :)
<rue> Metaprogramming is just programming
<rue> Maybe Dwemthy's still fun?
<rue> corundum: dwemthy?
<corundum> who knows?
andrewhl [andrewhl!~andrew@24-246-15-43.cable.teksavvy.com] has joined #ruby-lang
adambeynon [adambeynon!~adambeyno@82-69-1-211.dsl.in-addr.zen.co.uk] has joined #ruby-lang
cek [cek!~cek@crius.pantheon.fused.net] has joined #ruby-lang
<cek> Hi. How do I inject a local variable into bound method? -> inside = lambda{ puts injected } ; outside = lambda{ injected = 123; inside.call }
<Mon_Ouie> The local variable must be defined before inside
<cek> I don't want to supply argument, the "inside" is very generic.
artOfWar [artOfWar!~artofwar@108-205-201-30.lightspeed.sntcca.sbcglobal.net] has joined #ruby-lang
<cek> undefined local variable or method `data' for TestPlugin:Module.
<cek> yea, it's complicated :)
RomD` [RomD`!~Roman@nrbg-4d070fe7.pool.mediaWays.net] has joined #ruby-lang
<queequeg1> anybody in here play rubywarrior?
<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
<bougyman> chris2: ping
<shevy> bougyman: pong NUKE DESTROY
<shevy> hmm
<shevy> file('foo.rb').get_all_methods
<mksm> prsimp, pastie the code
<rue> prsimp: You may not need to
<rue> ^^
<prsimp> okay - go easy though :D
dejongge [dejongge!~jonke@pD9E0C9BF.dip0.t-ipconnect.de] has joined #ruby-lang
<mksm> prsimp: the data is in a file?
<prsimp> yeah, and I just pipe it in
<prsimp> data looks like this
<andrewvos> Hey can wget download a directory?
<rue> Hmm, maybe
<prsimp> My method works fine, its just inefficient for large numbers of cities, obviously.
<lianj> andrewvos: -r or -m
<andrewvos> lianj: Thanks
<lianj> -r --level=1
<andrewvos> lianj: Aww man that is very cool thanks
<andrewvos> lianj: Needed all of these http://hidemyass.com/vpn-config/
<andrewvos> lianj: Because of you I may be able to watch Community
<rue> prsimp: So, to start off easy: testcases.times { … }
<andrewvos> rue: Hey, is your VPN service blocked by hulu??
<lianj> andrewvos: :) all credit to wget
<andrewvos> rue: Or proxy
imperator [imperator!~Daniel@63-225-247-192.hlrn.qwest.net] has quit ["Leaving"]
<rue> andrewvos: Proxy, and no. Just have to turn off certain things to hide that it's a proxy
<TTilus> prsimp: care to elaborate on what you are actually trying to solve there?
<andrewvos> rue: I'm using hidemyass and it says something like "looks like you're using a proxy fucker".
<TTilus> prsimp: maybe its just me, but i can't easily figure it out from the code
<rue> Better variable names would probably help :)
<prsimp> heh, yeah sorry for the poor names
<TTilus> having something to do with cities and cable weight still leaves whole a lot of details open
<prsimp> TTilus: there are a number of cities on an x-axis (coords array)
<prsimp> and each one has a given population (pops array)
<prsimp> the number of connections needed to network 2 cities is equal to the max of the populations of the two cities
<shevy> andrewvos I am bored. say something funny please
<prsimp> the total cable used to network two cities (kilos_of_cable) is equal to the number of connections needed times the distance between them
<rue> prsimp: It's not a single axis, though, you can go from a to both b AND c, not a <-> b <-> c ?
<prsimp> I am trying to find the total distance of cable needed to network every city to every other city
<TTilus> prsimp: that makes sense
<prsimp> rue: yes, all cities must be connected to each other (to prevent congestion)
<TTilus> prsimp: is city location really single dimensional?
<prsimp> yes
<prsimp> not that difficult of a problem, really.
<prsimp> as I said, the for loops solve it - it just is horribly inefficient
<TTilus> that really simplifies =D
<andrewvos> shevy: hmmm
<prsimp> and being new to ruby, i'm trying to figure out the better way to do it.
<shevy> ewwww for loops
<TTilus> prsimp: this has pretty much nothing to do with ruby
<prsimp> new to programming then:P
<andrewvos> shevy: reddit.com/r/funny
<shevy> basically your cities... are like spots. and you want to calculate the distance from spot A to B to C
<TTilus> prsimp: would that just be taking all the city-pairs and calculating needed cable?
<prsimp> yes
<shevy> lol andrewvos http://i.imgur.com/i5QdI.jpg
igotnolegs [igotnolegs!~igotnoleg@75-162-83-166.slkc.qwest.net] has joined #ruby-lang
<prsimp> but I don't see how to get all the city-pairs distances without using a nested loop
<andrewvos> shevy: haha
<mksm> prsimp: array.combination(2) helps
<prsimp> mksm: looking at the docs, thanks.
<TTilus> prsimp: cities.combination(2).map { |city1, city2| calculate_cable_needed(city1, city2) }.reduce(:+)
<shevy> cool
<shevy> never saw combination() like that before
<rue> #combination is like unique #permutation?
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
<epitron> damn, i hate clipping
<epitron> this works for the beginning and middle cases: http://codepad.org/iuZmct8W
mikeric [mikeric!~mike@96.49.104.11] has joined #ruby-lang
<epitron> there we go
<epitron> well, closer :)
<epitron> man, the minus sign makes code like this so hard to decipher.
<epitron> what's a good "distance" operator?
<epitron> i guess i could use a..b.size
<manveru> ?
<manveru> ah, pagination
dejongge [dejongge!~jonke@pD9E0C9BF.dip0.t-ipconnect.de] has joined #ruby-lang
skinnymuch [skinnymuch!~skinnymuc@c-68-36-123-133.hsd1.nj.comcast.net] has quit [#ruby-lang]
<manveru> hehe
tesseract [tesseract!~tesseract@c-98-210-179-23.hsd1.ca.comcast.net] has joined #ruby-lang
dbussink [dbussink!dirkjan@elle.fallingsnow.net] has joined #ruby-lang
cyri_ [cyri_!~cyri_@jem75-1-87-88-118-80.dsl.sta.abo.bbox.fr] has joined #ruby-lang
Faris [Faris!~amnay@41.248.198.201] has joined #ruby-lang
rolfb [rolfb!~rolfb@165.219.202.84.customer.cdi.no] has joined #ruby-lang
<manveru> hm, been a while since i wrote one of those
<epitron> yeah...
<epitron> it's a lot like doing graphics
<epitron> you have a nice simple average case, and then clipping adds all these annoying edge cases
<epitron> i guess any visual layout algorithm has that problem
<epitron> everything is fine, until you run out of room
<epitron> then you have to figure out how to collapse things, which becomes a problem of communicating with neighbouring elements...
<epitron> pagination seems so simple conceptually :)
<epitron> like, just the layout algorithm
<epitron> our brains must use a totally different way of computing/representing things like htat
dbussink [dbussink!dirkjan@elle.fallingsnow.net] has joined #ruby-lang
<epitron> maybe the brain uses parallel multi-pass algorithms :)
<epitron> like, it decorates things
<epitron> manveru: have you ever tried to write a stable iterator?
<manveru> iterating over what?
<epitron> uhmmm
<epitron> like, it lets you modify the list you're iterating over
<epitron> while remembering the element you're on
<epitron> if i removed the previous element, it wouldn't skip one
<manveru> no, i don't think i was ever crazy enough to need that
<epitron> it's good for clustering.. you can look at neighbours and merge elements...
<epitron> it makes your algorithm a lot simpler
<manveru> i like my map/reduce
<epitron> haha
workmad3 [workmad3!~workmad3@cpc1-bagu10-2-0-cust81.1-3.cable.virginmedia.com] has joined #ruby-lang
alessio_rocco [alessio_rocco!~alessio@94.165.137.130] has joined #ruby-lang
srbaker [srbaker!~srbaker@184.66.82.213] has joined #ruby-lang
<epitron> there's some good discussion
<epitron> it's cropped up before for me in other scenarios... can't remember where though
<rue> epitron: Awesome, they've invented linked lists
<epitron> rue: linked lists aren't stable
<epitron> what if you remove the current node? :)
Faris1 [Faris1!~amnay@41.249.12.105] has joined #ruby-lang
<rue> Then you're fucked
<epitron> exactly
<epitron> also, it has to be at least doubly-linked
<rue> Well, yeah.
<rue> A singly linked list is about the most useless data structure. Saves a couple bytes
<epitron> i use linked lists on my atari 2600 ^_^
<epitron> no wait
<epitron> i just use raw memory chunks
<shevy> I count my fingers on ataris
<rue> I'm not sure if there's really a compelling case for a “stable” iterator over deletions
<rue> (Should probably use a different term… a snapshot iterator?)
<epitron> think about clustering
<rue> When do you want to iterate over already-deleted nodes?
M4g1c5t0rM [M4g1c5t0rM!~M4g1c5t0r@201.22.190.116.dynamic.adsl.gvt.net.br] has joined #ruby-lang
<epitron> okay..
<epitron> so say i want to group objects that are directly adjacent in... time
Axsuul [Axsuul!~Axsuul@75-140-75-52.dhcp.mtpk.ca.charter.com] has joined #ruby-lang
<epitron> within some delta
<epitron> the algorithm would go:
<epitron> current.merge_with(prev)
<epitron> move_to(prev)
<rue> I mean, I get the requirement that it shouldn't *break*
<epitron> if you do "next.merge_with(current)" you also have to make sure the next iteration is "self"
<epitron> and, you have to make sure next exists
<epitron> so that's annoying
<rue> So this is a case where a -> b -> c => ab -> c ?
<epitron> yeah
<epitron> or a,b,c,d,e,f => [a,b,c],d,[e,f]
<epitron> given some "is adjacent?" operator
<epitron> i most recently used this to group together lines in a log file by time
<epitron> dmesg was spewing out all these hard drive errors
<epitron> so i wanted to see if they clustered in time
<epitron> or if they were just random
<epitron> and group_by wouldn't work
<epitron> because the deltas are relative to each element
<epitron> *pair of elements*
<epitron> (agglomerative clustering is the technical name)
Keva161_ [Keva161_!~Keva161@78.32.156.143] has joined #ruby-lang
saLOUt [saLOUt!~rriemann@91-65-223-29-dynip.superkabel.de] has joined #ruby-lang
<epitron> you can imagine using this to do divisive clustering too
<epitron> you start with everything in one big blob, and append elements to the list as you divide them up
<epitron> another thing i'd find interesting is being able to stick partitions into a set as you're going through it
<epitron> and having the iterator know about those partitioned sets
<epitron> so you can jump around between them, or have edge-triggered things
<rue> Mm, there are some cases where in-place is desired
<rue> epitron: Have you looked at functional solutions to such cases?
<epitron> a recursive solution to clustering?
<epitron> and/or partitioning?
ryanf [ryanf!~revfitz@adsl-67-122-210-85.dsl.snfc21.pacbell.net] has joined #ruby-lang
Jake232 [Jake232!~textual@5e0e7144.bb.sky.com] has joined #ruby-lang
<rue> Clustering; not sure if it need be recursive
dbussink [dbussink!dirkjan@elle.fallingsnow.net] has joined #ruby-lang
dfr|mac [dfr|mac!~dfr|work@ool-18baf7e7.dyn.optonline.net] has joined #ruby-lang
Locke23rus [Locke23rus!~quassel@128-70-111-50.broadband.corbina.ru] has joined #ruby-lang
RomD` [RomD`!~Roman@nrbg-4d076bd7.pool.mediaWays.net] has joined #ruby-lang
heftig [heftig!jan@shine.heftig.linuxsecured.net] has joined #ruby-lang
Guest61670 [Guest61670!jan@archlinux/developer/heftig] has joined #ruby-lang
dous [dous!~dous@unaffiliated/dous] has joined #ruby-lang
arooni-mobile [arooni-mobile!~arooni-mo@201.154.131.2] has joined #ruby-lang
saLOUt [saLOUt!~rriemann@91-65-223-29-dynip.superkabel.de] has joined #ruby-lang
RubyHead [RubyHead!~rubyhead@pool-98-109-5-109.nwrknj.fios.verizon.net] has joined #ruby-lang