« Back to channel list

#ruby - 19 March 2018

« Back 1 day Forward 1 day »
[00:07:15] white_lilies: has joined #ruby
[00:20:00] darkhanb: has joined #ruby
[00:20:26] n0m4d1c: has joined #ruby
[00:24:47] robscomputer: has joined #ruby
[00:31:04] dr3wo: has joined #ruby
[00:33:14] erlend: has joined #ruby
[01:06:54] BTRE: has joined #ruby
[01:06:55] duckpuppy: has joined #ruby
[01:08:25] meadmoon: has joined #ruby
[01:10:12] bmurt: has joined #ruby
[01:11:08] robscomputer: has joined #ruby
[01:14:12] noobineer: has joined #ruby
[01:22:01] duderonomy: has joined #ruby
[01:30:13] _whitelogger: has joined #ruby
[01:34:32] ElFerna: has joined #ruby
[01:35:37] ElFerna: has joined #ruby
[01:51:13] workmad3: has joined #ruby
[01:52:05] unreal: has joined #ruby
[01:55:35] duckpuppy: has joined #ruby
[01:55:48] alfiemax: has joined #ruby
[01:55:52] Emmanuel_Chanel: has joined #ruby
[01:56:57] Emmanuel_Chanel: has joined #ruby
[01:58:53] maedi_: has joined #ruby
[01:59:43] Maedi: has joined #ruby
[02:02:47] chatchatt: has joined #ruby
[02:07:29] banisterfiend: has joined #ruby
[02:09:05] alfiemax: has joined #ruby
[02:13:10] maedi_: has joined #ruby
[02:16:56] dstrunk: has joined #ruby
[02:24:48] kapil___: has joined #ruby
[02:25:42] alfiemax: has joined #ruby
[02:29:02] claw: has joined #ruby
[02:39:14] duderonomy: has joined #ruby
[02:41:21] gizmore: has joined #ruby
[02:41:54] erlend: has joined #ruby
[02:46:00] twe4ked: has joined #ruby
[02:47:56] garyserj: has joined #ruby
[02:48:39] garyserj: Say I do [1,2,3].each { |x| puts x } I've heard that the block is everything within the { } even perhaps including the {}. But i've also heard that |x| is passed into the block (which suggests that |x| is not part of the block itself). Which is it?
[02:48:59] robscomputer: has joined #ruby
[02:49:36] alfiemax: has joined #ruby
[02:50:07] alfiemax: has joined #ruby
[02:50:38] Radar: garyserj: it's a block argument. The .each method takes the block and executes the block for each item in the list. Each item is available as "x" inside the block because you do |x|
[02:51:30] jenrzzz: has joined #ruby
[02:52:02] garyserj: So is it correct to say that the stuff between the { } is not just the block. It's the parameter to the block, and the block?
[02:52:27] milardovich: has joined #ruby
[02:53:11] weaksauce: pretty much yeah but the entire thing is the block
[02:53:44] weaksauce: the block is an anonymous function that gets called on each execution of the each loop
[02:54:11] duckpuppy: has joined #ruby
[02:54:46] weaksauce: def somefunc(arg1, arg2) is very similar to something.anotherfunc do |arg1, arg2| puts x end
[02:54:53] weaksauce: er puts arg1
[02:55:12] Radar: fun = lambda { |x| puts x }
[02:55:22] Radar: >> fun = lambda { |x| puts x }; fun.call(1)
[02:55:23] ruby[bot]: Radar: # => 1 ...check link for more (https://eval.in/974240)
[02:55:27] Radar: >> fun = lambda { |x| puts x }; fun.(1)
[02:55:28] ruby[bot]: Radar: # => 1 ...check link for more (https://eval.in/974241)
[02:55:34] Radar: >> fun = lambda { |x| puts x }; [1,2,3].each(&fun)
[02:55:35] ruby[bot]: Radar: # => 1 ...check link for more (https://eval.in/974242)
[02:55:59] baweaver: A block is basically an anonymous function.
[02:56:00] baweaver: |x| is just supplying the argument to it.
[02:56:08] Radar: garyserj: Maybe those executable examples might help you understand it?
[02:56:37] baweaver: [1,2,3].map { |x| x * 2 } is the same as Javascript: [1,2,3].map(function (x) { return x * 2; })
[02:57:04] jenrzzz: has joined #ruby
[02:57:04] jenrzzz: has joined #ruby
[02:57:21] dinfuehr_: has joined #ruby
[03:01:01] garyserj: so in ruby, the block includes the signature?
[03:01:29] garyserj: well not so much signature 'cos it's an anonymous function
[03:01:36] garyserj: but the block includes the formal parameter.
[03:02:31] garyserj: baweaver: yes I understand that about how it works i'm just asking a definition question.
[03:03:00] baweaver: An argument is part of an anonymous function, so yes
[03:03:06] baweaver: { ... } is the block
[03:03:10] baweaver: do ... end is the block
[03:04:04] garyserj: and in other languages like c# or javascript, the block does not include the formal parameter, right?
[03:04:37] Xeago_: has joined #ruby
[03:04:46] garyserj: like c# says (int a)=>{a++;}
[03:05:00] baweaver: It does, it just has them outside
[03:05:12] baweaver: Ruby also has stabby lambdas: -> x { x * 2 }
[03:05:15] garyserj: baweaver: if it's outside the block it's not in the block
[03:05:42] garyserj: but yeah would do the same thign
[03:05:59] baweaver: If we're being incredibly pedantic
[03:06:00] baweaver: It's a part of the block
[03:06:56] garyserj: baweaver: in c# if you say void a(int t) {..} would you say that 'int t' is part of the block?
[03:07:14] baweaver: I'd say that that's not a block
[03:07:22] baweaver: at least not insofar as ruby parlence
[03:07:41] garyserj: what about (a,b)=>{..}
[03:07:52] garyserj: (int a, int b)=>{..}
[03:07:59] baweaver: ruby parlance conflates the idea of blocks and anonymous functions
[03:08:03] garyserj: would you say that int a, and int b, are part of the block?
[03:08:23] baweaver: redefine block to be anonymous function and I would say yes
[03:08:32] baweaver: because you're associating some other definition to block
[03:08:47] garyserj: well, without redefining block
[03:08:54] garyserj: e.g. is block meant to be {... } ?
[03:09:01] baweaver: though I would still argue that this really doesn't achieve anything other than being hopelessly pedantic
[03:09:28] garyserj: it's just a definition question
[03:09:41] garyserj: whether block is {...} or a formal parameter outside of it too
[03:09:47] jenrzzz: has joined #ruby
[03:09:53] jenrzzz: has joined #ruby
[03:09:59] baweaver: you have a definition though
[03:10:13] garyserj: no I have a blurry definition with a question mark.
[03:10:47] Radar: garyserj: The block is everything including the argument.
[03:10:53] Radar: The block without the argument is meaningless.
[03:10:59] Radar: And it won't... ahem... function.
[03:11:37] Radar: >> blk = lambda { "block with no args" }; blk.()
[03:11:37] ruby[bot]: Radar: # => "block with no args" (https://eval.in/974243)
[03:12:04] baweaver: ACTION approves of the punnery
[03:15:04] garyserj: blk = lambda {|d| "abc" } <-- is it possible to move the |d| outside the {..} ?
[03:15:10] jenrzzz: has joined #ruby
[03:15:11] jenrzzz: has joined #ruby
[03:15:30] baweaver: -> d { 'abc' }
[03:15:55] Radar: blk = -> d { d }; blk.(1)
[03:15:58] Radar: >> blk = -> d { d }; blk.(1)
[03:15:59] ruby[bot]: Radar: # => 1 (https://eval.in/974244)
[03:16:11] Radar: "stabby lambda" syntax
[03:16:55] garyserj: thanks.. and what's the reason for the dot?
[03:17:10] morfin: method call?
[03:17:12] weaksauce: it's a method call
[03:17:19] baweaver: being able to do paren-free has its drawbacks
[03:17:54] garyserj: but this is a dot between the name of the method and the arguments to the method
[03:18:07] Radar: garyserj: yes. It's a Ruby shortcut. Means the same as blk.call(1)
[03:18:07] baweaver: >> add2 = -> x { x + 2 }; [add2.(2), add2.call(2), add2[2]]
[03:18:09] ruby[bot]: baweaver: # => [4, 4, 4] (https://eval.in/974245)
[03:18:32] Radar: Elixir has the same shortcut for their anonymous functions.
[03:18:40] baweaver: [] because you can define the [] method: def [](arg) ... end
[03:18:46] ruby[bot]: weaksauce: # => 7 (https://eval.in/974246)
[03:19:05] baweaver: Slightly different with plus
[03:20:30] morfin: when i do blk.call() will scope available in block be same?
[03:21:56] garyserj: why do i have to say blk.call(4) Why can't I say blk(4)?
[03:21:59] Maedi: has joined #ruby
[03:22:11] Radar: garyserj: You can say blk.(4)
[03:22:24] Radar: blk(4) will make the interpreter look for a method called blk.
[03:22:35] morfin: seems like yes )
[03:22:38] garyserj: ok.. I get that blk.(4) = blk.call(4)
[03:22:47] morfin: https://eval.in/974252
[03:22:51] garyserj: so lambda syntax doesn't define a method?
[03:23:17] garyserj: ok so in ruby, functions and methods are different?
[03:23:28] garyserj: methods are on objects only i suppose
[03:23:29] Radar: methods are functions
[03:23:37] Radar: :mindblown:
[03:24:00] Radar: >> def a(b); puts b; end; method(:a).call(2)
[03:24:01] ruby[bot]: Radar: # => 2 ...check link for more (https://eval.in/974253)
[03:25:18] Radar: >> def a(b); puts b; end; method(:a).(2)
[03:25:19] ruby[bot]: Radar: # => 2 ...check link for more (https://eval.in/974254)
[03:25:41] Radar: The difference is that methods are defined on instances, but lambdas / procs are just ... out there, floating in the ether.
[03:25:50] Radar: Well, whatever scope they're defined in I guess.
[03:26:48] baweaver: I'm _really_ dang tempted to hack the lexer to allow proc(), proc(1), etc
[03:26:52] orbyt_: has joined #ruby
[03:31:30] garyserj: what about Class.new is .new a method and is Class an instance?
[03:32:37] jenrzzz: has joined #ruby
[03:33:07] morfin: Class is an instance
[03:33:25] morfin: >> Class.ancestors
[03:33:27] ruby[bot]: morfin: # => [Class, Module, Object, Kernel, BasicObject] (https://eval.in/974261)
[03:35:33] garyserj: Since classes are objects in ruby, then would be meant by 'an instance'?
[03:35:48] garyserj: then would = then what would
[03:37:53] Radar: Class is a instance of the Class class.
[03:39:19] Radar: I was thinking of running an instance of my classes to teach my juniors that Class is an instance of the Class class but... I think that's too classy for them.
[03:39:41] Radar: There will come an instance when they need to know this knowledge.
[03:39:58] Radar: but right now they're content with it being along the lines of the Dothraki: "It is known."
[03:40:21] garyserj: is sounds a bit recursive in the definition though
[03:40:22] yokel: has joined #ruby
[03:40:34] Radar: Yes. See also: the beginning of this line.
[03:40:50] garyserj: doesn't that make the definition flawed? there's no base case
[03:40:55] garyserj: the recursion is infinite
[03:41:02] Maedi: has joined #ruby
[03:41:12] garyserj: a circular definition
[03:41:34] Radar: ACTION feels like garyserj is trying to make a point
[03:41:40] Radar: ACTION squints really hard
[03:41:59] baweaver: class is a keyword
[03:42:00] baweaver: Class is an instance of class which is an Object
[03:42:21] baweaver: though I agree there's a point trying to be made here, though I still stand by this getting to be incredibly pedantic over definitions
[03:43:11] garyserj: baweaver: you wrote "Class is an instance of class " Do you mean Class is an instance of Class? ;-)
[03:43:19] garyserj: the keyword was class
[03:43:54] robscomputer: has joined #ruby
[03:44:20] baweaver: http://patshaughnessy.net/ruby-under-a-microscope
[03:44:51] baweaver: In any case I'm done.
[03:45:19] jenrzzz: has joined #ruby
[03:45:20] jenrzzz: has joined #ruby
[03:49:39] Radar: garyserj: So what's the point for all these questions?
[03:50:37] garyserj: Radar: just to improve my understanding, and it's improving. thanks
[03:51:28] workmad3: has joined #ruby
[03:51:42] d^sh: has joined #ruby
[03:52:01] KeyJoo: has joined #ruby
[03:55:09] jenrzzz: has joined #ruby
[03:55:47] duckpuppy: has joined #ruby
[03:59:27] Dimik: has joined #ruby
[04:11:37] p4tch3s: has joined #ruby
[04:15:38] drab_20: has joined #ruby
[04:22:04] tAn: has joined #ruby
[04:22:20] jenrzzz: has joined #ruby
[04:25:14] trautwein: has joined #ruby
[04:26:27] alfiemax: has joined #ruby
[04:28:54] jcarl43: has joined #ruby
[04:39:12] _whitelogger: has joined #ruby
[04:48:15] gix-: has joined #ruby
[04:50:02] Antiarc1: has joined #ruby
[04:50:36] erlend: has joined #ruby
[04:50:47] duckpuppy: has joined #ruby
[05:01:03] claw: has joined #ruby
[05:01:18] jenrzzz: has joined #ruby
[05:07:16] claw: has joined #ruby
[05:10:25] burgestrand: has joined #ruby
[05:11:29] jenrzzz: has joined #ruby
[05:15:13] za1b1tsu: has joined #ruby
[05:15:41] duderonomy: has joined #ruby
[05:20:26] Yzguy: has joined #ruby
[05:21:55] robscomputer: has joined #ruby
[05:29:43] howdoi: has joined #ruby
[05:33:08] Azure: has joined #ruby
[05:38:16] jenrzzz: has joined #ruby
[05:47:51] sidx64: has joined #ruby
[05:48:00] duckpuppy: has joined #ruby
[05:51:47] workmad3: has joined #ruby
[05:53:18] reber: has joined #ruby
[05:58:11] duderonomy: has joined #ruby
[06:03:50] stoffus: has joined #ruby
[06:04:14] anisha: has joined #ruby
[06:07:50] toks: has joined #ruby
[06:10:01] aupadhye: has joined #ruby
[06:12:09] jamesaxl: has joined #ruby
[06:14:07] jenrzzz: has joined #ruby
[06:27:01] mrx: has joined #ruby
[06:34:42] dminuoso: >> -> f { -> y { y[y] }[->x { f[-> v { x[x][v] }] }] }[-> f, x { x == Math.cos(x) ? x : f[Math.cos(x)]}.curry][3]
[06:34:44] ruby[bot]: dminuoso: # => 0.7390851332151607 (https://eval.in/974305)
[06:35:30] dminuoso: elomatreb: https://gist.github.com/dminuoso/15bf862cb1a8787e002a7d650a86c23b
[06:35:59] dminuoso: The error does not imply infinite recursion. It just means you've run out of stack space (Which could happen in legitimate non-infinite-recursion as well)
[06:38:55] sidx64_: has joined #ruby
[06:39:27] rwb: has joined #ruby
[06:44:11] sidx64: has joined #ruby
[06:49:24] jenrzzz: has joined #ruby
[06:53:46] duckpuppy: has joined #ruby
[06:57:28] alex``: has joined #ruby
[06:58:49] erlend: has joined #ruby
[07:00:28] shpoont: has joined #ruby
[07:00:40] karapetyan: has joined #ruby
[07:04:27] za1b1tsu: has joined #ruby
[07:05:14] apeiros: has joined #ruby
[07:11:21] sidx64: has joined #ruby
[07:18:58] sidx64: has joined #ruby
[07:19:39] pwntrik: has joined #ruby
[07:20:24] pwntrik: hey i'm trying to create modules (mixins?) that implement a class: https://paste.ofcode.org/34wkPJu3QV7Db7eQFAVATkG
[07:23:48] n008f4g_: has joined #ruby
[07:24:04] sidx64: has joined #ruby
[07:25:55] sidx64: has joined #ruby
[07:28:35] sidx64: has joined #ruby
[07:28:41] Mon_Ouie: pwntrik: I'm not sure how Rails autoloading works (see #rails), but maybe using ::TumbleTinder (to explicit the fact this is a top-level constant) would work?
[07:29:46] Mon_Ouie: Also if you want to call your method as Tumble::somefunc (or Tumble.somefunc) as opposed to Tumble.new.somefunc, you would have to use extend instead of include
[07:30:13] dminuoso: pwntrik: config/initializers is not an autoloaded directory. You have to restart the rails server to pick that class up (and probably spring as well)
[07:31:13] dminuoso: pwntrik: Err, even lib/ is not autoloaded. :-)
[07:31:17] conta: has joined #ruby
[07:32:04] dminuoso: pwntrik: Or it might be, but the error if self explanatory. If you nest this inside Tumble::, then the defining file has to be inside a tumble/ directory.
[07:36:19] pwntrik: i shouldn't have posted that error :( It's actually loading the file just fine. the problem is more about how do I factor my code so that "bar" is outputed
[07:37:32] toks: has joined #ruby
[07:38:21] pwntrik: What I want is to reference Tumble throughout the application, but I can create modules for Tumble that would replace functions. Like in the example above, by default Tumble::somefunc would output "foo" but I could load the module TumbleTinder and it would output "bar" instead.
[07:40:21] pwntrik: What I want is to reference Tumble throughout the application, but I can create modules for Tumble that would replace functions. Like in the example above, by default Tumble::somefunc would output "foo" but I could load the module TumbleTinder and it would output "bar" instead.
[07:40:29] pwntrik: oops sorry
[07:40:34] pwntrik: Now that I have the class and the module, how do I load the module so that calling Tumble::somefunc outputs "bar"? What code do I put in config/intializers or how do I do it?
[07:40:41] aufi: has joined #ruby
[07:41:09] schneider: has joined #ruby
[07:48:16] andikr: has joined #ruby
[07:52:06] workmad3: has joined #ruby
[07:53:06] duckpuppy: has joined #ruby
[07:55:20] Mon_Ouie: included Modules are like parent classes, they appear above the class they are included in in the ancestry chain, which mains methods are looked up in the class itself first
[07:55:39] Mon_Ouie: You can use Module#prepend to make the module appear before the class
[07:57:17] goatish: has joined #ruby
[07:59:51] alex``: has joined #ruby
[08:00:47] jenrzzz: has joined #ruby
[08:05:10] rabajaj: has joined #ruby
[08:05:44] jenrzzz: has joined #ruby
[08:05:44] ryan_ford: has joined #ruby
[08:08:47] alfiemax: has joined #ruby
[08:09:22] rabajaj: has joined #ruby
[08:11:26] tAn: has joined #ruby
[08:12:58] duderonomy: has joined #ruby
[08:13:31] jenrzzz: has joined #ruby
[08:16:45] willmichael: has joined #ruby
[08:19:40] ferr1: has joined #ruby
[08:20:28] jenrzzz: has joined #ruby
[08:22:19] venmx: has joined #ruby
[08:26:55] jenrzzz: has joined #ruby
[08:26:55] jenrzzz: has joined #ruby
[08:29:52] schneider: has joined #ruby
[08:32:53] jenrzzz: has joined #ruby
[08:33:41] sidx64: has joined #ruby
[08:35:11] sidx64: has joined #ruby
[08:38:02] claudiuinberlin: has joined #ruby
[08:40:41] schneider: has joined #ruby
[08:42:25] jenrzzz: has joined #ruby
[08:44:34] aupadhye: has joined #ruby
[08:48:47] mtkd: has joined #ruby
[08:49:08] riotjones: has joined #ruby
[08:49:23] mikecmpbll: has joined #ruby
[08:56:50] duckpuppy: has joined #ruby
[08:59:00] psychicist__: has joined #ruby
[08:59:57] jenrzzz: has joined #ruby
[09:00:34] shuforov: has joined #ruby
[09:03:24] karapetyan: has joined #ruby
[09:04:23] vondruch: has joined #ruby
[09:06:17] nowhereman_: has joined #ruby
[09:06:45] jenrzzz: has joined #ruby
[09:07:37] erlend: has joined #ruby
[09:10:11] guille-moe: has joined #ruby
[09:18:01] rabajaj: has joined #ruby
[09:18:46] nadir: has joined #ruby
[09:19:10] za1b1tsu: has joined #ruby
[09:22:47] marr: has joined #ruby
[09:24:13] clemens3: has joined #ruby
[09:29:51] tomphp: has joined #ruby
[09:31:27] d^sh_: has joined #ruby
[09:35:29] phaul: has joined #ruby
[09:35:45] ss942: has joined #ruby
[09:35:46] Aloy: has joined #ruby
[09:36:28] modin: has joined #ruby
[09:36:47] WhereIsMySpoon: has joined #ruby
[09:37:35] Nightmare: has joined #ruby
[09:38:51] DarthGandalf: has joined #ruby
[09:41:02] kenichi: has joined #ruby
[09:41:51] Junaos: has joined #ruby
[09:43:34] mistym: has joined #ruby
[09:43:34] mistym: has joined #ruby
[09:43:42] _whitelogger: has joined #ruby
[09:44:13] sidx64: has joined #ruby
[09:44:18] creat: has joined #ruby
[09:46:48] tomphp: has joined #ruby
[09:48:23] jenrzzz: has joined #ruby
[09:49:01] duckpuppy: has joined #ruby
[09:50:10] ss942: Ok ladies and gentelmens. I had never wrote single line nor in ruby nor rails. But now is my time. I were Python/Django dev back days. (ok it was just intern) Now I have to write rest API for an open source project - ERPmine (redmine plugin)
[09:50:10] ss942: Right now it even have "some" API, but it makes only one feature from whole system usable from API. I have to contribute, and make more jsons that returns more data, and more actions possible.
[09:50:10] ss942: Deadline was yesterday, and I'm wondering where the hell should I start with this? Any tips? Ruby in X minutes, Rails in X minutes, then Rails API, then reading ERPmine code and contributing to it?
[09:51:19] dminuoso: ?rails ss942
[09:51:19] ruby[bot]: ss942: Please join #RubyOnRails for Rails questions. You need to be identified with NickServ, see /msg NickServ HELP
[09:52:03] dminuoso: ss942: Though if the deadline is yesterday, I recommend hiring a consultant.
[09:52:20] workmad3: has joined #ruby
[09:54:23] venmx: has joined #ruby
[09:57:44] Serpent7776: has joined #ruby
[09:58:00] tomphp: has joined #ruby
[10:01:09] venmx: has joined #ruby
[10:08:23] karapetyan: has joined #ruby
[10:09:18] alfiemax: has joined #ruby
[10:10:24] dr3wo: has joined #ruby
[10:12:14] workmad3: has joined #ruby
[10:16:43] Quentinius: has joined #ruby
[10:18:58] tomphp: has joined #ruby
[10:23:32] jenrzzz: has joined #ruby
[10:24:54] jamesaxl: has joined #ruby
[10:33:49] tomphp: has joined #ruby
[10:40:01] james541: has joined #ruby
[10:43:38] rabajaj: has joined #ruby
[10:45:13] Guest33581: has joined #ruby
[10:48:12] tvw: has joined #ruby
[10:48:43] dr3wo: has joined #ruby
[10:52:36] ferr1: has left #ruby: ("WeeChat 2.0.1")
[10:53:42] duckpuppy: has joined #ruby
[10:53:48] chegypcio: has joined #ruby
[10:53:50] AJA4350: has joined #ruby
[10:53:56] mtkd: has joined #ruby
[10:57:45] karapetyan: has joined #ruby
[11:03:25] apparition: has joined #ruby
[11:03:54] rabajaj: has joined #ruby
[11:06:44] jenrzzz: has joined #ruby
[11:07:44] dr3wo: has joined #ruby
[11:13:19] rabajaj: has joined #ruby
[11:13:44] KeyJoo: has joined #ruby
[11:16:18] erlend: has joined #ruby
[11:17:22] lvmbdv: has left #ruby: ("WeeChat 2.0.1")
[11:19:45] chatchat1: has joined #ruby
[11:24:39] cschneid: has joined #ruby
[11:28:04] armando: has joined #ruby
[11:30:45] Psybur: has joined #ruby
[11:32:04] shinnya: has joined #ruby
[11:33:26] ldnunes: has joined #ruby
[11:35:08] jenrzzz: has joined #ruby
[11:35:09] jenrzzz: has joined #ruby
[11:36:02] Cavallari: has joined #ruby
[11:36:13] _joes_: has joined #ruby
[11:36:55] apeiros: has joined #ruby
[11:40:21] jenrzzz: has joined #ruby
[11:40:55] alfiemax_: has joined #ruby
[11:43:20] dionysus69: has joined #ruby
[11:52:19] dionysus69: has joined #ruby
[11:54:31] rabajaj: has joined #ruby
[11:54:41] duckpuppy: has joined #ruby
[11:57:38] ldnunes: has joined #ruby
[12:01:08] tcopeland: has joined #ruby
[12:02:40] sameerynho: has joined #ruby
[12:04:01] antoine1: has joined #ruby
[12:04:33] wxmisterjack: has joined #ruby
[12:05:28] synthroid: has joined #ruby
[12:08:27] Papierkorb: has joined #ruby
[12:09:27] bmurt: has joined #ruby
[12:10:41] tomphp: has joined #ruby
[12:12:26] sidx64: has joined #ruby
[12:16:46] jenrzzz: has joined #ruby
[12:16:47] jenrzzz: has joined #ruby
[12:19:56] ryan_ford: has joined #ruby
[12:21:38] tomphp: has joined #ruby
[12:23:05] luoliyan: has joined #ruby
[12:23:50] luoliyan: has joined #ruby
[12:24:23] bmurt: has joined #ruby
[12:24:27] coderphive: has joined #ruby
[12:24:52] John_Ivan: has joined #ruby
[12:24:53] John_Ivan: has joined #ruby
[12:25:09] sidx64: has joined #ruby
[12:25:17] synthroid: has joined #ruby
[12:26:30] arquebus: has joined #ruby
[12:35:49] luoliyan: has joined #ruby
[12:36:52] yeticry: has joined #ruby
[12:38:01] luoliyan: has joined #ruby
[12:39:34] za1b1tsu: has joined #ruby
[12:39:41] luoliyan: has joined #ruby
[12:40:54] perzival: has joined #ruby
[12:44:03] Papierkorb: has left #ruby: ("Konversation terminated!")
[12:53:38] luoliyan: has joined #ruby
[12:54:51] luoliyan: has joined #ruby
[12:55:13] dminuoso: Okay.. I want react-style nested string interpolation. What are my options?
[12:55:24] duckpuppy: has joined #ruby
[12:55:58] dminuoso: Oh nevermind. I was too stupid to bracket right.
[12:56:01] dminuoso: >> "fo#{"fo#{1+1}o"}o"
[12:56:02] ruby[bot]: dminuoso: # => "fofo2oo" (https://eval.in/974521)
[12:57:03] luoliyan: has joined #ruby
[12:59:42] luoliyan: has joined #ruby
[13:02:57] am55: has joined #ruby
[13:07:36] cdg: has joined #ruby
[13:09:30] jcalla: has joined #ruby
[13:10:54] luoliyan: has joined #ruby
[13:11:32] gnufied: has joined #ruby
[13:14:30] luoliyan: has joined #ruby
[13:14:32] luoliyan: has left #ruby: ()
[13:15:23] luoliyan: has joined #ruby
[13:15:24] sidx64: has joined #ruby
[13:15:42] luoliyan: has left #ruby: ()
[13:17:45] leah2: has joined #ruby
[13:19:43] sidx64: has joined #ruby
[13:20:03] ledestin: has joined #ruby
[13:20:59] duckpuppy: has joined #ruby
[13:22:15] jshjsh: has joined #ruby
[13:22:54] tcopeland: has joined #ruby
[13:24:59] erlend: has joined #ruby
[13:26:40] jcalla: has joined #ruby
[13:27:09] jenrzzz: has joined #ruby
[13:27:09] jenrzzz: has joined #ruby
[13:29:01] ineb: has joined #ruby
[13:30:09] ghormoon: has joined #ruby
[13:30:12] DLSteve: has joined #ruby
[13:30:44] sidx64: has joined #ruby
[13:35:39] ghormoon: has joined #ruby
[13:42:29] nowhereman_: has joined #ruby
[13:44:41] jrafanie: has joined #ruby
[13:45:19] sidx64: has joined #ruby
[13:45:57] am55: has joined #ruby
[13:46:11] venmx: has joined #ruby
[13:48:44] coderphive: has joined #ruby
[13:49:29] AgentVenom: has joined #ruby
[13:49:47] duckpuppy: has joined #ruby
[13:50:46] cdg: has joined #ruby
[13:53:18] rsh: has joined #ruby
[13:54:47] tomphp: has joined #ruby
[13:54:47] ghormoon: has joined #ruby
[13:57:48] yeticry: has joined #ruby
[14:01:38] jenrzzz: has joined #ruby
[14:10:16] tomphp: has joined #ruby
[14:13:40] ozaki: has joined #ruby
[14:18:49] psychicist__: has joined #ruby
[14:20:13] Rapture: has joined #ruby
[14:21:25] tens0r: has joined #ruby
[14:23:07] Dimik: has joined #ruby
[14:26:39] tomphp: has joined #ruby
[14:28:32] tcopeland: has joined #ruby
[14:28:54] ghormoon: has joined #ruby
[14:29:43] tomphp: has joined #ruby
[14:29:53] chouhoulis: has joined #ruby
[14:30:46] chouhoulis: has joined #ruby
[14:34:07] howdoi: has joined #ruby
[14:35:58] bmurt: has joined #ruby
[14:36:20] kn-928: has joined #ruby
[14:40:46] SteenJobs: has joined #ruby
[14:41:00] troulouliou_div2: has joined #ruby
[14:42:34] synthroid: has joined #ruby
[14:43:03] jenrzzz: has joined #ruby
[14:43:03] jenrzzz: has joined #ruby
[14:46:28] SteenJobs: has joined #ruby
[14:46:49] samort7: has joined #ruby
[14:48:43] netherwolfe: has joined #ruby
[14:54:25] rabajaj: has joined #ruby
[14:55:06] duckpuppy: has joined #ruby
[14:58:29] mtkd: has joined #ruby
[15:02:44] cschneid: has joined #ruby
[15:03:10] tomphp: has joined #ruby
[15:04:41] drale2k_: has joined #ruby
[15:05:08] drale2k_: i want to launch a go app from rails. Should i use exec() / system() or fork() ?
[15:07:45] rippa: has joined #ruby
[15:07:53] _insomniac: dralek2k_: depends... exec() replaces current process, probably not what you want; system() executes the app and wait for it to finish; fork doesn't help here (except I guess for fork+exec combo)
[15:08:41] drale2k_: by "replaces current process" would that mean if i launch this from my rails app, rails would crash ?
[15:08:42] _insomniac: don't know what your use case is but you probably want system() (sync) or Process.spawn() (async)
[15:09:13] drale2k_: i just want to lanuch the app and from there on the app is on its own
[15:09:18] synthroid: has joined #ruby
[15:09:26] _insomniac: then I would just use Process.spawn
[15:09:46] dminuoso: drale2k_: what do you want to do with the `go app` ?
[15:09:57] dminuoso: drale2k_: And when is it started?
[15:10:12] drale2k_: the go app will provide a html site which i will iframe into my rails app
[15:10:16] drale2k_: and it should start immediately
[15:10:42] drale2k_: to be precise, this should be started by Rails https://github.com/yudai/gotty
[15:12:02] samort7: has joined #ruby
[15:12:52] yokel: has joined #ruby
[15:15:13] synthroid: has joined #ruby
[15:23:55] jenrzzz: has joined #ruby
[15:23:55] jenrzzz: has joined #ruby
[15:25:13] canton7: drale2k_, bear in mind you'll have to make sure that process terminates if someone just closes the web page
[15:25:43] drale2k_: canton7: ye i am still thinking about what the best way is. Probably a browser event
[15:27:55] Lytol: has joined #ruby
[15:28:34] cdg: has joined #ruby
[15:29:00] minimalism: has joined #ruby
[15:30:11] cdg: has joined #ruby
[15:30:56] oleo: has joined #ruby
[15:32:40] cdg_: has joined #ruby
[15:33:41] erlend: has joined #ruby
[15:34:20] apeiros: has joined #ruby
[15:42:11] apeiros: has joined #ruby
[15:43:45] crankharder: has joined #ruby
[15:43:46] alfiemax: has joined #ruby
[15:43:46] dionysus69: has joined #ruby
[15:47:08] jcarl43: has joined #ruby
[15:48:38] duckpuppy: has joined #ruby
[15:51:31] cagomez: has joined #ruby
[15:51:50] ski7777: has joined #ruby
[15:53:04] [Butch]: has joined #ruby
[15:55:41] roca: has joined #ruby
[15:55:54] InfinityFye: has joined #ruby
[15:56:31] SteenJobs: has joined #ruby
[15:57:28] desperek: has joined #ruby
[15:59:56] alfiemax: has joined #ruby
[16:03:41] tomphp: has joined #ruby
[16:03:51] marxarelli: has joined #ruby
[16:04:59] duderonomy: has joined #ruby
[16:05:36] jenrzzz: has joined #ruby
[16:05:36] jenrzzz: has joined #ruby
[16:07:51] coderphive: has joined #ruby
[16:12:56] hinbody: has joined #ruby
[16:14:10] breakfast1: has joined #ruby
[16:14:21] za1b1tsu: has joined #ruby
[16:16:01] synthroid: has joined #ruby
[16:19:27] rwb: has joined #ruby
[16:21:12] conceivably: has joined #ruby
[16:23:06] conceivably: Good morning. Why in the world does 'zip' with a block return nil? Of course it's easy to circumvent, but I'm trying to understand why it wouldn't return an enum or something. It seems to render that version mostly useless.
[16:24:47] pastorinni: has joined #ruby
[16:25:45] havenwood: conceivably: It does seem like something that'd be nice to improve in Ruby 3 with a breaking change.
[16:25:56] havenwood: I don't like it returning `nil` either.
[16:26:07] darkhanb: has joined #ruby
[16:26:17] dminuoso: conceivably: Have you tried hask.. oh hey havenwood!
[16:26:24] havenwood: dminuoso: o/
[16:26:52] dminuoso: Good evening indeed.
[16:27:43] apeiros: conceivably: run into the same thing. a possible reason: the language designers thought zip with block means you want the side-effect, so they saved the cost of creating a new array.
[16:27:45] dminuoso: havenwood: Oh shoot, so you cant do something like...
[16:27:50] dminuoso: a.zip(b, &:+) ?
[16:27:55] dminuoso: That sucks.
[16:28:13] apeiros: conceivably: and as you say, it's easy enough to get around using e.g. a.zip(b).map { … }
[16:28:25] dminuoso: Though I guess that wouldn't work anyway.
[16:28:36] dminuoso: \o/ apeiros
[16:28:42] Mike11: has joined #ruby
[16:29:14] apeiros: dminuoso: heh, yeah. it'd be nice if ruby had unobnoxious syntax for all the variants of one-method blocks
[16:29:34] conceivably: :D thanks for the input. I was just wondering whether maybe I was missing something super obvious.
[16:29:34] apeiros: there are gems to provide short-cuts. but without native support, I prefer the full block.
[16:29:42] dminuoso: Screw blocks
[16:29:47] dminuoso: Tacit programming.
[16:30:00] dminuoso: ACTION hugs his combinatorically derived lambdas
[16:30:02] orbyt_: has joined #ruby
[16:30:02] apeiros: ah right. you're having new shtiks to follow :-D
[16:30:16] WhereIsMySpoon: dminuoso: whats this now
[16:30:23] WhereIsMySpoon: ive not heard of those before
[16:31:43] dminuoso: WhereIsMySpoon: Simple. You start with class Proc; def *(o); ->(*arg) { self[o[*args]]}; end; end
[16:31:43] dminuoso: And then you start going.
[16:32:07] burgestrand: has joined #ruby
[16:32:31] WhereIsMySpoon: im no ruby expert :P i just tinker every now and then
[16:32:38] jimmylu2333-rpi3: has joined #ruby
[16:32:44] dminuoso: WhereIsMySpoon: Stare at that definition and think about it for one moment.
[16:32:59] dminuoso: WhereIsMySpoon: Ill give you one hint, o is assumed to be a proc/lambda.
[16:33:01] burgestrand: WhereIsMySpoon you ever found out the true min/max values of your floats? :)
[16:33:24] WhereIsMySpoon: Burgestrand: ha, no i didnt get to, because the stupid portaudio library led me on a merry chase all of my 2nd day
[16:33:40] dminuoso: WhereIsMySpoon: After that you need to badly patch Proc#call and Proc#[] to do push/enter
[16:33:47] dminuoso: So you dont go insane
[16:33:59] WhereIsMySpoon: i eventually went home, talked to my friends who are c experts, and found out i NEED to call paComplete if i want to exit out of the stream’s block
[16:34:01] Nahra: has joined #ruby
[16:34:09] WhereIsMySpoon: otherwise it will keep going forever
[16:34:18] WhereIsMySpoon: even if you call stream.close
[16:34:21] dminuoso: ACTION should make a blog post about this
[16:34:39] WhereIsMySpoon: dminuoso: what is *?
[16:34:53] dminuoso: WhereIsMySpoon: its function composition
[16:35:07] dminuoso: facest: f * x = -> (a) { f[x[a]] }
[16:35:20] dminuoso: Err ^- WhereIsMySpoon.
[16:35:37] dminuoso: (Look at this as a statement of equality, not actual ruby code)
[16:36:11] dminuoso: f * g combines two lambdas into a single lambda that takes an argument, applies g to it, and then applies f to the result of f.
[16:36:22] dminuoso: *and then applies f to the result of g
[16:36:30] shuforov: has joined #ruby
[16:36:35] WhereIsMySpoon: i think i get it
[16:36:38] WhereIsMySpoon: so whats this for
[16:36:53] dminuoso: WhereIsMySpoon: About building functions that do things.
[16:37:09] dminuoso: You build functions with functions, rather than taking the pencil and drawing them bit by bit.
[16:37:24] imode: has joined #ruby
[16:37:34] WhereIsMySpoon: Burgestrand: I ended up being stuck in a while true loop for most of the day (sometimes) because of the interacton between portaudio’s ffi and the ruby code i was writing
[16:37:45] burgestrand: WhereIsMySpoon hehe, rough day :)
[16:37:56] WhereIsMySpoon: Burgestrand: I was intensely frustrated at the end
[16:38:07] WhereIsMySpoon: Thats what comes of using ruby to do sound processing I guess :)
[16:38:12] dminuoso: WhereIsMySpoon: If you're around in 30 minutes Ill show you some tricks if you are interested
[16:38:20] WhereIsMySpoon: dminuoso: im interested
[16:38:24] WhereIsMySpoon: ill be around in about 30 minutes
[16:38:27] mtkd: has joined #ruby
[16:39:25] WhereIsMySpoon: Burgestrand: what frustrates me most is that I would have had no idea what was going on if I didn’t have friends who knew C
[16:39:30] dminuoso: WhereIsMySpoon: so before I get there, consider `f * g` to be a combinatoric way to do chaining like `x.g.f` but without having to talk about `xz
[16:39:45] dminuoso: And in a way that you can pass such constructions as blocks or values around
[16:40:14] burgestrand: WhereIsMySpoon either that or if you were curious enough to look up what :paContinue actually did :D
[16:40:46] WhereIsMySpoon: Burgestrand: I tried my best on that dude, the docs are little and I understand very little C
[16:41:25] WhereIsMySpoon: plus, it wasnt consistent
[16:41:32] WhereIsMySpoon: sometimes the stream would exit on stream.close
[16:41:48] WhereIsMySpoon: because it was all a race condition between the GIL and ffi
[16:42:19] burgestrand: WhereIsMySpoon ah yes, not saying it would be easy, I think you could've figured it out eventually, but you are indeed lucky to have your C friends :)
[16:42:55] WhereIsMySpoon: Burgestrand: I had no idea there was a problem at this level :) I didnt even think to look inside the internals
[16:43:32] WhereIsMySpoon: Maybe next time I will use another language for sound processing that has up to date libraries :D
[16:43:54] alfiemax_: has joined #ruby
[16:44:21] eckhardt_: has joined #ruby
[16:44:24] WhereIsMySpoon: Burgestrand: thank you for all your help all the same :)
[16:44:49] burgestrand: WhereIsMySpoon heh, yeah, there are drawbacks to being one of the pioneers
[16:45:03] morfin: i think i found solution how i can bulk create models
[16:45:19] morfin: with validations
[16:50:53] sanscoeur: has joined #ruby
[16:52:25] duckpuppy: has joined #ruby
[16:54:14] X-Jester: has anyone tried the new jetbrains 2018 rubymine beta yet?
[16:55:31] jeffreylevesque: has joined #ruby
[16:56:03] cagomez: I'm chaining enumerators. is there an easy way to produce the result of the enumerator without having to guess their order? ie I don't know if the index, object being iterated over, or `memo` is the first arg
[16:56:09] cagomez: *first result?
[16:57:55] tomphp: has joined #ruby
[16:58:34] bmurt: has joined #ruby
[16:58:49] ramfjord: has joined #ruby
[16:59:01] havenwood: cagomez: What does it mean to chain enumerators? Like concatenating multiple enumerators? Can you show the code for what you've tried?
[16:59:27] havenwood: There is a feature request for Enumerator#concat: https://bugs.ruby-lang.org/issues/14593
[16:59:38] havenwood: enums.lazy.flat_map(&:lazy).to_enum { enums.sum(&:size) if enums.all?(&:size) } >.>
[17:00:17] cagomez: I got it havenwood. %i(foo bar baz).each_with_object([]).with_index(1) { |*args| puts *args }
[17:00:41] cagomez: I was trying to see what order the arguments would appear in the block
[17:00:47] cdg: has joined #ruby
[17:01:09] havenwood: cagomez: #reduce is the opposite of #each_with_object, aye
[17:01:44] havenwood: I like #each_with_object.
[17:01:59] cagomez: same. inject() and reduce() seem clunky in comparison
[17:02:21] dminuoso: cagomez: What you are complaining about is the lack of a type system to help you.
[17:02:22] cdg__: has joined #ruby
[17:02:33] dminuoso: WhereIsMySpoon: Alright. So lets start first with the motivation behind all of this.
[17:02:49] havenwood: >> %i(foo bar baz).each_with_object([]).with_index(1).first.map(&:class)
[17:02:50] ruby[bot]: havenwood: # => [Array, Fixnum] (https://eval.in/974706)
[17:02:57] dminuoso: WhereIsMySpoon: In Ruby it's quite common to "chain" methods, such as str.f(args).g(moreArgs).h(evenMore)
[17:03:03] cdg-me: has joined #ruby
[17:03:37] dminuoso: WhereIsMySpoon: This feels quite natural because it represents a processing pipeline where data are placed in from the left side, and results come out from the right side.
[17:03:44] dminuoso: WhereIsMySpoon: So far so good?
[17:03:58] yashi: has left #ruby: ()
[17:03:58] cagomez: dminuoso: the Fluent Builder pattern is beautiful . ie FooBuilder.build.with_bar.with_baz.foo
[17:04:21] dminuoso: cagomez: function composition is beautiful and strong.
[17:04:22] WhereIsMySpoon: dminuoso: interesting, I wasnt aware this was a normal pattern in generic ruby programming, but im aware of that pattern
[17:04:41] dminuoso: WhereIsMySpoon: It happens quite frequently.
[17:04:43] dminuoso: For example
[17:05:20] dminuoso: >> (1..10).select(&:even?).map(&:to_s).zip(100..200)
[17:05:21] ruby[bot]: dminuoso: # => [["2", 100], ["4", 101], ["6", 102], ["8", 103], ["10", 104]] (https://eval.in/974707)
[17:05:37] dminuoso: Things like this happen rather frequently in idiomatic ruby code.
[17:06:03] dminuoso: WhereIsMySpoon: That's one half. Now the second is that Ruby is filled with higher order functions.
[17:06:03] havenwood: It tends to be a concise way to write code that reads well.
[17:06:31] WhereIsMySpoon: dminuoso: righto, this is becoming more common in java too with streams (c# linqs etc)
[17:07:01] dminuoso: WhereIsMySpoon: Right. Java has been experiencing a strong influx of FP ideas because they are quite powerful, even if you dont go all-in functional.
[17:07:08] WhereIsMySpoon: (im mainly a java dev)
[17:07:11] WhereIsMySpoon: indeed they are
[17:07:36] dminuoso: WhereIsMySpoon: So lets consider (1..10).select(&:even?) for a second. At first glance that looks like the command pattern, but in reality you are just taking a shortcut
[17:07:50] dminuoso: Conceptually this is just (1..10).select { |e| e.even? }
[17:07:58] dminuoso: But what is that block? That looks an awful lot like a function, doesn't it?
[17:08:30] dminuoso: If its a function it has input and output. #select wants not any function, but one that acts as a predicate
[17:08:41] havenwood: A proc without an object? Let's call it a block!
[17:09:10] WhereIsMySpoon: dminuoso: sure, that makes sense
[17:09:48] dminuoso: WhereIsMySpoon: So what if you wanted to filter based on a function, that first takes its input as a string, removes any non-digit characters, and then parses that into a number, and then checks if the number is even?
[17:10:02] dminuoso: That logic itself is a simple function. But how do we describe such a function?
[17:10:09] dminuoso: You split it into simple task.
[17:10:11] WhereIsMySpoon: as a composition of those functions
[17:10:24] WhereIsMySpoon: removal of non digits, parsing, then even check
[17:10:59] dminuoso: onlyDigit = -> e { e.gsub(/\D/, '') }
[17:11:07] dminuoso: toNum = -> e { e.to_i }
[17:11:17] dminuoso: even = -> e { e.even? }
[17:11:20] Zaab1t: has joined #ruby
[17:11:32] dminuoso: and then you have some: p = even * toNum * onlyDigit
[17:11:39] dminuoso: and then you can go arr.select(&p)
[17:11:54] WhereIsMySpoon: right, this is just syntactic sugar for map though
[17:12:15] jimmylu2333-fedo: has joined #ruby
[17:12:23] WhereIsMySpoon: because you defined a function based on other ones
[17:12:44] ledestin: has joined #ruby
[17:12:52] WhereIsMySpoon: thats a thing you can do in haskell i think, right?
[17:13:00] WhereIsMySpoon: just with the base language
[17:13:20] dminuoso: Though (.), which is the equivalent of *, is defined in terms of the language itself.
[17:13:23] dionysus69: has joined #ruby
[17:13:23] vdl: has joined #ruby
[17:13:32] dminuoso: So it's not really important that the language has it, you could trivially define it yourself.
[17:13:39] dminuoso: Which is what I do in Ruby.
[17:14:08] dminuoso: WhereIsMySpoon: So the next important part is currying
[17:14:15] dminuoso: Which is the final bit you need to create powerful things
[17:14:25] dminuoso: (well you kind of also want push/apply evaluation, but meh)
[17:14:33] dminuoso: so you could do
[17:14:43] dminuoso: at = -> i, a { a[i] }.curry
[17:14:43] jimmylu2333-fedo: has joined #ruby
[17:15:27] dminuoso: Which is kind of like Symbol#to_proc, but way cooler.
[17:15:34] jimmylu2333-rpi3: has joined #ruby
[17:16:31] dminuoso: WhereIsMySpoon: Assume we have some users = [{name: 'dminuoso',hobbies: ['nonsense', 'fp']},{name: 'havenwood',hobbies: ['being even more silly', 'fp']}];
[17:16:50] dminuoso: And we wanted to know the top hobbies of our users
[17:17:17] dminuoso: We could simply do: topHobby = at[0] * at[:hobbies]; users.map(&topHobby)
[17:17:29] jimmylu2333-fedo: has joined #ruby
[17:19:33] dminuoso: Which part?
[17:20:05] WhereIsMySpoon: the start of your curring explanation
[17:20:12] jimmylu2333-fedo: has joined #ruby
[17:20:14] WhereIsMySpoon: what is i and a
[17:20:28] dminuoso: -> i, a { a[i] }
[17:20:43] dminuoso: is just a lambda that takes two arguments, and indexes into the second argument using the first
[17:20:51] dminuoso: seems rather boring doesnt it?
[17:21:33] WhereIsMySpoon: now i still dont get your topHobby line
[17:21:33] dminuoso: WhereIsMySpoon: Currying just modifies a lambda to - conceptually - only have a single argument
[17:21:50] dminuoso: WhereIsMySpoon: Do you require further explanation of currying?
[17:23:05] dminuoso: it turns.. `-> i, a { a[i] }` into `-> i { -> a { a[i]} }`, so instead of function taking multiple parameters, each function only takes a single argument
[17:23:22] dminuoso: so if you pass a single parameter, you get a function back that is waiting for the remaining ones
[17:23:52] dminuoso: for example:
[17:23:59] dminuoso: add = -> a, b { a + b }.curry
[17:24:18] dminuoso: add[5] creates an adder, a function that takes an argument and adds 5 to it
[17:24:22] dminuoso: so you could say add[5] creates a 5-adder
[17:24:34] WhereIsMySpoon: right, i get that much
[17:24:41] WhereIsMySpoon: what does at[0] do
[17:24:48] dminuoso: at = -> i, a { a[i] }.curry
[17:24:50] dminuoso: you tell me
[17:25:15] WhereIsMySpoon: returns a function that calls a() on 0?
[17:25:47] WhereIsMySpoon: oh, it returns the 0th element of a
[17:25:56] dminuoso: So it creates an "accessor for the 0th element"
[17:26:09] dminuoso: so "at" creates accessors.
[17:26:23] dminuoso: WhereIsMySpoon: A useful intuition for function composition now is
[17:26:35] dminuoso: that `f * g` is pronounced "f after g"
[17:26:44] dminuoso: because first g is applied to an argument, and then f
[17:26:47] dminuoso: so f is applied after g.
[17:26:51] WhereIsMySpoon: ok, perhaps firstHobby is a better name :)
[17:27:10] dminuoso: I was just thinking they were sorted by the persons interest in it
[17:27:13] dminuoso: but that works too
[17:27:26] WhereIsMySpoon: right, that wasnt so obvious :D i was wondering where this sorting comes in
[17:27:39] dminuoso: well if you want.. we can build that sorting in too!
[17:27:48] dminuoso: sort takes a comparing function..
[17:28:00] dminuoso: function means you can construct it from higher order functions and composition
[17:28:05] krawchyk: has joined #ruby
[17:28:20] dminuoso: WhereIsMySpoon: once you start that road, you can separate these functions - making them testable as well as refactorable
[17:28:53] WhereIsMySpoon: all this is coming back to me slowly, i remember reading all about this when i was learning haskell
[17:29:46] dminuoso: WhereIsMySpoon: the only downside is that you have to create some helping things to make this work, because ruby is missing some of the important puzzle pieces
[17:30:01] dminuoso: that's mostly a one thing cost though
[17:30:31] WhereIsMySpoon: whats this push evaluation youre on about
[17:30:37] dminuoso: let me give you an example
[17:30:47] dminuoso: WhereIsMySpoon: do you know what zip does?
[17:31:29] dminuoso: WhereIsMySpoon: please do explain in a very short sentence with your own words
[17:31:44] WhereIsMySpoon: it merges arrays together indexes at a time
[17:32:08] dminuoso: right. like a zipper it takes two arrays, and zips them together as it were.
[17:32:12] WhereIsMySpoon: [1,2,3].zip([4,5,6],[7,8,9] = [[1,4,7],[2,5,8],[3,6,9]]
[17:32:39] dminuoso: we had two lists
[17:32:49] dminuoso: arr1 and arr2, and wanted to add them together component wise
[17:32:51] dminuoso: how would you do it?
[17:34:06] WhereIsMySpoon: zip then perform sum on the arrays
[17:34:32] WhereIsMySpoon: assuming by component wise you mean index wise
[17:34:59] dminuoso: the plain ruby way would look like this
[17:35:27] dminuoso: >> [1,2,3].zip([3,4,5]).map { |arr| arr.reduce(&:+) }
[17:35:28] ruby[bot]: dminuoso: # => [4, 6, 8] (https://eval.in/974737)
[17:35:35] dminuoso: but thats not very nice
[17:35:35] biberu: has joined #ruby
[17:36:09] dminuoso: since this is a rather frequent thing to do - even in idiomatic ruby, we just lack the tools to develop good habits - we use this
[17:36:15] dminuoso: zipWith = -> f, l r {l.zip(r).map { |a, b| f.(a, b) }}
[17:36:19] dminuoso: zipWith = -> f, l r {l.zip(r).map { |a, b| f.(a, b) }}.curry
[17:36:42] dminuoso: and then you have some add = -> a, b { a + b }
[17:36:44] dminuoso: and then you go
[17:36:48] dminuoso: zipWith(add, arr1, arr2)
[17:36:52] dminuoso: looks pretty cool right?
[17:37:36] dminuoso: WhereIsMySpoon: Now what if we wanted an array of arrays..
[17:37:43] dminuoso: say a 3x3 matrix represented by nested arrays
[17:37:52] dminuoso: and you had two such matrices, and you wanted to add them element wise..
[17:38:00] dminuoso: with ruby you now start to write some pretty painful code to read.
[17:39:01] dminuoso: WhereIsMySpoon: https://eval.in/974750
[17:39:05] dminuoso: here's the code we have so far
[17:41:05] dminuoso: WhereIsMySpoon: So ideally if we had some mat1 and mat2, we could now do this:
[17:41:23] dminuoso: (zipWith * zipWith)[add, arr1, arr2]
[17:41:28] dminuoso: So lets try this.
[17:41:31] dminuoso: WhereIsMySpoon: https://eval.in/974753
[17:42:10] chatchatt: has joined #ruby
[17:42:20] dminuoso: But something went wrong. The problem here is that lambda call doesn't consider the arity of arguments.
[17:42:21] erlend: has joined #ruby
[17:42:53] dminuoso: Instead of Proc#[] doing the right(tm) thing, and pushing one argument at a time (which is what we want in our curry happy world), it applies everything on each call.
[17:43:03] WhereIsMySpoon: which lambda call please
[17:43:51] dminuoso: WhereIsMySpoon: So ruby forces you to know when a lambda is "popped" and a "new one is returned" https://eval.in/974755
[17:44:00] WhereIsMySpoon: im lost a little
[17:44:01] dminuoso: so you cant mindlessly just shove arguments in like in Haskell
[17:44:05] WhereIsMySpoon: whats the output of that code
[17:44:14] dminuoso: which one, the last?
[17:45:29] dminuoso: creates some -> *args { f[g[*args]] }
[17:46:12] dminuoso: WhereIsMySpoon: Our problem is, we want just one argument to be pushed into zipWith, and the return of that + the remaining into the other zipWith
[17:46:52] dminuoso: or it may be more obvious if we fix our Proc#*
[17:47:27] dminuoso: class Proc; def *(o); -> args { self[o[args]] }; end; end
[17:47:37] dminuoso: so its clear, that this lambda expects only one argument right?
[17:47:57] morfin: with Capistrano i get Net::SSH::ConnectionTimeout: Net::SSH::ConnectionTimeout but when use SSH client everything is ok
[17:48:03] morfin: any idea?
[17:48:09] WhereIsMySpoon: dminuoso: right
[17:48:14] dminuoso: WhereIsMySpoon: We could just do this: (zipWith * zipWith)[add][mat1][mat2] which works fine
[17:48:28] dminuoso: but thats annoying, we dont want to manually apply each returned lambda
[17:48:43] dminuoso: instead we want to pass it "some arguments", and have it "apply one argument from that list at a time"
[17:48:49] morfin: looks ugly)
[17:48:57] Ryzokuken: has joined #ruby
[17:49:27] morfin: Haskess can do better i believe
[17:49:32] dminuoso: WhereIsMySpoon: so that's where push/apply comes in, where you keep a stack of arguments, and look at the arity, and provide as many as necessary
[17:49:32] coderphive: has joined #ruby
[17:49:49] WhereIsMySpoon: morfin: yes, but haskell was built with this in mind :)
[17:49:52] dminuoso: you can simply monkey patch Proc#[] and Proc#call to do just that, which should be a reasonably safe thing to do
[17:50:19] dminuoso: WhereIsMySpoon: with such a monkey patch you can simply say
[17:50:26] dminuoso: (zipWith * zipWith)[add, mat1, mat2]
[17:50:38] dminuoso: WhereIsMySpoon: and that is a rather elegant way of zipping nested lists together with add
[17:50:44] dminuoso: you can even do higher tensors too
[17:50:56] dminuoso: (zipWith * zipWith * zipWith)[add, t1, t2]
[17:51:00] dminuoso: For three dimensional lists..
[17:51:38] ramfjord: has joined #ruby
[17:52:08] vcavallo: has joined #ruby
[17:52:10] WhereIsMySpoon: so (zipWith * zipWith)[add, mat1, mat2] applies zipWith to the arguments twice, yes?
[17:52:55] dminuoso: WhereIsMySpoon: let me rewrite slightly
[17:53:02] WhereIsMySpoon: then im a bit conufsed :D
[17:53:11] dminuoso: zipWith[zipWith[add], t1, t2]
[17:53:14] dminuoso: thats the same thing.
[17:53:27] dminuoso: so the thing you zipWith itself is a zipWith that adds.
[17:53:59] dminuoso: if you think about it
[17:54:07] dminuoso: zipWith takes a binary function that combines two things.
[17:54:16] dminuoso: well, zipWith[add] is a function that combines two lists right?
[17:54:36] guanine: has joined #ruby
[17:55:30] dminuoso: zipWith(f, mat1, mat2) requires f to be a function that combines two lists.
[17:55:42] dminuoso: because mat1 and mat2 are of type [[Int]]
[17:55:46] \void: has joined #ruby
[17:55:49] dminuoso: (i.e. they are 2 dimesional lists)
[17:56:17] duckpuppy: has joined #ruby
[17:56:31] dminuoso: (zipWith * zipWith)[add] = zipWith[zipWith[add]]
[17:57:06] dminuoso: so from that follows
[17:57:17] dminuoso: (zipWith * zipWith * zipWith)[add, t1, t2] = zipWith[zipWith[add]][t1,t2]
[17:57:40] dminuoso: (zipWith * zipWith)[add, t1, t2] = zipWith[zipWith[add]][t1,t2]
[17:57:44] dminuoso: and equivalently
[17:57:56] jrafanie: has joined #ruby
[17:58:20] dminuoso: Ah well this becomes harder to talk about with ruby without type signatures
[17:58:28] cdg: has joined #ruby
[17:58:30] dminuoso: zipWith works on single lists
[17:58:35] dminuoso: zipWith * zipWith works on matrixes
[17:58:51] WhereIsMySpoon: i think i kinda get it :P
[18:00:41] WhereIsMySpoon: now my brain is leaking
[18:00:55] cdg_: has joined #ruby
[18:02:03] WhereIsMySpoon: i think in general adding ways to more easily code in fp paradigms is good :)
[18:02:16] WhereIsMySpoon: fp code is generally less prone to bugs and more succinct
[18:02:56] dminuoso: I wouldn't say that fp is less prone to bugs, its rather that fp languages tend to have strong and expressive type systems that prevent tons ofbugs.
[18:03:18] dminuoso: but the abstractions are stronger, so it's easier to maintain code
[18:04:39] klabautermann: has joined #ruby
[18:06:04] perzival: has joined #ruby
[18:07:11] klabautermann: Any ideas why puts "Status: #{scan_info['status']}" won't print the actual status? It displays Status: but nothing after. However, if I remove ['status'], it prints the entire json response
[18:07:12] SteenJobs: has joined #ruby
[18:07:44] dminuoso: klabautermann: what is scan_info?
[18:07:55] klabautermann: scan_info = client.call('pro.task_status', task_id)
[18:08:09] dminuoso: No I mean..
[18:08:17] klabautermann: its stored json
[18:08:31] dminuoso: klabautermann: gist the output of `puts scan_info.inspect`
[18:09:35] klabautermann: Status: {"3"=>{"status"=>"done", "error"=>"", "created_at"=>1521473433, "progress"=>100, "description"=>"Discovering", "
[18:09:35] klabautermann: info"=>"Sweep of 15.1.45.12-15.1.45.12 complete (1 new host, 11 new services)", "workspace"=>"newjoetest", "usern
[18:09:35] klabautermann: ame"=>"admin", "result"=>"", "path"=>"C:/temp/apps/pro/tasks/2018-03-19T15-30-33_task_pro.discover_3.txt", "si
[18:09:59] cdg: has joined #ruby
[18:10:04] klabautermann: Im wantiong the output of "done"
[18:10:10] dminuoso: klabautermann: With your own words, what are the keys of that entire hash?
[18:10:30] dminuoso: klabautermann: Formulate a hypothesis. Test it by chcking scan_info.values
[18:10:41] dminuoso: or scan_info.keys rather I guess =)
[18:10:51] klabautermann: ohh, these are things I didnt know about
[18:10:56] dminuoso: klabautermann: yes they are.
[18:10:57] klabautermann: ok, let me try those
[18:11:03] dminuoso: klabautermann: hold on one sec
[18:11:08] dminuoso: scan_info['status']
[18:11:19] dminuoso: tries to look up the value for the key 'status'
[18:11:26] dminuoso: so you are presuming that the outer hash must have a key called "status"
[18:11:38] dminuoso: so, if you look at the hash, what are the outermost keys?
[18:12:00] klabautermann: there is no hash here
[18:12:30] dminuoso: klabautermann: What is there?
[18:12:41] klabautermann: im only passing arguments via rpc
[18:12:57] dminuoso: klabautermann: scan_info.class
[18:13:00] dminuoso: what do you get back?
[18:14:18] klabautermann: when you say outermost keys
[18:14:31] klabautermann: what is that excatly? Thats new to me, and id like to look it up
[18:14:46] dminuoso: klabautermann: you're holding a russian doll in your hand.
[18:15:01] dminuoso: the outer most layer happens to be a hash
[18:15:03] dminuoso: if its a hash, it has keys
[18:19:16] shpoont: has joined #ruby
[18:20:12] Asher: has joined #ruby
[18:23:01] perzival: has joined #ruby
[18:26:02] pd2000: has joined #ruby
[18:26:32] kn-928: has joined #ruby
[18:27:15] tomphp: has joined #ruby
[18:31:09] vutral|kali: has joined #ruby
[18:31:09] vutral|kali: has joined #ruby
[18:32:50] ltt: has joined #ruby
[18:36:29] coderphive: has joined #ruby
[18:40:22] cagomez: I'm working within a rails app and my `const_get` is finding the incorrect class (a model in my Rails app rather than in my module) during an Rspec test. Any help? https://hastebin.com/wucehodaso.rb
[18:42:11] dminuoso: cagomez: Make a working testcase.
[18:42:21] dminuoso: (by working I mean one that reproduces your issue)
[18:42:47] dminuoso: or perhaps just gist the model and the spec.
[18:43:53] tAn: has joined #ruby
[18:44:45] O0SFGWmcintosh: has joined #ruby
[18:45:36] samort7_: has joined #ruby
[18:47:07] John_Ivan: has joined #ruby
[18:48:03] tomphp_: has joined #ruby
[18:51:50] duckpuppy: has joined #ruby
[18:52:55] erts: has joined #ruby
[18:54:04] claudiuinberlin: has joined #ruby
[18:56:55] cagomez: has joined #ruby
[18:56:57] tAn: has joined #ruby
[19:01:52] conceivably: has joined #ruby
[19:03:26] conceivably: Is there a name for arrays of the form [[k1, v1], [k2, v2],...,[kn, vn]] that can be hashed?
[19:06:02] bmurt: has joined #ruby
[19:06:10] schneider: has joined #ruby
[19:06:59] hahuang65_: anyone here knowledgable about TCPSocket and how that works in Ruby? I'm having trouble with it resolving a docker-style link "http://#{container_name}
[19:07:20] hahuang65_: I'm wondering if it just doesn't resolve those names and needs a specific IP
[19:08:36] fiachetti: has joined #ruby
[19:13:01] cagomez: has joined #ruby
[19:13:16] clemens3: has joined #ruby
[19:20:24] nowhere_man: has joined #ruby
[19:22:23] weird_error: has joined #ruby
[19:23:26] jamiejackson2577: has joined #ruby
[19:24:08] venmx: has joined #ruby
[19:24:59] samort7: has joined #ruby
[19:25:33] cdg_: has joined #ruby
[19:31:42] n0m4d1c: has joined #ruby
[19:35:03] jamesaxl: has joined #ruby
[19:37:47] jenrzzz: has joined #ruby
[19:37:47] jenrzzz: has joined #ruby
[19:39:38] cagomez: has joined #ruby
[19:40:01] c0ncealed: has joined #ruby
[19:40:25] ldepandis: has joined #ruby
[19:42:40] deadnull: has joined #ruby
[19:43:34] cdg: has joined #ruby
[19:44:13] rsh: has joined #ruby
[19:45:05] Dimik: has joined #ruby
[19:46:02] mtkd: has joined #ruby
[19:46:28] eckhardt_: has joined #ruby
[19:47:21] tolerablyjake: has joined #ruby
[19:48:13] guacamole: has joined #ruby
[19:48:13] guacamole: has joined #ruby
[19:49:11] pd2000: has joined #ruby
[19:49:41] duckpuppy: has joined #ruby
[19:51:03] erlend: has joined #ruby
[19:54:38] pastorinni: has joined #ruby
[19:57:18] cagomez: has joined #ruby
[19:59:12] SteenJobs: has joined #ruby
[20:00:23] shpoont: has joined #ruby
[20:02:12] duderonomy: has joined #ruby
[20:04:13] shpoont: has joined #ruby
[20:06:38] sameerynho: has joined #ruby
[20:08:10] jenrzzz: has joined #ruby
[20:10:40] milardovich: has joined #ruby
[20:11:18] graft: has joined #ruby
[20:13:22] cagomez: has joined #ruby
[20:13:55] roshanavand: has joined #ruby
[20:27:40] kn-928: has joined #ruby
[20:29:09] Nahra: has joined #ruby
[20:40:57] cdg: has joined #ruby
[20:42:32] cdg: has joined #ruby
[20:44:33] n008f4g_: has joined #ruby
[20:48:37] pastorinni: has joined #ruby
[20:49:31] duckpuppy: has joined #ruby
[20:50:14] duderonomy: has joined #ruby
[20:53:38] appdevolopur: has joined #ruby
[20:55:14] FrostCandy: has joined #ruby
[20:57:05] za1b1tsu: has joined #ruby
[20:57:42] SeepingN: has joined #ruby
[21:01:59] xelkarin: has joined #ruby
[21:02:59] venmx: has joined #ruby
[21:04:39] shpoont: has joined #ruby
[21:05:44] sameerynho: has joined #ruby
[21:07:38] ldnunes: has joined #ruby
[21:11:19] workmad3: has joined #ruby
[21:12:59] John_Ivan: has joined #ruby
[21:13:00] John_Ivan: has joined #ruby
[21:13:34] krawchyk: has joined #ruby
[21:19:14] conceivably: Why is it legal to divide by 0.0 ?
[21:23:46] kke: what's the most awesomely written web service api wrapper you ever saw? (looking for inspiration)
[21:31:25] nowhereman_: has joined #ruby
[21:32:38] shpoont: has joined #ruby
[21:34:13] n008f4g_: has joined #ruby
[21:34:57] chouhoul_: has joined #ruby
[21:39:34] dminuoso: conceivably: Because IEEE 754 says so.
[21:39:35] kke: perhaps leaning towards droplet_kit in my current research
[21:40:30] dminuoso: conceivably: Note that
[21:40:34] ruby[bot]: dminuoso: # => divided by 0 (ZeroDivisionError) ...check link for more (https://eval.in/974843)
[21:40:38] ruby[bot]: dminuoso: # => Infinity (https://eval.in/974844)
[21:40:55] kke: to Float::INFINITY and beyond
[21:41:28] conceivably: Ah I see, that makes sense thank you :)
[21:41:41] kke: there's also Float::NaN
[21:43:56] kke: conceivably: maybe because floating point math is so weird. 0.0 could also be 0.00000....00000000234 but you just don't have enough precision
[21:44:26] dminuoso: kke: No. It has nothing to do with that.
[21:44:34] dminuoso: kke: It's only because IEEE 754 demands this behavior.
[21:44:41] dminuoso: Nothing more, nothing less.
[21:44:47] kke: let's get those bastards
[21:45:33] jottr: has joined #ruby
[21:46:22] trautwein: has joined #ruby
[21:47:10] Tempesta: has joined #ruby
[21:47:12] karapetyan: has joined #ruby
[21:47:27] trautwein: has joined #ruby
[21:48:26] biox: has joined #ruby
[21:49:10] shpoont: has joined #ruby
[21:49:54] trautwein: has joined #ruby
[21:50:08] trautwein: has joined #ruby
[21:52:23] tAn: has joined #ruby
[21:56:31] duckpuppy: has joined #ruby
[21:57:00] tomphp: has joined #ruby
[21:57:52] kke: of course they had a reason to demand that
[21:58:18] harrycs: has joined #ruby
[21:59:48] erlend: has joined #ruby
[21:59:54] havenwood: reasoning that there is a reason seems reasonable
[22:00:59] kke: >> 1 / 1.0e-308
[22:01:16] kke: ok then.
[22:01:29] kke: 309 gives float::infinity on my machine, so that you know.
[22:01:39] havenwood: #=> 1.0e+308
[22:02:40] samort7: "The Well Grounded Rubyist" third edition is up for preorder on the publishers website. %50 off with code wm031618lt
[22:02:59] samort7: After shipping came to ~$31 for me if anyone's interested
[22:03:17] havenwood: samort7: I'm glad to see the third edition is out. thanks for the heas-up
[22:03:27] samort7: headius: np
[22:03:28] shpoont: has joined #ruby
[22:03:50] samort7: Also, their pre-order program is pretty neat. You get early access to the ebook as its written
[22:05:06] harrycs: nice, reminds me that maybe i should finish the second edition ':D
[22:05:49] samort7: currently has 160 pages available. 5 chapters worth
[22:06:57] duderonomy: has joined #ruby
[22:08:43] chouhoulis: has joined #ruby
[22:10:17] kiltzman: has joined #ruby
[22:10:37] sameerynho: has joined #ruby
[22:13:59] trautwein: has joined #ruby
[22:14:42] cagomez: has joined #ruby
[22:15:07] xall: has joined #ruby
[22:15:34] trautwein: has joined #ruby
[22:16:50] mooe: has joined #ruby
[22:16:55] ChaosBringer: has joined #ruby
[22:25:59] AJA4350: has joined #ruby
[22:29:08] milardovich: has joined #ruby
[22:31:45] eckhardt_: has joined #ruby
[22:35:23] duderonomy: has joined #ruby
[22:40:18] shpoont: has joined #ruby
[22:42:17] tomphp: has joined #ruby
[22:42:52] havenwood: Someone should make sure they've changed the `(1..Float::INFINITY).each` examples to `1.step`.
[22:43:51] tcopeland: has joined #ruby
[22:53:21] duckpuppy: has joined #ruby
[23:02:17] eckhardt_: has joined #ruby
[23:05:32] roshanavand: has joined #ruby
[23:07:14] white_lilies: has joined #ruby
[23:07:49] Zedax: has joined #ruby
[23:10:34] shpoont: has joined #ruby
[23:11:33] workmad3: has joined #ruby
[23:15:23] kn-928: has joined #ruby
[23:18:41] jamiejackson2577: has joined #ruby
[23:21:25] brentw: has joined #ruby
[23:22:16] eckhardt_: has joined #ruby
[23:23:16] cschneid: has joined #ruby
[23:23:49] brentw: i'm having pulling down a file form S3, that I uploaded earlier due to the permissions being set to owner, when i need them as world
[23:24:51] brentw: when using aws-sdk is an option when doing AWS_BUCKET.objects[blah].write(file: blah, permission_option: 'public-read')
[23:25:21] brentw: or a way to set the permission on a specific file after it's been uploaded so i can pull it down later
[23:29:55] ramfjord: has joined #ruby
[23:31:01] roca: has joined #ruby
[23:35:05] yxhuvud: has joined #ruby
[23:35:58] ramfjord: has joined #ruby
[23:36:41] houhoulis: has joined #ruby
[23:37:00] StreetOwl: has joined #ruby
[23:37:04] StreetOwl: has left #ruby: ("No boundaries on the net!")
[23:39:13] bmurt: has joined #ruby
[23:39:22] Azure: has joined #ruby
[23:39:38] postmodern: has joined #ruby
[23:41:36] venmx: has joined #ruby
[23:41:49] milardovich: has joined #ruby
[23:42:56] phenom: has joined #ruby
[23:44:05] dstrunk: has joined #ruby
[23:46:00] bmurt: has joined #ruby
[23:46:04] roshanavand: has joined #ruby
[23:48:04] nicesignal: has joined #ruby
[23:49:18] mikecmpbll: has joined #ruby
[23:51:20] ramfjord: has joined #ruby
[23:52:16] cdg: has joined #ruby
[23:54:50] duckpuppy: has joined #ruby
[23:58:47] eckhardt_: has joined #ruby
[23:59:25] cdg: has joined #ruby