baweaver

Activity Graph

« Prev | Page 2 of 255 | Next »

2019-01-10

[00:11:52] baweaver: mikecmpbll: Can you shoot us the full error?
[00:12:13] baweaver: also super rare to see nested methods like that
[00:12:48] baweaver: L96 may do bad things too, but probably not the point
[00:13:49] baweaver: Hrm. I'd probably just drop a binding.pry in there and see why it's screwy.
[00:16:05] baweaver: you could also put a rescue in there to try and catch it and reraise
[00:31:22] baweaver: con3: What's not working with it?
[00:32:28] baweaver: Don't use -e
[00:32:38] baweaver: that evaluates it as a literal ruby program instead of as a file
[00:32:56] baweaver: test is an actual Ruby function
[00:33:20] baweaver: hence the error
[00:34:53] baweaver: Also return isn't needed there
[00:35:20] baweaver: You have nothing that outputs to your console, STDOUT
[00:35:42] baweaver: Remember though that puts returns nil
[00:35:48] baweaver: So don't use it in a method
[00:36:37] baweaver: If you use it at the end of your program it's fine
[00:36:49] baweaver: but if you put puts at the end of a method it'll return nil implicitly
[00:37:42] baweaver: Well we're around if you need help
[00:41:21] baweaver: The shell will show it, but that's STDOUT, not necessarily the return value
[00:41:26] baweaver: so it does technically print
[00:44:30] baweaver: They're not
[02:13:00] baweaver: phaul: I always get hung up on code style arguments
[02:13:13] baweaver: On one hand it could probably be done better, but on the other it works
[02:13:35] baweaver: Really I think I just fall in the camp of making it mutually understandable to whoever is working with you.
[02:13:54] baweaver: Then codifying said standard to prevent shenanigans later.
[16:05:05] baweaver: Honestly I tend to use `include?` to make it more readable
[16:05:21] baweaver: if %w(200 201).include?(response.code)
[16:05:42] baweaver: or `in?`: if response.code.in?(%w(200 201))
[16:06:18] baweaver: If people get uppity about performance, just make it a constant
[16:06:45] baweaver: though really by that point it just gets incredibly pedantic

2019-01-09

[23:48:53] baweaver: SeepingN: no?
[23:49:07] baweaver: Do you have an example?
[23:49:36] baweaver: Works in 2.3, 2.4, 2.5, and 2.6.
[23:49:43] baweaver: Not sure what you're seeing.
[23:50:22] baweaver: What version of Ruby are you using?
[23:50:50] baweaver: 2.6.0 :002 > 1 + 1
[23:50:50] baweaver: 2.6.0 :001 > RUBY_VERSION
[23:51:17] baweaver: 2.5.1 :001 > RUBY_VERSION
[23:51:18] baweaver: 2.5.1 :002 > 1 + 1
[23:51:52] baweaver: I think something's screwy with your ruby install
[23:52:07] baweaver: That, and 2.2.x is super out of date

2019-01-08

[01:32:50] baweaver: In some cases I'd be tempted to say if you don't know where that line is it's probably not a great idea to use it.
[01:32:57] baweaver: Though I'd also argue that people seriously overload that word as well
[01:33:07] baweaver: and a lot of the ideas that are dubbed as metaprogramming really aren't
[01:33:44] baweaver: If you're using Rails you probably are in some capacity, though they tend to move away from it more as time goes on for speed and stability reasons
[01:34:07] baweaver: find_by_name_and_email type methods don't really exist anymore in favor of keyword / query type methods
[01:34:49] baweaver: Not really metaprogramming.
[01:35:03] baweaver: That's just making a DSL using functions
[01:35:26] baweaver: Hence mentioning above that the term is quite overloaded and we tend to call a lot of things metaprogramming when they really aren't
[01:35:52] baweaver: That, and I think there's this mentality to call things dirty, ugly, or hacky whenever they're a perfectly normal part of the language
[01:36:50] baweaver: I just see there being no good reason to use a chainsaw to trim a bonsai tree when there are hedge clippers within reach.
[01:37:14] baweaver: Use the least powerful tool to do the task you need, less likely to behave oddly later
[01:37:55] baweaver: Like I could write any and all Enumerable functions using reduce, but I rarely use it like that. I'd use the actual functions instead.
[01:43:43] baweaver: My common rule is that if I have to ask or think about something being appropriate I probably shouldn't do something
[01:43:52] baweaver: That applies to programming, life, and other bits as well.
[01:44:50] baweaver: ohai lunarkittychan
[01:46:57] baweaver: fugee: Again, you need to contact their support channels. They have a slack among other things
[05:38:24] baweaver: With += yeah, it does bad things
[05:38:53] baweaver: I still don't agree with it treating it as a local variable in that context honestly

2019-01-07

[07:16:30] baweaver: What's your code?
[07:16:51] baweaver: because chances are high you don't need to do that.
[07:17:45] baweaver: So you're trying to rotate an array?
[07:18:09] baweaver: First note: Ruby has a rotate function
[07:18:28] baweaver: Second note: rotated_arr = arr does not make a clone, it points to the same array
[07:21:17] baweaver: I'd use each_with_index and just make a new array.
[07:29:59] baweaver: What if I told you that this is possible with a oneliner?
[07:30:09] baweaver: The trick is to use modulus.
[07:30:34] baweaver: Do you know what that is?
[07:30:43] baweaver: I'm horrid at math too
[07:31:17] baweaver: What happens when you add a negative number?
[07:31:33] baweaver: Let's take a look at our base array: [1, 2, 3]
[07:31:52] baweaver: If we were to rotate it by -1, you could say it'd be [2, 3, 1]
[07:32:26] baweaver: What's the index of 1 before the rotation?
[07:33:17] baweaver: It's now ['a', 'b', 'c']
[07:33:17] baweaver: Let's switch the base array
[07:33:29] baweaver: what's the index of 'a' before and after a rotation of -1?
[07:34:07] baweaver: What happens if you use modulo on a negative number?
[07:34:19] baweaver: Give it a try in a repl
[07:34:45] baweaver: Describe what modulo does to me real quick
[07:35:57] baweaver: So the reason you have two while loops?
[07:36:32] baweaver: Adding negative numbers :)
[07:36:39] baweaver: you only need to rotate once
[07:36:45] baweaver: and in one "direction" so to speak
[07:38:52] baweaver: Have you tried in your REPL?
[07:39:17] baweaver: What did that second one give you?
[07:39:45] baweaver: So if i + offset is -1...
[07:39:58] baweaver: You now have the index of the end of the array
[07:40:21] baweaver: So 0 offset by -1 is -1, meaning it'd go at the end of the array
[07:40:32] baweaver: See if you can figure out how to code that in
[07:40:43] baweaver: I'd suggest taking 3-5 lines
[07:40:49] baweaver: 1 is just showing off to make it compact
[07:44:40] baweaver: If they get close feel free to shoot them this: https://repl.it/@baweaver/IllustriousPristineClients
[07:45:17] baweaver: Here's the compact version: https://repl.it/@baweaver/IllustriousPristineClients
[07:46:24] baweaver: You'd be far far more likely to see `array.rotate(1)`
[07:46:39] baweaver: with_index makes the arg order kinda gnarly
[07:47:17] baweaver: but otherwise pretty much
[07:47:42] baweaver: Very rarely do you need to implement your own functions like that in the real world, though eventually it's nice to know how they work
[07:48:25] baweaver: reduce and each_with_object just happen to be absurdly overpowered functions capable of reimplementing any of the other Enumerable functions.
[07:48:43] baweaver: Including combinations thereof
[07:49:37] baweaver: It teaches you to think and consider things
[07:49:51] baweaver: You're not going to come to immediate solutions to things when starting out
[07:50:09] baweaver: Instead take time to write it out, get a feel for how the data flows, and try and find patterns
[07:50:24] baweaver: once you build that recognition you start noticing a lot of problems look awfully similar
[21:16:50] baweaver: If any of you end up on the west coast shoot me a ping
[21:40:50] baweaver: tubbo: Wanna see something fun?
[21:41:27] baweaver: You can see me making lemur voices with colorful cartoons at RubyConf: https://www.youtube.com/watch?v=x3b9KlzjJNM
[21:56:52] baweaver: This is just the start, I have several more talks in mind :D
[21:58:12] baweaver: The super big one for Rails Conf will the "The Action Cable Symphony"
[22:12:10] baweaver: I'd be riffing off of Gavin Joyce's amazing talk: https://www.youtube.com/watch?v=bt9MRkf5Mus&feature=youtu.be&t=4601
[22:12:21] baweaver: Just shot him an email to ask for advice and a blessing on it
[23:14:52] baweaver: Common rule: don't
[23:15:05] baweaver: prefer !, &&, and ||
[23:15:36] baweaver: You're more likely to give yourself headaches with operator precedence by using the english versions comet23
[23:38:50] baweaver: kankava: I'd suggest contacting their support channels for questions
[23:38:51] baweaver: They have them listed here: https://spreecommerce.org/
[23:47:45] baweaver: For where you're currently at in programming, no.
[23:48:51] baweaver: There are exceptions to every rule, but typically you want to play by those rules where possible to avoid confusion.
[23:49:31] baweaver: Much the same with metaprogramming and eval. 99% of the time you don't need them, but every beginner wants to use them at every turn because they have a shiny new tool and it looked fun
[23:49:57] baweaver: More often than not they end up creating a pretty big mess of it when a single-line would have done the same thing if they hadn't been fixating on that.
[23:59:43] baweaver: That's a fair assessment by them. There are uses but they're rare and are rarely justifiable

2019-01-06

[02:34:10] baweaver: It's an issue with old versions of the mysql2 gem.
[02:34:29] baweaver: or rather it's an incompatibility with newer versions of Ruby > 2.4ish iirc
[02:36:22] baweaver: Hrm. What version of Rails are you on?
[02:36:40] baweaver: It may be you found a 2.6 bug, there are a few edges around still
[02:38:18] baweaver: There are already some 2.6 errors ereported
[02:38:28] baweaver: Though 4.2 is also old and pretty well in security only mode.
[02:38:42] baweaver: Can you see if it happens with a later version of Rails?
[02:39:21] baweaver: Worst case I'd report this on the Rails github page as something screwy is going on there
[02:43:58] baweaver: define_instance_method if I remember right
[02:44:36] baweaver: Ah, it was just define method
[02:44:54] baweaver: define_method(name, &function)

2019-01-04

[08:16:17] baweaver: Woo, put everything from 2018 together - https://medium.com/@baweaver/2018-in-review-3f619f26baca
[20:11:50] baweaver: havenwood / phaul: https://twitter.com/keystonelemur/status/1081086171495620609
[20:12:01] baweaver: ( yes, I know it breaks some other things )]
[20:12:16] baweaver: Also got a 2018 review done - https://medium.com/@baweaver/2018-in-review-3f619f26baca
[20:15:28] baweaver: Pretty much.
[22:44:22] baweaver: ACTION wanders in
[22:45:29] baweaver: ACTION kinda thinks this sounds like Rails

2019-01-03

2019-01-02

[17:36:59] baweaver: Someone likes parens
[17:37:25] baweaver: if number == arr[i+1] && !(arr[0..i-1]).include?(arr[i])
[17:37:37] baweaver: if number == arr[i+1] && !arr[0..i-1].include?(arr[i])
[17:38:00] baweaver: There we go. That does the same thing and doesn't have superfluous parens.
[17:38:33] baweaver: &ri Enumerable#chunk
[17:38:38] baweaver: Read into that.
[17:40:16] baweaver: phaul: I should coax them into visiting IRC again
[17:40:24] baweaver: We chat on Twitter occasionally.
[19:51:49] baweaver: ohai cjohnson
[19:51:53] baweaver: happy new years
[23:15:08] baweaver: !connection laaron
[23:15:30] baweaver: ACTION wanders in

2018-12-31

[04:08:23] baweaver: ACTION wanders in
[05:49:08] baweaver: What happens when you multiply a number by 0?
[05:49:09] baweaver: Also map is the wrong function for this.
[05:52:03] baweaver: How did you find that one?
[05:52:27] baweaver: ....how did you figure that out?
[05:52:34] baweaver: They're just conveniently spaced?
[05:54:10] baweaver: Interesting.
[17:16:26] baweaver: Swyper: lead with the problem description
[17:17:25] baweaver: line 6 doesn't actually make a new list.
[17:18:08] baweaver: You don't need one.
[17:18:25] baweaver: numbers.map instead
[17:19:16] baweaver: Though you could use map.with_index to get the index, which you probably need for this anyways.
[17:20:47] baweaver: One could just invert that singular number considering how multiplication works.
[17:21:16] baweaver: Commutative property wasn't it?
[17:21:29] baweaver: a * b * c == c * b * a
[17:21:35] baweaver: which could be done in any order.
[17:22:17] baweaver: Swyper: If I add one to a number, how would I undo that?
[17:23:37] baweaver: True, but that's not the business of the array_product function
[17:23:45] baweaver: the name becomes a lie by doing that.
[17:24:08] baweaver: That, and you want to likely use sum or reduce instead for getting a product.
[17:25:45] baweaver: well, reduce.
[17:26:27] baweaver: &>> [1, 2, 3].reduce(1) { |accumulator, v| accumulator * v }
[17:26:40] baweaver: &>> [1, 2, 3].reduce(1) { |a, v| a * v }
[17:26:49] baweaver: &>> [1, 2, 3].reduce(1, :*)
[17:27:18] baweaver: This will give you a whole view into how reduce works: https://medium.com/@baweaver/reducing-enumerable-part-one-the-journey-begins-ddc1d4108490
[17:27:42] baweaver: each only iterates a list
[17:27:51] baweaver: map is used to transform a list and return a new list
[17:31:16] baweaver: Hrm, maybe I should go through a tutorial of basics on how Enumerable works overall and going through usecases of each of the methods.
[17:31:24] baweaver: s/go through/write/
[17:54:47] baweaver: uniq doesn't modify the list.
[18:22:20] baweaver: &>> 'aabbcccdef'.chars.group_by(&:itself).select { |ch, count| count == 1 }.keys
[18:22:50] baweaver: &>> 'aabbcccdef'.chars.group_by(&:itself).select { |ch, chs| chs.size == 1 }.keys
[18:23:16] baweaver: &>> 'aabbcccdef'.chars.group_by(&:itself)
[18:24:02] baweaver: ACTION really wants a count_by function
[22:23:14] baweaver: https://twitter.com/keystonelemur/status/1079811981568167937
[22:23:16] baweaver: Oh here we go.
[22:23:43] baweaver: Take that idea along with this article I wrote a while back: https://medium.com/rubyinside/destructuring-in-ruby-9e9bd2be0360a
[22:24:12] baweaver: https://medium.com/rubyinside/destructuring-in-ruby-9e9bd2be0360
[22:24:44] baweaver: Ah, accidentally typed an a
[22:24:45] baweaver: havenwood ^
[22:24:46] baweaver: josh_cheek found a way to get default arguments
[22:24:55] baweaver: I've about cracked a way to translate that into a full destructuring system that nests.
[22:25:21] baweaver: Mostly just writing notes for it. This is going to be a fun article :D
[22:27:24] baweaver: &>> [1,2,3,4,5].last(2)
[22:27:40] baweaver: `return` isn't really needed in ruby either.
[22:28:44] baweaver: instead of as an array, which is probably what you intended.
[22:28:44] baweaver: Also you're quite literally returning both of the strings as one string
[22:30:03] baweaver: &>> 'some words are longer than other words, who would have thought?'.split.max_by(2) { |w| w.count('a-zA-Z') }
[22:30:44] baweaver: not in the count, but in the return.
[22:30:44] baweaver: Interesting part is that that _includes_ punctuation
[22:34:46] baweaver: That phrase gets far more common the more programming one does.

2018-12-30

[17:51:02] baweaver: comet23: Purposely misspelling stuff today?
[17:51:19] baweaver: It helps if you describe what exactly you're trying to do.
[17:53:05] baweaver: They know how to type properly, they've been around before.
[17:53:10] baweaver: and they're about to get a timeout for being purposely dense.

2018-12-28

[03:48:51] baweaver: hays: What're you trying to learn?
[03:49:22] baweaver: al2o3-cr / phaul: Yeah, that one is... interesting
[03:49:30] baweaver: How're things for you lot?
[03:49:56] baweaver: Want to see some Ruby black magic? :D
[03:50:08] baweaver: https://medium.com/@baweaver/mf-abusing-rubys-operator-precedence-ccf3f071bad8
[03:53:03] baweaver: ACTION wanders off again
[06:28:30] baweaver: al2o3-cr / phaul / havenwood: 30 :D - https://medium.com/@baweaver/on-on-call-operations-and-holidays-d6ec85c0826b

2018-12-27

[04:04:09] baweaver: The numbers were grouping instead of applying to eachother.
[05:17:03] baweaver: https://medium.com/@baweaver/sf-abusing-operators-and-method-missing-ced78ab428cb
[05:17:06] baweaver: al2o3-cr: 29
[18:13:06] baweaver: I did more bad things to Ruby: https://medium.com/@baweaver/sf-abusing-operators-and-method-missing-ced78ab428cb
[18:13:56] baweaver: marz_d`ghostman: What's the full code?
[18:16:42] baweaver: I figured it our
[18:17:06] baweaver: Sf + 5 * 10 -> Sf + (5 * 10)
[18:21:06] baweaver: Nope, not without hacking the everloving heck out of the parser :P
[18:21:14] baweaver: I feel like at_exit should not be used in a module, but as a supervisor
[18:21:35] baweaver: I doubt it works as an instance method even if included.