« Back to channel list

#ruby - 13 November 2017

« Back 1 day Forward 1 day »
[00:02:09] ur5us: has joined #ruby
[00:03:28] plexigras: ruby koans is great :)
[00:03:33] milardovich: has joined #ruby
[00:03:53] apeiros: has joined #ruby
[00:04:58] alveric1: has joined #ruby
[00:06:10] char_var[buffer]: has joined #ruby
[00:09:43] Asher: has joined #ruby
[00:11:05] Freshnuts: has joined #ruby
[00:12:59] mikecmpbll: has joined #ruby
[00:16:12] cdg: has joined #ruby
[00:21:21] charliesome: has joined #ruby
[00:21:42] guardianx: has joined #ruby
[00:25:40] apeiros: has joined #ruby
[00:27:10] enko: has joined #ruby
[00:35:51] Ropeney: has joined #ruby
[00:36:21] guacamole: has joined #ruby
[00:39:27] enterprisey: has joined #ruby
[00:40:19] Uptime: has joined #ruby
[00:42:31] Uptime: has joined #ruby
[00:47:15] Devalo: has joined #ruby
[00:51:05] apeiros: has joined #ruby
[00:52:10] Azure: has joined #ruby
[00:58:54] c0dec: has left #ruby: ()
[00:59:39] dviola: has joined #ruby
[00:59:51] tristanp: has joined #ruby
[01:02:06] Exhiled: has joined #ruby
[01:03:07] cschneid_: has joined #ruby
[01:07:13] jackjackdripper: has joined #ruby
[01:15:23] cschneid_: has joined #ruby
[01:15:28] gnufied: has joined #ruby
[01:16:02] cdg: has joined #ruby
[01:21:36] yeticry_: has joined #ruby
[01:35:18] raynold: has joined #ruby
[01:35:28] Jameser: has joined #ruby
[01:35:34] tristanp: has joined #ruby
[01:39:32] mim1k: has joined #ruby
[01:45:47] Technodrome: has joined #ruby
[01:46:45] Jameser: has joined #ruby
[01:47:15] DrCode: has joined #ruby
[01:55:26] diego1: has joined #ruby
[01:55:48] diego1: has joined #ruby
[02:00:22] mson: has joined #ruby
[02:01:57] Exhiled: has joined #ruby
[02:05:19] dviola: has joined #ruby
[02:07:20] mim1k: has joined #ruby
[02:13:31] NightMonkey: has joined #ruby
[02:15:02] houhoulis: has joined #ruby
[02:16:23] chmurifree: has joined #ruby
[02:16:54] JsilverT: has joined #ruby
[02:19:03] mim1k: has joined #ruby
[02:19:08] skweek: has joined #ruby
[02:28:47] nowhere_man: has joined #ruby
[02:32:03] alfiemax: has joined #ruby
[02:34:36] mim1k: has joined #ruby
[02:34:59] hutch34: has joined #ruby
[02:37:03] nowhere_man: has joined #ruby
[02:37:49] cdg: has joined #ruby
[02:39:57] c0ncealed: has joined #ruby
[02:41:46] cdg: has joined #ruby
[02:47:55] knight33: has joined #ruby
[02:48:26] DrCode: has joined #ruby
[02:48:28] milardovich: has joined #ruby
[02:57:05] d^sh: has joined #ruby
[03:02:12] kryptoz: has joined #ruby
[03:05:26] mim1k: has joined #ruby
[03:08:19] chouhoulis: has joined #ruby
[03:09:14] memo1: has joined #ruby
[03:10:25] [[thufir]]: has joined #ruby
[03:11:32] dtzuzu: has joined #ruby
[03:15:42] alfiemax: has joined #ruby
[03:15:45] mim1k: has joined #ruby
[03:16:18] Technodrome: has joined #ruby
[03:18:06] uZiel: has joined #ruby
[03:24:32] kryptoz: has joined #ruby
[03:26:13] shakes: has joined #ruby
[03:28:00] s2013: has joined #ruby
[03:31:18] mim1k: has joined #ruby
[03:36:09] dviola: has joined #ruby
[03:39:11] emers2n: has joined #ruby
[03:41:43] nowhere_man: has joined #ruby
[03:42:53] mim1k: has joined #ruby
[03:46:27] millz: has joined #ruby
[03:57:23] govg: has joined #ruby
[03:58:26] weathermaker1: has joined #ruby
[04:00:11] cschneid_: has joined #ruby
[04:01:14] p0p0pr37: has joined #ruby
[04:02:53] char_var[buffer]: has joined #ruby
[04:09:00] mim1k: has joined #ruby
[04:12:10] _whitelogger: has joined #ruby
[04:14:37] tristanp: has joined #ruby
[04:16:53] alfiemax_: has joined #ruby
[04:24:33] mim1k: has joined #ruby
[04:27:06] alfiemax: has joined #ruby
[04:27:16] gix: has joined #ruby
[04:30:54] oshanz: has joined #ruby
[04:40:00] nolakat: has joined #ruby
[04:40:03] mim1k: has joined #ruby
[04:42:43] guacamole: has joined #ruby
[04:43:29] false_economy: has joined #ruby
[04:44:13] testing: has joined #ruby
[04:44:37] baweaver: Feel free to ignore.
[04:47:58] jamesaxl: has joined #ruby
[05:00:41] jamesaxl: has joined #ruby
[05:12:57] Dimik: has joined #ruby
[05:13:07] houhoulis: has joined #ruby
[05:15:07] tristanp: has joined #ruby
[05:15:58] alfiemax_: has joined #ruby
[05:26:25] guardianx: has joined #ruby
[05:27:39] howdoi: has joined #ruby
[05:31:28] iamarun: has joined #ruby
[05:32:08] anisha: has joined #ruby
[05:38:23] nolakat: has joined #ruby
[05:39:27] moei: has joined #ruby
[05:40:48] b100s: has joined #ruby
[05:41:49] b100s: hi2all; is there autovivification for hashes? i want to do next: `foo={} foo['x']['y']=1 foo # => {"x"=>{"y"=>1}}
[05:43:32] Radar: b100s: not in Ruby.
[05:43:52] Radar: I could see how it'd be helpful.
[05:44:31] skweek: has joined #ruby
[05:45:11] baweaver: b100s / Radar: Oh we about to have fun
[05:45:59] baweaver: >> viv_hash = Hash.new { |h,k| h[k] = Hash.new(&h.default_proc) }; viv_hash[:a][:b][:c] = 5; viv_hash
[05:46:00] ruby[bot]: baweaver: # => {:a=>{:b=>{:c=>5}}} (https://eval.in/898429)
[05:46:35] baweaver: So then, fun time, what is that doing? A Hash can take a block constructor that allows you to define the value for a missing key, a default if you will
[05:46:37] JsilverT: has joined #ruby
[05:46:42] baweaver: That block is called the default_proc of the hash
[05:47:13] baweaver: and since `h` in that block is the hash itself, you can borrow that block and make a new Hash with that same block indefinitely
[05:47:44] baweaver: Now this isn't "true" autovivification as Perl would let you mix and match with Arrays. Ruby can only really get away with Hashes like this
[05:48:52] baweaver: Read through this one b100s: https://medium.com/@baweaver/abusing-hash-constructors-65d59c0a5b27
[05:50:16] b100s: baweaver, thanks
[05:52:33] milardovich: has joined #ruby
[05:58:29] BTRE: has joined #ruby
[05:58:48] mjolnird: has joined #ruby
[06:04:28] mim1k: has joined #ruby
[06:06:27] DrCode: has joined #ruby
[06:07:41] stoffus: has joined #ruby
[06:08:06] skweek: has joined #ruby
[06:11:22] skweek: has joined #ruby
[06:14:38] Technodrome: has joined #ruby
[06:19:49] mim1k: has joined #ruby
[06:23:43] reber: has joined #ruby
[06:29:13] milardovich: has joined #ruby
[06:33:55] mim1k: has joined #ruby
[06:39:35] guacamole: has joined #ruby
[06:42:02] aufi: has joined #ruby
[06:49:28] mim1k: has joined #ruby
[06:50:21] dminuoso: o/ good morning
[06:52:11] charliesome: has joined #ruby
[06:59:08] mim1k: has joined #ruby
[07:02:37] FrankD: has joined #ruby
[07:09:43] mim1k: has joined #ruby
[07:18:49] zoras: has joined #ruby
[07:21:27] mozzarella: has joined #ruby
[07:21:30] mim1k: has joined #ruby
[07:22:21] cadillac_: has joined #ruby
[07:33:53] false_economy: has joined #ruby
[07:35:40] dionysus69: has joined #ruby
[07:37:03] mim1k: has joined #ruby
[07:40:17] alex``: has joined #ruby
[07:40:21] conta: has joined #ruby
[07:41:40] zautomata: has joined #ruby
[07:43:16] biberu: has joined #ruby
[07:47:34] ferr: has joined #ruby
[07:50:11] bigkevmcd: has joined #ruby
[07:50:38] mim1k: has joined #ruby
[07:55:42] bigkevmcd: has joined #ruby
[08:01:13] andikr: has joined #ruby
[08:01:53] mim1k: has joined #ruby
[08:04:50] zautomata: has joined #ruby
[08:05:20] [[thufir]]: has joined #ruby
[08:08:48] mim1k: has joined #ruby
[08:12:17] tAn: has joined #ruby
[08:13:32] skweek: has joined #ruby
[08:15:42] claudiuinberlin: has joined #ruby
[08:17:42] Stan: has joined #ruby
[08:18:05] iamarun: has joined #ruby
[08:18:42] zoras: has joined #ruby
[08:24:23] mim1k: has joined #ruby
[08:24:33] sina: has joined #ruby
[08:28:37] Ilie[]: has joined #ruby
[08:29:03] mark_66: has joined #ruby
[08:33:48] dinfuehr: has joined #ruby
[08:34:15] Technodrome: has joined #ruby
[08:34:19] Ilie[]: has joined #ruby
[08:36:44] Ilie[]: has left #ruby: ()
[08:38:10] marr: has joined #ruby
[08:39:37] mim1k: has joined #ruby
[08:40:48] larcara: has joined #ruby
[08:42:17] sysvalve: has joined #ruby
[08:44:07] tomphp: has joined #ruby
[08:51:22] pwnd_nsfw: has joined #ruby
[08:52:46] Defenestrate: has joined #ruby
[08:52:46] Defenestrate: has joined #ruby
[08:53:33] iamarun: has joined #ruby
[08:55:18] giraffe: has joined #ruby
[08:56:05] cdg: has joined #ruby
[08:56:05] tpendragon: has joined #ruby
[09:02:07] aupadhye: has joined #ruby
[09:02:38] alfiemax: has joined #ruby
[09:04:46] guille-moe: has joined #ruby
[09:06:16] vondruch: has joined #ruby
[09:07:48] mikecmpbll: has joined #ruby
[09:08:45] guille-moe: has joined #ruby
[09:12:50] Silthias: has joined #ruby
[09:16:43] mim1k: has joined #ruby
[09:17:00] quobo: has joined #ruby
[09:18:01] nhhc: has joined #ruby
[09:18:48] guille-moe: has joined #ruby
[09:19:09] hs366: has joined #ruby
[09:22:38] InfinityFye: has joined #ruby
[09:26:46] Technodrome: has joined #ruby
[09:27:16] Beams: has joined #ruby
[09:27:53] kapil___: has joined #ruby
[09:36:52] ur5us: has joined #ruby
[09:40:40] gradio: has joined #ruby
[09:48:27] charliesome: has joined #ruby
[09:50:38] Silthias1: has joined #ruby
[09:51:50] guardianx: has joined #ruby
[09:52:57] Serpent7776: has joined #ruby
[09:53:38] Xeago: has joined #ruby
[10:01:00] papanik: has joined #ruby
[10:14:06] banisterfiend: has joined #ruby
[10:16:51] banisterfiend: has joined #ruby
[10:21:46] zoras: has joined #ruby
[10:23:34] ShalokShalom: has joined #ruby
[10:23:55] guille-moe: has joined #ruby
[10:25:37] workmad3: has joined #ruby
[10:29:44] milardovich: has joined #ruby
[10:37:37] Defenestrate: has joined #ruby
[10:37:53] guille-moe: has joined #ruby
[10:40:29] banisterfiend: has joined #ruby
[10:43:14] tvw: has joined #ruby
[10:43:35] ldnunes: has joined #ruby
[10:46:50] xco: has joined #ruby
[10:47:53] DrCode: has joined #ruby
[10:53:00] banisterfiend: has joined #ruby
[10:54:34] [[thufir]]: has joined #ruby
[10:55:47] DrCode: has joined #ruby
[11:00:12] roshanavand: has joined #ruby
[11:02:37] zanoni: has joined #ruby
[11:06:35] Bish: how was that thing called that i get a "paged_each" of an enumerable
[11:06:43] Bish: say i have an array with 10000 elements
[11:06:51] Bish: and i want to iterate through each 1k block
[11:07:44] Bish: is it each slice?
[11:07:59] Bish: guess so !
[11:08:23] elomatreb: #each_cons is also kind of like that
[11:08:44] Bish: well, no, that would get my doubles, doesnt it?
[11:08:56] Bish: >> [1,2,3].each_cons(2).map(&:itself)
[11:08:59] ruby[bot]: Bish: # => [[1, 2], [2, 3]] (https://eval.in/898719)
[11:09:10] Bish: >> [1,2,3].each_slice(2).map(&:itself)
[11:09:12] ruby[bot]: Bish: # => [[1, 2], [3]] (https://eval.in/898720)
[11:09:25] Bish: yep, i guess thats what i want
[11:09:52] veeti: has joined #ruby
[11:10:25] kn330: has joined #ruby
[11:11:22] jk1rk: has joined #ruby
[11:11:50] yokel: has joined #ruby
[11:15:39] gigetoo: has joined #ruby
[11:19:05] Bish: >> [1,2,3,4].each_slice(3).map(&:itself)
[11:19:06] ruby[bot]: Bish: # => [[1, 2, 3], [4]] (https://eval.in/898739)
[11:23:10] Bish: wait, whats the point with doing it with more than 2
[11:24:29] alfiemax: has joined #ruby
[11:34:24] jaruga: has joined #ruby
[11:34:48] ferr: has left #ruby: ("WeeChat 1.9.1")
[11:37:29] 7GHAA6JEP: has joined #ruby
[11:44:05] enterprisey: has joined #ruby
[11:44:25] hightower2: has joined #ruby
[11:44:56] larcara: has joined #ruby
[11:48:50] plexigras: has joined #ruby
[11:56:42] mim1k_: has joined #ruby
[11:57:11] alfiemax: has joined #ruby
[12:18:23] larcara: has joined #ruby
[12:23:37] apeiros: uh Bish, just .to_a instead of .map(&:itself)
[12:24:07] alfiemax: has joined #ruby
[12:52:27] heftig: has joined #ruby
[12:53:04] ferr: has joined #ruby
[12:53:10] ferr: has left #ruby: ()
[12:54:29] Hexafox[I]: has joined #ruby
[12:58:48] Bish: has joined #ruby
[12:59:06] rabajaj: has joined #ruby
[12:59:50] Silthias: has joined #ruby
[13:02:58] govg: has joined #ruby
[13:06:05] tristanp: has joined #ruby
[13:08:22] govg: has joined #ruby
[13:08:43] dviola: has joined #ruby
[13:09:02] conta1: has joined #ruby
[13:10:05] synthroid: has joined #ruby
[13:13:07] erciccione_[m]: has joined #ruby
[13:18:48] tsglove: has joined #ruby
[13:22:36] tcopeland: has joined #ruby
[13:25:02] gradio: has joined #ruby
[13:37:08] alfiemax: has joined #ruby
[13:37:38] bmurt: has joined #ruby
[13:38:05] xco: has joined #ruby
[13:39:04] mson: has joined #ruby
[13:39:14] dinfuehr: has joined #ruby
[13:42:01] guardian: hello, if I do def foo(h = {}, x) -- I can't call it this way: foo(bar: 'baz', 'x')
[13:42:18] guardian: is there a way to approach "first parameters end up in the hash, last one end up in x" ?
[13:42:26] guardian: not sure if Ruby syntax allows that
[13:45:06] crst: has joined #ruby
[13:46:12] claudiuinberlin: has joined #ruby
[13:50:36] uZiel: has joined #ruby
[13:51:20] alfiemax: has joined #ruby
[13:52:42] Psybur: has joined #ruby
[13:56:54] milardovich: has joined #ruby
[13:58:09] cdg: has joined #ruby
[13:59:33] apeiros: guardian: foo({bar: 'baz'}, 'x')
[13:59:48] guille-moe: has joined #ruby
[14:01:05] AliasSpider: has joined #ruby
[14:03:11] s2013: has joined #ruby
[14:04:04] cdg: has joined #ruby
[14:06:44] guardian: that's what I expected
[14:07:02] alfiemax: has joined #ruby
[14:16:09] JsilverT: has joined #ruby
[14:24:13] nopolitica: has joined #ruby
[14:24:17] zoras: has joined #ruby
[14:31:20] shinnya: has joined #ruby
[14:32:53] john__: has joined #ruby
[14:34:29] oleo: has joined #ruby
[14:35:43] zarubin1: has joined #ruby
[14:38:20] milardov_: has joined #ruby
[14:39:01] zoras: has joined #ruby
[14:39:39] alfiemax: has joined #ruby
[14:39:50] DLSteve: has joined #ruby
[14:43:37] krawchyk: has joined #ruby
[14:43:42] banisterfiend: has joined #ruby
[14:44:18] cdg: has joined #ruby
[14:46:55] gizmore: has joined #ruby
[14:51:37] iamarun: has joined #ruby
[14:51:46] uZiel: has joined #ruby
[14:55:22] jrafanie: has joined #ruby
[14:56:02] bmurt: has joined #ruby
[14:56:53] uZiel: has joined #ruby
[14:59:01] tsglove2: has joined #ruby
[15:02:22] polishdub: has joined #ruby
[15:03:04] hutch34: has joined #ruby
[15:04:39] mikecmpb_: has joined #ruby
[15:06:50] Rapture: has joined #ruby
[15:07:03] jey: has joined #ruby
[15:14:12] rippa: has joined #ruby
[15:16:13] mim1k: has joined #ruby
[15:16:24] cdg: has joined #ruby
[15:16:34] veeti: has joined #ruby
[15:19:22] milardovich: has joined #ruby
[15:24:18] bmurt: has joined #ruby
[15:26:46] tristanp: has joined #ruby
[15:27:44] RougeR: has joined #ruby
[15:29:04] RougeR: has joined #ruby
[15:33:46] cadillac_: has joined #ruby
[15:37:03] mikecmpbll: has joined #ruby
[15:38:09] zautomata: has joined #ruby
[15:48:43] jrafanie: has joined #ruby
[15:51:11] Silthias1: has joined #ruby
[15:53:26] DLSteve: has joined #ruby
[15:55:47] Lytol: has joined #ruby
[15:57:35] synthroid: has joined #ruby
[15:57:47] yqt: has joined #ruby
[16:00:41] milardov_: has joined #ruby
[16:01:43] jrafanie_: has joined #ruby
[16:03:10] brendan-: has joined #ruby
[16:03:42] jackjackdripper: has joined #ruby
[16:07:01] AliasSpider: has joined #ruby
[16:07:15] ahrs: has joined #ruby
[16:07:23] nadir: has joined #ruby
[16:11:22] cschneid_: has joined #ruby
[16:11:27] mim1k: has joined #ruby
[16:12:45] alfiemax: has joined #ruby
[16:18:14] elphe: has joined #ruby
[16:19:01] milardovich: has joined #ruby
[16:20:22] cdg: has joined #ruby
[16:22:19] cdg_: has joined #ruby
[16:32:36] sindssyg: has joined #ruby
[16:35:11] Technodrome: has joined #ruby
[16:36:33] Bish: has joined #ruby
[16:39:56] cagomez: has joined #ruby
[16:43:34] milardovich: has joined #ruby
[16:51:18] selim: has joined #ruby
[16:53:06] bmurt: has joined #ruby
[16:56:45] aScottishBoat: has joined #ruby
[16:57:38] aScottishBoat: what's the craic rubyists
[17:00:23] selim: has joined #ruby
[17:00:54] urk187: has joined #ruby
[17:01:22] mikecmpb_: has joined #ruby
[17:01:46] marxarelli: has joined #ruby
[17:01:53] veeti: has joined #ruby
[17:02:22] michael3: has joined #ruby
[17:05:15] tsglove3: has joined #ruby
[17:06:22] Exhiled: has joined #ruby
[17:06:23] larcara: has joined #ruby
[17:07:55] uZiel: has joined #ruby
[17:09:55] tomphp: has joined #ruby
[17:11:03] tsglove2: has joined #ruby
[17:12:31] dcluna: has joined #ruby
[17:13:26] ahrs: has joined #ruby
[17:14:34] [Butch]: has joined #ruby
[17:16:57] bmurt: has joined #ruby
[17:19:39] Silthias: has joined #ruby
[17:20:22] Exhiled: has joined #ruby
[17:22:35] vipaca: has joined #ruby
[17:22:38] conta1: has joined #ruby
[17:23:38] d5sx43: has joined #ruby
[17:26:18] DTZUZO: has joined #ruby
[17:26:34] Asher: has joined #ruby
[17:30:34] alfiemax: has joined #ruby
[17:30:39] uZiel: has joined #ruby
[17:33:12] ledestin: has joined #ruby
[17:36:55] cagomez: has joined #ruby
[17:37:58] uZiel: has joined #ruby
[17:40:13] mson: has joined #ruby
[17:40:40] airdisa: has joined #ruby
[17:41:29] MrSparkle: has joined #ruby
[17:42:11] orbyt_: has joined #ruby
[17:42:58] mikecmpbll: has joined #ruby
[17:44:33] ur5us: has joined #ruby
[17:44:51] polishdub: has joined #ruby
[17:49:12] veeti: has joined #ruby
[17:49:50] false_economy: has joined #ruby
[17:52:53] xco: has joined #ruby
[17:53:25] xco: has joined #ruby
[17:54:14] xco: has joined #ruby
[17:55:12] xco: has joined #ruby
[17:55:39] roshanavand: has joined #ruby
[17:56:01] xco: has joined #ruby
[17:59:02] kies: has joined #ruby
[18:04:59] muelleme: has joined #ruby
[18:05:17] flak: has joined #ruby
[18:05:40] dionysus69: has joined #ruby
[18:06:07] whippythellama: has joined #ruby
[18:06:57] airdisa_: has joined #ruby
[18:11:20] millerti: has joined #ruby
[18:12:09] larcara: has joined #ruby
[18:14:10] eckhardt: has joined #ruby
[18:14:27] Gadgetoid: has joined #ruby
[18:17:43] michael3: has joined #ruby
[18:18:10] elphe: has joined #ruby
[18:20:37] dcluna: has joined #ruby
[18:21:33] Gadgetoid: has joined #ruby
[18:22:26] SeepingN: has joined #ruby
[18:23:28] gnufied: has joined #ruby
[18:23:48] AliasSpider: has joined #ruby
[18:25:32] larcara: has joined #ruby
[18:27:33] cagomez: has joined #ruby
[18:29:44] David_H_Smith: has joined #ruby
[18:31:38] milardovich: has joined #ruby
[18:33:30] tamouse__: has joined #ruby
[18:34:52] cagomez: has joined #ruby
[18:36:21] milardovich: has joined #ruby
[18:36:38] milardov_: has joined #ruby
[18:37:36] RickHull: It may be Monday, but the weather is beautiful here after a gray, drizzly weekend :)
[18:38:05] dminuoso: RickHull, oh man
[18:38:15] dminuoso: I prepared a gist about why some functional stuff was so awesome
[18:38:24] dminuoso: Accidentally closed the tab and forgot what I wrote.
[18:38:52] RickHull: i think there is a reasonable CLI interface to gists -- like setting up push/pull
[18:39:00] RickHull: but I always just use the web ui
[18:39:37] troys: has joined #ruby
[18:39:52] RickHull: oh, you can probably restore old tabs too
[18:39:52] dminuoso: RickHull, in the end I just tried to point out how the function-returning perspective is so useful. How defc :eq { |a, b| a == b } is a "predicate constructor"
[18:40:02] dminuoso: RickHull, I was drunk, didnt notice.
[18:40:15] RickHull: shoot, maybe it never even happened ;)
[18:40:32] dminuoso: RickHull, so something like eq('foo') can be viewed as a partially applied equal test.
[18:40:43] dminuoso: But if you look at what you get back, its just something of the shape: [String] -> Bool
[18:40:48] dminuoso: err String -> Bool
[18:40:53] raynold: has joined #ruby
[18:40:53] dminuoso: And we call this a predicate.
[18:41:01] RickHull: overloaded term
[18:41:01] dminuoso: We use this a lot in fact. For example in Array#filter
[18:41:26] eckhardt: has joined #ruby
[18:41:26] dminuoso: RickHull, when I say eq, I mean extensional equality without looking into object id
[18:41:40] RickHull: no, i mean as in predicate method like is_a?
[18:41:48] dminuoso: RickHull, same exact thing!
[18:42:16] dminuoso: is_a? :: Module -> Bool
[18:42:18] dminuoso: Its a predicate.
[18:42:23] RickHull: the defining characteristic of returning a bool, isn't that just coincidental in your case?
[18:42:32] dminuoso: No, thats what's called a predicate.
[18:42:36] tAn: has joined #ruby
[18:42:37] kinduff: has joined #ruby
[18:42:39] dminuoso: Anything that returns a bool is called a predicate.
[18:42:42] RickHull: ok, I thought you were implying something else
[18:43:11] dminuoso: So my point is just that defc :eq { |a, b| ... } taking two parameters can also be viewed in this JS notation
[18:43:23] dminuoso: eq = (a) => (b) => a === b
[18:43:33] dminuoso: so eq is just a function that takes an argument, and returns a predicate.
[18:43:42] dminuoso: it literally constructs predicates.
[18:44:15] dminuoso: RickHull, So how you do filter an array for an element that equals "foo" in the canonical way?
[18:44:23] dminuoso: Just do the natural thing that comes to mind
[18:44:36] RickHull: ary.select { |a| a == 'foo' }
[18:44:55] dminuoso: Lets look at that. You called select, and (semantically) passed one argument: the block
[18:45:05] dminuoso: { |a| a == 'foo' } is just a very explicit construction of a predicate function.
[18:45:05] RickHull: ary.select(&:eq('foo')) ?
[18:45:07] dminuoso: You made a predicate function.
[18:45:30] xco: has joined #ruby
[18:45:33] RickHull: ary.select(&:eq, 'foo') ?
[18:45:40] dminuoso: And Im just saying, why not invent functions that construct them for you? It also saves you the trouble of finding a sensible name for that parameter
[18:46:02] dminuoso: ary.select eq('foo') # would be kind of cool.
[18:46:11] jrafanie: has joined #ruby
[18:46:20] dminuoso: RickHull, you have been doing this style of function constructoin in a different space
[18:46:22] RickHull: i think this is kinda how perl's map works?
[18:46:38] dminuoso: RickHull, [1,2,3], convert this into an array of strings, where each number gets converted to a string using .to_s
[18:46:52] dminuoso: Using the short and elegant syntax.
[18:46:56] RickHull: [1,2,3].map(&:to_s)
[18:47:08] dminuoso: &:to_s can be viewed as a higher order function.
[18:48:02] dminuoso: When invoked (through to_proc), it returns a function back (a Proc object).
[18:48:15] RickHull: for ary.select eq('foo') -- is 'foo' a or b?
[18:48:42] RickHull: what code is responsible for assigning the other value in the comparison?
[18:48:45] dminuoso: RickHull, good question. Lack of expressive syntax means you have to rely on convention.
[18:48:53] dminuoso: RickHull, eq curries.
[18:49:02] RickHull: so something in select
[18:49:12] dminuoso: RickHull, well select would have to be rigged to work with lambdas of course.
[18:49:18] dminuoso: (Which my upcoming fp library does)
[18:49:35] dminuoso: you could also do it the hard way ary.select &eq('foo')
[18:49:50] dminuoso: RickHull, think about what select does with your block
[18:50:03] dminuoso: RickHull, it just *calls* it.
[18:50:34] dminuoso: RickHull, so if eq('foo') returns a predicate (a _function_ returning bool), and select *calls* whatever you give it for each element..
[18:50:41] RickHull: so 'foo' is a?
[18:50:46] RickHull: and select provides b?
[18:50:51] kapil___: has joined #ruby
[18:50:51] dminuoso: RickHull, yes.
[18:51:05] RickHull: ha, is a? xD
[18:51:28] dminuoso: RickHull, in haskell you could do even do this with operators like: map (/2) [1,2,3,]
[18:51:38] dminuoso: RickHull, this makes it quite obvious which "parameter" is not applied in (/2)
[18:51:44] Exhiled: has joined #ruby
[18:52:06] RickHull: I suppose it doesn't much matter which is which, but in the current version of select, select provides 'a' and the block locally defines b
[18:52:18] dminuoso: if the operator is commutative it does not. but in case for division it does.
[18:52:26] dminuoso: luckily you also come with a flip operator
[18:52:31] dminuoso: (it just flips the argument of a 2-arity function)
[18:52:33] biox: has joined #ruby
[18:52:38] pskosinski: has joined #ruby
[18:52:38] dminuoso: so you can always "apply the other one"
[18:52:43] cagomez: has joined #ruby
[18:53:25] RickHull: it's pretty neat, but what about barking up the wrong tree for a language without typed method signatures?
[18:53:31] dminuoso: so if you wanted to divide an entire list by 2 element wise, you could do: [1,2,3,4,5].fmap flip(div).(2)
[18:54:13] dminuoso: RickHull, in JS I have been using comments with haskell style type signatures
[18:54:22] RickHull: i think, for readability, I like the ary.map { |i| i / 2 }
[18:54:24] dminuoso: It works quite well to keep track on what types you have
[18:54:33] dminuoso: RickHull, yeah this is not an ideal example.
[18:54:36] RougeR: has joined #ruby
[18:55:10] Scient: has joined #ruby
[18:56:01] sinduck: has joined #ruby
[18:56:02] Technodrome: has joined #ruby
[18:56:04] dminuoso: RickHull, let me find a real world example for you
[18:58:42] larcara: has joined #ruby
[18:59:42] Exhiled: has joined #ruby
[19:00:42] cagomez: has joined #ruby
[19:00:54] cagomez: has joined #ruby
[19:02:17] veeti: has joined #ruby
[19:03:17] jrafanie_: has joined #ruby
[19:04:10] roshanavand: has joined #ruby
[19:06:04] elphe: has joined #ruby
[19:06:32] RickHull: no need, really -- I'm more or less a true believer, except I prefer to do this stuff in Elixir, where the language is more encouraging of this style
[19:07:15] RickHull: I think Elixir is better suited for large, more complex apps, where the work types do is worth their expense
[19:07:49] RickHull: and Ruby is more optimized for smaller libs and microservices, where the API is the unit of abstraction
[19:07:58] RickHull: somewhat more expressive in the procedural realm
[19:08:26] dminuoso: RickHull, https://gist.github.com/norc/fa0ac8ef1c6eac1b6f9837a3306702fe
[19:08:49] dminuoso: This is made up and can be tweaked in a few ways.
[19:09:02] d5sx43: has joined #ruby
[19:09:21] dminuoso: But almost every function in there is only partially applied to obtain the "build me a function of some shape with desired behavior" semantics
[19:10:02] RickHull: I like the general structure here, building up
[19:11:00] RickHull: i don't quite follow L22
[19:11:11] RickHull: what is postsL and special path?
[19:11:22] dminuoso: postsL is a lens.
[19:11:30] Exhiled: has joined #ruby
[19:11:37] RickHull: i thought so :/
[19:11:38] dminuoso: They are functions of a very special kind. Basically think of them as something like XPath
[19:11:50] dminuoso: But without the ugliness. You can create them through functoinal means, compose them
[19:11:54] dminuoso: And do a lot of extremely wild things.
[19:12:05] RickHull: sounds a bit like the C# thing, LINC?
[19:12:08] RickHull: whatsitcalled?
[19:12:54] dminuoso: RickHull, think closer to like... imagine you have a huge nested hash with arrays and more hashes and so forth.
[19:12:57] RickHull: running into a lens there is like going down a nice path in the woods with berries and squirrels and running into a bear
[19:13:00] milardovich: has joined #ruby
[19:13:04] dminuoso: RickHull, and for some reason you are only interested in one particular point of the structure
[19:13:10] dminuoso: perhaps you want to look at it, or modify it.
[19:13:16] RickHull: yeah, that makes sense
[19:13:28] dminuoso: and a lens is just the "point at the thing"
[19:13:30] RickHull: it's ugly and hacky trying to that in a general way with basic ruby
[19:13:55] dminuoso: over/set/view take a lens and then either update/set/look at that point the lens points at.
[19:14:12] dminuoso: And like in optics, you can chain lenses to combine their effects.
[19:14:12] muelleme: has joined #ruby
[19:14:20] jackjackdripper: has joined #ruby
[19:14:25] conta2: has joined #ruby
[19:15:06] dminuoso: RickHull, this dealing with nested structures is one of the more painfully things to do in traditional ruby. you frequently end up using highly imperative code that suggests the structure
[19:15:16] RickHull: my hesitation here is that maybe deeply nested structures aren't that great to reason about in general
[19:15:31] RickHull: maybe rather than sharper tools, we should compose the problem differently
[19:15:35] RickHull: to reduce the deep nesting
[19:15:38] dminuoso: RickHull, you get them everywhere. Not many APIs follow JSON:API. So there better be an elegant way to deal with it.
[19:16:08] dminuoso: RickHull, its the same need how css selectors and XPath have been invented
[19:16:17] jackjackdripper: has joined #ruby
[19:16:21] dminuoso: the need to somehow find expressive ways of describing "how something can be found" from code.
[19:16:28] dminuoso: *and decoupling it from code
[19:16:44] tcopeland: has joined #ruby
[19:16:52] RickHull: FWIW, i haven't felt tempted to use XPath in a long time. though maybe it's from prior trauma at working with deeply nested structures.
[19:16:52] dminuoso: RickHull, its essentially the same reason why you dont use for to iterate over arrays. You use map.
[19:17:19] RickHull: I haven't written many functions that take more than a 2 dim array either
[19:17:21] Dimik: has joined #ruby
[19:17:28] RickHull: i'll rely on the caller to give me something simpler
[19:17:53] dminuoso: RickHull, another great thing about lenses is that it allows you to express how to access a certain portion of an object in a uniform manner.
[19:18:01] dminuoso: No longer do you have 17 source files all doing their own iteration and inspection
[19:18:13] dminuoso: You just share a set of single lenses that you can combine.
[19:18:25] RickHull: that seems sensible
[19:18:41] dminuoso: And in a way that both parties interested in mutating as well as viewing are using the same exact code.
[19:18:50] Technodrome: has joined #ruby
[19:19:12] RickHull: the worst part about deeply nested structures is that assumptions get made, and you address something like foo.bar.internals.undercarriage.drivetrain.hub.bearing
[19:19:20] RickHull: and then the domain model shifts slightly
[19:19:21] dminuoso: And better yet, if the structure is renested somewhere else, combining their lens with yours is as simple as: myLensL * yourNestedObjL
[19:19:23] dminuoso: Tadaa, done.
[19:19:26] dminuoso: New lens created.
[19:19:37] dminuoso: RickHull, yup
[19:19:48] dminuoso: RickHull, and now to make things interesting, optics allow you to sneak in Maybe
[19:20:03] dminuoso: RickHull, so suddenly you can sanely deal with "but what if internals does not exist?"
[19:20:10] dminuoso: but in a meaningful and expressive way.
[19:20:14] larcara: has joined #ruby
[19:20:52] dminuoso: The usual way would be to start foo.bar.internals.undercarriage&.drivetrain&.hub&.bearing. But what if you also want foo.bar.internals.undercarriage.drivetrain.hub.master?
[19:21:22] dminuoso: And what if there's an array or hash in between. &.[](0) is anything but sexy.
[19:22:12] dminuoso: These are not made up, I've dealt with this many times with deeply nested structures, where the structure might depend on values. Where intermediate path segments might not be present.
[19:22:18] RickHull: another way to do it is to just deal with a Drivetrain, and let some outer layer do a lot of nil checking and fail fast if the model has clearly shifted
[19:23:31] RickHull: yeah, arrays get gross -- you almost always have to take the first, but wonder if that's correct
[19:23:45] dminuoso: RickHull, and now you maybe want to traverse over intermediate paths.
[19:23:53] dminuoso: say you have this rigorous foo.bar.internals.undercarriage.drivetrain.hub.bearing structure
[19:23:57] dminuoso: and internals is an array.
[19:24:02] dminuoso: and you want an array of all bearings.
[19:24:06] dminuoso: Which may or may not exist
[19:24:23] RickHull: so maybe use relational algebra?
[19:24:26] Exhiled: has joined #ruby
[19:24:46] dminuoso: RickHull, right. So you quickly start to explore things that act lawful.
[19:24:52] dminuoso: Things that compose.
[19:24:57] dminuoso: Things that express.
[19:25:08] dminuoso: Lenses are in that box of solutions that fit.
[19:25:15] RickHull: but relational algebra is an argument against hierarchical models, right?
[19:25:22] RickHull: an alternative to deeply nested structures?
[19:25:49] nogic: has joined #ruby
[19:26:13] dminuoso: RickHull, again. What if you have an API just gives you these deeply nested structures?
[19:26:21] dminuoso: Especially with web APIs this happens so frequently its not funny.
[19:26:22] RickHull: use a different API, I say!
[19:26:35] zarubin1: has joined #ruby
[19:27:27] hutch34: has joined #ruby
[19:28:33] RickHull: the tricky part with arrays in the middle of a hierarchy, is that one tends to want to address leaves
[19:28:40] bmurt: has joined #ruby
[19:28:44] RickHull: in a static-looking way
[19:28:57] RickHull: but almost always you need a function to properly select the array member
[19:29:03] RickHull: and #first gets used by default
[19:29:36] RickHull: and what if two members pass the filter?
[19:30:00] RickHull: your address starts to become unreasonable
[19:30:22] kozrar: has joined #ruby
[19:30:38] RickHull: or else encodes unreasonable assumptions
[19:30:57] dminuoso: RickHull, Im not saying the imperative approach is wrong or unsustainable. But FP is equipped with certain things that have universal "go through an enumerable set of things, and then do transformations with effects"
[19:31:47] erciccione_[m]: Hi! I'm a noob looking for some feedbacks about my "Hello World" program: https://github.com/erciccione/50plus1-watcher
[19:31:48] erciccione_[m]: I already asked on /r/ruby and /r/learningruby, but haven't got many answers yet. My main concern is the overall structure
[19:31:53] dminuoso: they are called traversals, and if you have any compsci background (your programs imply you do), then you will recognize this in tree traversals.
[19:32:20] dminuoso: Hiya erciccione_[m], and welcome to ruby :)
[19:32:49] dminuoso: RickHull, ^- hah you see that? Lots of probing into structures!
[19:33:25] erciccione_[m]: Thanks Hiya! ( no '_[m]' needed ;) )
[19:33:35] dminuoso: erciccione_[m], my tab completion does this on its own.
[19:33:51] tomphp: has joined #ruby
[19:33:54] cseder: has joined #ruby
[19:34:00] dminuoso: erciccione_[m], which languages do you come from?
[19:34:04] RickHull: erciccione_[m]: proper indentation would help
[19:34:45] erciccione_[m]: dminuoso: yes i guess IRC doesn't understand that [m]
[19:34:49] dminuoso: erciccione_[m], if this is truly your first program, I don't think there's too many things to critize, except the complete disregard of ruby's object oriented nature.
[19:34:55] dminuoso: erciccione_[m], it's part of your nickname currently.
[19:34:58] erciccione_[m]: sorry i have no it background
[19:35:16] dminuoso: erciccione_[m], does it work™?
[19:35:54] erciccione_[m]: yes, I still need to properly understand that. [m] is because I'm using matrix/riot
[19:36:01] RickHull: dminuoso: well, my sense that when you have a tree with millions of items, very small perturbations to how operations are performed can have massive performance and resource implications
[19:36:04] dminuoso: erciccione_[m], then feel free to ignore it.
[19:36:13] tcopeland: has joined #ruby
[19:36:30] cseder: has joined #ruby
[19:36:32] dminuoso: RickHull, granted. I would not use my FP style to write high performance ruby code.
[19:36:39] dminuoso: But then again I wouldn't be writing it in ruby in the first place.
[19:36:40] RickHull: and so when you have such trees or structures at very large scale, you use tools that help with that. and ruby probably isn't one of them
[19:36:54] dminuoso: RickHull, and then FP languages are back in the game.
[19:37:52] RickHull: so when I choose ruby to tackle a problem, it's usually because I'm optimizing for expressiveness, and that means I can shrink the scope to something manageable
[19:38:30] dminuoso: RickHull, my Haskell experience is quite early. But I find that Haskell offers me a higher level of expressiveness through higher order functions and the incredibly amazing type system.
[19:38:47] RickHull: and if I get back a big terrible undercarriage thing, I'll use a disciplined procedural approach to validate its structure and fail fast if it doesn't meet the assumptions
[19:39:40] erciccione_[m]: dminuoso: thanks btw, will better check the indentation and object programming
[19:39:47] RickHull: dminuoso: agreed
[19:39:53] kyrofa: has joined #ruby
[19:39:56] dminuoso: erciccione_[m], be sure to check out the books link in the topic. It has some great resources for learning.
[19:40:05] imode: has joined #ruby
[19:40:28] RickHull: but Haskell and FP are also very sensitive to small perturbations, where something that basically looks right does unexpected stuff
[19:40:30] dminuoso: RickHull, something like Monoid m => [m] -> [m] tells me a lot of things without even seeing the *name* of the functions.
[19:40:37] erciccione_[m]: dminuoso: will do!
[19:40:41] dminuoso: RickHull, parametricity tells me so much about what laws this *must* hold.
[19:40:47] kyrofa: Can anyone explain to me how Ruby determines its arch-specific RUBYLIB path?
[19:41:00] dminuoso: RickHull, like its fundamentally impossible for that to not adhere to certain laws.
[19:41:43] ur5us: has joined #ruby
[19:41:45] dminuoso: RickHull, well any programming language has that.
[19:41:48] RickHull: dminuoso: that is true, but with Ruby, it's easier to mentally trace what the code does. Haskell requires a big load of the haskell model into the reader's brain
[19:41:54] dminuoso: RickHull, but a rigid type system catches errors.
[19:41:59] kyrofa: On amd64 it ends up with ruby/2.4.0/x86_64-linux, for example. However, on my raspberry pi it ends up with ruby/2.4.0/armv7l-linux-eabihf
[19:42:06] RickHull: agreed, I am more of a fan of types now
[19:42:33] dminuoso: RickHull, this "type correctness does not provide validity" is silly in two important ways: With parametricity you actually can prove validity in some cases. And more importantly: if your program does NOT typecheck it *IS* wrong.
[19:43:31] RickHull: kyrofa: it is probably part of the compile time options for the ruby interpreter
[19:43:43] kyrofa: RickHull, right, I'm building from source with no options
[19:43:44] dminuoso: I have spent numerous times debugging the wrong library, because duck typing allowed a faulty object to be passed in the wrong spot. And for some reasons it wasnt until in some seemingly unrelated code it explode.
[19:43:45] RickHull: kyrofa: have you looked at $LOAD_PATH as well?
[19:44:03] RickHull: kyrofa: you may want to look at what ruby-build and ruby-install projects do
[19:45:04] kyrofa: RickHull, I'm really just trying to figure out where the eabihf comes from.
[19:45:13] dminuoso: RickHull, I mean a trivial example: imagine a maximally malicious implementatoin of Enumerable where #each will at random yield and *then* delete an object.
[19:45:46] RickHull: kyrofa: uname maybe?
[19:45:48] dminuoso: Making sure that something like #filter would produce hilarious results.
[19:45:48] claudiuinberlin: has joined #ruby
[19:46:26] Papierkorb: dminuoso: read-only "variables" are part of the memory model used, not directly the type system
[19:46:41] Papierkorb: Though not being able to type in ruby is the biggest disvantage of the language.
[19:46:57] vipaca: has joined #ruby
[19:47:03] dminuoso: Papierkorb, that depends. There are typesystems where side-effects *have* to reside in special types.
[19:47:24] dminuoso: (Which allows you to look at a functions return type and see whether it has effects or not)
[19:47:31] Papierkorb: ah sure, the memory model and type model interact quite heavily
[19:47:34] RickHull: dminuoso: my sense is that going full-retard-FP has downsides that are mitigated by a type system. so I want to add FP sensibility to my ruby programs where it helps expressiveness. but Lenses without types might be more trouble than worth
[19:48:05] dminuoso: RickHull, I agree that its difficult to use right without a type system because you often wont understand what went wrong.
[19:48:26] FrostCandy: has joined #ruby
[19:48:27] dminuoso: It makes it difficult in JS, but it is doable with some discipline.
[19:48:42] dminuoso: (Though flow can give you a lot back)
[19:48:54] dminuoso: Papierkorb, this is something elixir has done right with protocols.
[19:49:07] dminuoso: Papierkorb, does crystal has some similar concept?
[19:49:16] Papierkorb: no idea what that is
[19:49:23] dminuoso: Papierkorb, think like Enumerable.
[19:49:39] dminuoso: Except you need to explicitly declare that something implements it.
[19:49:42] RickHull: similar to an interface?
[19:49:42] vipaca: has joined #ruby
[19:49:54] dminuoso: And Enumerable has some mechanism that says what it is required for something to be Enumerable.
[19:49:56] dminuoso: RickHull, yup.
[19:50:05] Papierkorb: like `include Enumerable' in ruby?
[19:50:17] dminuoso: Papierkorb, 0 checking going on
[19:50:29] dminuoso: >> class Foo; include Enumerable; end. Foo.new.is_a? Enumerable
[19:50:29] Papierkorb: or do you mean enforcement using abstract methods?
[19:50:30] ruby[bot]: dminuoso: # => undefined method `Foo' for Foo:Class (NoMethodError) ...check link for more (https://eval.in/899261)
[19:50:35] dminuoso: Bah. You know what I Mean.
[19:50:42] dminuoso: Papierkorb, yeah. Basically enforced interfaces.
[19:50:47] Papierkorb: Ah sure we have that
[19:51:12] dminuoso: RickHull, its also called "concepts", "typeclasses", "protocols"
[19:51:16] dminuoso: but they are all the same idea.
[19:52:37] dminuoso: RickHull, an example of using this would be: Ord a => [a] -> [a] which is saying: this works with anything that has Ord (which means objects of that typeclass are orderable). This strongly implies that whatever the function does, its very likely ordering related.
[19:52:40] Papierkorb: Crystal is 100% statically typed, even if the code (sometimes) doesn't look like that at all (Which is awesome). We don't have a "VM" under us while executing code
[19:52:57] Technodrome: has joined #ruby
[19:53:09] dminuoso: It does not care what it gets, as long as whatever type you pass it has been declared an instance of Ord (and by doing that you have to implement a method for comparing two objects)
[19:53:28] Papierkorb: dminuoso: Are you impressed by that?
[19:53:41] dminuoso: Papierkorb, no but only because I already knew crystal compiled to LLMV :P
[19:53:42] mtkd: has joined #ruby
[19:53:48] Papierkorb: I mean, that's a normal feature for a statically typed language I guess
[19:54:17] milardov_: has joined #ruby
[19:54:21] dminuoso: Papierkorb, but type inference (what you meant by "doesnt look like that at all") is what makes rigid type systems usable.
[19:54:28] larcara: has joined #ruby
[19:54:39] dminuoso: Being forced to be fully explicit is what makes Java so absolutely disgusting.
[19:54:58] RickHull: dminuoso: would Crystal be a better substrate for a ruby-like FP adventure?
[19:54:59] Papierkorb: It's .. among the issues of the Java language lul
[19:55:13] dminuoso: RickHull, if you want something with static types yes.
[19:55:23] RickHull: how about types at all?
[19:55:27] dminuoso: RickHull, elixir would be another option (but that has.. no real types.. well. it does)
[19:55:27] vipaca: has joined #ruby
[19:55:31] RickHull: are Haskell types static?
[19:55:34] dminuoso: RickHull, ruby has types.
[19:55:39] Papierkorb: RickHull: There's #crystal-lang on Freenode where we hang out
[19:55:48] Asher: has joined #ruby
[19:55:51] RickHull: Papierkorb: we've chatted in there in the last month ;)
[19:55:55] dminuoso: RickHull, yes. Haskell is strongly and statically typed.
[19:55:58] Papierkorb: Yeah I wasn't sure RickHull :P
[19:55:59] RickHull: I'll be back
[19:56:28] dminuoso: RickHull, Haskell has no "type conversion" except in some special spots with language extensions turned on.
[19:56:35] dminuoso: RickHull, instead Haskell has something better. Polymorphic types.
[19:56:41] waveprop: does an undergrad CS degree usually cover theory of computation, automata, like the Hindley-Milner etc
[19:56:42] hutch34: has joined #ruby
[19:56:55] waveprop: s/like the//
[19:56:56] RickHull: waveprop: yes, though I didn't study H-M
[19:57:07] dminuoso: waveprop, HM would only appear in specialized courses.
[19:57:31] RickHull: dminuoso: so wouldn't Crystal be more suitable than Ruby for this effort?
[19:57:46] waveprop: ok cool. might enroll then
[19:57:54] dminuoso: RickHull, I feel that Elixir has more application in industry high-performance/high-availability situations to the richness of OTP
[19:58:38] Papierkorb: Elixir is more "appropriate" if you want to learn something to get a job now
[19:58:42] RickHull: I don't disagree, but that's a different question ;)
[19:59:42] RickHull: OTP plus pattern matching and abandoning some OOP handcuffs
[19:59:56] dminuoso: RickHull, but crystal does not come with any of those fancy FP paradigms. What you get is a cleaned up language with a fast implementation, no "oops. someone just monkey patched String" situatoins
[20:00:06] dminuoso: Its the Ruby that should have been.
[20:00:09] dminuoso: From what I can tell.
[20:00:14] dminuoso: Papierkorb should know more
[20:00:16] RickHull: sure, and real types
[20:00:24] RickHull: with enforcement and signatures
[20:00:44] Papierkorb: I like FP as far it actually helps me. After that, nah.
[20:01:02] kyrofa: has left #ruby: ("Leaving")
[20:01:19] dminuoso: RickHull, dont ever try out dependent types.
[20:01:30] dminuoso: Im now jealous to not have them everywhere.
[20:01:39] vipaca: has joined #ruby
[20:01:50] dminuoso: Saw this amazing presentation of a PhD I think, who built a custom regex implementation that matched some simple string, and then demonstrated "it works"
[20:01:51] RickHull: my main exposure to types is via Elixir a few years ago -- I'm surely still a type klutz
[20:01:52] Papierkorb: #map and friends is good shit. Maybe at some point we get more rich guardy-clauses to do `def foo(0); 1; end; def foo(n) foo(n-1)*n; end`
[20:02:11] Papierkorb: but that's already cutting it, and I don't like that example
[20:02:40] dminuoso: Papierkorb, I think the expressivity falls down if you dont have = notatoin
[20:02:51] dminuoso: f 1 = 2 makes a lot of sense in the mathematical way
[20:02:58] Papierkorb: Programming isn't math
[20:02:58] dminuoso: def foo(0) 1; end
[20:03:02] dminuoso: does feel like noise
[20:03:11] Papierkorb: Because that's not what you write
[20:03:23] Papierkorb: If something feels wrong, it's usually because it's wrong
[20:03:31] dminuoso: Papierkorb, no its just a syntax issue
[20:03:56] dminuoso: Papierkorb, I mean Im deeply used to it from template specialization in C++, but its harsh to read
[20:04:02] airdisa: has joined #ruby
[20:04:03] RickHull: good languages guide you to do the right thing, where an approach feels good or bad
[20:04:12] RickHull: but syntax is more of a taste thing, and your tastes adjust
[20:04:20] armando: has joined #ruby
[20:04:41] dminuoso: <Papierkorb> #map and friends is good shit. Maybe at some point we get more rich guardy-clauses to do `def foo(0); 1; end; def foo(n) foo(n-1)*n; end`
[20:04:43] dminuoso: And is this not induction?
[20:04:45] dminuoso: Thats very mathy!
[20:04:58] havenwood: Multi-methods!
[20:05:23] Papierkorb: dminuoso: What, that I used a sample which I even wrote I don't like?
[20:05:36] Papierkorb: Sure you can reduce everything to 1s and 0s
[20:05:42] Papierkorb: You don't have to.
[20:06:05] muelleme: has joined #ruby
[20:06:18] Papierkorb: The problem with the math-only view is that more often than not, it only focuses on the local issues, and completely disregards the global issues
[20:06:41] havenwood: Papierkorb: multimethods could theoretically be added just as a different class of method
[20:06:50] havenwood: Papierkorb: like clojure's defmulti
[20:06:56] dminuoso: Papierkorb, I dont think that really applies.
[20:06:59] jrafanie: has joined #ruby
[20:07:26] dminuoso: Papierkorb, I rather tend to view it the different way around. The reason is that imperative languages constantly force you to think what happens in the smallest scale.
[20:07:27] havenwood: https://clojuredocs.org/clojure.core/defmulti
[20:07:42] Papierkorb: dminuoso: I'
[20:07:50] dminuoso: Papierkorb, but in FP you construct complexity by building functions together. So at each step you grow into a larger scope
[20:07:52] Papierkorb: dminuoso: I'm a low level guy. I want to know what happens there.
[20:07:57] dminuoso: Papierkorb, oh thats fair enough.
[20:08:11] Papierkorb: And yeah, that's what you do in imperative or OOP too.
[20:08:19] dminuoso: Papierkorb, Im not saying it's wrong, because thousands of software projects demonstrate that you can successfully write programs that way.
[20:08:30] michael3: has joined #ruby
[20:09:13] tcopeland: has joined #ruby
[20:09:15] dminuoso: Papierkorb, yup. I mean ultimately you compose by using routines - but a lot of these require understanding exact semantics on a low level (because everything could have someside-effect)
[20:09:30] jenrzzz: has joined #ruby
[20:09:49] havenwood: I always like the Perl term "subroutine"
[20:10:16] dminuoso: havenwood, yeah it's the one thing about the language they got right.
[20:11:33] dminuoso: Papierkorb, but I can respect your point of view. I was in that mindset for a long time. Personally I just found comfort in being able to zoom out and not look at details anymore when I wanted to.
[20:11:53] PaulCapestany: has joined #ruby
[20:11:59] RickHull: is one defining characteristic of subroutine that it's a closure, basically? it can refer to outside variables?
[20:12:29] Papierkorb: dminuoso: thing is, I've not come across a single realworld sample yet where this has been an issue. "State might change!" so then just don't? Developer discipline can't be directed by a type system.
[20:12:51] dminuoso: RickHull, its rather meant as a distinction from functions in the mathematical sense. (referential transparency, lack of side effects)
[20:13:08] RickHull: also, where people like to use lambdas, essentially giving a variable name to a block of code -- seems like a function, but it's a closure unlike a function?
[20:13:16] PaulCapestany: has joined #ruby
[20:13:58] dminuoso: RickHull, closure is about something else uhm...
[20:14:03] hutch34: has joined #ruby
[20:14:08] dminuoso: RickHull, a closure is a way of implementing free variables in lambda calculus.
[20:14:09] RickHull: closing over the environment
[20:14:16] RickHull: able to refer to outside variables
[20:14:17] dminuoso: but its only *one* method
[20:16:06] dminuoso: RickHull, a lambda is just an anonymous functoin
[20:16:19] RickHull: but often one assigns a variable name to it
[20:16:23] RickHull: so in *that* case
[20:16:30] dminuoso: RickHull, the point is just to treat it like a first class citizen.
[20:16:33] RickHull: what is the major distinction to a function?
[20:16:35] dminuoso: You can stuff it into an object and pass it around.
[20:16:43] dminuoso: RickHull, a function has referential transparency.
[20:16:46] dminuoso: and no side-effects.
[20:16:56] RickHull: s/function/ruby method/
[20:17:03] dminuoso: (nowadays the term "function" has been changed to "pure function" in programming, because imperativist have stolen the word "function"
[20:17:14] RickHull: i'm talking about preferring to assign a lambda to a local var in ruby, rather than def foo
[20:17:20] dminuoso: RickHull, for the purpose of this discussion I will not differentiate between method/function/proc/lambda/block.
[20:17:39] PaulCapestany: has joined #ruby
[20:17:40] RickHull: it's going to be tough to answer my question, I suspect xD
[20:17:46] dminuoso: You can trivially recover a proc from a block, or a proc from a method.
[20:17:57] dminuoso: or Method from a method I guess
[20:17:59] dminuoso: but thats close enough
[20:18:26] dminuoso: RickHull, the point is just: referential transparency and lack of side effects. output is only determinstically determined by parameters.
[20:18:36] conta2: has joined #ruby
[20:18:46] dminuoso: basically a simple way to test this is: if you can memoize a function call f(1) its pure.
[20:18:58] dminuoso: puts "foo" can very obviously not be memoized.
[20:19:09] RickHull: my question is tangential to the current discussion: "where a lambda is assigned to a local var foo, this is done in preference to `def foo` because the lambda is a closure, unlike the method foo"
[20:19:30] dminuoso: RickHull, oh no. This is because ruby shadows names.
[20:19:40] dminuoso: (Interestingly lambda calculus does this too)
[20:20:09] dminuoso: Or I guess they are tightly related.
[20:20:21] RickHull: I believe my statement is more or less correct, but perhaps there are other reasons to assign a lambda to a local var
[20:20:30] RickHull: perhaps one cannot def methods in the current scope?
[20:20:43] dminuoso: RickHull, a reason is to pass the function as an argument...
[20:20:49] dminuoso: for that to work it has to exist as an object.
[20:21:10] G66K: has joined #ruby
[20:21:14] RickHull: I have seem lambdas used, where `def` would work just as well, in one or more of your gists
[20:21:23] RickHull: and wasn't sure why
[20:21:33] G66K: hello all im new to ruby what is the best practice to learn it fast ?
[20:21:35] c-c_: I wonder why the named pipes always need a flush before they push the written out.
[20:21:44] dminuoso: RickHull, it makes reusability (due to their first class nature) a lot easier.
[20:21:53] dminuoso: RickHull, its a habit I picked up.
[20:22:02] RickHull: G66K: write it fast and execute it fast
[20:22:12] c-c_: G66K: pick a real world problem, write hour every day for 90 days, learn linux, editor and bash as well (ie. 3 hours a day)
[20:22:20] dminuoso: G66K, check out the topic. It contains some useful information, as well as a good book list.
[20:22:27] PaulCapestany: has joined #ruby
[20:22:50] c-c_: I thought IO.puts promises to feed a line feed...
[20:22:54] dminuoso: RickHull, this is also why I wrote defc to sneakily convert methods into lambdas..
[20:22:56] RickHull: c-c_: not sure on the details but it's a common C idiom
[20:23:09] RickHull: c-c_: incorrect, look at the need for $stdout.sync
[20:23:09] c-c_: ...wonder what is special about flush, whats it do that \n doesn't.
[20:23:11] G66K: RickHull: :D
[20:23:16] dminuoso: RickHull, (could have also used proc, but lambda has just subtly better semantics)
[20:23:29] c-c_: ACTION looks
[20:23:36] mozzarella: dminuoso: why not use method(:symbol)?
[20:23:41] G66K: c-c im already linux user since years i just came from different programming language and i want to learn something new
[20:23:47] G66K: dminuoso: thanks :)
[20:23:56] dminuoso: mozzarella, because you now have to bind it to something in order to call it.
[20:23:57] RickHull: c-c_: buffering output is a performance optimization -- you can get more throughput with controlling the flush behavior
[20:24:05] c-c_: G66K: what do you plan to use ruby for?
[20:24:15] hutch34: has joined #ruby
[20:24:15] RickHull: c-c_: or you can set to autoflush with more predictable behavior but generally less performance
[20:24:20] dminuoso: mozzarella, my defc trick has that amazing property that you can do: f = [1,2,3].include?; puts f.(10)
[20:24:34] c-c_: RickHull: yeah just wondering if I'm doing it wrong or if misunderstood something
[20:24:45] dminuoso: mozzarella, and you can still do [1,2,3].include? 10 if you wanted to
[20:25:05] RickHull: c-c_: my understanding is that it's a C/Unix idiom, like fsync on the filesystem
[20:25:10] G66K: c-c_: i found some free framework on the wild and i love them i was thinking to edit them to fit my need :)
[20:25:26] dminuoso: G66K, what languages do you come from?
[20:25:38] c-c_: G66K: web MVC things?
[20:25:52] G66K: dminuoso: perl php js python /etc
[20:25:54] dminuoso: mozzarella, also I like that very concise way of passing a function by simply naming it but not invoking it.
[20:26:11] G66K: c-c its network framework
[20:26:15] RickHull: c-c_: there may be some C APIs in which "\n" is significant and acts to flush, but in general "\n" is just another integer to C
[20:26:28] jrafanie: has joined #ruby
[20:26:53] dminuoso: G66K, Eloquent Ruby is probably the best pick for you.
[20:27:23] c-c_: hehe I want nonblocking sync...
[20:27:38] RickHull: async sync, sure buddy...
[20:28:06] c-c_: hm, I wonder if 'sync' implies ruby doesn't wait on it, or that the opened IO object is forced to block until done?
[20:28:15] dminuoso: c-c_, you can use IO#sync(bool) to change whether an IO is buffered or not.
[20:28:24] G66K: dminuoso: yes i figured that its quit simple and i love the syntax of it
[20:28:25] dminuoso: (The end might *still* be buffered)
[20:28:47] dminuoso: G66K, I think you misunderstood. Thats the name of a book (its listed in the books guide)
[20:28:50] Papierkorb: c-c_: Somethings' telling me you're looking for select(3), or `IO.select` in ruby
[20:29:38] c-c_: Papierkorb: yeah I'm using this kind of code https://gist.github.com/rickhull/757f0c1740c8e9f612f26c9f90c696e6#file-open_named_pipe-rb-L34
[20:30:09] zautomata: has joined #ruby
[20:30:20] c-c_: but if I want to write, always have to write: pipe_to_engine.puts msg_str; pipe_to_engine.flush;
[20:30:21] Papierkorb: I remember advising someone on how to refactor that code
[20:30:22] G66K: dminuoso: i saw that :) but for now i perfer lynda courses
[20:30:44] c-c_: - the flush gives me the "extra non-succinct line that looks non-dry"
[20:31:09] Papierkorb: Then write a method that does what you want c-c_?
[20:31:16] vipaca: has joined #ruby
[20:31:28] Papierkorb: You could dig out the big hammer and build a proxy object
[20:31:39] hutch34: has joined #ruby
[20:31:48] Papierkorb: Or .. maybe putting it into unbuffered mode is enough for your use-case
[20:32:04] c-c_: Papierkorb: yes, I'm wondering if I should attach a new method on the IO object that putsflushes. But not sure if I'm just DIW or flush is "for my own non-blocking good" or something.
[20:32:10] RickHull: you could put the pipe into sync mode
[20:32:22] RickHull: or if flush does block, you could spin a tiny thread for it
[20:32:40] c-c_: no I don't want to run the pipe in blocking mode as that stops the kernel io
[20:32:42] Papierkorb: c-c_: why not have a simple helper function in the class wrapping the pipe?
[20:33:05] Papierkorb: c-c_: That class can simply offer a #write (and/or other IO methods, or include IO itself), in which it does the write/flush
[20:33:11] Papierkorb: clean and simple
[20:33:12] c-c_: Papierkorb: class wrapping the pipe? what, do you think I'm some kind of a real programmer :)
[20:33:34] Papierkorb: Yeah I heard a few mins ago that you can't do that in OOP
[20:33:44] c-c_: ACTION is aiming for "just a couple of lines of monkey patching and OS/Kernel does the work"
[20:34:28] Papierkorb: you don't want to though. The program environment is a big sandbox. There are many playing in it, so a single one shouldn't mess it up for everyone else
[20:34:53] dminuoso: c-c_, I tried this too. With my macbook. Turns out that messing with one without having a clue what one does has a tendency to break things.
[20:35:11] c-c_: yeah I don't want to monkey patch everything, just the utilities I'm using and contain them in their own little process(es).
[20:35:20] RickHull: c-c_: what's the big concern with calling flush? that it blocks, or that it makes your code look ugly?
[20:35:22] dminuoso: After my "repair" the spacebar was no longer in its spot, but on my lap...
[20:35:29] tamouse__: has joined #ruby
[20:36:26] c-c_: I wondered earlier maybe I should just implement json messaging with them pipes and forget this simple stuff. But thats another 4 weeks more work.
[20:36:33] RickHull: as noted, you could just make a class SewagePipe that autoflushes and provides a cleaner API
[20:36:55] c-c_: BubblegumAndPAckingTapePipe
[20:37:15] RickHull: if it's bidirectional, call it a Bidet
[20:37:21] Papierkorb: c-c_: You can more or less rely on that JSON is always single-line, even if it contains multi-line strings. Hence, on the receiving end, a IO#gets may be sufficient
[20:37:45] c-c_: Papierkorb: what? YAML::to_json gives minimum 2 \n
[20:37:52] Papierkorb: Yeah, YAML ain't JSON
[20:38:02] cdg: has joined #ruby
[20:38:06] dminuoso: Wait.. thats not the meaning of that acronym, is it?
[20:38:07] c-c_: well, its supposed to be JSON subset
[20:38:15] Papierkorb: Yet Another Markup Language
[20:38:27] airdisa: has joined #ruby
[20:38:34] Papierkorb: Mh .. or was it YAML Ain't Markup Language
[20:38:52] cdg: has joined #ruby
[20:38:59] dminuoso: Yet another meta language.
[20:39:01] c-c_: thats another "more work incoming" I'm trying to solve by not doing. Maybe just escape \n to 'ø' or something
[20:39:16] dminuoso: ACTION wonders whether RickHull gets the joke
[20:39:41] larcara: has joined #ruby
[20:39:48] Papierkorb: pipe.puts(stuff.to_json) .. JSON.load(pipe.gets)
[20:40:04] dminuoso: RickHull, I should find some #yaml channel and ask how to declare a parametrically polymorphic attribute in my yaml file.
[20:40:27] Papierkorb: You must love XML
[20:40:34] dminuoso: Extra Meta Language!
[20:40:43] dminuoso: ML has done so much for the world.
[20:40:45] c-c_: >> require "yaml"; YAML::dump "Just Another String"
[20:40:51] Papierkorb: Extensive Markup Language
[20:41:02] Papierkorb: c-c_: I don't get why you think that YAML is JSON
[20:41:07] RickHull: ML will eventually provide DWIM-lang
[20:41:11] Papierkorb: YAML happens to parse JSON
[20:41:11] lupine: JSON is YAML though
[20:41:26] lupine: the reverse is not true
[20:41:28] Papierkorb: Still, saying "use JSON" and then using YAML doesn't make sense
[20:41:29] dminuoso: RickHull, that reminds me.. I so badly need to try out a dependently typed language like Idris or Coq.
[20:41:39] RickHull: >> require 'json'; { foo: :bar, baz: :quux }.to_json.split("\n").size
[20:41:40] ruby[bot]: RickHull: # => 1 (https://eval.in/899283)
[20:41:47] dminuoso: But those languages look so freaking intimidating next to haskell
[20:42:27] c-c_: well, I think of YAML as subset of JSON for some reason. Afaics YAML should have full JSON parsability
[20:42:39] Papierkorb: YAML.dump writes YAML
[20:43:01] larcara: has joined #ruby
[20:43:02] c-c_: Well if its 100% parsable JSON, what do you mean?
[20:43:04] tcopeland: has joined #ruby
[20:43:05] RickHull: c-c_: the partial equivalency seems to be confusing your attempts at using a JSON API
[20:43:12] RickHull: if you are concerned about newlines, that is
[20:43:36] c-c_: yeah maybe should use binary
[20:43:44] RickHull: just use the JSON lib
[20:43:52] RickHull: it emits the JSON on one line
[20:44:09] RickHull: it can *also* pretty print multiline JSON
[20:44:12] hutch34: has joined #ruby
[20:44:26] c-c_: long time ago, in a country far away, I remember testing 1.9 yaml and json libs and yaml libs were like 5x faster
[20:44:49] RickHull: have another look, I'd be curious :)
[20:45:23] RickHull: ACTION ponders the root of all evil
[20:45:33] Papierkorb: ... you're concerned about performance yet using a text-based representation?
[20:46:22] c-c_: I want ultra simple. Least possible LOC. Newbie readable if possible. And as fast as possible with as little work done inside ruby as possible.
[20:46:26] dminuoso: c-c_, https://msgpack.org/index.html
[20:46:28] dminuoso: screw human readable.
[20:46:37] Papierkorb: I already gave you a functioning snippet
[20:46:40] dminuoso: you want small and fast
[20:47:09] c-c_: yeah maybe I should just json
[20:47:24] c-c_: ACTION remembers that scary character from that old movie
[20:53:08] eckhardt: has joined #ruby
[20:56:52] RougeRR: has joined #ruby
[20:58:43] jenrzzz: has joined #ruby
[20:58:43] jenrzzz: has joined #ruby
[21:00:00] hutch34: has joined #ruby
[21:01:30] vipaca: has joined #ruby
[21:03:20] milardovich: has joined #ruby
[21:04:28] ap4y: has joined #ruby
[21:05:52] goyox86_: has joined #ruby
[21:06:54] c-c_: I decided to monkey patch more. Add the puts+flush method on the opened IO file handle (named pipe) -object.
[21:07:59] c-c_: >> self.define_singleton_method(:flputs) do |arf=nil|; puts "With flush " + arf.to_s; end; flputs 777
[21:08:21] RickHull: if you think your code might be used as a lib, it's better to not monkey patch core classes
[21:08:41] RickHull: you can just define methods on your objects, or wrap core classes and use the wrappers
[21:08:47] RickHull: or use refinements?
[21:09:37] RickHull: often, I think a big reason core classes get monkeypatched is the convenience of the built-in literal representations
[21:09:43] RickHull: e.g. String wrappers suck to use
[21:09:50] PaulCape_: has joined #ruby
[21:09:52] c-c_: Its an instance returned from the named_pipe method. Want to use it here, line 17. https://gist.github.com/csmr/c6f7d9e4da7313d60845e5996130beb6#file-open_named_pipe-rb-L6
[21:10:19] c-c_: (do not want to touch any classes, or even add any)
[21:10:41] tAn: has joined #ruby
[21:10:45] RickHull: you can def pipe_handle.whatever
[21:12:57] RickHull: once, I lobbied ljarvis for Slop#error, but then I realized I would want to define the exact behavior and this is probably a better API for that anyway: https://github.com/rickhull/device_input/blob/master/bin/evdump#L17
[21:15:33] wolfshappen: has joined #ruby
[21:15:42] zautomata: has joined #ruby
[21:16:39] PaulCapestany: has joined #ruby
[21:18:18] orbyt_: has joined #ruby
[21:19:00] vipaca: has joined #ruby
[21:19:03] hutch34: has joined #ruby
[21:19:20] c-c_: Well, this epic adventure got done. My dreams of having no longer to write "flush" has come true! https://gist.github.com/csmr/c6f7d9e4da7313d60845e5996130beb6/c850396f552ba387e7adf188d5d250c413be988e#file-open_named_pipe-rb-L17
[21:21:30] c-c_: Or maybe that should be just named_pipe.put! do |arg| ... ?
[21:25:11] eam: c-c_: if you don't want to flush, use syswrite
[21:26:36] c-c_: hm, would doing named_pipe.put do; #method body; end -actually define a method on the class? Where does that go?
[21:27:47] aech: has joined #ruby
[21:28:58] hutch34: has joined #ruby
[21:29:21] Devalo: has joined #ruby
[21:29:36] PaulCape_: has joined #ruby
[21:31:34] eckhardt: has joined #ruby
[21:31:54] imode: has joined #ruby
[21:32:23] c-c_: eam yeah, I wonder if you've already told me the diff between rb_io_write and rb_write_internal
[21:34:56] cagomez: has joined #ruby
[21:37:59] hutch34: has joined #ruby
[21:38:22] Devalo: has joined #ruby
[21:39:14] c-c_: looks like the linux kernel has a 4 kb buffer for the named pipes that ruby opens
[21:41:20] c-c_: Also, I don't get the deal with '\n'. Even syswrite needs that to actually ever write the message. Must be somewhere in the C.
[21:44:43] milardov_: has joined #ruby
[21:46:09] c-c_: Wow! Howcome I didn't use Marshal. It's one of the first things I ever used in ruby (for a rw-ormy object store)
[21:46:20] err_ok_: has joined #ruby
[21:46:20] chrisseaton_: has joined #ruby
[21:46:20] c-c_: Scratch yaml and json, marshal it is
[21:46:28] aurelien`: has joined #ruby
[21:46:36] JJonah_: has joined #ruby
[21:46:45] Lloyd__: has joined #ruby
[21:46:51] gmcintire_: has joined #ruby
[21:46:54] rann_: has joined #ruby
[21:47:00] hsiktas_: has joined #ruby
[21:47:02] RickHull: yaml and json are specifically meant for human readable text and interop
[21:47:08] auv5: has joined #ruby
[21:47:09] cstrahan_: has joined #ruby
[21:47:14] kireevco_: has joined #ruby
[21:47:20] RickHull: Marshal.load(Marshal.dump(some_obj_from_somewhere)) may fail
[21:47:21] boxrick1: has joined #ruby
[21:47:48] RickHull: er, that's not quite right
[21:47:58] rikai_: has joined #ruby
[21:48:07] contradictioned_: has joined #ruby
[21:48:22] RickHull: but if you have a dumped object from Tuesday, you may not be able to load it on Wednesday with v2 of the class
[21:48:32] adaedra: Are we still inventing complicated ways of doing simple things in here?
[21:48:51] harmaahy1je: has joined #ruby
[21:48:56] hutch34: has joined #ruby
[21:48:58] Rush: has joined #ruby
[21:49:02] tcopeland: has joined #ruby
[21:49:03] freezey: has joined #ruby
[21:49:12] cdg: has joined #ruby
[21:49:25] kaspergr1bbe: has joined #ruby
[21:49:40] RickHull: a JSON payload from last year and last year's version of the lib is not useless
[21:49:50] RickHull: a marshal dump probably is useless
[21:49:51] c-c_: Next I'm going to have to implement async request-reply handling
[21:49:55] jenrzzz: has joined #ruby
[21:49:56] jenrzzz: has joined #ruby
[21:51:07] RickHull: even tougher with marshal is when you release a new version and pipe the objdump to the old version
[21:51:40] RickHull: it's a form of tight coupling
[21:51:55] RickHull: and good luck reimplementing one side of the pipe in Crystal
[21:52:07] FifthWall: has joined #ruby
[21:52:14] knight-: has joined #ruby
[21:52:15] headius: has joined #ruby
[21:52:15] 7GHAA6UVM: has joined #ruby
[21:52:17] Zimsky: has joined #ruby
[21:52:18] tessi_zz: has joined #ruby
[21:52:19] c-c_: And FWIW, theres an ui process that asks for data from state server. State server returns 1) n*n map squares 2) objects with properties, but I don't see how the classes would get obsolete for a game. Of course between versions but not one game.
[21:52:27] inukshuk: has joined #ruby
[21:52:30] bazzy: has joined #ruby
[21:52:37] gsingh93: has joined #ruby
[21:52:41] sundhell_away: has joined #ruby
[21:52:41] woodruffw: has joined #ruby
[21:52:41] woodruffw: has joined #ruby
[21:52:43] EvilJStoker: has joined #ruby
[21:52:44] ablackack: has joined #ruby
[21:53:00] c-c_: (also, engine puts objects to the state server)
[21:53:01] rideh: has joined #ruby
[21:53:11] RickHull: i'm just pointing out potential pitfalls -- if you can avoid them, then all to the good
[21:53:13] c-c_: Its simple arrays or hashes.
[21:53:44] c-c_: Also, why would opening a pipe be diff in crystal?
[21:53:56] c-c_: - its the kernel that handles the pipe
[21:54:13] c-c_: ACTION concerned
[21:54:18] RickHull: are you planning to Marshal.dump a crystal object?
[21:54:27] RickHull: or Marshal.load a ruby object?
[21:54:40] c-c_: Well arrays and hashmaps
[21:54:50] c-c_: I see your point now
[21:56:15] c-c_: looks like its JSON for the POC
[21:56:30] c-c_: - besides this says JSON is faster than YAML https://gist.github.com/havenwood/4513627
[21:56:45] c-c_: hehe thanks for the brainshare RickHull
[21:57:11] c-c_: and channel! eam ada Papier dimi etc
[21:57:12] cosimo_: has joined #ruby
[21:57:13] beccamorgan: has joined #ruby
[21:57:15] wolfshappen: has joined #ruby
[21:58:30] kryptoz: has joined #ruby
[21:58:43] David_H__: has joined #ruby
[21:58:51] hutch34: has joined #ruby
[21:59:15] yqt: has joined #ruby
[22:00:03] RickHull: on the shoulders of giants we stand
[22:01:47] c-c_: adaedra: yes you thanks
[22:02:06] c-c_: ACTION is more like climbing on their shoes
[22:02:26] adaedra: c-c_: this is a ruby channel. We don't do ada in here.
[22:02:39] c-c_: ACTION would really like to do Ada sometimes
[22:02:42] adaedra: /nick rubyedra
[22:03:08] Kyle__: adaedra: There. I add a.
[22:03:56] Kyle__: add a. ada. It's pun. Not a very good one, but it's been that sort of day.
[22:04:27] bokayio: has joined #ruby
[22:04:51] iNs: has joined #ruby
[22:05:51] postmodern: has joined #ruby
[22:07:15] eam: 21:39 < c-c_> looks like the linux kernel has a 4 kb buffer for the named pipes that ruby opens
[22:07:56] Tagami[m]: has joined #ruby
[22:08:14] eam: c-c-zZ: not 4kb necessarily, though 4k is still relevant to I think something around atomic read/writes
[22:08:30] eam: it's been 64k for a while now
[22:09:06] eam: and I think it's configurable
[22:09:10] tcopeland: has joined #ruby
[22:09:33] eam: but the internal buffer in a pipe() is different from the stdio buffering which happens in puts/write vs syswrite
[22:09:46] eam: stdio buffering happens in an in-process buffer
[22:09:50] impermanence: has joined #ruby
[22:10:32] c-c-zZ: hm. yeah that was kinda brainfart from me - what I was trying to communicate, is the named pipe seems to flush/sync, once ~4000 chars have been written to it. I didn't realize I don't even know how many bytes ruby utf char is (not constant)
[22:11:38] eam: the mechanism is a bit different than what you're imagining, I think
[22:11:44] minimalism: has joined #ruby
[22:11:59] c-c-zZ: yeah, that was with IO#puts so it might be ruby buffer as well
[22:12:09] eam: the stdio buffer is a chunk of memory in the process, and when you call puts() it just copies memory to that buffer - no write, no system/linux interaction at all
[22:12:28] eam: #flush forces that buffer into a syswrite
[22:13:08] eam: there's a memory buffer in a pipe() pair, however there's no need to flush it because as soon as there's a single byte in it, a select() on the other end will return ready
[22:13:42] eam: the pipe buffer is mostly relevant to how much the writer can write before it blocks on needing hte reader to read -- but it's not really relevant to flushing
[22:14:19] eam: (it can't be flushed)
[22:14:34] tristanp: has joined #ruby
[22:14:48] RickHull: does flush block? and if so, is it nontrivial in that respect?
[22:14:52] blackmesa: has joined #ruby
[22:15:08] eam: yes, flush performs a blocking write
[22:15:14] apofis: has joined #ruby
[22:15:16] hutch34: has joined #ruby
[22:15:31] eam: well, it performs a write
[22:15:38] RickHull: in C, I imagine you check for an error code. in ruby as well?
[22:15:47] eam: if the descriptor is nonblocking I imagine it might return without flushing? I'm not sure
[22:16:02] eam: I suspect mixing nonblocking i/o with stdio is a recipe for disaster
[22:16:08] c-c-zZ: hehe I try not to check
[22:16:21] RickHull: it's possible ruby throws an exception
[22:16:25] eam: I suspect some of the methods do not check error codes, and some raise
[22:16:36] RickHull: s/throw/raise/ :)
[22:17:08] eam: puts does NOT raise
[22:17:09] eam: ruby -e'f = open "/dev/full", "w"; f.puts "hi"'
[22:17:22] eam: contrast with ruby -e'f = open "/dev/full", "w"; f.syswrite "hi"'
[22:17:56] c-c-zZ: yep, it just makes the thing sit there and lets you wonder where the hell did it stop
[22:19:03] eam: I believe the way the stdio layer (which puts uses) works is that it masks the error and copies the buffer to the stdio buffer
[22:19:12] eam: and once that's full, it'll raise
[22:19:33] eam: but you don't really have good locality between when writes started to fail, and when the raise eventually (if ever) occurs
[22:19:48] eam: ruby can exit with a dirty buffer, without passing anything up
[22:19:58] eam: generally, if you care, avoid stdio
[22:20:33] eam: especially anything doing ipc, sockets, etc, you don't want that stdio layer between you and your reads and writes
[22:21:34] c-c-zZ: I use it for this ui process atm. I guess the raw input will make stdio go away.
[22:21:48] c-c-zZ: (from curses)
[22:22:47] c-c-zZ: ok, time for theta and delta brainwave cycles
[22:24:14] Tristan-Speccy: has joined #ruby
[22:25:07] hutch34: has joined #ruby
[22:25:59] pilne: has joined #ruby
[22:26:34] David_H_Smith: has joined #ruby
[22:27:15] enterprisey: has joined #ruby
[22:27:55] elphe: has joined #ruby
[22:32:00] knight33: has joined #ruby
[22:32:46] aviraldg: has joined #ruby
[22:32:46] Hanma[m]: has joined #ruby
[22:32:46] dtcristo: has joined #ruby
[22:32:46] jonjits[m]: has joined #ruby
[22:32:46] yana[m]: has joined #ruby
[22:32:47] M107262[m]: has joined #ruby
[22:32:47] lasenna[m]: has joined #ruby
[22:32:47] erciccione_[m]: has joined #ruby
[22:32:47] Giphy[m]: has joined #ruby
[22:32:47] haylon: has joined #ruby
[22:32:47] astronavt[m]: has joined #ruby
[22:32:47] velu_aon[m]: has joined #ruby
[22:32:47] watzon: has joined #ruby
[22:32:47] torarne: has joined #ruby
[22:32:47] zalipuha[m]: has joined #ruby
[22:32:48] dman[m]: has joined #ruby
[22:32:48] turt2live: has joined #ruby
[22:32:48] KevinMGranger: has joined #ruby
[22:32:53] itmerc[m]: has joined #ruby
[22:32:54] aagdbl[m]: has joined #ruby
[22:32:54] gokul_mr[m]: has joined #ruby
[22:32:54] Matt[m]1: has joined #ruby
[22:32:55] kua[m]: has joined #ruby
[22:33:38] tristanp: has joined #ruby
[22:35:02] hutch34: has joined #ruby
[22:39:41] goyox86: has joined #ruby
[22:40:17] mim1k: has joined #ruby
[22:43:22] dviola: has joined #ruby
[22:43:47] hutch34: has joined #ruby
[22:45:59] kitsunenokenja: has joined #ruby
[22:46:44] knight33_: has joined #ruby
[22:51:28] xco: what will be the simplest way to factorise this? 'him@gmail.com, me@gmail.com, us@gmail.com'
[22:51:44] xco: it’s one string with emails separated by commas
[22:51:50] xco: i want to avoid repeating @gmail.com
[22:52:20] xco: i’m trying with ['him', 'me', 'us'].each do |x| … but it’s getting too long and i don’t want that
[22:54:01] kinduff: xco: whats the input output you're expecting?
[22:54:55] RickHull: >> %w{him me us}.map { |s| [s. 'gmail.com'].join('@') }
[22:54:56] ruby[bot]: RickHull: # => /tmp/execpad-5e653df3c8b9/source-5e653df3c8b9:2: syntax error, unexpected tSTRING_BEG, expecting '(' ...check link for more (https://eval.in/899317)
[22:55:09] RickHull: >> %w{him me us}.map { |s| [s, 'gmail.com'].join('@') } # gah!
[22:55:10] ruby[bot]: RickHull: # => ["him@gmail.com", "me@gmail.com", "us@gmail.com"] (https://eval.in/899318)
[22:56:18] xco: RickHull: oh that’s nice! thanks!
[22:56:27] RickHull: >> %w{him me us}.map { |s| [s, 'gmail.com'].join('@') }.join(', ') # even
[22:56:28] ruby[bot]: RickHull: # => "him@gmail.com, me@gmail.com, us@gmail.com" (https://eval.in/899319)
[22:56:42] moei: has joined #ruby
[22:57:39] xco: thank you :)
[22:58:24] mtkd: has joined #ruby
[23:02:58] jenrzzz_: has joined #ruby
[23:03:23] hutch34: has joined #ruby
[23:04:06] Exhiled: has joined #ruby
[23:04:13] baweaver: RickHull: Interpolation?
[23:04:37] baweaver: >> %w[him me us].map { |s| "#{s}@gmail.com" }
[23:04:38] ruby[bot]: baweaver: # => ["him@gmail.com", "me@gmail.com", "us@gmail.com"] (https://eval.in/899320)
[23:05:48] RickHull: yeah -- sometimes it's nice to make the structure explicit, depending on the context
[23:06:06] xco: baweaver: even cooler! :) i like both methods
[23:06:59] thinkpad: has joined #ruby
[23:09:18] RickHull: >> %w(him me us).map { |s| "%s@gmail.com" % s } # percent ess erryday ;)
[23:09:19] ruby[bot]: RickHull: # => ["him@gmail.com", "me@gmail.com", "us@gmail.com"] (https://eval.in/899321)
[23:10:06] bougyman: RickHull: rubocop hates that.
[23:10:29] RickHull: but muh python
[23:10:36] knight33: has joined #ruby
[23:10:45] RickHull: also, rubocop's attitude can be... adjusted
[23:11:22] baweaver: >> %w(him me us).zip(['@gmail.com'].cycle).map(&:join) # Then tell Rubocop to zip it
[23:11:23] ruby[bot]: baweaver: # => ["him@gmail.com", "me@gmail.com", "us@gmail.com"] (https://eval.in/899322)
[23:12:27] RickHull: huh, Enumerable#cycle, cool
[23:13:21] hutch34: has joined #ruby
[23:15:13] goyox86: has joined #ruby
[23:15:18] baweaver: >> 'him me us'.gsub(/\w+/) { |w| "#{w}@gmail.com" }
[23:15:19] ruby[bot]: baweaver: # => "him@gmail.com me@gmail.com us@gmail.com" (https://eval.in/899323)
[23:18:05] baweaver: Probably a ton of different ways to do it really
[23:19:14] RickHull: >> 'him me us'.gsub(/\s+/, '@gmail.com ')
[23:19:15] ruby[bot]: RickHull: # => "him@gmail.com me@gmail.com us" (https://eval.in/899324)
[23:19:56] baweaver: I kinda like the block form of that one more
[23:20:15] RickHull: besides correctness? ;)
[23:21:10] RickHull: >> 'him me us'.gsub(/\s+/, '@gmail.com ') + '@gmail.com' # for good measure
[23:21:11] ruby[bot]: RickHull: # => "him@gmail.com me@gmail.com us@gmail.com" (https://eval.in/899325)
[23:22:07] charliesome: has joined #ruby
[23:22:23] RickHull: i bet you there is a simple scan impl but I can never remember quite how scan works
[23:23:12] hutch34: has joined #ruby
[23:26:17] ogres: has joined #ruby
[23:28:27] cdg: has joined #ruby
[23:32:14] eckhardt: has joined #ruby
[23:33:10] hutch34: has joined #ruby
[23:40:02] nehero: has joined #ruby
[23:40:50] nehero: Hola. Can anyone tell me why just a raw string ("\xAE\xA4=\x01\xC1\x9B\xF69\xFB\x9B\xCAt\xCD\x808\x91\x85\x15\x84-\x17\xC3\f\x14lO\\\xAA\x13\xD1\xE2,") would have a bytesize of 32, but when I access it through Rails.application.secrets.encryption_key it would have a bytesize of 49?
[23:41:30] RickHull: I would compare the raw bytes from Rails to the original string
[23:42:16] apeiros: if it was 99 instead of 49, I'd go with "wrong quotes"
[23:42:25] apeiros: but 49? yeah, compare :)
[23:42:32] nehero: How do you mean? When I do "the above string".bytesize i get 32, but when i do Rails.application.secrets.encryption_key.bytesize i get 49
[23:42:46] RickHull: so look at e.g. the first 5 bytes of each
[23:42:49] RickHull: are they identical?
[23:43:05] hutch34: has joined #ruby
[23:43:19] apeiros: .bytes to not be confused by inspect & encodings
[23:43:52] nehero: Ah gotcha
[23:43:54] paulr: has joined #ruby
[23:43:57] galeido: has joined #ruby
[23:44:00] darthThorik: has joined #ruby
[23:44:00] nehero: The first 5 are indeed different
[23:44:26] nehero: could there be a problem with encoding?
[23:44:50] ggherdov: has joined #ruby
[23:45:38] RickHull: how does the original string get into rails' clutches?
[23:45:55] nehero: via config/secrets.yml
[23:46:07] nehero: I have it stored under development -> encryption_key
[23:46:11] nehero: then stored in double quotes
[23:46:49] RickHull: try reading it from Yaml on your own
[23:47:05] RickHull: and then keep reverse engineering the rails process
[23:47:51] apeiros: are you actually looking at the right file?
[23:48:06] apeiros: as in: if you change the value in the file, does the (wrong) value change too?
[23:48:15] uneeb: has joined #ruby
[23:49:15] charliesome: has joined #ruby
[23:49:19] cadillac_: has joined #ruby
[23:49:52] Exhiled: has joined #ruby
[23:50:34] RickHull: also, try putting e.g. "\x00\x01\x02" in there
[23:51:03] aroaminggeek: has joined #ruby
[23:51:38] nehero: Yeah even loading the file manually via yaml i get 49 in bytesize :(
[23:52:01] nehero: Another weird observation is that when I dump the raw string in rails.console It spits it back nice
[23:52:16] nehero: but when i do the Rails.application.secret.encryption_key it spits out weird UTF-8 chars
[23:52:56] hutch34: has joined #ruby
[23:53:35] cdg: has joined #ruby
[23:54:01] mikecmpbll: has joined #ruby
[23:56:54] apeiros: nehero: uh, how do you write it in the yaml?
[23:56:58] cdg: has joined #ruby
[23:58:01] nehero: encryption_key: "\xAE\xA4=\x01\xC1\x9B\xF69\xFB\x9B\xCAt\xCD\x808\x91\x85\x15\x84-\x17\xC3\f\x14lO\\\xAA\x13\xD1\xE2,"
[23:58:29] apeiros: yeah, uh, that's not how you write binary data in yaml :)
[23:58:44] nehero: hahahahah here we go
[23:58:48] jenrzzz: has joined #ruby
[23:58:48] jenrzzz: has joined #ruby
[23:58:56] apeiros: try your_string.to_yaml
[23:59:01] apeiros: that gives you a save representation