« Back to channel list

#ruby - 26 December 2018

« Back 1 day Forward 1 day »
[00:02:26] Swyper: has joined #ruby
[00:04:27] spacesuitdiver: has joined #ruby
[00:30:36] davidw: has joined #ruby
[00:40:47] hutch: has joined #ruby
[00:50:22] RougeR: has joined #ruby
[01:12:39] sarink: has joined #ruby
[01:15:25] sotrhraven: has joined #ruby
[01:34:28] hutch: has joined #ruby
[01:36:24] sarink: has joined #ruby
[01:38:27] tiff: has joined #ruby
[01:55:01] cschneid: has joined #ruby
[02:00:40] sgen: has joined #ruby
[02:17:41] donofrio: has joined #ruby
[02:33:03] hutch: has joined #ruby
[02:34:38] spacesuitdiver: has joined #ruby
[02:45:10] _whitelogger: has joined #ruby
[02:47:34] nchambers: has joined #ruby
[02:49:05] esrse: has joined #ruby
[02:57:50] ellcs: has joined #ruby
[03:06:10] _whitelogger: has joined #ruby
[03:15:34] clemens3: has joined #ruby
[03:23:21] tdy: has joined #ruby
[03:44:00] moei: has joined #ruby
[03:54:10] _whitelogger: has joined #ruby
[04:05:45] sgen: has joined #ruby
[04:10:43] braincrash: has joined #ruby
[04:14:40] kapil____: has joined #ruby
[04:24:34] cschneid: has joined #ruby
[04:26:07] Nicmavr: has joined #ruby
[04:27:42] hutch: has joined #ruby
[04:40:34] tdy: has joined #ruby
[04:47:31] Exuma: has joined #ruby
[04:51:51] tdy: has joined #ruby
[04:54:55] elphe: has joined #ruby
[05:04:21] darkhanb: has joined #ruby
[05:06:21] marz_d`ghostman: has joined #ruby
[05:10:31] elphe: has joined #ruby
[05:10:36] tdy: has joined #ruby
[05:18:25] cschneid: has joined #ruby
[05:45:43] cthu|: has joined #ruby
[05:46:13] paranoicsan: has joined #ruby
[05:49:40] rippa: has joined #ruby
[05:56:16] tdy: has joined #ruby
[06:06:25] elphe: has joined #ruby
[06:07:52] donofrio: has joined #ruby
[06:20:11] tdy: has joined #ruby
[06:24:17] aupadhye: has joined #ruby
[06:26:25] Mia: has joined #ruby
[06:27:49] marz_d`ghostman: How do I capture my thread's output and error? https://gist.github.com/marzdgzmn/dc6e8992a353ecf9ed2384b2cb987c3a When I manually run the class itself, the one that should be run on a different thread, it gives me errors. But if I run it on a different thread the errors/output doesn't come up
[06:47:00] cnsvc: has joined #ruby
[07:05:30] dellavg_: has joined #ruby
[07:18:28] Exuma: has joined #ruby
[07:23:11] za1b1tsu: has joined #ruby
[07:23:56] cschneid: has joined #ruby
[07:29:18] Exuma: has joined #ruby
[07:29:37] yqrashawn: has joined #ruby
[07:44:24] tiff: has joined #ruby
[07:49:35] Exuma: has joined #ruby
[07:50:21] cruzo66342: has joined #ruby
[07:55:05] elphe: has joined #ruby
[07:55:45] Exuma: has joined #ruby
[08:17:22] Exuma: has joined #ruby
[08:35:12] paranoicsan: has joined #ruby
[08:41:34] yqrashawn: has joined #ruby
[08:45:58] jmcgnh: has joined #ruby
[08:55:09] alxd: has left #ruby: ("Leaving")
[09:14:53] yqrashawn: has joined #ruby
[09:19:45] venmx: has joined #ruby
[09:22:16] evdubs: has joined #ruby
[09:41:41] ur5us: has joined #ruby
[09:42:47] elphe: has joined #ruby
[09:50:49] laaron: has joined #ruby
[09:51:02] cruzo66342: has joined #ruby
[09:52:53] Calinou: has joined #ruby
[10:00:53] Calinou: hi, I'm writing a Jekyll plugin as a convenience method (implementing cache busting) so I'm looking up keys in a hash. However, I can't look up the hash by an object property (which is a string) but I can look it up by a string assigned to a variable
[10:01:09] MasterAsia: has joined #ruby
[10:02:13] Calinou: that's the code I'm using for testing: https://dpaste.de/r23m
[10:02:30] laaron: has joined #ruby
[10:02:36] Calinou: I'll make it clear Ruby isn't a language I use often, but this still puzzles me… I haven't found anything online about that
[10:03:48] yqrashawn: has joined #ruby
[10:19:18] phaul: Calinou: first glance I can't spot anything, it should work. Can you puts @text == '/static/main.js'? If false it's possible that some non-visible UTF-8 char is in @text
[10:20:37] pwnd_nsfw: has joined #ruby
[10:21:27] phaul: the other possibility is if some gem or code messed with String#hash
[10:22:18] gix: has joined #ruby
[10:22:33] Calinou: looks like it's always returning false :(
[10:22:57] Calinou: I'm using a Liquid tag of the form {% asset '/static/main.js' %} to call it
[10:27:05] phaul: So I don't think @text is a String. You can verify by puts ing its class. puts @text.class. Therefore it's not found in the hash.
[10:29:09] Calinou: I did that, it's a String
[10:32:15] phaul: but it's not equal to '/static/main.js' but when printed looks like it. So maybe indeed it contains some non visible differences. check their lengths
[10:33:54] cthulchu_: has joined #ruby
[10:34:30] Calinou: I compared the lengths of a version stripped from its non-ASCII characters and it's the same
[10:34:49] Calinou: like this: https://dpaste.de/8tBq
[10:38:51] phaul: weird. Assuming that String#== is not overriden eqaul strings should be equal
[10:39:12] phaul: &>> @a = 'text'; @a == 'text'
[10:39:14] rubydoc: # => true (https://carc.in/#/r/5uuv)
[10:42:15] tdy: has joined #ruby
[10:47:28] phaul: Calinou: print their .encoding
[10:47:36] phaul: maybe that's different
[10:48:28] Calinou: they're both in UTF-8
[11:01:12] laaron: has joined #ruby
[11:02:12] laaron: has joined #ruby
[11:03:00] yqrashawn: has joined #ruby
[11:03:13] laaron: has joined #ruby
[11:04:12] laaron: has joined #ruby
[11:05:42] laaron: has joined #ruby
[11:06:43] laaron: has joined #ruby
[11:07:44] laaron: has joined #ruby
[11:10:28] tdy: has joined #ruby
[11:28:06] yqrashawn: has joined #ruby
[11:35:15] Calinou: phaul: I solved my problem by using an include file as a Liquid function of sorts :) this will do for now
[11:36:29] phaul: cool. I don't get what that means but important thing is that it works :)
[11:36:51] Calinou: http://hamishwillee.github.io/2014/11/13/jekyll-includes-are-functions/
[11:44:04] yqrashawn: has joined #ruby
[11:45:06] cthu|: has joined #ruby
[11:50:18] cschneid: has joined #ruby
[11:52:53] aonemd: has joined #ruby
[11:54:23] reber: has joined #ruby
[11:56:02] r3m: has joined #ruby
[11:57:40] cthulchu_: has joined #ruby
[12:08:47] yqrashawn: has joined #ruby
[12:48:42] yqrashawn: has joined #ruby
[12:59:56] marz_d`ghostman: What does catch(:halt) { yield } do? I know it catches the thrown :halt but what does the { yield } do? I don't see anywhere it's being used with a block passed to it
[13:00:03] marz_d`ghostman: https://github.com/sinatra/sinatra/blob/v1.4.6/lib/sinatra/base.rb#L1066
[13:11:24] yqrashawn: has joined #ruby
[13:26:59] tbuehlmann: marz_d`ghostman: https://github.com/sinatra/sinatra/blob/v1.4.6/lib/sinatra/base.rb#L1081-L1085 for example
[13:30:49] AJA4350: has joined #ruby
[13:31:44] cow[moo]: has joined #ruby
[13:36:59] yqrashawn: has joined #ruby
[13:41:39] kapil____: has joined #ruby
[13:42:17] canton7: has joined #ruby
[13:45:58] elphe: has joined #ruby
[13:46:45] claudiuinberlin: has joined #ruby
[13:52:17] cruzo66342: has joined #ruby
[14:05:13] marz_d`ghostman: tbuehlmann: Oh, I see, so the block is passed to invoke, thanks.
[14:15:22] yqrashawn: has joined #ruby
[14:19:04] cschneid: has joined #ruby
[14:19:35] nchambers: has joined #ruby
[14:25:29] RougeR: has joined #ruby
[14:26:44] RougeR: has joined #ruby
[14:38:02] mostlybadfly: has joined #ruby
[14:40:55] venmx: has joined #ruby
[14:45:16] cruzo66342: has joined #ruby
[14:50:18] Rapture: has joined #ruby
[14:51:11] hiroaki: has joined #ruby
[15:02:29] cruzo66342: has joined #ruby
[15:05:47] Nicmavr: has joined #ruby
[15:09:06] Xiti: has joined #ruby
[15:18:55] Mike11: has joined #ruby
[15:23:37] venmx: has joined #ruby
[15:26:55] elphe: has joined #ruby
[15:28:42] agent_white: has joined #ruby
[15:29:20] MasterAsia: has joined #ruby
[15:29:33] agent_white: has joined #ruby
[15:43:06] donofrio: has joined #ruby
[15:44:07] cruzo66342: has joined #ruby
[15:44:40] marz_d`ghostman: has joined #ruby
[15:44:53] marz_d`ghostman: Anyone using concurrent-ruby gem? How do I rescue exception from threads? thread_pool = Concurrent::FixedThreadPool.new(10, max_queue:50) until job_list.empty? job = job_list.shift Concurrent::Promises.future(executor: thread_pool) { MyJob.run(job) }. rescue{ |e| puts e }.result end
[15:45:05] marz_d`ghostman: Sorry, mispasted it, I meant: https://gist.github.com/marzdgzmn/37ef33a17716fae30db86446b4d8b769
[15:45:16] marz_d`ghostman: Doesn't seem to work
[15:45:49] cschneid: has joined #ruby
[15:46:12] cruzo66342: has joined #ruby
[15:46:43] Sembei: has joined #ruby
[15:54:14] neuraload: has joined #ruby
[15:56:03] marz_d`ghostman: I was missing the .result at the end though :)
[16:01:18] yqrashawn: has joined #ruby
[16:09:14] sarink: has joined #ruby
[16:15:03] Xiti: has joined #ruby
[16:19:39] donofrio: has joined #ruby
[16:20:19] davidw: has joined #ruby
[16:20:36] Xiti`: has joined #ruby
[16:22:04] Xiti`: has joined #ruby
[16:27:01] yqrashawn: has joined #ruby
[16:37:57] sgen: has joined #ruby
[16:39:06] cthu|: has joined #ruby
[16:45:14] cruzo66342: has joined #ruby
[17:00:48] donofrio: has joined #ruby
[17:09:15] RougeR: has joined #ruby
[17:10:11] hays: what is truffleruby?
[17:11:04] cschneid: has joined #ruby
[17:13:18] gitness: has joined #ruby
[17:15:04] darkhanb: has joined #ruby
[17:15:20] ua: has joined #ruby
[17:15:44] havenwood: hays: It's an implementation of Ruby.
[17:16:19] hays: saw it pop up when checking out the new 2.6
[17:16:24] polishdub: has joined #ruby
[17:16:26] hays: (when doing ruby-install)
[17:16:54] havenwood: hays: It's fun to contribute to as a Rubyist, since much of core is implemented in pure Ruby.
[17:17:25] havenwood: hays: The other perks are performance and language interop on the GraalVM.
[17:18:03] hiroaki: has joined #ruby
[17:18:35] hays: reading about it--never heard of the Graal VM
[17:18:50] havenwood: At 46.5% Ruby, it's the highest percent Ruby of any of the Ruby implementations.
[17:23:40] twobitsprite: has joined #ruby
[17:24:23] ellcs: has joined #ruby
[17:31:15] cschneid: has joined #ruby
[17:32:08] \void: has joined #ruby
[17:38:18] sarink: has joined #ruby
[17:38:58] spacesuitdiver: has joined #ruby
[17:44:44] cschneid: has joined #ruby
[17:48:23] kapil____: has joined #ruby
[17:48:58] spacesuitdiver: has joined #ruby
[18:09:10] _whitelogger: has joined #ruby
[18:12:50] hutch: has joined #ruby
[18:13:53] ixti: has joined #ruby
[18:24:31] hays: i have been programming in Ruby for a while now and i feel a bit stuck. Not sure I really 'get it' and always feel like im fighting against the language
[18:24:44] prestorium: has joined #ruby
[18:31:34] Exuma: has joined #ruby
[18:32:35] hays: i think im missing a high level view of the philosophy of the language and how things are supposed to fit together
[18:33:43] phaul: hays: is the object model clear to you?
[18:34:05] phaul: if not digging into that could help I think
[18:34:46] hays: hmm.. do you mean generally what an object is with reference to OOP?
[18:35:39] phaul: I mean in Ruby. Modules vs Classes , Meta classes. include, extend prepend etc
[18:36:12] sarink: has joined #ruby
[18:36:15] hays: then i must admit I am not clear
[18:36:41] hays: modules vs. classes has been a point of confusion for me--when I've tried to use them they haven't worked how i expect
[18:36:56] phaul: if you google ruby object model you should find some material
[18:37:19] cthulchu_: has joined #ruby
[18:37:39] hays: i'll check it out
[18:38:18] phaul: there is a youtube vid (with Dave Thomas) that's my fav, but it takes him some time to get into the topic, and also some might find his style a bit too much.
[18:41:13] gnarmis: has joined #ruby
[18:49:29] donofrio: has joined #ruby
[18:50:14] raulp: has joined #ruby
[18:52:24] agent_white: has joined #ruby
[18:55:58] laaron: has joined #ruby
[19:03:23] laaron: has joined #ruby
[19:06:53] gnarmis: has joined #ruby
[19:07:51] hutch: has joined #ruby
[19:09:16] sarink: has joined #ruby
[19:11:30] spacesuitdiver: has joined #ruby
[19:11:38] arand: has joined #ruby
[19:11:42] hays: i think im watching it
[19:11:56] hays: the medium article i read ended at part 1
[19:14:10] sonofentropy: has joined #ruby
[19:17:58] agent_white: has joined #ruby
[19:18:18] armyriad: has joined #ruby
[19:19:24] hutch: has joined #ruby
[19:29:33] jaj8: has joined #ruby
[19:31:53] trif: has left #ruby: ()
[19:37:40] jaj8: has joined #ruby
[19:41:03] sarink: has joined #ruby
[19:51:55] donofrio: has joined #ruby
[19:52:00] ellcs: has joined #ruby
[19:53:10] sarink: has joined #ruby
[19:58:55] ur5us: has joined #ruby
[20:03:04] laaron: has joined #ruby
[20:05:15] code_zombie: has joined #ruby
[20:16:18] Inline: has joined #ruby
[20:17:48] hays: phaul: good video
[20:18:42] phaul: it's a bit dated now, but concepts are still the same. prepend did not exist back then
[20:25:21] sgen: has joined #ruby
[20:30:56] sonofentropy: has joined #ruby
[20:38:32] spacesuit: has joined #ruby
[20:42:53] Inline: has joined #ruby
[20:50:29] hays: i'll read about prepend
[20:50:54] hays: what about design? e.g. how to use these concepts with coherence
[20:51:19] spacesuitdiver: has joined #ruby
[20:55:57] Exuma: has joined #ruby
[20:57:43] donofrio: has joined #ruby
[21:02:52] phaul: there are books on the subject especially Sandy Metz wrote about Ruby and OOP and she did presentations on various rubyconfs about design. but to me it's always a bit foggy how you reach a design from a specification. For me it's usually trial and error
[21:03:23] laaron: has joined #ruby
[21:07:12] phaul: tbh it's also foggy to me how to write a specification. I don't beleive anyone actually does a formal spec anywhere. but if they did rspec would be a tool, maybe.
[21:12:47] hays: well in an agile environment the spec changes and can be a result of a bit amorphous set of features
[21:13:13] hays: but i suppose you look at the backlog and do your best to think ahead about it
[21:14:29] phaul: yeah, I think this is the part that you can't learn from books, or formulate how to do. You do it a lot and at some point you are better in it :)
[21:14:35] hays: the code i write tends to start as a script with a bunch of stuff i guess in main
[21:14:54] hays: i get tripped up transisioning this into reusable code
[21:16:07] hays: i guess i can put functions in modules and then in my main use extend
[21:21:52] tfitts: has joined #ruby
[21:21:56] phaul: I think if you deepen your understanding of these language tools, it will become easier to move code around
[21:22:18] arand: has joined #ruby
[21:27:08] sarink: has joined #ruby
[21:40:21] MasterAsia: has joined #ruby
[21:47:17] Exuma: has joined #ruby
[21:51:33] elphe: has joined #ruby
[21:55:14] cthu|: has joined #ruby
[21:55:24] sonofentropy: has joined #ruby
[21:58:31] uplime: is it possible to make classes private to a module?
[21:59:24] lupine: maybe you want private_constant. I wouldnt though
[22:00:16] al2o3-cr: &>> module Foo class Bar def bar() 42 end end; private_constant :Bar end; Foo::Bar.new
[22:00:20] rubydoc: # => private constant Foo::Bar referenced (NameError) (https://carc.in/#/r/5uzx)
[22:07:00] laaron: has joined #ruby
[22:15:11] _whitelogger: has joined #ruby
[22:15:54] planigan: has joined #ruby
[22:20:48] phaul: &>> module Foo class Bar def bar; 42 end; end; def self.x; Bar; end; private_constant :Bar; end; Foo.x.new
[22:20:49] rubydoc: # => #<Foo::Bar:0x0000564a92c83218> (https://carc.in/#/r/5v05)
[22:21:43] phaul: so it's really just the constant
[22:22:18] al2o3-cr: sure, nothing is really private.
[22:26:04] al2o3-cr: &>> module Foo class Bar def bar() 42 end end; private_constant :Bar end; Foo.const_get(:Bar).new.bar
[22:26:05] rubydoc: # => 42 (https://carc.in/#/r/5v09)
[22:26:32] lupine: you really need a process boundary to protect anything from malicious users with eval rights in ruby
[22:30:19] tdy: has joined #ruby
[22:31:43] phaul: I don't know about any language where visibility scopes mean actual protection in security sense. I don't think there is one, but could be wrong.
[22:32:08] phaul: c++ you just get to the address and cast
[22:36:53] Exuma: has joined #ruby
[22:37:54] phaul: maybe some domain languages like SQL stored procedures etc
[22:39:08] tiff: has joined #ruby
[22:48:12] baweaver: I bring fun and more Ruby hackery! Rejoice! - https://medium.com/@baweaver/mf-abusing-rubys-operator-precedence-ccf3f071bad8
[22:51:15] al2o3-cr: baweaver: there is also >> for inverse order.
[22:51:33] baweaver: Yep. I should probably note that.
[22:52:09] al2o3-cr: aye, nice write up also.
[22:57:45] baweaver: al2o3-cr: 26 articles down so far this year
[22:57:53] hutch: has joined #ruby
[22:57:57] baweaver: Wonder if I can get up to 30 by end of year.
[22:59:13] al2o3-cr: 4 articles in 5 days no problem hehe ;)
[23:00:50] baweaver: Technically I have a few articles in half-state I just haven't finished, so there's three
[23:00:51] baweaver: then one more RubyConf recap probably
[23:02:10] al2o3-cr: it'll be close tbh ;)
[23:03:12] laaron-: has joined #ruby
[23:03:56] al2o3-cr: but should be doable.
[23:05:23] al2o3-cr: hey, baweaver; def up(s) s.upcase end; def re(s) s.reverse end; ["foo", "bar", "baz"].map &method(:up) << method(:re)
[23:05:37] al2o3-cr: also works on Method too.
[23:05:56] baweaver: Yep, and I'll likely do an entire writeup on that part of it
[23:06:17] al2o3-cr: only just really looking through 2.6 new features myself.
[23:06:50] baweaver: Still drafting this one: https://medium.com/@baweaver/exploring-ruby-2-6-proc-compose-and-enumerator-chain-49f10e237542
[23:06:52] baweaver: Was really hoping that .: got into 2.6, so I'll have to rewrite that section of it.
[23:07:36] al2o3-cr: yeah Enumarable#chain is pretty cool.
[23:07:58] al2o3-cr: (1..10).each.+([*?a..?f]) { ... }
[23:08:26] lupine: oh very nice
[23:08:45] al2o3-cr: Enumerator#chain sorry
[23:09:08] baweaver: Still need to finish that one out
[23:09:50] al2o3-cr: i quite like this one: ((1..20).%(4)).to_a #=> [1, 5, 9, 13, 17]
[23:10:21] al2o3-cr: chain is aliased to + & step is aliased to %
[23:11:28] baweaver: I'm still convinced that's just so Mame could code golf more cleanly :P
[23:12:20] phaul: but why is it .% ? why the . if % is an operator?
[23:13:03] al2o3-cr: ((1..)%(4)).take(10) phaul this is valid.
[23:13:17] phaul: ah. cool.
[23:14:43] al2o3-cr: as is (1..10).each+[23..33]
[23:16:54] agent_white: has joined #ruby
[23:18:14] al2o3-cr: baweaver: is this is intended? .then(&JSON.:parse)
[23:18:50] baweaver: I was hoping that 2.6 had the method shorthand
[23:18:50] baweaver: but it doesn't and that article isn't published so I intended to fix it ltaer.
[23:19:10] al2o3-cr: ah.. i see.
[23:21:01] baweaver: Eh, why not, let's finish it off right quick
[23:21:51] al2o3-cr: nifty example at the end there baweaver
[23:21:58] phaul: random pondering.. would ((1..).each + (1..).each).take(10) run for ever or work..
[23:21:59] baweaver: brb, 30m or so, need to think of some contrived examples
[23:22:50] al2o3-cr: phaul: you don't need the last each
[23:23:09] al2o3-cr: and it works
[23:25:36] phaul: i havent looked at any of 2.6 in any detail yet, but as soon as arch releases the new packages Im updating :)
[23:25:47] Exuma: has joined #ruby
[23:26:16] al2o3-cr: phaul: that'll be next year then.
[23:27:51] al2o3-cr: always seems forever before it comes out of testing.
[23:28:09] phaul: especially if its a new ruby release ;)
[23:28:47] al2o3-cr: aye for ruby, python is generally within a day or so.
[23:29:53] al2o3-cr: actually i think they had a problem merging 2.5 last year, can't remember the details now though.
[23:34:46] al2o3-cr: i got it wrong twice; Enumerable#chain & Enumerator#+ (that better be right ;)
[23:34:50] bga57: has joined #ruby
[23:35:31] phaul: I guess because Array#+ and such would collide
[23:36:10] phaul: have you tried --jit yet?
[23:36:56] al2o3-cr: phaul: no, not really. i don't write anything big enough to probably take advantage of it.
[23:42:48] tdy: has joined #ruby
[23:46:03] elphe: has joined #ruby
[23:47:01] al2o3-cr: phaul: you can now do this too: (?a..?e).to_h { |v| [v, v.ord] } # without using map and then an extra method call to to_h
[23:47:16] al2o3-cr: which i think is pretty handy tbh.
[23:48:12] phaul: yeah I saw that on the channel few days back, but until one starts using these things in practise one forgets.. :)
[23:54:22] phaul: &>> "you have to learn new stuff, rubydoc"..
[23:54:23] rubydoc: # => (https://carc.in/#/r/5v0m)
[23:59:42] baweaver: https://medium.com/@baweaver/exploring-ruby-2-6-proc-compose-and-enumerator-chain-49f10e237542