<mara>
hi, what's the recommended way of mapping multiple keys to the same value, for a look-up table? i.e. aliasing 3 unique strings to the same value?
<mara>
{"foo" => %w[bar baz]} and then finding the key where the values.include? seems ... backwards, but requires the least code
Tempesta has joined #ruby
<mooff>
mara: sounds awkward. can you share code or more details about the problem?
roadie has joined #ruby
<havenwood>
mara: Will there only be one key with the value or multiple?
<o|||||o>
i'm running Order.first.order_items.sum {|item| item.art.price.to_i * item.quantity} and getting the value of the price but if i pp them, i get the correct value for each iteration but it still outputs the price
<impermanence>
The following CVE https://ubuntu.com/security/CVE-2022-0778 is forcing an update on my ubuntu servers. Although my chef code has the relevant packages pinned at a particular version, it's still trying to upgrade them. And for whatever reason its complaining about dependency violations (of course). I realize this isn't the chef channel of
<impermanence>
course (there isn't one really anymore). But curious if anyone has any advice. I know nothing of Chef but figure there's probably one or two heads in here that do. Fine to dm.
<leah2>
did you pin including the tiny version?
dionysus69 has quit [Read error: Connection reset by peer]
dionysus69 has joined #ruby
ua_ has joined #ruby
<nakilon>
adam12 can you please add the ferrum gemdocs? also would be nice if it was v0.11
<nakilon>
they put the "evrone" trademark everywhere on github and landing for the "help making the project website" and could not even add any docs links on it... smh
lunarkitty has joined #ruby
eddof13 has joined #ruby
roadie has quit [Ping timeout: 252 seconds]
o|||||o has quit [Ping timeout: 256 seconds]
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
roadie has joined #ruby
o|||||o has joined #ruby
dionysus69 has quit [Ping timeout: 268 seconds]
oxfuxxx has quit [Ping timeout: 240 seconds]
roadie has quit [Ping timeout: 240 seconds]
eddof13 has joined #ruby
<nakilon>
what's the purpose of "If the given object is not a Regexp, returns the value returned by object =~ self." in String#=~ ?
<nakilon>
by a mistake I did str =~ [regex] and it didn't raise an error
<nakilon>
especially weird considering that Array has no =~ method
<ox1eef>
the receiver is String#=~ in that example, not Array
<nakilon>
so the amount of new memory should not depend on the size of the inside objects
<mara>
actually, xyproblem. the reason i'm asking is that i have an array with a couple million elements, and i'm running .detect on it a few thousand-or-so times. with each subsequent .detect, i already know an offset up to which the .detect will not find anything and i thought that perhaps i could speed this up by using something like
<mara>
foo[offset..].detect, to save scanning up to offset
<weaksauc_>
though they do say in the object docs that it's deprecated because it can hide troublesome type errors nakilon
<nakilon>
if I wanted to do Regex#=~ I would do that explicitely, and why there is no error on Array?
<weaksauc_>
it was intended to be the general pattern matching operator
<nakilon>
mara that's another question; probably the [] is the same O(n) as detect
<nakilon>
*it may be that
<nakilon>
oh, maybe it does not raise only on 2.3, didn't check it further
<mara>
the detect should be heavier than an index access because it's doing complex comparisons
<nakilon>
I mean not [i] but [i..j]
<mara>
mm
<weaksauc_>
those docs are 3.1 so who knows when they deprecated it
<weaksauc_>
yeah 2.3 is not deprecated
<weaksauc_>
yet
<weaksauc_>
it was deprecated between 2.5 and 2.6
roadie has joined #ruby
roadie has quit [Ping timeout: 252 seconds]
Thanzex has quit [Read error: Connection reset by peer]
Thanzex has joined #ruby
roadie has joined #ruby
<mooff>
mara: you may want .lazy.detect
<mara>
mooff: why would .lazy.detect be faster than .detect?
oxfuxxx has quit [Ping timeout: 256 seconds]
roadie has quit [Ping timeout: 250 seconds]
<mooff>
mara: when you're chaining multiple filter / map stages, it'll run it as one sequence rather than processing the whole lot at each step
<mara>
i only have one detect on an existing object
<mara>
so making just that lazy will do nothing as far as i understand
<mooff>
ah, i misread your message
asveepay has quit [Quit: Lost terminal]
<mooff>
foo[offset..].detect is worth trying. benchmark it and see?
<mara>
i think my problem just solved itself. rather than running detect in a loop i'm now using select and then .index in the loop body which appears to be heaps faster anyway
<mara>
(i'm deleting *multiple* values (incl. values that have not been selected) of the array i'm running this on in the loop body, so i couldn't just use reject to begin with)
<mara>
that cut my run time from 93s to less than 1s 🙃
roadie has joined #ruby
roadie has quit [Client Quit]
<mooff>
iterating may skip elements if yer deleting as you go :)
oxfuxxx has joined #ruby
<mara>
i'm aware, that's why i'm not iterating over the object directly & the whole reason i'm dealing with these arcane ways of doing things :p
andrea[m] has joined #ruby
* mooff
crawls back to his cave :P
oxfuxxx has quit [Ping timeout: 252 seconds]
<mara>
heh
oxfuxxx has joined #ruby
hanzo has joined #ruby
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
eddof13 has joined #ruby
<adam12>
nakilon: added ferrum.
impermanence has quit [Quit: Connection closed]
fef has quit [Ping timeout: 240 seconds]
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<adam12>
nakilon: Ah interesting. That's the first gem I've added manually since adding a database, and I guess I never updated my quick script to use the db. heh.