« Back to channel list

#ruby - 10 December 2017

« Back 1 day Forward 1 day »
[00:04:20] guille-moe: has joined #ruby
[00:06:55] zautomata: has joined #ruby
[00:09:47] agent_white: has joined #ruby
[00:10:53] vikaton: has joined #ruby
[00:13:36] mtkd: has joined #ruby
[00:15:07] goyox86: has joined #ruby
[00:16:48] johnpaul: has joined #ruby
[00:17:02] daemonwrangler_: has joined #ruby
[00:17:17] enterprisey: has joined #ruby
[00:25:09] veeti: has joined #ruby
[00:31:32] goyox86: has joined #ruby
[00:34:49] bkxd: has joined #ruby
[00:41:47] hndk: has joined #ruby
[00:47:29] goyox86: has joined #ruby
[00:51:59] CrazyEddy: has joined #ruby
[00:56:42] Puppet`: has joined #ruby
[00:56:51] alex``: has joined #ruby
[01:04:55] ur5us: has joined #ruby
[01:06:46] patteh: has joined #ruby
[01:22:05] RickHull: has joined #ruby
[01:22:35] alfiemax: has joined #ruby
[01:30:10] RickHull: noticed something strange about private methods: https://gist.github.com/rickhull/4e1384c4264a00de57e731dff775e370
[01:30:46] RickHull: the rule I am familiar with is that you can't call private methods with a receiver. i.e. inside a class, self.bar will raise NoMethodError
[01:31:25] RickHull: but you can declare a writer method `def bar=` private, and it can be called inside the class like: `self.bar = 42`
[01:31:35] RickHull: what's up with that?
[01:35:40] alfiemax: has joined #ruby
[01:35:41] workmad3: has joined #ruby
[01:41:50] mahlon: has joined #ruby
[01:43:56] milardovich: has joined #ruby
[01:51:23] rexb0t: has joined #ruby
[01:55:46] eckhardt: has joined #ruby
[02:08:12] JBbanks: has joined #ruby
[02:11:40] astronavt: has joined #ruby
[02:14:36] goyox86: has joined #ruby
[02:18:48] mtkd: has joined #ruby
[02:20:17] mson: has joined #ruby
[02:20:40] kitsunenokenja: has joined #ruby
[02:32:43] gizmore: has joined #ruby
[02:33:13] CrazyEddy: has joined #ruby
[02:33:37] oetjenj: has joined #ruby
[02:34:27] RickHull: it looks like this is because calling `bar = val` without a receiver makes bar a local var. this also proves that "no explicit receiver" is not a useful rule. Foo#bar= is still inaccessible from the outside
[02:38:26] cadillac_: has joined #ruby
[02:39:25] milardovich: has joined #ruby
[02:42:30] dminuoso: its still a useful rule.
[02:42:32] dminuoso: its just a bug.
[02:42:46] dminuoso: seeing as I cant even launch any lldb session anymore..
[02:42:53] dminuoso: I cba to debug this since it'd require a hardreboot.
[02:43:42] RickHull: I don't see how it's a useful rule
[02:44:05] RickHull: why make a class's own methods inaccessible (i.e. when calling via self)?
[02:44:32] RickHull: i think it was done this way because privacy from the outside is achieved
[02:44:45] RickHull: but privacy on the inside is nonsensical
[02:45:36] RickHull: furthermore, can this even be fixed? won't `bar = val` be hard / impossible to disambiguate?
[02:46:19] RickHull: what does the rule about no `self.bar` achieve for private methods?
[02:46:34] RickHull: and why can this rule be violated in the case of private writers?
[02:47:56] RickHull: it seems you fix this by dropping the rule about no `self.bar` on private methods
[02:48:12] RickHull: I truly don't see any upside to this rule
[02:48:49] rivalomega: has joined #ruby
[02:49:06] d^sh: has joined #ruby
[02:50:32] ski7777: has joined #ruby
[02:51:56] dminuoso: RickHull: because `privacy` has a different meaning.
[02:52:06] dminuoso: This is not C++
[02:52:49] RickHull: what is achieved with the "no explicit receiver" rule? what is useful about this notion of privacy?
[02:53:46] dminuoso: RickHull: I give you an object foo of my own chosing.
[02:54:00] dminuoso: Anything that is declared private is inaccessible for you.
[02:54:07] vikaton: has joined #ruby
[02:54:21] RickHull: yes -- this is the standard notion of privacy. i can't access private methods "from the outside"
[02:54:41] dminuoso: `private` just means `not part of the exposed interface`
[02:54:44] RickHull: no explicit receiver does provide this -- at the cost of making private methods inaccessible from the inside as well
[02:54:58] RickHull: we know that private writer methods can violate this rule
[02:55:03] RickHull: what is the harm?
[02:55:10] dminuoso: well I guess it does hold true for foo= methods (or it should at leasT)
[02:55:26] dminuoso: I wonder, is foo=() legal?
[02:55:30] ruby[bot]: dminuoso: # => 1 (https://eval.in/915920)
[02:55:40] RickHull: if there is no harm to violating a rule, then what use is the rule?
[02:55:50] dminuoso: RickHull: you cant violate it really
[02:55:56] dminuoso: unless you pry it open with `send`
[02:56:02] RickHull: private writer methods can be called with an explicit receiver
[02:56:12] RickHull: this violates the rule about calling private methods with an explicit receiver
[02:56:21] dminuoso: Its called a bug.
[02:56:27] RickHull: what is the harm in this violation?
[02:56:28] dminuoso: Dont get so worked up about it =)
[02:56:33] dminuoso: There is no real harm
[02:56:36] dminuoso: Its just a bug.
[02:56:43] dminuoso: Perhaps its intended.
[02:56:46] RickHull: so what is the use of a rule if there is no harm in violating it?
[02:56:50] dminuoso: No I think it could be intended.
[02:56:51] dminuoso: Think about it.
[02:56:57] dminuoso: How would you call a private foo= method?
[02:56:58] oetjenj: has joined #ruby
[02:57:06] dminuoso: I mean.. just think about it.
[02:57:16] RickHull: did you see my gist?
[02:57:20] RickHull: why are you asking this question?
[02:57:24] dminuoso: Everything is fine.
[02:57:29] dminuoso: RickHull: Look the point is about `public interface`
[02:57:41] dminuoso: if you have the class open, there's no notion of `privacy` really
[02:57:44] oetjenj: has joined #ruby
[02:57:52] dminuoso: as long as .bar= is protected from the outside, all is good.
[02:57:57] RickHull: yes, thank you
[02:58:05] RickHull: so the "no explicit receiver" does far too much
[02:58:18] RickHull: and of course it's problematic for private writer methods
[02:58:19] dminuoso: so this feels like an intended hack to make private assign methods available in the ruby model
[02:58:36] oetjenj: has joined #ruby
[02:58:52] dminuoso: so its "no explicit receiver, unless its a writer method and you're inside .. [insert some smart remark about scopes and stuff]"
[02:59:00] RickHull: which really means the rule about "no explicit receiver" isn't useful
[02:59:07] dminuoso: it fits 99% of all cases.
[02:59:12] RickHull: private writer methods are inaccessible from the outside, without that rule
[02:59:22] dminuoso: they still are.
[02:59:22] RickHull: so why shouldn't all private methods be consistent?
[02:59:28] dminuoso: you cant access a private assign method from the outside.
[02:59:45] dminuoso: RickHull: Because you wouldnt be able to call a private bar= method.
[02:59:57] dminuoso: Without changing the semantics of the language.
[03:00:02] RickHull: the only thing that matters for privacy is what happens from the outside
[03:00:09] dminuoso: And that is perfectly preserved.
[03:00:11] RickHull: within the class, there should be no notion of privacy
[03:00:14] dminuoso: From outside the rule holds.
[03:00:31] dminuoso: RickHull: really?
[03:00:36] dminuoso: what about modules?
[03:00:38] dminuoso: what about ancestors?
[03:00:47] armando: has joined #ruby
[03:00:55] dminuoso: what about singleton classes?
[03:01:12] RickHull: what I mean is: within the class, what is gained by disallowing self.bar?
[03:01:25] RickHull: we clearly have costs -- but no benefit
[03:02:04] Xiti`: has joined #ruby
[03:02:06] dminuoso: RickHull: Im guessing its easier to just speficy it in terms of `receiver` because ruby is weird.
[03:02:12] dminuoso: Just look at the source code
[03:02:14] dminuoso: and you will understand why
[03:02:18] dminuoso: let me find a good example
[03:02:18] RickHull: it doesn't have to be weird
[03:02:30] RickHull: and it causes all kinds of hacks and inconsistencies
[03:02:43] meesles: has joined #ruby
[03:02:47] RickHull: but yes, I think this was done "for convenience"
[03:04:06] RickHull: "no explicit receiver" does provide the standard notion of privacy, but it brings along a whole associated set of behaviors and implications that aren't desirable
[03:04:17] faces: has joined #ruby
[03:04:31] RickHull: and as we see with private writer methods, you can still have an explicit receiver and standard privacy
[03:04:38] dminuoso: RickHull: https://github.com/ruby/ruby/blob/trunk/regexec.c#L2566-L2567
[03:04:47] dminuoso: in the middle of thousands of lines of undocumented code
[03:04:53] RickHull: so again, I am still curious what the value of the "no explicit receiver" rule is. I am guessing there is no value and it's just "convenient"
[03:04:54] dminuoso: you get these kinds of comments.
[03:05:55] ur5us: has joined #ruby
[03:10:12] Xiti: has joined #ruby
[03:11:35] chocoelho: has joined #ruby
[03:15:58] alfiemax: has joined #ruby
[03:16:20] RickHull: i thought bar=(val) would be able to find the private method, but nope, still a local var
[03:16:22] goyox86: has joined #ruby
[03:18:39] armando: has joined #ruby
[03:19:04] cschneid_: has joined #ruby
[03:19:56] RickHull: this touches on a related matter I disagree with Ruby on -- I think methods should *always* have an explicit receiver :)
[03:20:18] RickHull: the ambiguity between local vars and method calls is a misfeature IMHO
[03:21:26] RickHull: nearly all of my code is written this way, with explicit self receivers inside classes. but I don't use private methods very much *wink*
[03:22:14] RickHull: it looks like protected methods will work for me, though
[03:22:29] char_var[buffer]: has joined #ruby
[03:24:19] dminuoso: 04:19 RickHull | this touches on a related matter I disagree with Ruby on -- I think methods should *always* have an explicit receiver :)
[03:25:29] char_var[buffer]: has joined #ruby
[03:26:22] RickHull: it makes your fingers hurt? or your eyes? or?
[03:27:41] drowze: has joined #ruby
[03:36:13] workmad3: has joined #ruby
[03:38:34] UserOO7: has joined #ruby
[03:47:42] UserOO7: has joined #ruby
[03:50:54] ozcanesen: has joined #ruby
[03:51:24] ozcanesen: has left #ruby: ()
[03:57:53] Exhiled: has joined #ruby
[03:59:34] armando: has joined #ruby
[04:00:35] UserOO7: has joined #ruby
[04:01:06] goyox86: has joined #ruby
[04:02:16] milardovich: has joined #ruby
[04:05:13] elphe: has joined #ruby
[04:06:12] aupadhye: has joined #ruby
[04:06:14] shinnya: has joined #ruby
[04:13:10] bkxd: has joined #ruby
[04:17:03] Exhiled: has joined #ruby
[04:17:44] ledestin: has joined #ruby
[04:17:51] jenrzzz: has joined #ruby
[04:17:51] jenrzzz: has joined #ruby
[04:22:48] Xiti: has joined #ruby
[04:24:02] apparition: has joined #ruby
[04:24:06] mtkd: has joined #ruby
[04:27:50] zenspider: has joined #ruby
[04:27:53] Exhiled: has joined #ruby
[04:28:02] zenspider: has joined #ruby
[04:29:53] armando: has joined #ruby
[04:29:58] milardovich: has joined #ruby
[04:30:14] gix-: has joined #ruby
[04:30:33] UserOO7: has joined #ruby
[04:30:49] zenspider: RickHull: I FINALLY got around to reviewing your PR for MT/B... I think it might be a failure in test, but my brain is fuzzy
[04:32:12] UserOO7: has joined #ruby
[04:33:46] RickHull: Hopefully someone with a solid statistics background can chime in. But the crux for me is that the linear r2 is a relative measure, against a baseline of "constant behavior" or "the mean"
[04:34:22] RickHull: i think it's more useful in a truly scattered plot
[04:35:45] RickHull: I implemented "best fit" and it seems to be more useful https://github.com/rickhull/compsci/blob/master/lib/compsci/fit.rb#L22
[04:38:25] RickHull: sorry, there are 2 issues -- one is that linear r2 is low / zero for constant data -- not a big deal
[04:38:38] RickHull: the other is that linear r2 is high for x^2 and x^3 data
[04:39:54] RickHull: i think, with the current approach, assert_linear should try all fits and only pass the assertion if the best r2 is the linear one
[04:41:16] RickHull: separately, i think a slightly different approach to the analysis is warranted. with x as the independent variable (aka N in big-O notation) and y as the dependent variable
[04:41:38] RickHull: as x goes up, we expect y to go up
[04:42:12] milardovich: has joined #ruby
[04:42:20] RickHull: possibly "constant" -- but it would never go down
[04:42:39] Exhiled: has joined #ruby
[04:42:50] cschneid_: has joined #ruby
[04:43:25] bkxd: has joined #ruby
[04:43:30] RickHull: we should be able to look at the slopes between each pair of points
[04:43:55] RickHull: and detect that y=x^2 and y=x^3 are nonlinear
[04:44:42] RickHull: the linear fit r^2 does this -- but fails to reject because the r^2 is high
[04:45:06] eckhardt: has joined #ruby
[04:45:25] RickHull: these 2 tests show the failure to reject -- I think they're in the PR as well https://github.com/rickhull/compsci/blob/master/test/fit.rb#L95
[04:47:50] RickHull: i believe the linear r^2 is high for y=x^3 because the linear predictor is nonetheless much better than the y=x_bar predictor
[04:48:38] RickHull: for asserting linear performance, we care about linear vs exponential, not linear vs constant
[04:49:38] RickHull: i need to write the test that shows "best fit" rejects linear in favor of exponential for y=x^2 or y=x^3
[04:50:36] zenspider: dude... too many words
[04:51:47] RickHull: which ones? ;)
[04:52:30] zenspider: RickHull: wrt the 2 issues: can you actually prove it, preferably in a failing test? The tests you submitted in that PR are NOT linear data, and the tests had errors in them (eg x2 couldn't pass, as written)
[04:52:55] zenspider: I didn't want to do a best_fit assertion because I want the test to specifically say what the performance curve SHOULD be
[04:53:25] RickHull: to be clear: assert_linear would run each fit and only pass if the best fit is in fact linear
[04:54:02] zenspider: I don't think I'm coming across clearly
[04:54:25] zenspider: Once test code errors are fixed... x^2 and x^3 fail just fine if given a linear domain. When given an exponential domain, they don't. This is expected and normal behavior
[04:55:03] RickHull: ok, let me review. my understanding is that my tests show assert_linear fails to reject x^2 and x^3
[04:55:59] zenspider: http://www.wolframalpha.com/input/?i=linear+fit+%7B%7B1,+1%7D,+%7B10,+100%7D,+%7B100,+10000%7D,+%7B1000,+1000000%7D%7D
[04:56:01] zenspider: try that first
[04:56:37] zenspider: r^2 of 0.993
[04:56:40] zenspider: vs http://www.wolframalpha.com/input/?i=linear+fit+%7B%7B1,+1%7D,+%7B2,+100%7D,+%7B3,+10000%7D,+%7B4,+1000000%7D%7D
[04:56:57] zenspider: r^2 of 0.60799
[04:57:24] zenspider: http://www.wolframalpha.com/input/?i=linear+fit+1,+100,+10000,+1000000
[04:57:28] zenspider: prettier url, same result
[04:57:46] bkxd: has joined #ruby
[04:58:12] zenspider: let's work on understanding THOSE... because that math seems right to me...
[04:58:21] milardovich: has joined #ruby
[04:58:35] RickHull: ok -- I'm going over your comments now
[04:59:06] zenspider: Once we're on the same page for those two sets (exponential domain vs linear domain)... then we can talk about minitest (which calculates almost the exact same values as wolfram)
[04:59:15] RickHull: I agree that the high r^2 is probably related to a small amount of data points
[04:59:20] zenspider: plain r^2, not adjusted... I don't know enough stats to do adjusted, or to know if it'd help
[05:00:19] zenspider: I think you're just not visualizing the space between the X values... you're making those as non-linear as the Y values, so they're actually a linear fit.
[05:00:29] zenspider: sorry... s/just //
[05:00:33] zenspider: I hate that word. sorry.
[05:00:53] RickHull: I see what you're saying -- but I don't think it's quite right. also the range/domain terminology confuses me
[05:01:01] RickHull: I know xs and ys, or independent/dependent
[05:01:15] zenspider: OOPS. sorry. domain is xs, range is ys
[05:01:19] RickHull: i know range/domain is standard but it's just something I never got used to using
[05:01:45] RickHull: my xs are exponential. yes. isn't this analogous to the default bench_range ?
[05:02:07] RickHull: that is, do something X number of times. do it once and time it. then 10x and time it
[05:02:25] RickHull: then 100, then 1000. we could step through each X but it would take a lot longer
[05:02:51] RickHull: if my Ys were linear -- say y = 2x
[05:03:07] RickHull: (1, 2) (100, 200) (1000, 2000)
[05:03:27] RickHull: so it shouldn't matter about gaps in the Xs
[05:03:43] zenspider: I'll come up with visuals... sec
[05:05:21] nf7: has joined #ruby
[05:05:21] RickHull: you can feed those 3 data points and get a perfect linear correlation
[05:05:26] nf7: has left #ruby: ()
[05:05:28] RickHull: y is literally 2x
[05:05:51] RickHull: now, let's say y=x^2
[05:05:58] zenspider: https://user-images.githubusercontent.com/9832/33802114-adba80b8-dd24-11e7-8707-1f5c34be5b77.png
[05:06:13] RickHull: (1, 1) (100, 10_000) (1000, 1_000_000)
[05:06:15] zenspider: there's your Ys, with both your exponential Xs and my linear Xs
[05:06:38] ur5us: has joined #ruby
[05:07:14] zenspider: does that graphic shed light on the R2? for you?
[05:07:50] RickHull: Table 1 is problematic -- right? the data are clearly nonlinear
[05:08:44] RickHull: I agree the r^2 is high -- and this is why it's a problem for asserting linear behavior
[05:08:52] zenspider: non linear, but given the domain, fits closely to a linear fit...
[05:09:13] RickHull: the slope is increasing wildly
[05:09:26] zenspider: no, this is why it is important to visualize your data because sometimes your experiment isn't set up well enough.
[05:09:39] zenspider: no, the slope is NOT increasing wildly... it's actually very slowly increasing
[05:09:48] RickHull: we know the data is literally y=x^2
[05:09:49] zenspider: (the CHANGE in slope)
[05:10:05] RickHull: that's like asserting O(N) behavior when you really have O(N^2)
[05:10:45] RickHull: in Table 1, the slope between the first pair of points is 10
[05:10:45] zenspider: because the CHANGE in slope is not increasing much, it fits to a linear slope. Compared to the linear Xs, where the CHANGE in slope is absurd, so it only fits to 60.8%.
[05:11:28] RickHull: er, the first slope is 11 I guess. 99 / 9
[05:11:54] mtkd: has joined #ruby
[05:11:55] RickHull: the next slope is 9900 / 90
[05:11:59] zenspider: both slopes are given in the formula
[05:12:38] zenspider: 1027 vs 300990... but that value doesn't matter, what matters is how the formula fits the data
[05:13:14] RickHull: the slope gets 10x steeper between every pair of points
[05:13:19] RickHull: just looking at table 1
[05:13:47] RickHull: it's around 10, then around 100, then the final slope between the last pair of points is around 1000
[05:14:29] RickHull: we can't accept an analysis that says "yup, that's linear"
[05:15:06] zenspider: you... mathmatica, apple numbers, and mathematica all agree that it fits to 99%
[05:15:22] RickHull: I totally agree the r^2 is correctly calculated
[05:15:26] RickHull: it's over 0.99
[05:15:39] zenspider: kk. then we're on the same page there... where are we diverging, if you can point to it?
[05:15:42] RickHull: it's the wrong test though
[05:15:50] RickHull: we know the data are nonlinear
[05:15:57] RickHull: so a test that says yup, it's linear is wrong
[05:16:33] RickHull: the r^2 doesn't distinguish between y=mx and y=x^2 very well
[05:16:55] RickHull: it was designed to distinguish a linear "pattern" from a scatter plot
[05:17:18] RickHull: that is a cloud of points. where the r^2 is high, it's saying there is a relationship between x and y, not random
[05:17:21] zenspider: I wish I could find that really awesome example of a perfect R^2, but when you visualize it, the plot is a perfect circle (therefore no fit at all)
[05:17:48] zenspider: nope. man... I'm gonna have to disagree with you there.
[05:18:11] zenspider: If you say assert_linear and you give it data that fits to 99%, then it fits to linear.
[05:18:24] zenspider: this is the case of setting up a bad experiment
[05:19:03] RickHull: the linear r^2 is measuring the error relative to x_bar predictor
[05:19:04] zenspider: I do NOT agree that this is a failure in assert_<whatever>.
[05:20:46] RickHull: in statistics, it helps distinguish a relationship from "no relationship"
[05:21:03] RickHull: but we care about distinguishing linear from exponential
[05:23:22] RickHull: if my simple example with y=x^3 fails to reject, then who knows what other real world data is failing to reject
[05:24:28] goyox86: has joined #ruby
[05:25:14] zenspider: if you care about distinguishing linear from exponential, then you need to set up yor experiment correctly (I view benchmark tests as scientific experiments more than straight up assertions in tests). You are positing a theory that something fits linearly. The data you give it DOES fit linearly. Therefore your experiment is a success. But you chose poorly for your input data. Visualizing that shows that and helps to easily corrects the
[05:25:15] zenspider: experiment.
[05:25:33] zenspider: This is also why benchmarks output a table of numbers in tab delimited format, so you can paste into a spreadsheet
[05:26:17] RickHull: i think that part of the reporting isn't working quite right, or not for me anyway
[05:26:26] RickHull: but shelve that for now :)
[05:26:59] zenspider: the output?
[05:27:33] RickHull: yeah, IIRC it just dumps the Ys not the Xs
[05:27:53] RickHull: or maybe the other way around -- I'll take another look later
[05:27:54] zenspider: ah. that might be true. Lemme poke
[05:28:14] zenspider: totally true. I'll fix that
[05:28:28] RickHull: in the realm of CS, asserting linear perf is -- in my eyes -- asserting O(N)
[05:28:46] RickHull: and anyone talking about O(N) cares greatly about distinguishing from O(N^2)
[05:29:13] RickHull: so a statistical test that fails to reject O(N^2) data is maybe the wrong tool
[05:29:58] RickHull: I've laid out the reasons why I believe the linear r^2 is bad for distinguishing against "higher order" relationships
[05:30:02] RickHull: (if that is the right term)
[05:30:09] rivalomega: has joined #ruby
[05:30:13] RickHull: it's good at distinguishing from "no relationship"
[05:30:13] cschneid_: has joined #ruby
[05:31:06] RickHull: i still think it can be salvaged -- just by running the exponential r^2 and making sure it's not higher
[05:34:53] alfiemax: has joined #ruby
[05:35:48] zenspider: That "S" in CS implies that we do science (experiments)... that includes crafting good experiments. Not sure which "it" you're referring to in "it can be salvaged".
[05:35:59] RickHull: the use of linear r^2
[05:36:05] RickHull: in asserting linear perf
[05:36:17] zenspider: I need a test against the benchmark tests to fix the domain row not printing... but I have the fix in place already
[05:36:35] workmad3: has joined #ruby
[05:37:03] RickHull: if there is an order: random / constant -> logarithmic -> linear -> exponential -> power
[05:37:26] RickHull: the linear r^2 just says hey: I'm not random / constant
[05:37:31] zenspider: *sigh*... I think we're going to have to agree to disagree.
[05:37:34] zenspider: I believe your test is simply bad. Just like any experiment that fails to pick good data and doesn't visualize it to see that the data was poorly picked.
[05:37:46] zenspider: you have a high R^2, because you created a high R^2.
[05:38:03] zenspider: and the code is working properly... and the experiment is passing because that's how it was structured.
[05:38:12] RickHull: the data are literally xs = [1, 10, 100, 1000] and ys = xs.map { |x| x**3 }
[05:38:25] RickHull: that's a classic case that assert_linear should reject
[05:38:31] zenspider: Yes, it is. and that fits to a linear model quite well.
[05:38:35] RickHull: even if the linear r^2 is high
[05:38:39] zenspider: as shown, graphically, and mathematically
[05:39:07] zenspider: assert_linear should NOT reject it, if that's the domain you picked
[05:39:16] Exhiled: has joined #ruby
[05:40:17] RickHull: I guess we'll have to agree to disagree. in CS we care about distinguishing linear from the higher order relationships. the statistical r^2 distinguishes from lower order relationships
[05:41:00] RickHull: it's just not good for detecting x^3
[05:41:15] RickHull: but that's what we care about -- detecting O(N^3)
[05:41:53] goyox86: has joined #ruby
[05:42:49] RickHull: the example is contrived -- but illustrative. it's a classic test case that we would not want our O(N) verifier to accept
[05:43:23] sriehl: has joined #ruby
[05:43:23] sriehl: has joined #ruby
[05:43:43] zenspider: OK... let's say this: You say: "it's just not good for detecting x^3"... that is NOT WHAT fit_linear does. if you want to detect x^3, then set up your experiment for it and use fit_exponential. If you want to detect linear, use fit_linear. In BOTH CASES, you *must* set up your experiment correctly or GIGO
[05:44:30] charliesome: has joined #ruby
[05:44:42] RickHull: well.. I don't know what my data is... I expect it it to be linear, so I assert_linear
[05:44:52] RickHull: and it says yup, it's linear
[05:45:05] RickHull: and only later do I go back to find my data is y=x^3
[05:45:05] bkxd: has joined #ruby
[05:45:10] zenspider: no... it says "yup, it fits linear to the degree you accept for this experiment"
[05:45:32] RickHull: that's another problem -- deciding up front what the r^2 threshold should be
[05:45:43] RickHull: this is why I think it's much more robust to run all fits and remember the best
[05:45:51] RickHull: and assert_linear only succeeds if best=linear
[05:46:08] zenspider: not sure I agree with you there.
[05:46:32] zenspider: that means you're saying "the shape of this shouldn't change with time" rather than saying "this should be X"
[05:46:44] zenspider: and that's just too wishywashy for me
[05:46:49] RickHull: no -- i'm definitely saying it should be X
[05:46:52] RickHull: it should be linear
[05:46:58] RickHull: and if exponential fits it better, then fail
[05:47:31] ruby[bot]: has joined #ruby
[05:47:32] ChanServ: +o ruby[bot]
[05:48:04] zenspider: what you said above "I think it's much more robust to run all fits and remember the best" is "it should be X, but I don't care what X is, as long as it stays X". If it is linear initially, great... if exponential, that's great too. as long as it stays the same
[05:48:17] RickHull: sorry -- I don't mean remember the best between bench runs
[05:48:25] zenspider: ah. ok. gotcha
[05:48:30] RickHull: I mean that my bench code has: assert_linear
[05:48:37] RickHull: and assert_linear goes and runs all the fits
[05:48:46] RickHull: and it fails if the best fit is not linear
[05:48:54] Hanmac: has joined #ruby
[05:49:04] uZiel: has joined #ruby
[05:49:26] RickHull: this should be much more robust for the x^3 problem and it sidesteps the need to decide an r^2 threshold
[05:49:37] RickHull: and you can still keep the r^2 threshold as an additional check
[05:50:06] RickHull: so even if best fit is linear but 0.65 r^2, you can fail assert_linear
[05:50:25] zenspider: at that point... blech
[05:50:41] RickHull: i want my assertions to fail :)
[05:51:06] zenspider: I see that. I want you to set up good experiments. :P
[05:51:22] RickHull: I got to this point by assert_linear passing on nonlinear data
[05:51:25] zenspider: I think this definitely points to a doco failure for sure.
[05:52:17] zenspider: but I'm more convinced that the math is working as intended, but it is too easy to set up bad experiments and have them pass. Not sure the best way to address that atm
[05:52:37] RickHull: yes, the math is correct
[05:52:45] RickHull: but I think the application of the math is flawed
[05:53:09] RickHull: since we care about distinguishing linear from higher order, we should make sure that higher order fits don't fit better
[05:53:25] RickHull: the linear fit on its own only distinguishes from lower order
[05:53:29] zenspider: agreed.... but that's where I stop, and you think assert_X should do something about it.
[05:53:39] zenspider: (agreed = application of math line)
[05:53:57] zenspider: I don't know this higher order vs lower order you keep using.
[05:54:17] RickHull: i think it's the wrong terminology
[05:54:22] RickHull: but here's the order: random / constant -> logarithmic -> linear -> exponential -> power
[05:54:38] RickHull: or maybe exponential is "steeper" than power?
[05:55:05] RickHull: corresponds to O(1) O(log n) O(N) O(N^2) O(2^N)
[05:55:05] zenspider: it is. I think I keep saying exponential when I mean geometric / power
[05:55:26] RickHull: we'd like to maybe have O(N log N) but anyway... :)
[05:55:55] RickHull: the linear r^2 calculates the relative error between a linear predictor and a constant predictor (y_bar)
[05:56:14] RickHull: y_bar meaning the mean of the ys
[05:56:32] RickHull: so it's good at distinguishing the lower order from linear
[05:56:46] RickHull: but not good at distinguishing the higher order from linear
[05:57:27] RickHull: the error from the constant predictor (y_bar) is huge in the case of y=x^3
[05:57:45] RickHull: and so it swamps the (still considerable!) error from the y=mx+b predictor
[05:58:32] RickHull: the last two lines are just my understanding after looking into this -- I'd love to hear from an expert
[05:59:57] RickHull: with more data points, or different X gaps, the linear r^2 probably goes down
[06:00:25] RickHull: but I bet I could come up with 20 examples of at least 4 data points that linear r^2 will fail to reject
[06:01:05] RickHull: where it's obvious the relationship is not linear -- it's a higher order relationship
[06:01:18] RickHull: but linear r^2 just doesn't look at it that way
[06:02:18] RickHull: assert_linear should be more about rejecting higher order relationships
[06:02:31] rob: has joined #ruby
[06:03:17] Guest59039: Anybody home that would be willing to help run through a quick coding issue?
[06:04:33] Exhiled: has joined #ruby
[06:05:33] apparition: has joined #ruby
[06:06:39] faces: has joined #ruby
[06:07:15] Guest59039: in the situation below, what would be the proper way to phrase the if then statement?
[06:07:18] Guest59039: {% for link.title == "page.title" %} {% assign collection = collections.[page.title] %}
[06:08:03] elphe: has joined #ruby
[06:08:47] RickHull: probably you want `if` instead of `for`
[06:09:02] RickHull: what templating system is that?
[06:09:12] Guest59039: This is for shopify
[06:09:21] Guest59039: the original statement was if
[06:09:52] RickHull: I don't know what to tell you about the {% %} stuff
[06:09:52] Guest59039: Though it currently is {% for link.title == "age.title" %} {% assign collection = collections.[page.title] %}
[06:09:59] Guest59039: sorry about that last post there
[06:10:25] Guest59039: {% for link.title == "Men's Apparel" %} {% assign collection = collections.mens-apparel %}
[06:11:08] Guest59039: I need to be able to assign the collections.mens-apparel as a general reference to whatever link.title may be
[06:11:22] Guest59039: link.title can either be a collections.title or a page.title
[06:11:30] keyjoo_: has joined #ruby
[06:12:22] RickHull: eh -- I don't think this is ruby
[06:12:38] Guest59039: I just generally need link title to be placed in front of collections on the assign function
[06:12:42] MrBismuth: has joined #ruby
[06:13:01] Guest59039: Shopify uses liquid files which use ruby and css
[06:13:28] RickHull: no clue, sorry. I've never used `for` in ruby
[06:14:00] Guest59039: Using if instead of for is not an issue
[06:14:09] RickHull: it is in ruby
[06:14:26] Guest59039: I can use {% if %} {% assign %}
[06:14:46] RickHull: dunno, I don't have time to learn a new language and explain it to you
[06:17:33] Guest59039: Sighz, sorry. Didn't know that it would be that far of a stretch from ruby, seeing as, having done some basic work in ruby, it functions pretty much the same
[06:17:37] Guest59039: Thanks for your time though.
[06:17:57] RickHull: sorry I couldn't be more helpful -- good luck :)
[06:20:38] Technodrome: has joined #ruby
[06:21:38] bkxd_: has joined #ruby
[06:27:06] 07IAB5HXJ: has joined #ruby
[06:31:59] bkxd: has joined #ruby
[06:45:50] Technodrome: has joined #ruby
[06:52:43] dan64: has joined #ruby
[06:57:54] shinnya: has joined #ruby
[07:01:07] KrzaQ: Does ruby have something like https://dlang.org/phobos/std_range.html#only ? I'd like to do a.only resulting in [a]
[07:03:30] elphe: has joined #ruby
[07:05:00] yeticry: has joined #ruby
[07:05:16] ur5us: has joined #ruby
[07:08:47] CrazyEddy: has joined #ruby
[07:16:40] cschneid_: has joined #ruby
[07:17:08] yeticry: has joined #ruby
[07:17:57] mozzarella: KrzaQ: why? does it do anything special?
[07:18:08] cdg: has joined #ruby
[07:18:20] KrzaQ: doesn't break pretty function chains
[07:19:01] mozzarella: give me an example where it breaks a chain
[07:19:53] alfiemax: has joined #ruby
[07:20:09] bkxd: has joined #ruby
[07:20:11] CrazyEddy: has joined #ruby
[07:20:40] cdg_: has joined #ruby
[07:22:40] KrzaQ: Array multiplication was my use case. ([a,b,c].chain.chain.chain * 10).chain.chain.chain vs [a,b,c].chain.chain.chainonly.map{*64}.first.chain.chain.chain
[07:22:43] elphe: has joined #ruby
[07:23:22] KrzaQ: missed a dot there, but I think it's readable anyway
[07:27:51] cschneid_: has joined #ruby
[07:32:37] RickHull: I still don't get what `only` does
[07:33:25] RickHull: it looks like something specific to D's version of ranges and avoiding memory allocation
[07:34:21] RickHull: but uh, have you considered Range#to_a ?
[07:34:34] RickHull: >> (0..3).to_a
[07:34:36] ruby[bot]: RickHull: # => [0, 1, 2, 3] (https://eval.in/915929)
[07:34:44] KrzaQ: I literally said it
[07:34:45] KrzaQ: I'd like to do a.only resulting in [a]
[07:35:03] elphe: has joined #ruby
[07:35:16] KrzaQ: possibly not an array/range
[07:35:23] KrzaQ: /enumerable
[07:35:57] KrzaQ: in D 10.only is pretty much equal to [10].
[07:36:33] KrzaQ: I didn't see anything similar in Ruby's docs, but I asked to be sure
[07:36:58] workmad3: has joined #ruby
[07:37:23] RickHull: not as a method on any object. but you can make it so:
[07:37:43] RickHull: >> class Object; def only; [self]; end; end; 10.only
[07:37:44] ruby[bot]: RickHull: # => [10] (https://eval.in/915930)
[07:37:51] KrzaQ: yeah, that's what I went with
[07:38:42] KrzaQ: I just wondered whether I'm duplicating existing functionality
[07:39:24] KrzaQ: RickHull: the way you said it implies that there are kinds of objects that already have .wrap_in_enumerable functionality. Have I misunderstood it?
[07:39:25] RickHull: not that I'm aware of
[07:40:01] KrzaQ: Now my aoc solution is a straight line of chains :)
[07:40:02] RickHull: in general, in Ruby, you wrap something in an array by wrapping it in square brackets ;)
[07:40:16] bkxd: has joined #ruby
[07:40:31] KrzaQ: but that breaks pretty chains
[07:41:32] RickHull: that's the cost of having a distinction between a method receiver and its first arg
[07:41:52] RickHull: e.g. why `puts 'this'` and not `'this'.puts`
[07:42:37] KrzaQ: I'm a fan of how D handles this
[07:42:55] RickHull: for pretty chains, I like Elixir's |>
[07:43:13] rippa: has joined #ruby
[07:43:59] CrazyEddy: has joined #ruby
[07:44:50] CrazyEddy: has joined #ruby
[07:45:56] cdg: has joined #ruby
[07:50:13] uZiel: has joined #ruby
[07:53:38] goyox86: has joined #ruby
[07:53:41] cdg: has joined #ruby
[07:55:48] cdg_: has joined #ruby
[07:58:33] elphe: has joined #ruby
[07:58:51] al2o3-cr: has joined #ruby
[08:00:08] ur5us: has joined #ruby
[08:00:24] Mia: has joined #ruby
[08:00:24] Mia: has joined #ruby
[08:04:35] elphe: has joined #ruby
[08:05:43] cschneid_: has joined #ruby
[08:06:33] guardianx: has joined #ruby
[08:07:32] veeti: has joined #ruby
[08:08:03] dionysus69: has joined #ruby
[08:08:20] yeticry: has joined #ruby
[08:19:35] KrzaQ: https://mlomnicki.com/yield-self-in-ruby-25/ that's kind of what I wanted, lol
[08:20:40] bkxd: has joined #ruby
[08:26:21] goyox86: has joined #ruby
[08:26:31] Technodrome: has joined #ruby
[08:29:39] dionysus69: has joined #ruby
[08:29:42] RickHull: ah, good article. I wasn't sure what the fuss was about
[08:30:33] cdg: has joined #ruby
[08:31:31] InfinityFye: has joined #ruby
[08:34:38] armyriad: has joined #ruby
[08:36:52] veeti: has joined #ruby
[08:36:58] InfinityFye: has left #ruby: ("Leaving")
[08:38:53] Emmanuel_Chanel: has joined #ruby
[08:42:14] alex``: has joined #ruby
[08:42:36] elphe: has joined #ruby
[08:44:50] jnyw: has joined #ruby
[08:46:27] bkxd_: has joined #ruby
[08:49:55] apparition: has joined #ruby
[08:51:26] cdg: has joined #ruby
[08:53:36] elphe: has joined #ruby
[08:55:19] claudiuinberlin: has joined #ruby
[08:57:55] bkxd: has joined #ruby
[09:05:00] baweaver: RickHull: that article gave me really bad ideas
[09:05:11] baweaver: Imma write my own and do bad things to Ruby again
[09:05:17] yeticry: has joined #ruby
[09:07:05] baweaver: Primarily around ActiveRecord, wrappers, and Maybes
[09:08:57] baweaver: I still really wish they'd chosen a shorter name. #tap vs #yield_self vs #pipe (my fave)
[09:17:24] yeticry: has joined #ruby
[09:19:00] elphe: has joined #ruby
[09:19:00] baweaver: hrm. Model#using -> Model.where(conditions: something).using(params[:limit]) { |l| limit(l) }
[09:19:19] baweaver: Not sure how I'd get it to respect that though
[09:19:59] baweaver: Thought about a fluent hash syntax some time ago: Model.with(limit: {if: params[:limit]})
[09:20:04] baweaver: though that can be ugly
[09:20:05] dviola: has joined #ruby
[09:20:37] baweaver: ACTION needs to play more
[09:25:39] miskatonic: has joined #ruby
[09:32:57] apparition: has joined #ruby
[09:33:26] oetjenj: has joined #ruby
[09:37:00] marr: has joined #ruby
[09:37:27] workmad3: has joined #ruby
[09:39:07] mjolnird: has joined #ruby
[09:39:33] bkxd_: has joined #ruby
[09:40:44] clemens3: has joined #ruby
[09:41:47] ldepandis: has joined #ruby
[09:44:02] ur5us: has joined #ruby
[09:45:13] guille-moe: has joined #ruby
[09:48:10] dionysus69: has joined #ruby
[09:49:12] mikecmpbll: has joined #ruby
[09:54:27] bkxd: has joined #ruby
[09:59:44] DoubleMalt: has joined #ruby
[10:01:04] dionysus69: has joined #ruby
[10:04:10] sagax: has joined #ruby
[10:06:19] dionysus69: has joined #ruby
[10:16:58] uZiel: has joined #ruby
[10:17:44] mtkd: has joined #ruby
[10:23:29] aurelien: has joined #ruby
[10:24:32] JustASlacker: has joined #ruby
[10:31:25] iamarun: has joined #ruby
[10:31:29] KeyJoo: has joined #ruby
[10:40:35] KeyJoo: has joined #ruby
[10:42:41] apparition: has joined #ruby
[10:50:23] GodFather: has joined #ruby
[10:50:35] bkxd_: has joined #ruby
[10:51:04] guille-moe: has joined #ruby
[11:12:05] oetjenj: has joined #ruby
[11:12:53] oetjenj: has joined #ruby
[11:13:37] oetjenj: has joined #ruby
[11:14:24] oetjenj: has joined #ruby
[11:15:10] oetjenj: has joined #ruby
[11:19:27] hfp_work: has joined #ruby
[11:20:21] Technodrome: has joined #ruby
[11:32:21] bkxd: has joined #ruby
[11:38:03] workmad3: has joined #ruby
[11:44:48] ur5us: has joined #ruby
[11:45:00] al2o3-cr: has joined #ruby
[11:58:08] Technodrome: has joined #ruby
[12:01:23] ski7777: has joined #ruby
[12:01:34] alfiemax: has joined #ruby
[12:02:59] GodFather: has joined #ruby
[12:03:12] oetjenj: has joined #ruby
[12:04:44] TomyLobo: with pry, is there a way to execute a .rb file either inside the pry environment or at least with the same binding?
[12:05:22] Papierkorb: TomyLobo: just `load "foo.rb"` it
[12:05:59] bkxd_: has joined #ruby
[12:06:13] TomyLobo: Papierkorb, and that ensures that i can access the same locals pry can?
[12:06:16] Papierkorb: If you want it to run within the same binding too, you can try`binding.eval File.read("foo.rb")`, but that may or may not do what you expect
[12:07:51] TomyLobo: the binding thing
[12:11:37] mikecmpbll: has joined #ruby
[12:15:35] DTZUZO: has joined #ruby
[12:17:06] banisterfiend: has joined #ruby
[12:25:35] despai: has joined #ruby
[12:28:52] enterprisey: has joined #ruby
[12:29:21] nicoulaj: has joined #ruby
[12:39:02] yeticry: has joined #ruby
[12:40:19] Technodrome: has joined #ruby
[12:41:52] mtkd: has joined #ruby
[12:48:25] selim: has joined #ruby
[12:52:52] shinnya: has joined #ruby
[12:54:17] csk157: has joined #ruby
[13:02:58] AJA4350: has joined #ruby
[13:13:19] yeticry: has joined #ruby
[13:17:33] guardianx: has joined #ruby
[13:24:53] yeticry: has joined #ruby
[13:27:02] kitsunenokenja: has joined #ruby
[13:37:40] cpruitt: has joined #ruby
[13:37:50] yeticry: has joined #ruby
[13:38:18] workmad3: has joined #ruby
[13:43:47] yeticry: has joined #ruby
[13:45:31] ur5us: has joined #ruby
[13:47:09] Asher: has joined #ruby
[13:48:27] c0ncealed: has joined #ruby
[13:50:41] Technodrome: has joined #ruby
[13:54:45] goepsilongo: has joined #ruby
[13:55:31] yeticry: has joined #ruby
[14:02:10] benjen: has joined #ruby
[14:06:28] UserOO7: has joined #ruby
[14:06:50] gizmore: has joined #ruby
[14:06:56] UserOO7: has joined #ruby
[14:07:10] ltem: has joined #ruby
[14:27:53] dinfuehr: has joined #ruby
[14:29:30] uZiel: has joined #ruby
[14:31:46] guille-moe: has joined #ruby
[14:33:54] UserOO7_: has joined #ruby
[14:37:44] Asher: has joined #ruby
[14:43:05] Barrt: has joined #ruby
[15:10:03] UserOO7: has joined #ruby
[15:11:49] jottr: has joined #ruby
[15:12:07] UserOO7: has joined #ruby
[15:22:43] UserOO7_: has joined #ruby
[15:28:47] kitsunenokenja: has left #ruby: ("WeeChat 1.9.1")
[15:37:12] vtx: has joined #ruby
[15:37:14] UserOO7: has joined #ruby
[15:38:10] uZiel: has joined #ruby
[15:38:38] workmad3: has joined #ruby
[15:38:43] JaccoP: has joined #ruby
[15:40:41] vtx: hi guys. i have a configure block in my sinatra app that looks like: https://gist.github.com/anonymous/3425b88a733e84b004d03a9921a43beb so, i want to instantiate services once at startup, and then set the db on my settings. so that, every time i try to use the db, only one connection is ever created, and that connection is used by all requests. however, calling settings.db seems to call into services.db every time i try to use settings.db, which means a ne
[15:40:41] vtx: connection is created for every request. how can i force settings.db to not reference the db via services?
[15:46:15] ur5us: has joined #ruby
[15:46:50] despai: has joined #ruby
[15:48:52] JustASlacker: has joined #ruby
[15:51:38] alfiemax: has joined #ruby
[15:52:14] JustASlacker: has joined #ruby
[15:55:11] nadir: has joined #ruby
[15:57:46] pwnd_nsfw`: has joined #ruby
[16:03:44] vtx: guys does anyone here use mongo with ruby? my application keeps creating connections to the database instead of reusing the same connection
[16:07:28] DTZUZO: has joined #ruby
[16:13:42] MrSparkle: has joined #ruby
[16:14:35] mtkd: has joined #ruby
[16:17:53] UserOO7_: has joined #ruby
[16:19:27] def_jam: has joined #ruby
[16:19:42] eb0t: has joined #ruby
[16:29:15] elphe: has joined #ruby
[16:30:15] UserOO7: has joined #ruby
[16:55:45] TinkerTyper: has joined #ruby
[16:56:34] DLSteve: has joined #ruby
[16:57:53] kapil___: has joined #ruby
[17:03:05] dinfuehr: has joined #ruby
[17:04:49] ledestin: has joined #ruby
[17:05:02] despai: has joined #ruby
[17:09:22] UserOO7: has joined #ruby
[17:09:43] tomphp: has joined #ruby
[17:10:03] UserOO7: has joined #ruby
[17:16:20] Aloy: has joined #ruby
[17:22:00] claudiuinberlin: has joined #ruby
[17:34:20] tomphp: has joined #ruby
[17:34:38] havenwood: KramerC: In Ruby 2.5 you'll be able to use #yield_self like: 42.yield_self { |n| [n] }
[17:35:10] KrzaQ: yeah, I linked an article about it later
[17:35:37] KrzaQ: yield_self is exactly what I want, because right now I have .to_array.map{...}.first
[17:36:09] alex``: has joined #ruby
[17:36:32] CrazyEddy: has joined #ruby
[17:39:02] workmad3: has joined #ruby
[17:41:42] Dimik: has joined #ruby
[17:42:11] dviola: has joined #ruby
[17:44:06] ur5us: has joined #ruby
[17:44:48] anisha: has joined #ruby
[17:46:44] rivalomega: has joined #ruby
[17:47:09] rivalomega: has joined #ruby
[17:53:37] anisha: has joined #ruby
[17:56:07] CrazyEddy: has joined #ruby
[18:01:00] cdg: has joined #ruby
[18:05:11] guille-moe: has joined #ruby
[18:09:47] orbyt_: has joined #ruby
[18:11:29] pifon: has joined #ruby
[18:11:43] leah2: has joined #ruby
[18:14:30] CrazyEddy: has joined #ruby
[18:15:11] techn1cs: has joined #ruby
[18:15:11] techn1cs: has joined #ruby
[18:16:22] mostlybadfly: has joined #ruby
[18:18:12] mtkd: has joined #ruby
[18:23:24] csk157: has joined #ruby
[18:25:50] nowhere_man: has joined #ruby
[18:38:19] Technodrome: has joined #ruby
[18:39:00] CrazyEddy: has joined #ruby
[18:41:27] konsolebox: has joined #ruby
[18:44:47] miskatonic: has joined #ruby
[18:48:36] despai: has joined #ruby
[18:49:39] conta: has joined #ruby
[18:50:15] enterprisey: has joined #ruby
[18:50:55] rivalomega: has joined #ruby
[18:51:06] CrazyEddy: has joined #ruby
[18:52:15] yeticry: has joined #ruby
[18:53:43] claudiuinberlin: has joined #ruby
[18:55:37] cschneid_: has joined #ruby
[18:57:03] vtx: has joined #ruby
[18:57:39] vtx: guys does anyone here use mongo with ruby? my application keeps creating connections to the database instead of reusing the same connection
[18:58:48] RickHull: vtx: can you point to the sinatra docs that cover this? (configure blocks)
[18:58:52] yeticry: has joined #ruby
[18:59:07] RickHull: is API::Services your class/module?
[18:59:14] RickHull: or Sinatras? or Mongos?
[19:00:02] vtx: RickHull: sorry, that’s my class
[19:00:45] RickHull: you mention settings.db but I dont see it in the gist
[19:00:52] vtx: so, i have API::Services as a class that contains all the code for parsing my env config, and setting up the necessary resources like loggers and in this case, a db connection
[19:01:12] RickHull: can you paste the relevant sections?
[19:01:43] vtx: RickHull: um okay, i’ve spent some trying moving stuff around, but it’s still not working, so i guess i’ll paste it anyway
[19:01:53] RickHull: what class is the actual connection? is it a Mongo class?
[19:02:50] RickHull: my gut says you are doing too much configuration stuff -- abstraction rather than working directly
[19:04:20] vtx: RickHull: so this is my config.ru: https://gist.github.com/anonymous/75a221227555732eb9afbca638e50712
[19:04:36] RickHull: ah, Rack, ok
[19:04:47] vtx: i’ve moved all the stuff around setting the db on the application into config.ru, so it’s completely removed from the api endpoints
[19:05:37] vtx: RickHull: i’m basing this off http://recipes.sinatrarb.com/p/databases/mongo which talks about using set to set a property on the application, which then can be access via settings
[19:05:41] RickHull: does Mongo::Client really want an array of strings?
[19:06:05] RickHull: apparently yes
[19:06:15] PaulCapestany: has joined #ruby
[19:06:26] vtx: so, the idea is, i create a connection at startup, and that connection gets reused for every request
[19:07:11] vtx: but looking at my mongo logs, every time i hit the endpoint, mongo prints out the number of connections, and that number continues to grow for every request
[19:07:29] RickHull: take a step back. can you make a single page sinatra app? like without config.ru ?
[19:07:47] RickHull: i notice the sinatra page has the configure block in a .rb file
[19:08:02] RickHull: sorry, not single page app -- i mean a single .rb file
[19:08:23] RickHull: i haven't used sinatra or rack in a while so I'm pretty rusty
[19:08:47] RickHull: in other words, start small, and make sure your little prototype does what you want
[19:09:01] RickHull: in terms of connection handling
[19:09:30] RickHull: skip all your API::Services stuff
[19:09:50] RickHull: just make a simple app that talks to mongo, send it a few requests, and watch the connections
[19:10:03] ur5us: has joined #ruby
[19:11:20] RickHull: also, I notice the sinatra recipe has: `set :db, client[db]` but you have: `set :db, client[db].database`
[19:14:52] vtx: RickHull: yep, but that’s jsut because later on in their code, they access database before accessing their collection name
[19:16:19] rivalomega: has joined #ruby
[19:17:27] selim: has joined #ruby
[19:18:25] RickHull: so -- do you think you can make a simple example that shows mongo connection reuse for multiple requests?
[19:19:11] vtx: um i guess i can try, i’ve only ever set it up before with config.ru etc, but i’ll give it a go to see if it narrows down the issue
[19:21:13] astronavt: has joined #ruby
[19:21:37] GodFather: has joined #ruby
[19:24:32] tomphp: has joined #ruby
[19:25:34] yxhuvud: has joined #ruby
[19:25:42] Technodrome: has joined #ruby
[19:27:01] Barrt: has joined #ruby
[19:28:53] guille-moe: has joined #ruby
[19:29:36] RickHull: i think you could probably copy/paste the sinatra recipe thing and go from there
[19:33:23] dionysus69: has joined #ruby
[19:33:41] RickHull: no need for all the CRUD stuff. just e.g. `get '/' do` and then query mongo
[19:34:39] cdg: has joined #ruby
[19:36:31] quobo: has joined #ruby
[19:37:25] bkxd: has joined #ruby
[19:39:23] workmad3: has joined #ruby
[19:43:33] nowhere_man: has joined #ruby
[19:43:35] therealGent: has joined #ruby
[19:44:35] tomphp: has joined #ruby
[19:47:54] milardovich: has joined #ruby
[19:49:29] goyox86_: has joined #ruby
[19:53:39] nofxx: has joined #ruby
[19:55:16] cdg: has joined #ruby
[19:55:41] kitsunenokenja: has joined #ruby
[19:58:14] cdg_: has joined #ruby
[19:59:54] techn1cs: has joined #ruby
[19:59:55] techn1cs: has joined #ruby
[20:03:26] rivalomega: has joined #ruby
[20:03:51] bkxd_: has joined #ruby
[20:05:18] workmad3: has joined #ruby
[20:09:27] JustASlacker: has joined #ruby
[20:12:57] unreal: has joined #ruby
[20:16:39] petervbeck: has joined #ruby
[20:16:52] milardovich: has joined #ruby
[20:18:52] petervbeck: has joined #ruby
[20:22:08] petervbeck: has joined #ruby
[20:23:08] astronavt: has joined #ruby
[20:24:19] kitsunenokenja: has left #ruby: ("WeeChat 1.9.1")
[20:26:21] pifon: has joined #ruby
[20:26:23] vtx: RickHull: so, running the smaller example worked, i.e., multiple requests doesnt result in multiple connections, so i’m gonna try and change up my main app to be similar to see if it works
[20:26:37] nofxx: has joined #ruby
[20:26:59] RickHull: cool! my immediate guess is something in the Services::API layer
[20:27:45] RickHull: or it could be due to the way rack is structured and under what circumstances the config.ru is initialized
[20:28:03] astronavt: has joined #ruby
[20:29:50] vtx: RickHull: yeah, so, thinking back to it, i did the whole services api layer to enable mocking for my spec tests, i.e. because the configure block runs when the file is loaded, my expect calls weren’t able to mock the db connection
[20:30:17] milardovich: has joined #ruby
[20:31:18] RickHull: yeah, testing web stuff can be tricky. I wish I had better advice here, but I wouldn't compromise or complicate your production runtime just to make testing easier
[20:31:43] RickHull: though I do tend to structure my apps to make testing easier
[20:32:00] RickHull: but without compromising or complicating the production scenario
[20:32:03] vtx: gah, changing the endpoint i’m calling to access the db connection isn’t working
[20:32:35] nofxx: personal opinion: do only integration non-mocked for views
[20:32:46] nofxx: don't loose time with unit in views and controllers
[20:33:05] nofxx: use chromeless/phantomjs and only happiness!
[20:33:55] vtx: is it possible to somehow find out what part of my code is causing the new connection to be created?
[20:36:32] RickHull: process of elimination ;)
[20:36:56] RickHull: that you have a working example with reusable connections is a great start
[20:37:12] RickHull: now, e.g. convert your working example to a config.ru example
[20:37:15] RickHull: and see what the effect is
[20:37:38] RickHull: or introduce the Services::API thing and see what the effect is
[20:37:47] csk157: has joined #ruby
[20:37:52] RickHull: poke and prod, trial and error
[20:42:13] conta: has joined #ruby
[20:44:13] vtx: oh i think i fixed it! just double checking
[20:44:54] drowze: has joined #ruby
[20:45:23] petervbeck: has joined #ruby
[20:46:25] astronavt: has joined #ruby
[20:48:42] bkxd: has joined #ruby
[20:52:36] astronavt: has joined #ruby
[20:57:13] milardovich: has joined #ruby
[21:07:44] vtx: RickHull: thanks so much for your help! i really appreciate it! \o/
[21:08:05] alfiemax: has joined #ruby
[21:08:33] RickHull: no prob, glad to help, cheers :)
[21:08:52] claudiuinberlin: has joined #ruby
[21:09:41] astronavt: has joined #ruby
[21:12:11] andrewir1: has joined #ruby
[21:13:53] JustASlacker: has joined #ruby
[21:14:13] rivalomega: has joined #ruby
[21:18:08] elphe: has joined #ruby
[21:18:10] Exhiled: has joined #ruby
[21:24:57] tomphp: has joined #ruby
[21:28:32] Technodrome: has joined #ruby
[21:29:08] armando: has joined #ruby
[21:30:36] bkxd_: has joined #ruby
[21:32:21] rivalomega: has joined #ruby
[21:34:00] bkxd: has joined #ruby
[21:35:38] Barrt: has joined #ruby
[21:39:22] yeticry: has joined #ruby
[21:49:58] Azure: has joined #ruby
[22:02:41] pwnd_nsfw: has joined #ruby
[22:03:02] elphe: has joined #ruby
[22:03:17] chocoelho: has joined #ruby
[22:03:17] aphprentice: has joined #ruby
[22:04:55] chmurifree: has joined #ruby
[22:12:23] jaruga: has joined #ruby
[22:12:58] nogic: has joined #ruby
[22:19:19] cdg: has joined #ruby
[22:19:41] bkxd: has joined #ruby
[22:20:11] AJA4350: has joined #ruby
[22:22:46] milardovich: has joined #ruby
[22:24:24] jinie: has joined #ruby
[22:36:29] orbyt_: has joined #ruby
[22:40:19] tomphp: has joined #ruby
[22:42:20] guardianx: has joined #ruby
[22:46:27] quobo: has joined #ruby
[22:51:55] cdg: has joined #ruby
[22:51:59] jinie: has joined #ruby
[22:52:31] johnzorn: has joined #ruby
[22:53:42] kitikonti: has joined #ruby
[22:53:59] krawchyk: has joined #ruby
[22:54:38] yeticry: has joined #ruby
[22:59:15] kitsunenokenja: has joined #ruby
[22:59:30] kitsunenokenja: has left #ruby: ()
[23:00:36] milardovich: has joined #ruby
[23:03:01] krawchyk: has joined #ruby
[23:04:46] tomphp: has joined #ruby
[23:04:51] nowhere_man: has joined #ruby
[23:12:40] bkxd: has joined #ruby
[23:15:59] ineb: has joined #ruby
[23:17:20] guardianx: has joined #ruby
[23:17:36] krawchyk: has joined #ruby
[23:24:03] ahrs: has joined #ruby
[23:26:21] Nightmare: has joined #ruby
[23:27:25] krawchyk: has joined #ruby
[23:28:26] armando: has joined #ruby
[23:29:24] johnpaul: has joined #ruby
[23:32:30] Lytol: has joined #ruby
[23:46:53] nowhere_man: has joined #ruby
[23:51:21] mullah_: has joined #ruby
[23:55:01] cschneid_: has joined #ruby
[23:57:30] bkxd: has joined #ruby
[23:57:56] minimalism: has joined #ruby
[23:59:05] cschneid_: has joined #ruby