« Back to channel list

#ruby - 09 October 2018

« Back 1 day Forward 1 day »
[00:02:38] improv42: has joined #ruby
[00:04:31] ansraliant: has joined #ruby
[00:08:44] c0ncealed3: has joined #ruby
[00:09:58] bmurt: has joined #ruby
[00:34:04] asphyxia: has joined #ruby
[00:35:40] moei: has joined #ruby
[00:36:10] orbyt_: has joined #ruby
[00:39:57] dbz: has joined #ruby
[00:45:20] dbz: has joined #ruby
[00:51:49] uplime: has joined #ruby
[00:52:21] asphyxia: has joined #ruby
[00:58:33] marahin: has joined #ruby
[00:59:03] lyr: has joined #ruby
[01:01:00] EXCHGR: has joined #ruby
[01:01:04] TheBrayn: has joined #ruby
[01:18:43] P1RATEZ: has joined #ruby
[01:23:19] Dimik: has joined #ruby
[01:27:51] tdy: has joined #ruby
[01:33:05] DTZUZO: has joined #ruby
[01:43:55] za1b1tsu: has joined #ruby
[01:52:12] cagomez: has joined #ruby
[02:13:12] ajsharma: has joined #ruby
[02:21:47] francisco: has joined #ruby
[02:37:55] orbyt_: has joined #ruby
[02:55:09] ruby[bot]: -bbb $a:schneider$#ruby-fix-your-connection schneider!*@*$#ruby-fix-your-connection *!*@unaffiliated/schneider$#ruby-fix-your-connection
[02:56:54] mroutis: has joined #ruby
[03:11:11] braincrash: has joined #ruby
[03:15:17] podlech: has joined #ruby
[03:16:50] dellavg_: has joined #ruby
[03:18:17] orbyt_: has joined #ruby
[03:32:28] podlech: has joined #ruby
[03:53:26] arescorpio: has joined #ruby
[04:34:44] cagomez: has joined #ruby
[04:37:13] sarmiena_: has joined #ruby
[04:42:55] sarmiena_: has joined #ruby
[04:45:06] Radar: 2 protips for junior rubyists: 1( attr_reader != attr_accessor (plz learn the difference) 2) keyword arguments were added in Ruby 2.0 (circa end of 2013) and will drastically reduce the code you write in initialize. Please use them.
[04:45:16] Radar: Signed, someone who is reviewing many, many junior Rubyist coding tests.
[04:46:00] Radar: THIRD BONUS PROTIP: Look at the Enumerable module. Gaze into it. Let it envelope you. `find` yourself within it. `select` from it particular methods that will help you. `each_with_object`, etc, etc, etc.
[04:48:00] baweaver: Oh come now Radar, that's just sad, only two enumerable puns? I reject that notion
[04:48:42] Radar: baweaver: Sorry, I was all? out of puns. I didn't have any? more.
[04:49:15] Radar: But now I am reading the documentation to .collect some more. I'll tell you the .first one I come across. p.s. inject is bad okay
[04:49:49] baweaver: I'm sure you'll filter out a few more (bonus for 2.6 syntax :D )
[04:49:57] Radar: each_with_object is much much better
[04:50:10] uplime: what are keyword arguments?
[04:50:17] baweaver: There are cases for reduce
[04:50:21] uplime: oh, foo(bar: baz, bing: bingo) ?
[04:50:45] baweaver: def adds(a:, b:) a + b end
[04:50:46] baweaver: adds(a: 1, b: 2) # => 3
[04:51:48] Radar: https://robots.thoughtbot.com/ruby-2-keyword-arguments
[04:52:05] Radar: ^ The blog post I have linked to about 15 times during these junior code review feedback writeups
[04:52:14] Radar: And blocks support keyword args too
[04:52:45] baweaver: Which is super fun with hashes :D
[04:53:03] baweaver: >> [{ a: 1 }, { b: 2 }].map { |a: 1, b: 2| a + b }
[04:53:09] ruby[bot]: baweaver: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `[]' for nil:NilClass
[04:53:37] Radar: ruby[bot]: just plz stop
[04:53:43] Radar: ruby[bot]: you're not even trying any more
[04:59:21] AKPWD: has joined #ruby
[05:01:38] eckhardt: has joined #ruby
[05:02:41] Cyrus: has joined #ruby
[05:08:07] Cyrus: has joined #ruby
[05:09:29] shakes: has joined #ruby
[05:24:32] asphyxia: has joined #ruby
[05:30:50] dbz: has joined #ruby
[05:32:02] za1b1tsu: has joined #ruby
[05:35:08] reber: has joined #ruby
[05:45:13] _whitelogger: has joined #ruby
[05:47:23] apeiros_: has joined #ruby
[05:56:08] MyMind: has joined #ruby
[06:10:17] argoneus: has joined #ruby
[06:13:41] Nicmavr: has joined #ruby
[06:18:41] aupadhye: has joined #ruby
[06:26:56] dbz: has joined #ruby
[06:34:24] snickers: has joined #ruby
[06:35:26] TomyLobo: has joined #ruby
[06:40:20] leafyleong: has joined #ruby
[06:50:38] stoffus: has joined #ruby
[07:04:19] nowhereman_: has joined #ruby
[07:09:23] phaul: has joined #ruby
[07:25:53] clemens3: has joined #ruby
[07:26:30] eckhardt_: has joined #ruby
[07:27:34] yohji: has joined #ruby
[07:28:16] kreantos: has joined #ruby
[07:36:37] themsay: has joined #ruby
[07:37:58] z3uS: has joined #ruby
[07:45:20] vondruch: has joined #ruby
[07:54:21] sonOfRa: has left #ruby: ("Leaving")
[08:00:37] ellcs: has joined #ruby
[08:07:03] Mike11: has joined #ruby
[08:08:42] lxsameer: has joined #ruby
[08:19:02] themsay: has joined #ruby
[08:21:38] Terens: has joined #ruby
[08:21:49] Terens: how can I initialize my hash here
[08:21:51] Terens: hash[:date] << key.to_s if property[:type] == :date
[08:22:12] xfbs: has joined #ruby
[08:24:01] phaul: do you mean hash is a new local var on that line, ie hash did not exist before?
[08:26:12] phaul: Terens: you said initialize, which is why Im asking
[08:30:15] venmx: has joined #ruby
[08:37:14] VladGh: has joined #ruby
[09:14:04] aufi_: has joined #ruby
[09:16:10] iAmDecim: has joined #ruby
[09:25:37] p0s1x: has joined #ruby
[09:29:56] za1b1tsu: has joined #ruby
[09:33:05] zenspider: Don't you love it when someone asks a question with seemingly no desire for an answer?
[09:34:20] clemens3: has joined #ruby
[09:37:21] phaul: yes, Im not sure what happened there.
[10:09:13] _whitelogger: has joined #ruby
[10:15:29] discopatrick: has joined #ruby
[10:29:42] MoritaShinobu: has joined #ruby
[10:37:39] aufi_: has joined #ruby
[10:46:55] AJA4350: has joined #ruby
[11:00:35] aufi_: has joined #ruby
[11:04:33] apeiros_: has joined #ruby
[11:10:59] michael_mbp: has joined #ruby
[11:20:11] aufi_: has joined #ruby
[11:23:57] jacobat: has joined #ruby
[11:24:50] jacobat: Is there an easy way to capture keywords args into a hash?
[11:25:21] jacobat: I could change the method signature to use a hash instead of kw args but that's not what I'm looking for
[11:25:44] tbuehlmann: `def foo(**kwargs); kwargs; end` where kwargs will be a hash, do you mean that?
[11:30:00] jacobat: No, I want to maintain a signature like `def foo(a:, b:)` - but in the body of the method I want an easy way to convert it into a hash, or otherwise use a subset of the arguments.
[11:32:07] jacobat: Here's a simple example of what I need: https://gist.github.com/jacobat/ab7b14530e0f1c790e2c79683ba7a404
[11:32:37] jacobat: Just imagine the number of arguments being somewhat bigger
[11:39:26] tbuehlmann: I don't think that's easily possible
[11:40:20] jacobat: Alright, thanks :)
[11:43:56] estrod: has joined #ruby
[11:50:29] improv42: has joined #ruby
[12:11:09] kurko_: has joined #ruby
[12:14:17] znz_jp: has joined #ruby
[12:15:34] emerson: has joined #ruby
[12:18:52] dbz: has joined #ruby
[12:23:47] Azure: has joined #ruby
[12:25:54] bmurt: has joined #ruby
[12:33:40] kurko_: has joined #ruby
[12:36:37] francisco: has joined #ruby
[12:50:31] phaul: has joined #ruby
[12:51:42] bmurt: has joined #ruby
[12:55:11] nowhereman_: has joined #ruby
[12:56:46] bkxd: has joined #ruby
[12:58:34] beefjoe: has joined #ruby
[13:04:27] deathwishdave: has joined #ruby
[13:06:25] deathwishdave: simple one i'm sure, https://gist.github.com/deathwishdave/a80dbada482a3533995d46829174aa6a, why does it output {"A"=>1, "A"=>3} ?
[13:06:39] deathwishdave: why do I have two "A" keys?
[13:08:53] snickers: has joined #ruby
[13:09:23] leah2: data[i] = data[j] you want == there
[13:10:27] dmitch: has joined #ruby
[13:10:34] estrod: has joined #ruby
[13:10:35] deathwishdave: leah2 thanks, i did actually have that before, but changed while trying to find the issue
[13:10:38] leah2: and it prints {"A"=>4} here
[13:11:06] leah2: and with Hash.new(0) you can always +=1
[13:11:45] deathwishdave: leah2, i get...
[13:11:46] deathwishdave: Daves-MacBook-Pro:RayCastOptimisations Dave$ ruby Optimise.rb
[13:11:46] deathwishdave: {"A"=>1, "A"=>1}
[13:11:47] deathwishdave: Daves-MacBook-Pro:RayCastOptimisations Dave$
[13:12:27] leah2: which ruby version?
[13:12:43] deathwishdave: ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin16]
[13:13:01] leah2: quite old. but this always worked oO
[13:13:16] leah2: puts groups.keys.map {|x| x.hash }
[13:14:16] beefjoe: has joined #ruby
[13:15:11] deathwishdave: Daves-MacBook-Pro:RayCastOptimisations Dave$ ruby Optimise.rb
[13:15:11] deathwishdave: -4025386002249382175
[13:15:11] deathwishdave: -1911482060860157796
[13:15:11] deathwishdave: Daves-MacBook-Pro:RayCastOptimisations Dave$
[13:15:37] leah2: interesting oO
[13:16:00] deathwishdave: upgrading ruby
[13:16:30] leah2: if you add p "A".hash
[13:17:57] Fr4n: has joined #ruby
[13:18:08] deathwishdave: Daves-MacBook-Pro:RayCastOptimisations Dave$ ruby Optimise.rb
[13:18:09] deathwishdave: 1064180750834429922
[13:18:09] deathwishdave: -2843238284506867293
[13:18:09] deathwishdave: Daves-MacBook-Pro:RayCastOptimisations Dave$
[13:18:23] bmurt: has joined #ruby
[13:18:28] leah2: it should print 3 things then
[13:20:23] deathwishdave: leah2 see above
[13:21:25] dbz: has joined #ruby
[13:21:41] leah2: the values change every run
[13:22:21] deathwishdave: in the csv? no
[13:24:50] leah2: the hashes
[13:24:51] leah2: but two should be the same oO
[13:26:23] jidar: has joined #ruby
[13:26:25] moei: has joined #ruby
[13:26:26] phaul: I wonder if 'A' is different from 'A' due to some nonvisible UTF8 or similar tricks...
[13:26:39] leah2: at least from the posted csv file that is not the case
[13:27:18] deathwishdave: phaul i did consider that
[13:27:26] marahin: has joined #ruby
[13:27:28] deathwishdave: I rewrote the csv file
[13:27:36] deathwishdave: no copy or paste
[13:29:17] bkxd: has joined #ruby
[13:32:55] aufi_: has joined #ruby
[13:35:13] SeepingN: has joined #ruby
[13:46:04] bkxd: has joined #ruby
[13:58:52] deathwishdave: leah2 same result with Ruby 2.5.1p57
[13:59:36] DTZUZO: has joined #ruby
[13:59:39] deathwishdave: leah2 , phaul fixed it!
[13:59:54] phaul: you have to tell us how :)
[14:00:25] deathwishdave: the csv was exported from Excel, i had only been changing it contents.
[14:00:55] deathwishdave: I created a new csv in my editor, and pasted contents in, now works!
[14:01:12] deathwishdave: this was excel for mac
[14:05:25] dionysus69: has joined #ruby
[14:08:39] chouhoulis: has joined #ruby
[14:12:30] dionysus69: has joined #ruby
[14:12:40] snickers: has joined #ruby
[14:13:07] ogres: has joined #ruby
[14:13:09] dinfuehr: has joined #ruby
[14:17:16] Rapture: has joined #ruby
[14:23:26] bkxd: has joined #ruby
[14:36:47] bkxd: has joined #ruby
[14:44:14] nowhereman_: has joined #ruby
[14:45:37] phaul: has joined #ruby
[14:47:15] bkxd: has joined #ruby
[14:53:44] orbyt_: has joined #ruby
[14:53:45] aufi_: has joined #ruby
[14:58:49] uplime: has joined #ruby
[15:01:52] bkxd: has joined #ruby
[15:05:47] dbz: has joined #ruby
[15:09:45] rubydoc: has joined #ruby
[15:10:17] phaul: I've started doing rubydoc ... I have 21 lines of code atm. so he is completely broken
[15:10:27] phaul: &ri Array#count
[15:10:28] rubydoc: https://www.rubydoc.info/stdlib/core/Array#count
[15:10:28] rubydoc: https://www.rubydoc.info/stdlib/core/Array#count-instance_method
[15:11:06] phaul: whops there you go. I don't know why he replied twice...
[15:12:26] bkxd: has joined #ruby
[15:13:05] phaul: derpy replacement
[15:13:16] orbyt_: &ri Array#first
[15:13:16] rubydoc: https://www.rubydoc.info/stdlib/core/Array#first
[15:13:16] rubydoc: https://www.rubydoc.info/stdlib/core/Array#first-instance_method
[15:13:26] orbyt_: Why is the command &ri lol
[15:14:14] phaul: we had a bot for this a while ago. Links the documentation. I am trying to resurect that
[15:15:05] phaul: the old bot used the command &ri iirc
[15:31:31] rippa: has joined #ruby
[15:33:14] orbyt_: phaul Ah, weird
[15:33:29] orbyt_: & is a weird character to trigger commands
[15:34:17] phaul: Feel free to suggest something else. I'll change it
[15:34:30] phaul: just don't collide with rubybot
[15:35:32] phaul: https://ruby-community.com/ruboto/commands
[15:36:28] apeiros_: has joined #ruby
[15:36:35] arup_r: has joined #ruby
[15:39:23] raulp: has joined #ruby
[15:42:27] aufi_: has joined #ruby
[15:45:12] GodFather: has joined #ruby
[15:57:20] schneider: has joined #ruby
[16:02:05] DTZUZO: has joined #ruby
[16:06:29] jcarl43: has joined #ruby
[16:06:57] duderonomy: has joined #ruby
[16:08:35] truenito: has joined #ruby
[16:09:49] johnny56: has joined #ruby
[16:11:56] duderonomy: has joined #ruby
[16:12:24] dbz: has joined #ruby
[16:12:52] cthulchu: has joined #ruby
[16:21:12] bkxd: has joined #ruby
[16:21:54] evdubs_: has joined #ruby
[16:25:23] baweaver: ACTION wanders in
[16:26:39] snickers: has joined #ruby
[16:30:09] darkhanb: has joined #ruby
[16:31:49] sarmiena_: has joined #ruby
[16:36:12] dbz: has joined #ruby
[16:37:32] conta1: has joined #ruby
[16:39:24] DTZUZO_: has joined #ruby
[16:39:46] bkxd: has joined #ruby
[16:41:42] francisco: has joined #ruby
[16:43:43] dbz: has joined #ruby
[16:44:01] dbz: has joined #ruby
[16:49:46] duderonomy: has joined #ruby
[16:50:08] Eiam: ACTION hands baweaver a beer so they can settle in
[16:53:26] Nicmavr: has joined #ruby
[16:53:57] bak1an: has joined #ruby
[16:54:02] xfbs: has joined #ruby
[16:58:51] sameerynho: has joined #ruby
[16:58:58] schneider: has joined #ruby
[17:00:21] sauvin: has joined #ruby
[17:01:23] sauvin_: has joined #ruby
[17:02:36] phaul: has joined #ruby
[17:03:47] bkxd: has joined #ruby
[17:06:49] beowuff: has joined #ruby
[17:14:52] roshanavand: has joined #ruby
[17:17:22] uplime: has joined #ruby
[17:18:07] uplime: has joined #ruby
[17:19:33] Dbugger: has joined #ruby
[17:23:17] kurko_: has joined #ruby
[17:23:53] uplime: has joined #ruby
[17:24:51] xfbs: has joined #ruby
[17:25:14] bkxd: has joined #ruby
[17:35:24] GodFather: has joined #ruby
[17:35:48] bkxd: has joined #ruby
[17:40:10] ellcs: has joined #ruby
[17:43:31] kapil____: has joined #ruby
[17:52:45] clemens3: has joined #ruby
[17:56:08] agent_white: has joined #ruby
[18:09:24] mroutis: has joined #ruby
[18:23:45] impermanence: has joined #ruby
[18:24:02] bkxd: has joined #ruby
[18:24:15] dviola: has joined #ruby
[18:26:18] improv42: has joined #ruby
[18:26:19] weaksauce: has joined #ruby
[18:28:15] kurko_: has joined #ruby
[18:33:02] cthulchu: we can next in each_line, right?
[18:35:07] krawchyk: has joined #ruby
[18:35:24] improv42: has joined #ruby
[18:35:34] conta1: has joined #ruby
[18:37:12] eckhardt: has joined #ruby
[18:39:17] clemens3: has joined #ruby
[18:42:07] bkxd: has joined #ruby
[18:45:59] improv42: has joined #ruby
[18:47:09] bkxd: has joined #ruby
[18:53:33] GodFather: has joined #ruby
[18:57:35] cthulchu: I found something weird
[18:57:49] cthulchu: looks like it's possible for a hash to have fields with the same keys
[18:57:49] bkxd: has joined #ruby
[18:57:58] cthulchu: I didn't know it about them
[18:58:48] cthulchu: so if I set a hash explicitly like hash={"qwe":""} and then do hash["qwe"]="bar", it will end up having two records
[18:58:58] cthulchu: with the same key but different values...
[18:59:12] cthulchu: Ruby is amazing
[18:59:49] phaul: Ruby is amazing, but you are mistaken there
[19:00:19] phaul: {"qwe":""} is { :qwe => '' }
[19:00:31] phaul: so not the same keys
[19:01:13] phaul: one is symbol the other is string
[19:01:41] cthulchu: I didn't mean symbols!
[19:02:10] teej: has joined #ruby
[19:02:40] cthulchu: so... the correct way would be... asd = {qwe = "qwe", asd = "asd"}?
[19:03:06] greengriminal: has joined #ruby
[19:03:51] cthulchu: should be {"qwe":"qwe"}
[19:04:05] uplime: {"abcd" => "efgh"}
[19:04:09] greengriminal: Hey all I'm currently using Ruby 2.3.4 and the following (0.99 + (1.0 * 0.025)).round(2) = 1.01 but in Ruby 2.3.7 I get 1.02
[19:04:14] cthulchu: oh, ok, thanks
[19:04:27] cthulchu: => is the arrow function?
[19:04:46] phaul: cthulchu: we used to have only one hash syntax. the => syntax. then they decided to give a syntactic sugar for symbol keys. that's when all the confusion started
[19:04:59] uplime: cthulchu: its not a function
[19:05:05] phaul: not function. it's a special syntax to define hashes
[19:05:12] uplime: key => value
[19:05:13] cthulchu: great, I'll do it then
[19:05:19] uplime: key_as_symbol: vlaue
[19:05:21] greengriminal: For that matter I get the same output on 2.4.0 as well
[19:07:34] deathwishdave: has joined #ruby
[19:08:41] rubydoc: has joined #ruby
[19:09:35] improv42: has joined #ruby
[19:10:16] rubydoc: https://www.rubydoc.info/stdlib/core/Hash
[19:11:02] duderonomy: has joined #ruby
[19:11:04] cthulchu: so that => is only in {}, right?
[19:11:18] cthulchu: once it's just hash["key"], I can assign
[19:13:02] bmurt: has joined #ruby
[19:23:11] ruurd: has joined #ruby
[19:34:19] greengriminal: has joined #ruby
[19:36:41] bkxd: has joined #ruby
[19:44:54] phaul: &ri Hash, phaul
[19:44:55] rubydoc: https://www.rubydoc.info/stdlib/core/Hash, phaul
[19:46:32] phaul: cool. even that works :) how versatile concatenation can be :)
[19:49:31] phaul: has joined #ruby
[19:50:41] ivanskie: has joined #ruby
[19:51:16] rubydoc: has joined #ruby
[19:51:32] cthulchu: ok, I'm excited
[19:51:47] cthulchu: I have this Android log that I parse in the runtime
[19:52:10] cthulchu: and there was an issue cuz the log grew rapidly and I didn't have a good way to solve the issue.
[19:52:43] cthulchu: I can't delete it cuz Genymotion won't create a file after that
[19:53:07] SeepingN: has joined #ruby
[19:53:14] cthulchu: but what I can do is remember the line number that I used before and do my analysis from there on
[19:53:19] cthulchu: or rather file reading
[19:53:26] cthulchu: sounds super cool
[19:54:06] cthulchu: although I would have to use @@
[19:54:12] cthulchu: but hey, it's not that bad
[19:58:52] cthulchu: so the question is... how do I read file starting from a specific line? I looked at arguments in each_line and it seems to have only two: separator and limit
[20:02:05] phaul: &ri IO#seek , cthulchu
[20:02:06] rubydoc: https://www.rubydoc.info/stdlib/core/IO:seek , cthulchu
[20:02:46] cthulchu: it will be significantly faster than each_line, right?
[20:02:59] chouhoulis: has joined #ruby
[20:03:01] cthulchu: I don't like the idea of seeking the line number
[20:03:06] phaul: ignore it, not good for your question sorry.
[20:06:06] cthulchu: I can't find a good solution
[20:07:09] phaul: my bet is that there is none. Even at filesystem / OS level, the system has no idea where the newlines are
[20:07:49] cthulchu: I was hoping that files are something like arrays
[20:07:57] cthulchu: hell this is bad
[20:08:06] cthulchu: well then I guess seek it is?
[20:08:23] cthulchu: I just find where the line number is and start iterating from there?
[20:08:27] cthulchu: can I do that?
[20:08:32] phaul: but how do you know where to seek to ?
[20:08:42] cthulchu: I will supply the line number
[20:09:00] cthulchu: I parse the same file many times for many tests
[20:09:01] dviola: has joined #ruby
[20:09:18] cthulchu: so I save the last used line number
[20:09:28] cthulchu: in a static variable
[20:09:35] agent_white: has joined #ruby
[20:09:46] cthulchu: and then I will use it for every next iteration to start reading from
[20:09:46] phaul: yes , that can work
[20:10:50] cthulchu: there is another approach where I only iterate through the last N lines, but it's not as reliable
[20:16:14] cthulchu: hell this documentation is quite hard to read
[20:17:30] cthulchu: looks like seek is not quite good at starting from somewhere meaningful
[20:17:47] cthulchu: it always starts from the beginning of the file
[20:18:01] cthulchu: and then you only influence the direction and limit of search
[20:18:12] cthulchu: whereas I need it to start from the specific line
[20:18:45] cthulchu: I guess I'd use lazy for it
[20:19:46] phaul: I thought you said you want to store a location from previous run and then seek to it next time
[20:20:05] phaul: that can be achieved with seek. but it will be byte position
[20:20:55] cthulchu: first iteration: seeking from 0 to 289, which happens to be the eof. second iteration: seeking from 289 to the new eof
[20:21:46] cthulchu: I also need a block and .each for seek
[20:22:05] cthulchu: it's not for seek
[20:22:25] cthulchu: aha! whence!
[20:22:31] cthulchu: whence can change the position
[20:22:38] cthulchu: no, it cant
[20:22:44] cthulchu: maybe rewind?
[20:22:56] cthulchu: like a smart rewind
[20:23:11] cthulchu: I have no clue
[20:24:39] cthulchu: maybe this? https://stackoverflow.com/questions/26950338/how-to-start-reading-a-filecsv-from-a-given-line-n-in-ruby
[20:25:41] Xiti: has joined #ruby
[20:25:42] phaul: I don't see how this saves you anything. It will read in everything
[20:26:19] mroutis: has joined #ruby
[20:26:27] phaul: maybe wont parse everything as CSV which is a save...
[20:29:36] havenwood: &ri IO#pread
[20:29:37] rubydoc: https://www.rubydoc.info/stdlib/core/IO:pread
[20:29:50] LiftLeft2: has joined #ruby
[20:31:04] havenwood: cthulchu: https://docs.ruby-lang.org/en/2.5.0/IO.html#method-i-pread
[20:31:12] phaul: havenwood: sorry my rubydoc.info.stdlib/core/ prefix paste bot is in very early stages :)
[20:31:14] havenwood: phaul: I think the docs.ruby-lang.org docs would make the best ri links.
[20:31:18] havenwood: phaul: nice
[20:32:06] apeiros_: you shouldn't use non-csv reading methods to advance in a csv (assuming the file does not consist of partially non-csv values)
[20:32:17] apeiros_: reason: a single csv row may very well contain newlines
[20:32:54] apeiros_: TIL pread, though. nice.
[20:33:35] jcalla: has joined #ruby
[20:33:49] deathwishdave: has joined #ruby
[20:36:15] dmitch: has joined #ruby
[20:37:57] phaul: but if this is just continuing from where you left of when that was an EOF (assuming that EOFs only happen at correct line boundaries) then you can seek to that byte position and continue
[20:38:22] bkxd: has joined #ruby
[20:38:25] tdy: has joined #ruby
[20:39:16] asphyxia: has joined #ruby
[20:45:24] kurko_: has joined #ruby
[20:51:22] bkxd: has joined #ruby
[20:51:46] phaul: apeiros_: can you find derpy's code - if it's public?
[20:54:39] apeiros_: didn't find it :( I'll try to contact adaedra
[20:54:52] phaul: ok thanks
[20:58:00] gheegh: has joined #ruby
[20:58:16] lxsameer: has joined #ruby
[20:59:45] havenwood: cthulchu: for the heck of it, here's reading through a file to find the newlines and preading between offsets. I didn't check it for off-by-one errors :P https://gist.github.com/havenwood/cd200b40ad0d8ebb91f45ea9c9671858
[21:07:03] SeepingN: has joined #ruby
[21:12:44] ellcs: has joined #ruby
[21:13:25] bkxd: has joined #ruby
[21:17:23] gheegh: hey all.. anyone using VCR? I'm having some problem figuring out what to do to get my "let" in RSPEC not re-retrieve the page..
[21:18:41] gheegh: https://gist.github.com/wflanagan/59f0434d11079ace97ed4679d503d31d this is an example.. not sure what i'm doing wrong.. the URL is identical.
[21:22:43] cthulchu: guys, files should be better
[21:22:57] cthulchu: byte position!
[21:23:16] cthulchu: phaul, I should remember the last byte and then start reading from there!
[21:23:25] cthulchu: buz bytes are arrays, right?
[21:23:35] cthulchu: I don't need to read through everything now!
[21:23:45] cthulchu: only one problem: can Ruby tackle that?
[21:24:54] havenwood: cthulchu: You can't find the byte position of the end of a line without reading up to a newline.
[21:25:20] havenwood: cthulchu: Files don't automagically know where newlines are.
[21:25:27] cthulchu: that's fine
[21:25:40] cthulchu: as I said, I read this file in iterations
[21:25:55] cthulchu: I have, say, 20 tests running one after another
[21:26:01] phaul: yeah what you are trying here would work.
[21:26:04] cthulchu: logs from all of them get to the same file
[21:26:25] cthulchu: but I don't need logs from test N 8 in test N 9
[21:27:02] cthulchu: but now the question is even harder
[21:27:07] havenwood: cthulchu: Above I showed an example of iterating through the file by line once, to find which offsets the newlines are located at. Then going through again, and reading between those offsets.
[21:27:17] cthulchu: how do I save the byte position and load it to start iterating from there
[21:27:49] phaul: cthulchu: IO#pos. IO#seek. IO#pos=
[21:28:10] cthulchu: havenwood, I can't afford that and it's not very applicable
[21:28:39] phaul: though I've never tried pos=, but seek to byte position should work
[21:30:14] cthulchu: the problem is that I don't need seek to...
[21:30:17] cthulchu: I need seek from
[21:30:29] cthulchu: also seek is weird
[21:30:33] cthulchu: I'm not sure how it works
[21:30:41] cthulchu: I saw its doc
[21:30:41] havenwood: cthulchu: Well, you've got to read through the file once to find the newlines. My example collects those points and uses #pread to read between them. You could read between them whenever you want, but you have to find the newlines if you want to seek to them.
[21:30:47] phaul: cthulchu: seek gets you to a byte position.
[21:30:47] cthulchu: but it seems to return 0
[21:30:57] cthulchu: and then what do I do with it?
[21:31:08] cthulchu: do I just do file.each_line?
[21:31:40] cthulchu: havenwood, I think I'll try seeking to byte #
[21:31:57] cthulchu: I hope seek is smart enough to treat it as an array and not iterate through the thing
[21:31:59] havenwood: cthulchu: My point is you can't see to the byte of a newline without reading the file to find where those bytes will be.
[21:32:22] cthulchu: havenwood, I described above
[21:32:35] cthulchu: havenwood, I read this file many times and don't want to start from 0 every time
[21:33:51] cthulchu: phaul, will seek work for each_line?
[21:34:08] phaul: talking across purposes...
[21:34:29] phaul: io.seek(100) will get you to byte position 100 (absolute position)
[21:34:44] cthulchu: and then how do I iterate through new lines after that?
[21:35:04] cthulchu: starting from that absolute position
[21:35:45] phaul: I expect io.each_line { to work. let me check ...
[21:35:46] cthulchu: or should I do that right in the each_line loop?
[21:36:11] phaul: no you should seek first, then read the rest
[21:36:41] havenwood: cthulchu: I showed an example of reading through once to find newlines without having the whole file in memory. You could then do the pread for each of those lines at any later point. I didn't show how to do it piecemeal, where you don't read through the whole thing but readline and continue, but that's not a far stretch from my example.
[21:36:58] cthulchu: havenwood, it is useless since the file changes
[21:37:14] cthulchu: I mean, the length of it. it's a log file
[21:37:52] cthulchu: so I need to know the address since where to look for new changes
[21:38:11] cthulchu: we figured it should be byte address, which makes perfect sense
[21:38:18] phaul: cthulchu: yes I tried it works as expected
[21:38:31] cthulchu: phaul, could you please show a snippet?
[21:38:48] phaul: io.seek(previous_last_pos); io.each_line { |line| } ; previous_last_pos = io.pos
[21:39:48] cthulchu: phaul, thanks a lot :)
[21:39:49] truenito: has joined #ruby
[21:46:53] ellcs: has joined #ruby
[21:46:54] bkxd: has joined #ruby
[21:47:25] havenwood: gheegh: #let memoizes within the #it, but not between the two
[21:47:44] gheegh: yeah, but i would have thought vcr would have matched it.. and returned the value
[21:47:56] havenwood: gheegh: ahh
[21:47:59] gheegh: since the URL is the same
[21:48:02] cthulchu: is there a way to find eof byte #?
[21:48:09] cthulchu: without iterating through it
[21:48:12] cthulchu: should be in FS
[21:48:26] cthulchu: it should be there
[21:48:41] cthulchu: how else do you read from the end
[21:48:45] cthulchu: yeah, for sure
[21:49:21] havenwood: cthulchu: seek to -1?
[21:50:54] phaul: there is IO::SEEK_END to start from the end of the file
[21:51:00] phaul: then offset is 0
[21:51:29] phaul: (IO::SEEK_END for the whence argument of seek)
[21:51:31] havenwood: file.seek(-1, IO::SEEK_END)
[21:52:12] cthulchu: havenwood, cool! thanks!
[21:52:41] cthulchu: I even saw it before
[21:52:53] phaul: where does that take you if the file is empty? :)
[21:53:04] cthulchu: great question
[21:53:23] cthulchu: where would it take me though?
[21:53:32] cthulchu: did we just found a way to travel in time?
[21:53:52] cthulchu: to brake the space-time continuum?
[21:54:07] cthulchu: hell I'm curious where it would take me
[21:54:17] deathwishdave: has joined #ruby
[22:05:28] havenwood: phaul: Errno::EINVAL
[22:05:49] phaul: yeah I checked too :)
[22:05:55] phaul: I think 0 is the right offset
[22:06:03] cthulchu: oh so when we do the argument magic, it's still symbols? like def asd(a:"",b:"",c:"")
[22:06:25] cthulchu: that means that the function accepts links
[22:07:07] cthulchu: and then if I run asd(a:"qweqwe"), I actually pass a link to a static string?
[22:07:21] cthulchu: I mean, not static, but primitive as hell
[22:07:43] cthulchu: nah, no, probably those aren't symbols
[22:08:36] Radar: slowwwwww dowwwwnnnn
[22:15:18] SeepingN_: has joined #ruby
[22:18:01] edwardthefma: has joined #ruby
[22:19:07] RougeR: has joined #ruby
[22:20:07] RougeR: has joined #ruby
[22:22:00] pastorinni: has joined #ruby
[22:32:17] SeepingN: has joined #ruby
[22:47:10] MoritaShinobu: has joined #ruby
[22:52:52] _phaul: has joined #ruby
[22:58:56] lxsameer: has joined #ruby
[22:59:20] dviola: has joined #ruby
[23:29:28] cthulchu: looks like I made a mistake :(
[23:33:34] weaksauce: has joined #ruby
[23:33:39] havenwood: cthulchu: the logs rotated? :P
[23:34:04] MaiconVieira: has joined #ruby
[23:34:10] cthulchu: I'll debug and come back
[23:34:55] fluxAeon: has joined #ruby
[23:36:56] DTZUZO_: has joined #ruby
[23:51:48] cthulchu: I also shouldn't debug at the end of a day
[23:52:08] cthulchu: I usually end up wasting hours on something trivial
[23:54:12] bkxd: has joined #ruby
[23:55:06] pastorinni: has joined #ruby
[23:57:36] Dimik: has joined #ruby