« Back to channel list

#ruby - 22 May 2019

« Back 1 day Forward 1 day »
[00:00:29] fphilipe: has joined #ruby
[00:06:53] tf2ftw: has joined #ruby
[00:10:39] skryking: has joined #ruby
[00:13:20] DarthGandalf: has joined #ruby
[00:26:20] CodeHex: has joined #ruby
[00:26:33] octos: has joined #ruby
[00:46:22] i1nfusion: has joined #ruby
[00:53:10] Swyper: has joined #ruby
[00:53:36] Swyper: has joined #ruby
[00:54:30] esp32_prog: has joined #ruby
[01:03:11] fphilipe: has joined #ruby
[01:04:15] kent\n: has joined #ruby
[01:14:42] Fusl: has joined #ruby
[01:22:19] jenrzzz: has joined #ruby
[01:24:41] Xeago_: has joined #ruby
[01:28:46] bambanx: has joined #ruby
[01:37:37] tdy: has joined #ruby
[01:44:30] i1nfusion: has joined #ruby
[01:52:41] Xeago: has joined #ruby
[01:56:46] Nicmavr: has joined #ruby
[01:59:50] houhoulis: has joined #ruby
[02:01:45] i1nfusion: has joined #ruby
[02:03:28] tf2ftw: has joined #ruby
[02:05:58] duderonomy: has joined #ruby
[02:13:51] houhoulis: has joined #ruby
[02:15:12] Wolland: has joined #ruby
[02:19:00] houhoulis: has joined #ruby
[02:20:51] houhoulis: has joined #ruby
[02:21:45] haxx0r: has joined #ruby
[02:22:33] houhoulis: has joined #ruby
[02:24:39] houhoulis: has joined #ruby
[02:28:25] gr33n7007h: has joined #ruby
[02:33:33] fphilipe: has joined #ruby
[02:34:34] AJA4351: has joined #ruby
[02:42:44] esp32_prog: has joined #ruby
[02:45:32] violentE: has joined #ruby
[02:48:30] gr33n7007h: has joined #ruby
[02:52:00] laaron: has joined #ruby
[03:05:12] laaron: has joined #ruby
[03:05:58] jenrzzz: has joined #ruby
[03:11:42] braincrash: has joined #ruby
[03:16:20] Swyper: has joined #ruby
[03:28:49] doodlebug: has joined #ruby
[03:37:20] yield: has joined #ruby
[03:39:19] houhoulis: has joined #ruby
[03:40:55] DarthGandalf: has joined #ruby
[03:43:07] kyrylo: has joined #ruby
[03:48:03] dar123: has joined #ruby
[03:52:15] dar123: has joined #ruby
[04:01:22] Wolland: has joined #ruby
[04:03:41] fphilipe: has joined #ruby
[04:04:09] dar123: has joined #ruby
[04:06:42] SeepingN: has joined #ruby
[04:24:47] regedit_: has joined #ruby
[04:30:58] esp32_prog: has joined #ruby
[04:35:08] podlech: has joined #ruby
[04:42:04] kapilp: has joined #ruby
[04:48:36] blackmesa1: has joined #ruby
[04:49:43] marmotini_: has joined #ruby
[05:13:00] ShalokShalom: has joined #ruby
[05:21:15] sauvin: has joined #ruby
[05:25:28] fphilipe: has joined #ruby
[05:25:42] Wolland: has joined #ruby
[05:26:25] conta: has joined #ruby
[05:27:27] blackmesa1: has joined #ruby
[05:33:15] WA9ACE: has joined #ruby
[05:33:38] jnix: has joined #ruby
[05:33:48] meinside: has joined #ruby
[05:33:52] Nuck: has joined #ruby
[05:33:53] Fenhl: has joined #ruby
[05:34:09] Liothen: has joined #ruby
[05:34:26] sariyar: has joined #ruby
[05:34:38] Iambchop: has joined #ruby
[05:34:38] Chew: has joined #ruby
[05:39:08] stooj: has joined #ruby
[05:41:44] schneider: has joined #ruby
[05:42:26] nowhere_man: has joined #ruby
[05:50:41] aupadhye: has joined #ruby
[05:59:00] yield: has joined #ruby
[06:02:01] conta: has joined #ruby
[06:10:25] aupadhye: has joined #ruby
[06:13:57] jefffrails35: has joined #ruby
[06:19:17] esp32_prog: has joined #ruby
[06:21:55] andikr: has joined #ruby
[06:29:31] slackmare: has joined #ruby
[06:31:02] ellcs: has joined #ruby
[06:35:48] jenrzzz: has joined #ruby
[06:38:30] marmotini: has joined #ruby
[06:40:39] TomyWork: has joined #ruby
[06:57:53] nowhere_man: has joined #ruby
[07:03:49] lxsameer: has joined #ruby
[07:05:36] andikr: has joined #ruby
[07:12:39] reber: has joined #ruby
[07:13:41] blackmesa1: has joined #ruby
[07:17:41] Dbugger: has joined #ruby
[07:24:18] alem0lars: has joined #ruby
[07:29:02] schne1der: has joined #ruby
[07:29:08] laaron: has joined #ruby
[07:31:52] deepreds1: has joined #ruby
[07:32:41] fphilipe: has joined #ruby
[07:34:44] teclator: has joined #ruby
[07:34:46] Fusl: has joined #ruby
[07:36:02] buckworst: has joined #ruby
[07:36:06] alem0lars: has joined #ruby
[07:37:07] galaxie: has joined #ruby
[07:40:10] mikecmpbll: has joined #ruby
[07:45:23] andikr: has joined #ruby
[07:45:28] esp32_prog: has joined #ruby
[07:49:42] kapilp: has joined #ruby
[08:03:31] ovnimancer: has joined #ruby
[08:13:08] weird_error: has joined #ruby
[08:21:26] teclator: has joined #ruby
[08:26:35] teclator: has joined #ruby
[08:26:36] miskatonic: has joined #ruby
[08:28:05] ellcs: has joined #ruby
[08:31:11] xco: has joined #ruby
[08:36:09] jenrzzz: has joined #ruby
[08:37:37] DarthGandalf: has joined #ruby
[08:41:48] Kestrel-029: has joined #ruby
[08:55:24] kyrylo_: has joined #ruby
[09:04:07] Jonopoly: has joined #ruby
[09:05:09] DTZUZO_: has joined #ruby
[09:06:00] andikr: has joined #ruby
[09:06:54] _axx8: has joined #ruby
[09:08:41] towo: has joined #ruby
[09:11:12] TheBrayn: has joined #ruby
[09:12:00] DTZUZO_: has joined #ruby
[09:16:30] kyrylo: has joined #ruby
[09:17:36] dhollinger: has joined #ruby
[09:20:55] tdy: has joined #ruby
[09:23:11] marz_d`ghostman: How do I remove characters like "\xe2\x80\x8b" in strings?
[09:24:20] mosh: has joined #ruby
[09:27:18] laaron: has joined #ruby
[09:31:52] arup_r: has joined #ruby
[09:48:45] laaron-: has joined #ruby
[09:56:48] blackmesa1: has joined #ruby
[09:58:59] kyrylo: has joined #ruby
[10:09:40] al2o3-cr: has joined #ruby
[10:10:31] RedSnarf: has joined #ruby
[10:16:43] marz_d`ghostman: '@gmail.com<U+200B>'.encode(Encoding.find('ASCII'), {:invalid => :replace, :replace => ''}) doesn't seem to remove the <U+200B> unicode, how do I remove it?
[10:16:44] dar123: has joined #ruby
[10:17:51] salerace: has joined #ruby
[10:21:11] _whitelogger: has joined #ruby
[10:21:49] mikecmpb_: has joined #ruby
[10:25:04] lunarkitty7: has joined #ruby
[10:38:46] andikr: has joined #ruby
[10:38:57] mikecmpbll: has joined #ruby
[10:43:59] apparition: has joined #ruby
[10:47:16] haxx0r: has joined #ruby
[10:52:51] DarthGandalf: has joined #ruby
[10:54:56] marmotini_: has joined #ruby
[10:55:06] AJA4350: has joined #ruby
[10:56:46] Nicmavr: has joined #ruby
[10:58:29] Jonopoly: anyone used Ruby & Selenium ?
[10:58:46] Jonopoly: $wait.until { $driver.find_element(:xpath => "//li[div[div[contains(text(), '"+waitFor+"')]]]") }
[10:59:17] Jonopoly: instead of addings sleep(1) on a new line is there another way to wait with try?
[10:59:38] Jonopoly: Try get this, wait 1 second and attempt 3 times or something
[11:09:24] Swyper: has joined #ruby
[11:13:21] gregf_: has joined #ruby
[11:14:11] vondruch_: has joined #ruby
[11:20:23] tf2ftw: has joined #ruby
[11:23:09] blackmesa1: has joined #ruby
[11:25:16] tdy: has joined #ruby
[11:25:38] GodFather: has joined #ruby
[11:26:29] za1b1tsu: has joined #ruby
[11:27:02] ricekrispie2: has joined #ruby
[11:32:07] DarthGandalf: has joined #ruby
[11:35:35] AJA4350: has joined #ruby
[11:38:45] blackmesa1: has joined #ruby
[11:44:16] kyrylo: has joined #ruby
[12:00:41] jenrzzz: has joined #ruby
[12:00:49] nowhere_man: has joined #ruby
[12:04:40] yield: has joined #ruby
[12:05:24] yield: has joined #ruby
[12:07:01] yield: has joined #ruby
[12:08:18] yield: has joined #ruby
[12:11:47] Kestrel-029: has joined #ruby
[12:19:10] conta: has joined #ruby
[12:24:55] clemens3: has joined #ruby
[12:25:48] AJA4350: has joined #ruby
[12:26:46] Nicmavr: has joined #ruby
[12:33:08] sleetdrop: has joined #ruby
[12:33:45] doodlebug: has joined #ruby
[12:39:45] doodleb76: has joined #ruby
[12:40:07] al2o3-cr: has joined #ruby
[12:41:47] Kestrel-029: has joined #ruby
[12:45:44] doodleb56: has joined #ruby
[12:46:08] queip: has joined #ruby
[12:55:45] yield: has joined #ruby
[12:56:46] Nicmavr: has joined #ruby
[12:59:48] octos: has joined #ruby
[13:02:33] yield: has joined #ruby
[13:04:42] aupadhye: has joined #ruby
[13:05:48] Swyper: has joined #ruby
[13:09:08] octos: has joined #ruby
[13:13:58] AJA4350: has joined #ruby
[13:15:29] SeepingN: has joined #ruby
[13:17:33] nowhere_man: has joined #ruby
[13:22:30] Swyper: has joined #ruby
[13:23:24] queip: has joined #ruby
[13:34:29] cd: has joined #ruby
[13:37:37] al2o3-cr: has joined #ruby
[13:47:06] hightower2: has joined #ruby
[13:47:26] WolfgangGrobar: has joined #ruby
[13:51:59] Sylario: has joined #ruby
[13:56:23] vondruch: has joined #ruby
[14:01:05] jenrzzz: has joined #ruby
[14:02:36] ryouba: has joined #ruby
[14:03:28] ryouba: is there anything that will do regex=/blah/;yes_or_no=str.match(regex);str.gsub!(regex) in one go?
[14:03:51] ryouba: sorry; `regex=/blah/;yes_or_no=str.match(regex);str.gsub!(regex, '')`
[14:04:57] havenwood: ryouba: with modern Rubies, it's faster and a bit less overhead to: yes_or_no=str.match?(regex)
[14:06:05] ryouba: havenwood: but that will still not remove the match from the string, right?
[14:06:18] havenwood: ryouba: true, it wont
[14:06:50] ryouba: okay, since you didn't mention anything about that, i guess i'll monkeypatch #match_and_gsub into String
[14:08:05] bougyman: why do you need that?
[14:08:13] bougyman: why not just str.gsub!(regex)
[14:08:19] bougyman: if the regex doesn't match, that'll just be a noop
[14:08:39] ryouba: bougyman: but does it tell me whether or not it matched?
[14:09:19] brool: has joined #ruby
[14:09:47] ryouba: oh, hmm, i guess it kind of does
[14:10:00] bougyman: [1] pry(main)> str = 'foo'; str.gsub! /a/, ''; $~
[14:10:07] bougyman: [2] pry(main)> str = 'foo'; str.gsub! /f/, ''; $~
[14:10:10] bougyman: => #<MatchData "f">
[14:10:12] bougyman: damn what's with all the spacing?
[14:10:13] bougyman: But yes, yes it does.
[14:10:21] Rapture: has joined #ruby
[14:11:29] bougyman: also: don't use $~ for anything real.
[14:11:46] ryouba: I didn't even know it existed :-P
[14:15:12] ryouba: btw i've started calling arrays of regular expression "regosaurs". as in: `regosaurs = [/one/, /two/, /.../]`. makes coding much more fun.
[14:20:28] schne1der: has joined #ruby
[14:21:15] WolfgangGrobar: What is more widely used in the ruby community: Test::Unit or Minitest (please ignore rspec)? Also what is usually used for mocking? Is the mocking stuff in minitest enough?
[14:25:53] AJA4350: has joined #ruby
[14:27:23] ua: has joined #ruby
[14:27:56] havenwood: WolfgangGrobar: Minitest
[14:30:47] spacesuitdiver: has joined #ruby
[14:32:43] DarthGandalf: has joined #ruby
[14:33:44] Jonopoly: Anyone used Ruby & Selenium for testing?
[14:34:32] havenwood: Jonopoly: Yes, that's popular.
[14:36:18] xco: Jonopoly: Yes :P
[14:37:37] WolfgangGrobar: Thank you, havenwood.
[14:38:58] xco: WolfgangGrobar: as far as i know Test::Unit is quite out-dated. These days it’ only Minitest you’d see around
[14:39:29] WolfgangGrobar: xco: good, then I'll use that
[14:40:41] Jonopoly: havenwood: xco: OH is it? I'm learning it now and its pretty fun
[14:46:38] conta: has joined #ruby
[14:48:25] cliluw: has joined #ruby
[14:48:37] spacesuitdiver: has joined #ruby
[14:52:25] cthulchu_: has joined #ruby
[14:55:27] zapata: has joined #ruby
[14:56:01] doodlebug: has joined #ruby
[14:56:40] doodlebug: has joined #ruby
[14:56:46] Nicmavr: has joined #ruby
[14:59:41] TheBrayn: has joined #ruby
[15:00:16] teclator: has joined #ruby
[15:09:01] vondruch: has joined #ruby
[15:13:28] jeremycw: has joined #ruby
[15:32:40] nowhereman: has joined #ruby
[15:34:54] WolfgangGrobar: has joined #ruby
[15:37:15] code_zombie: has joined #ruby
[15:38:08] blackmesa1: has joined #ruby
[15:40:33] WolfgangGrobar: What is the idiomatic ruby way to do the equivalent of dependency injection? I ask because of this Yegge quote: "Dependency Injection is [...] a popular new Java design pattern that programmers using Ruby [...] have probably never heard of. And if they've heard of it, they've probably (correctly) concluded that they don't need it."
[15:42:42] phaul: it can take shape like https://github.com/phaul/befunge/blob/master/lib/befunge/interpreter.rb#L15
[15:44:28] rippa: has joined #ruby
[15:45:14] phaul: not sure about being idiomatic there. it's debatable.
[15:46:08] WolfgangGrobar: This looks like standard constructor dependency injection with default params. What am I missing?
[15:49:46] adam12: WolfgangGrobar: There's a bunch of ways to "dependency inject" in Ruby. The constructor with default params is just one method. I don't think any specific way is "idiomatic".
[15:50:18] WolfgangGrobar: I understood the quote to mean that it would be done somehow different in ruby.
[15:50:50] adam12: WolfgangGrobar: Oh. I think people expect more than what is required.
[15:52:15] adam12: WolfgangGrobar: The simplest solution is indeed accessors and perhaps params to the constructor. At the opposite end of the scale is something like dry-auto_inject which is paired with some sort of IoC container.
[15:55:20] doodlebug: has joined #ruby
[15:57:04] WolfgangGrobar: I see, so it seems not really different.
[15:57:51] doodleb87: has joined #ruby
[15:59:54] nowhereman: has joined #ruby
[16:04:46] graphene: has joined #ruby
[16:09:32] nowhere_man: has joined #ruby
[16:14:23] tdy: has joined #ruby
[16:16:12] AJA4350: has joined #ruby
[16:19:56] conta: has joined #ruby
[16:21:35] sgen: has joined #ruby
[16:21:56] doodlebug: has joined #ruby
[16:26:47] Kestrel-029: has joined #ruby
[16:30:37] jenrzzz: has joined #ruby
[16:32:16] esp32_prog: has joined #ruby
[16:39:28] laaron: has joined #ruby
[16:40:48] code_zombie_: has joined #ruby
[16:42:37] sameerynho: has joined #ruby
[16:50:52] rprimus: has joined #ruby
[16:51:09] hmaronon: has joined #ruby
[16:51:41] brool: has joined #ruby
[16:52:39] duderonomy: has joined #ruby
[16:53:52] nowhere_man: has joined #ruby
[16:59:17] laaron-: has joined #ruby
[17:01:41] Fusl: has joined #ruby
[17:02:26] conta: has joined #ruby
[17:03:53] wildermind: has joined #ruby
[17:06:08] blackmesa: has joined #ruby
[17:06:34] al2o3-cr: has joined #ruby
[17:22:49] jeremycw: I think a lot of the cases to use DI go away when using ruby in many circumstances.
[17:23:09] jeremycw: In java you can't test anything without DI everywhere.
[17:23:43] jeremycw: Since ruby is way more dynamic if your only reason for DI is so you can swap in a mock or something during tests you don't really need it.
[17:24:01] fphilipe: has joined #ruby
[17:24:17] hiroaki: has joined #ruby
[17:25:10] jeremycw: instead you can just stub methods or use other dynamic features to accomplish the same thing.
[17:26:46] Nicmavr: has joined #ruby
[17:28:02] laaron: has joined #ruby
[17:30:54] ravenous_: has joined #ruby
[17:31:18] gix: has joined #ruby
[17:32:01] ravenous_: has joined #ruby
[17:32:06] doodleb97: has joined #ruby
[17:34:01] polishdub: has joined #ruby
[17:34:30] dellavg_: has joined #ruby
[17:35:10] laaron: has joined #ruby
[17:41:47] Kestrel-029: has joined #ruby
[17:42:59] blackmesa: has joined #ruby
[17:44:28] esp32_prog: has joined #ruby
[17:51:45] laaron: has joined #ruby
[17:58:57] mikecmpbll: has joined #ruby
[18:12:31] ta: has joined #ruby
[18:25:24] ShalokShalom43: has joined #ruby
[18:30:52] jenrzzz: has joined #ruby
[18:36:51] jenrzzz: has joined #ruby
[18:47:10] ShalokShalom: has joined #ruby
[18:56:11] ellcs: has joined #ruby
[18:56:56] Nicmavr: has joined #ruby
[19:02:02] ravenous_: has joined #ruby
[19:02:49] mad_al_: has joined #ruby
[19:04:48] Kilo`byte: has joined #ruby
[19:06:30] houhoulis: has joined #ruby
[19:08:08] AJA4351: has joined #ruby
[19:11:52] Kestrel-029: has joined #ruby
[19:13:44] houhoulis: has joined #ruby
[19:19:09] Inline: has joined #ruby
[19:20:15] mad_al: has joined #ruby
[19:20:17] reaVer: has joined #ruby
[19:25:00] fredolinhares: has joined #ruby
[19:32:42] esp32_prog: has joined #ruby
[19:33:50] doodlebug: has joined #ruby
[19:34:12] stryek: has joined #ruby
[19:38:56] spiette: has joined #ruby
[19:39:55] happyhans: has joined #ruby
[19:41:35] brool: has joined #ruby
[19:44:03] gix: has joined #ruby
[19:57:55] jenrzzz: has joined #ruby
[20:08:30] fphilipe: has joined #ruby
[20:11:51] Nicmavr: has joined #ruby
[20:18:04] Swyper: has joined #ruby
[20:21:13] octos: has joined #ruby
[20:26:08] Swyper_: has joined #ruby
[20:28:55] leitz: has joined #ruby
[20:30:26] jenrzzz: has joined #ruby
[20:31:13] AJA4350: has joined #ruby
[20:32:53] octos: has joined #ruby
[20:36:19] fphilipe: has joined #ruby
[20:39:45] jeremycw: has joined #ruby
[20:50:01] nevada1: has joined #ruby
[20:50:51] nevada1: Is there a more elegant way to split a number into groups of 3 digits? number.to_s.reverse.scan(/\d{1,3}/).map(&:reverse).map(&:to_i)
[20:52:32] nevada1: (and then getting the integer out of each group)
[20:59:17] mikecmpbll: nevada1 : what's all the reversing about?
[20:59:21] jenrzzz: has joined #ruby
[21:00:08] mikecmpbll: ah, so the incomplete group is always at the front?
[21:02:24] nevada1: e.g. 1_326_767 => '7676231' => ['767', '623', '1'] => (now comes reversing each one, because 623 should be 326) => ['767', '326', '1'] => [767, 326, 1]
[21:03:30] nevada1: It's basically 767 for hundreds, 326 for thousands, 1 for millions.
[21:04:13] nevada1: mikecmpbll: Hope I was clear enough.
[21:04:50] mikecmpbll: i see, yeah.
[21:05:15] mikecmpbll: there is a way without dealing with strings but i'm doubtful it'll be more elegant.
[21:05:26] Exuma: has joined #ruby
[21:05:49] luminousnine: has joined #ruby
[21:05:49] luminousnine: has joined #ruby
[21:07:29] nevada1: Ah, I see.
[21:08:31] jenrzzz: has joined #ruby
[21:09:09] xfbs: has joined #ruby
[21:11:08] octos: has joined #ruby
[21:13:43] octos: has joined #ruby
[21:16:12] octos: has joined #ruby
[21:18:21] SeepingN: has joined #ruby
[21:19:46] fphilipe: has joined #ruby
[21:20:57] esp32_prog: has joined #ruby
[21:22:03] gix: has joined #ruby
[21:27:05] Tempesta: has joined #ruby
[21:27:16] jenrzzz: has joined #ruby
[21:36:59] havenwood: &>> 1326767.digits.each_slice(3).map(&:join).join('_').reverse # nevada1
[21:37:02] rubydoc: # => "1_326_767" (https://carc.in/#/r/6ykv)
[21:38:45] mikecmpbll: never knew digits :>
[21:39:01] octos: has joined #ruby
[21:39:08] AJA4351: has joined #ruby
[21:40:10] jenrzzz: has joined #ruby
[21:42:54] nevada1: havenwood: Thanks, never knew digits gave them in reverse order.
[21:42:59] nevada1: That's helpful.
[21:48:17] mikecmpbll: should be poss with a regexp but i'm useless at it.
[21:56:06] havenwood: &>> 1326767.to_s.reverse.gsub(/(.{1,3})(?!$)/, '\1_').reverse # mikecmpbll
[21:56:07] rubydoc: # => "1_326_767" (https://carc.in/#/r/6ykx)
[21:56:45] jenrzzz: has joined #ruby
[21:57:53] mad_al: has joined #ruby
[21:58:15] Fernando-Basso: has joined #ruby
[21:59:35] octos: has joined #ruby
[22:01:26] nevada1: I actually only needed to end up with [767, 326, 1]
[22:02:19] nevada1: &>> 1326767.digits.each_slice(3).map(&:join).map(&:reverse).map(&:to_i)
[22:02:20] rubydoc: # => [767, 326, 1] (https://carc.in/#/r/6yl3)
[22:03:08] havenwood: nevada1: 1326767.digits.each_slice(3).map { |a| a.join.reverse.to_i }
[22:03:40] nevada1: Even better.
[22:04:37] nevada1: It would be cool if Ruby allowed something like map(&:join, &:reverse, &:to_i)
[22:04:47] laaron: has joined #ruby
[22:05:05] nevada1: But the block version is great.
[22:05:35] fphilipe: has joined #ruby
[22:05:49] mikecmpbll: how about ...
[22:05:56] mikecmpbll: do you need them in that reverse order, or?
[22:06:20] nevada1: I do, yes.
[22:09:47] mikecmpbll: &>> num = 1326767; (0...num.to_s.size).step(3).map{ |i| (num/10**i) % 1000 }
[22:09:48] rubydoc: # => [767, 326, 1] (https://carc.in/#/r/6yl6)
[22:09:55] mikecmpbll: that's my fav :p
[22:10:35] havenwood: &>> 1326767.digits.each_slice(3).map { |a, b = 0, c = 0| a + b * 10 + c * 100 }
[22:10:36] rubydoc: # => [767, 326, 1] (https://carc.in/#/r/6yl7)
[22:11:33] nevada1: If this isn't TIMTOWTDI at its finest, I don't know what is.
[22:13:15] fphilipe_: has joined #ruby
[22:15:39] nevada1: havenwood: I think this last version may be the most efficient since it's just adding and multiplying for each slice.
[22:18:34] nevada1: Actually, I don't know how Ruby does things in the backstage. map { |a| a.join.reverse.to_i} might be just as fast for all I know.
[22:19:08] havenwood: &>> 1326767.then { |n| 0.step(by: 3, to: Math.log10(n.abs).floor.succ).map { |i| n / 10 ** i % 1000 } }
[22:19:09] rubydoc: # => [767, 326, 1] (https://carc.in/#/r/6yl8)
[22:19:13] havenwood: nevada1: Math is fast.
[22:20:38] nevada1: Dear lord, the last one seems like an overkill.
[22:20:48] havenwood: Yeah, just being silly. ;)
[22:24:45] nevada1: In the end, I think this is the most readable. 1326767.digits.each_slice(3).map { |a| a.join.reverse.to_i }
[22:28:33] havenwood: nevada1: And the mathy `a + b * 10 + c * 100` one is fastest.
[22:28:41] havenwood: https://gist.github.com/havenwood/2e0985c044be9c5df4327b9c85848669
[22:29:46] havenwood: nevada1: It's super fast either way, so more readable might be nicer than 3x faster.
[22:30:05] nevada1: Thanks, man.
[22:30:29] nevada1: I am in such a love and hate relationship right now with Ruby.
[22:30:38] havenwood: Embrace the love.
[22:30:51] nevada1: You can do a lot if you know the right one-liners, or you can suffer terribly if you don't.
[22:32:18] leitz: nevada1, it took me a while to get over some frustrations but Ruby is my favorite language by far.
[22:32:32] leitz: First one I ever wanted to read the reference manual for.
[22:33:19] rocx: has joined #ruby
[22:33:44] nevada1: For a guy (me) who came from a background of verbose languages like Java or C#, Ruby's "less is more" style was a real struggle.
[22:33:53] havenwood: There's an ISO spec now to read! https://www.ipa.go.jp/files/000011432.pdf
[22:34:11] mikecmpbll: |a, b = 0, c = 0|: 440984.8 i/s - 1.48x slower >> in ruby 2.5.1
[22:34:50] mikecmpbll: (than step(3).map)
[22:35:23] havenwood: mikecmpbll: I was checking on the nightly build, hmmmm. I'm curious now.
[22:36:00] leitz: nevada1, I come from shell, with some python, perl, C, Go, PHP. When I tell people what's "the best language" I suggest they try several in whatever domain they want to program in. Ruby is the most joy for me.
[22:36:06] laaron: has joined #ruby
[22:36:53] rocx: nevada1: ruby has the advantage of being quicker and in a sense more pure when it comes to objects.
[22:36:55] leitz: havenwood, how relevant is that spec? It's 10 years old.
[22:37:17] leitz: I remember getting yelled at for using old Ruby. :)
[22:37:31] havenwood: leitz: It's mostly relevant, but yeah, it doesn't cover anything recent.
[22:37:40] leitz: Then I got yelled at for using new Ruby...
[22:37:44] nevada1: I mainly faced issues with Rubocop telling me how to do things. < 10 lines per method, too many assignments, blah-blah. I needed to adapt my way of thinking.
[22:38:12] leitz: nevada1, I quit using Rubocop. It's not a bad idea, but it's not the law.
[22:38:16] havenwood: mikecmpbll: I can reproduce your results... Intriguing!
[22:39:26] havenwood: mikecmpbll: It looks like it changes between 2.5 and 2.6.
[22:41:39] mikecmpbll: all benched on 2.5.1 here anyways; https://gist.github.com/mikecmpbll/a1523af6b84d2cf1553b6b89050740df
[22:42:03] mikecmpbll: most readable is slowest ;))
[22:42:20] mikecmpbll: i'm sure that speed is critical to your application!
[22:42:28] havenwood: mikecmpbll: step(3) is faster on 2.4 & 2.5 but b = 0, c = 0 is faster on 2.6 and dev. I guess 2.6 optimizations are paying off.
[22:42:34] doodleb45: has joined #ruby
[22:42:57] mikecmpbll: question is, is b = 0, c = 0 on 2.6 faster than step(3) on 2.5 ?
[22:43:25] havenwood: actually...
[22:43:51] havenwood: mikecmpbll: ah, I betcha that it's Enumerator Instruction Sequence...
[22:43:57] havenwood: yeah, that's gotta be it
[22:44:22] havenwood: that adds a penalty that's noticeable in this tight loop
[22:45:40] nevada1: In case you are curious why I needed such a silly thing in the first place. https://dpaste.de/z25P
[22:45:46] nevada1: I was working on that.
[22:46:40] AJA4351: has joined #ruby
[22:48:33] nevada1: It's now a (somewhat) decent number wordifier.
[22:50:36] mochiyoda_: has joined #ruby
[22:51:00] xco: has joined #ruby
[22:52:58] nevada1: I'm open to any suggestions if you see something that hurts your eyes.
[22:53:23] leitz: nevada1, smarter people than me have said you must code to get better at coding. Finding a language you enjoy coding in helps motivate that process.
[22:53:41] skryking: has joined #ruby
[22:53:50] nevada1: leitz: That sounds like a reasonable statement.
[22:55:40] leitz: I have been in Perl for a few months. Powerful language, makes me feel as worn out as Frodo and Sam crossing the wastes before going to Mordor. A day back with Ruby and I'm enjoying code again.
[22:56:37] fphilipe_: has joined #ruby
[22:56:49] nevada1: I was more or less forced to learn Ruby because of my job.
[22:57:02] nevada1: Still in a love and hate relationship with it.
[22:57:27] rocx: nevada1: if you think ruby's pretty good, wait until you try crystal.
[22:57:36] rocx: then you'll know the true meaning of a love-hate relationship. ;p
[22:57:43] nevada1: rocx: I did try it, actually.
[22:57:53] nevada1: I have only good things to say about it so far.
[22:58:04] rocx: makes me miss method overloading to be honest.
[22:58:19] leitz: Yeah, a job requirement can cause issues.
[22:58:59] nevada1: Specifying types is something I would love to be able to do in Ruby sometimes.
[22:59:15] nevada1: As in having that in the core language, not using some gem.
[22:59:24] Xiti: has joined #ruby
[22:59:43] rocx: hence the overloading. change how a method works based on type.
[23:09:13] esp32_prog: has joined #ruby
[23:10:41] leitz: There's some good to be said for Go. Not a bad language, typed, and the object system is much simpler.
[23:11:47] Kestrel-029: has joined #ruby
[23:12:14] nevada1: I like it because it's pretty C-like. Anything that resembles C is enjoyable for me.
[23:12:36] weird_error: has joined #ruby
[23:12:52] leitz: Yup. I'm glad your brain rejoices in C. Mine just barely gets it.
[23:13:17] nevada1: It's the first language I learned.
[23:13:21] doodlebug: has joined #ruby
[23:13:50] leitz: Wow. You're smarter than me then. I started on Pascal.
[23:14:41] nevada1: If smarter means needing to learn it for Computer Science, then yeah, haha.
[23:15:08] nevada1: But along the way came Ruby and it shattered everything.
[23:15:55] leitz: I was an electronics guy but needed some computer credits. Pascal, C, and Netware 3.
[23:16:39] nevada1: Another thing I kinda dislike about Ruby is that function calls can lack ( ).
[23:16:40] leitz: I've been an apprentice in a few languages but found Ruby and really started to understand more about OOP, testing, etc.
[23:17:32] leitz: "Whereever you go, there you are." I'd suggest leaving other language idioms with the other languages, it just makes your joy less.
[23:19:05] nevada1: Before diving into it, I thought it's only used with Rails and that's about it.
[23:20:31] nevada1: But maybe there's some truth in that. Before Rails, I don't think too many people knew about Ruby outside of Japan.
[23:20:37] nevada1: Or so I've heard.
[23:20:52] leitz: Sadly, that's most of the Ruby market. There are other web options and most anything you can do with Python or Perl you can do with Ruby. You can drop directly into C as needed.
[23:21:07] rocx: nevada1: first heard of it in RPG Maker XP. but that might still be the "japan" part.
[23:21:17] weird_error: has joined #ruby
[23:21:33] leitz: I first heard of it in Chef and Puppet, which is why I started learning it.
[23:23:23] nevada1: So yeah, 1996 to 2005, Ruby not as popular, then Rails comes along and books about it. You could create a blog in 15 minutes and that appealed to people. As other programming languages evolved and their respective frameworks, and new ones popped up, I think Ruby started declining a bit since... 2015?
[23:23:53] rocx: shame. it's a beautiful...ish language.
[23:25:08] jenrzzz: has joined #ruby
[23:26:40] nevada1: The community seems to be trying to branch out a bit from developing mainly with Rails. Dry-rb appears to be an alternative, or so it was stated in a 2017 Ruby conference.
[23:28:00] nevada1: But what do I know, I'm probably trying to preach to the pope here.
[23:28:18] rocx: nanoc's also a good site generator for the fact you can make it nearly do bloody well anything.
[23:28:35] leitz: Sinatra, Roda, for web. Puppet and Chef for Config mgmt. Really, lots of other stuff possible. The colleges seem to be moving to Python though.
[23:28:57] nevada1: Yeah, Python is in CS 101.
[23:28:58] rocx: > implying colleges will be moving away from java
[23:29:07] leitz: rocx, yes.
[23:29:15] nevada1: There's C, Python and Java in CS, mainly.
[23:29:34] rocx: ...C? in college? you sure undergrads will be able to understand pointers?
[23:29:46] leitz: The new Java license will spook a lot of folks and Python is winning the Data Science slot over R.
[23:29:52] rocx: because half of my java classes can't even grasp objects. some can't even grasp methods.
[23:29:59] nevada1: rocx: You bet, haha, it's what I had to do.
[23:30:54] nevada1: There's always OpenJDK, thankfully.
[23:31:10] nevada1: I also learned that you can run Ruby on the JVM, with JRuby.
[23:31:31] nevada1: Though I don't know how popular that is.
[23:32:35] rocx: probably not so popular since ruby's popularity is declining thanks to everyone moving everything to js.
[23:32:50] rocx: (and it's a righteous pain in the butt if your hardware isn't top-of-the-line)
[23:33:36] nevada1: It's amazing to see how a language that was never intended to deliver anything more than a little DOM manipulation became what it is today.
[23:33:52] rocx: and a poor one at that.
[23:34:17] nevada1: It appeals to people because it's easy to write.
[23:34:39] brool: i hate the js craze
[23:34:52] brool: we need more c++ and websites should be written in WASM
[23:35:03] brool: ACTION runs
[23:35:04] rocx: nevada1: and then how it handles types becomes problematic.
[23:35:24] rocx: typeof([] + []) for example
[23:35:35] rocx: and "0" == 0 and 0 == [] but "0" != []
[23:35:37] nevada1: You have TypeScript that... tries to solve that.
[23:35:41] brool: one thing that's evidently very bad about the js craze is how people are writing native desktop applications with it using electron
[23:35:49] brool: discord makes my fans spin just by being idle
[23:35:50] rocx: brool: and that's just chrome.
[23:35:52] darix: has joined #ruby
[23:36:02] brool: firefox with 20 tabs and multiple windows doesn't do that
[23:36:19] brool: coffeescript best javascript
[23:37:30] brool: it's like ruby and python had a javascript baby
[23:37:39] nevada1: Can you imagine the layers of abstraction? You have the hardware, the OS, the graphical environment, a (headless) browser that runs on top of it and needs to make OS calls and an interpreter inside it.
[23:37:48] fphilipe_: has joined #ruby
[23:38:01] nevada1: It's huge.
[23:38:01] brool: ACTION runs back to gcc
[23:38:09] brool: ACTION clings to machine code
[23:38:50] jenrzzz: has joined #ruby
[23:38:53] brool: AND you have people trying to use and learn OOP design patterns in a language that doesn't even really do OOP
[23:39:02] nevada1: OOP is weird because every language implements it differently.
[23:39:27] nevada1: Python doesn't even have proper encapsulation.
[23:39:29] brool: javascript does OLOO :^)
[23:39:51] nevada1: You prefix variables with __ to make them appear private.
[23:39:56] nevada1: That's a joke.
[23:40:04] brool: heh yeah python is pretty ugly
[23:40:20] brool: it's like the nerdy kid at school who went on to be a scientist but nobody will ever date him
[23:41:04] nevada1: More like the guy who tries to do everything but does a lot of things badly.
[23:41:06] AJA4350: has joined #ruby
[23:41:15] brool: " ".join(reverse(string.split())) [iirc]
[23:41:17] nevada1: Maybe except Machine Learning.
[23:41:46] Nicmavr: has joined #ruby
[23:41:48] brool: why no string.split("").reverse.join(" ")
[23:41:54] brool: cus that's pretty
[23:42:05] brool: you see what's going on in the order it makes sense to think about it
[23:44:32] Freshnuts: has joined #ruby
[23:46:06] nevada1: How do you add functionality do Ruby? Do you write C programs using the ruby header files?
[23:46:09] edwardly: has joined #ruby
[23:46:09] edwardly: has joined #ruby
[23:46:50] brool: you write ruby
[23:57:01] nevada1: has left #ruby: ()