Activity Graph

Page 1 of 2 | Next »


[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 }


[02:52:57] leftylink: at first was like "WHAT, didn't you already do this in december", but that was the `ordered_vowel_word?` question, phew
[02:53:15] leftylink: if it had been the exact question it would have been very dismaying.
[02:53:23] leftylink: s/exact/exact same/
[02:54:12] leftylink: Swyper: please consider the value of intermediate expressions. for example, use a REPL to see what the value of "aaoeee".split is
[17:30:33] leftylink: I see that you are asking about a directory. That probably means https://ruby-doc.org/core-2.5.1/Dir.html#method-c-5B-5D is a good starting point for the answer
[17:33:36] leftylink: for backticks, see https://ruby-doc.org/core-2.6.1/Kernel.html#method-i-60
[19:44:38] leftylink: amosbird: if you just want to concatenate them, not caring about uniqueness, the + operator will do. if you want to deduplicate, try | (or I guess you could + and then .uniq, but unnecessary!)
[19:45:22] leftylink: &>> [ ["a", "b"] + ["b", "c"], ["a", "b"] | ["b", "c"] ]
[19:45:29] leftylink: the two possible things you might want to do
[19:48:26] leftylink: of course it doesn't, but that wasn't what you were asking
[19:48:42] leftylink: you were asking how to combine the results of the two Dir calls, not their inputs
[23:36:41] leftylink: think of this as primarily sorting by the letter, then secondarily sorting by the modifier (+, -, nothing)
[23:37:06] leftylink: sorting primarily by criterion 1 and secondarily by criterion 2 is achieved by having sort_by 's block yield a two-element array
[23:38:38] leftylink: for example, [1, 10, 2, 40, 4, 13].sort_by { |x| [x.digits.sum, x] }
[23:38:45] leftylink: &>> [1, 10, 2, 40, 4, 13].sort_by { |x| [x.digits.sum, x] }
[23:39:03] leftylink: as you can see, it has sorted primarily by the digital sum and secondarily by the magnitude of the number
[23:41:50] leftylink: sort_by will not explicitly mention what's going on when you have its block yield an array, but it is the consequence of the fact of how arrays compare against each other
[23:42:04] leftylink: nevertheless, yes, reading about sort_by is still encouraged
[23:44:01] leftylink: if it is a requirement tha tyou use <=>, I suppose you'd have to say `something <=> other.something`, where the `something` is what we discussed above w/ the two-element array
[23:44:32] leftylink: in which case sort_by would not come into play
[23:45:15] leftylink: sort_by would only come into play if we have something like `%w(A+ F B- B B+).sort_by { |g| ... }`
[23:49:28] leftylink: I pretty much never do because I really don't want to be vampired, but maybe I overcompensate
[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


[00:41:58] leftylink: I think using is for a refinement
[00:43:21] leftylink: &>> module ArraysCanSayHello refine Array do def hello; "hello" end end end; using ArraysCanSayHello; [].hello
[00:56:41] leftylink: mr_blue: I'm sure there probably is. you will probably be able to find it, now that you know it is called a Refinement. It should be in the docs for versions 2.0.0 and later


[22:47:27] leftylink: while it would be possible to do `x|!0` to change nil to false, I would find it more likely that it's not necessary to change nil to false
[23:02:08] leftylink: !0 is false, that's all there is to it
[23:02:48] leftylink: golfing, so it's better to write `false` in as few chars as possible... but then I realised that !!x is one char less than x|!0
[23:04:59] leftylink: in the same vein, one wants to write `p` instead of `nil` and `!p` instead of `true`
[23:11:02] leftylink: ... whoops, which also made me realise it doesn't work if x is possibly a number, since then it will do something for `|` (bitwise or) that I didn't want it to do
[23:13:36] leftylink: ... so yeah another reason why !! is the better


[09:30:05] leftylink: Ping timeout: 245 seconds
[19:51:37] leftylink: well, today I learned about https://ruby-doc.org/core-2.5.1/Regexp.html#class-Regexp-label-Special+global+variables . so thanks for that


[16:19:39] leftylink: probably. though I guess you can do something like...
[16:19:55] leftylink: &>> require 'ostruct'; h = {a: 5}; OpenStruct.new(**h).a
[16:20:40] leftylink: though you cannot do the same with something like to_s
[16:20:46] leftylink: &>> require 'ostruct'; h = {to_s: 5}; OpenStruct.new(**h).to_s
[16:21:03] leftylink: so doing that will still cause some surprises
[16:24:39] leftylink: ... and just found out that the ** are not needed in either of those example
[16:25:03] leftylink: learn something every day
[19:03:25] leftylink: hmm, I wonder if using backticks in &>> would be unwise
[19:03:29] leftylink: &>> `echo hi`
[19:05:02] leftylink: huh, turns out backticks weren't necessary for the point I needed to make
[19:56:20] leftylink: I wanted to demonstrate waiting on IO (and therefore still benefitting from threads in the presence of the GVL) with `sleep 5` but it turns out Kernel.sleep also qualifies
[21:15:43] leftylink: jmosco: note that when I do `zsh -c "echo $'\u2388 '"` I get a snowflake-like symbol, whereas if I do `env LC_CTYPE=C zsh -c 'echo $"\u2388"'` , I get "zsh:1: character not in range". You may wish to check whether that environment variable (or any of the related environment variables) are set as you expect them to be
[21:18:19] leftylink: where "the related environment variables" are I assume the ones output by `locale` command


[19:29:34] leftylink: the only way I found to call [] was self.[foo]
[19:29:43] leftylink: er, without the dot
[19:29:54] leftylink: self[foo], or I guess self.[](foo) would also work
[19:30:32] leftylink: given that you can do maybe_an_array&.[](foo) , seems logical that self.[](foo) would work
[19:33:39] leftylink: the passing of control used to invite some sort of discussion about https://ruby-doc.org/core-2.5.0/Continuation.html but nowadas I guess people prefer https://ruby-doc.org/core-2.5.0/Fiber.html . I haven't delved into them much


[07:40:47] leftylink: Remote host closed the connection


[05:41:36] leftylink: Remote host closed the connection
[07:53:09] leftylink: has joined #ruby
[07:53:14] leftylink: has joined #ruby-offtopic


[03:43:35] leftylink: NOW WE'LL NEVER KNOW
[17:42:36] leftylink: no reason to even consider regretting it, it was a good pun, bud


[22:28:15] leftylink: remember that sudoku bug... there was a small subproblem of "make a public statement that makes it likely I know the answer, but doesn't give too much away"
[22:41:06] leftylink: o. yeah if it had just been a "find the unspecified bug in these 300 lines" I probably wouldn't have bothered


[00:46:52] leftylink: heh, I accidentally used `next` in a lambda when I instead meant to use `return`, but it was fine. TIL I guess
[00:47:04] leftylink: &>> ->{ next 5 }[]
[00:47:16] leftylink: can't do that if it's a function though
[00:47:24] leftylink: &>> def f; next 5; end; f


[01:01:10] leftylink: dmwit: in ruby 2.4 or later, try Hash#transform_values


[20:05:29] leftylink: correction: the result of the expression is false, but `result` is true.
[20:06:01] leftylink: &>> xxx = (result = true and false); [xxx, result]
[20:08:12] leftylink: the ruby console shows you the value of the last expression, which is not necessarily the same as the value assigned to any variables that may have been present


[09:21:02] leftylink: &>> ["a".match(/a$/), "a".match("a$"), "will_never_match_a".match("/a$/"), "could_m/a/tch".match("/a/")]
[10:51:02] leftylink: well, if you have https://en.wikipedia.org/wiki/Sed installed, you could consider using it


[04:38:33] leftylink: ocampa: if manjaro is using arch's package for that, then https://www.archlinux.org/packages/community/any/ruby-irb/ may be necessary
[04:42:29] leftylink: whoa, I never knew such a command existed


[05:31:38] leftylink: you didn't store the result of change.round(2)
[10:27:48] leftylink: oh lol whoops
[10:27:54] leftylink: wouldn't have had that problem in an even-sized board


[08:28:38] leftylink: Ping timeout: 250 seconds
[08:28:55] leftylink: has joined #ruby-offtopic
[08:28:55] leftylink: has joined #ruby
[08:51:22] leftylink: you can consider %02d for the formatting part
[08:52:00] leftylink: &>> '%02d:%02d:%02d' % [0, 1, 22]


[17:22:57] leftylink: maybe a file w/ one element per line is good


[16:33:23] leftylink: Quit: Lost terminal
[16:44:36] leftylink: has joined #ruby
[16:44:40] leftylink: has joined #ruby-offtopic


[08:11:16] leftylink: that sounds fun. I would consider something like running imagemagick in a loop, https://imagemagick.org/script/convert.php has the deets
[08:11:42] leftylink: and ffmpeg can probably put all the frames into a webm


[21:48:23] leftylink: when we expect it to not
[21:59:58] leftylink: also since it was never explicitly stated... there *was* a bit of uncertainty about `@instance` but I suppose the assumption in most of my statements was that it was either an array or a string, therefore `<<` will always be truthy
[22:06:40] leftylink: recall that for the given code to make sense we also have to intersect that set with the set of things that have `include?` ... also that I assumed that `includes?` in the original was misspelled