havenwood changed the topic of #ruby to: Rules & more: https://ruby-community.com | Ruby 2.7.1, 2.6.6, 2.5.8: https://www.ruby-lang.org | Paste 4+ lines of text to https://dpaste.de/ and select Ruby as the language | Rails questions? Ask in #RubyOnRails | Books: https://goo.gl/wpGhoQ | Logs: https://irclog.whitequark.org/ruby | Can't talk? Register/identify with Nickserv first!
gix has quit [Ping timeout: 265 seconds]
nicholaslyang has joined #ruby
justache has quit [Ping timeout: 240 seconds]
<Vashy> hm looks like I had to install `rspec` separately, when I ran `gem install rspec` it worked
<Vashy> I assumed `rspec-rails` was enough because of their documentation
nicholaslyang has quit [Client Quit]
<apotheon> You said you ran `bundle install` -- right? I'd expect that to install rspec, unless for some reason rspec isn't a dependency of rspec-rails.
<apotheon> . . . which would be weird, I think.
<apotheon> I'm glad you got it working.
<apotheon> Oh . . . I wonder if you had something in your Gemfile.lock that conflicted with what you needed.
<apotheon> Maybe?
<apotheon> oh well
<apotheon> I'm off for dinner. Ta.
TCZ has quit [Quit: Leaving]
AndreYuhai has quit [Quit: Leaving]
nicholaslyang has joined #ruby
nicholaslyang has quit [Client Quit]
justache has joined #ruby
nicholaslyang has joined #ruby
quazimodo has joined #ruby
oddp has quit [Ping timeout: 264 seconds]
jayx has joined #ruby
tau has quit [Ping timeout: 264 seconds]
ur5us has quit [Ping timeout: 260 seconds]
nofxx has quit [Remote host closed the connection]
nofxx has joined #ruby
greypack has quit [Ping timeout: 265 seconds]
davispuh has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
TCZ has joined #ruby
ur5us has joined #ruby
jayx has quit [Quit: Leaving]
justache has quit [Quit: The Lounge - https://thelounge.chat]
justache has joined #ruby
nicholaslyang has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
roadie has joined #ruby
fabio_ has joined #ruby
MadLamb has quit [Ping timeout: 260 seconds]
orbyt_ has joined #ruby
TCZ has quit [Quit: Leaving]
roadie has quit [Ping timeout: 246 seconds]
nicholaslyang has joined #ruby
fercell has quit [Quit: WeeChat 2.8]
alfiemax has joined #ruby
alfiemax has quit [Ping timeout: 240 seconds]
ttoocs has joined #ruby
nicholaslyang has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
nicholaslyang has joined #ruby
roadie has joined #ruby
_aeris_ has quit [Remote host closed the connection]
ChmEarl has quit [Quit: Leaving]
_aeris_ has joined #ruby
_0x03b5 has joined #ruby
nicholaslyang has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
imode has quit [Ping timeout: 264 seconds]
nicholaslyang has joined #ruby
drincruz has quit [Ping timeout: 256 seconds]
roadie has quit [Ping timeout: 272 seconds]
howdoi has quit [Quit: Connection closed for inactivity]
_whitelogger has joined #ruby
roadie has joined #ruby
Garb0 has quit [Quit: I'm out.]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
waheedi has joined #ruby
donofrio has quit [Remote host closed the connection]
waheedi has quit [Ping timeout: 264 seconds]
roadie has quit [Ping timeout: 260 seconds]
alfiemax has joined #ruby
reaVer has quit [Ping timeout: 272 seconds]
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
roadie has joined #ruby
reaVer has joined #ruby
roadie has quit [Ping timeout: 272 seconds]
imode has joined #ruby
Technodrome has joined #ruby
wymillerlinux has quit [Ping timeout: 260 seconds]
wnd-trans has joined #ruby
wnd has quit [Ping timeout: 272 seconds]
claw has quit [Read error: Connection reset by peer]
claw has joined #ruby
tastemakerChuck has quit [Ping timeout: 246 seconds]
JoL1hAHN has quit [Ping timeout: 272 seconds]
JoL1hAHN has joined #ruby
<al2o3-cr> good morning everyone, looks like it's going to be another beautiful day.
claw has quit [Ping timeout: 272 seconds]
wnd-trans is now known as wnd
skx86 has quit [Quit: Connection closed for inactivity]
tastemakerChuck has joined #ruby
claw has joined #ruby
Besnik_b has quit [Remote host closed the connection]
Besnik_b has joined #ruby
ur5us has quit [Ping timeout: 260 seconds]
zapata has quit [Ping timeout: 244 seconds]
Roelof has joined #ruby
rafadc has quit [Quit: ZNC - https://znc.in]
<Roelof> hello, I did some ruby development a long time ago. What is the best way to get up to speed ?
rafadc has joined #ruby
waheedi has joined #ruby
waheedi has quit [Client Quit]
alfiemax has quit [Remote host closed the connection]
alfiemax has joined #ruby
nicholaslyang has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
nicholaslyang has joined #ruby
dfucci has joined #ruby
apotheon has quit [Ping timeout: 258 seconds]
nicholaslyang has quit [Read error: Connection reset by peer]
MrCrackPot has quit [Read error: Connection reset by peer]
Roelof has quit [Ping timeout: 245 seconds]
vondruch has joined #ruby
bocaneri has joined #ruby
schne1der has joined #ruby
imode has quit [Ping timeout: 260 seconds]
ur5us has joined #ruby
Uncle_Cid has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
UncleCid has quit [Ping timeout: 240 seconds]
Roelof has joined #ruby
<Roelof> Hello again. Is rubyMonk a good way to learn ruby ?
sarna has joined #ruby
bocaneri has quit [Remote host closed the connection]
<havenwood> roelof: If you're enjoying it, sure!
<Roelof> or can I better use the codeacademy course ?
<Roelof> and at the same time practice with exercism.io challenges
nofxx has quit [Quit: Leaving]
<havenwood> roelof: I've not done them to compare. If you can do some exercism exercises, that seems like a good idea.
<havenwood> roelof: Ask here for iterative ideas on improvements.
<Roelof> oke, thanks,
<Roelof> then first look how I can install ruby the best on Windows 10 with a nice IDE
quazimodo has quit [Ping timeout: 260 seconds]
bocaneri has joined #ruby
<Roelof> anyone a good tutorial how to make ruby work on Win10 with a nice IDE ?
chalkmonster has quit [Quit: WeeChat 2.8]
Roelof has quit [Remote host closed the connection]
roellof has joined #ruby
<roellof> anyone who can recommend a good ide for win10 ?
<TheBrayn> roellof: rubymine
<roellof> oops, that is one payed and I find it too expensive for just hobby purpose
<jhass> IDEs are not very popular in the ruby community. Most use a good editor and a shell
fercell has joined #ruby
<rapha> we started using VSCode at work now ... first time i'm considering keeping an IDE around
<roellof> oke, hopefully the last problem. I installed rubu on wsl. How do I make a linkso that I also can use c:/mnt/c to do things
<jhass> I wouldn't call VSCode an IDE
<jhass> it still has no throughout semantic understanding of the code _and_ a UI tailored to make use of that understanding
<rapha> There's plugins for both of these.
<jhass> so there are for Vim, Atom, Sublime, emacs, probably gedit, kate & notepad++ these days. Are all of these IDEs?
<jhass> also I knew this point was coming, hence the emphasis on the and
<roellof> hmm,, maybe I can better use the rubyinstaller instead of installing ruby with wsl2 :(
cd has joined #ruby
<leftylink> I like vim
TomyWork has joined #ruby
<roellof> oke, done two challenges on exercism and I now have to wait on a mentor :)
_aeris_ has quit [Remote host closed the connection]
iNs_ has quit [Remote host closed the connection]
iNs has joined #ruby
_aeris_ has joined #ruby
jennis5 has joined #ruby
memcorrupt has joined #ruby
chihhsin_ has joined #ruby
jennis has quit [Quit: Ping timeout (120 seconds)]
jennis5 is now known as jennis
electrostat has quit [Quit: uwotm8]
camilasan_ has quit [Remote host closed the connection]
electrostat_ has joined #ruby
MasterNayru_ has quit [Remote host closed the connection]
electrostat_ is now known as electrostat
<rapha> hmm
<rapha> i don't want to fight
<rapha> i just wanted to say that for GUI i like VSCode now
<rapha> command line still Vim
chihhsin has quit [Ping timeout: 265 seconds]
<rapha> roellof: they're two different things. do you want to use WSL or do you want to not use WSL-.
camilasan has joined #ruby
MasterNayru has joined #ruby
shortdudey123 has quit [Ping timeout: 264 seconds]
<roellof> I succeed in making things work in WSL and solved the first two challenges. Now I have to wait for approval
shortdudey123 has joined #ruby
_0x03b5 has quit [Read error: Connection reset by peer]
snuz has joined #ruby
<memcorrupt> roellof: what challenges? and WSL => Windows Subsystem for Linux?
oddp has joined #ruby
roellof has quit [Remote host closed the connection]
Roelof has joined #ruby
lmat has quit [Ping timeout: 264 seconds]
rubydoc has quit [Ping timeout: 256 seconds]
phaul has quit [Ping timeout: 265 seconds]
lmat has joined #ruby
<Roelof> exercism,io challenges so I learn ruby
ur5us has quit [Ping timeout: 260 seconds]
arahael has joined #ruby
<memcorrupt> hmmh... I personally prefer hackerrank and codingame...
<CommunistWolf> ugh
<sarna> roelof: on my windows machine I set up vscode to develop in docker containers with ruby in them
<Roelof> o, never knew that is possible
rubydoc has joined #ruby
isxek has joined #ruby
<Roelof> any tutorials how to install ruby in a docker container and how I can make vs code work with it
<Roelof> sarna
cliluw has quit [Ping timeout: 256 seconds]
memcorrupt has quit [Ping timeout: 246 seconds]
alfiemax has quit [Remote host closed the connection]
<Roelof> thanks, will take a look at it
phaul has joined #ruby
alfiemax has joined #ruby
rubydoc has quit [Ping timeout: 246 seconds]
phaul has quit [Ping timeout: 265 seconds]
<Roelof> CommunistWolf do you not like hackerrank or codinggame ? or do you not like exercism.io ?
phaul has joined #ruby
Roelof has quit [Remote host closed the connection]
<CommunistWolf> any of them. people inevitably end up using them during the hiring process, which is terrible
memcorrupt has joined #ruby
memcorrupt has quit [Changing host]
memcorrupt has joined #ruby
<sarna> I like doing stuff on my own and ask for help here :)
<sarna> s/ask/asking
rubydoc has joined #ruby
kent\n has joined #ruby
isxek has quit [Quit: Leaving]
tbisker8 has quit [Quit: ZNC 1.7.5 - https://znc.in]
titanbiscuit has joined #ruby
isxek has joined #ruby
Roelof has joined #ruby
* Roelof hopes he has not missed the answer to his last question
<leftylink> well, it is important to know that the channel logs are linked in the channel topic.
rubydoc has quit [Ping timeout: 265 seconds]
phaul has quit [Ping timeout: 264 seconds]
isxek is now known as rcl
rcl is now known as d00fuz
phaul has joined #ruby
<Roelof> leftylink thanks
<Roelof> according to the log I miss the answer
<leftylink> so now you know
<Roelof> pity that on the I do not how many minutes the connection get lost
rubydoc has joined #ruby
d00fuz is now known as rcl
rcl is now known as d00fuz
d00fuz is now known as rcl
rcl has quit [Quit: Leaving]
d00fuz has joined #ruby
donofrio has joined #ruby
alfiemax has quit [Remote host closed the connection]
alfiemax has joined #ruby
alfiemax has quit [Ping timeout: 246 seconds]
rubydoc has quit [Ping timeout: 260 seconds]
phaul has quit [Ping timeout: 260 seconds]
* Roelof hopes he can now stay long in this channel
<sarna> roelof: there's a service called irccloud that could in theory make your connection more stable
<sarna> I think they include two hours of logs in their free plan
<sarna> if you pay, you get unlimited history I think
<jhass> or if you have a spare box just install ZNC :P
<sarna> and a spare few hours ;)
<jhass> most of that time is not installing ZNC but configuring a decent IRC client :P
rubydoc has joined #ruby
phaul has joined #ruby
roelof_ has joined #ruby
<sarna> well, or configuring ZNC itself
<sarna> it's a whole experience
<jhass> I feel like you getty pretty far with the defaults at first
<sarna> yeah true
_Caerus has quit [Ping timeout: 260 seconds]
dionysus69 has joined #ruby
alfiemax has joined #ruby
<Roelof> hmm, is there a better way to solve this one :
<Roelof> ```
<Roelof> class ResistorColorDuo COLORS = %w(black brown red orange yellow green blue violet grey white) def self.value(string) outcome = 0 for i in 0 .. 1 outcome = outcome * 10 + COLORS[string[i]] end outcome end
skx86 has joined #ruby
<Roelof> another better link : https://dpaste.org/nFZv
drincruz has joined #ruby
d00fuz has quit [Remote host closed the connection]
TCZ has joined #ruby
<Roelof> hmm, maybe I can better use map
<Roelof> I will experimnt more
Caerus has joined #ruby
<sarna> roelof: I think `(0..1).each do |i| ... end` would be more idiomatic
rubydoc has quit [Ping timeout: 240 seconds]
phaul has quit [Ping timeout: 246 seconds]
<Roelof> sarna I did solve it this way : ` string[0..1].map { | item| COLORS.index(item) }.join.to_i `
<sarna> roelof: looks nice!
<Roelof> thanks, and for a beginner :)
<sarna> I'm a beginner as well :)
ineb has joined #ruby
<leftylink> it makes you wish the join didn't have to happen, because it is a shame to have to convert it to a string only to convert it back to an integer, but since the problem only says to deal with two colours, my concern about using join is misplaced here
<Roelof> oke, if there is a way without the join im happy to learn
<ineb> What is a good way to wrap json responses from a web API in a ruby object? Lets say the API returns {"foo": "bar"}, i want a 'robust' ruby object like response.foo # => "bar". I think i want these objects dynamically. I have looked at OpenStructs and Hashie but they do not look 'robust' because in case of response.not_existing, they always return 'nil' instead of method_missing
GodFather_ has quit [Ping timeout: 256 seconds]
<Roelof> leftylink is there then a method I can add all the indexes up and multiply the old one with 10 ?
<jhass> I can't say I'm a huge hashie fan, but https://github.com/hashie/hashie#strictkeyaccess
akem has quit [Ping timeout: 265 seconds]
<jhass> roelof: you only need to handle two values. How about using a + ?
<jhass> and a * to put one of the digits into its right decimal place
phaul has joined #ruby
<ineb> jhass: ty, i will look at it.
<Roelof> @jhass you mean something like `COLORS.index(string[0]) * 10 + COLORS.index(string[1[) `
rubydoc has joined #ruby
<jhass> yeah
<Roelof> oke, thanks
stryek has joined #ruby
phaul has quit [Ping timeout: 265 seconds]
rubydoc has quit [Ping timeout: 240 seconds]
phaul has joined #ruby
rubydoc has joined #ruby
rubydoc has quit [Remote host closed the connection]
rubydoc has joined #ruby
<Roelof> I like this one too : ` string[0..1].reduce(0) { |total, item| total * 10 + COLORS.index(item) } `
<Roelof> that can be expanded to more if needed
phaul has quit [Ping timeout: 256 seconds]
rubydoc has quit [Ping timeout: 260 seconds]
<jhass> one the one hand yes, otoh it makes an uncessary two element array
<jhass> actually isn't it wrong?
<jhass> ah, now I see, it does 0 * 10 on the first iteration
<Roelof> All the tests are green so it suppose/assumed that the code is allright ?
jetchisel has quit [Quit: Unfortunately time is always against us -- [Morpheus]]
<jhass> yeah
<jhass> idk it feels too smart for this simple problem :)
memcorrupt has quit [Ping timeout: 265 seconds]
memcorrupt has joined #ruby
memcorrupt has quit [Changing host]
memcorrupt has joined #ruby
Technodrome has joined #ruby
burningserenity has joined #ruby
burningserenity has quit [Client Quit]
burningserenity has joined #ruby
phaul has joined #ruby
rubydoc has joined #ruby
darkstardev13 has quit [Remote host closed the connection]
darkstardev13 has joined #ruby
con3 has quit [Ping timeout: 258 seconds]
rubydoc_ has joined #ruby
rubydoc has quit [Excess Flood]
phaul has quit [Ping timeout: 265 seconds]
rubydoc_ has quit [Ping timeout: 265 seconds]
drincruz has quit [Ping timeout: 264 seconds]
freshmaker666 has quit [Quit: ZNC 1.7.2 - https://znc.in]
<sarna> I reverted to webmock alone, I can't get VCR to work with any of the HTTP libraries :( I don't know if it's a bug in VCR or something else
drincruz has joined #ruby
<sarna> anyway - can you specify that a request with some parameters have been made on a stub?
<sarna> oh there's a with in the stub :facepalm:
BrianWGray has quit [Ping timeout: 264 seconds]
<sarna> ..but HTTP doesn't put params in the URL, oh lord
<sarna> oh it does! I had a bug :)
<adam12> ineb: You could try creating a new Object then using define_singleton_method for each field, and return the value. This may have unintended performance implications with the GC and method cache.
<ineb> adam12: yeah, i think another simple solution is to just wrap the actual hash and check for key existence before accessing anything
<adam12> ineb: Yep. That would work fine too if you're not opposed to method_missing.
phaul has joined #ruby
rubydoc_ has joined #ruby
sarna has quit [Quit: Connection closed]
wymillerlinux has joined #ruby
phaul has quit [Ping timeout: 240 seconds]
rubydoc_ has quit [Ping timeout: 256 seconds]
phaul has joined #ruby
rubydoc_ has joined #ruby
TCZ has quit [Ping timeout: 240 seconds]
BrianWGray has joined #ruby
cd has quit [Ping timeout: 260 seconds]
alfiemax has quit [Remote host closed the connection]
alfiemax has joined #ruby
Roelof has quit [Ping timeout: 245 seconds]
roelof_ is now known as roelof
akem has joined #ruby
reffle has joined #ruby
alfiemax has quit [Ping timeout: 260 seconds]
memcorrupt has quit [Ping timeout: 258 seconds]
MrCrackPot has joined #ruby
memcorrupt has joined #ruby
memcorrupt has quit [Changing host]
memcorrupt has joined #ruby
d00fuz has joined #ruby
ChmEarl has joined #ruby
burningserenity has quit [Ping timeout: 240 seconds]
dionysus69 has quit [Ping timeout: 264 seconds]
arahael1 has joined #ruby
snuz has quit [Read error: Connection reset by peer]
snuz has joined #ruby
arahael has quit [Ping timeout: 240 seconds]
Roelof55 has joined #ruby
<Roelof55> what do you experts think of this solution : https://gist.github.com/RoelofWobben/ec2de24bdc8941ee154b0352894f4e2f
rubydoc_ has quit [Ping timeout: 264 seconds]
phaul has quit [Ping timeout: 246 seconds]
_0x03b5 has joined #ruby
Garb0 has joined #ruby
alfiemax has joined #ruby
<adam12> Roelof55: Looks OK but won't handle an invalid strand. By design?
<havenwood> Roelof55: Pretty nice solution, but still room to improve. :)
<Roelof55> yep it is a challenge from exercism,io where you never get invalid input
<Roelof55> havenwood I think there is always room to improve but shoot
<havenwood> Roelof55: Clearly, the most important thing is `dnastring` should be `dna_string`. :P
_0x03b5 has quit [Remote host closed the connection]
<havenwood> Roelof55: A neat trick with your block, is to: map(&DNA_TO_RNA)
_0x03b5 has joined #ruby
<havenwood> Roelof55: You are close to the nicest solution that doesn't keep it a String.
<Roelof55> never know that one. is what your doing the same as I did
<havenwood> Roelof55: Yup.
<Roelof55> oke, learned another thing
<havenwood> dnastring.chars.map(&DNA_TO_RNA).join
<havenwood> Roelof55: It works because of Hash#to_proc.
<havenwood> Roelof55: From there, I'd suggest thinking about how you could possibly solve this without ever having an Array you join back to a String.
<Roelof55> so if I do convert something I can do &function ?
<havenwood> Roelof55: The & does two things, it calls #to_proc then passes the resulting proc as the block.
<Roelof55> that would be very nice because I convert it to a array and then convert it back to a string
<havenwood> Roelof55: So what String methods can "swap" letters?
<havenwood> &>> String.instance_methods(false)
ellcs1 has joined #ruby
<Roelof55> havenwood I was trying 'each_char` but then the test are failing
<havenwood> Roelof55: Hint, to narrow it down: String.instance_methods.grep(/\A\w{2,4}\z/)
<havenwood> Roelof55: Look at short methods.
<havenwood> &>> String.instance_methods(false).grep(/\A\w{2,4}\z/)
<havenwood> #=> [:to_r, :to_c, :sum, :next, :upto, :chr, :dump, :hex, :size, :succ, :oct, :ord, :to_s, :to_i, :to_f, :gsub, :sub, :scan, :chop, :tr, :tr_s, :hash]
<havenwood> Roelof55: Which of those ^ might work? There's more than one option in there, but I think one stands out.
<Roelof55> my eyes looked at to_c but I do not think it the good one
<havenwood> 'Too complex!'.to_c #=> (0+0i)
<havenwood> Nope, not #to_c.
<Roelof55> I take a break
<Roelof55> none of them looks to me like a good candidate
<havenwood> Roelof55: Two work. One works really well. :)
<havenwood> Well, more than two work, but...
<Roelof55> wait, maybe gsub
<adam12> That's what I'd use.
<Roelof55> with that one I can global change a character
<havenwood> Roelof55: That's the runner up. There's one better yet. A shorter one...
phaul has joined #ruby
<Roelof55> then sub but that one works only till the first one and I think there could be more then 1 the same character
<havenwood> Roelof55: Fun to try it with #gsub, but even more concise with a two-letter option.
_0x03b5 has quit [Ping timeout: 260 seconds]
<Roelof55> the only one with 2 character I see it tr
<havenwood> Roelof55: :)
rubydoc_ has joined #ruby
<havenwood> There's a command line command by the same name.
<havenwood> tr -- translate characters
<adam12> havenwood: I forgot tr will accept a range.
<adam12> I'd still use gsub out of habit.
duckpupp- has quit [Read error: Connection reset by peer]
<adam12> Probably wouldn't matter for a small string like this but I wonder which would be faster on a larger document.
<havenwood> adam12: Or a "^", which is kinda fun.
<havenwood> adam12: #tr wins generally
<havenwood> so fast
<Roelof55> hmm, then time to experiment how the code looks like then. this is not working ` dna.tr('gcta', DNA_TO_RNA('gcta'))`
<havenwood> Roelof55: Nope, I'd not involve a Hash.
<havenwood> Roelof55: I'd #tr from what you have to what you want.
<havenwood> 'Roelof55'.tr('oe', 'ao') #=> "Raolaf55"
rippa has joined #ruby
memcorrupt has quit [Quit: bye]
<Roelof55> I know
<havenwood> 👍🏽
<Roelof55> or d I have to write tr for every dna part so one for the G, one for the C and so on ?
<havenwood> Roelof55: Look carefully at how #tr works.
chalkmonster has joined #ruby
<havenwood> Roelof55: See my example above.
<havenwood> Roelof55: What did `.tr('oe', 'ao')` do?
<Roelof55> I changed the oe to ao
<havenwood> Roelof55: "Raol --> a <-- f55"
<Roelof55> and I need to translate a G to a C, a C to a G and so one
ineb has left #ruby ["WeeChat 2.8"]
<havenwood> Roelof55: Like how the "o"s became "a"s.
<havenwood> Roelof55: How #tr works surprizes most on first impression.
<Roelof55> sorry, im more and more confused now
<havenwood> Take a second look at how the arguments work.
renich has joined #ruby
<Roelof55> oke, back to the example `Roelof55'.tr('oe', 'ao') #=> "Raolaf55" `
<havenwood> Roelof55: What happened to the "a"s in that ^ example?
Roelof55 has quit [Remote host closed the connection]
roelof100 has joined #ruby
<roelof100> and again im kicked out
shokohsc has quit [Quit: The Lounge - https://thelounge.chat]
<havenwood> roelof: Here's another example:
<havenwood> roelof100: Consider this:
<havenwood> 'X.O.X.O'.tr('AXON', 'BOXE')
<havenwood> roelof100: What do you expect that ^ result to be?
<roelof100> O.X.O.X ??
<havenwood> #=> "O.X.O.X"
<havenwood> roelof100: Would that work for the DNA/RNA?
<havenwood> roelof100: What would the proper two argument Strings be?
shokohsc has joined #ruby
<roelof100> wait , it could work like this `DNA.tr('GCTA`, 'CGAU`)
<roelof100> I do not need the hash anymore
<havenwood> roelof100: 🙌
duckpuppy has joined #ruby
dionysus69 has joined #ruby
<roelof100> havenwood and it working
<roelof100> very short code
<roelof100> thanks for the lesson and patience
shokohsc has quit [Quit: The Lounge - https://thelounge.chat]
darkstardev13 has quit [Remote host closed the connection]
shokohsc has joined #ruby
<roelof100> and now I have to wait till a mentor approves it. Have the max challenges done where I can ask for mentor approval
fercell has quit [Quit: WeeChat 2.8]
<phaul> &renick
rubydoc_ is now known as rubydoc
<rubydoc> okay
Bounga has joined #ruby
ellcs1 has quit [Ping timeout: 260 seconds]
Bounga has quit [Remote host closed the connection]
Bounga has joined #ruby
renich_ has joined #ruby
Bounga has quit [Remote host closed the connection]
renich has quit [Ping timeout: 240 seconds]
renich_ is now known as renich
renich has quit [Client Quit]
Bounga has joined #ruby
Bounga has quit [Remote host closed the connection]
<roelof100> wish you all a good evening its supper time for me :
Bounga has joined #ruby
drincruz has quit [Ping timeout: 240 seconds]
donofrio_ has joined #ruby
<sagax> hi all!
<sagax> if i need recursion but i have error about this - what i can do?
donofrio_ has quit [Remote host closed the connection]
donofrio_ has joined #ruby
donofrio has quit [Ping timeout: 264 seconds]
nychtel has joined #ruby
nychtel has quit [Client Quit]
alfiemax has quit [Remote host closed the connection]
burningserenity has joined #ruby
stdedos has joined #ruby
<adam12> sagax: What's the error? are you referring to tail recursion?
roelof100 has quit [Ping timeout: 245 seconds]
TomyWork has quit [Remote host closed the connection]
drincruz has joined #ruby
howdoi has joined #ruby
Eiam has joined #ruby
<havenwood> sagax: Show us!
dionysus69 has quit [Remote host closed the connection]
orbyt_ has joined #ruby
FastJack has quit [Ping timeout: 258 seconds]
FastJack has joined #ruby
stdedos has quit [Quit: Connection closed]
<sagax> >> stack level too deep
<ruby[bot]> sagax: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `[]' for nil:NilClass
ellcs1 has joined #ruby
<adam12> sagax: We'd need the full stack trace pasted somewhere. Ruby doesn't (IIRC) have natural tail recursion without a flag, which isn't enabled by default.
apotheon has joined #ruby
<sagax> it's without `drawed` field -- https://termbin.com/y6ou and in this example i don't have `stack level too deep`. AND in this example, https://termbin.com/4hdi and this example have `stack level too deep`, https://termbin.com/726j
<Uncle_Cid> Dude in discord has "def level_order(node = @root)" as method signature, and I can't quite figure out how to tell him that the default assignment on this probably isn't a good practice?
<Uncle_Cid> or why it isn't
<Uncle_Cid> it seems like an out of the box thing someone doesn't normally do because I'
<Uncle_Cid> m not really getting search results for what I am looking for lol
mossplix has joined #ruby
bocaneri has quit [Remote host closed the connection]
apotheon has quit [Ping timeout: 246 seconds]
cliluw has joined #ruby
<adam12> Uncle_Cid: I don't see instance variables used that often as a default assignment but often a method call that would be backed by the instance variable. So it would be OK in my books.
sagax has quit [Ping timeout: 256 seconds]
sagax has joined #ruby
apotheon has joined #ruby
<Uncle_Cid> heard that
imode has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
snuz has quit [Read error: Connection reset by peer]
snuz_ has joined #ruby
rmnull has joined #ruby
<rapha> adam12: what does it mean for a method call to be "backed" by the (a?) instance variable?
<Uncle_Cid> He's assuming whoever is writing code using this method would have defined the default value before calling the method
Roelof20 has joined #ruby
<Roelof20> Hello, last question of the day.What do you experts think of this solution : https://gist.github.com/RoelofWobben/908289f389c0622858d75343c9779a4b
fabio_ has quit [Remote host closed the connection]
<Uncle_Cid> if statement probably makes more sense
<havenwood> &>> -42.abs2
<rubydoc> # => 1764 (https://carc.in/#/r/9bdo)
<Uncle_Cid> You're not really using case for it's benefits
wymillerlinux has quit [Quit: wymillerlinux]
<havenwood> Roelof20: Omit those `return`s.
<adam12> rapha: Ruby accessors use an instance variable to provide the value. So instead of seeing `node = @root`, I might have seen `node = root`, with `root` being an accessor. Or a method.
<adam12> rapha: The method being `def root; @root; end` or something, but that's easily a reader.
<adam12> rapha: I mostly dislike instance variables because of the way they'll return `nil` for undefined instance variables. I'll prefer a local or a method call almost every time. Probably why I rarely see an instance variable used as a default in a method definition.
<havenwood> Roelof20: .rs is a Rust extension. ;P
<havenwood> Roelof20: .rb for Ruby.
<Roelof20> oke, all the returns are deleted
<Roelof20> and the file has a extension of rb. Typo when making a gists
<havenwood> Roelof20: You can edit a Gist.
<Roelof20> also changed
<havenwood> Roelof20: 5.abs2 #=> 25
<havenwood> [[:abs2], [:**, 2], [:pow, 2], [:*, 5], [:+, 20], [:lcm, 25]]
orbyt_ has joined #ruby
<havenwood> (Just an aside.)
<Roelof20> also changed
rmnull has quit [Quit: WeeChat 2.8]
<rapha> adam12: wait, so you also try to use attr_accessor as little as possible?
rmnull has joined #ruby
<havenwood> Roelof20: Just put a space after that comma!
<havenwood> Roelof20: (x,y)
rmnull has quit [Client Quit]
<havenwood> Roelof20: (x, y)
<adam12> rapha: No. I try to use attr_* as _much_ as possible (compared to an instance variable).
<havenwood> I use instance variables. :P
<adam12> rapha: If it comes down to @foo or private attr_reader :foo, I'll probably use the latter almost every time.
<adam12> rapha: Rubocop helps with this to some degree, as does ruby -w.
<havenwood> Roelof20: It now reads pretty well, yeah?
<Roelof20> yep, it is still working and the tests are still green
<adam12> Instance variables are probably faster in some minor way.
<Roelof20> havenwood
<adam12> You can't use the extract method refactor pattern as easy tho.
Bounga has quit [Ping timeout: 260 seconds]
<rapha> adam12: okay, so you're fine with instance variables "protected" by accessor methods, is what I understood now?
<Roelof20> and I think I will install ruby tomorrow again with ruby installer
<Roelof20> this makes me crazy
<adam12> rapha: Yeah. Nothing wrong with instance variables, but I prefer them to normally be in `initialize` and nowhere else. If I need them, they are through an accessor or another method call.
<havenwood> I use instance variables directly when it suffices, to convey the simplest case to the reader and for speed.
<Roelof20> installing gems is a nightmare with WSL
<adam12> Roelof20: How so?
apotheon has quit [Ping timeout: 264 seconds]
<Roelof20> I did install the solargrapg gem and still when I open vs studio I see this error : https://imgur.com/a/MSJBjQU
<Roelof20> havenwood so my code is now good enough ?
<adam12> Roelof20: Do you use rvm or anything?
<Roelof20> I use rbenv like this guide told me to do : https://gorails.com/setup/windows/10
<havenwood> Roelof20: Can you launch VSCode from the command line?
<havenwood> I don't have a WSL box handy.
<Roelof20> yep
<havenwood> I clearly need a gaming rig.
<havenwood> Roelof20: Run `code` then see if Solargraph works.
<havenwood> (ENV vars...)
<Roelof20> I use the whole day code , to get the right challenge in vs code
<havenwood> Roelof20: It's fairly normal to see folk launch their editor from the command line so it inherits env vars.
<Roelof20> when I do `code , ` I see vs studio open with the challenge that is on that directory
<havenwood> Or you can set it up yourself.
<Roelof20> I mean `code .`
<havenwood> Huh?
<Roelof20> he, I found a error message : `[Error - 9:16:59 PM] Starting client failed/bin/bash: solargraph: command not found `
<havenwood> I'm not sure what the problem is, but seems Ruby, rbenv, Solargraph, VSCode, etc all work and you're having a PATH problem.
<Roelof20> it seems that vs code is looking for solargraph on my windows box and not on the wsl
<havenwood> Roelof20: gem install solargraph
<havenwood> Roelof20: Oh
<havenwood> Roelof20: WSL problems
<havenwood> Roelof20: I'm going to burn these BLTs. AFK!
<Roelof20> BLT ??
<Roelof20> so maybe tomorrow I have to install everything with rubyinstaller or look again to do it on docker
<al2o3-cr> Roelof20: bacon, lettuce and tomato
apotheon has joined #ruby
<Roelof20> sorry, still do not make sense to me. maybe because english is not my mother language
<Uncle_Cid> adam12 I would probably argue against assigning default value with an instance variable because perhaps it's not clear
<Uncle_Cid> what is really going on there
<Uncle_Cid> or what a good default value ACTUALLY is
<Roelof20> what is then a better way. Do the calculation in the score function ?
<Roelof20> adam12 Uncle_Cid
cnsvc has joined #ruby
schne1der has quit [Ping timeout: 256 seconds]
* Uncle_Cid shrugs
<Uncle_Cid> idk what youg uys got going on lol
vondruch has quit [Ping timeout: 246 seconds]
<havenwood> Roelof20: Normally I'd suggest that you think about what internal state you need to store, if any.
asfas has joined #ruby
<havenwood> Roelof20: The #distance is a reader, so it can't change. That means the #score value can just be memoized (remembered and served up again, if asked).
<asfas> Hey guys! Question - I have a shitty deeply nested hash (which I have no control over) which has a certain key either, 4 levels down or 5 levels sometimes. How do I write a block of code that handles this without having to dirty 4 nested loops and then handle the case for the 5th if the key isn't found in the 4th?
<havenwood> Roelof20: Since no internal state matters, this could just be an actual module function. Happy to discuss.
<havenwood> Roelof20: Or you could pretend it does matter, and practice memoizing.
<havenwood> asfas: Are you already using #dig?
<havenwood> asfas: Sounds like #dig twice.
jayx has joined #ruby
<asfas> I am using dig, but the resultant code is pretty bad. It is 4 levels down sometimes and 5 and sometimes 3. How do I repeat this pattern? Could you please give an example? Thanks!
<havenwood> asfas: Could you show us a small example hash of the 4 or 5 levels down and the desired result?
<havenwood> Or a 1 or 2 levels down paired down example?
<havenwood> Roelof20: You're giving two arguments and no stored internal value of the class matters, so a module function makes sense unless something is asking the Dart score multiple times.
<havenwood> Roelof20: Consider these examples: https://gist.github.com/havenwood/a81401724cbcbf1f78e79f42ed4b0e33
<havenwood> Roelof20: So basically, make it an actual function in a module or if it's a class, go ahead and calculate the score when it's initialized.
<havenwood> Roelof20: Sometimes these problems are contrived, and the goal is just to match the interface, which might not be a particularly sensible interface.
<asfas> havenwood Thanks for the quick response. Here's an example of the kind of structure it is - https://gist.github.com/7f3056437a98dc3b982cc84765ee33c5
<asfas> I am trying to get to the "ColData" field, which sometimes is embedded within another "Rows" + "Row" structure.
schne1der has joined #ruby
<havenwood> asfas: fwiw, `"Rows":` is a Symbol key and is just a verbose `Rows:`.
<havenwood> asfas: To clarify, currently, you are doing?:
<havenwood> payload.dig(:Rows, :Row, :Rows, :Row, 0, :Header) || payload.dig(:Rows, :Row, :Rows, :Row, :Rows, :Row, 0, :Header)
<havenwood> &>> {:Rows=>{:Row=>{:Rows=>{:Row=>[{:Header=>{:ColData=>[{:value=>""}, {:value=>""}, {:value=>""}, {:value=>""}]}}]}}}}.dig(:Rows, :Row, :Rows, :Row, 0, :Header)
<rubydoc> # => {:ColData=>[{:value=>""}, {:value=>""}, {:value=>""}, {:value=>""}]} (https://carc.in/#/r/9beu)
<leftylink> hmm. my thought would be to successively descend into one layer of Rows+Row, once there are no more Rows+Row to descend into, take the ColData from there
<havenwood> leftylink: yeah, I was contemplating a recursive flipfloppy type thing too
<havenwood> hard to tell what the rules are exactly
<leftylink> if you thought of recursion first, that is interesting, since I also thought of it first. then I had to consider whether to explicitly mention that in my suggestion
<havenwood> leftylink: you just made me consider whether you were recursing as a joke
<havenwood> now I'm wondering if I'm recursing as a joke
<asfas> recursion sounds like a feasible solution
Roelof20 has quit [Ping timeout: 245 seconds]
<asfas> The structure always remains this -> (Rows, Row) -> Array -> 0 -> (Rows, Row) -> Array -> 0 -> (Rows, Row) -> Array.. at some point you find ColData there
<leftylink> I chose not to explicitly mention recursion since I decide to leavce it up the implementor's choice whether to use recursion or not to achieve "successively descend"
<asfas> I made it! Thank you so much havenwood and leftylink! For some reason, I didn't even consider recursion
jetchisel has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
schne1der has quit [Remote host closed the connection]
schne1der has joined #ruby
AndreYuhai has joined #ruby
<AndreYuhai> How many jobs can I submit into sidekiq queue? What's the upper limit
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
<havenwood> AndreYuhai: 2³²
<havenwood> &>> 2 ** 32
<rubydoc> # => 4294967296 (https://carc.in/#/r/9bey)
<havenwood> I'd think somewhere around there.
<AndreYuhai> Oh that's nice. :D I couldn't find anything in the docs about it.
<havenwood> AndreYuhai: I think it's more of a Redis question.
<havenwood> AndreYuhai: I'd suggest trying it if you're worried about the upper bound.
<AndreYuhai> havenwood, I don't have 2^32 jobs but I have millions at least.
<AndreYuhai> By the way
<AndreYuhai> There is also "Failed" count. Is it just a count of retries?
<AndreYuhai> I mean the count of the failed jobs.
<AndreYuhai> Because the dead ones go to "Dead" after some retry counts. So what does "Failed" mean?
<AndreYuhai> like this : https://dpaste.org/oOFY
gix has joined #ruby
<AndreYuhai> havenwood, so failed is just simply the number of jobs failed
Benett has quit [Quit:  ]
Benett has joined #ruby
hays has joined #ruby
ellcs1 has quit [Ping timeout: 260 seconds]
darkstardev13 has joined #ruby
burningserenity has quit [Quit: Leaving.]
Bounga has joined #ruby
Querens has quit [Ping timeout: 246 seconds]
voker57 has quit [Ping timeout: 272 seconds]
AndreYuhai has quit [Quit: Leaving]
Querens has joined #ruby
voker57 has joined #ruby
asfas has quit [Remote host closed the connection]
Mikaela has quit [Remote host closed the connection]
snuz__ has joined #ruby
ur5us has joined #ruby
snuz_ has quit [Ping timeout: 256 seconds]
Bounga has quit [Remote host closed the connection]
schne1der has quit [Ping timeout: 265 seconds]
mossplix has quit [Remote host closed the connection]
d00fuz has quit [Remote host closed the connection]
jetchisel has quit [Ping timeout: 246 seconds]
Garb0_ has joined #ruby
Bounga has joined #ruby
Garb0 has quit [Ping timeout: 240 seconds]
hays has quit [Ping timeout: 260 seconds]
mossplix has joined #ruby
rhe has quit [Ping timeout: 260 seconds]
mossplix has quit [Ping timeout: 240 seconds]
<oddp> Trying to count truthy vals in a 2d array. Why doesn't the to_proc nesting work here? `arr.sum &:count &:itself`
<oddp> Doesn't get slicker than `arr.sum { |row| row.count &:itself }`, does it? (apart from using a 1d array and manual indexing)
Bounga has quit [Ping timeout: 272 seconds]
UncleCid has joined #ruby
funnel has quit [Ping timeout: 258 seconds]
Uncle_Cid has quit [Ping timeout: 256 seconds]
funnel has joined #ruby
ur5us has quit [Ping timeout: 260 seconds]
mheld has joined #ruby
<al2o3-cr> arr.sum([]).count &:itself or just use flatten
<oddp> Alright, thanks!
<al2o3-cr> np
mossplix has joined #ruby
mossplix has quit [Ping timeout: 256 seconds]
ur5us has joined #ruby
_aeris_ has quit [Ping timeout: 240 seconds]
_aeris has joined #ruby
_aeris is now known as _aeris_
hays has joined #ruby
stryek has quit [Quit: Connection closed for inactivity]
hays has quit [Client Quit]
jayx has left #ruby ["Leaving"]
drincruz has quit [Ping timeout: 265 seconds]
snuz__ has quit [Read error: Connection reset by peer]
reffle has quit [Quit: This computer has gone to sleep]
dviola has joined #ruby
orbyt_ has joined #ruby
quazimodo has joined #ruby
mossplix has joined #ruby