« Back to channel list

#ruby - 05 February 2019

« Back 1 day Forward 1 day »
[00:00:22] ansraliant: has joined #ruby
[00:01:20] tdy: has joined #ruby
[00:28:11] Swyper: has joined #ruby
[00:30:55] Renich: has joined #ruby
[00:46:52] leftylink: heh, I accidentally used `next` in a lambda when I instead meant to use `return`, but it was fine. TIL I guess
[00:47:04] leftylink: &>> ->{ next 5 }[]
[00:47:06] rubydoc: # => 5 (https://carc.in/#/r/665l)
[00:47:16] leftylink: can't do that if it's a function though
[00:47:24] leftylink: &>> def f; next 5; end; f
[00:47:25] rubydoc: # => (https://carc.in/#/r/665m)
[01:04:14] ericboehs: has joined #ruby
[01:05:48] hahuang6-: has joined #ruby
[01:09:36] blackmesa: has joined #ruby
[01:12:51] blackmesa1: has joined #ruby
[01:14:58] blackmesa: has joined #ruby
[01:24:13] AJA4350: has joined #ruby
[01:27:25] blackmesa: has joined #ruby
[01:31:14] raulp: has joined #ruby
[01:45:23] Nicmavr: has joined #ruby
[01:47:12] raulp: has joined #ruby
[01:53:22] sticaz: has joined #ruby
[02:06:05] mikecmpbll: has joined #ruby
[02:14:27] AJA4351: has joined #ruby
[02:20:46] cnsvc: has joined #ruby
[02:34:45] arescorpio: has joined #ruby
[02:44:52] arekushi: has joined #ruby
[02:45:04] crankharder: has joined #ruby
[02:48:13] AJA4351: has joined #ruby
[02:57:43] tpanarch1st: has joined #ruby
[03:04:03] robscomputer: has joined #ruby
[03:05:39] jgpawletko: has joined #ruby
[03:05:48] crankharder: has joined #ruby
[03:08:49] ivanskie: has joined #ruby
[03:10:10] ericboehs: has joined #ruby
[03:12:41] Swyper: has joined #ruby
[03:26:22] crankharder: has joined #ruby
[03:27:48] ericboehs: has joined #ruby
[03:33:09] cnsvc: has joined #ruby
[03:40:49] tdy: has joined #ruby
[03:46:59] crankharder: has joined #ruby
[03:48:35] sagax: has joined #ruby
[03:56:41] Swyper: has joined #ruby
[04:02:49] orbyt_: has joined #ruby
[04:04:23] \void: has joined #ruby
[04:05:22] crankharder: has joined #ruby
[04:08:49] braincrash: has joined #ruby
[04:15:51] skyikot: has joined #ruby
[04:19:27] ericboehs: has joined #ruby
[04:42:27] GodFather: has joined #ruby
[04:45:29] skyikot: has joined #ruby
[04:46:09] mangold: has joined #ruby
[04:46:59] ansraliant: has joined #ruby
[04:54:42] skyikot: has joined #ruby
[05:16:35] cd: has joined #ruby
[05:18:09] cd: has joined #ruby
[05:25:20] cd: has joined #ruby
[05:27:42] spacesuitdiver: has joined #ruby
[05:50:46] mangold: has joined #ruby
[06:09:54] asphyxia: has joined #ruby
[06:10:33] kapil____: has joined #ruby
[06:18:15] za1b1tsu: has joined #ruby
[06:19:39] reber: has joined #ruby
[06:21:17] conta: has joined #ruby
[06:24:45] skyikot: has joined #ruby
[06:25:57] sauvin: has joined #ruby
[06:33:28] funnel: has joined #ruby
[06:35:41] robscomputer: has joined #ruby
[06:43:30] jesfre: has joined #ruby
[06:49:59] za1b1tsu: has joined #ruby
[07:05:31] asphyxia_: has joined #ruby
[07:08:18] dellavg__: has joined #ruby
[07:08:28] dionysus69: has joined #ruby
[07:22:16] aupadhye: has joined #ruby
[07:25:07] ericboehs: has joined #ruby
[07:34:00] mangold: has joined #ruby
[07:38:48] ansraliant: has joined #ruby
[07:41:00] clemens3: has joined #ruby
[07:42:35] jmcgnh_: has joined #ruby
[07:46:05] jmcgnh: has joined #ruby
[08:02:49] blackmesa: has joined #ruby
[08:11:34] dionysus69: I was wondering the other day, I want to become a contributor to some starter grade repo, does anyone know any repo that needs help? notice: I am beginner in this realm, haven't really worked with gems so far
[08:12:12] aufi: has joined #ruby
[08:16:36] clemens3: has joined #ruby
[08:17:32] blackmesa1: has joined #ruby
[08:28:41] mikecmpbll: has joined #ruby
[08:30:03] bruce_lee: has joined #ruby
[08:34:01] za1b1tsu: has joined #ruby
[08:47:14] tuor: has joined #ruby
[08:49:45] ellcs: has joined #ruby
[08:58:54] nowhere_man: has joined #ruby
[09:00:23] volkov: has joined #ruby
[09:06:28] TvL2386: hey all, I've an issue with the ruby CSV class. I'm reading data from a mariadb database and create a csv. This data contains "weird chars". The CSV class is capable of generating the csv, but not reading it, because it will rais a CSV::MalformedCSVError
[09:06:36] TvL2386: code to reproduce is here: https://dpaste.de/6Y79#L14,27
[09:08:51] canton7: TvL2386, it would be helpful to see what the stringio contains
[09:11:13] mikecmpbll: has joined #ruby
[09:12:02] asphyxia: has joined #ruby
[09:15:23] kapil____: has joined #ruby
[09:28:38] al2o3-cr: TvL2386: try passing the liberal_parsing: true to the options hash.
[09:28:48] mikecmpb_: has joined #ruby
[09:31:19] conta: has joined #ruby
[09:31:26] al2o3-cr: requires ruby 2.4+ though.
[09:34:55] duderonomy: has joined #ruby
[09:35:03] Guest16678: has joined #ruby
[09:37:22] richard55: has joined #ruby
[09:40:30] Sylario: has joined #ruby
[09:41:21] Sylario: I have a ruby question about code from the Devise gem : https://github.com/plataformatec/devise/blob/715192a7709a4c02127afb067e66230061b82cf2/lib/devise/mailers/helpers.rb#L34 Why is resource not "undefined" ?
[10:23:47] apparition: has joined #ruby
[10:41:28] za1b1tsu: has joined #ruby
[10:43:30] TvL2386: al2o3-cr: ty that works!
[10:47:04] TvL2386: al2o3-cr: reading about that option, makes me wonder why the generated csv is not RFC4180 compatible
[10:55:38] vonfry: has joined #ruby
[10:58:14] mike274: has joined #ruby
[11:03:06] tdy: has joined #ruby
[11:04:10] conta: has joined #ruby
[11:04:17] TvL2386: al2o3-cr: upon further inspection: enabling that option does deal with the Exception, but the printed row on line 15 is an Array with only 1 String in there
[11:05:16] vonfry1: has joined #ruby
[11:05:54] sriehl: has joined #ruby
[11:06:39] kent\n: has joined #ruby
[11:06:53] jordanm: has joined #ruby
[11:07:01] roshanavand: has joined #ruby
[11:07:29] al2o3-cr: TvL2386: probably need col_sep: ';'
[11:08:02] TvL2386: al2o3-cr: please see: https://dpaste.de/KcQk
[11:08:06] ByronJohnson: has joined #ruby
[11:08:33] TvL2386: you are totally correct sir
[11:08:42] TvL2386: I missed that -_-'
[11:09:47] Swyper: has joined #ruby
[11:10:03] al2o3-cr: no worries ;)
[11:10:41] ua: has joined #ruby
[11:10:44] thinkpad: has joined #ruby
[11:11:38] gnufied: has joined #ruby
[11:12:37] GodFather: has joined #ruby
[11:13:46] jcalla: has joined #ruby
[11:13:55] v01d4lph4: has joined #ruby
[11:15:52] troulouliou_div2: has joined #ruby
[11:16:18] conta: has joined #ruby
[11:16:59] johnny56: has joined #ruby
[11:31:24] conta: has joined #ruby
[11:36:05] conta: has joined #ruby
[11:41:29] conta: has joined #ruby
[11:50:08] za1b1tsu: has joined #ruby
[11:58:36] catbusters: has joined #ruby
[12:01:03] phaul: sylario: did you expect it to be undefined because there is no such local variable in that method? If local variable lookup fails it still can be a method name on self. This case it is, look at L14
[12:02:20] eb0t: has joined #ruby
[12:04:34] roshanavand: has joined #ruby
[12:05:17] Sylario: @phaul ho... that was an easy one.
[12:06:53] phaul: this part of ruby is very tricky and can trip up ppl easily. if they have attr_writer :foo, and they do foo += 13 in their method. And they expect @foo to increase by 13. But it wouldn't!
[12:07:13] conta1: has joined #ruby
[12:08:20] mangold: has joined #ruby
[12:09:31] roshanavand: has joined #ruby
[12:11:13] phaul: &>> class X; def initialize; @foo = 0; end; attr_accessor :foo; def bar; foo += 13; end; end; x = X.new; x.bar; x.foo
[12:11:15] rubydoc: # => undefined method `+' for nil:NilClass (NoMethodError) (https://carc.in/#/r/667h)
[12:13:27] phaul: in this case foo becomes a local var in bar because of the assignment. def bad; self.foo += 13; end; does increase @foo however
[12:14:47] tdy1: has joined #ruby
[12:32:35] ubalot: has joined #ruby
[12:36:48] Rudd0: has joined #ruby
[12:42:25] roshanavand: has joined #ruby
[13:00:36] Swyper: has joined #ruby
[13:14:14] tdy1: has joined #ruby
[13:22:33] TitoN-: has joined #ruby
[13:33:08] AJA4350: has joined #ruby
[13:48:20] soyeomul^bionic: has joined #ruby
[14:04:18] v01d4lph4: has joined #ruby
[14:14:40] AJA4351: has joined #ruby
[14:17:04] hiroaki: has joined #ruby
[14:23:34] queip: has joined #ruby
[14:30:05] donofrio: has joined #ruby
[14:32:03] Guest16678: has joined #ruby
[14:39:14] nfk: has joined #ruby
[14:41:12] sagax: has joined #ruby
[14:43:32] cow[moo]: has joined #ruby
[14:48:49] polishdub: has joined #ruby
[14:53:56] Rapture: has joined #ruby
[14:59:49] kapil____: has joined #ruby
[15:00:57] yokel: has joined #ruby
[15:12:09] Guest16678: has joined #ruby
[15:12:48] Inline: has joined #ruby
[15:13:42] xco: has joined #ruby
[15:14:04] xco: I’d like to read each line and put each line in quotes like this
[15:14:16] xco: ‘some_line’,
[15:14:29] xco: so in essence i want to wrap each lien with ‘’,
[15:14:32] xco: i have this
[15:14:55] xco: File.readlines('dbs.txt').each { |line| puts "'#{line}'," }
[15:14:58] xco: but that’s not doing the job
[15:15:01] xco: any ideas?
[15:18:15] phaul: try stripping the lines from any "\n" at the end
[15:18:44] phaul: puts "'#{line.strip}',"
[15:19:15] canton7: xco, what makes you think it isn't doing the job?
[15:19:57] xco: canton7: adding strip does what i want
[15:20:05] xco: phaul: thanks :)
[15:37:26] Renich: has joined #ruby
[15:39:58] rippa: has joined #ruby
[15:40:22] orbyt_: has joined #ruby
[15:41:23] znz_jp: has joined #ruby
[15:48:44] Renich_: has joined #ruby
[16:00:26] conta1: has joined #ruby
[16:00:35] szulak_: has joined #ruby
[16:06:06] spacesuitdiver: has joined #ruby
[16:12:28] Renich: has joined #ruby
[16:13:30] tdy1: has joined #ruby
[16:13:34] loincloth: has joined #ruby
[16:14:43] AJA4350: has joined #ruby
[16:15:49] v01d4lph4: has joined #ruby
[16:16:50] dinfuehr: has joined #ruby
[16:18:41] BH23: has joined #ruby
[16:24:49] roshanavand: has joined #ruby
[16:30:23] jinie: has joined #ruby
[16:38:39] jetpack_joe: has joined #ruby
[16:39:27] lucasb: has joined #ruby
[16:40:37] tpanarch1st: has joined #ruby
[16:52:01] \void: has joined #ruby
[16:53:50] gigetoo: has joined #ruby
[16:54:08] Dbugger: has joined #ruby
[16:54:37] GodFather: has joined #ruby
[16:58:43] moei: has joined #ruby
[16:58:44] jottr: has joined #ruby
[17:01:12] roshanavand: has joined #ruby
[17:06:11] jottr: has joined #ruby
[17:08:17] headius: havenwood: worth pointing out that small benchmarks often end up doing nothing at all in TR, which isn't typical for e.g. a web application with lots of opaque IO
[17:12:12] tdy1: has joined #ruby
[17:12:16] havenwood: headius: Good point. And I'm sure you're right that's what's happening with unused literals in that trivial benchmark.
[17:13:07] al2o3-cr: has joined #ruby
[17:16:13] eb0t: has joined #ruby
[17:16:59] AJA4351: has joined #ruby
[17:20:59] GodFather: has joined #ruby
[17:31:20] [Butch]: has joined #ruby
[17:34:31] nowhere_man: has joined #ruby
[17:35:04] gnufied: has joined #ruby
[17:37:29] jottr: has joined #ruby
[17:39:45] jottr: has joined #ruby
[17:41:15] akemot: has joined #ruby
[17:43:23] jottr_: has joined #ruby
[17:43:48] orbyt_: has joined #ruby
[17:44:57] AJA4351: has joined #ruby
[17:45:00] eblip: has joined #ruby
[17:47:04] robscomputer: has joined #ruby
[17:52:19] Guest16678: has joined #ruby
[17:52:20] gix: has joined #ruby
[17:52:56] AJA4351: has joined #ruby
[17:57:37] DTZUZO: has joined #ruby
[18:00:32] mikecmpbll: has joined #ruby
[18:12:46] TheBrayn: Is there any reason to use 1 << 3 instead of 2 ** 3? I'm seeing this in some code I am reviewing
[18:13:06] scrptktty: has joined #ruby
[18:13:10] baweaver: Unless you're in the context of bit-shifting, no.
[18:13:22] baweaver: ohai scrptktty
[18:13:38] TheBrayn: I think the person writing this code is just trying to be purposefully obscure
[18:14:00] baweaver: Typically I'd advise writing things as clearly as possible
[18:14:15] baweaver: Even if that means writing something a bit longer or more verbosely
[18:14:15] TheBrayn: yes, absolutely
[18:14:35] baweaver: Mostly because I hate reading my own "clever" code later and trying to figure out what it is and why I did it that way.
[18:18:07] havenwood: &>> "#<#{self.class}:#{sprintf "%#018x", object_id * 2}"
[18:18:09] rubydoc: # => "#<Object:0x00005616bee462d8" (https://carc.in/#/r/66cl)
[18:18:39] baweaver: havenwood: wat?
[18:19:34] havenwood: baweaver: Most folk say the id in an object is `object_id << 1` so this convo ^ reminded me of overriding #inspect.
[18:19:53] Renich_: has joined #ruby
[18:21:10] phaul: in that domain << 1 is clearer, as it's about shifting rather than multiplying
[18:21:46] baweaver: Context is a heck of a drug
[18:21:55] def_jam: has joined #ruby
[18:23:01] havenwood: &>> class << self; undef_method :inspect end; self
[18:23:02] rubydoc: # => (https://carc.in/#/r/66cm)
[18:25:08] havenwood: explicit version: "#<#{self.class.name}:0x#{(object_id << 1).to_s(16).rjust(16, '0')}"
[18:26:26] baweaver: Amusingly I ended up deep into Lisp land
[18:26:43] havenwood: baweaver: all those parens are a good sign that's true!
[18:26:50] baweaver: Diffing s-expressions
[18:27:46] baweaver: Going to see if it's possible to write something like this and have it work: converter(from: '[].map { |v| v.even? }', to: '[].map(&:even?)')
[18:28:13] baweaver: I have most of the foundational pieces already, it's just generalizing the algorithm enough that it can intelligently do the conversions.
[18:28:30] orbyt_: has joined #ruby
[18:28:52] baweaver: Most of it would be being able to tell that undiff'd code branches are effectively wildcards
[18:29:56] baweaver: '[].map { |v| v.even? }' -> '_._ { |v| v._ }' -> '_._(&:_)' -> '[].map(&:even?)'
[18:30:19] baweaver: Where underscores are wildcards that would try and map from one to another
[18:30:38] dellavg__: has joined #ruby
[18:30:42] havenwood: baweaver: seems like macros
[18:31:46] baweaver: Here's the problem
[18:31:48] baweaver: First (input) s-exp: (block (send (array) :map) (args (procarg0 :v)) (send (lvar :v) :even?))
[18:32:09] havenwood: baweaver: may not be relevant, but Querly patterns are interesting for the match (but not replace) portion: https://github.com/soutaro/querly/blob/master/manual/patterns.md
[18:32:15] baweaver: Second (output) s-exp: (send (array) :map (block-pass (sym :even?)))
[18:32:34] baweaver: Drops the outer block among other transformations
[18:33:06] baweaver: https://www.rubydoc.info/gems/rubocop/RuboCop/NodePattern
[18:33:14] baweaver: NodePattern in RuboCOp is about the same
[18:33:20] baweaver: gotta go, train arriving, cheers
[18:33:55] orbyt_: has joined #ruby
[18:45:36] AJA4350: has joined #ruby
[18:50:48] lxsameer: has joined #ruby
[18:51:38] slester: has joined #ruby
[19:00:40] orbyt_: has joined #ruby
[19:04:25] agent_white: has joined #ruby
[19:05:43] jottr_: has joined #ruby
[19:07:26] loincloth: has joined #ruby
[19:09:46] segy: has joined #ruby
[19:11:27] eb0t: has joined #ruby
[19:14:35] hiroaki: has joined #ruby
[19:15:50] duderonomy: has joined #ruby
[19:17:27] klaas: has joined #ruby
[19:21:24] r29v: has joined #ruby
[19:21:28] reber: has joined #ruby
[19:23:52] marmotini_: has joined #ruby
[19:24:52] ivanskie: has joined #ruby
[19:25:37] xco: has joined #ruby
[19:29:21] Renich: has joined #ruby
[19:36:39] Renich: has joined #ruby
[19:44:30] cnsvc: has joined #ruby
[19:45:53] jottr_: has joined #ruby
[19:52:10] jottr_: has joined #ruby
[19:54:23] hiroaki: has joined #ruby
[19:56:20] jottr_: has joined #ruby
[19:58:02] jottr_: has joined #ruby
[20:03:02] tAn: has joined #ruby
[20:09:01] johnny56: has joined #ruby
[20:13:09] jottr: has joined #ruby
[20:15:16] phaul: reek us fun
[20:16:13] jottr_: has joined #ruby
[20:16:49] tdy: has joined #ruby
[20:24:18] phaul: I had code that relied on some config boolean that came from further up. If true I had to do apply a bunch of gsub s on a string if false I had to not do it. It took some thinking to find a solution that removes the control argument, but it's really neat and reminds me of null pattern. instead of bool control I have an array of filters in the config. It can be empty array.
[20:26:47] manakanapa: has joined #ruby
[20:31:49] ur5us: has joined #ruby
[20:33:37] NoidedSuper: has joined #ruby
[20:33:56] cd: has joined #ruby
[20:35:06] jesfre: has joined #ruby
[20:36:08] code_zombie: has joined #ruby
[20:42:15] jesfre: has joined #ruby
[20:44:59] phaul: has joined #ruby
[20:45:04] orbyt_: has joined #ruby
[20:48:47] SeepingN: has joined #ruby
[20:50:59] skyikot: has joined #ruby
[20:51:56] AJA4351: has joined #ruby
[20:53:14] jinie: has joined #ruby
[20:53:42] madhatter: has joined #ruby
[20:55:39] jinie: has joined #ruby
[20:56:17] spacesuitdiver: has joined #ruby
[20:58:33] orbyt_: has joined #ruby
[21:08:14] lytol_: has joined #ruby
[21:08:26] Fernando-Basso: has joined #ruby
[21:11:18] Swyper: has joined #ruby
[21:14:22] dviola: has joined #ruby
[21:19:46] dviola: has joined #ruby
[21:31:13] orbyt_: has joined #ruby
[21:33:32] AJA4351: has joined #ruby
[21:46:56] tdy: has joined #ruby
[21:48:38] tAn: has joined #ruby
[22:03:16] houhoulis: has joined #ruby
[22:04:01] AJA4351: has joined #ruby
[22:06:57] SeepingN: has joined #ruby
[22:12:36] Renich_: has joined #ruby
[22:18:15] agent_white: has joined #ruby
[22:29:06] Swyper: has joined #ruby
[22:29:45] AJA4351: has joined #ruby
[23:02:10] akemot: has joined #ruby
[23:05:18] Nicmavr: has joined #ruby
[23:05:38] Swyper: has joined #ruby
[23:06:23] eblip: has joined #ruby
[23:24:55] GinoMan2440: has joined #ruby
[23:36:10] ellcs: has joined #ruby
[23:38:08] AJA4350: has joined #ruby
[23:42:32] spacesuitdiver: has joined #ruby
[23:48:09] Swyper: has joined #ruby
[23:49:52] robscomputer: has joined #ruby
[23:50:02] xco: has joined #ruby
[23:50:50] asphyxia: has joined #ruby
[23:52:38] ansraliant: has joined #ruby
[23:54:32] Swyper: has joined #ruby