baweaver

Activity Graph

Page 1 of 257 | Next »

2019-03-18

[05:14:27] baweaver: https://medium.com/@baweaver/ruby-2-7-numbered-parameters-3f5c06a55fe4

2019-03-14

[23:03:16] baweaver: zenspider: evil me is writing in only double-quotes for the book
[23:03:39] baweaver: It feels like a bad idea to teach newbies otherwise, too much potential for confusion for very little gain.
[23:07:02] baweaver: cxl: HIRB, but it hasn't been updated in quite a while: http://tagaholic.me/hirb/doc/index.html
[23:07:59] baweaver: Fair. Trying not to add a ton of nuance to the book, and more of just "do it this way"

2019-03-11

[17:19:41] baweaver: Excess Flood
[17:19:51] baweaver: has joined #RubyonRails-offtopic
[17:19:51] baweaver: has joined #elixir-lang
[17:19:51] baweaver: has joined #logga
[17:19:51] baweaver: has joined #ruby
[17:19:51] baweaver: Changing host
[17:19:51] baweaver: has joined #ruby
[17:19:51] baweaver: has joined #logga
[17:19:51] baweaver: has joined #elixir-lang
[17:19:51] baweaver: has joined #RubyonRails-offtopic
[17:20:26] baweaver: has joined #ruby-offtopic
[17:20:26] baweaver: has joined #RubyOnRails

2019-03-08

[22:21:42] baweaver: sagax: Use begin / rescue
[22:31:58] baweaver: sagax: Use begin / rescue, you'll have a lot easier time.
[22:32:08] baweaver: What code do you _need_ it for?
[22:32:27] baweaver: begin / rescue can also return a result.
[22:33:12] baweaver: Very often when one thinks they _need_ a language feature that's not entirely accurate. It depends heavily on context, and sometimes we're bent on shoehorning our problem to match.
[22:33:43] baweaver: What problem are you trying to solve?
[22:33:44] baweaver: because it sounds a lot like `break` or `next`
[22:34:11] baweaver: You're fixating on try/catch, not your actual problem.
[22:34:18] baweaver: Do you have a code example?
[22:34:38] baweaver: You can use `return` for that as well.
[22:35:22] baweaver: Can you show us some example code?: https://dpaste.de
[22:35:44] baweaver: What if we said that try/catch is ugly?
[22:35:55] baweaver: If you're bent on using it, use it.
[22:36:32] baweaver: leftylink: fixation is fun.
[23:08:08] baweaver: Yeah, just use `return`.
[23:09:04] baweaver: You're not gaining any clarity there.
[23:09:43] baweaver: If anything you're trying to ad-hoc on pattern matching
[23:10:01] baweaver: It's an approximation of an Either type.
[23:10:32] baweaver: You're using throw/catch as a psuedo-either type to pass additional context with returns
[23:10:49] baweaver: It's more commonly known as Railway Oriented Programming: https://fsharpforfunandprofit.com/rop/
[23:11:42] baweaver: I'm not really sure what you want here.
[23:11:44] baweaver: You're fixated on one solution, so just use it.
[23:11:53] baweaver: Just be warned it's not very common and will likely confuse other programmers.
[23:22:35] baweaver: How's things phaul?

2019-03-07

[04:53:38] baweaver: has joined #RubyonRails-offtopic
[04:53:39] baweaver: has joined #RubyOnRails
[04:53:40] baweaver: has joined #ruby-offtopic
[04:53:43] baweaver: has joined #elixir-lang
[04:53:44] baweaver: has joined #ruby
[04:53:45] baweaver: has joined #logga
[22:20:27] baweaver: ACTION reads back
[22:21:12] baweaver: What's `nwserver` doing BoomerBile?
[22:21:36] baweaver: Left I guess.
[22:21:55] baweaver: al2o3-cr: Doesn't really read like bashing, just annoyance at something breaking.

2019-03-01

[23:26:29] baweaver: Darmani: How do blocks work in Ruby?
[23:26:55] baweaver: Give you a hint: they're not parens in this case.
[23:27:08] baweaver: Also that scan isn't going to do what you think it will.
[23:27:33] baweaver: Also it's `grade`, not `string`
[23:27:57] baweaver: psuedo code might not run so well in Ruby :P
[23:28:15] baweaver: also `sort_by` only works on Enumerable types.
[23:28:29] baweaver: Is the grade a string or what is it?
[23:28:40] baweaver: If it's an array you might want to call it grades instead.
[23:28:48] baweaver: and also split the string
[23:29:08] baweaver: Line 5 though, that's a string?
[23:29:42] baweaver: What's an example of input?
[23:29:46] baweaver: and the expected output?
[23:30:42] baweaver: What's in the string?
[23:30:53] baweaver: and what's a greade
[23:31:02] baweaver: Anything doesn't really help.
[23:31:09] baweaver: There we go
[23:31:28] baweaver: and you want to sort by those grades lexically? (alphabetical order)
[23:31:54] baweaver: You want sort, which yields two items
[23:32:11] baweaver: collection.sort { |a, b| ... }
[23:32:27] baweaver: sort_by if you have a property available
[23:32:49] baweaver: I wonder...
[23:33:06] baweaver: &>> %w(A+ F B- B B+).sort
[23:33:45] baweaver: So it'll get the letter right, you just have to give a higher priority to the +.
[23:33:46] baweaver: which property?
[23:33:56] baweaver: No, that's what you're sorting
[23:34:01] baweaver: each item would have a property
[23:37:17] baweaver: Make a map for the second property
[23:37:45] baweaver: yeah, sort_by would work here, not thinking clearly.
[23:43:43] baweaver: &>> OPS = { '+' => 0, nil => 1, '-' => 2 }; %w(A+ F B- B B+).sort_by { |g| [g[0], OPS[g[1]]] }
[23:47:57] baweaver: Just tend not to post full solutions in channel
[23:48:04] baweaver: Kinda curious how I'd teach that though
[23:50:49] baweaver: It's a hard balance
[23:51:04] baweaver: iirc Darmani was a bit vampy

2019-02-28

[04:30:12] baweaver: Swyper: You're on your own for syntax errors, you need to look those up.
[04:31:21] baweaver: What have you tried to fix your syntax errors?
[04:32:24] baweaver: How do you write a Ruby method?
[04:32:54] baweaver: What's the syntax?
[04:34:15] baweaver: Fix the indentation as a first step
[04:34:39] baweaver: Second, what's your method name?
[04:34:58] baweaver: Third, where is that method defined when you call it on 7 through 10?
[04:36:44] baweaver: 2: No it's not
[04:36:59] baweaver: Ruby isn't that smart.

2019-02-27

[02:40:23] baweaver: havenwood: https://twitter.com/keystonelemur/status/1100584320752848896

2019-02-26

[22:57:46] baweaver: Probably shellwords.

2019-02-25

[08:19:36] baweaver: What have you tried?
[08:20:06] baweaver: Do you know how map works?
[08:21:11] baweaver: &>> [1, 2, 3].map { |v| v * 2 } # Map makes a new list by transforming elements using a function, in this case doubling each number
[08:22:05] baweaver: &>> {a: 1, b: 2, c: 3}.map { |k, v| v * 2 } # With a hash it gives you the key and the value
[08:22:42] baweaver: So in your case, it'd be something like: values.map { |name, info| ... }
[08:22:53] baweaver: See if you can figure it out from there
[08:23:22] baweaver: This is one of the most powerful tools you'll use in Ruby - https://ruby-doc.org/core-2.6.1/Enumerable.html
[08:23:40] baweaver: Enumerable is in Array and Hash as a way to do all sorts of things to collections
[08:24:09] baweaver: The main ones you'll use are: map, select, find, reduce
[08:25:31] baweaver: If you want a fun way to learn all of that: https://www.youtube.com/watch?v=x3b9KlzjJNM
[08:29:09] baweaver: or perhaps we're not
[08:29:31] baweaver: You'll have more luck leading with your question though :)
[08:36:38] baweaver: ntt: Do you only want the IP?
[08:37:08] baweaver: That's not really too complex.
[08:37:17] baweaver: Break it down a bit, you have a hash with nested hashes
[08:37:29] baweaver: the key is the name of the node, and the value is its configuration
[08:38:05] baweaver: So when using map, ask the configuration what the IP is
[08:38:13] baweaver: It's a hash, how do you get a single value from a hash?
[08:41:01] baweaver: You should probably lead with that
[08:41:32] baweaver: So you only need ipaddress?
[08:41:39] baweaver: Not network?
[08:43:02] baweaver: So really you only need the nodes
[08:43:20] baweaver: Can you use other gems?
[08:44:05] baweaver: Xf.trace(:ipaddress).get_value(hash)
[08:44:20] baweaver: data.map(&Xf.trace(:ipaddress).get)
[08:44:51] baweaver: https://github.com/baweaver/xf
[08:46:32] baweaver: Traces basically go down through a hash until it can finally find a key that matches
[08:46:41] baweaver: or key and value, but that's a different thing.
[08:48:05] baweaver: The two articles up top explain how it works
[08:49:02] baweaver: Yeah, trace is slow-ish because of how it works
[08:49:17] baweaver: Though to be fair it won't matter unless you have something like 10k nodes or more
[08:49:33] baweaver: and even then, maybe a quarter second
[08:50:30] baweaver: The answer to what's the best way to do something is: it depends
[08:51:14] baweaver: Now if there were a way to potentially know what those paths are you could use dig instead.
[08:52:47] baweaver: but my advice for sysadmin type tasks: optimize for writing time, not runtime, until it becomes an actual issue.
[08:54:56] baweaver: for 30 nodes the time difference is non-existent
[08:56:05] baweaver: So merge based on similar keys?
[08:56:34] baweaver: Hash#merge is nice for that.
[09:01:20] baweaver: V1s1ble: https://bpaste.net/show/9b308d3810ec
[09:01:31] baweaver: reduce / each_with_object is good for that type of problem
[09:02:05] baweaver: grep can take a regex (it uses === for compares)
[09:02:18] baweaver: Then just reduce it into a hash with arrays as the default value

2019-02-24

[06:15:14] baweaver: noAKA: I'd bet on some form of eval (instance, module, class)
[06:15:42] baweaver: If you made locals right above it I bet it works
[06:16:49] baweaver: loddbot = Cinch::Bot.new; loddbot.configure do ... end
[06:16:52] baweaver: Try that instead
[06:17:56] baweaver: Bingo: `instance_eval(&b) if block_given?`
[06:18:01] baweaver: https://www.rubydoc.info/github/cinchrb/cinch/Cinch/Bot#initialize-instance_method

2019-02-22

[03:33:54] baweaver: elcontrastador: What do you want to learn about?

2019-02-20

[22:39:36] baweaver: https://twitter.com/keystonelemur/status/1098351041576263680
[22:39:41] baweaver: https://twitter.com/keystonelemur/status/1098351041576263680
[22:39:46] baweaver: https://twitter.com/keystonelemur/status/1098351041576263680

2019-02-18

[03:16:37] baweaver: havenwood / phaul / al2o3-cr - https://codepen.io/keystonelemur/pen/jdXwrm
[03:16:43] baweaver: Got it to play multi-tracks. Now to hook this lot up to Rails and make it pretty. That, and figure out how control events work.
[06:10:08] baweaver: https://medium.com/@baweaver/exploring-tracepoint-in-ruby-part-two-events-f4fd291992f5
[06:10:08] baweaver: Part Two of 'Exploring TracePoint' is out where we take a look at the events we can monitor on, and some of their potential uses in debugging:
[08:03:12] baweaver: You'd basically have to make your own object mapper
[08:03:39] baweaver: There are dynamic ways to do that, sure, but you'd almost need API contracts for that.
[08:05:28] baweaver: I mean you could dynamically map things down to OpenStructs
[08:07:21] baweaver: https://github.com/aetherknight/recursive-open-struct
[08:07:37] baweaver: Though there are all types of fun issues with that.

2019-02-15

[04:15:06] baweaver: I regret nothing: https://twitter.com/keystonelemur/status/1096261336705593344
[04:15:11] baweaver: I regret nothing: https://twitter.com/keystonelemur/status/1096261336705593344
[23:03:45] baweaver: !connection Inline
[23:04:05] baweaver: !connection Inline
[23:04:25] baweaver: ACTION stares at bot
[23:08:13] baweaver: He's on vacation / break last I knew
[23:16:12] baweaver: So I have some fun news.
[23:16:49] baweaver: The lemurs are headed to RailsConf.

2019-02-14

[09:34:35] baweaver: sevenseacat: want to see something pretty?

2019-02-13

[06:19:23] baweaver: Oi, webpacker is a pain to get running on a fresh install, what gives
[06:20:51] baweaver: fresh install `rails new name --webpack --no-sprockets` and I can't get it to hello world from the initial pack
[06:20:59] baweaver: included the lines in app template too
[06:21:41] baweaver: <%= javascript_pack_tag 'application' %> copied and pasted right in there
[06:22:17] baweaver: Nothing, that's the pesky part
[06:22:26] baweaver: give me a sec, uploading it.
[06:22:35] baweaver: you're sevenseacat on github right?
[06:24:00] baweaver: Added, you also get to see all my fun notes from the project
[06:24:14] baweaver: Decided to nest the Rails app in a directory to have notes to the side of it.
[06:24:30] baweaver: Probably putting other assets in there that aren't directly related too
[06:29:52] baweaver: Should probably install 2.6.1 later.
[06:29:59] baweaver: ACTION bets money it's something silly.
[06:37:19] baweaver: ACTION goes into corner of shame
[06:37:54] baweaver: I swear I can develop X_X
[06:44:19] baweaver: interesting that they removed any note of the welcome controller now.
[08:25:53] baweaver: Radar: had to nuke my Ruby setup again, so updated your guide: https://github.com/radar/ryanbigg.com/pull/25

2019-02-12

[08:42:01] baweaver: destination_address = [operation['to'], operation['from']].find(&:itself)

2019-02-11

[08:09:06] baweaver: Qo 1.0.0 PR is out, any feedback is appreciated :D
[08:09:07] baweaver: https://github.com/baweaver/qo/pull/23
[08:09:08] baweaver: https://github.com/baweaver/qo/pull/23
[08:09:08] baweaver: Qo 1.0.0 PR is out, any feedback is appreciated :D
[08:09:10] baweaver: https://github.com/baweaver/qo/pull/23
[08:09:10] baweaver: Qo 1.0.0 PR is out, any feedback is appreciated :D
[08:09:12] baweaver: That was a heck of a lot of work, but I like where it's going so far
[23:46:31] baweaver: How's things?

2019-02-10

[07:35:05] baweaver: &>> class Custom; def to_proc -> v { true } end; end; [1,2,3].select(&Custom.new)
[07:36:25] baweaver: &>> class Custom; def to_proc; -> v { true } end; end; [1,2,3].select(&Custom.new)
[07:37:05] baweaver: &>> class Custom; def call; true; end; def to_proc; method(:call) end; end; [1,2,3].select(&Custom.new)
[07:37:25] baweaver: havenwood: hrm
[07:37:45] baweaver: method won't go for Proc requirements apparently, slightly pesky
[22:57:23] baweaver: More fun - https://twitter.com/keystonelemur/status/1094726091531407361

2019-02-08

[04:06:30] baweaver: elcaro: Ruby-esque? Not sure we really have a word for it.
[04:09:13] baweaver: Running? :P
[07:10:05] baweaver: https://medium.com/@baweaver/exploring-tracepoint-in-ruby-part-one-example-code-2cf9b1a1b956
[07:10:05] baweaver: New article is up on TracePoint, one of the more interesting parts of Ruby and debugging in it:
[23:06:42] baweaver: ACTION wanders in

2019-02-07

[17:49:34] baweaver: uplime: Huh, apparently wasn't following them myself
[17:49:43] baweaver: ACTION is bad at keeping track of those things
[17:55:17] baweaver: What's your handle?
[18:06:15] baweaver: Working on a new API, thoughts? - https://github.com/baweaver/trace_spy/issues/1

2019-02-06

[20:22:23] baweaver: Why would you?
[20:22:30] baweaver: What's the use case?
[20:24:44] baweaver: Just use `then`
[20:25:18] baweaver: Trying to be too clever in DSLs tends to be hard to test and maintain
[20:25:35] baweaver: and functional piping isn't really necessary anymore, we have << and >> for composition in 2.6
[20:26:19] baweaver: You're thinking about it backwards.
[20:26:34] baweaver: a | b | c { ... }
[20:27:02] baweaver: a, b, and c are all entities. | is an operator that works on those entities. The clock doesn't belong to |, it belongs to c
[20:28:13] baweaver: &>> adds = -> x { -> y { x + y } }; multiplies = -> x { -> y { x * y } }; [1, 2, 3].map(&adds[1] >> multiplies[5])
[20:28:30] baweaver: << composes in the other direction
[20:28:35] baweaver: &>> adds = -> x { -> y { x + y } }; multiplies = -> x { -> y { x * y } }; [1, 2, 3].map(&adds[1] << multiplies[5])
[20:29:02] baweaver: which is more accurately what people mean with `compose` in functional languages.
[20:29:28] baweaver: It's less of "Can Ruby do X" than "Should you be doing X?"
[20:30:13] baweaver: Though I'm 95% they just ignored that
[20:30:31] baweaver: which is why often times I don't show how it's done
[20:31:02] baweaver: The reason the parens are needed is the difference between `{ ... }` blocks and `do ... end` blocks
[20:31:22] baweaver: The former creates ambiguity for the parser between that and a hash / kw param
[20:32:03] baweaver: It's the same reason you can't do this in RSpec: `let :value { ... }`
[20:32:57] baweaver: Give it a try in a REPL
[20:35:56] baweaver: Figured, didn't remember.
[20:36:17] baweaver: REPLs are great for answering questions and experimenting.

2019-02-05

[18:33:06] baweaver: https://www.rubydoc.info/gems/rubocop/RuboCop/NodePattern
[18:33:14] baweaver: NodePattern in RuboCOp is about the same
[18:33:20] baweaver: gotta go, train arriving, cheers