jhass[m] changed the topic of #ruby to: Rules: https://ruby-community.com | Ruby 3.1.2, 3.0.4, 2.7.6: https://www.ruby-lang.org | Paste 4+ lines to: https://gist.github.com | Books: https://goo.gl/wpGhoQ
<ox1eef_> if the keys are to remain symbols, it could be less chrs:
<ox1eef_> x.map{|k,v|[*v].map.with_index(1){|v1,i|[*v].size>1?[:"#{k}#{i}",v1]:[k,v1]}}.flatten(1).to_h
sam113101 has quit [Quit: WeeChat 3.5]
sam113101 has joined #ruby
jpn has joined #ruby
s-liao-2000 has joined #ruby
Rounin has quit [Ping timeout: 255 seconds]
sagax has quit [Excess Flood]
Guest26nakilon has joined #ruby
<Guest26nakilon> hi
<Guest26nakilon> ah nvm, ruby again made the problem resolved faster than I could type the question
Guest26nakilon has quit [Client Quit]
markong has quit [Ping timeout: 246 seconds]
sagax has joined #ruby
jhass has quit [Ping timeout: 260 seconds]
jhass has joined #ruby
jl- has quit [Ping timeout: 240 seconds]
<ox1eef_> when i read nvm these days my first thought is 'node version manager'.
jhass has quit [Ping timeout: 246 seconds]
jl- has joined #ruby
cocalero has joined #ruby
jhass has joined #ruby
jhass has quit [Ping timeout: 246 seconds]
jhass has joined #ruby
jl- has quit [Ping timeout: 255 seconds]
matoro has quit [Quit: ZNC 1.8.2 - https://znc.in]
matoro has joined #ruby
jhass has quit [Ping timeout: 240 seconds]
matoro has joined #ruby
matoro has quit [Changing host]
jhass has joined #ruby
cocalero has quit [Quit: Going offline, see ya! (www.adiirc.com)]
matoro has quit [Remote host closed the connection]
matoro has joined #ruby
matoro has joined #ruby
matoro has quit [Changing host]
Ziyan has joined #ruby
dionysus69 has joined #ruby
rvalue has quit [Remote host closed the connection]
rvalue has joined #ruby
michigan has joined #ruby
davidw_ has quit [Ping timeout: 240 seconds]
ur5us has quit [Ping timeout: 268 seconds]
_ht has joined #ruby
jl- has joined #ruby
jl- has quit [Ping timeout: 268 seconds]
darkstardevx has quit [Quit: Leaving]
protektwar has joined #ruby
protektwar has joined #ruby
protektwar has quit [Changing host]
s-liao-2000 has quit [Ping timeout: 252 seconds]
michigan has quit [Quit: Connection closed for inactivity]
s-liao-2000 has joined #ruby
michigan has joined #ruby
protektwar has quit [Ping timeout: 264 seconds]
Rounin has joined #ruby
sagax has quit [Excess Flood]
jpn has quit [Ping timeout: 268 seconds]
Ziyan has quit [Ping timeout: 268 seconds]
Ziyan has joined #ruby
protektwar has joined #ruby
protektwar has quit [Changing host]
protektwar has joined #ruby
Ziyan has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
Ziyan has joined #ruby
dionysus69 has quit [Ping timeout: 272 seconds]
dionysus69 has joined #ruby
Aminda has quit [Ping timeout: 268 seconds]
Aminda has joined #ruby
Jonopoly has joined #ruby
tolerance5 has joined #ruby
niv has quit [Quit: Powered by LunarBNC: https://LunarBNC.net]
niv has joined #ruby
banisterfiend has joined #ruby
<banisterfiend> hi guys - we have an http payload signed with ed25519
<banisterfiend> what's the best way to verify that in ruby? and is it possible to verify using stdlib?
tolerance5 has quit [Remote host closed the connection]
dionysus69 has quit [Ping timeout: 268 seconds]
jpn has joined #ruby
desnudopenguino has quit [Read error: Connection reset by peer]
Ziyan_ has joined #ruby
desnudopenguino has joined #ruby
Ziyan has quit [Ping timeout: 268 seconds]
protektwar has quit [Ping timeout: 240 seconds]
dionysus69 has joined #ruby
michigan has quit [Quit: Connection closed for inactivity]
protektwar has joined #ruby
protektwar has quit [Changing host]
protektwar has joined #ruby
siery has joined #ruby
Ziyan_ has quit [Ping timeout: 268 seconds]
Ziyan has joined #ruby
Madd has joined #ruby
jl- has joined #ruby
Madd has quit [Quit: Client closed]
jl- has quit [Ping timeout: 246 seconds]
banisterfiend has quit [Quit: Client closed]
markong has joined #ruby
Guest30 has joined #ruby
Ziyan has quit [Ping timeout: 260 seconds]
Ziyan has joined #ruby
<Guest30> Hello, everyone! After developing in Ruby for a few years, I'm now for the first time looking at the Ruby source code. I was writing a local C extension that adds a pair of methods to Array, just to play around. I bumped into this, however:
<Guest30> It's some kind of comparison optimization:
<Guest30> ```
<Guest30> #define id_cmp idCmp
<Guest30> ```
<Guest30> I cannot find where idCmp is defined or what it does exactly. I tried tracing back through the commit history, but it's hard to find explanations on why it was introduced. Can anyone give me a hint?
<Guest30> Let me know also if this is the right place to ask such questions.
siery has quit [Ping timeout: 248 seconds]
protektwar has quit [Ping timeout: 248 seconds]
protektwar has joined #ruby
protektwar has joined #ruby
protektwar has quit [Changing host]
s-liao-2000 has quit [Quit: Client closed]
finsternis has quit [Read error: Connection reset by peer]
protektwar has quit [Ping timeout: 255 seconds]
Ziyan has quit [Ping timeout: 268 seconds]
Ziyan has joined #ruby
Ziyan has quit [Ping timeout: 268 seconds]
Ziyan has joined #ruby
protektwar has joined #ruby
protektwar has quit [Changing host]
protektwar has joined #ruby
Ziyan has quit [Ping timeout: 255 seconds]
Ziyan has joined #ruby
<adam12> Guest30: This is the right place, but fewer C authors in here than Ruby authors.
<Guest30> I can try Discord too then. Thanks
s-liao-2000 has joined #ruby
Ziyan has quit [Ping timeout: 246 seconds]
Guest30 has quit [Quit: Client closed]
Ziyan has joined #ruby
Guest30 has joined #ruby
Guest30 has quit [Client Quit]
protektwar has quit [Ping timeout: 268 seconds]
Ziyan_ has joined #ruby
Ziyan has quit [Ping timeout: 255 seconds]
<rapha> y'all
<rapha> what's the meaning of !!something?
<rapha> whatever i make "something" be, it seems i always get true out of it
<rapha> havenwood: ox1eef_: wow, ok, you did golf that down, good lord!!!
<rapha> havenwood: i'm not sure i'm understanding yours, but only due to a typo / line break on IRC ... was it intended to begin with `each.with_index(1).each_with_object({})`?
dionysus69 has quit [Ping timeout: 268 seconds]
dionysus69 has joined #ruby
<gr33n7007h> x.each_with_object({}){|(k,v),h,i=0|(Array===v)?v.map{h[:"#{k}#{i+=1}"]=_1}:h[k]=v}
<gr33n7007h> got it down to 83 chars =)
<gr33n7007h> x.map{|k,v,i=0,**h|(Array===v)?v.map{h[:"#{k}#{i+=1}"]=_1}:h[k]=v; h}.inject(:merge) # =( 84 chars
michigan has joined #ruby
<gr33n7007h> oh no, 83, i had a space.
<rapha> hmm
<rapha> but missing the edge case of 1 element in the array only :)
jpn has quit [Ping timeout: 268 seconds]
<gr33n7007h> rapha: this part handles 1 element `:h[k]=v` of the ternary operator =)
<rapha> o_O
jpn has joined #ruby
<rapha> ok i'll have to expand that and really read it in depth tonight after work
<gr33n7007h> rapha: 👍
jpn_ has joined #ruby
jpn has quit [Ping timeout: 260 seconds]
jl- has joined #ruby
Ziyan has joined #ruby
Ziyan_ has quit [Ping timeout: 248 seconds]
jl- has quit [Ping timeout: 268 seconds]
bit4bit has joined #ruby
jpn_ has quit [Ping timeout: 246 seconds]
davidw_ has joined #ruby
jpn has joined #ruby
dionysus69 has quit [Ping timeout: 240 seconds]
dionysus69 has joined #ruby
<adam12> I wonder if OptionParser can work in a git-subcommand style. Where some options are global, and some options are relevant to ARGV[0] after parsing. Has anybody done that before?
<adam12> I'm trying to stay dependency-free for this, so only core+stdlib.
jl- has joined #ruby
<adam12> I feel like you'd need to double parse, first for the global options, then second for the specific command options, but OptionParser complains when it finds an option it doesn't recognize. I don't think you could just rescue it as the flow is already broken. Hmm.
jl- has quit [Ping timeout: 268 seconds]
jpn has quit [Ping timeout: 246 seconds]
Jonopoly has quit [Quit: WeeChat 3.0]
dionysus69 has quit [Ping timeout: 268 seconds]
szkl has joined #ruby
onyx has joined #ruby
jpn has joined #ruby
s-liao-2000 has quit [Quit: Client closed]
jpn has quit [Ping timeout: 255 seconds]
perrierjouet has quit [Quit: WeeChat 3.5]
perrierjouet has joined #ruby
Ziyan has quit [Ping timeout: 268 seconds]
dstein64- has joined #ruby
Ziyan has joined #ruby
dstein64 has quit [Ping timeout: 256 seconds]
dstein64- is now known as dstein64
perrierjouet has quit [Quit: WeeChat 3.5]
jpn has joined #ruby
perrierjouet has joined #ruby
Ziyan has quit [Ping timeout: 268 seconds]
siery has joined #ruby
Ziyan has joined #ruby
Goodbye_Vincent has quit [Quit: Ping timeout (120 seconds)]
Goodbye_Vincent has joined #ruby
Goodbye_Vincent has quit [Client Quit]
Goodbye_Vincent has joined #ruby
Ziyan has quit [Ping timeout: 240 seconds]
Goodbye_Vincent has quit [Quit: Ping timeout (120 seconds)]
Ziyan has joined #ruby
jpn has quit [Ping timeout: 268 seconds]
Goodbye_Vincent has joined #ruby
siery has quit [Read error: Connection reset by peer]
jl- has joined #ruby
Ziyan has quit [Ping timeout: 248 seconds]
jl- has quit [Ping timeout: 240 seconds]
Ziyan has joined #ruby
siery has joined #ruby
siery has quit [Read error: Connection reset by peer]
rvalue has quit [Read error: Connection reset by peer]
rvalue has joined #ruby
jpn has joined #ruby
TomyWork has joined #ruby
markong has quit [Ping timeout: 246 seconds]
<ox1eef_> rapha: you could also remove the .size check by checking if index 1 is nil.
<ox1eef_> x.map{|k,v|[*v].map.with_index(1){|v1,i|[*v][1]?["#{k}#{i}",v1]:[k.to_s,v1]}}.flatten(1).to_h
<ox1eef_> gr33n7007h: Array===v is a lot. id try get rid of that somehow.
<ox1eef_> my example is killed by .flatten mostly
FetidToot has quit [Ping timeout: 246 seconds]
FetidToot has joined #ruby
<weaksauce> adam12 i know you are looking for dep free but you could look at how gli does it since that's pretty much exactly what you are looking for
<adam12> weaksauce: I'll check it out. Thanks.
<weaksauce> i've used it before and it's pretty slick
<axisys> how to handle exception and return "false" and with no exception return "true"
<ox1eef_> many ways
<ox1eef_> def foo
<ox1eef_> bar
<ox1eef_> true
<ox1eef_> rescue
<ox1eef_> false
<ox1eef_> end
<ox1eef_> thats one way
gr33n7007h has quit [Ping timeout: 240 seconds]
<axisys> ox1eef_: will that return true when there is no exception?
<ox1eef_> yup, assuming that 'bar' is a method call that doesn't raise, true will be returned.
gr33n7007h has joined #ruby
michigan has quit [Quit: Connection closed for inactivity]
<axisys> awesome!
<axisys> i see some where it is written as `return true` or `return false` .. but I see just `true` or `false` works perfect for ruby since it returns the last output.. so what is recommended?
<weaksauce> axisys whatever your company dictates :)
<weaksauce> barring that I would just do true
<ox1eef_> when you dig into it, it expands into different opinions and mindsets. some would argue, and i generally agree, that returning a strict true or return false value is often unneccessary - you can rely on the value being truthy, or false/nil.
szkl has quit [Quit: Connection closed for inactivity]
<ox1eef_> if you know 'bar' will return something truthy, you could drop the 'true' altogether.
jpn has quit [Ping timeout: 256 seconds]
jpn has joined #ruby
jl- has joined #ruby
jl- has quit [Ping timeout: 272 seconds]
<axisys> ox1eef_: yeah my case it does not. so just true or false actually worked nicely
dionysus69 has joined #ruby
fandre1986 has joined #ruby
<ox1eef_> cool
TomyWork has quit [Quit: Leaving]
Ziyan has quit [Quit: Textual IRC Client: www.textualapp.com]
siery has joined #ruby
gr33n7007h has quit [Ping timeout: 248 seconds]
gr33n7007h has joined #ruby
_ht has quit [Remote host closed the connection]
fandre1986 has quit [Quit: Connection closed]
jl- has joined #ruby
jl- has quit [Ping timeout: 264 seconds]
dionysus69 has quit [Read error: Connection reset by peer]
dionysus69 has joined #ruby
ur5us has joined #ruby
dionysus69 has quit [Ping timeout: 268 seconds]
siery has quit [Ping timeout: 268 seconds]
mynameisdebian has joined #ruby
<mynameisdebian> I just learned testing (Test::Unit) but I'm not totally sure what to do with these tests.  Say I want an e-mail fired off if a test fails.  Do I have to write a shell script to read the result of running the Ruby test, or is there some framework or something that allows me to do it all in Ruby?  Or is that part of Test::Unit and I just don't
<mynameisdebian> know?
<mynameisdebian> Ruby, not Rails
bit4bit has quit [Quit: Leaving]
<ox1eef_> mynameisdebian: it looks like there is test-unit-notify which would come in helpful for that: https://github.com/test-unit/test-unit-notify
<ox1eef_> you could create your own class, EmailNotify and rather than shell out just email instead.
markong has joined #ruby
<ox1eef_> might not be the perfect fit, looks like a decent starting point though
jl- has joined #ruby
bastienleonard has joined #ruby
bastienleonard has quit [Client Quit]
bastienleonard has joined #ruby
bastienleonard has quit [Client Quit]
bastienleonard has joined #ruby
moldorcoder7 has quit [Ping timeout: 268 seconds]
mynameisdebian has quit [Ping timeout: 252 seconds]
Rounin has quit [Ping timeout: 248 seconds]
crundar has joined #ruby
jl- has quit [Ping timeout: 268 seconds]
markong has quit [Ping timeout: 268 seconds]