havenwood changed the topic of #ruby to: Rules & more: https://ruby-community.com | Ruby 2.6.4, 2.5.6, 2.7.0-preview1: 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!
<havenwood> Intelo: Consider: survey.zip(payload.each_slice(2)).flatten(1).compact
<havenwood> &>> 1.upto(3).to_h { |n| [n, n] }
<Intelo> result = survey.zip(payload.each_slice(2)).flatten(1).compact
<Intelo> => [{1=>1}, [{"a"=>"a"}, {"b"=>"b"}]]
<havenwood> Intelo: (I was just getting you closer intentionally.)
<havenwood> Intelo: Compare `flatten` with `flatten(1)`.
<havenwood> 1.upto(3).to_h { |n| [n, n] }
<havenwood> #=> {1=>1, 2=>2, 3=>3}
<Intelo> what is 1.upto?
<havenwood> Intelo: In Ruby, you can ask it! :D
<Intelo> :)
<havenwood> 1.method(:upto).owner
<havenwood> #=> Integer
<havenwood> Integer#upto
<Intelo> am.. what are you trying to do?
<Intelo> [{1=>1}, {"a" => "a"}, {"b" => "b"}, {2=>2}, {"c" => "c"}, {"d" => "d"}, {3=>3}] how d I get this?
<havenwood> Intelo: I was just trying to show that: (1..3).to_h { |n| [n, n] } #=> {1=>1, 2=>2, 3=>3}
<Intelo> hm
<havenwood> Intelo: I thought that was your `survey`, but unsure since I haven't seen that example input.
banisterfiend has quit [Quit: Textual IRC Client: www.textualapp.com]
jenrzzz has quit [Ping timeout: 264 seconds]
<Intelo> havenwood, survey is {1=>1}
<Intelo> or it can be {1=>1}, {2=>2} ,{3=>3} or more in []
<Intelo> havenwood, can you paste what you got working so far?
<leftylink> &ri Enumerable#zip
<leftylink> note that as that has so kindly explained
<havenwood> Intelo: I know various solutions. I was hoping to guide you to one.
<leftylink> If the size of any argument is less than enum#size, nil values are supplied. If a block is given, it is invoked for each output array, otherwise an array of arrays is returned.
segy has joined #ruby
<leftylink> er, I am sorry, that is not what I m eant to paste
jenrzzz has joined #ruby
<leftylink> `The length of the resulting sequence will be enum#size. If the size of any argument is less than enum#size, nil values are supplied.`
<Intelo> havenwood, can you paste the shortest working one?
<havenwood> Intelo: Just as an example, here's how I'd ask if I was wanted to get from what I showed you to your desired data: https://gist.github.com/havenwood/c8f560eb7b910fbdcd10ed7a34014069
<havenwood> was wanting*
<havenwood> Intelo: You want my code golf? Haha.
<havenwood> Intelo: I don't think that'll help you!
segy has quit [Max SendQ exceeded]
skryking has quit [Ping timeout: 268 seconds]
<leftylink> so, seeing how `survey` has one element, therefore you see why only one element of `payload.each_slice(2)` is in the output
<havenwood> Intelo: The shortest answers are hilarious but not practical.
GodFather has joined #ruby
<Intelo> havenwood, I learn by code reading
<Intelo> leftylink, hm
skryking has joined #ruby
<havenwood> Intelo: There's a UNIX rule that data is easier to understand than logic. I can show you code, but I need data to know what you want.
<havenwood> Intelo: Ideally, data in the form of failing tests.
<Intelo> want it that way. 1s are survey and abcs are payload [{1=>1}, {"a" => "a"}, {"b" => "b"}, {2=>2}, {"c" => "c"}, {"d" => "d"}, {3=>3}]
lucasb has quit [Quit: Connection closed for inactivity]
grilix has quit [Read error: Connection reset by peer]
jenrzzz has quit [Ping timeout: 245 seconds]
segy has joined #ruby
grilix has joined #ruby
<Intelo> havenwood, leftylink ?
<havenwood> Intelo: Here's an example failing test: https://gist.github.com/havenwood/8e55cb14ce064d9b04a9f7d48a08a18d
<havenwood> Intelo: If you define the function, the test will pass.
<havenwood> Intelo: You can add additional assertions for additional testcases if you want comprehensive ansers.
<havenwood> Intelo: In my experience, writing test cases defines the problem and assists in quick solutions that pass all tests.
<havenwood> Intelo: It also makes it super easy for us to confirm our solutions without a ton of duplicate work.
<Intelo> hm
<leftylink> wasn't there some episode where they had some tearful reunion with jisoo or someshit like that?
<havenwood> Intelo: If you save that file as `intelo.rb` you can run the tests with: ruby intelo.rb
<leftylink> whoops, sorry
<havenwood> Intelo: Note, there's just one failing.
<havenwood> Intelo: Typically, you want at least several assertions, to cover the bases.
<Intelo> hm
segy has quit [Ping timeout: 258 seconds]
<havenwood> Intelo: This also lets you spot regressions when you refactor. :)
<havenwood> Which gives you license to refactor liberally.
<havenwood> And to try various solutions.
<Intelo> hm..
<Intelo> you are a fond of TDD?
<Intelo> havenwood, you do everything with TDD?
cagomez has joined #ruby
<cagomez> what are some examples of needing to define a class due to it being stateful vs not needing to?
<havenwood> Intelo: I vary my approach. I certainly don't always write tests first. I'd say I usually don't write tests first. But that's different than not writing tests. :P
<havenwood> cagomez: A class isn't necessary if there's no state.
<havenwood> cagomez: You can use a module in that case.
<Intelo> hm
<cagomez> havenwood: right, looking for examples though
<Intelo> leftylink, havenwood tell me how to achieve this. I am still very curious.
banisterfiend has joined #ruby
bitwinery has quit [Remote host closed the connection]
<havenwood> cagomez: Look at whether they're methods (where the receiver of the method call matters for the result) or functions (where the receiver is irrelevant and the output depends only on arguments).
<havenwood> Intelo: I'm getting on a plane right now, but if you write failing tests I'd be happy to write a passing solution.
<leftylink> you have already been adivsed by me that Enumerable#zip walks two enumerables in lockstep. if you have any questions about this advisement, you are free to ask those follow-up questions.
bitwinery has joined #ruby
<Intelo> havenwood, I have zero experience with tdd
tsrt^ has joined #ruby
<havenwood> Intelo: I wrote a test. Add an assertion. :)
<Intelo> absolutely no clue untill I get classes on that
<cagomez> havenwood: what's an example of the former case? I almost get it haha
<leftylink> if you instead ignore this advisement and/or you decide that someone else's advisement is superior to mine, I accept your judgment
bitwinery has quit [Remote host closed the connection]
<cagomez> the latter case makes a ton of sense, btw
<havenwood> cagomez: If the same arguments always result in the same return value, then it's a function.
bitwinery has joined #ruby
<havenwood> cagomez: If the thing that you're calling the method on might change, and then that changes the return value, then it's a method.
<havenwood> cagomez: Folk can quibble about function/method exact definition, which vary by community, but that
<havenwood> gotta board >.> brb maybe
<cagomez> the context of my question is a service object. If a class has one method, and operating on an instance variable , which always returns the same thing, could it just as easily be a class with a single class method (requiring no instantiation?)
hutch has quit [Ping timeout: 264 seconds]
<Intelo> havenwood, have a safe flight
<leftylink> I remember that once someone wrote an instance method that did something with an instance variable. then that person realised that the code would work better if it were just a bare function that took its input as a parameter, since it was easier to be able to pass various things as input to the function and it is not always easy or obvious to change the instance variable
<Intelo> leftylink, you there to hint me with code?
<leftylink> perhaps that is in the similar vein as the current discussion
<cagomez> yeah, very similar leftylink
Guest11997 has quit [Ping timeout: 245 seconds]
<cagomez> in my case, rather than change the instance variable, you could just init a whole new instance
<havenwood> Intelo: It got delayed half hour so I'm still here!
<havenwood> cagomez: Are you passing the instance variable to the method?
<Intelo> oh ok. so result = survey.zip(payload.each_slice(2)).flatten(1).compact
<Intelo> => [{1=>1}, [{"a"=>"a"}, {"b"=>"b"}]]
<cagomez> no, the method takes no params. it just operates on the ivar
<havenwood> cagomez: Where does the ivar come from?
<havenwood> cagomez: Could you pass it to the method rather than instantiating with it?
<havenwood> Intelo: I'm still not sure on your various scenarios. We really need at least examples with expected output for each.
<havenwood> Intelo: You may be overestimating how much we understand about what you want.
<Intelo> ok. one sec
<havenwood> Maybe someone else gets it? I'm tired and may be daft.
<leftylink> sorry I was a little vague with the exact circumstance where the instance method was replaced with a plain function, I have to figure out exactly how much I can share about it. since I realise you asked for concrete examples I know I am not being very helpful :)
<cagomez> havenwood: something like this: https://gist.github.com/cagmz/faa1e48d585c4ac7f39f2cc8bc5f5718 . would there be a performance impact between the two?
<havenwood> leftylink: It totally depends on where the ivar came from! If you're instantiating with that ivar as an argument for that sole purpose, better to simply use a module and pass the argument to the method directly. That saves overhead and is simpler.
<havenwood> That's a good case for a module function.
hutch has joined #ruby
leitz has quit [Quit: Leaving]
<havenwood> If you that function is called repeatedly and the argument doesn't change, that's a good case for a singleton class.
<havenwood> call that*
<cagomez> havenwood: https://gist.github.com/cagmz/faa1e48d585c4ac7f39f2cc8bc5f5718#file-call-rb-L1-L7 is an alternative to a module + module_function , right? A class with a static method
<havenwood> Intelo: That's way better! I'd suggest moving it towards tests but that's soooo much better than logic. Folk here can solve for that. :)
<cagomez> err, actually, module + module_function can be `included` in classes. with classes, you'd need to use the static methods
<havenwood> cagomez: Yes, it's a very similar alternative and sometimes a better one when you don't want to use it as a mixin ever or need private module functions.
<havenwood> cagomez: The key is, either way you have no internal state.
<havenwood> cagomez: There's a single instance.
<havenwood> cagomez: Actually, that's wrong, no instance whatsover.
<havenwood> cagomez: A singleton class is a single instance, when you have a single instance of state.
<havenwood> cagomez: You can have constants with a module.
<havenwood> cagomez: State is something that isn't, then you create it an it's a thing.
<Intelo> havenwood, tell me function before boarding
<havenwood> Intelo: hrm?
<Intelo> tdd is not my thing for now
<Intelo> how to get wanted
john2496 has joined #ruby
mikecmpbll has quit [Quit: inabit. zz.]
ravenousmoose has joined #ruby
segy has joined #ruby
AJA4350 has quit [Quit: AJA4350]
<leftylink> oh, hmm, I was about to react badly because that sounded selfish, but I may have misinterpreted, my apologies
<leftylink> like, the selfish way of interpreting that would have been "hey let's completely ignore the fact that you have other shit to do in your life, let's make it all about me me me me me I want you to give me the code now"
<leftylink> I shouldn't misinterpret like that though
GodFather has quit [Ping timeout: 268 seconds]
<Intelo> leftylink, sorry if you felt that way. i was just curious
<leftylink> it is unfortunate, indeed. since English is not my first language, sometimes I misinterpret things like that, sorry
GodFather has joined #ruby
<Intelo> whats the solution here?
ravenousmoose has quit [Ping timeout: 264 seconds]
<leftylink> I'm not sure there's a solution other than "leftylink should get better at English and remember to assume good faith"
<Intelo> good solution!
<leftylink> great
<havenwood> Intelo: Hint: flatten
<havenwood> Intelo: I got you two methods from the solution.
<havenwood> .this.that
<havenwood> Intelo: The first method is #flatten, and takes one argument.
baojg has quit [Remote host closed the connection]
<havenwood> Intelo: The second method makes it a Hash.
<havenwood> If anyone wants to reveal, please do!
<havenwood> But my lips are sealed.
<havenwood> Intelo: Read up on #flatten and try some args! :)
<Intelo> already tried (1,2
<Intelo> and 3
<havenwood> colder
<havenwood> Intelo: What does the argument do?
<Intelo> flaterns with interval of 2/3/4 whatever args
<havenwood> Intelo: What's the default value for the argument?
<Intelo> it assumes (1(
Exuma has joined #ruby
<havenwood> Intelo: Which seems to flatten one too much here.
<leftylink> hold on.
<leftylink> 00:52:30 < Intelo> flaterns with interval of 2/3/4 whatever args
<leftylink> that is not what flatten does
<havenwood> leftylink: good point
<havenwood> intervals aren't involved
<havenwood> more like levels
<Intelo> [1,[[3,4,6],3,7],5,1,[1,2,3],5].flatten
<Intelo> # => [1, 3, 4, 6, 3, 7, 5, 1, 1, 2, 3, 5]
<havenwood> Intelo: What would flatten less, but still just a bit?
<havenwood> Intelo: Keep in mind, the default argument is: 1
<havenwood> Intelo: It's 1 level too deep.
gell5 has joined #ruby
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<leftylink> hmm, I would rather think of the default argument as infinity
<leftylink> but shrug
<havenwood> leftylink: It's not, though!
oetjenj has joined #ruby
<havenwood> leftylink: Oh, I kinda get what you're saying. But what's Infinity minus 1? :P
<leftylink> I must have misunderstood again. I'll just say that the reason I said "oh, I didn't think the default argument is 1" is because there are counterexamples to the statement `forall a, a.flatten == a.flatten(1)`
<havenwood> Intelo: What would flatten 1 level less than 1?
<leftylink> if I misunderstood what you were saying, I apologise again for that
<havenwood> leftylink: I'm probably the one misunderstanding. :)
<havenwood> leftylink: Long week!
<Intelo> havenwood, no flatten at all.
<leftylink> the counterexample I had in mind was [[[1]]]. try [[[1]]].flatten(1) vs [[[1]]].flatten
<Intelo> havenwood, or a string
<havenwood> leftylink: -1 is default, yeah?
<havenwood> leftylink: I get confused on flatten and flat_map and often have to reference docs.
<havenwood> Actually, flat_map I don't forget, just flatten.
segy has quit [Ping timeout: 258 seconds]
<havenwood> Intelo: Try a lower number...
<havenwood> Intelo: It's worth experimenting a bit with #flatten so you know when to re-reference the docs.
<cagomez> Intelo: what's the pattern for https://pastebin.ubuntu.com/p/y9bMd9tGjD/ ? having trouble figuring it out
<Intelo> survey.zip(payload.each_slice(2)).flatten(0).compact
<Intelo> => [[{1=>1}, [{"a"=>"a"}, {"b"=>"b"}]]]
<Intelo> cagomez, yes
<havenwood> cagomez: A module_function can be included into a class. It will be private within the class, so it can be called freely within the class but doesn't expose a public instance method.
<Intelo> cagomez, interval of two pockets is pattern
<havenwood> cagomez: That's exactly why you use a module_function rather than a class method, since it'll be private.
<havenwood> (When included.)
<leftylink> hmm. IMO I would like it more if a negative level would raise an exception, but perhaps there may be good reasons why these things are happening
<leftylink> okay, looking at the source code I think it is kind of... for practicality
hutch has quit [Ping timeout: 264 seconds]
<leftylink> I do not want to know what happens if someone makes -1 wrap around to 0 though
<leftylink> you'd have to have an array nested 2**32 deep for that though, so hopefully it's fine and doesn't happen :)
<leftylink> or 2**64? who knows
queip has quit [Ping timeout: 244 seconds]
<leftylink> can I even do that
GodFather has quit [Ping timeout: 245 seconds]
<leftylink> brb, running `a = [1]; (2**32 + 5).times { a = [a] }`
<leftylink> is this going to break my computer?
poontangmessiah_ has quit [Remote host closed the connection]
<leftylink> okay well doing it with 2**25 takes 9 seconds
<leftylink> so maybe I can expect 2**32 to finish in 1152 seconds :(
bruce_lee has quit [Ping timeout: 244 seconds]
<leftylink> I guess I will... not do that then. :(
<leftylink> :(
bruce_lee has joined #ruby
bruce_lee has quit [Changing host]
bruce_lee has joined #ruby
DaRock has joined #ruby
gell5 has quit [Remote host closed the connection]
queip has joined #ruby
Exuma has quit [Quit: Textual IRC Client: www.textualapp.com]
<leftylink> not to say that someone is copying homework or anything, just saying that I try to make it so that people can learn something. if they learn nothing then I have not helped the world
alan_w has quit [Ping timeout: 246 seconds]
gell5 has joined #ruby
ule has quit [Quit: #RubyOnRails]
ule has joined #ruby
ule has quit [Changing host]
ule has joined #ruby
<Intelo> o.O
john2496_ has joined #ruby
thebananaking has quit [Quit: Connection closed for inactivity]
segy has joined #ruby
nahra` has quit [Quit: ERC (IRC client for Emacs 26.2)]
john2496 has quit [Ping timeout: 258 seconds]
<Intelo> 2.5.5 :046 > survey.zip(payload.each_slice(2)).flatten(0).compact
<Intelo> 2.5.5 :047 > survey.zip(payload.each_slice(2)).flatten(-5).compact
<Intelo> => [[{1=>1}, [{"a"=>"a"}, {"b"=>"b"}]]]
<Intelo> => [{1=>1}, {"a"=>"a"}, {"b"=>"b"}]
<Intelo> 2.5.5 :050 > survey.zip(payload.each_slice(2)).flatten.compact
<Intelo> => [{1=>1}, {"a"=>"a"}, {"b"=>"b"}]
emptyflask has quit [Ping timeout: 245 seconds]
nahra has joined #ruby
emptyflask has joined #ruby
bambanx has joined #ruby
segy has quit [Ping timeout: 245 seconds]
Swyper has quit [Remote host closed the connection]
cliluw has quit [Read error: Connection reset by peer]
cliluw has joined #ruby
gell5_ has joined #ruby
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
gell5 has quit [Ping timeout: 245 seconds]
athens98 has joined #ruby
cagomez has quit [Remote host closed the connection]
athens98 has quit [Remote host closed the connection]
<leftylink> may I give a reminder that given there is a pipeline of functions, it is useful to examine the results at each step. if `flatten` is not receiving inputs that would allow it to produce the desired output, then changing `flatten` and anything beyond it makes no progress.
cyclonis has quit [Ping timeout: 250 seconds]
alan_w has joined #ruby
psilly0 has joined #ruby
banisterfiend has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
psilly0 has quit [Client Quit]
psilly0 has joined #ruby
alan_w has quit [Ping timeout: 245 seconds]
<leftylink> irb
<leftylink> wrong window
segy has joined #ruby
<leftylink> what was that donald knuth quote
segy has quit [Ping timeout: 268 seconds]
duderonomy has joined #ruby
<leftylink> ah here we go
<leftylink> https://www.maa.org/sites/default/files/pdf/upload_library/22/Ford/DonaldKnuth.pdf "Computer Science and its Relation to Mathematics"
<leftylink> It has often been said that a person does not really understand something until he teaches it to someone else. Actually a person does not _really_ understand something until he can teach it to a _computer_.
duderonomy has quit [Client Quit]
ElFerna has joined #ruby
ElFerna has quit [Quit: ElFerna]
ElFerna has joined #ruby
Fr4n has quit [Remote host closed the connection]
_whitelogger has joined #ruby
tdy has quit [Ping timeout: 245 seconds]
schneider has quit [Ping timeout: 246 seconds]
ElFerna has quit [Quit: ElFerna]
alan_w has joined #ruby
ElFerna has joined #ruby
alan_w has quit [Ping timeout: 244 seconds]
cagomez has joined #ruby
ElFerna has quit [Quit: ElFerna]
cagomez has quit []
cd has quit [Quit: cd]
segy has joined #ruby
_whitelogger has joined #ruby
segy has quit [Ping timeout: 268 seconds]
jacobnollette_ is now known as greypack
tdy has joined #ruby
greypack has quit [Quit: All your IRC are belong to ZNC]
greypack has joined #ruby
hutch has joined #ruby
chakan has joined #ruby
alan_w has joined #ruby
Fusl has quit [Excess Flood]
Fusl has joined #ruby
<chakan> Hi
alan_w has quit [Ping timeout: 244 seconds]
greypack has quit [Quit: All your IRC are belong to ZNC]
_whitelogger has joined #ruby
jacobnollette_ has joined #ruby
jacobnollette_ is now known as greypack
al2o3-cr has quit [Read error: Connection reset by peer]
grilix has quit [Ping timeout: 244 seconds]
hutch has quit [Ping timeout: 276 seconds]
x0f_ has quit [Ping timeout: 252 seconds]
x0f has joined #ruby
oetjenj has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jaequery has joined #ruby
Nicmavr has quit [Read error: Connection reset by peer]
Nicmavr has joined #ruby
tdy has quit [Ping timeout: 245 seconds]
segy has joined #ruby
hightower3 has quit [Ping timeout: 245 seconds]
thebananaking has joined #ruby
_whitelogger has joined #ruby
duderonomy has joined #ruby
segy has quit [Ping timeout: 245 seconds]
psilly0 has quit [Quit: psilly0]
Swyper has joined #ruby
Swyper has quit [Ping timeout: 246 seconds]
alan_w has joined #ruby
al2o3-cr has joined #ruby
segy has joined #ruby
alan_w has quit [Ping timeout: 245 seconds]
john2496_ has quit [Remote host closed the connection]
jaequery has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jaequery has joined #ruby
jaequery has quit [Client Quit]
jaequery has joined #ruby
jaequery has quit [Client Quit]
jaequery has joined #ruby
jaequery has quit [Client Quit]
jaequery has joined #ruby
jaequery has quit [Client Quit]
john2496 has joined #ruby
jaequery has joined #ruby
jaequery has quit [Client Quit]
bambanx has quit [Read error: Connection reset by peer]
bitwinery has quit [Quit: Leaving]
bitwinery has joined #ruby
Swyper has joined #ruby
Swyper has quit [Remote host closed the connection]
dasher00 has quit [Ping timeout: 258 seconds]
alan_w has joined #ruby
emptyflask has quit [Ping timeout: 244 seconds]
alan_w has quit [Ping timeout: 244 seconds]
bitwinery has quit [Quit: Leaving]
john2496 has quit [Ping timeout: 245 seconds]
dionysus69 has joined #ruby
sameerynho has joined #ruby
jaequery has joined #ruby
dionysus69 has quit [Remote host closed the connection]
dionysus69 has joined #ruby
Jonopoly has joined #ruby
tsujp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
tsujp has joined #ruby
tsujp has quit [Client Quit]
tsujp has joined #ruby
thebananaking has quit [Quit: Connection closed for inactivity]
<havenwood> chakan: hi
jaequery has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jenrzzz has joined #ruby
al2o3-cr has quit [Ping timeout: 246 seconds]
jenrzzz has quit [Ping timeout: 258 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 268 seconds]
yasumi2136 has joined #ruby
dr_mdma_md has joined #ruby
oetjenj has joined #ruby
jenrzzz has joined #ruby
<dr_mdma_md> Anyone here offer freelance development/freelance tutoring? I have this app I need fixed. Thanks.
jenrzzz has quit [Ping timeout: 245 seconds]
mikecmpbll has joined #ruby
queip has quit [Ping timeout: 258 seconds]
Jonopoly has quit [Quit: WeeChat 2.5]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 258 seconds]
queip has joined #ruby
<Intelo> leftylink, cant solv it
Fernando-Basso has joined #ruby
jenrzzz has joined #ruby
dionysus69 has quit [Ping timeout: 268 seconds]
jenrzzz has quit [Ping timeout: 246 seconds]
jenrzzz has joined #ruby
yasumi2136 has quit [Remote host closed the connection]
jenrzzz has quit [Ping timeout: 246 seconds]
banisterfiend has joined #ruby
banisterfiend has quit [Client Quit]
jenrzzz has joined #ruby
nowhere_man has joined #ruby
dretnx has joined #ruby
jenrzzz has quit [Ping timeout: 244 seconds]
jenrzzz has joined #ruby
jenrzzz_ has joined #ruby
jenrzzz has quit [Ping timeout: 244 seconds]
oetjenj has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
oetjenj has joined #ruby
oetjenj has quit [Client Quit]
oetjenj has joined #ruby
oetjenj has quit [Client Quit]
jenrzzz_ has quit [Ping timeout: 268 seconds]
jenrzzz has joined #ruby
oetjenj has joined #ruby
oetjenj has quit [Client Quit]
oetjenj has joined #ruby
tsujp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
oetjenj has quit [Client Quit]
oetjenj has joined #ruby
oetjenj has quit [Client Quit]
oetjenj has joined #ruby
oetjenj has quit [Client Quit]
oetjenj has joined #ruby
oetjenj has quit [Client Quit]
oetjenj has joined #ruby
oetjenj has quit [Client Quit]
oetjenj has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
oetjenj has quit [Client Quit]
oetjenj has joined #ruby
oetjenj has quit [Client Quit]
oetjenj has joined #ruby
oetjenj has quit [Client Quit]
oetjenj has joined #ruby
oetjenj has quit [Client Quit]
oetjenj has joined #ruby
oetjenj has quit [Client Quit]
oetjenj has joined #ruby
oetjenj has quit [Client Quit]
tsujp has joined #ruby
dasher00 has joined #ruby
dr_mdma_md has quit []
Ven`` has joined #ruby
lightstalker has quit [Ping timeout: 268 seconds]
lightstalker has joined #ruby
mn3m has joined #ruby
hoijui has joined #ruby
<hoijui> does anyone here have experience with gollum (the git backed wiki written in ruby)?
<hoijui> it is used by github for their per-project wiki's aswell
<hoijui> I am interested to know whether it is compatible wiht gitlab and gitea aswell
al2o3-cr has joined #ruby
<al2o3-cr> &>> ((1..10) % 0).to_a
<rubydoc> stderr: playpen: application terminated abnormally with signal 31 (Bad system call) (https://carc.in/#/r/7iqi)
<al2o3-cr> shouldn't this raise ZeroDivisionError
<al2o3-cr> &>> ((1..10) % 0).take(5)
<rubydoc> # => [1, 1, 1, 1, 1] (https://carc.in/#/r/7iqj)
<al2o3-cr> &>> SystemCallError.new(31)
<rubydoc> # => #<Errno::EMLINK: Too many links> (https://carc.in/#/r/7iqk)
suukim has joined #ruby
<al2o3-cr> ah, it's just does a shit load of mremap sys calls.
alan_w has joined #ruby
<al2o3-cr> wow, that consumes memory fast
<leftylink> well, I guess since it's not doing division, no need for division by zero, but I was also not prepared for what would happen there
mikecmpbll has quit [Quit: inabit. zz.]
hoijui has quit [Quit: Leaving]
schneider has joined #ruby
<al2o3-cr> oh right yeah, i should of check that first.
<al2o3-cr> i just took it as it did modulo.
alan_w has quit [Ping timeout: 268 seconds]
hightower3 has joined #ruby
InfinityFye has joined #ruby
bruce_lee has quit [Read error: Connection reset by peer]
dbugger has joined #ruby
dbugger has quit [Remote host closed the connection]
xfbs has quit [Ping timeout: 264 seconds]
luminousnine has quit [Ping timeout: 264 seconds]
jenrzzz has quit [Ping timeout: 244 seconds]
reyfi9e has quit [Ping timeout: 276 seconds]
luminousnine has joined #ruby
luminousnine has quit [Changing host]
luminousnine has joined #ruby
AJA4350 has joined #ruby
hightower3 has quit [Changing host]
hightower3 has joined #ruby
xfbs has joined #ruby
Fernando-Basso has quit [Remote host closed the connection]
<chakan> What's the best framework available for ruby (besides rails)
DTZUZO has quit [Ping timeout: 245 seconds]
DTZUZO has joined #ruby
DTZUZO has quit [Ping timeout: 244 seconds]
<leftylink> (fake answer) I am the best bambaratatata dadadadada
Inline has joined #ruby
<otaznik[m]> chakan: best for what?
ravenousmoose has joined #ruby
<otaznik[m]> leftylink: (thread on fake answer) nope, you are the humBlEST
reyfi9e has joined #ruby
al2o3-cr has left #ruby ["WeeChat 2.5"]
ElFerna has joined #ruby
ElFerna has quit [Remote host closed the connection]
banisterfiend has joined #ruby
poontangmessiah has joined #ruby
ElFerna has joined #ruby
ElFerna has quit [Client Quit]
reyfi9e has quit [Quit: Konversation term]
jenrzzz has joined #ruby
reyfi9e has joined #ruby
jenrzzz has quit [Ping timeout: 245 seconds]
hutch has joined #ruby
Intelo_ has joined #ruby
Intelo has quit [Ping timeout: 246 seconds]
planigan has quit [Ping timeout: 245 seconds]
planigan has joined #ruby
dionysus69 has joined #ruby
nowhere_man has quit [Ping timeout: 244 seconds]
MrCrackPot has quit [Remote host closed the connection]
MrCrackPot has joined #ruby
lucasb has joined #ruby
MrCrackPot has quit [Max SendQ exceeded]
MrCrackPot has joined #ruby
banisterfiend has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
MrCrackPot has quit [Max SendQ exceeded]
MrCrackPot has joined #ruby
MrCrackPot has quit [Max SendQ exceeded]
MrCrackPot has joined #ruby
banisterfiend has joined #ruby
MrCrackPot has quit [Max SendQ exceeded]
hutch has quit [Ping timeout: 264 seconds]
MrCrackPot has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.5]
MrCrackPot has quit [Max SendQ exceeded]
ravenousmoose has quit [Remote host closed the connection]
ravenousmoose has joined #ruby
banisterfiend has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
banisterfiend has joined #ruby
ElFerna has joined #ruby
Swyper has joined #ruby
john2496 has joined #ruby
ElFerna has quit [Quit: ElFerna]
john2496 has quit [Ping timeout: 245 seconds]
alan_w has joined #ruby
DTZUZO has joined #ruby
schneider has quit [Ping timeout: 245 seconds]
ravenousmoose has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
alan_w has quit [Ping timeout: 244 seconds]
Fernando-Basso has joined #ruby
Fernando-Basso has quit [Max SendQ exceeded]
Fernando-Basso has joined #ruby
<havenwood> chakan: Rails is one Rack framework but there are many. Roda is my favorite. Hanami and Sinatra are also very nice and there are a variety of other options.
troulouliou_div2 has joined #ruby
mn3m has quit [Ping timeout: 245 seconds]
SCHAPiE has quit [Remote host closed the connection]
Swyper has quit [Remote host closed the connection]
SCHAPiE has joined #ruby
Esa_ has joined #ruby
IndoRuby has joined #ruby
dellavg has quit [Ping timeout: 246 seconds]
DaRock has quit [Ping timeout: 268 seconds]
dellavg has joined #ruby
MrCrackPot has joined #ruby
<IndoRuby> Can I say hello here?
IndoRuby has quit [Quit: Leaving]
banisterfiend has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Intelo_ has quit [Remote host closed the connection]
Intelo has joined #ruby
involans has quit [Quit: involans]
troulouliou_div2 has quit [Remote host closed the connection]
grilix has joined #ruby
<havenwood> Intelo: Welcome!
<havenwood> Haha, autotab fail. But hi Intelo too!
<Intelo> :)
<Intelo> havenwood, how was your flight? where were to moving to?
Swyper has joined #ruby
<havenwood> Intelo: Just a tiny trip back from SF to LA.
Ven`` has quit [Quit: Textual IRC Client: www.textualapp.com]
<havenwood> Intelo: Try doing a `survey.zip(payload.each_slice(2)).flatten.compact` and consider what it takes to get from that to what you want.
Yojimble has joined #ruby
<Intelo> havenwood, if survey = [{1 => 1}, {2 => 2}] then survey.zip(payload.each_slice(2)).flatten.compact
<Intelo> => [{1=>1}, {"a"=>"a"}, {"b"=>"b"}, {2=>2}, {"c"=>"c"}, {"d"=>"d"}]
<Intelo> but
<Intelo> if survey = [{1 => 1}]
<Intelo> survey.zip(payload.each_slice(2)).flatten.compact
<Intelo> => [{1=>1}, {"a"=>"a"}, {"b"=>"b"}]
cd has joined #ruby
linduxed has joined #ruby
<havenwood> Intelo: I only accounted for the test cases where you showed corresponding input and desired output.
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
<havenwood> Intelo: You'll get *MUCH* faster answers if you just show runnable examples and then what you want the return value to be for each.
Technodrome has joined #ruby
<havenwood> Intelo: I know you don't want to write tests, but you'd sure get your answer faster and be able to communicate what's not working better if you bothered.
<Intelo> ok one sec havenwood
<havenwood> Intelo: you can clone that gist, and run: ruby intelo.rb
<havenwood> Intelo: If you change it to be your data and multiple assertions, you have a test.
<havenwood> Intelo: You don't even need to use a testing framework, but what I'm saying is make it runnable with examples.
<havenwood> Intelo: You're just showing two examples. I don't see where it's failing. It's really hard to tell what you're wanting. You're showing literally TWO test cases and both pass for the code. I think you want more than two cases.
<Intelo> my issue: last 2 hashes are trimmed
<Intelo> if survey only has one has
<Intelo> h
<Intelo> last 2 hashes of payload
<havenwood> Intelo: Sec, I'll show you what I mean.
dionysus69 has quit [Ping timeout: 244 seconds]
<Intelo> havenwood, see line line 7-11 http://rubyfiddle.com/riddles/c085c/2
parity has joined #ruby
TvL2386 has quit [Ping timeout: 245 seconds]
<havenwood> Intelo: I commented with the output of running the file.
<Intelo> I appreciate you taste but I can't get it nor I work that way
<havenwood> We seem to be at an impasse. Haha.
Nicmavr has quit [Read error: Connection reset by peer]
Nicmavr has joined #ruby
<Intelo> havenwood, is there anyway you can sent me the code so I can test/learn? :)
<havenwood> Intelo: There's ^ some code to ponder!
<havenwood> Intelo: Can you make that test pass?
<Intelo> no tests please. I am zero
<Intelo> I never did tests.
<Intelo> don't know anything about these
<Intelo> havenwood, can we discuss on payload.each_slice(2)
<Intelo> newresult = survey.map { |i| [i, begin; result.next; rescue; end].compact}.flatten
<havenwood> Intelo: This is Minitest, it ships with Ruby: https://gist.github.com/havenwood/fea05da5c6b9be112d47d6c896dd8ad6#file-intelo-rb-L1
<havenwood> Intelo: Okay, I'll discuss your code.
<havenwood> Intelo: What about it?
<Intelo> havenwood, see line line 7-11 http://rubyfiddle.com/riddles/c085c/2
<havenwood> Intelo: Yes.
<Intelo> I want that result
<Intelo> I have that code
<Intelo> that code is not giving that result
<Intelo> so I guess I need to change code or result
<Intelo> but I choose to change code
<Intelo> and not result needed
<Intelo> so my question is
<Intelo> what part of code to change?
<Intelo> I believe it has 1 liner answer
<havenwood> Intelo: I don't want to just write your code. I'll solve a similar problem to help you with the principles but I don't want to just write your software if you won't write tests.
TvL2386 has joined #ruby
<Intelo> I know. you are teaching me to fish and not give fish
<Intelo> but I learn seeing you catch fish
<havenwood> Intelo: For example, I'd be happy to help you get the tests I wrote above passing. That should be a solution to your problem.
<havenwood> I'll do a similar problem, like the one I wrote tests for. You may find it's the same problem.
<Intelo> havenwood, I am not at that level yet...
<havenwood> Intelo: Someone else may be willing to just give you a one-liner if you want to hold out for that. :)
<Intelo> I have my own learning way. I want to adapt but.. can't righ tnow
<Intelo> I understand and agree with you but I have my ..
<havenwood> I have my own way of teaching. Someone else might be more your style!
<Intelo> I respect your style
chalkmonster has joined #ruby
chalkmonster has quit [Client Quit]
SeepingN has quit [Quit: The system is going down for reboot NOW!]
<havenwood> Intelo: This code is meant to be similar to your problem and also similar to your partial solution. Instead of using an Enumerator and rescuing I switched it to an index-based system since I think you'll have more luck with that. https://gist.github.com/havenwood/fea05da5c6b9be112d47d6c896dd8ad6
<havenwood> Intelo: Can you tell how that's ^ the same problem domain as what you're working on?
<Intelo> hm
<Intelo> let me be back
<havenwood> Intelo: Note, you can try other solutions and just run that file to test if it works for all cases with: ruby intelo.rb
<Intelo> I wonder why survey.zip(payload.each_slice(2)).flatten.compact dont work
<havenwood> &>> [].zip([1, 2, 3])
<rubydoc> # => [] (https://carc.in/#/r/7isy)
<havenwood> Intelo: ^
<havenwood> Intelo: It just doesn't have the behavior you want. It does a similar thing, but you added a test case it doesn't pass for so that approach won't work.
<Intelo> havenwood, we spent many hours on it.
<havenwood> Intelo: Huh?
ravenousmoose has joined #ruby
<Intelo> on the strategy but not exact .methods that can do it
<havenwood> Intelo: I'm not writing your one-liner. I can, just wont! :P
<havenwood> Intelo: This is as far as I go.
<havenwood> ¯\_(ツ)_/¯
<Intelo> I know.
<Intelo> :))
<havenwood> Happy to work through solutions or help understand any part you don't quite grok.
<havenwood> Intelo: Did the gist above give you any ideas for a solution? Any parts of it you don't get?
<Intelo> will be back
ravenousmoose has quit [Ping timeout: 252 seconds]
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
jaequery has joined #ruby
wildtrees has joined #ruby
edwardly has quit [Quit: ??????????]
Fusl has quit [Excess Flood]
galeido has quit [Changing host]
galeido has joined #ruby
Fusl has joined #ruby
ravenousmoose has joined #ruby
edwardly has joined #ruby
edwardly has joined #ruby
edwardly has quit [Changing host]
ravenousmoose has quit [Ping timeout: 250 seconds]
mr_rich101 has quit [Quit: ZNC - http://znc.in]
<leftylink> for some reason I didn't know that minitest had `describe` as well. I looked at its changelog and it is not new, so this reveals I must have never read the docs
mr_rich101 has joined #ruby
<leftylink> has existed for about a decade or something
DTZUZO has quit [Quit: WeeChat 2.0]
AJA4350 has quit [Ping timeout: 244 seconds]
dbugger has joined #ruby
poontangmessiah has quit [Remote host closed the connection]
xfbs has quit [Ping timeout: 252 seconds]
luminousnine has quit [Ping timeout: 250 seconds]
jacobnollette_ has joined #ruby
greypack has quit [Read error: Connection reset by peer]
alan_w has joined #ruby
tdy has joined #ruby
<chakan> Basically when you are looking for project to Support, they ask you to know ruby on rails
<chakan> Most of them
jacobnollette_ has quit [Quit: All your IRC are belong to ZNC]
<chakan> Seems like mandatory to learn it
greypack has joined #ruby
greypack has quit [Client Quit]
greypack has joined #ruby
schaerli has joined #ruby
alan_w has quit [Ping timeout: 246 seconds]
Fernando-Basso has quit [Remote host closed the connection]
dretnx has quit [Quit: Going offline, see ya! (www.adiirc.com)]
greypack has quit [Quit: All your IRC are belong to ZNC]
jaequery has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
greypack has joined #ruby
ElFerna has joined #ruby
dinfuehr has quit [Ping timeout: 258 seconds]
dinfuehr has joined #ruby
ElFerna has quit [Ping timeout: 244 seconds]
michael_mbp has quit [Ping timeout: 246 seconds]
michael_mbp has joined #ruby
dinfuehr has quit [Ping timeout: 244 seconds]
dinfuehr has joined #ruby
alan_w has joined #ruby
queip has quit [Ping timeout: 245 seconds]
schaerli has quit [Ping timeout: 264 seconds]
alan_w has quit [Ping timeout: 244 seconds]
hiroaki has joined #ruby
dinfuehr has quit [Ping timeout: 246 seconds]
dinfuehr has joined #ruby
suukim has quit [Quit: Konversation terminated!]
dinfuehr has quit [Ping timeout: 240 seconds]
queip has joined #ruby
Freshnuts has joined #ruby
Freshnuts has quit [Max SendQ exceeded]
dinfuehr has joined #ruby
tdy1 has joined #ruby
tdy1 has quit [*.net *.split]
queip has quit [*.net *.split]
dinfuehr has quit [*.net *.split]
spacesuitdiver has joined #ruby
dinfuehr has joined #ruby
tdy1 has joined #ruby
tdy has quit [Ping timeout: 245 seconds]
queip has joined #ruby
spacesuitdiver has quit [*.net *.split]
dinfuehr has quit [*.net *.split]
dinfuehr has joined #ruby
spacesuitdiver has joined #ruby
dinfuehr has quit [*.net *.split]
queip has quit [*.net *.split]
johnny56 has quit [*.net *.split]
dinfuehr has joined #ruby
queip has joined #ruby
johnny56 has joined #ruby
hiroaki has quit [Ping timeout: 276 seconds]
jinie_ has joined #ruby
jinie has quit [Ping timeout: 246 seconds]
jinie_ is now known as jinie
dviola has joined #ruby
DTZUZO has joined #ruby
cagomez has joined #ruby
KramerC has quit [Quit: Leaving]
KramerC has joined #ruby
spacesuitdiver has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
AJA4350 has joined #ruby
Fernando-Basso has joined #ruby
Fernando-Basso has quit [Max SendQ exceeded]
Fusl has quit [Excess Flood]
cagomez has quit [Remote host closed the connection]
Fusl has joined #ruby
Freshnuts has joined #ruby
Freshnuts has quit [Max SendQ exceeded]
cagomez has joined #ruby
bitwinery has joined #ruby
bitwinery has quit [Max SendQ exceeded]
bitwinery has joined #ruby
bitwinery has quit [Max SendQ exceeded]
bitwinery has joined #ruby
luminousnine has joined #ruby
luminousnine has quit [Changing host]
luminousnine has joined #ruby
xfbs has joined #ruby
reber has joined #ruby
Tempesta has quit [Quit: AdiIRC is updating to v3.6 Beta Build (2019/09/06 UTC) 64 Bit]
dviola has quit [Quit: WeeChat 2.5]
jinie has quit [Ping timeout: 240 seconds]
jinie has joined #ruby
Tempesta has joined #ruby
Tempesta has quit [Max SendQ exceeded]
Tempesta has joined #ruby
Tempesta has quit [Max SendQ exceeded]
Tempesta has joined #ruby
Tempesta has quit [Max SendQ exceeded]
Tempesta has joined #ruby
Tempesta has quit [Max SendQ exceeded]
grilix has quit [Ping timeout: 244 seconds]
Tempesta has joined #ruby
Tempesta has quit [Max SendQ exceeded]
Tempesta has joined #ruby
gell5_ has quit [Remote host closed the connection]
cagomez has quit []
poontangmessiah has joined #ruby
ElFerna has joined #ruby
reber has quit [Remote host closed the connection]
poontangmessiah has quit [Remote host closed the connection]
duderonomy has quit [Quit: Textual IRC Client: www.textualapp.com]
ElFerna has quit [Ping timeout: 268 seconds]
spacesuitdiver has joined #ruby
camilasan has joined #ruby
bitwinery has quit [Ping timeout: 248 seconds]
bitwinery has joined #ruby
cagomez has joined #ruby
ravenousmoose has joined #ruby
jinie has quit [Ping timeout: 252 seconds]
greengriminal has joined #ruby
ravenousmoose has quit [Ping timeout: 248 seconds]
jinie has joined #ruby
_whitelogger has joined #ruby
cagomez has quit []
alan_w has joined #ruby
alan_w has quit [Ping timeout: 265 seconds]
<greengriminal> Hey all
<phaul> hi greengriminal
<greengriminal> As rubyist we know that multiple conditions with `unless` does not work for example: `puts 'test' unless false && true` <- won't work because "not" does apply to all conditionals. However take these snippets into consideration. But take this snippet for example.
Swyper has quit [Remote host closed the connection]
<greengriminal> you'll find that the only `truthy` expression is when both or conditions are false. Which brings me to my question it appears like you "can" use multiple expression with unless.
<greengriminal> Assuming that both left and right or conditions are false.
<jhass> just mentally rewrite unless expr to if !(expr)
<jhass> it's the same
<jhass> so of course puts "test" unless false && true "works", it's the same as puts "test" if !(false && true)
RiPuk has quit [Quit: ZNC 1.7.4 - https://znc.in]
<phaul> hi jhass , the bot seems to be fast again - no more time outs, did you do anything?
RiPuk has joined #ruby
<jhass> yeah, turns out qcow2 images don't like to live on btrfs m(
<phaul> oh ok. that's good, that means that we probably will be fine ;)
poontangmessiah has joined #ruby
Swyper has joined #ruby
<jhass> for a while, I'll have to rewrite the thing at some point, the sandbox I use is no longer maintained :(
<jhass> greengriminal: https://p.jhass.eu/7a.txt
<jhass> whether you use a variable there, call a method or embed the expression directly into the unless doesn'
<jhass> doesn't make a difference
<greengriminal> jhass, that makes more sense.
Swyper has quit [Remote host closed the connection]
bitwinery has joined #ruby
bitwinery has quit [Max SendQ exceeded]
ElFerna has joined #ruby
Technodrome has quit [Read error: Connection reset by peer]
ElFerna has quit [Client Quit]
dinfuehr has quit [Ping timeout: 244 seconds]
dinfuehr has joined #ruby
uranoss has joined #ruby
Emmanuel_Chanel has quit [Ping timeout: 244 seconds]
DaRock has joined #ruby
mn3m has joined #ruby
mn3m has quit [Max SendQ exceeded]
sameerynho has quit [Ping timeout: 246 seconds]
schne1der has joined #ruby
dbugger has quit [Quit: Leaving]
havenwood has quit [Quit: ZNC 1.7.3 - https://znc.in]
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
vondruch has quit [Remote host closed the connection]
vondruch has joined #ruby