Activity Graph

Page 1 of 237 | Next »


[18:38:27] havenwood: Guest37: I disagree.
[18:39:47] havenwood: Guest37: I think you like the Ruby language more than you realize. The things you initially disliked are starting to seem reasonable now that you're becoming accustomed to a new way.
[18:42:36] havenwood: Guest37: welcome
[18:43:25] havenwood: it's an interesting idea to improve Ruby namespaces with proper module imports but i haven't seen a viable proposal
[18:43:57] havenwood: it's a tradeoff with Ruby's object model namespacing
[18:44:56] havenwood: i've not had the lack of it be a practical barrier but i agree it's nice to have
[18:46:40] havenwood: i really like both Clojure and Elixir style imports
[19:37:13] havenwood: leftylink: this is actually fixed on master
[19:37:26] havenwood: leftylink: it'll work come Christmas with Ruby 2.7
[19:37:36] havenwood: leftylink: even in irb ;)
[19:38:09] havenwood: in the meantime it works on nightly ruby! https://gist.github.com/havenwood/823382815cbdcfddadd798d4042023a8
[19:43:56] havenwood: leftylink: al2o3-cr: that reminds me, i should put on my resume that @chrisseaton titled me, "The human fuzzer." https://gitter.im/graalvm/truffleruby?at=5b980b19f3c26b08f6615a20
[19:44:36] havenwood: I should probably write more useful code and do less fiddling but I love fiddling.
[19:51:09] havenwood: ACTION tries to resist /offtopic ing the "topic" :P
[19:51:25] havenwood: I guess it's more on "topic."
[20:00:19] havenwood: al2o3-cr: some incredible work on that list!!
[20:33:56] havenwood: xco: Rubby 2.6.
[20:34:22] havenwood: xco: https://developer.squareup.com/blog/rubys-new-infinite-range-syntax-0/
[20:34:40] havenwood: xco: that's an article i wrote about it back in the day
[20:35:47] havenwood: xco: s[1..-1]


[09:25:26] havenwood: thomas_25: you can just put it in a module then require it
[09:25:29] havenwood: thomas_25: https://gist.github.com/havenwood/f177132c0f7ebaae76ea
[09:25:48] havenwood: thomas_25: https://gist.github.com/havenwood/6d91ebf489ac7739a4d10aaa79ed5b24
[09:26:37] havenwood: thomas_25: looks like you wrapped it in a module. Nice. I'd put the constant inside the module.
[09:26:53] havenwood: thomas_25: By convention, you'd usually name the module to match the file.
[09:27:24] havenwood: thomas_25: For? PRECISION = 6
[09:27:36] havenwood: thomas_25: Not inside a method, just inside the module.
[09:28:14] havenwood: thomas_25: then add one `module_function` up top in the module, also before the first method
[09:28:26] havenwood: thomas_25: you can then call `Xenakis.sync` etc.
[09:28:46] havenwood: ryouba: nokogiri or oga
[09:30:19] havenwood: ryouba: Nokogiri::HTML(html).text
[09:30:30] havenwood: ryouba: you can then search that text
[09:31:56] havenwood: ryouba: Once it's a string, you can search it like any other string.
[09:32:15] havenwood: ryouba: or use trigrams with your db or whatever else if you want indexed search
[09:32:20] havenwood: ryouba: or elastic search
[09:34:02] havenwood: ryouba: Postgres trigrams are nice.
[09:34:12] havenwood: ryouba: pg_trgm
[09:35:41] havenwood: it works well and the indexing is simple
[09:35:52] havenwood: you should be able to find plenty of articles
[09:37:11] havenwood: ryouba: or you can always just not index: https://github.com/seamusabshere/fuzzy_match
[09:37:34] havenwood: ryouba: it totally depends on what you're doing, how much of it, etc. there're many ways to search for similar text.


[14:25:19] havenwood: robotcars: is it Ruby 2.6?
[14:25:28] havenwood: robotcars: double check!
[14:25:49] havenwood: robotcars: by where it fails with #to_h, can you?: p RUBY_VERSION
[14:26:16] havenwood: robotcars: What's the receiver of #to_h? Do you know what it being called on?
[14:35:20] havenwood: kapil_: https://github.com/thoughtbot/factory_bot/blob/4d1cb6219b44d9ab005697d4bcd9f448ac7b897d/lib/factory_bot/syntax/default.rb#L6-L8
[14:36:35] havenwood: kapil_: https://github.com/thoughtbot/factory_bot/blob/4d1cb6219b44d9ab005697d4bcd9f448ac7b897d/lib/factory_bot/syntax/default.rb#L49
[14:38:12] havenwood: kapil_: https://docs.ruby-lang.org/en/2.6.0/BasicObject.html#method-i-instance_eval
[14:49:22] havenwood: kapil_: It runs a thingy. ¯\_(ツ)_/¯
[14:50:44] havenwood: kapil_: Check out the methods on the DSL class. It's presumably wanting access to those in the block and this is one way to do that.
[14:51:12] havenwood: kapil_: https://github.com/thoughtbot/factory_bot/blob/4d1cb6219b44d9ab005697d4bcd9f448ac7b897d/lib/factory_bot/syntax/default.rb#L15-L46
[14:51:31] havenwood: kapil_: See if the instance_eval docs make sense to you?
[15:32:12] havenwood: GeorgesLeYeti: What is it you're trying to do?
[17:36:00] havenwood: Quit: ZNC 1.7.3 - https://znc.in
[17:38:10] havenwood: has joined #RubyonRails-offtopic
[17:38:11] havenwood: has joined #RubyonRails-offtopic
[17:38:11] havenwood: has joined #ruby
[17:38:11] havenwood: Changing host
[17:38:11] havenwood: has joined #ruby
[17:38:32] havenwood: has joined #ruby-offtopic
[17:38:32] havenwood: has joined #RubyOnRails
[17:45:00] havenwood: Quit: ZNC 1.7.3 - https://znc.in
[17:45:43] havenwood: has joined #RubyonRails-offtopic
[17:45:43] havenwood: has joined #ruby
[17:45:43] havenwood: Changing host
[17:45:43] havenwood: has joined #ruby
[17:45:43] havenwood: has joined #RubyonRails-offtopic
[17:45:58] havenwood: has joined #ruby-offtopic
[17:45:58] havenwood: has joined #RubyOnRails
[17:47:24] havenwood: Client Quit
[17:49:06] havenwood: has joined #RubyonRails-offtopic
[17:49:06] havenwood: has joined #ruby
[17:49:06] havenwood: Changing host
[17:49:06] havenwood: has joined #ruby
[17:49:06] havenwood: has joined #RubyonRails-offtopic
[17:49:36] havenwood: has joined #ruby-offtopic
[17:49:39] havenwood: has joined #RubyOnRails
[17:57:14] havenwood: Quit: ZNC 1.7.3 - https://znc.in
[18:04:05] havenwood: has joined #RubyonRails-offtopic
[18:04:05] havenwood: has joined #ruby
[18:04:05] havenwood: Changing host
[18:04:05] havenwood: has joined #ruby
[18:04:05] havenwood: has joined #RubyonRails-offtopic
[18:04:19] havenwood: has joined #ruby-offtopic
[18:04:19] havenwood: has joined #RubyOnRails
[18:24:47] havenwood: Quit: ZNC 1.7.3 - https://znc.in
[18:25:26] havenwood: has joined #ruby
[18:25:26] havenwood: has joined #RubyonRails-offtopic
[18:25:27] havenwood: has joined #RubyonRails-offtopic
[18:25:27] havenwood: has joined #ruby
[18:25:27] havenwood: Changing host
[18:25:40] havenwood: has joined #ruby-offtopic
[18:25:43] havenwood: has joined #RubyOnRails
[21:44:22] havenwood: Quit: ZNC 1.7.3 - https://znc.in
[21:45:26] havenwood: has joined #RubyonRails-offtopic
[21:45:26] havenwood: has joined #ruby
[21:45:26] havenwood: Changing host
[21:45:26] havenwood: has joined #ruby
[21:45:26] havenwood: has joined #RubyonRails-offtopic
[21:45:42] havenwood: has joined #ruby-offtopic
[21:45:42] havenwood: has joined #RubyOnRails


[14:40:22] havenwood: https://youtu.be/RpkQEq75y18
[14:46:21] havenwood: kapil_: It's an instance of a new Struct!
[14:46:28] havenwood: kapil_: It has one member, :s.
[14:46:58] havenwood: &>> '.йгше'.grapheme_clusters # dpl
[14:47:09] havenwood: #=> [".", "й", "г", "ш", "е"]
[14:47:58] havenwood: #=> [[46], [208, 185], [208, 179], [209, 136], [208, 181]]
[14:47:58] havenwood: '.йгше'.grapheme_clusters.map(&:bytes)
[14:55:26] havenwood: class String; include Enumerable; alias each each_grapheme_cluster end
[16:33:23] havenwood: kapil_: I prefer the modern variant: Struct.new(:s, keyword_init: true)
[16:34:13] havenwood: kapil_: Point = Struct.new(:x, :y, :z, keyword_init: true)
[16:34:40] havenwood: kapil_: Point.new(z: 42, x: 5, y: 0) #=> #<struct Point x=5, y=0, z=42>
[16:36:10] havenwood: kapil_: Typically, Structs have more than one member.
[16:36:35] havenwood: (But not always.)


[00:10:17] havenwood: Pop quiz. What's the Ruby 2.7 output for?: Enumerator.produce(&:itself).take(3)
[00:12:12] havenwood: Enumerator.produce(10) { |n| n.zero? ? raise(StopIteration) : n.pred }.to_a
[00:12:17] havenwood: #=> [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
[00:14:47] havenwood: I liked 0.step but it's awesome to get (0..) and Enumerator.produce(0, &:succ) too.
[00:16:59] havenwood: &>> 1.step.step
[00:42:31] havenwood: leftylink: not too late for the pop quiz. :P
[00:42:40] havenwood: What's the result?!
[00:42:54] havenwood: leftylink: Too late for yoshie?
[00:57:48] havenwood: leftylink: [nil, nil, nil]
[00:58:37] havenwood: leftylink: The default block argument is `nil`, so it's `nil.itself #=> nil`.
[00:58:58] havenwood: leftylink: You win!
[01:45:00] havenwood: leftylink: pretty amazing what folk come up with for esoteric Ruby
[01:45:57] havenwood: leftylink: I don't think anyone in history so far can beat mame for quines.
[11:29:33] havenwood: pLaTo0n: http://roda.jeremyevans.net
[13:44:14] havenwood: for ruby (${RUBIES:t}) chruby-exec $ruby -- update_rubygems -- end
[13:50:12] havenwood: i guess better to
[13:50:13] havenwood: for ruby (${RUBIES:t}) chruby-exec $ruby -- gem update --system -- end
[16:16:56] havenwood: kapil_: preceding a constant with :: means the outermost scope.
[16:18:07] havenwood: ::Kapil is Kapil not Foo::Kapil or Foo::Bar::Kapil
[16:18:32] havenwood: kapil_: https://cirw.in/blog/constant-lookup.html
[16:18:42] havenwood: kapil_: https://gist.github.com/kyrylo/6413067
[16:23:20] havenwood: sshine: delete_prefix('.')


[14:40:34] havenwood: throstur: def magic_wrap; yield rescue JiraError end; magic_wrap { raise JiraError }
[14:40:42] havenwood: throstur: (but the real errors you want to rescue)
[14:40:59] havenwood: throstur: There are many other ways to do it.
[14:45:02] havenwood: throstur: or even use DelegateClass
[14:48:54] havenwood: kapil_: is it good that you're doing that?
[14:49:15] havenwood: kapil_: you're rewriting some Ruby code in C++?
[14:49:28] havenwood: kapil_: What's the purpose? Learning?
[14:50:08] havenwood: kapil_: You're rewriting a "very big project" from Ruby to C++ and want to know if that's good?
[14:51:56] havenwood: kapil_: This is for work, not for fun?
[14:52:41] havenwood: kapil_: I'm surprised they're okay with you rewriting a huge codebase. ¯\_(ツ)_/¯
[14:52:49] havenwood: kapil_: Good luck!
[14:53:54] havenwood: kapil_: will it?
[14:54:06] havenwood: kapil_: Is it not performing?
[14:54:34] havenwood: kapil_: Is it I/O or CPU bound?
[14:56:16] havenwood: kapil_: So you're going to do lots of work to end up with the same thing you already have, if you succeed.
[14:56:37] havenwood: If you fail, you've done lots of work to end up with something worse.
[14:57:45] havenwood: kapil_: It sounds like you might just want to learn Rails or take another gig.
[14:58:17] havenwood: If you're dead set on C++, find a C++ project to work on!
[14:59:33] havenwood: kapil_: Then I don't understand what you're asking. If you know Rails, and have a huge Rails app, obviously don't port it to C++.
[15:00:53] havenwood: spent costs.
[15:01:38] havenwood: kapil_: https://www.wikiwand.com/en/Sunk_cost
[19:26:53] havenwood: yoshie902a: You can't create a method like that. That's not valid code. Are you trying to use regular args or keyword args?
[19:27:29] havenwood: yoshie902a: You can either `def test(name:, zip:)` or `def test(name, zip)` but not `def test(:name, :zip)`.
[19:28:08] havenwood: yoshie902a: With either of the former, you know they were passed, since they're both mandatory arguments. You can't call the method without providing the positional or keyword arguments, since they're not optional.
[19:28:59] havenwood: yoshie902a: By providing a default value.
[19:29:11] havenwood: yoshie902a: def test(name: nil, zip: nil)
[19:31:32] havenwood: yoshie902a: If you really need an undefined, and you don't know the input, you can do a pattern where you have a constant set to a rando object.
[19:31:44] havenwood: yoshie902a: UNDEFINED = Object.new
[19:31:59] havenwood: yoshie902a: def test(name: UNDEFINED, zip: UNDEFINED)
[19:32:14] havenwood: yoshie902a: if name == UNDEFINED
[19:34:53] havenwood: yoshie902a: That doesn't sound right. Show your code?
[21:27:55] havenwood: robotcars What's the problem you're running into? Getting an error? What doesn't work?
[21:29:22] havenwood: robotcars: So if left or right is `nil`, is that a bug or what should happen?
[21:29:38] havenwood: robotcars: What *should* happen if one side is nil?
[21:30:13] havenwood: robotcars: Larger than nil?
[21:30:19] havenwood: robotcars: Are you considering `nil` to be zero?
[21:30:53] havenwood: &>> nil.to_i
[21:31:37] havenwood: robotcars: zero isn't greater than zero. I don't really understand what you want to happen if left or right is nil.
[21:31:55] havenwood: &>> 0.to_i > 0
[21:32:33] havenwood: &>> value = nil; value&.size.to_i > 0
[21:32:53] havenwood: robotcars: If you wanted `nil` to be zero, it's easy.
[21:34:21] havenwood: robotcars: I'd suggest assigning updates, field, etc to symbols then: updates.dig(event_name, field, :value).to_s
[21:34:54] havenwood: robotcars: i'd suggest adding a few if statements until it works the way you want. Then we can help you refactor.
[21:35:30] havenwood: eam: good evenin'!
[21:36:55] havenwood: eam: how about you?
[21:45:05] havenwood: robotcars: Seems you've nested two methods? Something is wrong with your gist.
[21:49:48] havenwood: yoshie902a: Instead of: list = []; count.times do |_count|; ...; end; list
[21:50:02] havenwood: yoshie902a: Just: Array.new(count) { ... }
[21:52:57] havenwood: yoshie902a: Looks like a Factorybot state issue.
[21:54:17] havenwood: yoshie902a: I don't use Factorybot but it seems it's not meant to be used like this. Maybe someone familiar with the library will know why.
[21:54:21] havenwood: yoshie902a: https://stackoverflow.com/questions/32172334/factory-girl-rspec-trait-not-registered-error/46467790
[21:56:02] havenwood: yoshie902a: Can you remove code and still reproduce the issue. Try to boil it down to a minimal repro case and ask the factorybot folk.
[21:57:20] havenwood: robotcars: yes, plenty of improvements to be made. i can suggest a few.
[22:17:10] havenwood: robotcars: I commented on your gist.
[22:17:30] havenwood: robotcars: I didn't test this code, but it should give you ideas.
[22:17:53] havenwood: robotcars: keep refactoring!
[22:20:36] havenwood: ACTION robotcars: updated comment for a mistake: https://gist.github.com/robert-carroll/535e2cbd9c903ffafdd5ba7d8a19e0e1
[22:20:53] havenwood: robotcars: you're welcome!
[22:32:28] havenwood: yoshie902a: can you reproduce this with less code
[22:32:54] havenwood: yoshie902a: what's the smallest amount of code you can repro with?
[22:32:57] havenwood: betcha someone who knows factorybot can tell you from there


[16:42:36] havenwood: leftylink: That reminds me, I was going to patch that in RVM.
[16:42:50] havenwood: leftylink: There's a developer meeting next week. That'll probably be when it's decided.
[16:43:12] havenwood: TheMoonMaster: It runs great too! Use the --jit flag for CRuby or TruffleRuby is the fastest by far.
[16:44:23] havenwood: "The fstring mechanism is too difficult for human (except normalperson (Eric Wong))."
[17:41:49] havenwood: leftylink: https://github.com/rvm/rvm/pull/4780
[19:09:35] havenwood: leftylin: Oops. My syntax highlighter chose a color for your nick too close to Sharcho's.
[21:31:12] havenwood: gambl0re: yup


[17:01:11] havenwood: This is super neat: https://github.com/ruby/ruby/pull/2450
[17:01:35] havenwood: This only makes me more eager to cache gem bytecode on install. :)
[17:02:42] havenwood: (It reduces RubyVM::InstructionSequence#to_binary output to be a quarter of the previous size.)
[17:05:11] havenwood: https://github.com/ko1/yomikomu/blob/master/lib/yomikomu.rb#L80-L89
[18:22:18] havenwood: Eiam: Do you have Pry installed for the current Ruby?
[18:22:25] havenwood: Eiam: gem which pry
[18:28:56] havenwood: Eiam: And nothing funky in your .pryrc?
[18:29:27] havenwood: Eiam: And the IRB you're using is also the current Ruby? Nothing in .irbrc?
[18:30:14] havenwood: Eiam: What paths does Pry show?
[18:30:29] havenwood: Eiam: So that's System Ruby it's showing.
[18:30:45] havenwood: Eiam: What do you get for?: which -a pry
[18:31:18] havenwood: Eiam: head -n1 /usr/local/bin/pry
[18:31:40] havenwood: leftylink: :)
[18:31:45] havenwood: Eiam: gem pristine pry
[18:32:38] havenwood: Eiam: head -n1 /usr/local/bin/pry
[18:33:12] havenwood: Eiam: Just to confirm, your Ruby 2.6 is brew Ruby? Is its GEM_PATH in your PATH?
[18:36:33] havenwood: Eiam: export PATH="$(gem env gemdir)/bin:$PATH"
[18:37:10] havenwood: Eiam: Then check: which -a pry
[18:37:18] havenwood: Eiam: Homebrew doesn't give proper instructions on setting up PATH for gems on install.
[18:37:24] havenwood: Eiam: If I had time, I'd fix that.
[18:38:49] havenwood: Eiam: https://gist.github.com/havenwood/ba31f67c1d89ac236400
[18:39:28] havenwood: Eiam: That's ^ my recommended setup for folk using chruby with brew Ruby.
[18:39:51] havenwood: There are other ways to do it and happy to help with one of those if you prefer.
[20:55:31] havenwood: Norrin Good.


[19:57:40] havenwood: naftilos76_: I think just pass the two args separately. You can splat if it's an Array: Product.where("name like ? or description like ?", *["%ba%", "%ba%"])
[19:57:58] havenwood: naftilos76_: When it's the same parameter twice I like to used a named bind variable rather than the question mark.
[19:58:41] havenwood: Product.where("name like :name or description like :name", name: ":naftilos76_")
[19:59:02] havenwood: Product.where("name like ? or description like ?", ":naftilos76_", ":naftilos76_")
[22:29:35] havenwood: davidw: Assuming you're not in Rails?
[22:30:59] havenwood: davidw: The rails solution is: Foo::Bar.name.demodulize
[22:31:51] havenwood: davidw: https://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-demodulize
[22:32:47] havenwood: davidw: Yeah, there's nothing other than string munging, unfortunately.
[22:33:33] havenwood: davidw: I'd suggest: Foo::Bar.name.rpartition('::').last