Activity Graph

Page 1 of 208 | Next »


[04:50:12] havenwood: nchambers: return enum_for __method__ unless block_given?
[04:50:20] havenwood: nchambers: https://gist.github.com/havenwood/236d387827c16695b55a7799770d8da1
[04:51:08] havenwood: nchambers: If you know the size of the Enumerator, you might want to also provide a lazily calculated size to your enum.
[04:52:19] havenwood: nchambers: an alias for #to_enum
[04:53:07] havenwood: nchambers: and `__method__` is just `:each`
[04:53:23] havenwood: nchambers: just a little more resilient to method name changes
[04:53:51] havenwood: no prob, you're welcome!
[04:55:45] havenwood: for a lazily calculated size of 2, for example: return enum_for(__method__) { 2 } unless block_given?
[08:47:02] havenwood: baweaver: Great posts!


[15:25:11] havenwood: &>> [:ru, :en].each_with_index.to_h # xerxes
[15:25:40] havenwood: #to_h gets even nicer in 2.6!
[15:40:11] havenwood: marahin: Does it work as you expect with just:
[15:40:12] havenwood: begin; sleep; rescue Interrupt; abort 'interrupted' end
[15:43:19] havenwood: marahin: Does it continue to run when either jobs fail or it's interrupted?
[15:44:43] havenwood: marahin: Are you in a modern Ruby where: Thread.report_on_exception = true
[15:44:45] havenwood: marahin: Or set: Thread.abort_on_exception = true
[15:48:52] havenwood: marahin: Are subshells involved in your jobs?
[15:49:09] havenwood: I suspect zombies.
[15:49:46] havenwood: marahin: Shelling out to commands. Yeah, looks like so: https://gist.github.com/Marahin/6f68bc9cfa2527cde06091d95afd88b8#file-ci-rb-L19
[15:51:20] havenwood: marahin: I'd suggest looking at spawning processes rather than shelling out from threads. Sec, let me find an article.
[15:51:48] havenwood: marahin: https://saveriomiroddi.github.io/Executing-and-killing-ruby-parallel-background-jobs/
[16:00:51] havenwood: marahin: The 0 signal is handy for that.
[16:02:05] havenwood: marahin: Process.kill 0, pid
[16:04:01] havenwood: marahin: `kill -0` just checks if a process exists
[16:06:25] havenwood: marahin: Jesse Storimer wrote a great little book on Processes in Ruby that's worth a read.
[16:06:59] havenwood: The TCP and Thread ones are good too: https://www.jstorimer.com/pages/books
[16:09:41] havenwood: marahin: Or for most platforms you can use Process::getpgid: https://docs.ruby-lang.org/en/2.5.0/Process.html#method-c-getpgid
[16:10:41] havenwood: (Not Windows.)
[16:12:26] havenwood: marahin: join or detach those processes - in your case here, looks like you want to joinn
[16:12:49] havenwood: marahin: ah, you did detach them
[16:13:11] havenwood: marahin: if you join main process won't exit
[16:13:27] havenwood: marahin: it's done
[16:13:57] havenwood: marahin: ahh, gotcha - i misunderstood - yeah
[16:14:19] havenwood: marahin: does `binding.irb` work or same?
[16:14:44] havenwood: marahin: I don't see an obvious reason for pry to fail here
[16:15:08] havenwood: marahin: ah, it's only in newer Ruby
[16:15:24] havenwood: I think it was introduced in 2.4
[16:15:35] havenwood: marahin: I'm not sure why Pry isn't playing nice.
[16:15:57] havenwood: marahin: your code looks straightforward
[16:18:56] havenwood: marahin: I'm assuming this example doesn't fail if you change the jobs to be say "ls" and "pwd"?
[16:20:35] havenwood: marahin: Is it `rspec_rerun` or `quality` causing the issue?
[16:22:07] havenwood: You might want to also take a look at: spawn


[07:00:10] havenwood: Quit: ZNC 1.7.1 - https://znc.in
[07:00:53] havenwood: has joined #RubyonRails-offtopic
[07:00:53] havenwood: Changing host
[07:00:53] havenwood: has joined #RubyonRails-offtopic
[07:01:23] havenwood: has joined #ruby-offtopic
[07:01:23] havenwood: has joined #ruby
[07:01:23] havenwood: has joined #RubyOnRails
[08:13:19] havenwood: marz_d`ghostman: abort 'foo'
[08:13:45] havenwood: marz_d`ghostman: Or say more about what you're wanting to do?
[10:10:55] havenwood: Quit: ZNC 1.7.1 - https://znc.in
[10:12:36] havenwood: has joined #RubyonRails-offtopic
[10:12:37] havenwood: has joined #RubyonRails-offtopic
[10:12:37] havenwood: Changing host
[10:12:45] havenwood: has joined #ruby-offtopic
[10:12:45] havenwood: has joined #ruby
[10:12:45] havenwood: has joined #RubyOnRails


[05:56:14] havenwood: hays: It's either equal or not? There's not greater than, less than, etc?
[05:57:31] havenwood: hays: Defining #== makes sense if you want to check `==` and `!=`.
[05:57:53] havenwood: hays: If you want more comparisons, `include Comparable` and define #<=>.
[05:58:48] havenwood: hays: Usually you define a public #== method.
[05:59:22] havenwood: hays: You might consider also defining #eql? and #=== for your custom class, if those make sense.
[06:01:02] havenwood: hays: it's the method argument
[06:01:53] havenwood: &>> class NeverEqual; def == _; false end end; NeverEqual.new == 42
[06:04:03] havenwood: hays: ah, I see what you're asking
[06:04:27] havenwood: hays: you can use meta-programming to get at private methods, when that makes sense
[06:04:59] havenwood: hays: other.send(:a)
[06:05:13] havenwood: other.instance_method_get(:@a)
[06:05:58] havenwood: hays: yes, that's where you also might define #eql?, since: 1.eql?(1.0) #=> false
[06:06:33] havenwood: hays: you can #send if #a is private or get the instance method if there's no method at all.
[06:07:28] havenwood: hays: or respond to #to_int
[06:09:53] havenwood: hays: #to_int is a special conversion just for this case, slightly different from #to_i
[06:10:28] havenwood: hays: === is for case statements, and predicate enumerable methods, and other such implicit use
[06:10:48] havenwood: those are for these implicit conversions, rather than explicit use
[06:11:09] havenwood: (by convention and stdlib pattern)
[06:11:23] havenwood: core/stdlib
[06:11:53] havenwood: hays: yeah, there's no #to_flt
[06:13:05] havenwood: hays: to_int, to_str, to_ary, to_hash
[06:13:53] havenwood: hays: https://zverok.github.io/blog/2016-01-18-implicit-vs-expicit.html


[05:10:10] havenwood: relyks: The Ruby manpage agrees!:
[05:10:11] havenwood: "If you want a language for easy object-oriented programming, or you don't like the Perl ugliness, or you do like the concept of LISP, but don't like too many parentheses, Ruby might be your language of choice."
[05:10:41] havenwood: Also a Perl burn.


[00:01:37] havenwood: assuming those Hashes are always just like that:
[00:01:41] havenwood: ule[:filters].replace([{"name"=>"Company", "value"=>"17"}, {"name"=>"Company", "value"=>"111"}])
[20:59:20] havenwood: Pillus: I think your template example looks good. Missing a `require 'json'` it seems. I commented with a few nit style suggestions.
[21:02:00] havenwood: Pillus: Just running `rubocop -a` with the rubocop gem will cover most style issues to a reasonable degree.
[21:07:50] havenwood: Pillus: I don't usually use Net::HTTP actually, so I'm not the best person to ask. There are others here who do. Slow Sunday though.
[21:07:54] havenwood: Looks likeURI.encode_www_form and #set_form_params.


[17:40:49] havenwood: phaul: think this looks like a draw?
[17:41:48] havenwood: no doubt - that was a neat game
[17:42:10] havenwood: magnus played crazy
[23:59:30] havenwood: ule[:filters].find { |h| h.values_at('name', 'value') == %w[Company 17] }['value'] = '111'


[02:26:15] havenwood: On modern Ruby, `chomp: true` is a nifty addition: File.readlines('json', chomp: true)
[15:45:12] havenwood: Tohm3: Try going from PHP 5 to PHP 6! :P
[16:36:08] havenwood: Roda's site got a nice overhaul: http://roda.jeremyevans.net/
[21:05:34] havenwood: &>> [1, 2, 3].sample 4 # Eiam
[21:06:30] havenwood: &>> [1, 2, 3].sample 2
[21:10:33] havenwood: &>> puts '💪o💪'.gsub(?💪) { %w[/ \\].sample }
[21:12:49] havenwood: Bish: I'd probably write that something like:
[21:12:50] havenwood: 6.times.map { [*0..5].sample rand 1..5 }
[21:14:31] havenwood: &>> [*0..5]
[21:15:51] havenwood: Mm, `Array.new(n)` is also a bit nicer than `6.times.map`.
[21:15:56] havenwood: Array.new(6) { [*0..5].sample rand 1..5 }
[21:16:23] havenwood: One fewer method calls.
[22:07:31] havenwood: i was, until work rudely interrupted
[22:07:41] havenwood: great game up to move 30!
[22:07:55] havenwood: deep endgame now?
[22:07:59] havenwood: caruana holding on?
[22:08:32] havenwood: what a match...


[01:08:59] havenwood: anyoen: No, I don't think Node.js sounds like a much better fit from what you've said so far.
[01:09:29] havenwood: anyoen: Are you running into scaling issues? Or what's the problem?
[01:10:16] havenwood: anyoen: Something like Phoenix with Channels might be a better fit, if you're running into scaling issues.
[01:11:27] havenwood: anyoen: https://hexdocs.pm/phoenix/channels.html
[01:11:40] havenwood: anyoen: Say more about the issues you're concerned with?
[01:15:29] havenwood: anyoen: I was working with Ruby and Node.js alongside BLE in 2014 - and I wish Elixir was around then :)
[01:16:34] havenwood: err, I mean Ruby and Python
[01:17:29] havenwood: (pre ActionCable days)
[01:26:11] havenwood: WebSockets backed by Thread::Light might be a different story, soon... :)
[01:28:30] havenwood: I spun up a million on my laptop before i got bored
[01:28:38] havenwood: it did take a while
[01:29:29] havenwood: (and nobody likes my Thread::Feather idea)
[01:31:47] havenwood: nchambers: a thread as light as a feather, right?! :)
[01:37:28] havenwood: https://bugs.ruby-lang.org/issues/13618
[01:37:38] havenwood: "Sorry, but no to "Feather". Again, I don't want to introduce new usage of words."
[17:07:49] havenwood: &>> ?\M-\cx.b.ord
[17:08:01] havenwood: al2o3-cr: heh, yikes
[18:35:20] havenwood: phaul: nice!


[04:33:05] havenwood: 'halloooo'.tr('a', 'e').squeeze('o')
[04:36:14] havenwood: Are we far enough past 1.8 we can safely embrace ?x character literal?
[04:36:31] havenwood: ACTION leans towards "yes"
[04:40:39] havenwood: 'halloooo'.tr(?a, ?e).squeeze(?o)
[17:09:53] havenwood: nsxt: In Ruby 1.8 and earlier, the character literal returned an integer. Then in 1.9 it changed to return the single-character string.
[17:10:20] havenwood: nsxt: Because of the breaking change, it fell into disfavor. That should probably change now that 1.8 is long gone.
[17:10:43] havenwood: 1.8: ?x #=> 120
[17:10:50] havenwood: 1.9: ?x #=> "x"
[17:15:38] havenwood: %i() etc are also hard to google, but not too bad to cover in a quick ref
[17:16:40] havenwood: i was just watching a presentation on how android studio helps new devs discover what things are
[17:18:09] havenwood: i don't know that there's an ide smart enough to reveal what a char literal is in Ruby
[17:18:50] havenwood: i guess it's not hard to pull from Ripper or disassembled YARV.
[17:30:44] havenwood: it's a shame GitHub, Google, etc fail at symbols
[17:31:07] havenwood: SymbolHound does find it
[18:58:46] havenwood: cjohnson: hrm, my first thought is something like: get 'opportunities/:key', to: redirect('/clinical-alerts-plus/opportunities/%{key}')
[18:59:19] havenwood: cjohnson: seems there might be a better way, but unsure ¯\_(ツ)_/¯
[19:00:14] havenwood: I don't know of a `forward_to_namespace` type block. Hmmm


[14:34:22] havenwood: Bish: You could run unicorn with `rackup`, but then it'll just be the path to rackup executable. If you put `PROGRAM_NAME = $0.dup` in http_server.rb, you could get at that, but again it'd be path to the unicorn executable.
[14:40:12] havenwood: Bish: How's it run when you don't want to? use_cache!
[14:46:32] havenwood: Bish: Maybe something like: %w[client_api_server rackup unicorn].include? File.basename $PROGRAM_NAME[/\A\S+/]
[17:10:59] havenwood: https://www.ruby-lang.org/en/news/2018/11/06/ruby-2-6-0-preview3-released/
[17:32:15] havenwood: craftytech: puma --debug
[17:32:39] havenwood: ruby-install --latest ruby-2.6.0-preview3
[18:20:05] havenwood: za1b1tsu: Don't want to type `bundle exec`?
[18:29:55] havenwood: za1b1tsu: You can use rubygems-bundler outside of RVM, but I don't. I guess I just like explicit more than I dislike typing `bundle exec`.
[18:30:56] havenwood: za1b1tsu: https://i.imgur.com/2Hlpoov.png
[20:15:18] havenwood: voelzmo: One option would be to use the ruby-versions repo, which ruby-install consumes for Ruby metadata: https://github.com/postmodern/ruby-versions
[20:16:34] havenwood: voelzmo: A while ago I needed something similar, and used the FTP mirror to get at it: https://gist.github.com/havenwood/4395461
[20:16:51] havenwood: kaleido: <3 Roda
[20:17:21] havenwood: voelzmo: ruby-versions has the md5, sha1, sha256 and sha512 - and the dl url can be composed from the version
[20:17:57] havenwood: kaleido: It's really, really nice. :)
[20:18:26] havenwood: kaleido: If you want something more Rails-inspired, Hanami is another nice option: https://hanamirb.org/
[20:18:46] havenwood: kaleido: I love Roda's simplicity, being just a routing tree with optional plugins: http://roda.jeremyevans.net/
[20:18:52] havenwood: voelzmo: You're welcome!
[20:20:22] havenwood: voelzmo: I don't know why it doesn't always get updated. I think this has happened before. I'm not sure what's the matter.
[22:09:54] havenwood: biberao: here are a few books: https://gist.github.com/baweaver/57a7c8296ca2c03effbd8fac1e7f6b40#learning-ruby
[22:10:11] havenwood: biberao: and more links: https://ruby-community.com/pages/links
[22:10:28] havenwood: biberao: and a few more: https://www.ruby-lang.org/en/documentation/
[22:10:44] havenwood: biberao: Feel free to ask questions here!
[22:11:16] havenwood: biberao: If you're familiar with REPLs, Ruby has great ones. I'd suggest getting started with irb or pry early.
[22:14:54] havenwood: biberao: Welcome to Ruby!
[22:18:17] havenwood: biberao: Do you have Ruby installed yet?
[22:18:44] havenwood: biberao: Awesome, you're ahead of the game!


[23:34:54] havenwood: hightower3: Modern Ruby now has #transform_keys and #transform_values.
[23:35:51] havenwood: hightower3: Ruby 2.6 will have #to_h, which is like #transform_keys_and_values.
[23:36:10] havenwood: {aim: true}.to_h { |k, v| [k.to_s, v.to_s] } #=> {"aim"=>"true"}
[23:39:16] havenwood: ivanskie: You did what? I don't follow. Have an example of how you use the hacked version?
[23:43:54] havenwood: ivanskie: So it's the help banner that's messed up?
[23:46:12] havenwood: ivanskie: I wonder if redefining `self.basename` would cause trouble ;)
[23:46:24] havenwood: ivanskie: you can always overwrite `self.banner`: https://gist.github.com/mattheworiordan/f3e84964bb699525a435


[16:35:37] havenwood: zxq2: Show us what you have so far?
[16:36:01] havenwood: zxq2: Can you say more about what "initialize during instantiation" means?
[16:37:09] havenwood: zxq2: Passing a hash to a constructor with values seems reasonable. What issue are you running into trying that?
[16:39:03] havenwood: zxq2: Have you tried doing that? What seems to be not working? Can you show the code?


[06:01:27] havenwood: JJonah: class Enumerator; def [] i; lazy.drop(i).first end end
[06:29:35] havenwood: warrshrike: you're not checking the node's #left
[06:29:46] havenwood: warrshrike: you're checking an undefined instance variable
[06:30:01] havenwood: >> @left #=> nil
[06:31:22] havenwood: warrshrike: here's a bit more Ruby style for your code: https://gist.github.com/havenwood/836ea8e9c6f40f26e41aa8a09a378322
[06:32:44] havenwood: warrshrike: within an instance feel free to use instance variables
[06:33:05] havenwood: warrshrike: use methods to expose instance variables outside the instance
[06:33:58] havenwood: warrshrike: i meant it to be the same as yours, with a few stylistic changes
[06:34:21] havenwood: warrshrike: baweaver works at Square too! lots of Ruby!!
[06:35:05] havenwood: baweaver: yeah, i stopped myself from going further for example simplicity sake - but i thought the same
[06:35:32] havenwood: warrshrike: it's easier to read when calling the method, huh? i like kwargs a lot.
[06:36:10] havenwood: warrshrike: keyword argument
[06:36:36] havenwood: the left: and right: are optional keyword arguments
[06:37:05] havenwood: you could do just `left:` for a mandatory keyword argument
[06:37:11] havenwood: providing the default `left: nil` makes it optional
[06:38:05] havenwood: warrshrike: correct
[06:40:39] havenwood: warrshrike: Blocks are a way to not instantiate an object for the function. Procs and lambdas are first class.
[06:42:00] havenwood: warrshrike: They actually also follow tennent's correspondence principle, with different locality of return for procs and lambdas.
[06:42:40] havenwood: warrshrike: you can though
[06:48:41] havenwood: warrshrike: there are many ways to do similar in Ruby
[06:48:45] havenwood: warrshrike: one example: https://gist.github.com/havenwood/de989d533cb8ea13daf3671a6cf057f0


[00:01:51] havenwood: phaul: a Hash is a doubly-circularly linked list already :)
[00:02:37] havenwood: phaul: yeah, I don't get much occasion to implement one mysellf
[00:55:19] havenwood: phaul: Since Ruby 1.9 it's been this implementation: https://www.igvita.com/2009/02/04/ruby-19-internals-ordered-hash/
[00:55:32] havenwood: phaul: Then in 2.4 it got some nice changes: https://blog.heroku.com/ruby-2-4-features-hashes-integers-rounding#hash-changes
[00:56:04] havenwood: phaul: And in Ruby 2.5 they switched from SipHash24 to SipHash 13 - following Rust's lead.
[00:58:06] havenwood: (One c round and three d rounds.)
[00:58:30] havenwood: "full cycle linear congruential generator" - has a ring to it
[01:00:46] havenwood: "a Hash is also a doubly-circular linked list!" ~ Ilya Grigorik
[01:01:21] havenwood: phaul: My girlfriend only allow me one pedantry per day. I've already used todays!
[01:01:51] havenwood: She usually uses her's earlier in the day than I do. :P
[01:07:35] havenwood: phaul: it was a grueling trip, but got some good work done.
[17:10:55] havenwood: phaul: In nightly: #!> `<main>': undefined method `a' for main:Object (NoMethodError)
[17:11:21] havenwood: Will be fixed in 2.6.0-preview3
[17:31:53] havenwood: eam: I agree.
[17:33:24] havenwood: phaul: it has it's own object model and is so far from the simplest thing that can possibly work - with benefits that seem dubious at best
[17:34:19] havenwood: I do wish Minitest had some ExUnit niceties to allow fewer custom asserts and still have nice error messages
[21:52:43] havenwood: bootstrappm: In-person in Boston or remote?
[21:52:59] havenwood: bootstrappm: Have you tried the Boston Ruby Meetup?
[22:31:09] havenwood: JJonah: lazy.drop(index).first
[22:32:36] havenwood: >> 'JJonah'.each_char.cycle.lazy.drop(42).first


[15:49:38] havenwood: "the use of class variables is not recommended (like global variables)" ~Matz
[15:50:01] havenwood: dachi: This is the best thread to follow for the issue: https://bugs.ruby-lang.org/issues/14541
[15:51:32] havenwood: Inside: Singleton is one of the stdlib libs that Matz himself maintains!
[15:56:44] havenwood: Inside: When you actually only have one instance of state, they're great.
[15:57:03] havenwood: Inside: Modules for no state, pure functions. Singletons for a single instance of state. Classes for multiple instances of state.
[23:50:46] havenwood: hi warrshrike
[23:51:07] havenwood: warrshrike: what do you mean by "unique"?
[23:52:11] havenwood: SipHash13 ftw.
[23:55:30] havenwood: warrshrike: See: https://ruby-doc.org/core-2.5.3/Object.html#method-i-eql-3F
[23:57:24] havenwood: warrshrike: equal? checks object id, so "" isn't #equal? to another ""
[23:58:43] havenwood: warrshrike: h.rehash
[23:59:27] havenwood: warrshrike: it's pass by reference to a value, which is an object ¯\_(ツ)_/¯