mheld has quit [Quit: Connection closed for inactivity]
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ur5us has quit [Ping timeout: 240 seconds]
memcorrupt has joined #ruby
memcorrupt has quit [Changing host]
memcorrupt has joined #ruby
memcorrupt has quit [Client Quit]
Garb0__ has joined #ruby
Lyubo1 has joined #ruby
spuk has joined #ruby
Garb0_ has quit [Ping timeout: 264 seconds]
rafadc has quit [Read error: Connection reset by peer]
rafadc has joined #ruby
spuk has quit [Quit: Human beings were created by water to transport it uphill.]
uplime has joined #ruby
<uplime>
Is there a way in IRB to override/extend the top-level method_missing? I'm messing around with some non-serious things, and would like to perform an action if it ends up not being found
<havenwood>
uplime: class << self
<leftylink>
that reminds me...
<leftylink>
yeah so I pasted http://sprunge.us/4BG5Hq in irb because someone asked whether it's possible to make a shell in ruby
<uplime>
leftylink: haha thats kind of what im working on
<uplime>
(just for personal use though)
<leftylink>
so now you can just type ls it's as if you did ls in your shell
<uplime>
havenwood: awesome, that looks to do it, thanks
<leftylink>
but it couldn't handle stuff like . or /
<leftylink>
so that sux
<havenwood>
uplime: you're welcome
<uplime>
I'm tempted to build the wrapper around pry, but it already has names for some commonly used commands
<havenwood>
uplime: you can remove pry commands if you'd like
<havenwood>
Roelof89: My feedback would be that since @x and @y can't be modified, they only need to be calculated once.
<havenwood>
Roelof89: I mean, the distance and score only need to be calculated once.
<Roelof89>
that is correct
<Roelof89>
so I do not need the initialize ?
<havenwood>
Roelof89: So I'd go the other direction, and store @distance and @score with attr_readers for those.
<havenwood>
Roelof89: This design would make sense if @x and @y could be modified.
<Roelof89>
hmm, now I have to think how to do that. Yesterday someone said I need to make a function for distance and not doing it in the initialize
<sarna>
what's the terminology when it comes to something implementing a module? would I say something "implements Enumerable", "mixes in Enumerable" or something else?
<havenwood>
sarna: Yeah, mixes in.
<sarna>
havenwood: thanks :)
<Roelof89>
havenwood and attrr is not explained in rubymonk as far as I did right now
<havenwood>
Roelof89: What's the requirement here? Is there a certain interface you're aiming for?
Bounga has joined #ruby
<havenwood>
Roelof89: I don't see any inherent reason to have a class. If there's no internal state to track, a simple module is better.
<havenwood>
Roelof89: If you're aiming for something you initialize that has a #score method, just for fun, memoize the @score.
<havenwood>
Roelof89: Say more about why you're doing this, and I'd be happy to recommend what to do.
<Roelof89>
I try to solve a exercism challenge and that one is asking for a class , a initialize and a score function
<Roelof89>
The challenge is about finding out a score on a dartboard depending on what the distance of the dart
cgfbee has quit [Ping timeout: 260 seconds]
<Roelof89>
what in the score and initialize function is up to me , the only thing I noticed is that initialize needs two arguments
<Roelof89>
See the text I also pasted in the gists , that is also all I know
<havenwood>
Roelof89: You'd need to know how you're using it to decide how to design it optimally. If a dart's @x and @y are known at creation and don't change and the score is only checked once, no need to ever even initialize and just use a module function. If they don't change but are checked repeatedly, memoize the value on initialization.
<havenwood>
Roelof89: This design isn't as nice as when you last visited though.
<havenwood>
Roelof89: The glaring issue here is that #distance can get called three times for a single #score.
<havenwood>
Roelof89: I think that's a regression.
<havenwood>
Roelof89: Line 14 calls #distance, does the calculation, then if it's greater than 1, #distance is called again on lie 16, and so on.
<havenwood>
Roelof89: If @x and @y are changing, this is chaos. If they're not changing, even recalculating @score is unnecessary.
<Roelof89>
hmm, you are right
<Roelof89>
maybe make a variable that calculates the distance in the score function and use that for finding out the score
<havenwood>
Roelof89: If the score doesn't change, don't recalculate it at all.
<Roelof89>
moment, is @score for you the score of the darts
<havenwood>
Roelof89: What the #score method currently returns. Just calculate it on initialize and return that instance variable if someone wants the score.
<havenwood>
Roelof89: If the score doesn't change after initialization, never calculate it ever again after initialization.
<sarna>
how do you order methods in a class? is it initialize -> needed for mixed in modules -> others? or something else?
<al2o3-cr>
where the trophy at?
<Roelof89>
al2o3-cr and why do you win then ?
<al2o3-cr>
i got bullseye
<Roelof89>
:)
mr_rich101 has quit [Ping timeout: 260 seconds]
mr_rich101 has joined #ruby
<havenwood>
sarna: The order is only by convention, if that.
<havenwood>
sarna: Typically, initialize is up top.
<sarna>
havenwood: yeah, I'm asking if there is any existing convention :)
<sarna>
I only know about initialize
<havenwood>
sarna: No particular method is needed for mixing in a module, but some may require a method be defined.
<havenwood>
sarna: For example, Comparable presumes #<=> and Enumerable presumes #each.
<sarna>
havenwood: I'm mixing in Enumerable at the moment, I was wondering where I should put #each
kmplsv has left #ruby ["WeeChat 2.8"]
<sarna>
I'm probably overthinking this
chalkmonster has quit [Quit: WeeChat 2.8]
<havenwood>
sarna: Module mixins are typically done up top. Methods after. Otherwise, we just pick what looks pretty.
<havenwood>
sarna: Yeah, it's just aesthetic.
<sarna>
havenwood: yep, I was gonna put #each right after initialize, but then I started thinking :D shouldn't have
<havenwood>
haha
<al2o3-cr>
i must violate 90% of the style guide haha
<havenwood>
al2o3-cr: one method to rule them all
<sarna>
how would you test #each, by the way? make `.each do |foo|` and then check.. well, what?
<al2o3-cr>
havenwood: yup :P
<havenwood>
sarna: what does it yield?
dviola has quit [Quit: WeeChat 2.8]
cgfbee has joined #ruby
<Roelof89>
pfff, next challenge is not nice. It looks I need a regex to split a string on several things and I hate regex :(
<havenwood>
sarna: I'd say test that #each without a block yields an Enumerator, and that it's a working one. Then that #each with a block is as expected. Fair to do the latter with #map or whatever, since Enumerable is presumed working.
<havenwood>
Roelof89: Minigame.
<Roelof89>
??
<havenwood>
Roelof89: Regexp is a mini-game embedded within the language.
<havenwood>
Like pinball in a space oddesy.
<leftylink>
there's https://regexcrossword.com/ but that's for understanding regexes, rather than creating them
<leftylink>
I know executeprogram has a regex course though I'm not familiar with what their pricing is
<Roelof89>
oke, but still I do not like them. I think I need to make a regex so I can abbreviate them
<sarna>
havenwood: sorry, I'm a bit confused. I should check if Foo#each returns an Enumerator, then that the Enumerator returned works (how to check that?), and then that Foo#each with a block works as expected?
<sarna>
and do you mean to check that block case with #map instead?
<havenwood>
sarna: yeah, I'm very tired so take it with a grain of salt but that's what i meant
xco has joined #ruby
<sarna>
havenwood: no worries, thanks for helping me out :)
<Roelof89>
havenwood is it then almost bed time or slept not good ?
<sarna>
I'm new to TDD and all that stuff
<Roelof89>
sarna that makes 2 of us, But I think you are further then me. I still have to learn to make tests
<havenwood>
Roelof89: i'll keep intermittently trying to sleep. one of these times it'll take.
<Roelof89>
testing is not the problem but how to make the right code to output the abbrevations
<al2o3-cr>
Roelof89: _hint_ use word boundries \b
<Roelof89>
oke, then I have to find a site where I can test things
<al2o3-cr>
Roelof89: rubular.com
<al2o3-cr>
or test in irb/pry
bocaneri has quit [Ping timeout: 240 seconds]
bocaneri has joined #ruby
exmortus has joined #ruby
<Roelof89>
im not totally happy ` string.split(/\b/) ` gives me ` ["Portable", " ", "Network", " ", "Graphics"] ` so I get empty entries in my array
<al2o3-cr>
Roelof89: you need more than just \b also use #scan instead of #split.
rippa has joined #ruby
mr_rich101 has quit [Ping timeout: 258 seconds]
jidar has quit [Ping timeout: 258 seconds]
<Roelof89>
oke, after some googling I found this : ` /\b[a-zA-Z]/ ` . Is it correct that i takes the boundries and take the first character if its in the range a-z or A-Z ?
<al2o3-cr>
Roelof89: basically, yup.
jidar has joined #ruby
<Roelof89>
then another challenge solved and learned something
<al2o3-cr>
Roelof89: module Acronym module_function def abbreviate(s) s.scan(/\b\p{L}/).join.upcase end end
<al2o3-cr>
that was my attempt
<Roelof89>
this is my attempt : `string.scan(/\b[a-zA-Z]/).join.upcase `
<al2o3-cr>
in case they include unicode characters.
<Roelof89>
still a lot to learn but that is oke
<Roelof89>
ruby is still very powerfull
<al2o3-cr>
Roelof89: sure, everyday is a learning day! :P
imode has quit [Ping timeout: 240 seconds]
<Roelof89>
yep, and not only for learning developing software :)
<al2o3-cr>
:)
<Roelof89>
also for learning how to deal with if things are not going as you want or learn how to deal with corana :(
<Roelof89>
as a example
<Roelof89>
now wait till mentor feedback
mossplix has quit [Remote host closed the connection]
oddp has joined #ruby
mossplix has joined #ruby
bmo has joined #ruby
cnsvc has quit [Ping timeout: 240 seconds]
mossplix has quit [Remote host closed the connection]
exmortus has quit [Read error: Connection reset by peer]
exmortus has joined #ruby
vondruch has joined #ruby
drincruz has joined #ruby
<roelof5>
thanks
Emmanuel_ChanelW has joined #ruby
drincruz has quit [Ping timeout: 260 seconds]
Technodrome has joined #ruby
dualfade has quit [Ping timeout: 258 seconds]
drincruz has joined #ruby
dualfade has joined #ruby
AndreYuhai has joined #ruby
<AndreYuhai>
I am using httprb and I want a persistent connection. But if I set headers like client.headers(headers).get('/') then the handshake is always done. What am I doing wrong?
burningserenity has joined #ruby
drincruz has quit [Ping timeout: 265 seconds]
Fischmiep has joined #ruby
burningserenity has quit [Remote host closed the connection]
drincruz has joined #ruby
stnly has quit [Quit: goodbye]
stnly has joined #ruby
Emmanuel_ChanelW has quit [Quit: Leaving]
roelof5 has quit [Ping timeout: 245 seconds]
Bounga has quit [Remote host closed the connection]
mr_rich101 has quit [Ping timeout: 264 seconds]
burningserenity has joined #ruby
Lyubo1 has quit [Ping timeout: 246 seconds]
Lyubo1 has joined #ruby
mr_rich101 has joined #ruby
leitz has joined #ruby
factormystic has joined #ruby
Bounga has joined #ruby
marahin has quit [Quit: ZNC 1.6.3+deb1ubuntu0.2 - http://znc.in]
<adam12>
leitz: Interested to see what RubyConf will look like this year. Will they go the same way as RailsConf? Time will tell.
Garb0 has joined #ruby
Garb0 has quit [Max SendQ exceeded]
<adam12>
leitz: The BrightonRuby conf was interesting this year; they're physically mailing Why's book all around the world, as part of the "swag" for the conference.
bsdbandit-01 has quit [Ping timeout: 246 seconds]
BH23 has quit [Remote host closed the connection]
Eiam has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<leitz>
IIUC, development on Perl 5 itself is difficult becuase they are very committed to backwards compatibility. Even to the point of re-introducing bugs. So the theory of Perl 7 is to allow that transition so new development could be easier.
TCZ has quit [Quit: Leaving]
_0x03b5 has joined #ruby
<apotheon>
I see.
nerium has joined #ruby
smccarthy has joined #ruby
nerium has quit [Client Quit]
Bounga has joined #ruby
Bounga has quit [Ping timeout: 272 seconds]
_0x03b5 has quit [Remote host closed the connection]
nerium has joined #ruby
<smccarthy>
Using bundler inline on AWS lambda gives me "Gem::FilePermissionError: You don't have write permissions for the /var/runtime directory". I see ENV[LAMBDA_RUNTIME_DIR] is set to /var/runtime , ENV[RUBYLIB] is /var/task:/var/runtime/lib:/opt/ruby/lib .
<havenwood>
Roelof54: Now move it outside the if statement.
<havenwood>
Roelof54: minutes, seconds = if ...
<havenwood>
DRY
<Roelof54>
updated
<havenwood>
Roelof54: Now just whitespace issues. You could consider more extract method refactors.
<havenwood>
Roelof54: Outside of Rails, folk tend to not leave that newline inside of a Class.
<havenwood>
Roelof54: Extra spaces onn line 8, 13, 16, etc.
<havenwood>
Roelof54: Rubocop might be nice at this point.
<havenwood>
Roelof54: rubocop -a MicroWave.rb
<havenwood>
Roelof54: Use snake_case for filenames.
<havenwood>
Roelof54: microwave.rb
<havenwood>
Roelof54: Match the filename to the class name.
<havenwood>
Roelof54: MicroWave becomes micro_wave.rb or Microwave becomes microwave.rb.
<smccarthy>
I even see "Bundler will use `/tmp/bundler20200624-9-1kz4qm99' as your home directory temporarily." if that matters. I just dont know why its trying to write to /var/runtime
<Roelof54>
the name of the class and function are given
<havenwood>
Roelof54: I'm complaining about your gist filename.
<havenwood>
:
<havenwood>
smccarthy: I can't think of a reason it would.
<smccarthy>
havenwood: I tried looking at the stacktrace and I think its getting /var/runtime as the current directory, but I am doing "Dir.chdir "/tmp" do" and the bundler inline code is in that loop, so not really sure.
<al2o3-cr>
Roelof54: consider using format/sprintf too.
<havenwood>
smccarthy: Do you need to set LAMBDA_TASK_ROOT or somethingn?
<havenwood>
Hrm.
Eiam has quit [Read error: Connection reset by peer]
<smccarthy>
oh maybe ? I can try LAMBDA_TASK_ROOT and LAMBDA_RUNTIME_DIR , to at least see if it affects the error
<smccarthy>
havenwood: I wonder if this is the reason for my failure : `Notice that chdir only works within your Ruby process, it doesn’t affect the “outside world”. It won’t change your shell’s working directory after your Ruby program stops running.` from https://www.rubyguides.com/2020/02/ruby-dir/
<havenwood>
Roelof54: VSCode just works with it, iir.
<al2o3-cr>
Roelof54: rubocop comes with an auto-correct feature.
* al2o3-cr
should use rubocop more often
<Roelof54>
oops. a lot of complains :'(
<Roelof54>
oops, rubocop does not like the %s in the format : ` Style/FormatStringToken: Prefer annotated tokens (like %<foo>s) over unannotated tokens (like %s). format('%02d:%02d', *@seconds.divmod(@seconds < 100 ? 60 : 100)) `
<al2o3-cr>
it moans more than a woman
<Roelof54>
so ignore it , just like this one : ` Style/Documentation: Missing top-level class documentation comment.class Microwave `
bocaneri has quit [Remote host closed the connection]
cnsvc has joined #ruby
<al2o3-cr>
Roelof54: you can.
c59 has joined #ruby
<Roelof54>
oke, then I will commit this one and see what a exercism mentor finds of it
<Roelof54>
Both thanks
dfucci has quit [Ping timeout: 260 seconds]
dfucci has joined #ruby
orbyt_ has joined #ruby
<al2o3-cr>
<> formatting {} no formatting always become unstuck with that one.
imode has joined #ruby
<Roelof54>
for time spend some time with the family and then try to get some sleep in a very warm house, Today in the Netherlands 30 degrees, not normal
c59 has quit [Remote host closed the connection]
<al2o3-cr>
28 degrees here and melting lol
c59 has joined #ruby
<Roelof54>
I know the feeling. Where do you live ?
<al2o3-cr>
UK
<Roelof54>
here till Saturday temperatures of 30 degrees , and then rain and thunder , Always the same story
<al2o3-cr>
Roelof54: pretty much the same.
bsdbandit-01 has quit [Quit: -a- Connection Timed Out]
bsdbandit-01 has joined #ruby
<Roelof54>
I could not resist so I did another exercism challenge : ` ('a'..'z').all? { |character| text.downcase.include? character } `
<Roelof54>
what do you experts think of this line to check if a word is a pangram
leitz has quit [Quit: Leaving]
<jhass>
not too bad, could move the .downcase out of the loop :)
<leftylink>
if one of the teaching points of the pangram is to teach about performance, then surely there will be comments on that. but since I don't know whether that's included in the teaching points of that exercise, I will refrain for now
bsdbandit-01 has quit [Ping timeout: 260 seconds]
<Roelof54>
they do not mentioned what the learning points are but im sure performance is not one of them
<leftylink>
very well then.
<Roelof54>
exercism is as I see it more about learning and practising with things like OOP or arrays or loops so concepts
Roelof54 has quit [Remote host closed the connection]
<skx86>
thats not a loop
roelof3 has joined #ruby
bsdbandit-01 has joined #ruby
<roelof3>
stupid channel, the connection was lost :'(
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
s2013 has joined #ruby
<roelof3>
@jhass so you would do `text_downcase = text.downcase and use text_downcase in the all method ?
<CalimeroTeknik>
for short, a technique that works for some problems, but does not include problems where you can't tell if you're close to a solution and actually have to exactly find it to tell you did
<CalimeroTeknik>
whenever you learn by examples or by experience, you're doing some form of PAC learning
<Roelof59>
but it makes the point. He/she does totally not what is asked. I think fizzbuzz can be written in ruby in some 5 - 10 lines ?
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<CalimeroTeknik>
it depends a bit on the paradigm you use and the clarity attained (not counting comments, which are for saying "why", not "what")
r29v has joined #ruby
<Roelof59>
was just a wild guess but now really time to sleep. Daugther needs to school tomorrow morning at 8 o clock :'(
<CalimeroTeknik>
parent and programmer, both are high-subtlety activities
<Roelof59>
programmer is a hobby , parent is my job
<Roelof59>
GN all
ur5us has joined #ruby
<rapha>
y'all
<rapha>
with Sequel
<rapha>
if .save comes back true on a .new row, but then the database (SQLite) in the end doesn't have the new item, what could be going wrong there?
kinduff has joined #ruby
schne1der has quit [Ping timeout: 240 seconds]
Roelof59 has quit [Remote host closed the connection]
gitter1234 has quit [Quit: Connection closed for inactivity]
<rapha>
(debugging info shows the insert statement, a select statement afterwards, and even the commit statement)
TCZ has joined #ruby
r29v has quit [Ping timeout: 240 seconds]
xco has joined #ruby
<adam12>
rapha: Maybe better asked in #sequel, but can you paste the SQL log somewhere? and maybe any relevant code?
<adam12>
rapha: I can only think of 2 things off the top of my head; different db connection strings (file, in-memory, or both), or a transaction that's rolled back elsewhere. Hard to say without seeing logs and code tho.
jetchisel has joined #ruby
jetchisel has quit [Max SendQ exceeded]
orbyt_ has joined #ruby
wymillerlinux has joined #ruby
gitter1234 has joined #ruby
wymillerlinux has quit [Quit: wymillerlinux]
wymillerlinux has joined #ruby
gitter1234 has quit [Client Quit]
nychtel has joined #ruby
nychtel has quit [Client Quit]
nychtel_ has joined #ruby
reffle has quit [Quit: Leaving]
Tempesta has quit [Quit: See ya!]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
orbyt_ has joined #ruby
tau has joined #ruby
tau has quit [Changing host]
tau has joined #ruby
chris__ has quit [Ping timeout: 256 seconds]
coniptor has quit [Ping timeout: 265 seconds]
coniptor has joined #ruby
TCZ has quit [Quit: Leaving]
Tempesta has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<rapha>
adam12: it magically started working after i put the snippet of code from an .rb file into a Rakefile. don't ask me why or how.
<havenwood>
rapha: How and why?
<havenwood>
:P
stryek has quit [Quit: Connection closed for inactivity]
<al2o3-cr>
havenwood: i know this might sound like a weird question but, the async gem, in the source code they use 2 space indentation but for example readme.me they use tabs? formatting issue or something
<havenwood>
al2o3-cr: Yeah, ioquatix has an unfortunate historical preference for hard tabs. Folk have been coaxing towards spaces and he's been receptive but it's a work in progress. :P