« Back to channel list

#ruby - 30 May 2018

« Back 1 day Forward 1 day »
[00:00:45] jrabe: has joined #ruby
[00:04:56] ckrailo_: has joined #ruby
[00:05:28] justinweiss_: has joined #ruby
[00:05:28] jimeh_: has joined #ruby
[00:05:28] sinabs: has joined #ruby
[00:05:31] jnix_: has joined #ruby
[00:05:32] quoboo: has joined #ruby
[00:05:33] rflot_: has joined #ruby
[00:05:34] stephenh_: has joined #ruby
[00:05:36] knowtheory_: has joined #ruby
[00:05:39] caw________: has joined #ruby
[00:05:39] mitsuhiko_: has joined #ruby
[00:05:41] pwillard_: has joined #ruby
[00:05:41] KnownSyntax_: has joined #ruby
[00:05:43] cstrahan_: has joined #ruby
[00:05:43] auv5: has joined #ruby
[00:05:45] untitaker_: has joined #ruby
[00:05:46] rfv_: has joined #ruby
[00:05:51] kireevco_: has joined #ruby
[00:05:55] Brak____________: has joined #ruby
[00:06:03] daxroc1: has joined #ruby
[00:06:04] boxrick1: has joined #ruby
[00:06:05] darthThorik: has joined #ruby
[00:06:07] Guest74533_: has joined #ruby
[00:06:31] wget_: has joined #ruby
[00:08:25] rupam123456: has joined #ruby
[00:10:42] naquad: has joined #ruby
[00:11:06] alfiemax: has joined #ruby
[00:11:13] Seich: has joined #ruby
[00:11:23] edwardly: has joined #ruby
[00:11:41] zleap: has joined #ruby
[00:11:44] curio: has joined #ruby
[00:12:08] sspreitz: has joined #ruby
[00:15:00] jsrn: has joined #ruby
[00:15:09] clampy: has joined #ruby
[00:15:21] swein: has joined #ruby
[00:15:44] baweaver: "Ruby is inferior because it doesn't have X feature from Y language I love"
[00:15:48] baweaver: Ah, a tale as old as time.
[00:16:04] Apocalypse: has joined #ruby
[00:16:06] karapetyan: has joined #ruby
[00:16:11] xtsee: has joined #ruby
[00:18:38] p0p0pr37_: has joined #ruby
[00:22:01] ramfjord: has joined #ruby
[00:30:02] cschneid: has joined #ruby
[00:32:33] lxsameer: has joined #ruby
[00:37:37] Apocalypse: has joined #ruby
[00:39:47] edwardly: has joined #ruby
[00:39:53] Kilo`byte: has joined #ruby
[00:39:54] darix: has joined #ruby
[00:39:55] elomatreb: has joined #ruby
[00:39:58] Danielss89: has joined #ruby
[00:40:03] reu: has joined #ruby
[00:40:06] Miron: has joined #ruby
[00:40:18] tjbp: has joined #ruby
[00:42:33] rfoust: has joined #ruby
[00:44:33] pocketprotector-: has joined #ruby
[00:45:37] plexigras: has joined #ruby
[00:46:00] sanscoeur: has joined #ruby
[00:47:08] orbyt_: has joined #ruby
[00:49:29] nertzy: has joined #ruby
[00:50:08] alfiemax: has joined #ruby
[00:50:19] p0p0pr37_: has joined #ruby
[00:50:19] p0p0pr37_: has joined #ruby
[00:52:44] cyberg: has joined #ruby
[00:53:49] cyberg: has joined #ruby
[01:04:52] intheclouddan: has joined #ruby
[01:05:01] beefjoe70: has joined #ruby
[01:06:46] karapetyan: has joined #ruby
[01:07:31] cschneid: has joined #ruby
[01:08:22] rkazak: has joined #ruby
[01:14:18] gizmore|2: has joined #ruby
[01:16:08] arashb: has joined #ruby
[01:19:13] eelster: has joined #ruby
[01:20:31] cschneid: has joined #ruby
[01:21:35] alfiemax: has joined #ruby
[01:21:56] Guest21588: has joined #ruby
[01:27:07] Jameser: has joined #ruby
[01:29:45] Tempesta: has joined #ruby
[01:31:06] cschneid: has joined #ruby
[01:31:08] jsrn: has joined #ruby
[01:32:59] tjbp: has joined #ruby
[01:34:46] arashb: has joined #ruby
[01:36:04] Jameser: has joined #ruby
[01:39:39] luna_x[m]: has joined #ruby
[01:39:39] aviraldg: has joined #ruby
[01:39:40] torarne: has joined #ruby
[01:39:40] Hanma[m]: has joined #ruby
[01:39:40] redlegion[m]: has joined #ruby
[01:39:40] haylon_: has joined #ruby
[01:39:40] Giphy[m]: has joined #ruby
[01:39:40] turt2live: has joined #ruby
[01:39:41] KevinMGranger: has joined #ruby
[01:39:46] nullmoose[m]: has joined #ruby
[01:39:47] failednoose[m]: has joined #ruby
[01:39:47] velu_aon[m]: has joined #ruby
[01:39:47] iceskins[m]: has joined #ruby
[01:39:47] zalipuha[m]: has joined #ruby
[01:43:18] jonjits[m]: has joined #ruby
[01:43:51] alfiemax: has joined #ruby
[01:44:04] clampy: has joined #ruby
[01:44:23] swein: has joined #ruby
[01:45:12] xtsee: has joined #ruby
[01:46:36] Asher: has joined #ruby
[02:01:50] Guest21588: has joined #ruby
[02:05:00] karapetyan: has joined #ruby
[02:09:58] moei: has joined #ruby
[02:11:24] Inoperable: has joined #ruby
[02:14:26] alfiemax: has joined #ruby
[02:17:04] Guest21588: has joined #ruby
[02:18:12] memo1: has joined #ruby
[02:19:18] cyberg: has joined #ruby
[02:21:37] iMadper: has joined #ruby
[02:32:42] arashb: has joined #ruby
[02:33:23] \void: has joined #ruby
[02:35:21] cschneid: has joined #ruby
[02:48:26] cschneid: has joined #ruby
[02:48:46] donofrio: has joined #ruby
[02:52:28] Jameser`: has joined #ruby
[02:56:47] Guest21588: has joined #ruby
[02:59:16] arashb: has joined #ruby
[03:00:19] cadillac_: has joined #ruby
[03:03:48] d^sh: has joined #ruby
[03:04:59] csk157: has joined #ruby
[03:05:30] cschneid: has joined #ruby
[03:08:19] sauvin: has joined #ruby
[03:10:24] arashb: has joined #ruby
[03:12:50] braincrash: has joined #ruby
[03:12:51] t0xik: has joined #ruby
[03:23:12] cschneid: has joined #ruby
[03:25:22] bmurt: has joined #ruby
[03:27:43] houhoulis: has joined #ruby
[03:33:24] chouhoulis: has joined #ruby
[03:37:06] Guest21588: has joined #ruby
[03:40:57] cschneid: has joined #ruby
[03:42:47] tdy: has joined #ruby
[03:49:33] guacamole: has joined #ruby
[03:51:59] Guest21588: has joined #ruby
[03:53:52] alfiemax: has joined #ruby
[03:54:13] cschneid: has joined #ruby
[03:54:58] alfiemax: has joined #ruby
[03:58:04] bmurt: has joined #ruby
[04:00:46] gix-: has joined #ruby
[04:10:49] cschneid: has joined #ruby
[04:16:07] apeiros: has joined #ruby
[04:17:12] thapakazi: has joined #ruby
[04:20:45] Xiti: has joined #ruby
[04:34:02] p0p0pr37_: has joined #ruby
[04:34:02] p0p0pr37_: has joined #ruby
[04:34:45] thapakazi_: has joined #ruby
[04:36:58] Guest21588: has joined #ruby
[04:37:37] tfitts: has joined #ruby
[04:40:54] cschneid: has joined #ruby
[04:44:04] Guest21588: has joined #ruby
[04:47:21] emilford: has joined #ruby
[04:51:12] Ryzokuken: has joined #ruby
[04:51:59] Guest21588: has joined #ruby
[04:52:12] alfiemax: has joined #ruby
[04:57:28] aufi: has joined #ruby
[05:05:04] apeiros: has joined #ruby
[05:05:22] \void: has joined #ruby
[05:06:32] ramfjord: has joined #ruby
[05:07:16] Guest21588: has joined #ruby
[05:11:34] anisha__: has joined #ruby
[05:13:22] pabs: has joined #ruby
[05:17:11] arashb: has joined #ruby
[05:17:20] Guest21588: has joined #ruby
[05:17:34] kapil___: has joined #ruby
[05:17:55] kapil___: when i do `.to_json` validto value is lost.
[05:18:41] phenom: has joined #ruby
[05:20:16] tcopeland: has joined #ruby
[05:20:39] NightMonkey: has joined #ruby
[05:23:25] Radar: kapil___: You've gotta start providing context for your questions.
[05:23:34] Radar: kapil___: You come in here and say one tiny little thing and we don't know what to do to help you.
[05:23:43] Radar: What is validto? What is to_json? Where are you calling it?
[05:23:47] Radar: Provide some code.
[05:24:29] kapil___: i am using rails. it has a model Tax. its has three column.
[05:24:57] kapil___: k = Tax.constantize.column_defaults
[05:25:22] kapil___: validto is datetime value. its default value is "Infiniy"
[05:26:37] kapil___: (i figure out that its class is Float in ruby)
[05:27:49] kapil___: when ever i try to convert above hash to json it not understand "validto" value properly.
[05:28:56] emilford: has joined #ruby
[05:30:41] byte00: has joined #ruby
[05:31:23] vinothvkr: has joined #ruby
[05:31:57] Guest21588: has joined #ruby
[05:33:12] wget: has joined #ruby
[05:33:12] wget: has joined #ruby
[05:35:12] Autolycus: has joined #ruby
[05:38:24] emilford: has joined #ruby
[05:38:50] bijan_: has joined #ruby
[05:41:11] karapetyan: has joined #ruby
[05:41:29] aupadhye: has joined #ruby
[05:41:36] Asher: has joined #ruby
[05:47:36] cschneid: has joined #ruby
[05:48:01] snapcase: has joined #ruby
[05:48:39] bijan_: has joined #ruby
[05:52:03] baweaver: >> y = 5; vs = [1,2,3].map { |x; y| y = 2; x + y }; [vs, y]
[05:52:04] ruby[bot]: baweaver: # => [[3, 4, 5], 5] (https://eval.in/1012260)
[05:53:20] emilford: has joined #ruby
[05:54:40] arashb: has joined #ruby
[05:56:12] cadillac_: has joined #ruby
[05:56:40] ByronJohnson: has joined #ruby
[05:56:48] suukim: has joined #ruby
[05:57:55] dminuoso: that semicolon doing there
[05:57:57] reber: has joined #ruby
[06:02:53] emilford: has joined #ruby
[06:09:50] emilford: has joined #ruby
[06:12:52] conta: has joined #ruby
[06:14:06] Mutsuhito: has joined #ruby
[06:14:06] Mutsuhito: has joined #ruby
[06:21:47] Guest21588: has joined #ruby
[06:31:27] p0p0pr37_: has joined #ruby
[06:31:27] p0p0pr37_: has joined #ruby
[06:35:32] Radar: Does anyone know an SFTP Server library for Ruby?
[06:35:40] Radar: Yeah, server not client.
[06:38:31] anisha__: has joined #ruby
[06:40:52] arashb: has joined #ruby
[06:41:59] quoboo: has joined #ruby
[06:42:17] cschneid: has joined #ruby
[06:45:20] clemens3_: has joined #ruby
[06:52:09] sanscoeur: has joined #ruby
[06:54:52] ciscam: has joined #ruby
[06:55:11] emilford: has joined #ruby
[06:56:06] dionysus69: has joined #ruby
[07:02:07] Guest21588: has joined #ruby
[07:03:49] saTchymoto: has joined #ruby
[07:03:55] csk157: has joined #ruby
[07:07:18] bijan_: has joined #ruby
[07:07:29] armyriad: has joined #ruby
[07:09:47] yohji: has joined #ruby
[07:11:00] CcjDoK: has joined #ruby
[07:11:31] bijan_: has joined #ruby
[07:14:03] anisha: has joined #ruby
[07:14:19] phaul: has joined #ruby
[07:14:36] clemens3: has joined #ruby
[07:14:52] biberu: has joined #ruby
[07:15:07] sysvalve: has joined #ruby
[07:15:54] emilford: has joined #ruby
[07:16:21] arashb: has joined #ruby
[07:18:37] TomyWork: has joined #ruby
[07:20:15] amar: has joined #ruby
[07:22:36] chussenot: has joined #ruby
[07:23:56] bijan_: has joined #ruby
[07:28:29] aufi: has joined #ruby
[07:32:56] bijan_: has joined #ruby
[07:33:09] emilford: has joined #ruby
[07:34:52] clemens3: has joined #ruby
[07:37:07] bijan__: has joined #ruby
[07:41:34] bijan_: has joined #ruby
[07:41:50] Guest21588: has joined #ruby
[07:45:06] cschneid: has joined #ruby
[07:47:05] emilford: has joined #ruby
[07:47:13] plexigras: has joined #ruby
[07:47:16] Mia: has joined #ruby
[07:47:50] Guest21588: has joined #ruby
[07:50:11] bijan_: has joined #ruby
[07:51:00] arashb: has joined #ruby
[07:54:18] bijan__: has joined #ruby
[07:58:37] mikecmpbll: has joined #ruby
[07:58:51] chussenot: has joined #ruby
[08:01:05] Azure: has joined #ruby
[08:01:58] conta: has joined #ruby
[08:06:29] schleppel: has joined #ruby
[08:07:29] tAn: has joined #ruby
[08:09:34] amar: has joined #ruby
[08:13:07] Cybergeek: has joined #ruby
[08:14:04] CcjDoK: has joined #ruby
[08:15:51] vondruch: has joined #ruby
[08:16:49] amar: has joined #ruby
[08:20:52] armyriad: has joined #ruby
[08:23:43] phaul: has joined #ruby
[08:24:27] cschneid: has joined #ruby
[08:25:32] arashb: has joined #ruby
[08:26:30] ellcs: has joined #ruby
[08:28:45] vondruch: has joined #ruby
[08:31:16] emilford: has joined #ruby
[08:35:21] saTchymoto: has joined #ruby
[08:37:25] ciscam: has joined #ruby
[08:38:56] guille-moe: has joined #ruby
[08:39:59] OS-35301: has joined #ruby
[08:42:53] vondruch: has left #ruby: ()
[08:54:08] vondruch: has joined #ruby
[08:54:46] ellcs: has joined #ruby
[08:56:32] anisha: has joined #ruby
[08:59:41] cschneid: has joined #ruby
[08:59:42] Beams: has joined #ruby
[09:00:21] emilford: has joined #ruby
[09:02:07] karapetyan: has joined #ruby
[09:05:43] emilford: has joined #ruby
[09:06:12] ramfjord: has joined #ruby
[09:08:03] yokel: has joined #ruby
[09:09:13] vondruch: has joined #ruby
[09:10:22] alfiemax_: has joined #ruby
[09:11:32] venmx: has joined #ruby
[09:11:59] SURAJIT: has joined #ruby
[09:13:17] SURAJIT: has joined #ruby
[09:13:43] vondruch: has joined #ruby
[09:15:13] SURAJIT: has joined #ruby
[09:16:49] arashb: has joined #ruby
[09:18:31] karapetyan: has joined #ruby
[09:21:53] sudorobo: has joined #ruby
[09:21:53] sudorobo: has joined #ruby
[09:21:58] emilford: has joined #ruby
[09:24:33] guille-moe: has joined #ruby
[09:25:31] amar: has joined #ruby
[09:25:50] amar: has joined #ruby
[09:26:53] OS-35301: has joined #ruby
[09:27:32] saTchymoto: has joined #ruby
[09:28:29] yohji: has joined #ruby
[09:34:05] cschneid: has joined #ruby
[09:36:25] amar: has joined #ruby
[09:36:53] anisha: has joined #ruby
[09:39:08] tvw: has joined #ruby
[09:39:37] guille-moe: has joined #ruby
[09:40:35] roshanavand: has joined #ruby
[09:42:48] emilford: has joined #ruby
[09:42:54] conta: has joined #ruby
[09:48:43] guille-moe: has joined #ruby
[09:52:12] emilford: has joined #ruby
[09:57:51] ur5us: has joined #ruby
[09:58:46] arashb: has joined #ruby
[10:00:29] emilford: has joined #ruby
[10:05:02] claw: anybody knows how i can prevent Rack::Defalte from deflating when send_file is used ?
[10:05:58] claw: i am using " send_file file " which causes problems with large files
[10:06:15] claw: because Content-Encoding:"gzip" is used
[10:08:09] nowhere_man: has joined #ruby
[10:08:19] emilford: has joined #ruby
[10:08:45] karapetyan: has joined #ruby
[10:09:32] claw: whoops im in #ruby - talking about sinatra
[10:09:34] gr33n7007h: has joined #ruby
[10:10:10] cschneid: has joined #ruby
[10:13:52] rikkipitt: has joined #ruby
[10:18:55] conta: has joined #ruby
[10:22:46] jamesaxl: has joined #ruby
[10:23:00] emilford: has joined #ruby
[10:25:15] bascht: has joined #ruby
[10:28:01] ciscam: has joined #ruby
[10:30:17] alfiemax: has joined #ruby
[10:36:03] troulouliou_div2: has joined #ruby
[10:38:22] aufi: has joined #ruby
[10:40:11] asio: has joined #ruby
[10:41:10] anisha: has joined #ruby
[10:45:38] cschneid: has joined #ruby
[10:47:43] reber: has joined #ruby
[10:49:08] emilford: has joined #ruby
[10:49:36] Jameser: has joined #ruby
[10:54:16] arashb: has joined #ruby
[10:55:49] emilford: has joined #ruby
[11:04:26] beauby: has joined #ruby
[11:06:02] ramfjord: has joined #ruby
[11:08:34] OS-35301: has joined #ruby
[11:16:43] AJA4350: has joined #ruby
[11:18:11] karapetyan: has joined #ruby
[11:18:35] amatas: has joined #ruby
[11:22:31] emilford: has joined #ruby
[11:28:03] cschneid: has joined #ruby
[11:30:11] banisterfiend: has joined #ruby
[11:31:13] karapetyan: has joined #ruby
[11:32:10] ldnunes: has joined #ruby
[11:35:59] reber: has left #ruby: ("Leaving")
[11:39:24] lypsis: has joined #ruby
[11:40:28] Cavallari: has joined #ruby
[11:46:25] BTRE: has joined #ruby
[11:48:27] amatas: has joined #ruby
[11:49:09] lypsis: has joined #ruby
[11:50:09] shinnya: has joined #ruby
[11:52:30] vondruch_: has joined #ruby
[11:53:34] chussenot: has joined #ruby
[11:58:08] eelster: has joined #ruby
[11:59:29] arashb: has joined #ruby
[12:01:24] alfiemax: has joined #ruby
[12:02:25] banisterfiend: has joined #ruby
[12:02:29] amar: has joined #ruby
[12:05:37] synthroid: has joined #ruby
[12:07:44] cschneid: has joined #ruby
[12:10:02] dreamthese: has joined #ruby
[12:10:37] amatas: has joined #ruby
[12:12:14] amar: has joined #ruby
[12:12:34] banisterfiend: has joined #ruby
[12:13:15] beefjoe70: has joined #ruby
[12:18:32] banisterfiend: has joined #ruby
[12:26:07] banisterfiend: has joined #ruby
[12:30:17] tcopeland: has joined #ruby
[12:41:23] cyberg: has joined #ruby
[12:42:04] cyberg: has joined #ruby
[12:44:09] dminuoso: Is there some class inheritance viewer?
[12:44:25] dminuoso: Or do I have to spend my time writing one? :|
[12:47:37] mjolnird: has joined #ruby
[12:48:00] lupine: the documentation generator kinda works
[12:48:08] chouhoulis: has joined #ruby
[12:54:11] vondruch: has joined #ruby
[12:54:44] dminuoso: lupine: No I need it for runtime hierarchies.
[12:55:01] dminuoso: Basically I need to figure out how the fuck rails is squishing things together
[12:55:11] dminuoso: Its an awful mess.
[13:03:18] nielsk: has joined #ruby
[13:04:43] RougeR: has joined #ruby
[13:04:43] RougeR: has joined #ruby
[13:05:48] phaul: has joined #ruby
[13:06:00] ellcs: has joined #ruby
[13:06:25] banisterfiend: has joined #ruby
[13:18:19] cschneid: has joined #ruby
[13:20:49] rfoust: has joined #ruby
[13:22:05] beefjoe70: How can I access json fields ?
[13:22:09] beefjoe70: I have this code
[13:22:10] beefjoe70: https://hastebin.com/uguqukonac.rb
[13:22:24] beefjoe70: and I'm getting {"resultType":"Integer","result":2}
[13:22:27] beefjoe70: for example
[13:22:40] beefjoe70: which is what I want, but how can I retrieve result only ?
[13:23:00] beefjoe70: using .result gives an undefined method error
[13:23:14] Sylario: has joined #ruby
[13:25:03] chouhoulis: has joined #ruby
[13:27:08] z64: beefjoe70: if you just have an opaque string, you need to parse that into a ruby object you can traverse first. you likely want to `require 'json'` and then pass that string to `JSON.parse` so you can access the data as a hash
[13:27:33] beefjoe70: but how can I have variables if it's a string ?
[13:27:43] beefjoe70: like the eval method
[13:28:14] beefjoe70: so basically like this
[13:28:15] beefjoe70: hash = JSON.generate({:resultType => eval(code).class,:result => eval(code)})
[13:28:16] beefjoe70: result = JSON.parse(hash)
[13:28:47] ellcs: it's not a hash you have there when generating a json
[13:28:52] ellcs: you'll have a json object
[13:28:59] ellcs: aka a string
[13:30:08] beefjoe70: obj = JSON.generate('{:resultType => eval(code).class,:result => eval(code)}')
[13:30:08] beefjoe70: result = JSON.parse(obj)
[13:30:24] beefjoe70: but then the whole thing is a string and doesn't give me the result I want
[13:33:12] apeiros: has joined #ruby
[13:35:31] bmurt: has joined #ruby
[13:48:13] Rapture: has joined #ruby
[13:48:40] k0mpa: has joined #ruby
[13:51:28] govg: has joined #ruby
[13:52:57] vondruch_: has joined #ruby
[13:52:57] amar: has joined #ruby
[14:02:54] cyberg: has joined #ruby
[14:07:06] ramfjord: has joined #ruby
[14:07:19] beefjoe70: has joined #ruby
[14:07:22] lxsameer: has joined #ruby
[14:08:10] dinfuehr: has joined #ruby
[14:09:00] thapakazi: has joined #ruby
[14:09:36] karapetyan: has joined #ruby
[14:10:49] alfiemax: has joined #ruby
[14:17:10] banisterfiend: has joined #ruby
[14:22:19] beefjoe70: how to parse json that has to be a string but have variables in it?
[14:23:53] Libre: has joined #ruby
[14:24:47] minimalism: has joined #ruby
[14:26:15] arkinor: has joined #ruby
[14:27:32] arashb: has joined #ruby
[14:27:41] cyberg: has joined #ruby
[14:29:22] havenwood: beefjoe70: Why do we use JSON? Sometimes we want to store code as a String. Say we have an Array of Integers and we want to store them as a string then reconstitute them into code. You can turn Ruby into a String like: [1, 2, 3].inspect #=> "[1, 2, 3]"
[14:29:44] havenwood: beefjoe70: Then you can turn that String back into Ruby code like: eval "[1, 2, 3]" #=> [1, 2, 3]
[14:30:28] havenwood: beefjoe70: That works fine, but when you eval a String, you're running arbitrary code.
[14:30:48] beefjoe70: which is insecure
[14:30:59] beefjoe70: gonna work on that later sure
[14:31:05] havenwood: beefjoe70: Right, you don't want to: eval "FileUtils.rm 'oops'"
[14:31:07] mostlybadfly: has joined #ruby
[14:32:00] havenwood: beefjoe70: So we use serializers instead of evaling code. They can only serialize specific data structures, so they're safe. (Some safer than others, because they can serialize less.)
[14:32:09] dbugger_: has joined #ruby
[14:32:19] havenwood: beefjoe70: You deserialize Ruby to a String. Then you serialize it back into Ruby.
[14:32:46] havenwood: beefjoe70: Marshal and YAML can serialize lots of things, so they're unsafe - similar to eval.
[14:33:05] havenwood: beefjoe70: JSON is a subset of YAML that's safe by default.
[14:33:20] havenwood: Use JSON.parse instead of JSON.load, or JSON is unsafe too.
[14:33:41] beefjoe70: hmm interesting
[14:33:45] beefjoe70: one question
[14:33:55] beefjoe70: what's the difference between that and openstruct ?
[14:33:59] ged_: has joined #ruby
[14:34:18] havenwood: An OpenStruct is a datastructure, not a String.
[14:34:25] havenwood: You can't send an OpenStruct as a String, unless you serialize it.
[14:35:18] havenwood: beefjoe70: An OpenStruct is like a Hash, it's just less performant but fancier.
[14:35:25] kmurphy4_: has joined #ruby
[14:35:44] beefjoe70: so it's not json
[14:35:49] bijan_: has joined #ruby
[14:35:59] havenwood: When you initialize an OpenStruct, it internally defines methods on itself. That breaks the method lookup cache, which isn't great to do all the time.
[14:36:00] beefjoe70: cause with it I can access using dot notation
[14:36:17] havenwood: beefjoe70: An OpenStruct is unrelated to JSON.
[14:36:22] havenwood: beefjoe70: JSON is a serialization format that is popular in many languages.
[14:36:39] havenwood: beefjoe70: An OpenStruct is a Ruby-specific datatstructure that is unrelated to serliazation.
[14:37:11] havenwood: beefjoe70: You could never use an OpenStruct, and that'd be fine.
[14:37:47] havenwood: There are more use caveats with OpenStructs than with most things in Ruby. I'm more likely to use a Rinda::TupleSpace than an OpenStruct.
[14:38:48] havenwood: beefjoe70: OpenStructs are fancy. They're fine to use, but usually Rubyists opt for a Struct or Hash instead
[14:39:11] apeiros: hm, I thought rinda was part of drb - is that a gem?
[14:39:18] havenwood: apeiros: stdlib
[14:39:34] beefjoe70: yea I'm going with json then, because I wanna work with the data using js
[14:39:37] apeiros: what's the needed require? doesn't seem to be 'rinda'
[14:40:06] dminuoso: Rinda::TupleSpace
[14:40:21] havenwood: apeiros: Here's an example where I use it as a cache (added it to my girlfriend's book sharing app): https://github.com/stephaniewilkinson/bookmooch/blob/master/lib/tuple_space.rb
[14:40:35] dminuoso: Whole thing looks Javatastic.
[14:40:54] apeiros: god damit stdlib!
[14:40:58] apeiros: require 'rinda' -> fail
[14:41:05] apeiros: require 'rinda/tuplespace' -> success
[14:41:16] apeiros: seriously, that's pissing me off :-S
[14:41:36] havenwood: haha, yeah - i was thinking the other day we should go through and at least make aliases to RubyGems style naming conventions.
[14:41:44] dminuoso: apeiros: The real problem is one of my main beefs with Ruby.
[14:41:51] dminuoso: We have no real module system.
[14:41:57] apeiros: dminuoso: agreed.
[14:42:42] apeiros: I'd phrase it differently - we have no good naming & namespacing requirements
[14:42:53] dminuoso: apeiros: No we have no way to correctly glue modules together.
[14:42:59] dminuoso: require is just a glorified eval.
[14:43:07] andygeorge: has joined #ruby
[14:43:12] dminuoso: evaling programs together in the right order is not fun.
[14:43:29] apeiros: ok, I guess I see where you're going and am at the very least inclined to agree.
[14:43:29] dminuoso: you have no way to explicitly export/import things - you cant separate modules
[14:43:56] apeiros: though proper namespace- & name- requirements would already go a long way
[14:43:56] havenwood: maybe once we get a live ast we can spruce up module and add an: import Fancy, only: [:pants]
[14:44:18] andygeorge: has left #ruby: ()
[14:44:32] apeiros: eh, if dminuoso had his typesystem, the "only" part becomes busywork the compiler can do for you :D
[14:44:59] dminuoso: apeiros: no I think tightly controlling what you import is useful.
[14:45:29] apeiros: I don't really see a value in that, but ok. I can accept that others do and want to have it.
[14:45:30] dminuoso: nameclashes and so on
[14:45:45] apeiros: well, nameclashes -> see proper naming requirements.
[14:47:02] havenwood: not following conventions can be fixed easily enough
[14:47:22] havenwood: cherry picking functions to require and aliasing are harder
[14:47:37] havenwood: i guess aliasing is easier than cherry picking
[14:47:45] dminuoso: havenwood: when I write a library
[14:47:59] dminuoso: I dont want to think about nameclashes with the rest of rubygems
[14:48:02] havenwood: namespacing gems by author seems sane
[14:48:09] dminuoso: I want to be free to use whatever internal concept I want
[14:48:15] dminuoso: and the outside world has no business of knowing about that
[14:48:33] dminuoso: havenwood: right, but when you import an identifier `foo`
[14:48:35] dminuoso: from F and G
[14:48:43] dminuoso: or maybe both have it, but you only want it from F
[14:49:32] nowhere_man: has joined #ruby
[14:49:54] kloeri: has joined #ruby
[14:50:42] cschneid: has joined #ruby
[14:50:50] havenwood: I do appreciate when languages handle that nicely.
[14:51:52] havenwood: It seems the functional ones tend to.
[14:51:54] chouhoulis: has joined #ruby
[14:52:32] havenwood: Clojure and Elixir come to mind as well done.
[14:52:51] cyberg: has joined #ruby
[14:52:58] apeiros: dminuoso: import foo from F as Ffoo, import foo from G as Gfoo
[14:53:00] havenwood: Maybe just too much pretense for Ruby. ;-P
[14:53:13] ged: has joined #ruby
[14:53:17] apeiros: and the reverse domain style namespacing is one of the things java imo did right
[14:53:30] havenwood: import Foo, only: :constants
[14:53:47] havenwood: import Foo, only: :methods
[14:57:25] skeeba: has joined #ruby
[14:57:31] rippa: has joined #ruby
[14:58:46] nima_m: has joined #ruby
[14:59:07] ged: Does anyone know if it's possible to call back into Ruby from a non-ruby thread?
[15:00:48] jottr: has joined #ruby
[15:06:57] bijan_: has joined #ruby
[15:07:05] dminuoso: apeiros: I dont mind hierarchical module organization.
[15:07:11] dminuoso: apeiros: But it's separate from identifier naming.
[15:07:40] dminuoso: havenwood: Even JS does it...
[15:08:31] apeiros: dminuoso: yes. the rdns stuff is not supposed to be part of the identifiers. but IMO it makes more sense to bind identifier to local symbols instead of tightly controlling import.
[15:08:48] RougeR: look what i did
[15:08:49] RougeR: https://gist.github.com/CodePint/de576891dd2889e90ae820fa451d6fa8
[15:09:00] dminuoso: apeiros: Ive tried a few systems. Haskell got it right I think
[15:09:00] RougeR: checks for pluralisation in rails controllers
[15:09:03] apeiros: tightly controlling still can clash - when you want same named from two packages
[15:09:16] dminuoso: apeiros: It allows you to pick identifiers, optionally or exclusively qualify them
[15:09:57] dminuoso: Or you can do a blanket "all except" kind of import (which can be useful if you want short identifiers, but still need to avoid a nameclash with something you dont use)
[15:10:05] dminuoso: JS is fairly close too
[15:10:33] jrabe: has joined #ruby
[15:11:15] vondruch: has joined #ruby
[15:11:35] UserOO7: has joined #ruby
[15:12:46] dminuoso: Java is kind of fine too
[15:13:38] arashb: has joined #ruby
[15:16:15] coderphive: has joined #ruby
[15:17:35] Paweded: has joined #ruby
[15:17:42] synthroid: has joined #ruby
[15:19:54] bijan_: has joined #ruby
[15:21:46] jcarl43: has joined #ruby
[15:24:09] bijan__: has joined #ruby
[15:25:25] redlegion: has joined #ruby
[15:26:14] cagomez: has joined #ruby
[15:28:39] bijan_: has joined #ruby
[15:30:59] airdisa: has joined #ruby
[15:31:38] Zaab1t: has joined #ruby
[15:32:39] bijan__: has joined #ruby
[15:32:53] tolerablyjake: has joined #ruby
[15:35:23] lupine: dminuoso: well, it's kind of available at runtime too, but I'm not aware of any tools to parse it
[15:35:39] airdisa: has joined #ruby
[15:37:00] bijan_: has joined #ruby
[15:37:01] apeiros: dminuoso: fun thing - if UnboundMethod wasn't so picky about its target, we could even implement all those things in the runtime
[15:37:39] dminuoso: apeiros: Please no. If you dont believe me that dynamic features are evil; they are the reason we cant have a proper module system
[15:37:49] dminuoso: they are the reason we cant have a proper type system, regardless of matz & co efforts
[15:37:54] dminuoso: they are the reason we cant have efficient code gen
[15:38:17] dminuoso: also they make it pretty hard to reason about code when staring at it
[15:39:00] apeiros: true, if you want formally verifiable code, ruby is the wrong tool
[15:39:03] dminuoso: and they make it hard to impossible to have good tooling
[15:39:04] apeiros: that doesn't mean it's bad.
[15:39:15] apeiros: it's just unsuited for a set of tasks.
[15:39:55] dminuoso: apeiros: If you check out Crystal. They offer typing, type inference, good code gen - and you can actually write tooling for it. The things you gain when you toss out dynamic features.
[15:40:00] dminuoso: Meta programming by macros :P
[15:40:14] dminuoso: But it still has the ruby feeling to it
[15:40:26] dminuoso: anyway back to reading about profunctor optics
[15:47:08] airdisa: has joined #ruby
[15:48:35] bijan_: has joined #ruby
[15:51:02] jamiejackson: has joined #ruby
[15:51:16] memo1: has joined #ruby
[15:51:17] Mikasi: has joined #ruby
[15:52:50] bijan__: has joined #ruby
[15:54:39] Libre: has joined #ruby
[15:55:41] alfiemax: has joined #ruby
[16:01:09] cyberg: has joined #ruby
[16:02:11] z64: +1 to crystal :)
[16:03:05] kvoz: has joined #ruby
[16:04:34] kvoz: Hi. Complete ruby noob here (never written a line of code) but been tasked with maintaining someone elses application, and I have been told I need to run rake db:migrate, but when I do I get "connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432", but thats not what my $DB_HOST variable says, I dont understand why its trying to connect to that db
[16:05:44] bijan_: has joined #ruby
[16:07:20] p0p0pr37_: has joined #ruby
[16:07:20] p0p0pr37_: has joined #ruby
[16:10:02] bijan__: has joined #ruby
[16:11:05] conta: has joined #ruby
[16:11:13] kapil___: has joined #ruby
[16:14:19] bijan_: has joined #ruby
[16:16:21] ciscam: has joined #ruby
[16:16:28] guacamole: has joined #ruby
[16:16:28] guacamole: has joined #ruby
[16:17:39] OS-35301: has joined #ruby
[16:24:14] alfiemax: has joined #ruby
[16:27:19] banisterfiend: has joined #ruby
[16:27:32] emilford: has joined #ruby
[16:27:35] bijan_: has joined #ruby
[16:30:06] jamiejackson: has joined #ruby
[16:31:59] brianpWins: has joined #ruby
[16:33:20] nitric: has joined #ruby
[16:33:48] manjaroi3_: has joined #ruby
[16:34:37] TomyLobo: has joined #ruby
[16:35:12] karapetyan: has joined #ruby
[16:39:11] alfiemax: has joined #ruby
[16:39:20] sent-hil: has joined #ruby
[16:39:48] bijan_: has joined #ruby
[16:40:35] emilford: has joined #ruby
[16:44:44] bijan__: has joined #ruby
[16:45:58] cagomez: has joined #ruby
[16:47:35] emilford: has joined #ruby
[16:50:12] banisterfiend: has joined #ruby
[16:50:34] amar: has joined #ruby
[16:50:47] memo1: has joined #ruby
[16:53:21] bijan_: has joined #ruby
[16:54:15] sanscoeur: has joined #ruby
[16:54:40] Puffball: has joined #ruby
[16:56:22] yxhuvud: has joined #ruby
[16:57:38] bijan_: has joined #ruby
[17:01:35] bijan__: has joined #ruby
[17:02:19] manjaroi3_: has joined #ruby
[17:06:32] amar: has joined #ruby
[17:06:58] conta: has joined #ruby
[17:07:07] andrevan: has joined #ruby
[17:09:06] emilford: has joined #ruby
[17:10:08] bijan_: has joined #ruby
[17:13:00] alfiemax: has joined #ruby
[17:13:10] jrafanie: has joined #ruby
[17:13:19] Eiam: has joined #ruby
[17:20:40] emilford: has joined #ruby
[17:21:51] gizmore: has joined #ruby
[17:22:02] jenrzzz: has joined #ruby
[17:22:02] jenrzzz: has joined #ruby
[17:23:03] bijan_: has joined #ruby
[17:25:02] weird_error: has joined #ruby
[17:25:20] manjaroi3_: has joined #ruby
[17:27:56] majuk: has joined #ruby
[17:30:34] manjaroi3_: Hi. Complete ruby noob here (never written a line of code) but been tasked with maintaining someone elses application, and I have been told I need to run rake db:migrate, but when I do I get "connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432", but thats not what my $DB_HOST variable says, I dont understand why its trying to connect to that db
[17:30:51] aupadhye: has joined #ruby
[17:31:08] mwlang: has joined #ruby
[17:31:24] tAn: has joined #ruby
[17:31:26] havenwood: manjaroi3_: A Rails app I'm guessing from the Rake command? Check the file: config/database.yml
[17:31:29] Lytol: has joined #ruby
[17:31:35] havenwood: ?rails manjaroi3_
[17:31:35] ruby[bot]: manjaroi3_: Please join #RubyOnRails for Rails questions. You need to be identified with NickServ, see /msg NickServ HELP
[17:32:08] emilford: has joined #ruby
[17:32:25] manjaroi3_: havenwood, will try there, thank you
[17:32:47] mwlang: is there a gem out there supporting .Net’s signalr websockets? I’m having trouble tracking one down.
[17:32:52] havenwood: manjaroi3_: Your nick needs to be registered to talk in #rubyonrails: https://freenode.net/kb/answer/registration
[17:33:07] majuk: Hi all. I have an application I want to deploy on an ARM board [iMx6]. Unfortunately, my target board does not have enough horse-power to build the required gems itself [chokes specifically trying to build nokogiri]. My googling for guides to cross compile is taking me a lot of places I don't understand.
[17:33:14] majuk: Any questions or comments are appreciated.
[17:33:53] mwlang: majuk I can compile and build nokogiri gem on a 1st and 2nd edition Raspberry Pi
[17:34:18] mwlang: it may not be horse power of the arm board, but rather a lack of necessary system packages.
[17:34:43] havenwood: mwlang: i think this lib uses SignalR, unsure: https://github.com/Azure/azure-sdk-for-ruby
[17:35:07] majuk: mwlang: No, my board runs out of memory during the build process. I lost the exact error message, but I can recreate it.
[17:35:27] havenwood: majuk: Do you need Nokogiri specifically or just an XML parser?
[17:35:43] havenwood: majuk: Oga is among the good alternatives.
[17:35:47] ellcs: has joined #ruby
[17:35:53] bijan_: has joined #ruby
[17:35:54] hahuang65_: has joined #ruby
[17:37:01] lxsameer: has joined #ruby
[17:37:03] majuk: havenwood: Nokogiri is required
[17:37:07] amar: has joined #ruby
[17:38:15] havenwood: majuk: I can't think of a way to get nokogiri compilation to use less memory.
[17:39:00] mwlang: havenwood: You are the queen - that package indeed has a signalr client in it.
[17:39:05] havenwood: majuk: are you hitting a ulimit or running out of system memory?
[17:39:31] havenwood: majuk: have you tried using system libs?
[17:39:35] majuk: havenwood: System memory IIRC. I'm recreating the error message as we speak but it will take another ~10 minutes for the process to give up.
[17:39:40] havenwood: mwlang: hooah!
[17:39:47] gizmore: what is usually better, preferring symbols or strings as hashmap keys? .... i am thinking of avoiding symbols in favor of mysql2 returns stringed hashmaps
[17:39:59] hotpancakes: has joined #ruby
[17:40:09] bijan__: has joined #ruby
[17:41:03] havenwood: gizmore: What kind of text? Have any examples?
[17:41:15] gizmore: column names
[17:42:37] havenwood: gizmore: I'd probably use Symbols for those. Symbols are generally preferred for Hash keys, and column names should look nice as Symbols.
[17:44:47] bijan_: has joined #ruby
[17:45:59] gizmore: havenwood: yeah.... maybe there is an option in mysql2 gem to return symbols as keys
[17:46:31] havenwood: gizmore: it's fine to use String Hash keys as well
[17:46:43] mwlang: gizmore: sequel gem will let you interact with the DBMS with ruby hashes.
[17:46:46] ramfjord: has joined #ruby
[17:47:05] lxsameer: has joined #ruby
[17:47:06] guille-moe: has joined #ruby
[17:47:29] mwlang: and with that library, it’s all symbols instead of strings.
[17:47:33] gizmore: i am working on my own dba :)
[17:48:07] mwlang: ok, gotcha. FWIW, I prefer symbols for hash keys over strings.
[17:48:16] havenwood: gizmore: look at Sequel's plugin system
[17:48:42] gizmore: i am fine.... but it probably is worth a look
[17:49:11] mwlang: I learned a lot of good Ruby tricks from the Sequel source. Definitely worth a study.
[17:49:38] gizmore: i also did my own autoloader... it just replaces :: with /
[17:49:46] gizmore: in missing constants... works charmy
[17:49:58] mwlang: neat idea.
[17:50:15] mwlang: where do you hook the autoloader in?
[17:50:21] gizmore: module GDO
[17:50:35] gizmore: only own classes are loaded that way
[17:53:03] bijan_: has joined #ruby
[17:55:16] chouhoulis: has joined #ruby
[17:56:22] nitric: has joined #ruby
[17:56:33] cadillac_: has joined #ruby
[17:56:36] eelster: has joined #ruby
[17:56:56] tao_: has joined #ruby
[17:57:09] lxsameer: has joined #ruby
[17:57:26] bijan__: has joined #ruby
[17:59:36] nitric_: has joined #ruby
[18:00:23] p0p0pr37_: has joined #ruby
[18:00:23] p0p0pr37_: has joined #ruby
[18:01:33] Jiaoyin: has joined #ruby
[18:01:46] Jiaoyin: ..hey guys, I was helping, I can get some tips
[18:02:37] Jiaoyin: Correct me if I'm wrong, but a hash is a associative array, right? When you create a hash you use {curly braces}, but when you want to use the key of a hash, you’re using [square brackets].
[18:03:46] gizmore: Jiaoyin: the [] function is to access values of the hash... use hash[key] to read a value
[18:04:05] gizmore: use hash[key]= to set a value
[18:04:23] mwlang: I don’t know if “associative array” is correct term for a Hash. key/value mapping seems more appropriate.
[18:04:29] bijan_: has joined #ruby
[18:04:59] havenwood: Jiaoyin: You're right, a Hash is a dictionary. Hash#[] is one Hash method for retrieving the value for the specified key. There's a little bit of syntactic sugar that let's you call it like `h[arg]` instead of `h.[](arg)`.
[18:05:18] Jiaoyin: If a hash for txt is {"txt"=>14}. The key for the hash is 14? To get the hash 14, you type in....[txt]. Correct?
[18:05:35] havenwood: >> {"txt"=>14}["txt"] # Jiaoyin
[18:05:36] ruby[bot]: havenwood: # => 14 (https://eval.in/1012761)
[18:05:49] havenwood: Jiaoyin: Try in irb or pry. :-)
[18:06:33] cyberg: has joined #ruby
[18:06:33] Jiaoyin: ....that's the key, right?
[18:06:48] havenwood: Jiaoyin: `{}` is a Hash literal. `"txt"` is the key and `14` is the value.
[18:06:57] havenwood: >> {}.class
[18:06:58] ruby[bot]: havenwood: # => Hash (https://eval.in/1012765)
[18:07:04] havenwood: >> {"txt"=>14}.keys
[18:07:05] ruby[bot]: havenwood: # => ["txt"] (https://eval.in/1012766)
[18:07:07] havenwood: >> {"txt"=>14}.values
[18:07:08] ruby[bot]: havenwood: # => [14] (https://eval.in/1012767)
[18:07:22] lxsameer: has joined #ruby
[18:08:46] Jiaoyin: ..so 14 is the hash?
[18:09:02] havenwood: Jiaoyin: Nope, the value of the one key/value pair in the hash.
[18:09:18] Jiaoyin: ...I'm taking a Google course on Coursera....................https://www.coursera.org/learn/it-automation/
[18:09:40] havenwood: Jiaoyin: The hash is `{"txt"=>14}`. It has one key/value pair. The one key is `"txt"`. The one value is `14`.
[18:09:41] mikecmpbll: has joined #ruby
[18:09:42] Jiaoyin: I'm still on the first week and I'm trying to understand the hash and key....that's why I ask
[18:10:22] Jiaoyin: that makes alot more sense
[18:10:26] Jiaoyin: I appreciate it :)
[18:11:02] russt: has joined #ruby
[18:11:09] havenwood: mwlang: I think it is the right overarching term. Hash, dictionary and map are all just different names for associative arrays, which can be implemented any which way.
[18:11:18] Jiaoyin: I thought 'txt' was the hash. Didn't know the whole thing inside the {} was the actual hash.
[18:11:33] Jiaoyin: thanks again
[18:11:33] havenwood: mwlang: Though I do have a bit of a bad taste re "associative array" because of PHP. ;-P
[18:11:47] havenwood: Jiaoyin: You're welcome. Happy coding!
[18:11:57] mwlang: havenwood: that may be it for me as well.
[18:13:29] guacamole: has joined #ruby
[18:13:30] guacamole: has joined #ruby
[18:14:27] nk121: has joined #ruby
[18:15:00] Jiaoyin: .......btw, I just notice you used used ' instead of "............why is that?
[18:15:49] Jiaoyin: ...is it just a preference thing?
[18:17:07] lxsameer: has joined #ruby
[18:17:40] havenwood: Jiaoyin: You mean the backticks I put around code, like `1 +1` or something else?
[18:18:51] havenwood: Jiaoyin: I don't understand what you're asking. ¯\_(ツ)_/¯
[18:19:11] havenwood: Jiaoyin: Oh, you mean single instead of double quote?
[18:19:27] Jiaoyin: ..when you were replying to me just a while ago, you said................The one key is `"txt"`. The one value is `14`.........................is their a reason why you said '"txt"' instead of 'txt' or just "txt"
[18:20:15] havenwood: Jiaoyin: I'm using the convention where you always surround code used inline in sentences with backticks.
[18:20:16] havenwood: Jiaoyin: They're not single quotes, they're backticks.
[18:20:25] spiette: has joined #ruby
[18:20:37] ruby[bot]: havenwood: # => 96 (https://eval.in/1012770)
[18:20:42] ruby[bot]: havenwood: # => "`" (https://eval.in/1012771)
[18:21:19] havenwood: Jiaoyin: In markdown and some other formats, that'll designate it as code. It's a fairly common convention.
[18:21:39] havenwood: Jiaoyin: If you denote what's code by convention it makes it easier to tell what's meant to be code and what's meant to be English.
[18:22:15] havenwood: Jiaoyin: So I try to always use backticks inline, or put my code following a colon, like: 1 + 1
[18:22:35] SeepingN: has joined #ruby
[18:22:40] havenwood: Jiaoyin: So `1 + 1` or: 1 + 1
[18:23:00] Jiaoyin: in the irb, when I typed in {"txt"=>14}.hash ............................I got 1017606070
[18:23:05] Jiaoyin: where is the number 1017606070 coming from?
[18:23:15] phaul: has joined #ruby
[18:23:26] havenwood: >> 'Jiaoyin'.hash
[18:23:27] ruby[bot]: havenwood: # => -533293653 (https://eval.in/1012772)
[18:23:35] havenwood: Jiaoyin: Your hash is negative!
[18:23:41] havenwood: >> 'Jiaoyin'.hash
[18:23:42] ruby[bot]: havenwood: # => 543477173 (https://eval.in/1012773)
[18:23:46] havenwood: Phew, that's better.
[18:25:40] Jiaoyin: I see the number, but how are these number calculated? I mean, how is it that 'Jiaoyin'.hash.....................brings up 481165061 ...........where as {"txt"=>14}.hash ...........brings up 1017606070
[18:26:10] Jiaoyin: what hashing algorithm is it using?....if it's using any
[18:26:41] Jiaoyin: Just curious how these hashes are being generated..
[18:27:06] lxsameer: has joined #ruby
[18:28:42] \void: has joined #ruby
[18:30:06] banisterfiend: has joined #ruby
[18:31:42] phaul: has joined #ruby
[18:32:15] havenwood: There's an algorithm called SipHash 13 that Ruby uses.
[18:33:23] havenwood: Jiaoyin: You can see the C implementation here: https://github.com/ruby/ruby/blob/trunk/siphash.c
[18:33:39] Jiaoyin: kool, thanks :)
[18:34:15] havenwood: Ruby fairly recently switched from SipHash 24 to SipHash 13, following Rust's lead.
[18:34:20] havenwood: https://bugs.ruby-lang.org/issues/13017
[18:34:42] havenwood: Jiaoyin: Here's a paper on SipHash: https://cr.yp.to/siphash/siphash-20120620.pdf
[18:35:39] Jiaoyin: ..............is their a online conversion tool? Let's say I get the siphash 481165061.............how I want to flip it back.........unhash or unencrypt it
[18:35:42] Jiaoyin: how do I do that?
[18:36:06] mwlang: why switch from SipHash24 to 13? performance?
[18:36:15] havenwood: mwlang: aye, performance
[18:37:13] lxsameer: has joined #ruby
[18:37:27] Jiaoyin: ..and, how do I check what algorithm Ruby is using for the hashing...using the irb?
[18:38:22] ellcs: has joined #ruby
[18:40:10] \void: has joined #ruby
[18:41:05] havenwood: Jiaoyin: You'd have to check the Ruby source code to see that implementation detail.
[18:41:17] havenwood: Jiaoyin: Most Rubyists don't know what SipHash 13 is nor care.
[18:41:53] Jiaoyin: Is their a online conversion tool out there?
[18:42:15] havenwood: Jiaoyin: You can't get from that hash number back to the object. It doesn't correspond like an object_id does.
[18:42:27] havenwood: Jiaoyin: It's being produced by a cryptographic function that was designed not to leak information.
[18:43:03] Jiaoyin: ...unless without the key?
[18:43:06] havenwood: Jiaoyin: An object_id on the other hand corresponds to the object's location in memory, and is simple enough to easily reverse engineer.
[18:43:31] havenwood: Jiaoyin: Read the SipHash 2-4 paper. ;-P
[18:43:37] havenwood: I linked it above.
[18:43:47] Jiaoyin: https://cr.yp.to/siphash/siphash-20120620.pdf
[18:45:02] havenwood: Jiaoyin: Here's a short Ruby implementation of SipHash 2-4: https://github.com/emboss/siphash-ruby/blob/master/lib/siphash.rb
[18:45:42] GodFather: has joined #ruby
[18:45:50] havenwood: I should do a SipHash 1-3 implementation in pure Ruby. That sounds fun.
[18:47:18] lxsameer: has joined #ruby
[18:48:42] Jiaoyin: You should :)
[18:48:55] codymj: has joined #ruby
[18:49:29] Jiaoyin: I looked through the pdf file and the rb file. It doesn't have anything on how to check what hashing algrithom your version of ruby has. Is their a way I can check this under the irb?
[18:50:00] banisterfiend: has joined #ruby
[18:50:26] havenwood: Jiaoyin: No, it's an implementation detail. As a Ruby user, it's not going to make any difference to you.
[18:50:31] Jiaoyin: ..something to type in the irb...............so it spits out something like, "You're using the hashing algorithm SipHash13"
[18:50:47] havenwood: Jiaoyin: Nope, nothing like that.
[18:50:51] Jiaoyin: I se, alright
[18:51:14] havenwood: Jiaoyin: Maybe if you can somehow embed the #ruby channel in your irb.
[18:51:36] nowhere_man: has joined #ruby
[18:56:20] hotpancakes: has joined #ruby
[18:57:16] lxsameer: has joined #ruby
[18:58:40] cyberg: has joined #ruby
[19:00:13] cagomez: has joined #ruby
[19:04:26] ramfjord: has joined #ruby
[19:06:14] hotpancakes: has joined #ruby
[19:07:01] lxsameer: has joined #ruby
[19:08:37] dreamthese: has joined #ruby
[19:09:38] RougeR: has joined #ruby
[19:09:39] RougeR: has joined #ruby
[19:10:21] manjaroi3_: has joined #ruby
[19:11:11] KeyJoo: has joined #ruby
[19:11:23] Jiaoyin: ..how do you embed the ruby channel in the IRB?..lol
[19:12:14] andrevan: has joined #ruby
[19:13:52] alfiemax_: has joined #ruby
[19:14:12] jrafanie_: has joined #ruby
[19:15:47] majuk: Is there a way to have bundler report the gems it thinks are required by a Gemfile?
[19:15:51] cagomez: has joined #ruby
[19:17:01] lxsameer: has joined #ruby
[19:19:01] z64: is a lockfile not suitable?
[19:19:51] majuk: z64: Ah, I think that's what I'm looking for. Thanks.
[19:20:27] z64: FWIW, you can generate a lockfile or print it to STDOUT with `bundle lock` (see --help)
[19:20:50] z64: (bundle lock wont actually install the gems)
[19:21:24] majuk: Cool, I'll look at that. It seems my earlier memory issue is local to bundler as using `gem install` outside bundler was able to install [most] of the necessary gems.
[19:22:19] majuk: That's a comment towards general chat, not specifically you z64
[19:23:50] banisterfiend: has joined #ruby
[19:24:43] eblip: has joined #ruby
[19:26:07] jottr: has joined #ruby
[19:27:07] lxsameer: has joined #ruby
[19:27:26] cyberg: has joined #ruby
[19:30:35] alfiemax: has joined #ruby
[19:30:52] ellcs: has joined #ruby
[19:31:35] cagomez: has joined #ruby
[19:33:43] nowhere_man: has joined #ruby
[19:35:19] Eiam: Jiaoyin: I can't tell if that was a serious question or not...
[19:35:38] coderphive: has joined #ruby
[19:36:57] lxsameer: has joined #ruby
[19:41:43] bogdan: has joined #ruby
[19:44:17] RougeR: has joined #ruby
[19:44:17] RougeR: has joined #ruby
[19:45:06] alfiemax: has joined #ruby
[19:47:11] lxsameer: has joined #ruby
[19:48:06] memo1: has joined #ruby
[19:48:14] jatto: has joined #ruby
[19:49:27] ski7777: has joined #ruby
[19:49:28] cagomez: has joined #ruby
[19:53:25] agent_white: has joined #ruby
[19:53:42] p0p0pr37_: has joined #ruby
[19:54:07] cyberg: has joined #ruby
[19:56:07] amar_: has joined #ruby
[19:56:20] phaul: has joined #ruby
[19:57:08] lxsameer: has joined #ruby
[20:02:18] mwlang: havenwood: embed #ruby irc channel in irb console!? You gotta build that! I can just see it now…an interactive Ruby shell that emits IRC messages as they come through while you’re working on something…and you can reply back with simple command => irc :ruby, “yeah, I got it.”
[20:05:37] mwlang: for any of you that are into crypto currencies and trading on exchanges, I put out a new open source gem that wraps cobinhood’s api: https://github.com/mwlang/cobinhood I’d love some feedback on how to improve this code (aside from the most obvious: writing some specs for it…)
[20:05:46] tolerablyjake: has joined #ruby
[20:07:05] lxsameer: has joined #ruby
[20:07:12] banisterfiend: has joined #ruby
[20:07:12] tAn: has joined #ruby
[20:07:18] mwlang: speaking of writing specs, for open source projects that may have sensitve server exchanges, what’s the typical approach to implementing? last thing I want to do is accidentally expose my private API keys through VCR cassettes and/or other means of fixture capturing.
[20:08:01] cyberg: has joined #ruby
[20:11:55] jcalla: has joined #ruby
[20:12:48] eckhardt: has joined #ruby
[20:16:31] guacamole: has joined #ruby
[20:16:32] guacamole: has joined #ruby
[20:17:11] lxsameer: has joined #ruby
[20:17:30] dreamthese: has joined #ruby
[20:17:49] havenwood: mwlang: I'd suggest inheriting from StandardError instead of Exception.
[20:18:02] havenwood: mwlang: Frozen string literal magic comment is fairly mainstream these days.
[20:18:59] havenwood: mwlang: ENV::[] always returns a String, so #to_s is redundant: https://github.com/mwlang/cobinhood/blob/master/lib/cobinhood/client/rest.rb#L30
[20:19:43] havenwood: mwlang: I'd suggest using ENV::fetch instead, to raise an error if the env var is missing, rather than have it be `nil` and percolate up elsewhere.
[20:20:35] mwlang: Good points on all, but I didn’t understand one: Frozen string literal magic comment?
[20:21:07] havenwood: mwlang: On the first line of the file: # frozen_string_literal: true
[20:21:43] havenwood: mwlang: It'll autofreeze all the Strings as if you ran Ruby with: --enable-frozen-string-literal
[20:21:43] mwlang: Ah! That’s a new feature to me.
[20:22:14] mwlang: does it go in every file or just the primary lib/cobinhood.rb file?
[20:22:31] havenwood: at the top of each Ruby file
[20:22:32] apeiros_: has joined #ruby
[20:22:52] havenwood: most popular libraries are just adding it across the board
[20:23:01] mwlang: what’s practically gained from freezing all the literal strings?
[20:23:24] havenwood: saving memory and speed
[20:23:31] apeiros_: and avoiding silly bugs
[20:23:50] havenwood: mwlang: Do you mean end of line or end of string here?: https://github.com/mwlang/cobinhood/blob/master/lib/cobinhood/client/rest.rb#L65
[20:24:04] havenwood: mwlang: If end of String, switch to: \z
[20:24:57] havenwood: mwlang: You can interpolate directly into a Regexp literal: https://github.com/mwlang/cobinhood/blob/master/lib/cobinhood/client/rest.rb#L99
[20:25:17] havenwood: >> option = 42; /:#{option}/
[20:25:18] ruby[bot]: havenwood: # => /:42/ (https://eval.in/1012811)
[20:26:08] havenwood: mwlang: In Ruby 2.4+ you can use #match? instead of #=~ to save memory and time: https://github.com/mwlang/cobinhood/blob/master/lib/cobinhood/client/rest.rb#L100
[20:26:31] banisterfiend: has joined #ruby
[20:26:36] apeiros: havenwood: huh? is match? optimized by the parser the same way =~ is?
[20:27:07] lxsameer: has joined #ruby
[20:28:53] havenwood: apeiros: #match? doesn't set MatchData and global variables, so it's way faster
[20:29:02] havenwood: apeiros: i think both are optimized instructions: https://github.com/ruby/ruby/blob/fde115b13c23a1278c06a0d42e1cd04aa7568ea1/insns.def#L1305-L1327
[20:29:13] apeiros: havenwood: neither does =~, they're set lazily
[20:29:44] apeiros: or at least that's how I learned it ages ago :D
[20:29:54] havenwood: match? ends up being a really nice performance improvement
[20:30:18] apeiros: eh, duly noted
[20:30:29] havenwood: apeiros: Rails switched String#blank? from #=~ to #match? and now it's as fast as the fast_blank C ext
[20:30:35] mwlang: learnt a couple of something new today!
[20:30:47] apeiros: interesting
[20:32:07] mwlang: I’ve been using !~ and =~ for quite some time just because I like it better than reading “match?” but an performance boost is enough for me to change.
[20:32:45] mwlang: truth be told, most time lost on the actual API call/response than anywhere else.
[20:33:00] havenwood: mwlang: It's a nit, but I'd argue for `@api.to_s.empty?` here, because I prefer a lone method to method with arg: https://github.com/mwlang/cobinhood/blob/master/lib/cobinhood/client/rest/auth_request_middleware.rb#L9
[20:33:16] havenwood: Also, one less String allocation.
[20:34:39] havenwood: mwlang: You can remove the colons with all the alias keywords: https://github.com/mwlang/cobinhood/blob/master/lib/cobinhood/client/rest/trading_api.rb#L10
[20:34:55] havenwood: mwlang: Just barewords: alias get_order order
[20:35:12] mwlang: now that I did not know!
[20:36:13] havenwood: mwlang: An alternative to `/ 1000.0` would be `fdiv 1000`: https://github.com/mwlang/cobinhood/blob/master/lib/cobinhood/client/rest/system_api.rb#L10
[20:36:26] Sembei: has joined #ruby
[20:37:05] lxsameer: has joined #ruby
[20:37:31] emilford: has joined #ruby
[20:38:22] guacamole: has joined #ruby
[20:38:22] guacamole: has joined #ruby
[20:38:37] havenwood: mwlang: Normally you don't commit the Gemfile.lock for gems.
[20:38:54] havenwood: mwlang: Unlike apps, you commit just the Gemfile.
[20:39:03] mwlang: good point. I forgot that one.
[20:40:17] havenwood: mwlang: I'd also add Gemfile.lock to the .gitignore.
[20:40:35] havenwood: mwlang: (And `git rm Gemfile.lock` and commit its removal.)
[20:41:59] havenwood: mwlang: I'd suggest #public_send instead of #send here, unless it really is intentionally calling a private method: https://github.com/mwlang/cobinhood/blob/master/lib/cobinhood/client/rest.rb#L94
[20:42:39] emilford: has joined #ruby
[20:42:59] mwlang: *havenwood all suggestions adopted.
[20:43:03] havenwood: mwlang: Congrats on the gem!
[20:43:22] mwlang: thanks. how was the structuring? was it easy to follow?
[20:45:03] mwlang: on the frozen literal string magic comment, if I add that, I should remove the #freeze call, right? https://github.com/mwlang/cobinhood/blob/master/lib/cobinhood/client/rest/api_endpoints.rb#L43 for example.
[20:47:12] lxsameer: has joined #ruby
[20:49:54] ldepandis: has joined #ruby
[20:50:24] BH23: has joined #ruby
[20:50:25] mwlang: havenwood: thanks for that detailed look and feedback. I definitely wasn’t expecting that and really appreciate it. I’m probably going to do a few more of these for various exchanges, esp. if the current ones out there royally suck like the cobinhood_api one did.
[20:50:57] mwlang: kucoin comes to mind. terrible implementation of a ruby wrapper on the existing gem.
[20:51:13] banisterfiend: has joined #ruby
[20:52:20] biox: has joined #ruby
[20:52:37] cliluw: has joined #ruby
[20:52:49] mwlang: one other performance idea: someone told me to switch the Faraday default adapter to Typhoeus. any opinions here on the merits of that suggestion?
[20:53:04] amar: has joined #ruby
[20:56:15] memo1: has joined #ruby
[20:57:02] lxsameer: has joined #ruby
[20:57:44] zleap: has joined #ruby
[20:59:36] tdy: has joined #ruby
[21:00:53] mwlang: hmmm…are you sure about “ ENV::[] always returns a String” ? I just tried this in IRB console: ENV["SOMETHING"] => nil
[21:01:51] t0xik: has joined #ruby
[21:02:05] dviola: has joined #ruby
[21:03:54] apeiros: mwlang: always returns a string +for existing keys+
[21:04:05] apeiros: nonexistent keys will return nil, yes
[21:04:46] Eiam: you could do ENV["SOMETHING"] ||= :emptyEnv
[21:04:58] mwlang: apeiros: thanks for clarifying.
[21:05:06] Eiam: in which case you'll always get something =0
[21:05:20] mwlang: I just simply did ENV[“SOMETHING”].to_s
[21:05:43] Eiam: eh, now you are encoding an empty string to mean state
[21:05:45] Eiam: but w/e its your code.
[21:06:27] mwlang: but you know…better idea is to change where I call #to_s
[21:07:09] mwlang: if only nil.empty? => true
[21:07:22] lxsameer: has joined #ruby
[21:07:37] Eiam: #rubyonrails is that way
[21:07:40] mwlang: all I needed to know at the point of using an api_key is whether it was blank/empty or not.
[21:08:11] mwlang: *sigh* any ideas they *didn’t* bolt on?
[21:08:31] mwlang: rails is a two-edged sword, for sure.
[21:09:04] Eiam: you can check length if you don't feel like writing an or... ?
[21:09:23] tAn: has joined #ruby
[21:09:38] Eiam: as long as you .to_s it like you said first, you'll get 0
[21:09:56] mwlang: that’s all I really need. sweet and simple.
[21:12:25] mwlang: pushed a new version with the nitpicks cleaned up. @Eiam this is where I’m using that #to_s: https://github.com/mwlang/cobinhood/blob/master/lib/cobinhood/client/rest/auth_request_middleware.rb#L10
[21:12:40] mwlang: line #6 sets it, line #10 uses it.
[21:14:15] Eiam: looks fair; why not raise in init?
[21:14:35] Eiam: question, not a critique
[21:15:10] mwlang: because there’s a public set of endpoints that do not require an api_key
[21:15:22] cliluw: has joined #ruby
[21:15:24] mwlang: if I raised it then, it would prevent using the library without an api_key
[21:15:54] mwlang: this way, error’s raised only first time an endpoint requiring the key is called.
[21:16:37] banisterfiend: has joined #ruby
[21:16:59] emilford: has joined #ruby
[21:17:12] lxsameer: has joined #ruby
[21:17:37] Eiam: ah, and you only call the middleware in such a case
[21:17:39] Eiam: got it, makes sense
[21:19:11] orbyt_: has joined #ruby
[21:20:53] ramfjord: has joined #ruby
[21:26:55] ramfjord: has joined #ruby
[21:27:04] lxsameer: has joined #ruby
[21:28:42] havenwood: mwlang: Who knew... shevy already made it: https://rubygems.org/gems/talk_in_irc_channel
[21:30:06] emilford: has joined #ruby
[21:32:20] hotpancakes: has joined #ruby
[21:32:28] ur5us: has joined #ruby
[21:33:18] jenrzzz_: has joined #ruby
[21:34:11] chouhoul_: has joined #ruby
[21:37:13] lxsameer: has joined #ruby
[21:38:10] guacamole: has joined #ruby
[21:38:10] guacamole: has joined #ruby
[21:38:52] tvw: has joined #ruby
[21:41:12] havenwood: I like baweaver's suggestion to hook it up so errors automatically post a question here. hahaha.
[21:41:13] havenwood: raise #ruby irc HALP
[21:41:42] apeiros: ACTION gets out the bigger banhammer in advance
[21:43:41] ellcs: has joined #ruby
[21:44:42] cliluw: has joined #ruby
[21:46:54] cyberg: has joined #ruby
[21:47:02] lxsameer: has joined #ruby
[21:47:06] p0p0pr37_: has joined #ruby
[21:47:06] p0p0pr37_: has joined #ruby
[21:48:47] CrazyEddy: has joined #ruby
[21:48:56] orbyt_: has joined #ruby
[21:49:23] ur5us: has joined #ruby
[21:51:58] tdy: has joined #ruby
[21:54:16] cajone: has joined #ruby
[21:57:10] lxsameer: has joined #ruby
[21:57:52] beefjoe70: has joined #ruby
[22:02:29] cajone: has left #ruby: ()
[22:05:38] eckhardt: has joined #ruby
[22:07:12] lxsameer: has joined #ruby
[22:16:52] venmx: has joined #ruby
[22:19:06] jenrzzz: has joined #ruby
[22:25:04] Jiaoyin: @mwlang I just saw your post about cobinhood..lol. I was one of the few original investors
[22:25:24] Jiaoyin: .....what's the program about?
[22:25:29] Jiaoyin: the one you're trying to write..
[22:25:30] bipul: has joined #ruby
[22:26:13] mwlang: @Jiaoyin original investor as in pre-pre ICO investor? :-o
[22:26:34] mwlang: @Jiaoyin What I produced is just Ruby API wrappers to the Cobinhood API
[22:27:02] mwlang: I needed it for algorithimic trading bots I’m building.
[22:27:57] Jiaoyin: I was in the ICO during around the time when they had the problem with EtherDelta
[22:28:10] Jiaoyin: ..and it went crashing..lol
[22:28:47] mwlang: Ah. I’ve been a long-term “investor” from point of view of simply holding and growing COB stack simply trading the gap in the spreads on the platform.
[22:29:14] Jiaoyin: that's kool
[22:29:18] mwlang: trying to automate what I’ve been doing manually until now.
[22:29:30] Jiaoyin: I'm currently learning Ruby so hearing about your code.....caught my attention
[22:29:50] mwlang: Ah. welcome to the Ruby community.
[22:30:19] Jiaoyin: Do you think Cobinhood is going to hold up? I'm hearing a ton of problems with RobinHood..ahaha
[22:30:20] mwlang: If you’re into cryptocurrencies, you may also like another open source Ruby project I have going: https://github.com/mwlang/crypto
[22:30:43] mwlang: I do. They seem to have a great team and constantly working on improving the platform.
[22:30:58] cagomez: has joined #ruby
[22:30:59] mwlang: their marketing needs help, but they’re getting better there.
[22:32:10] Jiaoyin: Looks like you got some good projects going.
[22:32:28] Jiaoyin: Still learning so I will look over it again once I get better at Ruby.
[22:32:32] mwlang: they’re fun and keeps me busy.
[22:34:03] cagomez: How do I set `email` key to an empty string if the key exists? {'email'=> nil}.reverse_merge('email' => 'foo')
[22:34:39] Jiaoyin: Goodluck with your project
[22:35:58] d^sh: has joined #ruby
[22:37:09] mwlang: Jiaoyin: thanks! you, too.
[22:42:07] emilford: has joined #ruby
[22:43:23] dinfuehr: has joined #ruby
[22:47:07] lxsameer: has joined #ruby
[22:47:42] emilford: has joined #ruby
[22:52:22] brianpWins: has left #ruby: ()
[22:56:39] sanscoeur: has joined #ruby
[22:57:07] willmichael: has joined #ruby
[22:57:22] hotpancakes: has joined #ruby
[22:58:31] emilford: has joined #ruby
[22:59:00] cagomez: has joined #ruby
[23:02:53] brianpWins: has joined #ruby
[23:03:43] ramfjord: has joined #ruby
[23:06:33] cschneid: has joined #ruby
[23:08:15] jenrzzz: has joined #ruby
[23:08:28] rfoust: has joined #ruby
[23:09:50] ramfjord: has joined #ruby
[23:10:11] cajone: has joined #ruby
[23:14:12] emilford: has joined #ruby
[23:15:28] noobineer: has joined #ruby
[23:15:41] pizzaops: Hi there. I'm experiencing some strange behavior with hash defaults and I'm wondering if somebody can help me understand this: https://gist.github.com/pizzaops/5502cd81c661d698bc15668234e1a7d4
[23:15:48] ramfjord: has joined #ruby
[23:15:55] pizzaops: specifically, I don't understand why `#keys` returns nothing etc
[23:16:05] grilix_: has joined #ruby
[23:16:08] pizzaops: you can still retrieve the value so clearly it's set
[23:16:26] pizzaops: but you can't loop, etc
[23:17:33] baweaver: pizzaops: https://medium.com/@baweaver/abusing-hash-constructors-65d59c0a5b27
[23:17:35] baweaver: Read through that
[23:18:13] baweaver: basically each and every single new key points to that same array
[23:18:20] baweaver: make it into a variable and keep dumping things into it
[23:18:37] pizzaops: i didn't realize i was updating the default
[23:18:39] baweaver: What you want instead is this: Hash.new { |h,k| h[k] = [] }
[23:19:03] baweaver: which invokes that function for every "new" key, setting the default to a new hash in the function
[23:19:20] pizzaops: i don't think this is uh
[23:19:22] pizzaops: the ideal behavior
[23:19:25] pizzaops: but thanks!
[23:19:38] baweaver: Same thing happens in Python
[23:19:51] baweaver: try and array default value, loads of fun.
[23:20:25] baweaver: The fun thing though is that because it's defined in a function, you have a ton of control over what it becomes
[23:20:50] baweaver: Like this fine beauty of code
[23:21:22] baweaver: >> vivified_hash = Hash.new { |h,k| h[k] = Hash.new(&h.default_proc) }; h[1][2][3][4][5] = 6; h
[23:21:24] ruby[bot]: baweaver: # => undefined local variable or method `h' for main:Object (NameError) ...check link for more (https://eval.in/1012874)
[23:21:35] baweaver: >> vivified_hash = Hash.new { |h,k| h[k] = Hash.new(&h.default_proc) }; vivified_hash[1][2][3][4][5] = 6; vivified_hash
[23:21:36] ruby[bot]: baweaver: # => {1=>{2=>{3=>{4=>{5=>6}}}}} (https://eval.in/1012876)
[23:22:19] emilford: has joined #ruby
[23:22:44] pizzaops: :hail_satan:?
[23:23:31] baweaver: >> factorial = Hash.new { |h,k| h[k] = k < 2 ? k : k * h[k - 1] }; factorial[5]; factorial
[23:23:32] ruby[bot]: baweaver: # => {1=>1, 2=>2, 3=>6, 4=>24, 5=>120} (https://eval.in/1012879)
[23:23:52] baweaver: point being, it's flexible
[23:23:57] SCHAPiE: has joined #ruby
[23:25:09] baweaver: The real fun is when you realize that hash, array, and proc all have a [] method
[23:25:19] pizzaops: you can index into a proc?
[23:25:22] baweaver: meaning you can return a lambda function instead of a hash or an array to do more fun things
[23:25:32] pizzaops: sorry i think of [] as indexing
[23:25:37] pizzaops: e.g. foo['bar']
[23:25:55] pizzaops: (i'm a lowly ops person who codes to automate, i don't write "real software")
[23:26:08] baweaver: >> adder = -> a { -> b { a + b } }; [1,2,3].map(&adder[5])
[23:26:09] ruby[bot]: baweaver: # => [6, 7, 8] (https://eval.in/1012880)
[23:26:28] baweaver: Ah foo with that. I've done ops for years, it's plenty real software
[23:26:59] willmichael: has joined #ruby
[23:27:06] baweaver: and starting in July I'm going back to ops
[23:27:17] baweaver: or SRE, or DevOps, or whatever in the world else they call it these days.
[23:27:47] havenwood: Snow Removal Engineer
[23:28:10] baweaver: Anyways, point being automation is real software. If it's written in a programming language it's real software.
[23:28:38] havenwood: and people who write programs are programmers!
[23:28:40] baweaver: Too many gate keepers wanting to sound high and mighty, honestly. Just ignore them.
[23:29:05] havenwood: baweaver: I agree.
[23:29:31] baweaver: Though [] is technically "call" for procs
[23:29:37] baweaver: screwy, no?
[23:31:42] Trevoke: has joined #ruby
[23:34:21] cschneid: has joined #ruby
[23:34:44] Trevoke: Hi all, I've got a doozy of a question. Is it possible to dynamically define named parameters for the instantiation of a new object? In essence, I _think_ I'm asking if I can dynamically define named parameters for an overridden class-level new method, so I _think_ I'm asking about passing dynamic names as block arguments to define_method and define_singleton_method but I could absolutely be wrong...
[23:34:48] mikecmpbll: has joined #ruby
[23:35:15] baweaver: What're you trying to do?
[23:35:32] Trevoke: So I have this hacky thing going: https://github.com/Trevoke/insane-hook
[23:35:39] Trevoke: (simple small readme)
[23:36:01] Trevoke: and I'd like to see if I can dial up the idiomatic feel of it by actually using named parameters instead of just faking it.
[23:36:32] Trevoke: For a second, let's completely ignore whether this is complete overkill and whether the idea itself is idiomatic Ruby or not :D
[23:36:54] baweaver: **kwargs, define_method, instance_eval
[23:37:23] baweaver: now that said, command patterns are next to completely unnecessary in languages which have functions
[23:38:17] baweaver: https://github.com/mariofusco/from-gof-to-lambda/tree/master/src/main/java/org/mfusco/fromgoftolambda/examples/command
[23:38:56] mikecmpbll: has joined #ruby
[23:39:39] baweaver: #1 and #2 are kinda flawed premises. Call is a method on a function, and functions should have arguments.
[23:39:49] Trevoke: You're suggesting that I can do something like `define_singleton_method(:new) do |instance_eval(x):|` ?
[23:40:23] p0p0pr37_: has joined #ruby
[23:40:23] p0p0pr37_: has joined #ruby
[23:40:27] Trevoke: Yeah. I also realized that I need to implement ===(foo) if I want it to be usable fully like a proc or some other object so I need to make changes to that.
[23:43:58] csk157: has joined #ruby
[23:45:09] Trevoke: **kwargs is the splat operator, it's what I'm currently using and I don't really get named arguments that way -- not pure anyway. I can fake it the way I am now and I could even raise the same error Ruby is raising if I wanted, but I don't know what to do with that otherwise. I don't know where to plug in the instance_eval - I know I can do `define_singleton_method(:new) do |x:|` and that'll work, but of course that's a hardcoded name
[23:45:09] Trevoke: parameter.
[23:47:59] Trevoke: Oh.. You're saying to use instance_eval and eval the string
[23:48:08] Trevoke: Ugh, I don't know if that's dirtier than I want to go.
[23:56:57] lxsameer: has joined #ruby
[23:57:10] ramfjord: sweet jesu that
[23:57:45] Trevoke: What, my horrible horrible hack?