« Back to channel list

#ruby - 02 February 2019

« Back 1 day Forward 1 day »
[00:08:29] alfiemax: has joined #ruby
[00:28:05] AJA4350: has joined #ruby
[00:33:10] _whitelogger: has joined #ruby
[00:42:49] cow[moo]: has joined #ruby
[00:47:24] agent_white: has joined #ruby
[01:26:21] Renich_: has joined #ruby
[01:28:35] TomyLobo: has joined #ruby
[01:45:17] alfiemax: has joined #ruby
[01:51:24] alfiemax: has joined #ruby
[01:54:28] tdy: has joined #ruby
[01:55:41] braincrash: has joined #ruby
[01:58:29] cnsvc: has joined #ruby
[02:06:13] znz_jp: has joined #ruby
[02:13:57] rkazak: has joined #ruby
[02:30:32] moei: has joined #ruby
[02:33:17] tdy: has joined #ruby
[02:55:26] apparition: has joined #ruby
[03:00:23] rkazak: has joined #ruby
[03:08:36] \void: has joined #ruby
[03:15:11] z4phod: has joined #ruby
[03:17:44] tdy: has joined #ruby
[03:20:42] rkazak: has joined #ruby
[03:21:17] laaron: has joined #ruby
[03:23:41] braincrash: has joined #ruby
[03:30:32] tdy: has joined #ruby
[03:49:27] alfiemax: has joined #ruby
[03:56:16] robscomputer: has joined #ruby
[03:59:03] Renich: has joined #ruby
[04:09:05] braincrash: has joined #ruby
[04:12:57] tdy: has joined #ruby
[04:23:39] alfiemax: has joined #ruby
[04:27:11] _whitelogger: has joined #ruby
[04:40:00] jcalla: has joined #ruby
[05:09:43] rkazak: has joined #ruby
[05:11:10] segy: has joined #ruby
[05:20:36] dinfuehr: has joined #ruby
[05:32:28] dinfuehr: has joined #ruby
[05:34:20] alfiemax: has joined #ruby
[05:36:34] rippa: has joined #ruby
[05:47:30] dinfuehr: has joined #ruby
[05:48:41] rkazak: has joined #ruby
[05:56:00] Xiti: has joined #ruby
[05:59:35] cnsvc: has joined #ruby
[06:09:25] rkazak: has joined #ruby
[06:16:59] \void: has joined #ruby
[06:28:04] d^sh: has joined #ruby
[06:31:28] armyriad: has joined #ruby
[06:31:35] dinfuehr: has joined #ruby
[06:32:54] sauvin: has joined #ruby
[06:36:34] dinfuehr: has joined #ruby
[06:41:35] dinfuehr: has joined #ruby
[07:01:46] JanMrlth: has joined #ruby
[07:21:34] orbyt_: has joined #ruby
[07:26:53] nfk: has joined #ruby
[07:57:53] kapil____: has joined #ruby
[08:00:48] n13z: has joined #ruby
[08:04:39] ravenousmoose: has joined #ruby
[08:19:37] alfiemax: has joined #ruby
[08:33:10] _whitelogger: has joined #ruby
[08:39:20] blackmesa1: has joined #ruby
[08:46:32] blackmesa1: has joined #ruby
[08:52:58] ravenousmoose: has joined #ruby
[09:00:41] n13z: has joined #ruby
[09:17:59] rkazak: has joined #ruby
[09:29:37] gix: has joined #ruby
[09:29:43] mcspud: has joined #ruby
[09:40:43] mcspud: Hi all, new to ruby but very experienced developer. Does anyone know why i'm getting rounding errors? https://dpaste.de/0LW4
[09:43:20] Fernando-Basso: has joined #ruby
[09:44:51] up|ime: mcspud: sounds like floating point maths to me
[09:45:14] up|ime: without linking code, our best guess is exactly that ^
[09:45:21] mcspud: Yeah, but even at 2pts of precision? 1.15 + 3.35
[09:45:26] mcspud: Yep one moment
[09:45:33] Nicmavr: has joined #ruby
[09:45:45] up|ime: [zarthus@nomenclature ~] $ irb
[09:45:46] up|ime: irb(main):001:0> 3.50 + 3.03
[09:45:46] up|ime: => 6.529999999999999
[09:46:15] al2o3-cr: mcspud: use Rationals
[09:46:23] mcspud: Any arbitrary precision think you can recommend
[09:46:31] mcspud: s/think/thing
[09:46:35] up|ime: if you're dealing with money, use a money lib
[09:46:52] mcspud: al2o3-cr - Sorry I literally started using ruby 2 hours ago - I've written my solution, I just can't get this test topass :)
[09:47:00] mcspud: Is rationals in the stdlib?
[09:47:01] al2o3-cr: &>> 3.50r + 3.03r == 6.53
[09:47:05] rubydoc: # => true (https://carc.in/#/r/65b9)
[09:47:39] al2o3-cr: &ri Rational mcspud
[09:47:39] rubydoc: mcspud: https://ruby-doc.org/core-2.6/Rational.html
[09:47:45] mcspud: great thanks
[09:48:07] up|ime: a money lib for monetary operations might still be preferred
[09:48:08] moei: has joined #ruby
[09:48:32] mcspud: up|ime - naa its just a simple test where I have to import some json files and calculate some simple prices
[09:49:35] mcspud: This is my main line - @payments.reduce(0) { |acc, payment| acc + payment.amount}, can I use something to cast those values to rationals as I go?
[09:49:51] mcspud: Maybe even setting the initial reduction to 0r?
[09:50:40] al2o3-cr: mcspud: sure.
[09:51:51] al2o3-cr: oh, wait. no.
[09:52:22] al2o3-cr: you'd have to make sure what your summing is rational
[09:53:57] mcspud: So from the docs I can wrap it in the Kernal#Rational class, but the tests are looking for floats and ints (ie like 5.5) and not something like (11/2)
[09:54:07] mcspud: Any ideas?
[09:54:21] al2o3-cr: &>> 3.50r + 3.03r == 6.53
[09:54:23] rubydoc: # => true (https://carc.in/#/r/65bc)
[09:55:42] al2o3-cr: it doesn't matter if it returns (11/2) or whatever.
[09:56:28] mcspud: Does if the test doesn't pass :)
[09:56:43] al2o3-cr: it's not passing?
[09:58:43] mcspud: al2o3-cr - https://dpaste.de/t0Xo
[10:00:24] conta: has joined #ruby
[10:01:06] al2o3-cr: i don't see why that isn't working, try Rational(order_total - payment_total).to_f
[10:03:03] mcspud: al2o3-cr - https://dpaste.de/oNVL comes back with that precision issue
[10:03:28] mcspud: I'm on 2.3.7 if you know of anything that was funky in this release
[10:04:00] al2o3-cr: not that i know of, there's something else wrong with your code.
[10:04:38] al2o3-cr: &>> Rational(8.00 - 2.50).to_f
[10:04:40] rubydoc: # => 5.5 (https://carc.in/#/r/65bh)
[10:04:55] al2o3-cr: maybe show your whole code.
[10:05:13] mcspud: sure, 1 moment
[10:09:46] al2o3-cr: bb in a sec.
[10:11:33] mcspud: al2o3-cr - https://dpaste.de/2jzj
[10:15:48] al2o3-cr: one sec taking a look.
[10:22:01] mcspud: Cheers dude
[10:27:57] Dbugger: has joined #ruby
[10:30:54] al2o3-cr: mcspud: i see what it is, how to fix without converting all json value to rational.
[10:31:37] mcspud: Ahh, what is it?
[10:32:09] mcspud: This package has good reviews: https://github.com/ruby/bigdecimal - I was going to wrap any of the calculations with it and pray for the best :)
[10:33:02] al2o3-cr: because the values are assigned to variables
[10:33:05] al2o3-cr: &>> [(3.50r + 3.03r).to_f, Rational(x=3.50 + y=3.03).to_f]
[10:33:05] rubydoc: # => [6.53, 6.529999999999999] (https://carc.in/#/r/65bt)
[10:35:50] clemens3: has joined #ruby
[10:36:11] al2o3-cr: you'll have to same problem with bigdecimal too.
[10:37:01] ellcs: has joined #ruby
[10:37:03] al2o3-cr: mcspud: just round(2)
[10:37:40] mcspud: So (val1 + val2).round(2) ?
[10:37:54] al2o3-cr: mcspud: yes.
[10:39:17] mcspud: awesome give me a miunte
[10:39:42] al2o3-cr: not the best solution, but...
[10:41:01] icy`: puts "%.2f" % (3.50 + 3.03)
[10:41:21] icy`: you just want it to appear rounded right? sprintf style ^
[10:41:29] mcspud: Finished in 0.01419 seconds (files took 0.10393 seconds to load)
[10:41:29] mcspud: 5 examples, 0 failures
[10:41:35] mcspud: Awesome thanks so much
[10:42:01] ua_: has joined #ruby
[10:42:08] mcspud: One more question, is MyClass.call a special signature?
[10:42:25] mcspud: I had to modify their test suite to use MyClass.new instead of call
[10:42:51] al2o3-cr: no, call is just a method on the class MyClass
[10:44:15] mcspud: Ok thanks
[10:44:52] al2o3-cr: np mcspud ;)
[10:44:54] Zarthus: has joined #ruby
[10:45:06] szulak_: has joined #ruby
[10:45:35] Zarthus: has joined #ruby
[10:46:56] Zarthus: has joined #ruby
[10:47:14] reber: has joined #ruby
[10:53:19] Zarthus: has joined #ruby
[10:53:26] al2o3-cr: up|ime: are you Zarthus too?
[10:53:48] Renich: has joined #ruby
[10:55:00] Zarthus: al2o3-cr: Yeah, though this should be the final disconnect
[10:55:54] al2o3-cr: ah, no probs, just from the irb paste ;)
[10:56:27] up|ime: the bot was having problems and I couldn't bother finding out what the syntax would be :P
[10:56:31] up|ime: so I just booted up ssh+irb
[10:58:32] Zarthus: has joined #ruby
[10:58:58] lxsameer: has joined #ruby
[11:08:40] roshanavand: has joined #ruby
[11:10:35] Zarthus: has joined #ruby
[11:16:39] Zarthus: ping @ops: all urls in the ENTRYMSG of this channel support https from the looks of it
[11:23:36] Zarthus: has joined #ruby
[11:28:15] sezuan: has joined #ruby
[11:30:35] d^sh: has joined #ruby
[11:32:38] Zarthus: has joined #ruby
[11:38:46] lucasb: has joined #ruby
[11:47:59] conta: has joined #ruby
[11:56:25] mikecmpbll: has joined #ruby
[12:02:25] AJA4350: has joined #ruby
[12:07:14] ravenousmoose: has joined #ruby
[12:11:48] blackmesa: has joined #ruby
[12:14:55] themsay: has joined #ruby
[12:16:28] roshanavand: has joined #ruby
[12:24:55] xrexeon: has joined #ruby
[12:26:09] marz_d`ghostman: has joined #ruby
[12:28:01] marz_d`ghostman: I'm running my ruby script via cron: scl enable rh-ruby24 /usr/bin/local/ruby_script. Is there a shortcut where it would read and use the ruby version and gemset of that script?
[12:28:14] marz_d`ghostman: Currently I'm getting an error running it unless I run it when i'm on the directory itself
[12:28:57] themsay: has joined #ruby
[12:30:37] universa1: has joined #ruby
[12:32:25] conta: has joined #ruby
[12:50:59] dellavg__: has joined #ruby
[13:01:50] nowhereman: has joined #ruby
[13:02:39] roshanavand: has joined #ruby
[13:11:24] j416: marz_d`ghostman: are you using bundler?
[13:25:57] j416: marz_d`ghostman: 'bundler exec' perhaps?
[13:26:20] conta: has joined #ruby
[13:27:25] marz_d`ghostman: j416: it install in the directory itself, when the command to run the script is run via cron, it doesn't seem to use the gemset installed by bundler
[13:28:41] akemot: has joined #ruby
[13:28:46] roshanavand: has joined #ruby
[13:30:24] roshanavand: has joined #ruby
[13:32:28] j416: marz_d`ghostman: did you try 'bundler exec'?
[13:32:44] roshanavand: has joined #ruby
[13:36:14] marz_d`ghostman: j416: Ah I just got that, let me try
[13:45:43] hrrz: has joined #ruby
[13:46:32] hrrz: hi - i'm struggling installing ruby on centos without gcc. any idea? I use the following ./configure -prefix=/home/wf/env --without-gcc - and getting checking whether the C compiler works... no
[13:50:15] dviola: has joined #ruby
[14:03:26] hrrz: anyone knows?
[14:05:07] alfiemax: has joined #ruby
[14:05:19] hrrz: hi - i'm struggling installing ruby on centos without gcc. any idea? I use the following ./configure -prefix=/home/wf/env --without-gcc - and getting checking whether the C compiler works... no
[14:11:19] darix: hrrz: you need a C compiler to build ruby. there is no way around it.
[14:13:53] hrrz: darix: i tried now a different approach, running configure on a host with gcc and then moving the Makefile and dir to a host with only clang - i saw an a python example that it works. but still failing with
[14:14:13] hrrz: this: /usr/bin/ld: cannot find crtbeginS.o: No such file or directory
[14:14:37] darix: hrrz: export CC=clang CXX=clang++
[14:14:39] darix: run configure
[14:14:53] hrrz: on the gcc host?
[14:16:34] darix: on the machine where you want to build it
[14:18:14] hrrz: darix: still getting: checking whether the C compiler works... no
[14:19:12] darix: see config.log
[14:47:52] ravenousmoose: has joined #ruby
[14:52:26] rkazak: has joined #ruby
[14:58:50] hrrz: darix: https://www.pastiebin.com/5c55b00bde373
[15:12:07] cthu|: has joined #ruby
[15:15:34] Iambchop: hrrz: this is from debian not centosm but: "clang-3.4 can't compile programs in a minimal chroot...install libgcc-4.7-dev or libgcc-4.8-dev, the problem goes away" https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=754963
[15:16:19] cthulchu_: has joined #ruby
[15:22:08] kapil____: has joined #ruby
[15:39:55] Fernando-Basso: has joined #ruby
[15:44:07] cd: has joined #ruby
[15:47:19] rkazak: has joined #ruby
[16:07:23] alfiemax_: has joined #ruby
[16:09:24] jottr: has joined #ruby
[16:28:33] rkazak: has joined #ruby
[16:31:22] moonglum[m]: has joined #ruby
[16:32:52] conta: has joined #ruby
[16:36:51] nowhereman: has joined #ruby
[16:41:58] hays: is there a data structure that is basically a hash where both key and value are keys? bidirectional essentially
[16:42:22] hays: within ruby that is.. i think its easy enough to make one, using two hashes
[16:49:58] havenwood: hays: Are the values unique?
[16:50:47] hays: for each k there exists only one k in the set and same for v
[16:51:39] havenwood: hays: Then an option with Hash is to #invert before looking up values.
[16:52:25] hays: invert is O(n) i bet
[16:52:32] havenwood: &>> h = {a: 1, b: 2, c: 3}; h.invert[2]
[16:52:35] rubydoc: # => :b (https://carc.in/#/r/65fl)
[16:53:09] hays: there's rassoc too i think
[16:54:05] havenwood: hays: https://github.com/ruby/ruby/blob/e1e3d642bfaf8f8c1a94687442cf51c897f8abdf/hash.c#L3505-L3510
[16:55:12] havenwood: https://github.com/ruby/ruby/blob/e1e3d642bfaf8f8c1a94687442cf51c897f8abdf/hash.c#L3505-L3510
[16:55:49] havenwood: oops, meant that second one to link a few lines down - rb_hash_foreach
[17:00:06] orbyt_: has joined #ruby
[17:00:22] hays: a decent option if im creating it once and not really updating it
[17:01:30] arekushi: has joined #ruby
[17:10:35] havenwood: hays: Yeah, if you're not mutating the Hash, invert once and have two Hashes - one for each direction.
[17:10:58] havenwood: hays: Are you changing values or adding keys often?
[17:11:19] hays: not in this use case
[17:15:48] akem: has joined #ruby
[17:37:06] rkazak: has joined #ruby
[17:39:22] AJA4351: has joined #ruby
[18:12:58] agent_white: has joined #ruby
[18:14:12] snowflakekiller: has joined #ruby
[18:21:43] conta: has joined #ruby
[18:40:58] rkazak: has joined #ruby
[18:42:31] robscomputer: has joined #ruby
[18:43:48] IGnorAND: has joined #ruby
[19:04:41] ellcs: has joined #ruby
[19:05:44] hahuang6-: has joined #ruby
[19:08:47] PasNox: has joined #ruby
[19:21:14] Renich: has joined #ruby
[19:25:36] uplime: has joined #ruby
[19:51:25] Zarthus: has joined #ruby
[20:00:33] blackmesa: has joined #ruby
[20:01:18] blackmesa: hi all. according to this article https://mixandgo.com/learn/understanding-boolean-operator-precedence-in-ruby
[20:01:24] blackmesa: result = true and false
[20:01:29] blackmesa: results in true
[20:01:37] blackmesa: in my ruby console its false
[20:05:29] leftylink: correction: the result of the expression is false, but `result` is true.
[20:06:01] leftylink: &>> xxx = (result = true and false); [xxx, result]
[20:06:03] rubydoc: # => [false, true] (https://carc.in/#/r/65hc)
[20:08:12] leftylink: the ruby console shows you the value of the last expression, which is not necessarily the same as the value assigned to any variables that may have been present
[20:25:18] Nicmavr: has joined #ruby
[20:34:10] raulp: has joined #ruby
[20:35:13] havenwood: blackmesa: it's similar to: false if result = true
[20:35:33] \void: has joined #ruby
[20:36:10] havenwood: blackmesa: with explicit parens: (result = true) and false
[20:40:45] baweaver: New stream just finished - Exploring ASTs - https://www.twitch.tv/videos/374107796
[20:45:18] FernandoBasso: has joined #ruby
[20:45:32] wilbert: has joined #ruby
[20:49:15] AJA4350: has joined #ruby
[21:16:40] arcaos: has joined #ruby
[21:17:07] alfiemax: has joined #ruby
[21:20:53] jlauer: has joined #ruby
[21:36:56] krawchyk: has joined #ruby
[21:52:58] Inline: has joined #ruby
[21:58:50] orbyt_: has joined #ruby
[21:59:25] wilbert: has joined #ruby
[22:03:10] Dreamer3: has joined #ruby
[22:47:42] agent_white: has joined #ruby
[22:58:42] TomyLobo: has joined #ruby
[23:00:43] duckpupp-: has joined #ruby
[23:00:45] ruby[bot]: has joined #ruby
[23:00:46] ChanServ: +o ruby[bot]
[23:01:17] ruby[bot]: -b+b *!~horriblep@unaffiliated/nightcoder *!~horriblep@unaffiliated/nightcoder$#ruby-banned
[23:03:11] tdy: has joined #ruby
[23:06:12] Swyper: has joined #ruby
[23:07:11] alfiemax: has joined #ruby
[23:32:04] houhoulis: has joined #ruby
[23:33:42] Milos: has joined #ruby
[23:35:25] xrexeon: has joined #ruby
[23:52:56] themsay: has joined #ruby
[23:55:37] clemens3_: has joined #ruby