Activity Graph

Page 1 of 221 | Next »


[00:02:50] havenwood: xco: if you create any new objects, they'll automatically be in the ObjectSpace
[00:03:39] havenwood: >> xco = Object.new; ObjectSpace.each_object.include? xco
[00:03:47] havenwood: &>> xco = Object.new; ObjectSpace.each_object.include? xco
[00:11:12] havenwood: xco: yeah, i just mean it automatically includes newly created objects


[16:01:13] havenwood: graft: require 'time'
[16:03:45] havenwood: graft: some classes, like Thread, Fiber, Time, etc, load more features when required
[16:06:12] havenwood: graft: they just show "require 'time'" in front of all the methods examples where it's required
[16:06:50] havenwood: graft: Some also say: "You must require 'time' to use this method."
[16:07:52] havenwood: graft: https://docs.ruby-lang.org/en/2.6.0/Time.html#method-c-xmlschema
[16:08:09] havenwood: "You must require 'time' to use this method."
[16:10:53] havenwood: graft: ruby-doc.org just puts the documentation here: https://ruby-doc.org/stdlib-2.6.3/libdoc/time/rdoc/Time.html
[16:11:17] havenwood: graft: The links are better for docs.ruby-lang.org, but you can find it on ruby-doc.org as well.
[16:11:39] havenwood: https://ruby-doc.org/stdlib-2.6.3/libdoc/time/rdoc/Time.html#method-i-iso8601
[16:13:07] havenwood: a twin, not to be mistaken for the lonely person operator
[17:20:54] havenwood: xco: Afaik, having WebPack install React just installs the package but doesn't provide further integrations. React-Rails and ReactOnRails both go further. I don't recall details of how they differ.
[17:21:12] havenwood: xco: https://github.com/shakacode/react_on_rails
[17:21:52] havenwood: xco: Both React-Rails and ReactOnRails existed before the WebPacker integration, but both carry on after it.
[17:24:39] havenwood: xco: I'd not seen this before, but it looks related: http://ruby-hyperloop.org/
[17:25:09] havenwood: I guess they have a whole React/Rails thingy going. Dunno! ¯\_(ツ)_/¯
[17:31:30] havenwood: ACTION nods
[17:36:14] havenwood: jstrong: show your code?
[17:43:10] havenwood: jstrong an aside, but base.rb line 28 - block will be nil if no block is given, so: block: block
[17:45:45] havenwood: jstrong: without really getting what's going on here, my first thought is to pass a lambda that has a binding to where woof is defined
[17:55:07] havenwood: jstrong: https://gist.github.com/havenwood/8e27cbb30d0e4548bf8268284f14fd9c
[17:55:28] havenwood: jstrong: that's ^ one way
[17:55:58] havenwood: jstrong: (Just using `[abs2, bar.wombat]` to show bindings to both working.)
[17:56:14] havenwood: jstrong: yes
[17:56:23] havenwood: jstrong: I'm assuming you need two contexts, for whatever reason.
[17:57:29] havenwood: jstrong: Then why are you #instance_exec'ing on @filter_builder if you don't need the context there?
[17:58:15] havenwood: jstrong: Call instance exec on the context you want the block run in.
[17:59:16] havenwood: Simple is good!
[17:59:28] havenwood: You can set the binding context!
[17:59:34] havenwood: I just don't follow, I guess.
[18:00:23] havenwood: I don't get why you're instance_exec'ing on @filter_builder if you don't want the context to be there?
[18:01:22] havenwood: You can pass bindings around or instance exec on whatever you want. I think I just don't follow since I'm multitasking.
[18:02:14] havenwood: I'd suggest the simplest thing that can possibly work, as a first step. Then see if refactoring improves or if simple is readable, fast and concise.


[16:08:39] havenwood: twobitsprite: +1 HTTP.rb
[16:08:58] havenwood: It's the most similar to Requests.
[16:38:06] havenwood: zodd_: ruby-odbc issue: https://stackoverflow.com/questions/1419397/rubyodbc-cannot-allocate-sqlhenv/2631898
[16:38:42] havenwood: zoUse snake_case instead of headlessCamelCase for local variables in Ruby
[16:42:06] havenwood: iffraff: Does it work to limit to a single worker process?
[16:42:09] havenwood: iffraff: foreman start -c listener=1,workers=1
[16:42:13] havenwood: or is it -m?
[18:11:44] havenwood: codefriar: So bar is a String with square braces in it?
[18:14:17] havenwood: foo.dig *bar.scan(/[^\[\]]+/)
[18:17:01] havenwood: codefriar: By 1, do you mean an Array index?
[18:19:48] havenwood: &>> foo = {'key' => [nil, :payload]}; bar = '[key][1]'; foo.dig *bar.scan(/(?<=\[).+?(?=\])/).map { |key| Integer(key, exception: false) || key }
[18:20:23] havenwood: codefriar: +1 where does the string come from?
[18:25:41] havenwood: codefriar: And what are you trying to add to it?
[18:31:25] havenwood: codefriar: site.dig('pages', 4, 'Included Software') << extra_included_software
[18:32:38] havenwood: codefriar: https://gist.github.com/havenwood/e7dd41176b053f84d63a195ab3aed8b0
[18:36:07] havenwood: codefriar: If you're ever going to be writing from more than one process, Ruby stdlib has YAML::Store for transactional file storage in YAML.
[18:36:16] havenwood: https://docs.ruby-lang.org/en/2.6.0/YAML/Store.html
[18:37:31] havenwood: codefriar: That way, your transactions will succeed or fail together and you can enable atomic writes as well.
[18:38:06] havenwood: See the PStore docs for YAML::Store options: https://docs.ruby-lang.org/en/2.6.0/PStore.html
[19:25:56] havenwood: yoshie902a: In Ruby 2.6 you can combine lines 8 & 9 using: .to_h { |id, attrs| ...
[19:26:10] havenwood: >> def foo; __method__ end; foo
[19:26:19] havenwood: &>> def foo; __method__ end; foo
[19:26:32] havenwood: yoshie902a: __method__ is the method name as a symbol
[19:26:42] havenwood: yoshie902a: self is Product
[19:43:57] havenwood: yoshie902a: Here are some refactoring suggestions: https://gist.github.com/havenwood/ad3c014f383d122190f32f2a3fdc577b
[19:45:04] havenwood: yoshie902a: Alternatively, you could make it a *real* ActiveModel backed by the YAML. :) I gave a talk on how to back your Models with an API (or YAML file works too) at RailsConf.
[19:46:44] havenwood: yoshie902a: My talk on it will be posted here: https://www.youtube.com/playlist?list=PLE7tQUdRKcyaOq3HlRm9h_Q_WhWKqm5xc
[19:47:36] havenwood: yoshie902a: You can get pretty far with the Active Model docs: https://guides.rubyonrails.org/active_model_basics.html
[19:48:20] havenwood: yoshie902a: I'll write an article on it and maybe even show how to use YAML::Store.
[19:48:35] havenwood: You can make a fine Model backed by YAML::Store.
[19:49:07] havenwood: We should write a gem that does just that, if someone hasn't already.
[19:49:17] havenwood: If there is one, I don't know about it.
[19:49:56] havenwood: Just found: https://github.com/zilkey/active_hash
[19:50:09] havenwood: I'll look into it.
[19:50:21] havenwood: Need write support ;)
[19:51:13] havenwood: yoshie902a: My talk is "An API-Backed Model with Square's Ruby SDK", but you can use anything that can CRUD rather than an API.
[19:52:20] havenwood: yoshie902a: My talk isn't posted yet - they're just being added now.
[19:52:36] havenwood: It should be posted in the next week or two.
[19:55:57] havenwood: I don't have them ready to post. Let me take a quick stab at a generic YAML solution. I can make it work properly later.
[20:01:01] havenwood: yeah, actually thinking about this a generic one isn't going to work for your particular case - but you can make it work custom anyhow.
[21:41:19] havenwood: yosh, oh no, they left
[21:41:57] havenwood: anyhow, I got pulled into meetings and didn't finish it, but here's about half way to a YAML-based read/write model: https://gist.github.com/havenwood/f23bd816ce5535132fbcffe0d028179a
[21:42:04] havenwood: maybe i'll finish it and make it generalizable this weekend
[22:15:57] havenwood: &>> require 'bigdecimal'; require 'bigdecimal/util'; 0.to_d.frozen?
[22:17:29] havenwood: &>> require 'bigdecimal'; require 'bigdecimal/util'; require 'fiddle'; big_decimal = 0.to_d; Fiddle::Pointer.new(big_decimal.object_id << 1)[1] = 0; big_decimal.frozen?
[22:22:06] havenwood: Exuma: nothing important
[22:22:17] havenwood: Exuma: you can unfreeze things if you use Fiddle
[22:23:00] havenwood: Or freeze everything that wasn't frozen and thaw everything that was: require 'fiddle'; ObjectSpace.each_object { |object| Fiddle::Pointer.new(object.object_id << 1)[1] ^= 1 }
[22:23:05] havenwood: (Ruby won't take nicely to that.0
[22:37:11] havenwood: xco: https://ruby-community.com/ruboto/facts
[22:39:28] havenwood: I need somebody! !help. Not just anybody. !help. You know I need someone. !help


[14:04:57] havenwood: ryouba: with modern Rubies, it's faster and a bit less overhead to: yes_or_no=str.match?(regex)
[14:06:18] havenwood: ryouba: true, it wont
[14:27:56] havenwood: WolfgangGrobar: Minitest
[14:34:32] havenwood: Jonopoly: Yes, that's popular.
[18:18:22] havenwood: tubbo: the chosen few
[21:36:59] havenwood: &>> 1326767.digits.each_slice(3).map(&:join).join('_').reverse # nevada1
[21:56:06] havenwood: &>> 1326767.to_s.reverse.gsub(/(.{1,3})(?!$)/, '\1_').reverse # mikecmpbll
[22:03:08] havenwood: nevada1: 1326767.digits.each_slice(3).map { |a| a.join.reverse.to_i }
[22:10:35] havenwood: &>> 1326767.digits.each_slice(3).map { |a, b = 0, c = 0| a + b * 10 + c * 100 }
[22:19:08] havenwood: &>> 1326767.then { |n| 0.step(by: 3, to: Math.log10(n.abs).floor.succ).map { |i| n / 10 ** i % 1000 } }
[22:19:13] havenwood: nevada1: Math is fast.
[22:20:48] havenwood: Yeah, just being silly. ;)
[22:28:33] havenwood: nevada1: And the mathy `a + b * 10 + c * 100` one is fastest.
[22:28:41] havenwood: https://gist.github.com/havenwood/2e0985c044be9c5df4327b9c85848669
[22:29:46] havenwood: nevada1: It's super fast either way, so more readable might be nicer than 3x faster.
[22:30:38] havenwood: Embrace the love.
[22:33:53] havenwood: There's an ISO spec now to read! https://www.ipa.go.jp/files/000011432.pdf
[22:35:23] havenwood: mikecmpbll: I was checking on the nightly build, hmmmm. I'm curious now.
[22:37:31] havenwood: leitz: It's mostly relevant, but yeah, it doesn't cover anything recent.
[22:38:16] havenwood: mikecmpbll: I can reproduce your results... Intriguing!
[22:39:26] havenwood: mikecmpbll: It looks like it changes between 2.5 and 2.6.
[22:42:28] havenwood: mikecmpbll: step(3) is faster on 2.4 & 2.5 but b = 0, c = 0 is faster on 2.6 and dev. I guess 2.6 optimizations are paying off.
[22:43:25] havenwood: actually...
[22:43:51] havenwood: mikecmpbll: ah, I betcha that it's Enumerator Instruction Sequence...
[22:43:57] havenwood: yeah, that's gotta be it
[22:44:22] havenwood: that adds a penalty that's noticeable in this tight loop


[00:06:19] havenwood: phaul: but these days dynamically created symbols are freed!
[00:07:39] havenwood: phaul: they didn't used to be, but Ruby 2.2 added Symbol GC after a nasty Rails DOS: https://bugs.ruby-lang.org/issues/9634
[00:09:27] havenwood: pengin: Symbols make the most elegant Hash keys.
[14:27:16] havenwood: ryouba: privateness is usually focused on the public interface of instances, and you can get at neither the private method nor private constant directly - so that's working well
[14:27:38] havenwood: myobj.helpermethod #!> NoMethodError: private method `helpermethod'
[14:31:28] havenwood: ryouba: Do you want `myobj.modmethod` to work?
[14:31:43] havenwood: phaul: yeah, isn't that a it bizarre. it's like module_function behavior.
[14:32:14] havenwood: ryouba: module_function would make #modmethod only available inside of the including class, but not expose it as a public method
[14:33:05] havenwood: ryouba: compare when you do or don't put a module_function in MyModule. Right now #modmethod is exposed publicly on the including class instance.
[14:34:11] havenwood: myobj.class::MyHelper #!> NameError: private constant MyModule::MyHelper referenced # phaul
[14:34:45] havenwood: phaul: i didn't know about that quirk either
[14:35:38] havenwood: ryouba: MyClass::MyHelper # fails (good)
[14:36:38] havenwood: ryouba: I mean like 26 or 30
[14:36:47] havenwood: ryouba: the private constant isn't visible from outside the class
[16:13:05] havenwood: require 'io/console'; IO.console.getpass 'What is the capital of Assyria?'
[18:07:52] havenwood: The RailsConf 2019 videos are starting to get posted. Here's DHH's keynote: https://youtu.be/VBwWbFpkltg
[18:11:13] havenwood: https://www.youtube.com/playlist?list=PLE7tQUdRKcyaOq3HlRm9h_Q_WhWKqm5xc
[18:30:53] havenwood: jeremycw: Are you familiar with ioquatix's async libraries? https://github.com/ioquatix
[18:31:20] havenwood: Instead of serializing procs, you can suspend fibers and resume later.
[23:36:06] havenwood: weaksauce: I like Active Job with Action Cable for that: https://blog.jakewilkins.com/2017/08/25/building-something-besides-a-chat-app-with-actioncable/
[23:42:58] havenwood: weaksauce: The MessageBus gem is solid if you want to avoid WebSockets, for whatever reason: https://github.com/SamSaffron/message_bus
[23:43:49] havenwood: weaksauce: no prob!


[14:22:54] havenwood: mXr: Which part isn't working? Is Rails generating the appropriate routes with the nesting path prepended? (That's the part `config.relative_url_root =` handles.)
[14:25:44] havenwood: mXr: If you manually start your app on a port locally, is `/gw/` prepended to links Rails generates?
[14:26:10] havenwood: mXr: If so, #relative_url_root= is working.
[17:33:39] havenwood: dretnx: Node.js was based in part on EventMachine, a Ruby library, iir. The author of Node was a Rubyist.
[17:34:34] havenwood: dretnx: These days, check out the Socketry libraries: https://github.com/socketry
[17:35:57] havenwood: dretnx: See Falcon for an example of putting these primitives together into a web server: https://github.com/socketry/falcon
[17:36:17] havenwood: dretnx: We could probably give you better answers if you say more about the perspective you're looking from. Are you doing IO? Computation?
[17:37:19] havenwood: dretnx: For web?
[17:39:24] havenwood: dretnx: Ruby is a lot of fun, give it a try! (Crystal too.)
[17:39:33] havenwood: dretnx: Here's a recent talk about the state of async in Rubyland: https://youtu.be/qKQcUDEo-ZI
[17:39:57] havenwood: TL;DR: Great work going on with async in Ruby.
[18:11:36] havenwood: Threaded web servers like Puma and Passenger also use an evented reactor too, and forking as well.
[20:18:43] havenwood: happyhans: https://www.ruby-toolbox.com
[20:28:31] havenwood: happyhans: Yes, but it's not open source yet. Stay tuned.
[20:28:52] havenwood: happyhans: Steep is already open source, if you want to look at an alternative: https://github.com/soutaro/steep
[20:29:32] havenwood: happyhans: Ruby 3 should have a standard .rbi format so you can use either of these tools, or others.


[13:11:49] havenwood: sonivi: What have you tried so far? Show the code?
[14:05:56] havenwood: sonivi: Here's your curl code translated to Net::HTTP: https://gist.github.com/havenwood/1d1ed51408b6fd8aa0048a21a8728fd5
[14:06:27] havenwood: sonivi: This tool will get you pretty close: https://jhawthorn.github.io/curl-to-ruby/
[14:15:00] havenwood: sonivi: You could convert that tool's logic to Ruby: https://github.com/jhawthorn/curl-to-ruby/blob/gh-pages/src/curlToRuby.js
[14:15:15] havenwood: sonivi: You have actual curl commands as input or something? :O
[18:18:38] havenwood: IGnorAND: Use an underscore as a placeholder.
[18:18:48] havenwood: IGnorAND: def foo(bar, _)
[18:19:06] havenwood: IGnorAND: Huh?
[18:20:29] havenwood: IGnorAND: Those are keyword arguments.
[18:23:08] havenwood: IGnorAND: It's a common pattern to set a default value to `nil`.
[18:23:24] havenwood: IGnorAND: You could see which are set. Are they ever both set? Neither set?


[14:58:50] havenwood: randomuseragain: Usually it's due to multiple Rubies installed. Does it work with `bundle exec rake db:migrate`?
[14:59:18] havenwood: randomuseragain: Sanity check `which bundle` and `gem which bundler`? It's the right Ruby?
[15:00:41] havenwood: randomuseragain: From those warnings, look like you might need a: gem pristine --all
[15:01:33] havenwood: randomuseragain: In modern Rails, the `rake` commands are aliased to `rails`, so you can: bin/rails db:migrate
[15:02:22] havenwood: randomuseragain: So first run just: bundle
[15:06:11] havenwood: randomuseragain: It seems there are two Rubies involved here, a system one and an RVM one.
[15:06:21] havenwood: randomuseragain: Is Bundler installed on your current Ruby?
[15:06:27] havenwood: randomuseragain: gem which bundler
[15:06:33] havenwood: randomuseragain: If not: gem install bundler
[15:06:55] havenwood: randomuseragain: You need to be able to install the gems from the Gemfile.lock to run the app.
[15:07:12] havenwood: randomuseragain: As the error suggests, you can vendor them if you want to install locally in the app directory.
[15:07:50] havenwood: randomuseragain: You don't have write permission for your own home dir?
[15:08:24] havenwood: randomuseragain: rvm fix-permissions
[15:08:58] havenwood: randomuseragain: Install gems somewhere you have permission to install gems. Run `bundle` from the account that can install gems.
[15:11:08] havenwood: randomuseragain: gem install bundler
[15:11:18] havenwood: randomuseragain: gem which bundler
[15:12:12] havenwood: randomuseragain: (there's an "r" in the gem name, but not the command)
[15:12:30] havenwood: randomuseragain: rvm fix-permissions
[15:13:22] havenwood: randomuseragain: Is that your own home dir? Seems there are a lot of permissions issues going on.
[15:20:12] havenwood: randomuseragain: ah, cool
[15:27:23] havenwood: randomuseragain: Now that Bundler's working on your primary account, from there run: bundle
[15:31:08] havenwood: randomuseragain: Usually to share gems between accounts, you'd either use vendor gems locally into the app directory or use a system gem installation both can share. Alternatively, you could install gems separately for both accounts.
[16:01:53] havenwood: randomuseragain: Rake actually is a gem!
[16:03:31] havenwood: randomuseragain: Along with did_you_mean, minitest, net-telnet, power_assert, test-unit and xml-rpc - rake is a "bundled" gem that ships along with Ruby.
[16:03:47] havenwood: Unlike default gems, which also ship with Ruby, bundled gems can be uninstalled.
[16:03:55] havenwood: Default gems can be updated, but not uninstalled.
[16:04:25] havenwood: No, rake is a bundled gem.
[16:05:11] havenwood: But yes, it ships with Ruby.
[16:06:32] havenwood: Default gems are bigdecimal, io-console, json, openssl, psych, rdoc, rubygems, webrick, cmath, csv, date, dbm, gdbm, sdbm, etc, fcntl, zlib, strscan, stringio, scanf, ipaddr, fileutils and fiddle. A bunch were gemified from the stdlib in 2.5.


[02:43:57] havenwood: Caerus: Yes, they'll upload most of the talks.
[02:44:20] havenwood: Caerus: There were some talks that weren't listed as being recorded, but most were.
[02:46:53] havenwood: Caerus: You'll be able to find them here as they're uploaded: http://confreaks.tv/events/railsconf2019
[02:47:02] havenwood: This is suspiciously on topic!
[15:12:30] havenwood: j`ey: rjust?
[15:12:45] havenwood: ljust doesn't seem right (zeros on the right)
[15:29:19] havenwood: j`ey: I'm curious about the context. Seems it's already hex, so wouldn't just ljust suffice?
[15:29:40] havenwood: rjust*, haha
[15:30:36] havenwood: j`ey: you can do: s.hex
[15:30:52] havenwood: &>> '0xa'.hex
[15:33:40] havenwood: &>> '%02x' % '0xa'.hex
[15:33:52] havenwood: &>> format '%02x', '0xa'.hex
[17:26:18] havenwood: Nebros: Opal is a gem. Once you've installed Ruby, you can: gem install opal
[17:27:01] havenwood: Nebros: On Windows, you can install Ruby with the RubyInstaller for Windows, with the Chocolatey package manager or with the Windows Subsystem for Linux (WSL).
[17:28:00] havenwood: Nebros: Opal does work from Windows.
[17:52:18] havenwood: xco: I think you meant to invert one of the `array & set1`s!
[17:52:19] havenwood: They're the same order on both sides of the ||
[17:53:12] havenwood: xco: I think `any?` would be nice here in place of `size.positive?`, which is pretty nice too
[17:53:50] havenwood: I commented on your Gist with another approach.
[17:54:01] havenwood: I also renamed everything! :P
[18:01:32] havenwood: xco: I left another comment with a #sum alternative to #reduce
[18:02:18] havenwood: xco: #any? / #include? is a common pattern
[18:11:57] havenwood: yup, exactly
[18:12:19] havenwood: and the reason to extract it to a constant is to only create that array of arrays one time, when the class is initially defined
[18:12:44] havenwood: xco: #include? doesn't dig recursively, it only checks the top level
[18:12:59] havenwood: &>> [[42]].include? 42
[18:14:31] havenwood: xco: But at that point it's `category` not `categories`.
[18:14:55] havenwood: &>> [[42]].first.include? 42
[18:15:22] havenwood: &>> [[42]].any? { |n| n.include? 42 }
[18:15:44] havenwood: bad variable naming there ^, I meant `a` not `n`.
[18:16:39] havenwood: xco: The idea behind it being a list of lists is that you can add a new category to categories and it'll *just work* without changing any logic
[18:17:56] havenwood: xco: you could alternatively write that: next(count + 1)
[18:18:18] havenwood: xco: yes, onto the next iteration
[18:19:09] havenwood: ah, you can pass the keyword the return value for the current iteration, and it'll go right onto the next
[19:01:56] havenwood: xco: "doh" not "dog" :P


[20:52:28] havenwood: xco: Yes, you can enable the extension in a migration. It's a one-liner.
[20:53:12] havenwood: xco: You can ditch lines 12-15 now.
[20:53:21] havenwood: oh, you're using cty
[20:53:44] havenwood: xco: ditch lines 12-13 & 14
[20:54:36] havenwood: xco: Awesome! Another neat thing to remember is that Postgres supports Trigrams with indexes, which work great with Rails: https://www.postgresql.org/docs/current/pgtrgm.html
[20:54:58] havenwood: xco: That lets you accommodate typos, etc, and still find the nearest matches.
[20:55:08] havenwood: xco: And... it's indexable with Rails!
[20:55:36] havenwood: https://scoutapm.com/blog/how-to-make-text-searches-in-postgresql-faster-with-trigram-similarity
[20:55:49] havenwood: xco: Yes, this is the pg_trgm extension.
[20:56:27] havenwood: xco: But, these are typically available with Postgres - they're the common extensions. You can use them on Heroku, etc, just out of the box after enabling them with a oneliner in a migration.
[20:56:56] havenwood: https://scoutapm.com/blog/pg_trgm-autocorrect