« Back to channel list

#ruby - 01 August 2018

« Back 1 day Forward 1 day »
[00:04:13] graphene: has joined #ruby
[00:04:33] graft: has joined #ruby
[00:05:02] graft: okay so everyone knows ary.inject(Hash.new(0)) {|count,i| count[i] +=1; count}
[00:05:09] graft: is there a shorter way to do this in 2.5?
[00:08:48] havenwood: graft: ary.group_by(&:itself).map { |k, v| [k, v.count] }.to_h
[00:09:12] havenwood: graft: There's an Enumerable#count_by proposed by Nobu I believe for Ruby 2.6.
[00:10:19] havenwood: https://bugs.ruby-lang.org/issues/11076
[00:10:38] havenwood: graft: Ah, baweaver actually points out a better 2.5 solution...
[00:10:54] havenwood: graft: ary.group_by(&:itself).transform_values(&:size)
[00:11:34] havenwood: graft: In 2.6: ary.count_by(&:itself)
[00:11:46] havenwood: (If #count_by is accepted.)
[00:13:55] eckhardt: has joined #ruby
[00:21:53] tty: has joined #ruby
[00:22:19] baweaver: havenwood havenwood havenwood!!! https://bugs.ruby-lang.org/issues/14869 && https://bugs.ruby-lang.org/issues/14916
[00:30:27] Radar: That fizzbuzz example from #14916 is cool
[00:37:35] r29v: has joined #ruby
[00:52:09] cagomez: has joined #ruby
[00:52:45] ule: Hey guys, what would you use to paginate a hash? Lets say I have a list with 100 items and want to paginate this into 5 groups
[00:53:04] ule: Not sure if there is a magic enumerable method that does this out of the box
[00:53:25] ule: a kind of group_by(n elements)
[00:56:06] ali_g: has joined #ruby
[00:56:49] havenwood: ule: each_slice
[00:57:25] leitz: Looking at the dry-core gem. In lib/ there's directory dry and file dry-core.rb that just has require 'lib/dry/core'. In lib/dry/core there's a dry directory and 'core.rb' that just has Module Core inside module Dry, with no other real code. There are ruby files in lib/dry/core that have Module Core defined inside Module Dry. Is the "require 'lib/dry/core'
[00:57:25] leitz: in the first file what sets this module up to be used?
[00:58:57] ali_g: Hello, everyone! can somebody help me with this one? https://gist.github.com/ponentesincausa/fc3e94bd48392f1b213e862d74dadec1
[00:59:42] ali_g: I am using map because that variable may sometimes collect several amount keys
[00:59:45] havenwood: ["amount", "700"]["amount"]
[00:59:59] havenwood: #!> TypeError: no implicit conversion of String into Integer
[01:00:58] havenwood: ali_g: In Ruby 2.5: h.transform_values(&:to_f)
[01:01:12] ali_g: if I h["amount"] it throws "700", why would the result be ["amount", "700"]["amount"]?
[01:01:22] havenwood: I guess 2.4 has #transform_values too
[01:04:30] havenwood: >> h = {"amount"=>"700", "dueDate"=>"2018-07-31"}; h.first # ali_g
[01:04:31] ruby[bot]: havenwood: # => ["amount", "700"] (https://eval.in/1043415)
[01:05:39] leitz: has left #ruby: ()
[01:08:50] havenwood: ali_g: When you #map over a Hash the |a| in your block argument is indeed an Array of two elements, the key and value.
[01:09:09] havenwood: (I'm assuming `a` is short for Array, in your naming scheme.)
[01:09:47] havenwood: ali_g: Your example would work with: a.first.to_f
[01:10:17] havenwood: ali_g: `a` is an Array, not a Hash, so you can't use #[] with "amount" since Array#[] expects an Integer.
[01:10:32] Freshnuts: has joined #ruby
[01:11:21] havenwood: ali_g: Does that make sense?
[01:11:49] ali_g: @havenwood I am seeing my mistake now, I thought I was grabbing a value from the key but I wasn't, I ended up with two array of 2 values. I can't use .first because the h in the example will be changing sometimes including more than one "amount" value, but I conclude from what you are saying that map is the wrong tool for this
[01:13:26] havenwood: ali_g: h['amount'].to_f #=> has 700.0
[01:14:25] ali_g: I'm looking to return an array with all the values for amount converted to string
[01:14:32] ali_g: sorry, converted to float
[01:16:58] havenwood: ali_g: h.merge({'amount' => h['amount'].to_f})
[01:17:27] havenwood: ali_g: h['amount'] = h['amount'].to_f; h
[01:17:49] havenwood: ali_g: ^o those are two ways amongst many
[01:18:34] havenwood: ali_g: oh, you just want the values for amount? sec
[01:18:51] havenwood: ali_g: you have an array of these hashes?
[01:19:28] havenwood: ali_g: a.map { |h| h['amount'].to_f }
[01:19:48] havenwood: ali_g: If you show what you really have, I'm sure we can show you an efficient solution.
[01:20:09] havenwood: ali_g: "an array with all the values for amount converted to string"
[01:20:13] havenwood: ali_g: is that really what you want?
[01:20:16] havenwood: I'm confused!
[01:20:40] havenwood: ali_g: a.map { |h| h['amount'].to_f.to_s }
[01:20:54] havenwood: Just stabbing wildly at this point.
[01:22:47] ule: havenwood: thanks!
[01:36:29] graphene: has joined #ruby
[01:39:44] lxsameer: has joined #ruby
[01:39:54] white_lilies: has joined #ruby
[01:40:10] cagomez: has joined #ruby
[01:43:42] darkhanb: has joined #ruby
[02:04:13] graphene: has joined #ruby
[02:06:54] memo1: has joined #ruby
[02:30:26] memo1: has joined #ruby
[02:32:38] graphene: has joined #ruby
[02:46:03] Azure: has joined #ruby
[02:57:40] ur5us: has joined #ruby
[02:58:35] ur5us: has joined #ruby
[03:00:31] cadillac_: has joined #ruby
[03:02:44] agent_white: has joined #ruby
[03:10:39] braincrash: has joined #ruby
[03:20:45] scrptktty: has joined #ruby
[03:21:35] kapil___: has joined #ruby
[03:40:26] lxsameer: has joined #ruby
[03:42:04] donofrio: has joined #ruby
[03:42:50] dinfuehr: has joined #ruby
[03:47:07] dinfuehr_: has joined #ruby
[04:10:48] nowhere_man: has joined #ruby
[04:39:19] lxsameer: has joined #ruby
[04:43:48] ur5us: has joined #ruby
[04:53:46] Tempesta: has joined #ruby
[04:54:15] za1b1tsu: has joined #ruby
[05:40:48] sauvin: has joined #ruby
[05:42:29] thinkpad: has joined #ruby
[05:45:44] reber: has joined #ruby
[05:49:30] thinkpad: has joined #ruby
[05:51:47] sauvin: has joined #ruby
[06:00:31] biberu: has joined #ruby
[06:06:17] bak1an: has joined #ruby
[06:12:03] snickers: has joined #ruby
[06:17:52] asphyxia: has joined #ruby
[06:18:20] conta: has joined #ruby
[06:18:48] Zaab1t: has joined #ruby
[06:19:06] Tempesta: has joined #ruby
[06:33:25] CJKinni: has joined #ruby
[06:37:44] nicesignal: has joined #ruby
[06:42:36] yohji: has joined #ruby
[06:53:00] dionysus69: has joined #ruby
[07:02:30] Dbugger: has joined #ruby
[07:14:04] Matrix9180: has joined #ruby
[07:20:23] mikecmpbll: has joined #ruby
[07:22:29] Sylario: has joined #ruby
[07:26:57] alfiemax: has joined #ruby
[07:33:02] badeball: gosh, I dislike it when I search for a method and docs.ruby-lang.org comes before ruby-doc.org
[07:33:31] badeball: I can't be the only one who finds it a bit hard to read green text on a white background, can I?
[07:33:41] elomatreb: ri is your friend, at least for pretty much anything in the standard library
[07:33:51] clemens3: has joined #ruby
[07:36:49] badeball: cli documentation you say? installed it, but I get $ ri Array.sort # => Nothing known about Array
[07:37:24] elomatreb: Did you build your Ruby without documentation by accident?
[07:37:59] badeball: I'm running arch, so it's packaged, but it wouødn't surprise me if that was the case
[07:38:07] badeball: however, I don't think they do it accidentally
[07:39:26] badeball: ah, there's a separete package called ruby-docs
[07:39:33] havenwood: badeball: pacman -S ruby-rdoc ruby-docs
[07:40:45] badeball: this is pretty crazy stuff, ri
[07:42:46] elomatreb: It's really nice yeah. If you use pry as your REPL it also has built-in ri commands, so you don't have to leave
[07:43:32] badeball: I've only really been using irb
[07:43:37] badeball: in what other ways am I missing out?
[07:44:12] elomatreb: Syntax highlighting and a whole bunch of convenience features
[07:46:55] tj-: has joined #ruby
[07:48:33] pistachio: has joined #ruby
[07:49:00] redlegion1: has joined #ruby
[07:49:24] redlegion1: has joined #ruby
[07:50:10] redlegion1: has joined #ruby
[07:50:35] redlegion1: has joined #ruby
[07:50:59] redlegion1: has joined #ruby
[07:51:44] redlegion1: has joined #ruby
[07:52:09] redlegion1: has joined #ruby
[07:52:33] redlegion1: has joined #ruby
[07:53:18] redlegion1: has joined #ruby
[07:53:42] redlegion1: has joined #ruby
[07:54:07] redlegion1: has joined #ruby
[07:54:53] redlegion1: has joined #ruby
[07:55:17] redlegion1: has joined #ruby
[07:55:42] redlegion1: has joined #ruby
[07:56:28] redlegion1: has joined #ruby
[07:56:53] redlegion1: has joined #ruby
[07:57:02] sameerynho: has joined #ruby
[07:57:18] redlegion1: has joined #ruby
[07:58:05] redlegion1: has joined #ruby
[07:58:30] redlegion1: has joined #ruby
[07:58:55] redlegion1: has joined #ruby
[08:05:56] lxsameer: has joined #ruby
[08:12:12] xall: has joined #ruby
[08:14:37] elphe: has joined #ruby
[08:25:01] deathwishdave: has joined #ruby
[08:38:28] _yohji_: has joined #ruby
[08:46:15] sysvalve: has joined #ruby
[08:55:13] Nicmavr: has joined #ruby
[08:56:46] conta: has joined #ruby
[09:07:20] deathwishdave: has joined #ruby
[09:10:59] venmx: has joined #ruby
[09:11:28] dionysus69: how do I use irb?
[09:13:27] Bish: 1) open up a shell 2) write "irb" enter
[09:13:52] dionysus69: no, I mean here
[09:13:58] Bish: >> "like this"
[09:14:09] Bish: >> "like this"
[09:14:14] Bish: seems to be offline
[09:14:22] dionysus69: ok I ll just post this
[09:15:01] dionysus69: this format("%.#{18}f", BigDecimal("0.000000000000000001")) returns correctly >> "0.000000000000000001"
[09:15:29] dionysus69: this is weird: format("%.#{18}f", BigDecimal("0.100000000000000001")) => "0.100000000000000006"
[09:15:57] dionysus69: this is extra weird: format("%.#{18}f", BigDecimal("1.000000000000000001")).to_s => "1.000000000000000000"
[09:16:20] Bish: well it's not weird, as usual
[09:16:35] dionysus69: what am I doing incorrectly?
[09:16:41] Bish: try 0.1+0.2
[09:17:05] Bish: if i understand correctly, you're experience floating point error
[09:17:12] Bish: experiencing*
[09:17:12] dionysus69: that's why I am creating BigDec?
[09:17:23] Bish: well.. bigdec has just a higher resolution
[09:17:26] Bish: but it doesnt make the problem go away
[09:17:34] Bish: only away around it is having rationals
[09:17:40] dionysus69: again this floating point brick wall
[09:17:51] Bish: welcome to the limitations of reality
[09:18:20] dionysus69: so how do I represent those numbers correctly with rationals?
[09:18:44] Bish: or better example >> 1/3r
[09:19:00] Bish: (the r prefixes, makes 3 a rational number... when 1 gets divided by a rational the result gets rational)
[09:19:43] Bish: (1.0/2.0).to_r or like this
[09:20:43] Bish: just take 2 integers *shru*
[09:20:48] wildermind: has joined #ruby
[09:23:38] dionysus69: ok let me state my problem more clearly
[09:24:03] conta: has joined #ruby
[09:24:58] deathwishdave: has joined #ruby
[09:25:26] Bish: how does one get the numerator and denominator of a rational
[09:25:35] Bish: ACTION wonders
[09:26:03] Xiti`: has joined #ruby
[09:26:21] cthulchu_: has joined #ruby
[09:26:22] Bish: oh there are the methods nvm
[09:26:26] p4p0l0: has joined #ruby
[09:26:53] postmodern_: has joined #ruby
[09:27:37] za1b1tsu_: has joined #ruby
[09:28:07] hays_: has joined #ruby
[09:28:46] manakanapa: has joined #ruby
[09:28:56] akaiiro: has joined #ruby
[09:30:31] Dark_Arc: has joined #ruby
[09:31:07] Caius: has joined #ruby
[09:32:14] woodruffw: has joined #ruby
[09:32:41] dionysus69: sorry for delay
[09:32:57] dionysus69: so i have this big decimal in database saved correctly, I just want to represent it in a float correctly
[09:33:00] dionysus69: 0.1000000000000000001e1
[09:33:07] lypsis: has joined #ruby
[09:33:14] dionysus69: I don't get how rationals help me here
[09:33:24] cadillac_: has joined #ruby
[09:33:33] dionysus69: I just want to show the user 1.1000000000000000001 instead of 0.1000000000000000001e1
[09:34:54] Tempesta: can't complete for download in https://www.ruby-lang.org/
[09:35:05] Tempesta: can I where download..?
[09:35:47] dionysus69: https://rvm.io/
[09:36:51] badeball: dionysus69: my guess would be that Kernel#format converts it to a float and you lose the resolution again. can you try the builtin BigDecminal#to_s with 'F', IE. BigDecimal.new('123').to_s('F')
[09:37:25] dionysus69: oh that sounds like it should work :D let me try
[09:37:46] Tempesta: sorry, how can I download for windows?
[09:38:32] Bish: dionysus69: safe a pair of 2 integers, there is no dateformat that can hold it
[09:38:32] tbuehlmann: dionysus69: are you looking for BigDecimal.new('0.1000000000000000001e1').to_s('F')?
[09:38:42] Bish: not a serializeable one
[09:38:57] tbuehlmann: oh, badeball already suggested it, nvm
[09:39:05] dionysus69: Tempesta: https://www.ubuntu.com/download/desktop :D
[09:39:23] dionysus69: thx tbuehlmann you too
[09:39:24] snickers: has joined #ruby
[09:39:26] Bish: dionysus69: what database you're using?
[09:39:47] Bish: well i bet my nuts it has a numerical type for that
[09:40:07] dionysus69: yea big decimal
[09:40:14] dionysus69: I have precision at 32 and scale at 18
[09:40:17] snickers: Hi, someone know why active record on oracle return 0.28522e5 for integer 28522
[09:40:17] Bish: wlel no, since that is IEEE754
[09:40:53] Bish: well time to lose my nuts, since postgres doesnt seem to have that by default
[09:41:11] Bish: i would store an array of 2 integers.
[09:41:20] dionysus69: dunno, haven't worked with any db but postgres for past 5 years
[09:41:32] Bish: well best choice either way in my opinion
[09:42:19] Bish: but if you want it to have losless, creating your own type / saving it as an array is your only choice
[09:42:24] Bish: ACTION checks what his ORM is doing
[09:42:32] Alina-malina: has joined #ruby
[09:42:35] dionysus69: yea I think so too ^.^ but where I come from, everyone uses either mysql oracle or mssql
[09:43:08] Bish: mysql is great... it's fast in shit, but if it gets slow
[09:43:11] Bish: have fun finding out why
[09:43:34] Bish: or funny things like.. inserting emojis into a varchar type
[09:43:41] Bish: and mysql is like "Okay, i inserted it :)"
[09:43:47] Bish: and the column entry is empty
[09:44:06] dionysus69: the only slowness I dealt with dbs was because of SSD I/O bottleneck
[09:44:06] User458764: has joined #ruby
[09:44:14] badeball: Bish: you have a binary format in psql, so if you can serialize / deserialize your preferred float type in you language then you're good to go
[09:44:26] Bish: or the bug that existed since 1997 (which finally got fixed right now)
[09:44:36] Bish: that u cannot regex for utf8(dafuq!? why did people use that)
[09:45:40] Bish: badeball: that doesnt help if your precision just cannot handle it
[09:46:07] Bish: im surprised my ORM does not seem to be able to save rational types either :o
[09:46:10] badeball: of course not, but it means that you can store / retrieve without lsos
[09:46:23] Bish: well.. yeah but the number is already "broken" then
[09:46:51] Bish: so the trick would be to serialize a Rational
[09:46:59] Bish: or complex even
[09:47:13] Bish: and having a type for that database-ish
[09:47:22] fmcgeough: has joined #ruby
[09:47:52] Bish: but who would even need that except for experimental physicists?
[09:48:41] badeball: unless you can represent integers of arbritary length, then a rational suffers from the same presicion problems
[09:48:43] fmcgeough: has joined #ruby
[09:49:14] tj-: has joined #ruby
[09:49:20] Bish: is it really the same? or similiar?
[09:50:02] badeball: a rational and a floating point are just two different ways of representing numbers, but constrained by the same reality
[09:50:13] Bish: yeah but you wont have things like
[09:50:26] Bish: "oh i cannot represent that number, let's take the nearest"
[09:50:38] Bish: so i wouldn't say it's the same thing.. but limited aswell, sure
[09:51:02] Bish: but when in doubt, store the number as a string, write a integer lib(does that exist in ruby?)
[09:51:22] Bish: and you have slow, limitless(except for memory) fractions
[09:51:27] dionysus69: Bish tbuehlmann as I wanted to format the number I found that include ActionView::Helpers::NumberHelper includes number_with_precision(any_number, precision: 18)
[09:51:51] dionysus69: so if the number is 0.001 I want to show 0.0010000....
[09:52:13] Bish: eh, you want to display pointless numbers :D?
[09:52:28] dionysus69: yea I guess :S :D it's for UX :D
[09:53:35] badeball: rationals can help you avoid accumulating floating errors over multiple arithmic operations
[09:54:40] dionysus69: I am dealing with cryptocurrencies
[09:54:47] dionysus69: the problem is that bitcoin for example uses floats
[09:54:55] dionysus69: while ethereum and cardano use integers
[09:55:10] Bish: wait what again someone talks about bitcoin?
[09:55:12] dionysus69: so I decided to use floats for all so I am converting everything to bigdecimal
[09:55:14] Bish: don't use floats at all
[09:55:29] Bish: how does bitcoin uses floats?
[09:55:38] dionysus69: the rpc server I mean
[09:55:43] Bish: oh.. really?
[09:55:47] dionysus69: returns balance of let's say 1.00001
[09:56:00] Bish: yeah that is not float
[09:56:04] Bish: you shouldn't use float for that
[09:56:10] dionysus69: I could convert it to integer but , then I would have to convert it back to float to show to user
[09:56:22] Bish: no you don't you want your own way of representing it
[09:56:24] dionysus69: by float I mean BigDecimal
[09:56:43] Bish: you don't want representation errors, even if it's just for displaying
[09:56:53] dionysus69: i figured by now that floats are unreliable :P
[09:56:57] Bish: literally every code i read about cryptocoins so far used integers
[09:56:57] dionysus69: so far everything's correct
[09:57:18] dionysus69: only glitch so far was with format("%.#{precision}f", number) as I just found out
[09:57:42] dionysus69: it's a choice, as I said, I encountered 0 mismatches
[09:58:11] Bish: well, i am not much of a math person, but most likely you won't have some
[09:58:16] Bish: as long as you're not calculating with these numbers
[09:58:31] Bish: but i wouldn't do it, simply becuase.. i don't know in future you, or someone working with your software
[09:58:38] Bish: might use that float for calculation
[09:59:02] Bish: you shouldn't use float, because it isn't
[09:59:12] dionysus69: I am tutoring one guy and he already knows this :D
[09:59:37] Bish: remember me when shit hits the fan
[10:00:01] dionysus69: I will, you are not the first one to warn me, wink wink people here :D
[10:00:12] Bish: yeah i remember the last time i think
[10:00:21] Bish: you had a different name and were kinda trollish, is that possible?
[10:00:40] dionysus69: lol no, this is my only nick on irc, ever
[10:00:50] Bish: okay, then a different person was doing the same thing
[10:01:15] deathwishdave: has joined #ruby
[10:01:36] Bish: i feel like even if float were fine
[10:01:46] dionysus69: big decimal is convenient cause postgres supports it, I don't see a problem with proper testing before deployment
[10:01:50] Bish: juggling around with it would be more work than writing your own format for a integer number
[10:02:15] Bish: you do not even need rationals..
[10:02:33] dionysus69: nah of course I don't :D so far I don't get how I would use them
[10:02:41] Bish: the amount of satoshis is fukin known, you don't need a floating POINT because there is not point, like literally
[10:02:54] Bish: the datatype you want to use there is integer
[10:03:00] Bish: a single one
[10:03:57] dionysus69: oh well, if any funny thing happens, I can reconvert everything to ints in day or two
[10:04:54] Bish: well.. if your database is already corrupted by floating point errors
[10:05:01] Bish: thats when u correct it:D while the solution would be so easy
[10:05:42] Bish: my i ask what you're writing so i never but my cryptocoins there?
[10:09:26] dionysus69: lol, I was already asked that
[10:09:41] dionysus69: you will know when it gets famous ^.^
[10:09:53] Bish: just trying to "insult" you so you're not doing this huge mistake
[10:10:00] Bish: especially when working with currencies
[10:10:19] Bish: really, don't do it, i am getting sick of sounding like "teh-irc-guy"
[10:10:23] Bish: but don't do it
[10:10:33] dionysus69: well, I inherited this software and bigdecimals were already there, I never bothered to change because they work
[10:10:47] Bish: ACTION is hurting
[10:16:40] elphe: has joined #ruby
[10:17:15] Bish: how many bits does a bitcoin balance have btw?
[10:17:22] Bish: or rather.. what is the max amount of a transaction
[10:17:44] dionysus69: you can transact any amount
[10:17:51] Bish: i doubt it
[10:18:07] Bish: i can't send 21000001 bitcoins
[10:18:11] dionysus69: dunno, no one probably has enough bitcoin to cause a software error while transacting
[10:18:17] dionysus69: oh lol that's what you mean
[10:18:27] Bish: yes, and i guess the limit is before that
[10:18:27] dionysus69: well yea I know there's finite amount
[10:18:52] dionysus69: more than 3-4 million is probably lost too
[10:19:09] dionysus69: while testing and stuff in early years
[10:20:41] GodFather: has joined #ruby
[10:26:56] alem0lars: has joined #ruby
[10:27:41] vonfry: has joined #ruby
[10:33:02] Bish: ACTION threw away so many 0.0x btc adresses, because they werent worth anything
[10:33:36] Bish: i even remember installing the bitcoin client as a kid (<18) being being like "wats dis lul, i mine a bit, what does this mean"
[10:34:13] Bish: must've been 17 (im 28 now)
[10:42:37] _aeris_: has joined #ruby
[10:48:46] FernandoBasso: has joined #ruby
[10:49:56] apparition47: has joined #ruby
[10:51:34] mikecmpbll: has joined #ruby
[10:53:49] tdy: has joined #ruby
[10:56:00] kapil___: has joined #ruby
[10:59:37] vondruch_: has joined #ruby
[11:11:45] beefjoe: has joined #ruby
[11:24:34] ciro: has joined #ruby
[11:27:28] tj-: has joined #ruby
[11:36:02] c0ncealed2: has joined #ruby
[11:40:47] DaniG2k: has joined #ruby
[11:43:02] cadillac_: has joined #ruby
[11:44:23] mikecmpbll: has joined #ruby
[11:52:30] conta: has joined #ruby
[12:12:03] deathwishdave: has joined #ruby
[12:19:06] ur5us: has joined #ruby
[12:26:01] lxsameer: has joined #ruby
[12:34:44] lxsameer: has joined #ruby
[12:39:44] nickjj_: has joined #ruby
[12:39:51] gix: has joined #ruby
[12:40:42] clemens3_: has joined #ruby
[12:40:52] conta1: has joined #ruby
[12:41:37] MuffinPimp_: has joined #ruby
[12:41:47] ryzokuken_: has joined #ruby
[12:41:51] spiette_: has joined #ruby
[12:42:17] uplime-: has joined #ruby
[12:43:32] bak1an: has joined #ruby
[12:43:51] galeido^: has joined #ruby
[12:44:09] tj-: has joined #ruby
[12:46:50] fumck: has joined #ruby
[12:47:20] x0F_: has joined #ruby
[12:48:48] coffeecupp: has joined #ruby
[12:49:41] brodul: has joined #ruby
[12:50:08] jerryskye: has joined #ruby
[12:51:15] mzo: has joined #ruby
[12:55:01] oblique: has joined #ruby
[12:58:37] Arahael: has joined #ruby
[13:00:24] n3b: has joined #ruby
[13:00:25] al2o3-cr: has joined #ruby
[13:01:13] al2o3-cr: has joined #ruby
[13:02:35] tj-: has joined #ruby
[13:07:44] BTRE: has joined #ruby
[13:20:44] infernix: has joined #ruby
[13:26:14] balo: has joined #ruby
[13:31:50] white_lilies: has joined #ruby
[13:48:40] bmurt: has joined #ruby
[13:48:42] beefjoe: has joined #ruby
[13:49:40] beefjoe: has joined #ruby
[13:51:02] beefjoe: has joined #ruby
[13:51:27] alfiemax: has joined #ruby
[13:54:31] Alina-malina: has joined #ruby
[13:55:35] Inline: has joined #ruby
[13:57:01] tj-: has joined #ruby
[14:19:29] Rapture: has joined #ruby
[14:19:40] ur5us: has joined #ruby
[14:23:13] mikecmpbll: has joined #ruby
[14:27:11] beefjoe: has joined #ruby
[14:29:44] postmodern: has joined #ruby
[14:33:30] hgost: has joined #ruby
[14:33:49] balr0g: has joined #ruby
[14:39:03] gnufied: has joined #ruby
[14:52:19] beefjoe: has joined #ruby
[14:53:33] tj-: has joined #ruby
[14:56:02] Mike11: has joined #ruby
[15:04:34] chouhoulis: has joined #ruby
[15:05:05] bmurt: has joined #ruby
[15:13:20] Xiti: has joined #ruby
[15:13:58] ciro: has joined #ruby
[15:14:00] mroutis: has joined #ruby
[15:15:32] maryo: has joined #ruby
[15:16:44] arup_r: has joined #ruby
[15:18:40] arup_r: I have some guids from twitter feed. I would like to compare the guid like which one is bigger. Those values are like "1024009734402256896" and "999729751781724165". If I do compare them by converting them to integer using `.to_i` like "1024009734402256896".to_i > "999729751781724165".to_i will there be a problem? As the numbers are keep growing.
[15:19:31] arup_r: if so, what will be the safest approach?
[15:22:27] bmurt: has joined #ruby
[15:24:07] arup_r: anyone here? :)
[15:27:06] Demos[m]: so there are different types of guid
[15:27:32] Demos[m]: the numbers don't nessassarly indicate anything about the guid
[15:27:52] Demos[m]: newer ones will tend to be larger (because many guids are generated via time based methods, or hwid based methods)
[15:28:32] Demos[m]: for hwids the ids tend to grow with time (although there's no cosmic reason for this), for time based ones time moves forward
[15:28:36] Demos[m]: there are also random guids that truely are just random
[15:28:51] Demos[m]: I belive you can somehow identify them but I forget how
[15:29:00] Demos[m]: what does "bigger" mean to you?
[15:31:02] arup_r: well. say in future "1024009734402256896" becomes "102400973440225689684848484848484444", and if I do call .to_i on it, I hope it will not break .
[15:31:12] arup_r: that is what my concern..
[15:32:01] r29v: has joined #ruby
[15:32:35] z64: twitter IDs are uint64
[15:34:11] arup_r: this is where I do the comparisons https://gist.github.com/aruprakshit/db9715720e1ca5554bf131967e33701a#file-tweet-rb-L38
[15:35:28] z64: a twitter ID would not be bigger than 18446744073709551615, though maybe one day it will be uint128
[15:35:58] z64: (i don't know how uint128 is supported in ruby)
[15:36:16] z64: for now it is a uint64 with encoded metadata
[15:36:21] z64: Time.at(((999729751781724165 >> 22) + epoch) / 1000.0)
[15:36:22] z64: => 2018-05-24 19:12:01 +0000
[15:36:27] ciro: Demos[m]:
[15:36:27] arup_r: ok.. so .to_i is safe then? :)
[15:36:50] ciro: irb(main):001:0> puts 372873827329873298732983729837298372983729837298372983729837298372983729837293872.to_i
[15:36:55] ciro: 372873827329873298732983729837298372983729837298372983729837298372983729837293872
[15:37:01] ivanskie: has joined #ruby
[15:37:11] z64: arup_r: yes i wouldn't worry about it
[15:37:19] z64: you can google "twitter snowflake" for more information
[15:37:30] arup_r: ok. thanks z64.
[15:37:46] z64: the function i displayed above ^ prints the embedded timestamp of whenever that resource was created
[15:38:04] ciro: no problem with big numbers, they will be converted to the needed class by the comparison methods
[15:38:05] z64: with the epoch = 1288834974657
[15:38:06] Demos: has joined #ruby
[15:38:35] epochwolf: ACTION perks up
[15:41:54] Demos: has joined #ruby
[15:42:02] ivanskie: has joined #ruby
[15:43:48] gyant: has joined #ruby
[15:44:01] havenwood: You can just compare Strings.
[15:44:27] havenwood: >> "1024009734402256896" <=> "102400973440225689684848484848484444"
[15:50:22] maryo: has joined #ruby
[15:50:24] cagomez: has joined #ruby
[15:52:33] jcarl43: has joined #ruby
[15:54:50] yohji: has joined #ruby
[16:00:21] Sylario: Assignation question, can I shorten this : a,b=foo.bar1,foo.bar2 ?
[16:07:27] z64: havenwood: you can, but i think that has edge cases in snowflake
[16:08:51] ciro: sylario: a=foo.bar1
[16:08:58] ciro: b=foo.bar2
[16:09:06] ciro: it's one character shorter
[16:09:35] ciro: intead of two "," you use one "\n"
[16:10:20] maryo: has joined #ruby
[16:10:44] ciro: btw what are the beneficts of making the code more complex? a,b=c,d instead of a=c; b=d ?
[16:12:54] ciro: it's like saying: "Mary and Luoise are my sister and my mother respectivelly" instead of "Mary is my sister, Louise is my mother"
[16:13:15] Sylario: @ciro In this case it for time periods
[16:13:19] maryo: while starting the dashing, I get an error. Some pointers would be helpful. Here is the error --> https://dpaste.de/dOti/raw
[16:13:25] Sylario: so it kind of make sense
[16:13:34] mzo: has joined #ruby
[16:13:57] sonOfRa: I don't frequently do ruby, but that kind of syntax just confuses me
[16:14:06] ciro: time periods... can you give an actual example?
[16:14:17] sonOfRa: And will probably confuse others as well; two lines is very likely the best, and most obvious path
[16:14:29] sonOfRa: Don't optimize your code for fewest characters, make it actually readable
[16:14:50] mzo: can you paste the one-liner in question
[16:15:24] Sylario: it's also in Python
[16:15:54] Sylario: start_date,end_date=p.date_start,p.date_stop
[16:15:57] ciro: I don't understand what you mean when you say "time periods"
[16:16:23] ciro: a date interval
[16:16:45] ciro: (Date.today)..(Date.tomorrow)
[16:16:54] ciro: for example, isn't it?
[16:17:33] Sylario: well, i probably used a bad namming for my objects then :/
[16:17:38] Demos: Can you ever really know what tomorrow's date will be?
[16:17:40] nowhere_man: has joined #ruby
[16:20:26] za1b1tsu_: has joined #ruby
[16:20:29] ur5us: has joined #ruby
[16:25:23] Sylario: Yup, it really seems periods is rarelly used for time interval in english :
[16:25:57] zapata: has joined #ruby
[16:25:59] ciro: sylario: in spanish it makes sense
[16:26:06] Sylario: in french too
[16:26:19] ciro: in english... well, I'm not a native english speaker, can not tell
[16:26:38] Sylario: It seems not
[16:26:56] Sylario: well, that code base will probably never be touched by a native speaker
[16:27:23] Sylario: And I bet it's the same in Italian than in French or spanish, so no problems here
[16:28:21] ciro: sylario: I renamed more than a half of the class names in the app in my last job
[16:28:52] Sylario: that's not a fun activity
[16:31:00] ciro: it was my first task, my boss commanded me to to it because the first programmers they hired did not speak english very well, and the class names, variable names, etc, had spanglish names or names in english that did not make any sense at all
[16:31:41] ciro: it was funny, 80K lines of code in a Ruby on Rails app
[16:32:46] Sylario: Rails was my first framework with pluralization, quickly learned the ie/y english rules
[16:32:57] Sylario: Like, almost instantly ^^
[16:33:07] ciro: hehe, that's good
[16:33:15] Sylario: so, no classname in french
[16:35:17] SeepingN: has joined #ruby
[16:42:11] memo1: has joined #ruby
[16:43:40] orbyt_: has joined #ruby
[16:52:45] Guest83186: has joined #ruby
[16:59:48] lytol_: has joined #ruby
[17:00:06] Guest83186: has joined #ruby
[17:01:37] jrich523: has joined #ruby
[17:01:54] jrich523: hey guys, does this seem right style wise? https://gist.github.com/jrich523/f09db4d657eca565d82a974b28abf1df
[17:08:34] alfiemax_: has joined #ruby
[17:09:47] Guest83186: has joined #ruby
[17:14:15] venmx: has joined #ruby
[17:14:54] Guest83186: has joined #ruby
[17:15:18] havenwood: jrich523: You can just use the truthiness with `||` instead of explicit nil? checks.
[17:15:25] havenwood: jrich523: Interpolation already does an implicit #to_s.
[17:16:10] jrich523: oh good call, forgot about that
[17:16:38] jrich523: return foreman || puppet; raise
[17:18:56] User458764: has joined #ruby
[17:19:15] havenwood: jrich523: false || false || raise('oops')
[17:19:30] havenwood: jrich523: @forman_host.cpus || @puppet_guest.cpus || raise
[17:19:35] jrich523: and drop the 'return' part?
[17:19:54] havenwood: jrich523: There's more than one way to do it! You could also assign an intermediary local variable, or map/find, etc.
[17:20:18] jrich523: lol there are like 50 ways to do it :)
[17:20:31] jrich523: it was in a if/elseif/else format
[17:22:43] havenwood: jrich523: return cpu_count if cpu_count = @forman_host.cpus || @puppet_guest.cpus
[17:23:07] jrich523: that seems... excessive
[17:23:34] memo2: has joined #ruby
[17:24:18] alfiemax: has joined #ruby
[17:24:25] havenwood: jrich523: it might be nice to just extract a method to get the known count
[17:24:55] havenwood: jrich523: two ||s suffice
[17:25:25] jrich523: thats what this is, its from the Guest class, so its to populat the guest with the 'best' info
[17:25:53] jrich523: however, i find it odd its in the cpu def, and not sorted out in the init
[17:26:01] jrich523: mem vs cpu i guess?
[17:26:36] havenwood: jrich523: Maybe worried someone is going to pull a core out at any moment. ;-P
[17:26:38] jrich523: has joined #ruby
[17:26:50] jrich523: rough day on the irc seas :)
[17:27:05] havenwood: the irseas*
[17:27:23] jrich523: lol yes, its choppy
[17:27:49] jrich523: but yeah, not sure if my msgs made it, but its a Guest class and they pass in the puppet/foreman data on init
[17:28:05] jrich523: so i find it odd that they do the work in the method, and not in the init (once vs everytime)
[17:28:09] jrich523: since the foreman/puppet data wont update
[17:28:26] havenwood: jrich523: do you even use the two instance variables separately?
[17:28:27] havenwood: can you just consolidate?
[17:28:42] snickers: has joined #ruby
[17:28:49] havenwood: jrich523: it does make sense to set an instance variable on init if you have what you need to calculate it and it doesn't change.
[17:30:33] NightMonkey: has joined #ruby
[17:30:49] jrich523: yeah i feel like i could just createa a bunch of attr_reader and sort it all out on init, or maybe its to only trigger errors if its actually looked at, vs load?
[17:31:55] jrich523: hmm it doesnt like 2 ||, the raise at the end is angry about the string being there?
[17:32:32] jrich523: if i wrap it || ( raise "" ) its ok, kinda wierd
[17:36:31] z64: `raise("foo")` instead
[17:36:56] jrich523: that looks better
[17:37:45] AJA4350: has joined #ruby
[17:39:02] cats: has joined #ruby
[17:43:22] mtkd: has joined #ruby
[17:46:42] ModusPwnens: has joined #ruby
[17:48:13] r29v: has joined #ruby
[17:49:40] ModusPwnens: style question: I have a block of code that I need to share within two different scopes in the same method. This shared block of code does NOT need to be shared outside of that method. Is it bad practice to use a proc/lambda for that to reflect that it doesn't need to be shared outside of the method?
[17:56:43] bmurt: has joined #ruby
[17:59:24] marius: has joined #ruby
[17:59:48] sriehl: has joined #ruby
[17:59:59] Guest83186: has joined #ruby
[18:00:26] AJA4351: has joined #ruby
[18:01:22] sina: has joined #ruby
[18:01:24] AndroidKitKat: has joined #ruby
[18:02:56] tfitts: has joined #ruby
[18:03:10] adambeynon: has joined #ruby
[18:04:04] mtkd: has joined #ruby
[18:04:24] orbyt_: has joined #ruby
[18:04:47] Guest83186: has joined #ruby
[18:06:05] nemesit|znc: has joined #ruby
[18:06:28] AJA4350: has joined #ruby
[18:07:43] balr0g: has joined #ruby
[18:07:53] heyimwill: has joined #ruby
[18:08:10] SuperTux88: has joined #ruby
[18:10:53] krasnus: has joined #ruby
[18:10:55] mensvaga: has joined #ruby
[18:11:52] mensvaga: I'm trying to build an RPM out of a ruby gem. But the resulting RPM doesn't install any ruby files, and it tries to install stuff by default into my home directory.
[18:12:23] mensvaga: Is there an example spec file that I can use to modify the spec file that gem2rpm creates so I can make RPMs out of gems that are similar to what gets installed when I do something like:
[18:12:39] mensvaga: yum install rubygem-io-console
[18:14:58] def_jam: has joined #ruby
[18:15:33] dendazen: has joined #ruby
[18:21:20] ur5us: has joined #ruby
[18:25:37] Azure: has joined #ruby
[18:26:06] eam: mensvaga: try fpm
[18:29:55] ^mtkd: has joined #ruby
[18:31:35] tj-: has joined #ruby
[18:37:20] weaksauce: has joined #ruby
[18:39:15] orbyt_: has joined #ruby
[18:40:42] beowuff: has joined #ruby
[18:42:42] jjman: has joined #ruby
[18:44:01] dviola: has joined #ruby
[18:44:52] Guest83186: has joined #ruby
[18:49:53] Guest83186: has joined #ruby
[18:54:53] Guest83186: has joined #ruby
[19:03:13] Rapture: has joined #ruby
[19:09:16] zapata: has joined #ruby
[19:14:31] dr3wo: has joined #ruby
[19:15:18] alaing: has joined #ruby
[19:16:38] alaing: i'm trying to exclude some folder from rspec but the exclude pattern does not seem to be working
[19:16:48] alaing: bundle exec rspec --exclude-pattern "**/spec/features/*_spec.rb"
[19:16:48] havenwood: alaing: what are you trying?
[19:17:08] alaing: I would like to exclude spec/features
[19:17:33] havenwood: alaing: Do you not know what dir spec/ will be in?
[19:18:14] havenwood: alaing: That pattern looks fine to me.
[19:18:50] havenwood: alaing: Can you gist an example of the directory/file that it's not properly excluding?
[19:18:56] scrptktty: has joined #ruby
[19:20:29] alaing: https://gist.github.com/aliuk2012/bfb19095d81ec499048e7878922b9806
[19:20:45] manakanapa5: has joined #ruby
[19:21:11] alaing: is there anyway to list out the files its testing?
[19:21:36] eckhardt: has joined #ruby
[19:21:40] alaing: I also tried profiling it and thats when i notice there were still specs in spec/features being run
[19:22:29] alaing: @havenwood ^
[19:22:37] \void: has joined #ruby
[19:24:14] havenwood: alaing: ruby -e 'p Dir["**/spec/features/*_spec.rb"]'
[19:24:27] alaing: havenwood: I specifically followed this example https://relishapp.com/rspec/rspec-core/docs/configuration/exclude-pattern#the-%60--exclude-pattern%60-flag-makes-rspec-skip-matching-files
[19:24:30] havenwood: alaing: What were the names of the ones still being run?
[19:24:47] alaing: except instead of models i replaced it with features
[19:25:12] havenwood: alaing: Can you show examples of the path of one that isn't properly excluded?
[19:26:13] havenwood: Like, I expected this file to be excluded: nope/spec/features/why_not_spec.rb
[19:27:23] havenwood: alaing: Right now we know the exclusion glob you used, but without an example path you expected to be exlcuded there's nothing for us to go on.
[19:27:27] alaing: one sec i might need to test it on another folder. features is rather long and slow running
[19:27:35] Zaab1t: has joined #ruby
[19:27:41] alaing: I tried that ruby command and it returned []
[19:27:54] havenwood: alaing: what did you expect it to match?
[19:28:18] havenwood: Give us the path of one of the specs you thought it would see!
[19:28:53] alaing: path to a file that should be excluded?
[19:29:27] havenwood: alaing: Yup, what's a file you expected to be matched by that glob that wasn't.
[19:29:58] alaing: $ ruby -e 'p Dir["**/spec/features/*_spec.rb"]'
[19:30:07] alaing: i would have expected to return a few files like
[19:30:25] SeepingN: you can do that?
[19:30:55] tj-: SeepingN same as Dir.glob()
[19:31:15] havenwood: TJ-: **similar to Dir.glob
[19:31:46] alaing: spec/features/admin/cases/business_units_spec.rb
[19:31:46] tj-: alaing: could the shell be expanding those wildcards first. And difference if you use single-quotes not double?
[19:32:01] tj-: s/And/Any/
[19:32:18] havenwood: TJ-: No difference in single or double quotes with globs.
[19:32:28] tj-: havenwood: to the calling shell there is
[19:32:39] havenwood: alaing: The "admin/cases" part isn't matched in your glob.
[19:32:59] SeepingN: bad example basically
[19:33:05] havenwood: There's no difference between single or double quotes in this example.
[19:33:29] havenwood: alaing: "**/spec/features/**/*_spec.rb"
[19:33:32] SeepingN: "**/spec/features/*_spec.rb" will never match spec/features/admin/cases/business_units_spec.rb
[19:34:05] alaing: ah because all my specs are in subfolder
[19:34:18] alaing: let me try that
[19:34:20] havenwood: alaing: yup, the * doesn't match the intermediary folders
[19:35:01] havenwood: alaing: * matches any file, not dir
[19:35:03] SeepingN: the whole reason you had ** up front. just need.. more stars
[19:35:23] alaing: completely about the subfolders needing wildcards
[19:35:24] havenwood: Had three, needed five!
[19:35:36] alaing: this ruby -e 'p Dir["**/spec/features/**/*_spec.rb"]' now returns all my tests
[19:35:46] alaing: not to add it to my exclude_pattern
[19:36:05] alaing: thank you so much for your help. i knew it had to be something stupid i was doing
[19:36:14] Nicmavr: has joined #ruby
[19:39:00] orbyt_: has joined #ruby
[19:40:12] sameerynho: has joined #ruby
[19:41:45] Creatornator: has joined #ruby
[19:42:34] mtkd: has joined #ruby
[19:58:50] Dbugger: has joined #ruby
[19:59:33] SeepingN: I imagine that glob could get out of hands
[19:59:50] SeepingN: starting with **, I beleive that will scan your entire drive no?
[20:01:44] whippythellama: has joined #ruby
[20:03:28] cthu|: has joined #ruby
[20:05:49] ur5us: has joined #ruby
[20:12:29] mtkd: has joined #ruby
[20:20:08] Creatornator: has joined #ruby
[20:27:00] Caerus: has joined #ruby
[20:37:22] patr0clus: has joined #ruby
[20:45:03] Frem: has joined #ruby
[20:47:30] orbyt_: has joined #ruby
[20:54:28] mtkd: has joined #ruby
[20:57:43] Mike11: has joined #ruby
[20:58:23] cthu|: interesting
[20:58:34] cthu|: so I'm running into an interesting thing...
[20:58:56] cthu|: I have a view v and it has a ton of testing methods
[20:59:10] cthu|: each of which returns the view
[21:00:12] cthu|: so tests look like v(args).go_there().do_that().now_go_there().and_finally_do_that()
[21:00:39] cthu|: I made a new method in that v. My new method is called byebug and it runs byebug and returns the view
[21:01:55] cthu|: buuut it causes an error
[21:03:23] nicesignal: has joined #ruby
[21:05:29] SegFaultAX: has joined #ruby
[21:08:54] mtkd: has joined #ruby
[21:11:18] cthu|: oops. it actually works
[21:18:57] SuperLag: has joined #ruby
[21:24:06] sticaz: has joined #ruby
[21:29:02] InfinityFye: has joined #ruby
[21:31:16] InfinityFye: has left #ruby: ("Leaving")
[21:34:40] Guest83186: has joined #ruby
[21:37:35] DarthGandalf: has joined #ruby
[21:39:57] venmx: has joined #ruby
[21:51:49] dr3wo: has joined #ruby
[21:53:58] nowhere_man: has joined #ruby
[22:00:39] mistergibson: has joined #ruby
[22:06:34] FernandoBasso: has joined #ruby
[22:07:42] DarthGandalf: has joined #ruby
[22:14:08] apeiros_: has joined #ruby
[22:25:24] Xiti`: has joined #ruby
[22:26:45] nickjj_: has joined #ruby
[22:27:48] Flashynuff: has joined #ruby
[22:37:00] zapata: has joined #ruby
[22:39:38] orbyt_: has joined #ruby
[22:48:24] alfiemax_: has joined #ruby
[22:50:59] ellcs: has joined #ruby
[23:04:19] eckhardt: has joined #ruby
[23:11:18] patr0clus: has joined #ruby
[23:19:23] tty: has joined #ruby
[23:21:23] Radar: has joined #ruby
[23:33:51] gigetoo: has joined #ruby
[23:35:19] helpa: has joined #ruby
[23:35:33] Guest83186: has joined #ruby
[23:36:12] nadir: has joined #ruby
[23:37:05] nadir: has joined #ruby
[23:38:03] nadir: has joined #ruby
[23:38:55] eckhardt: has joined #ruby
[23:38:56] nadir: has joined #ruby
[23:39:53] nadir: has joined #ruby
[23:41:25] whippythellama: has joined #ruby
[23:42:42] n13z: has joined #ruby
[23:46:14] cadillac_: has joined #ruby
[23:46:18] eckhardt: has joined #ruby
[23:51:05] r29v: has joined #ruby
[23:59:16] hfp_work: has joined #ruby