Activity Graph

Page 1 of 3 | Next »


[18:13:26] leftylink: Ping timeout: 272 seconds
[18:15:59] leftylink: has joined #ruby-offtopic
[18:15:59] leftylink: has joined #ruby
[23:42:16] leftylink: mynameisdebian: in total ignorance because I have no experience with slack api, is it at all possible that https://ruby-doc.org/stdlib-2.6.3/libdoc/net/http/rdoc/Net/HTTP.html#method-i-use_ssl-3D is needed? to set it to true
[23:48:36] leftylink: oh, was tha tit?


[20:14:09] leftylink: ugh, might have to do something ugly like %w(these_two go_together but these don't).map { |x| x.replace(?_, ?\s) |
[20:14:25] leftylink: &>> %w(these_two go_together but these don't).map { |x| x.replace(?_, ?\s) }
[20:14:40] leftylink: &>> %w(these_two go_together but these don't).map { |x| x.tr(?_, ?\s) }
[20:14:48] leftylink: I obviously meant tr :)
[20:15:30] leftylink: we've got it
[20:15:41] leftylink: https://docs.ruby-lang.org/en/2.6.0/syntax/literals_rdoc.html
[20:15:45] leftylink: For the two array forms of percent string, if you wish to include a space in one of the array entries you must escape it with a “\” character:
[20:16:02] leftylink: &>> %w[these\ two go\ together but these don't]
[20:16:47] leftylink: it may nevertheless be difficult to visually tell the difference at a glance
[20:17:03] leftylink: I might still prefer the _ and tr if I wanted to make it easier on the reader.... not sure
[20:18:27] leftylink: if I put every element on its own line, then I'd be ok with inline \ to escape the spaces


[11:00:18] leftylink: maybe I can suggest `tap`
[11:02:25] leftylink: I seem not to understand though. if I want to do_something and then return, then it'd be `do_something\nreturn`. so there must be some context I am missing
[11:04:54] leftylink: how about a semicolon.
[11:05:01] leftylink: if you must put it on a same line
[11:05:21] leftylink: but I will be sad as a reader of the code if I have to look for `return` in places where I not expecting it
[11:05:33] leftylink: ... so that depends on setting the reader's expectations
[11:07:56] leftylink: I must be frustrating, making alternative suggestions instead of answer the question. I will recuse myself
[11:08:17] leftylink: see you all in the next question
[11:10:02] leftylink: oh hmm, I realised, the fact that my suggestion of newline was accepted without complaint implies that the returning may not have been conditional on do_something. making it conditional is when I would have considered using some of the original questioned things
[11:10:08] leftylink: better make it clear
[11:10:27] leftylink: whether returning is conditional on do_something's truthiness
[21:19:49] leftylink: it seems it is being ignored a lot. WHAT IF!!! something automatically took the content and put it on another paste service..!!!!!!!!!!!!!!
[21:20:45] leftylink: would that get complaints of "I didn't consent for you to take my content and put it elsewhere"
[23:55:54] leftylink: hmm, although that doesn't sound like something I would personally want (I would prefer that integers should stay integers and bools should stay bools), if I wanted to do that, I would use WELL GUESS I DON'T NEED TO TYPE AN ANSWER NOW
[23:56:21] leftylink: sorry for the caps, I was very vexed


[19:59:06] leftylink: pretty much I just translate mechanically. whenever I would have written thing && thing.f in 2.2 I write it as thing&.f . however there are some times where I wouldn't be able to use that pattern


[23:40:43] leftylink: indeed... though that is not the only change needed to make the sentence


[07:35:03] leftylink: I know that https://github.com/rails/rails/issues/32070 exists. perhaps there are other.
[07:35:21] leftylink: I don't know if &. was also in this category
[17:17:31] leftylink: I guess I understand why you'd say that if you're combining two things, but if you're combining two things into one (as opposed to many things into one) it doesn't seem to buy a lot to use inject/reduce. how about if I say that as a human, the way I would do that is "first I have monday. I look at _from and _to for monday. next I have tuesday. I look at _from and _to for tuesday, and so on for the other
[17:47:54] leftylink: ACTION looks for a time-of-day in ruby stdlib
[17:48:17] leftylink: hmmmmmmmmmmmmm
[17:48:22] leftylink: guess it is not in stdlib
[17:49:38] leftylink: because then the unfortunate thing is then I might have shit like
[17:49:40] leftylink: &>> ("14:00".."23:00").cover?("1:33")
[17:50:34] leftylink: better hope so


[00:01:41] leftylink: "I see you walking by every day" ?
[00:01:58] leftylink: sorry, that's just the first thing that comes to mind if someone just says "boy" in one sentence with no other context
[00:46:11] leftylink: Ping timeout: 244 seconds
[00:46:28] leftylink: has joined #ruby
[12:25:42] leftylink: but it seems to me that the error messages already list the files that are circularly requiring one another
[12:25:51] leftylink: were the messages inaccurage for some reason?
[12:27:35] leftylink: for example it has cited files at lines https://gist.github.com/LeamHall/4cf785ed2ffcb51445d07120297397b8#file-circular_loads-error-txt-L11 and https://gist.github.com/LeamHall/4cf785ed2ffcb51445d07120297397b8#file-circular_loads-error-txt-L14
[12:27:57] leftylink: so that seems like a good place to look
[22:08:01] leftylink: has joined #ruby-offtopic
[22:09:04] leftylink: ... well we are quickly getting into #ruby-offtopic category but in response to the above comments about screaming, I submit http://www.poorlydrawnlines.com/comic/goat/


[00:27:27] leftylink: I will regret this but
[00:27:51] leftylink: &>> puts (0...45).each_with_object(rand: nil, fizzbuzz: []) { |i, o| o[:rand] = Random.new(1781773465) if i % 15 == 0; o[:fizzbuzz] << [i + 1, 'Fizz', 'Buzz', 'FizzBuzz'].sample(random: o[:rand]) }[:fizzbuzz]
[00:28:05] leftylink: &>> (0...45).map.with_object(rand: nil, fizzbuzz: []) { |i, o| o[:rand] = Random.new(1781773465) if i % 15 == 0; o[:fizzbuzz] << [i + 1, 'Fizz', 'Buzz', 'FizzBuzz'].sample(random: o[:rand]) }[:fizzbuzz]
[00:28:57] leftylink: oh, that map was useless, it should have kept being each_with_obj, just needed to get rid of the puts which put only one on every line
[00:29:23] leftylink: though maybe puts was better anyway
[00:29:30] leftylink: anyway, one gets the idea
[00:29:59] leftylink: should have just made it ...100 anyway, it wasn't going to all show up anyway
[00:39:23] leftylink: unfortunate
[04:02:12] leftylink: but a list can be splatted into another list
[04:02:22] leftylink: &>> [*[:a]]
[04:02:46] leftylink: &>> [*[:a] * 5]


[14:06:32] leftylink: *.net *.split


[19:25:17] leftylink: that looks like either "all substrings" if "ac" should not be included, or "powerset" if "ac" should be included
[19:25:49] leftylink: note that in both cases "b" would be included
[19:26:06] leftylink: but I assumed its omission wasn't intentional


[10:04:42] leftylink: &>> require 'yaml'; YAML.load("22:22")
[10:10:13] leftylink: &>> 80520 == 22 * 3600 + 22 * 60


[16:52:08] leftylink: Ping timeout: 245 seconds
[16:52:25] leftylink: has joined #ruby


[23:44:54] leftylink: ah. I wanted to see if there was a way to have a clearer correspondence between the number of backslashes in the literal vs in the value. but I see a bit of an unfortunate circumstance
[23:45:03] leftylink: &>> %q(\) # that is a syntax error
[23:45:20] leftylink: &>> %q(\ ).strip # but this is fine
[23:45:44] leftylink: &>> %q(\\) == %q(\ ).strip
[23:46:07] leftylink: so that is a bit unfortunate if you want the correspondence
[23:47:36] leftylink: maybe if you wanted two, you could do something silly like
[23:47:53] leftylink: &>> %q(\ \ ).delete(' ').bytes
[23:48:05] leftylink: two in the literal and two in the value, that'd be fine
[23:51:21] leftylink: or I guess if you didn't want to faff about with how to represent it in your literal maybe you want something like
[23:51:57] leftylink: &>> single_backslash = ?\\; raise "NOPE" if single_backslash.size != 1; puts single_backslash * 3


[19:26:45] leftylink: "You can put ruby on rails, and it will stay on the rails, unless it rolls off."
[19:26:52] leftylink: the faq article that that quote came from is all right


[10:16:13] leftylink: while I would have thought you can say `::Rails`, I would also have equally thought it was not necessary. apparently there is something I don't understand in this matter.
[10:16:25] leftylink: I wonder what it is I have failed to understand
[10:24:56] leftylink: &>> module Foo end; module Bar puts ::Foo == Foo end
[10:25:28] leftylink: hmm. there must be some subtlety in the situation, such that the simple situation is not a good analogy for it anymore


[01:03:05] leftylink: *.net *.split
[22:48:49] leftylink: &ri Method#parameters might be what shalok wants?


[00:05:40] leftylink: I see *a* bug, but it doesn't explain the fact that the stderr is not present
[00:07:50] leftylink: ... upon review in irb, the bug I found is not a bug. that is too bad (I had thought that prepend doesn't mutate, but I was thinking of the newly-added delete_suffix and delete_prefix)
[00:08:18] leftylink: this is going to cause me all sorts of confusion in the future, I am sure of it
[00:09:08] leftylink: having to remember what I need to add ! to and what I don't


[20:37:59] leftylink: hmm, if someone were to tell me "hey Ray, Ruby is your Blub", I wonder how to know whether that's true. As I understand it, Blub implies I am not able to comprehend this or that feature. Then again, it's hard to know the difference between "I don't understand it" and "I understand it and judge that it does not benefit this project"
[20:38:43] leftylink: (substitute "Lefty" for "Ray" if it reads better to use my internet name)
[20:40:16] leftylink: I guess it's hard to know if you're in that situation. Just as the ant is not able to understand the human
[20:40:38] leftylink: so really the best thing to do is just to expand your understanding, no matter what
[20:41:15] leftylink: on the other hand, "Ruby is your most-used language" is a much more well-defined statement, and one that is true if said to me


[16:49:39] leftylink: *.net *.split


[00:54:35] leftylink: another possibility might be fdiv.
[00:58:41] leftylink: that's too bad. I waned to see if it was possible to define a custom operator, then you could `refine`/`using` in something like `1 // 3`, but I do not think that is possible, if I believe https://stackoverflow.com/questions/11874579/define-custom-ruby-operator
[02:14:54] leftylink: don't wanna spoil the surprise... I can refine in &>> right... let's see
[02:15:29] leftylink: &>> module HelloString refine String do def hello; "hello #{self}" end end end; using HelloString; p ?a.hello
[02:15:36] leftylink: okay we can refine
[02:17:22] leftylink: if you want to abuse syntax and make /~ *look* like a floating point division operator (which the code does not actually make it do), and in the process remove your ability to bit-flip an integer, then have I got just your ticket.
[02:17:33] leftylink: &>> module LolDiv refine Integer do def ~; to_f end end end; using LolDiv; p 1 /~ 3
[02:17:43] leftylink: ACTION pounds table in laughter
[02:21:57] leftylink: can shorten with alias?
[02:22:04] leftylink: yes, can shorten with alias
[02:22:18] leftylink: &>> module LolDiv refine Integer do alias :~ :to_f end end; using LolDiv; p 2 /~ 7
[02:24:09] leftylink: ... a 1 byte savings
[02:24:31] leftylink: it also expends extra time for me too since how to use alias isn't in my working memory
[02:24:35] leftylink: so I have to figure it out


[20:43:31] leftylink: to see where ruby is looking for files that are `require`d, you may find it useful to look at the value of $LOAD_PATH . it sounds like a directory is not in there that should be.
[20:44:31] leftylink: as for how to get a directory in there that needs to be, I yield the floor


[00:14:45] leftylink: I would think `false` for `(0..).cover?(..0)`, as I reason that there is at least one member of `..0` not in `0..`
[01:55:17] leftylink: ah... yeah I could have done slightly better by explicitly naming a member I was thinking of instead of making you puzzle it out havenwood . but looks like you got it so it is all good
[02:03:04] leftylink: s/done slightly better/been more helpful/


[02:46:48] leftylink: &>> h1 = {Something: 5}; h2 = {"Something": 5}; h3 = {"Something" => 5}; p [h1 == h2, h1 == h3, h2 == h3] # sirensari_
[02:47:33] leftylink: huh. I guess that's not what I wanted to show
[02:48:05] leftylink: I tricked myself :)
[02:50:05] leftylink: sorry for my misunderstanding


[11:32:04] leftylink: has joined #ruby


[01:17:34] leftylink: if there were to be a built in method for it, it would be called something like "interleave". you might try that as a search term and see what happens (I don't know what will happen off the top of my head)
[01:22:37] leftylink: under no circumstances confuse the mesh with the interleave operator
[01:22:43] leftylink: except in confusing circumstances
[01:26:00] leftylink: hmm. kinda makes you wish there were a serious section and a srs section
[01:26:24] leftylink: gotta put "ain't" for !=
[01:28:13] leftylink: consternation at the fact that ~> is called both pessimistic and optimistic
[01:28:32] leftylink: that is my consterned face
[01:33:31] leftylink: ... uh oh. was the correct english word consternated instead


[09:14:54] leftylink: marz_d`ghostman: it doesn't look to me like anything in there is specifically rails
[09:16:49] leftylink: &>> class C; attr_accessor :foo end; a = C.new; b = C.new; b.foo = 17; a.send("foo=", b.send("foo")); a.foo # marz_d`ghostman
[20:11:14] leftylink: wasn't sure what was meant by "it" in "it still seems to take all numbers", so if you didn't find an answer from the docs, maybe some example code
[20:36:01] leftylink: *waves* what happened? / nothing link, we were just about to have a feast


[06:15:53] leftylink: ah interesting


[20:39:05] leftylink: za1b1tsu: in irb, I do `a = 5`, then I do `irb`, that is a sub-irb. In the sub-irb, what happens if I ask for `a` ? Without flag, it is not defined, NameError. With flag, it is defined (it is 5)
[20:42:15] leftylink: I hope it was clear. if not, maybe a quick log of my session will help, https://dpaste.de/PHbz/raw
[21:58:23] leftylink: note that as we can see from https://ruby-doc.org/core-2.5.0/File.html#method-c-open , the file is passed to the block. no other assumptions are made about the block. if the block needs to do something to the file, then it is obligated to do so by using the appropriate operations on the file
[23:30:57] leftylink: I think a similar thing I do is something like
[23:31:01] leftylink: "you forgot to X"
[23:31:11] leftylink: when I actually predict that X didn't even cross the other person's mind
[23:32:05] leftylink: if there's an umbrella term for these two things and others in the same category... iono, maybe "giving the other person an out" or an opportunity to save face or someshit
[23:32:33] leftylink: excuse me, it was not necessary


[07:41:09] leftylink: sagax: consider `f.drop(1)`
[07:41:26] leftylink: f[1..-1] might also be appropriate as well
[07:49:12] leftylink: wrong window
[18:54:00] leftylink: recall from https://rubular.com/ or a regexp tutorial that * matches zero-or-more occurrences
[18:55:07] leftylink: very interesting.
[18:58:29] leftylink: I notice that I sometimes say "recall X" even when I estimate it to be likely that the other person never knew X and therefore would be learning it, not recalling it. but I think that is the safer way to phrase it so I'm not sure I can do differently
[18:59:29] leftylink: &ri Kernel#p PeterNewbie
[19:00:41] leftylink: https://docs.ruby-lang.org/en/2.6.0/syntax/exceptions_rdoc.html can explain about begin/end
[19:02:17] leftylink: re emails, recall that https://www.mcsweeneys.net/articles/e-mail-addresses-it-would-be-really-annoying-to-give-out-over-the-phone exists


[00:54:17] leftylink: Remote host closed the connection
[01:02:42] leftylink: has joined #ruby
[01:02:47] leftylink: has joined #ruby-offtopic
[22:03:40] leftylink: &ri Kernel#caller rockandska
[22:14:46] leftylink: rockandska: ah I see. In that case, I actually aven't looked into this personally but it looks like caller_locations might be promising
[22:21:12] leftylink: it seems to give an object from which you can get the method name, rather than having to parse a string
[22:21:15] leftylink: which is why I suggested it


[08:59:19] leftylink: interesting. maybe the easiest way to find out is to look at its .ord
[08:59:22] leftylink: >> "\b".ord
[09:00:09] leftylink: interesting.
[10:49:31] leftylink: I wondered if it would be possible to use Array#uniq but it seems there are a few snags there so I defer to the other suggestions


[05:23:58] leftylink: mjacob: I couldn't think of a way to do that, since the docs say that `using` activates a refinement for a lexical scope. unless the entire project is contained within one file, but that probably was not intended by the question


[00:07:31] leftylink: a study of https://ruby-doc.org/core-2.5.0/doc/syntax/literals_rdoc.html#label-Here+Documents reveals that IF this is using a literal, the only option is to disable *both* interpolation and escaping, with no option to only disable escaping while keeping interpolation. so the solution will have to be something other than a literla.
[17:46:07] leftylink: jack479: there are probably two parts to your question but if I assume that we are focusing on how to include a hyphen inside a character class, then https://www.regular-expressions.info/charclass.html is probably helpful
[17:48:57] leftylink: one thing to note is that the escaping you did (with a backslash) does indeed cause the hyphen to be included in the character class
[17:53:26] leftylink: if instead we focus on a different part of the question (how to express "- can't be the first or last character"), though there might be multiple ways to express this, one way that comes to mind is to say, well, the valid characters for the first/last character are the characters other than hyphen, and the valid chars for those in the middle are including hyphen
[18:10:02] leftylink: hm. thinking about ranges has got me thinking
[18:10:11] leftylink: if you have a range that is "unusual" what happens...
[18:10:32] leftylink: &>> /[A-z]/ =~ (?A.ord + 28).chr; $~
[18:10:47] leftylink: thought it might have been something like that
[18:11:28] leftylink: hopefully anyone who uses it is okay with it matching the 6 chars in between
[18:12:10] leftylink: &>> /[a-9]/
[18:13:26] leftylink: &>> (0..255).select { |c| /[9-a]/.match?(c.chr) }.minmax
[18:36:10] leftylink: to be fair I didn't check that the range is continuous
[22:22:34] leftylink: I forgot catch / throw exists
[22:27:26] leftylink: that is interesting.
[22:31:39] leftylink: &>> catch(:hello) { 1.step { |n| throw :hello, n if Math.log(Math.log(n)) >= Math::E } }
[22:31:43] leftylink: so, I could do that, if I felt like
[22:31:50] leftylink: but I wuld rather use 1.step.find in this instance
[22:32:00] leftylink: or I would use a function and return frmo it maybe?
[22:34:40] leftylink: if you want to stop a function and return something, then it sounds like you want `return`, not try/catch
[22:34:45] leftylink: ... beaten to the punch


[23:50:26] leftylink: huh. I guess that is one thing that is not currently possible to do w/ &>>, demonstrate code containing a heredoc... guess it has to be &url then...


[05:01:06] leftylink: Dir is https://ruby-doc.org/core-2.5.1/Dir.html
[05:03:30] leftylink: since Dir is a class and not a function, `Dir ["/"]` and `Dir(["/"])` do not work. Both of those forms attempt to call a function named Dir with a single argument, ["/"]
[05:56:02] leftylink: one must be careful if one of the two regexes to be concatenated contains |, since the first approach someone might think of won't do the trick there. but perhaps some parentheses can solve that problem
[05:56:37] leftylink: &>> r1 = /a|b/; r2 = /c/; rcat = /#{r1.source}#{r2.source}/; rcat.match?('a') # but you would think this should be false
[05:57:39] leftylink: so perhaps some parens, possibly with ?: if preventing capture is important
[05:58:55] leftylink: ah, that is fortunate.


[19:32:44] leftylink: it would be fair to think of it as "next unless X" means that after this line, X is certainly true
[19:32:56] leftylink: so hopefully X is what you want it to be
[20:12:23] leftylink: ACTION hand on chin
[20:14:44] leftylink: for the particular case I wanted to do last time (use someone's gist, and then add an example usage of the gist to show that it still needs work), one would need to be able to append extra content to the contents of the gist. I don't know how commonly one wants to do that, but that would be what I wanted
[20:15:21] leftylink: one can search for that using the term "stabby lambda"
[20:16:24] leftylink: one can call a lambda using [] or .call or .()


[00:04:57] leftylink: I suddenly had a crazy thought. what if I wanted to use rubydoc to test whether someone's gist worked. how will I instruct it to load the gist... well...!!!!!!
[00:05:30] leftylink: &>> eval `curl https://gist.githubusercontent.com/mfifth/46fb313965ab679409dedf1765232e52/raw/2c27dacd91eb3817ffb3aad1ed29c19d7803ee35/app.rb`; Grade.new("A+") <=> Grade.new("A")
[00:05:35] leftylink: I am a bad person
[00:05:41] leftylink: that is unfortunate
[00:06:15] leftylink: does the curl part even work?
[00:06:30] leftylink: &>> `curl https://gist.githubusercontent.com/mfifth/46fb313965ab679409dedf1765232e52/raw/2c27dacd91eb3817ffb3aad1ed29c19d7803ee35/app.rb`[0, 30]
[00:06:35] leftylink: okay guess not
[00:07:57] leftylink: &>> `wget -O - example.com`[0, 30]
[00:08:30] leftylink: I can do the http get from ruby code natively but it sounds like work
[00:09:17] leftylink: &>> require 'net/http'; Net::HTTP.get('example.com', '/index.html')[0, 30]
[00:09:38] leftylink: I mean I guess that's to be expected
[00:10:16] leftylink: and it encourages people to use more minimal examples
[00:10:35] leftylink: or compress their entire class into a one-liner, but nobody wants to read an entire class as a one-liner
[00:19:56] leftylink: hopefully, it makes sense why the current code would (wrongly) consider "a-" to be greater than "a". that should hopefully give hints as to what it should do instead
[00:36:59] leftylink: the reason you should be suspicious is that you notice that the result of <=> depends nothing on `other_grade`
[00:37:14] leftylink: which will mean that C <=> A will surely give the same result as C <=> F
[00:37:33] leftylink: which should cause suspicion
[00:37:35] leftylink: to put it lightly
[00:47:33] leftylink: as it has been made apparent, sorting solely on letter doesn't work. and sorting solely on the symbol doesn't work, because then C+ <=> A- will surely give the same answer as C+ <=> D-
[00:53:46] leftylink: thus, we see it is necessary to consider both of those components when sorting
[00:53:50] leftylink: or comparing, rather
[01:18:44] leftylink: you know, I was presenting this as a primary+secondary sort kind of thing, but it occurs to me that converting each possible grade to a number would work as well for this purpose
[01:28:28] leftylink: you know, I was presenting this as a primary+secondary sort kind of thing, but it occurs to me that converting each possible grade to a number would work as well for this purpose
[01:29:22] leftylink: at any rate, it seems prudent to test each combination of possible grades. if we are to assume they can only go from A to F, there are so few of them that one should do it exhaustively
[01:29:34] leftylink: with something like
[01:30:01] leftylink: %w(A+ A A- B+ B B- C+ C C- D+ D D- F).map { |g| [g, Grade.new(g)] }.combination(2) { |(s1, g1), (s2, g2)| puts "#{s1} should > #{s2}" unless g1 > g2; puts "#{s2} should be < #{s1}" unless g2 < g1 }


[23:50:43] leftylink: well, at least the benefit of using <=> would be that you'd be able to get the other comparison ops for free!
[23:51:00] leftylink: so, given that it is not required, that would be the deciding factor of whether to use it