havenwood changed the topic of #ruby to: Rules: https://ruby-community.com | Ruby 3.1.1, 3.0.3, 2.7.5: https://www.ruby-lang.org | Paste 4+ lines to: https://gist.github.com | Books: https://goo.gl/wpGhoQ
donofrio has quit [Read error: Connection reset by peer]
eddof13 has joined #ruby
eddof13 has quit [Client Quit]
eddof13 has joined #ruby
markong has quit [Ping timeout: 256 seconds]
<leah2> with 3.1 it's fast
<bougyman> Hey leah2
<bougyman> ltnc
<leah2> hey bougyman
<leah2> agree
<mooff> \o/
<mooff> you could watch a movie in the time it takes to paste a file into 2.7
<nakilon> for some reason the "Copy fetch" has less headers than "Copy curl" -- there is no Authority, User-agent, and DNT
<ox1eef> fetch as in JS?
<ox1eef> if so, thats because the browser handles those - at least user-agent & dnt.
ur5us has joined #ruby
ur5us_ has joined #ruby
ur5us has quit [Read error: Connection reset by peer]
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<nakilon> damn Cloudflare; I already ensures that I fully reproduce the header via httpbin.org but it immediately responds with 503
<nakilon> (I mean I compare the header sent from my program and from the curl that successfully gets 200)
roadie has joined #ruby
donofrio has joined #ruby
lunarkitty has quit [Quit: Connection closed for inactivity]
Rounin has quit [Ping timeout: 256 seconds]
osXnut has joined #ruby
osXnut has quit [Ping timeout: 240 seconds]
ur5us_ has quit [Ping timeout: 240 seconds]
roadie has quit [Quit: ERC (IRC client for Emacs 25.3.50.1)]
osXnut has joined #ruby
hanzo has joined #ruby
Tempesta has quit [Quit: See ya!]
reset has joined #ruby
wand has quit [Ping timeout: 240 seconds]
wand has joined #ruby
lunarkitty has joined #ruby
donofrio has quit [Ping timeout: 240 seconds]
dionysus69 has joined #ruby
Ziyan has joined #ruby
ollysmith_ has quit [Quit: ZNC 1.8.2+deb2+b2 - https://znc.in]
ollysmith has joined #ruby
taupiqueur has joined #ruby
dionysus69 has quit [Remote host closed the connection]
dionysus69 has joined #ruby
hanzo has quit [Quit: Connection closed for inactivity]
dionysus69 has quit [Quit: dionysus69]
dionysus69 has joined #ruby
_ht has joined #ruby
teclator has joined #ruby
Thanzex has quit [Read error: Connection reset by peer]
Thanzex has joined #ruby
Ziyan has quit [Quit: Textual IRC Client: www.textualapp.com]
___nick___ has joined #ruby
ur5us_ has joined #ruby
teclator has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
lunarkitty has quit [Quit: Connection closed for inactivity]
Rounin has joined #ruby
fef has joined #ruby
___nick___ has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
___nick___ has joined #ruby
___nick___ has quit [Client Quit]
___nick___ has joined #ruby
osXnut has quit [Quit: leaving]
TCZ has joined #ruby
nmollerup has quit [Quit: Leaving]
oxfuxxx has joined #ruby
oxfuxxx has quit [Ping timeout: 256 seconds]
oxfuxxx has joined #ruby
ur5us_ has quit [Ping timeout: 240 seconds]
markong has joined #ruby
taupiqueur has quit [Ping timeout: 240 seconds]
oxfuxxx has quit [Ping timeout: 250 seconds]
_ht has quit [Remote host closed the connection]
dionysus70 has joined #ruby
dionysus69 has quit [Quit: dionysus69]
dionysus70 is now known as dionysus69
dionysus69 has quit [Client Quit]
TCZ has quit [Quit: Leaving]
dionysus69 has joined #ruby
Sheilong has joined #ruby
Tempesta has joined #ruby
Tempesta has quit [Quit: See ya!]
mara has joined #ruby
<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?
<havenwood> {"foo" => %w[bar baz]}.each_with_object({}) { |(k, v), h| v.each { h[_1] = k } }
<havenwood> #=> {"bar"=>"foo", "baz"=>"foo"}
<havenwood> mara: If the values only have a single key each, you can invert the Hash.
<mara> havenwood: multiple values mapping to one key (many to one), no value will ever map to multiple keys (many to many)
<mara> yeah that's what i've been doing
<mara> though i doubt that's the best approach, is it
<havenwood> mara: Inverting the Hash is the best approach.
<mara> mm, alright
<havenwood> mara: With more context we might be able to suggest better, but from what you've said that's correct.
<havenwood> mara: It's far better to have `{"bar"=>"foo", "baz"=>"foo"}` than to check #include? repeatedly.
<mara> yeah, figure it makes sense to invert the hash once rather than run a couple thousand #include?
<mara> i'll go with that, thx
acosta has quit [Quit: The Lounge - https://thelounge.chat]
acosta has joined #ruby
o|||||o has joined #ruby
oxfuxxx has joined #ruby
<o|||||o> hey all, i'm having difficulty with sum
<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
<o|||||o> console log here: https://paste.ee/p/LwYGG
ua_ has quit [Ping timeout: 240 seconds]
impermanence has joined #ruby
<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
___nick___ has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
<nakilon> but [regex] is an object so it's calling [regex] =~ string according to docs
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gr33n7007h has joined #ruby
___nick___ has joined #ruby
___nick___ has quit [Client Quit]
___nick___ has joined #ruby
roadie has joined #ruby
roadie has quit [Remote host closed the connection]
roadie has joined #ruby
oxfuxxx has joined #ruby
o|||||o has quit [Ping timeout: 250 seconds]
roadie has quit [Ping timeout: 260 seconds]
oxfuxxx has quit [Ping timeout: 252 seconds]
oxfuxxx has joined #ruby
eddof13 has joined #ruby
roadie has joined #ruby
markong has quit [Ping timeout: 256 seconds]
<weaksauc_> isn't that the operator that is used for pattern matching in case statements nakilon
<weaksauc_> which is why it is the way it is
roadie has quit [Ping timeout: 252 seconds]
<nakilon> isn't that === ?
<mara> if i take a part of an array like foo[100..1000], does that return the same memory within foo or does it duplicate the elements in the range?
<weaksauc_> i guess so but it is the basic pattern matching operator
<nakilon> I believe it will duplicate 900 references
<weaksauc_> that other objects can implement
<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_> because it's defined on object
<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…]
eddof13 has joined #ruby
graywolf has joined #ruby
eddof13 has quit [Client Quit]
gr33n7007h has quit [Ping timeout: 252 seconds]
libsys has quit [Ping timeout: 250 seconds]
libsys has joined #ruby
agrosant has joined #ruby
___nick___ has quit [Ping timeout: 240 seconds]
agrosant has left #ruby [#ruby]
agrosant has joined #ruby
<nakilon> adam12 this i empty http://gemdocs.org/search?q=ferrum
gr33n7007h has joined #ruby
markong has joined #ruby
Exuma has joined #ruby
lunarkitty has quit [Quit: Connection closed for inactivity]
lunarkitty has joined #ruby
hanzo has quit [Quit: Connection closed for inactivity]
oxfuxxx has quit [Ping timeout: 268 seconds]
Exuma has quit [Quit: Textual IRC Client: www.textualapp.com]
o|||||o has joined #ruby
graywolf has quit [Quit: WeeChat 3.3]
m_antis has quit [Quit: ZNC - https://znc.in]
m_antis has joined #ruby
<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.