« Back to channel list

#ruby - 06 October 2018

« Back 1 day Forward 1 day »
[00:05:55] cschneid_: has joined #ruby
[00:06:13] schneider: has joined #ruby
[00:06:55] spiette: has joined #ruby
[00:15:04] nertzy: has joined #ruby
[00:15:33] schneider: has joined #ruby
[00:24:48] schneider: has joined #ruby
[00:29:08] graphene: has joined #ruby
[00:30:38] deadnull: has joined #ruby
[00:34:04] schneider: has joined #ruby
[00:43:23] schneider: has joined #ruby
[00:49:50] uplime: has joined #ruby
[00:52:40] schneider: has joined #ruby
[00:57:09] MoritaShinobu: has joined #ruby
[01:01:57] schneider: has joined #ruby
[01:07:20] bkxd: has joined #ruby
[01:11:32] schneider: has joined #ruby
[01:20:28] schneider: has joined #ruby
[01:29:47] schneider: has joined #ruby
[01:37:22] aleph-: has joined #ruby
[01:39:05] schneider: has joined #ruby
[01:43:27] pskosinski: has joined #ruby
[01:43:57] darkhanb: has joined #ruby
[01:48:25] schneider: has joined #ruby
[01:55:08] dbz: has joined #ruby
[01:57:35] schneider: has joined #ruby
[02:05:31] cagomez: has joined #ruby
[02:07:03] schneider: has joined #ruby
[02:15:29] chouhoulis: has joined #ruby
[02:16:19] schneider: has joined #ruby
[02:25:39] schneider: has joined #ruby
[02:26:21] tAn: has joined #ruby
[02:31:40] joast: has joined #ruby
[02:32:17] za1b1tsu: has joined #ruby
[02:33:43] cschneid_: has joined #ruby
[02:34:56] schneider: has joined #ruby
[02:44:10] schneider: has joined #ruby
[02:47:19] chouhoulis: has joined #ruby
[02:53:29] schneider: has joined #ruby
[02:54:29] zenspider: !connection schneider
[02:54:29] ruby[bot]: +bbb $a:schneider$#ruby-fix-your-connection schneider!*@*$#ruby-fix-your-connection *!*@unaffiliated/schneider$#ruby-fix-your-connection
[02:54:29] ruby[bot]: ruby[bot] kicked schneider: join/part detected
[02:54:51] devyn: has joined #ruby
[03:03:28] gix: has joined #ruby
[03:07:46] fluxAeon: has joined #ruby
[03:08:06] DecimPrime: has joined #ruby
[03:09:43] braincrash: has joined #ruby
[03:11:57] LenPayne: has joined #ruby
[03:12:51] segy: has joined #ruby
[03:16:37] bkxd: has joined #ruby
[03:18:50] tdy: has joined #ruby
[03:25:20] d^sh: has joined #ruby
[03:26:08] cschneid_: has joined #ruby
[03:35:21] apeiros: has joined #ruby
[03:37:07] orbyt_: has joined #ruby
[03:45:04] savolla: has joined #ruby
[03:51:11] chouhoulis: has joined #ruby
[03:54:19] eckhardt: has joined #ruby
[03:57:29] elphe: has joined #ruby
[04:00:52] duderonomy: has joined #ruby
[04:08:47] Puffball: has joined #ruby
[04:34:36] seggy: has joined #ruby
[04:38:33] tAn: has joined #ruby
[04:42:01] tdy: has joined #ruby
[04:42:47] nertzy: has joined #ruby
[04:55:50] cagomez: has joined #ruby
[05:15:03] nowhere_man: has joined #ruby
[05:22:14] Furai: has joined #ruby
[05:22:29] savolla: has joined #ruby
[05:24:02] duderonomy: has joined #ruby
[05:25:54] cschneid_: has joined #ruby
[05:41:49] moei: has joined #ruby
[05:55:37] apeiros: has joined #ruby
[06:02:46] elphe: has joined #ruby
[06:07:33] duderonomy: has joined #ruby
[06:11:16] dellavg_: has joined #ruby
[06:15:55] apeiros: has joined #ruby
[06:27:13] _whitelogger: has joined #ruby
[06:31:30] tAn: has joined #ruby
[06:32:43] dinfuehr: has joined #ruby
[06:34:27] cschneid_: has joined #ruby
[06:35:12] BloodyMary: has joined #ruby
[06:37:27] apeiros: has joined #ruby
[06:38:55] BloodyMary: has left #ruby: ()
[06:40:03] duderonomy: has joined #ruby
[06:41:03] c0ncealed3: has joined #ruby
[07:05:04] reber: has joined #ruby
[07:05:46] dbz: has joined #ruby
[07:05:49] za1b1tsu: has joined #ruby
[07:06:32] doubledup: has joined #ruby
[07:06:45] maasha: has joined #ruby
[07:07:22] doubledup: has joined #ruby
[07:07:53] maasha: I have an array of hashes. I want to create a new array with the first hash value for each hash?
[07:08:50] maasha: [{a: 1, b: 2}, {a: 3, b: 4}] => [1, 3]
[07:09:49] maasha: hash slice flatten?
[07:09:49] apeiros: maasha: take a look at Array#map
[07:10:27] apeiros: why slice? for slice you need to know the key, not the position
[07:12:14] maasha: yeah, inject it was. This works ary.sort_by { |e| -1 * e[:score] }.inject([]) {|a, e| a << e[:relation] }
[07:12:58] apeiros: ok, that solution has like *nothing* to do with your question
[07:13:13] maasha: some sort of Schwartzian transform ;o)
[07:13:16] apeiros: why do oyu ask for "first hash value" when you actually know the key you want hte value of?
[07:13:47] apeiros: also -1 * e[:score] is a rather overcomplicated way to say -e[:score]
[07:14:03] maasha: :oD - but it is that structure
[07:14:31] apeiros: .inject([]) {|a, e| a << e[:relation] } --> .map { |e| e[:relation] }
[07:15:07] apeiros: so: ary.sort_by { |e| -e[:score] }.map { |e| e[:relation] }
[07:15:35] maasha: apeiros: great! I love ruby golfing !
[07:16:20] apeiros: I love ruby use-the-right-tool-for-the-job :-p, the compaction of the code is just fringe benefit.
[07:16:43] apeiros: is there a verb for "concise"?
[07:18:19] apeiros: 🤣👍🏻
[07:18:51] VeryBewitching: apeiros: Distill.
[07:18:56] VeryBewitching: Probably the best fit.
[07:19:05] Radar: That word is very bewitching.
[07:22:35] phaul: has joined #ruby
[07:28:57] duderonomy: has joined #ruby
[07:35:39] duderonomy: has joined #ruby
[07:36:28] ramfjord: has joined #ruby
[07:39:49] elphe: has joined #ruby
[07:51:29] phaul: has joined #ruby
[07:53:26] tdy: has joined #ruby
[07:54:21] phaul: has joined #ruby
[07:59:19] baweaver: apeiros: Have I told you about my new crazy thing yet?
[07:59:33] apeiros: since I've been offline for a while - probably not :D
[07:59:48] baweaver: What do you think this fellow is for? - https://twitter.com/keystonelemur/status/1047935342244851712
[08:01:10] baweaver: Came up with an interesting idea while musing on how Santa can scale and deliver presents, and came to an even more interesting answer: Mrs Claus does it all
[08:01:34] baweaver: She's the one behind monitoring, logging, infra, scaling, ddos(anta) mitigation, all of it. Santa just does the deliveries
[08:01:55] baweaver: So Santa gets sick, and the lemurs get a call, which let to this fun little talk idea for December: https://gist.github.com/baweaver/512e901196d195c7dda5a3b394bd61d1
[08:02:31] baweaver: Scaling Christmas - An Illustrated Adventure in Holiday Ops
[08:03:20] LiftLeft: has joined #ruby
[08:04:14] cschneid_: has joined #ruby
[08:08:22] VeryBewitching: No reindeer in your talk, I suppose Santa has a Fedex account?
[08:09:56] baweaver: Globally sharded distribution centers running sleigh manufacturing automation plants
[08:10:39] baweaver: The reindeer didn't scale past the first 100 million
[08:11:10] baweaver: but they have been used as a regional distribution avenue
[08:11:34] VeryBewitching: The Industrial North Pole: A Competitive Analysis of Shaped Wood in Sleigh Production
[08:11:53] baweaver: They prefer carbon fiber
[08:12:13] VeryBewitching: Those are smart elves.
[08:12:15] baweaver: ( mind I'm improv'ing the heck out of this )
[08:12:47] VeryBewitching: I love the idea, it's easy to have fun with while still being productive.
[08:13:12] baweaver: and I've done exactly this when I was working at Playstation, so it makes for a more realistic story too :D
[08:13:31] baweaver: It'll only be given 3 times and be a 10-15m talk, so quite an investment
[08:13:44] baweaver: but Christmas is special, so I want to spread the cheer :)
[08:13:47] sauvin_: has joined #ruby
[08:14:11] baweaver: As to why I bring this up in October? It takes me 1-2 months to get an Illustrated Adventure ready
[08:16:45] baweaver: It's submitted to Fog City Ruby and WaffleJS in December, we'll see if they'
[08:16:48] baweaver: re interested in it
[08:24:53] ellcs: has joined #ruby
[08:25:43] apeiros: ACTION afk for a while, got to continue my target disk mode experiments… last round now :)
[08:27:41] apeiros_: has joined #ruby
[08:33:27] doubledup: has joined #ruby
[08:38:47] apeiros_: has joined #ruby
[08:41:24] doubledup: has joined #ruby
[08:48:45] xfbs: has joined #ruby
[08:55:51] conta: has joined #ruby
[09:00:09] doubledup: has joined #ruby
[09:00:37] tdy: has joined #ruby
[09:01:21] graphene: has joined #ruby
[09:01:53] sameerynho: has joined #ruby
[09:20:51] hahuang6-: has joined #ruby
[09:21:24] Fernando-Basso: has joined #ruby
[09:23:06] elphe: has joined #ruby
[09:31:04] kapil____: has joined #ruby
[09:33:22] aupadhye: has joined #ruby
[09:34:46] cschneid_: has joined #ruby
[09:36:46] ramfjord: has joined #ruby
[09:52:37] Miron: has joined #ruby
[10:15:21] Miron: has joined #ruby
[10:36:11] guardian: can someone please remind me how to solve that
[10:36:19] guardian: I'm debugging some code through rspec
[10:36:29] guardian: and I want to stop in pry with require 'pry' ; binding.pry
[10:36:42] guardian: except that rspec keeps outputing the current progress in the terminal
[10:36:48] guardian: it looks like it has a monitoring thread doing so
[10:36:53] guardian: is there a way to disable it?
[10:39:34] d^sh: has joined #ruby
[10:43:26] AJA4350: has joined #ruby
[10:46:09] dbz: has joined #ruby
[10:49:55] MyMind: has joined #ruby
[11:04:37] cschneid_: has joined #ruby
[11:14:11] DTZUZO: has joined #ruby
[11:20:02] graphene: has joined #ruby
[11:26:02] desperek: has joined #ruby
[11:26:04] DTZUZO: has joined #ruby
[11:30:38] tdy: has joined #ruby
[11:37:01] ramfjord: has joined #ruby
[12:02:02] RougeR: has joined #ruby
[12:03:32] conta: has joined #ruby
[12:07:11] xt233: has joined #ruby
[12:15:12] akem: has joined #ruby
[12:24:41] lypsis: has joined #ruby
[12:36:03] cschneid_: has joined #ruby
[12:37:04] wildermind: has joined #ruby
[12:37:43] bkxd: has joined #ruby
[12:40:20] za1b1tsu: has joined #ruby
[12:42:54] dreamthese: has joined #ruby
[12:45:19] ellcs: has joined #ruby
[12:59:02] dbz: has joined #ruby
[13:21:26] za1b1tsu: has joined #ruby
[13:27:16] ellcs: has joined #ruby
[13:27:27] al2o3-cr: has joined #ruby
[13:37:19] ramfjord: has joined #ruby
[13:39:52] nertzy: has joined #ruby
[13:41:38] al2o3-cr: has joined #ruby
[13:51:15] ramfjord: has joined #ruby
[13:52:42] sgen: has joined #ruby
[13:53:25] dbz: has joined #ruby
[13:56:34] ellcs: has joined #ruby
[13:57:20] nertzy: has joined #ruby
[13:57:52] za1b1tsu: has joined #ruby
[13:58:40] dbz: has joined #ruby
[14:00:42] tdy: has joined #ruby
[14:04:25] Dbugger: has joined #ruby
[14:04:57] cschneid_: has joined #ruby
[14:07:18] akemot: has joined #ruby
[14:13:51] Nicmavr: has joined #ruby
[14:19:27] nertzy: has joined #ruby
[14:23:27] _whitelogger: has joined #ruby
[14:25:14] dbz_: has joined #ruby
[14:29:22] GodFather: has joined #ruby
[14:31:18] twe4ked: has joined #ruby
[14:41:33] xfbs: has joined #ruby
[14:43:41] za1b1tsu: has joined #ruby
[14:50:05] chouhoulis: has joined #ruby
[15:04:42] apeiros_: has joined #ruby
[15:17:35] Tempesta: has joined #ruby
[15:18:04] dbz: has joined #ruby
[15:37:41] eckhardt: has joined #ruby
[15:49:53] za1b1tsu: has joined #ruby
[15:50:15] eckhardt_: has joined #ruby
[15:59:20] nertzy: has joined #ruby
[16:02:52] Emmanuel_Chanel: has joined #ruby
[16:03:29] tdy: has joined #ruby
[16:12:00] chouhoulis: has joined #ruby
[16:15:48] cschneid_: has joined #ruby
[16:16:13] ellcs: has joined #ruby
[16:21:42] chouhoulis: has joined #ruby
[16:24:09] Fr4n: has joined #ruby
[16:26:52] za1b1tsu: has joined #ruby
[16:31:29] duderonomy: has joined #ruby
[16:33:20] rprimus: has joined #ruby
[16:36:20] za1b1tsu: has joined #ruby
[16:40:07] bmurt: has joined #ruby
[16:40:20] Emmanuel_Chanel: has joined #ruby
[16:47:04] cschneid_: has joined #ruby
[17:08:59] ogotai: has joined #ruby
[17:10:14] orbyt_: has joined #ruby
[17:11:30] ogotai: folks, what am I doing wrong with regexp repetition - if my input == ", a=true, c='d'", then this works - /^([, \w]*=['\w]*)([, \w]*=['\w]*)$/.match(input) --- but this doesn't - /^([, \w]*=['\w]*){2}$/.match(input)
[17:12:04] ogotai: it's exactly the same regex, second instance I'm just doing (pattern){2}, instead of (pattern)(pattern), and yet the (pattern){2} fails
[17:13:11] ogotai: when I say fails, it just matches the second instance, the ", c='d'" part of the string
[17:18:23] RougeR: has joined #ruby
[17:19:22] baweaver: ogotai: What exactly are you trying to do?
[17:20:18] baweaver: Could you not use `input.split(/, */).map { |pair| pair.split('=') }` ?
[17:21:57] za1b1tsu: has joined #ruby
[17:23:34] ogotai: baweaver: I could, but it's a much longer string with other complications, I thought I could have a nicely crafted regex to extract all I need and just iterate over match data
[17:23:50] baweaver: If you can avoid complicated regex, do so.
[17:24:02] ogotai: and now that it got under my skin, I'm really curious why this regex doesn't work :)
[17:24:24] ogotai: I know, it became an obsession more than anything
[17:27:35] baweaver: rubular.com
[17:27:46] baweaver: That helps get a visual of why something does or does not work.
[17:31:15] ogotai: same result, I expect 2 match groups, but getting 1 -- http://rubular.com/r/nNir8FGbGY
[17:31:42] ogotai: I'm reading that "".scan() possibly behaves in the way I want, and .match() might not...
[17:31:55] ogotai: though not getting out of "".scan() the desired result either
[17:33:22] eckhardt: has joined #ruby
[17:34:51] ogotai: okay, success -- input.scan(/([, \w]*=['\w]*)/) -- just had to abandon any indication of repetition in the regex itself (i.e. the {2} thing), and use String#scan() instead of Regexp#match() - ruby can be sometimes confusing
[17:37:11] apeiros_: ogotai: just replacing the second group with {2} still matches for me
[17:37:22] apeiros_: but ruby's regex engine does not repeat capturing groups
[17:37:35] apeiros_: so if you quantify a capturing group, you'll only get the last substring it matches
[17:38:06] apeiros: personally I'd prefer if it'd match as arrays (or nested arrays in case of nested quantified capturing groups)
[17:38:22] apeiros: (or hashes and nested hashes/arrays in case of named capturing groups)
[17:38:42] ogotai: apeiros: yep, although supposedly (?=(regex)) is backtracking and matching everything, but that didn't work for me either
[17:39:00] apeiros: (?=) is a lookahead and does not consume
[17:39:12] apeiros: backtracking is a different mechanism
[17:41:06] ogotai: I see, well, there probably is a way to do this in match(), but seems like scan() is nicely returning all repeating matches as array, so happy with that
[17:41:26] apeiros: there is no way with quantified captures. rubys regex engine simply doesn't do that.
[17:42:09] apeiros: and yes, scan can be a way around that. and if scan is insufficient, there's also its bigger sibling StringScanner
[17:48:06] ogotai: thanks, will look into StringScanner
[18:02:49] al2o3-cr: has joined #ruby
[18:09:54] thinkpad: has joined #ruby
[18:19:52] dbz: has joined #ruby
[18:20:42] dbz: has joined #ruby
[18:20:59] dbz_: has joined #ruby
[18:29:36] xfbs: has joined #ruby
[18:30:08] Fr4n: has joined #ruby
[18:41:52] apeiros__: has joined #ruby
[18:41:56] agent_white: has joined #ruby
[19:02:58] Vapez: has joined #ruby
[19:07:44] pabs: has joined #ruby
[19:09:25] za1b1tsu: has joined #ruby
[19:16:50] grenierm: has joined #ruby
[19:23:00] doubledup: has joined #ruby
[19:23:57] dbz: has joined #ruby
[19:24:21] craysiii: has joined #ruby
[19:24:50] dbz: has joined #ruby
[19:30:02] thinkpad: has joined #ruby
[19:37:08] Pisuke: has joined #ruby
[19:39:15] grenierm: has joined #ruby
[19:42:18] Sembei: has joined #ruby
[19:52:02] dbz: has joined #ruby
[20:08:41] Puffball: has joined #ruby
[20:21:30] themsay: has joined #ruby
[20:38:28] al2o3-cr: has joined #ruby
[20:39:18] zenspider: ogotai: you might prefer split
[20:44:30] mroutis: has joined #ruby
[20:45:57] cagomez: has joined #ruby
[20:46:01] tdy: has joined #ruby
[20:52:45] za1b1tsu: has joined #ruby
[20:59:09] duderonomy: has joined #ruby
[21:00:20] cagomez: has joined #ruby
[21:03:18] mroutis: has joined #ruby
[21:05:43] mroutis: What's a good way to read from IO (line by line) without a huge memory impact?
[21:10:16] IanMalcolm: has joined #ruby
[21:16:37] elphe: has joined #ruby
[21:32:16] Nicmavr: has joined #ruby
[21:32:38] al2o3-cr: mroutis: i think they're changing buffers.
[21:33:12] al2o3-cr: at a guess anyway.
[21:33:28] mroutis: ohh, right
[21:34:04] uplime: to a very important one too
[21:42:00] clemens3: has joined #ruby
[21:43:33] apeiros: mroutis: sure, IO#foreach f.ex.
[21:44:09] apeiros: or things like IO#each_line, #gets, #read with a length arg, etc.
[21:44:11] mroutis: apeiros: what about each_line?
[21:44:19] mroutis: right, thanks
[21:44:50] apeiros: well, re #each_line - unless you have other things to do with the IO, there no point in needing the added code.
[21:45:39] mroutis: what added code are you refering to?
[21:47:00] akem: has joined #ruby
[21:48:26] dbz: has joined #ruby
[21:53:28] apeiros: mroutis: well, you have to open the file in order to have a filehandle to call #each_line on it
[21:56:41] mroutis: ohh, silly me, I was doing ARGF.each_line, wondering why it was consuming a lot of memory; I guess is trying to read everything at once
[22:07:45] apeiros: no, it doesn't
[22:08:09] apeiros: but feel free to gist your full code. maybe you do something which causes memory bloat
[22:09:43] xfbs: has joined #ruby
[22:19:09] IanMalcolm: has joined #ruby
[22:23:48] mroutis: sure, apeiros, I was trying to solve the first and easiest codechef problem using ruby: https://www.codechef.com/viewsolution/18471591
[22:24:45] mroutis: basically, you've a file with numbers, and you output just the lines that have `42` included
[22:25:02] apeiros: mroutis: that doesn't look like it should consume a lot of memory. unless your lines are huge.
[22:25:08] mroutis: using sed, it would be `sed -n /42/p`
[22:25:18] mroutis: lines are just a number
[22:25:40] mroutis: if you have a look at the proposed solution in their dashboard, it says that it consumes 28M !
[22:25:43] mroutis: https://www.codechef.com/status/TEST,mroutis?sort_by=Mem&sorting_order=asc&language=All&status=All
[22:25:48] RougeR: has joined #ruby
[22:25:49] apeiros: break means it'll stop at the first 42
[22:26:07] apeiros: 28M might just be ruby + rubygems tbh :D
[22:27:23] mroutis: ACTION facepalm
[22:27:24] apeiros: hm, though on my machine it's 11MB
[22:27:42] mroutis: right, it stops at the first 42 number
[22:28:34] mroutis: so, it would be `sed -n 1,/42/p`
[22:30:15] mroutis: It's weird, apeiros, because there are other solutions consuming 0M of memory
[22:30:27] mroutis: take a look https://www.codechef.com/status/TEST?sort_by=Mem&sorting_order=asc&language=17&status=All&Submit=GO
[22:31:22] apeiros: 0M of memory is quite amazing. it means it doesn't even start ruby 😂
[22:31:30] mroutis: everyone is doing this `gets.chomp` thingy; it's more fun if you can write "efficient" and readable code
[22:31:58] mroutis: I think they don't take into account the memory accumulated before running the code
[22:36:02] apeiros: not quite sure why it says your would use 28MB. the solution looks sensible (apart from the break vs. next mistake).
[22:37:04] apeiros: also not quite sure why the topmost solution uses chomp. to_i will throw away the newline anyway.
[22:40:19] za1b1tsu: has joined #ruby
[22:40:25] apeiros: hm, though those solutions all do stop at the first 42
[22:42:17] mroutis: yes, I misread my code, apeiros ... I thought it was intended to output just `42` (the `next` solution), but it's about printing until you match the first 42 (`break` one)
[22:42:29] mroutis: sorry for that one, hehe
[22:46:16] mroutis: lol, I copypasted the solution with 0M and submitted it again with my account
[22:47:19] mroutis: I don't know if they are loading more stuff than needed, or it is the base runtime memspace of ruby 2.3.3
[22:48:50] mroutis: well, mystery solved, thank you a lot, apeiros, it was bugging me like crazy
[22:51:07] Freshnuts: has joined #ruby
[22:54:54] duderonomy: has joined #ruby
[22:56:09] apeiros: mroutis: good to know. I guess their instrumentation was not updated along with other things.
[23:02:00] duderonomy: has joined #ruby
[23:41:13] beeman: has joined #ruby