« Back to channel list

#ruby - 31 October 2017

« Back 1 day Forward 1 day »
[00:00:12] baweaver: and I am baweaver
[00:00:23] baweaver: so what did you get when you tried that?
[00:00:46] dalitom: I was getting weird s%$^
[00:00:56] dalitom: and got frustrated
[00:01:09] dalitom: it has been a long day
[00:03:21] darix: >> "/home/eail\r\n/home/dtomic/".lines
[00:03:22] ruby[bot]: darix: # => ["/home/eail\r\n", "/home/dtomic/"] (https://eval.in/889751)
[00:03:58] darix: dalitom: "/home/eail\r\n/home/dtomic/".each_line { |l| puts l.chomp }
[00:04:34] havenwood: or in Ruby 2.4+: lines(chomp: true)
[00:05:17] ElDoggo: has joined #ruby
[00:06:07] Technodrome: has joined #ruby
[00:07:10] agent_white: has joined #ruby
[00:09:36] jphase: has joined #ruby
[00:10:32] al2o3-cr: why can chomp take any truthy value?
[00:18:05] darix: al2o3-cr: i think you pass a hash with the option chomp set to true into the lines function. :P
[00:19:13] al2o3-cr: darix: i mean why does lines(chomp: []/!p/42...) etc work?
[00:19:47] cagomez: has joined #ruby
[00:20:51] idefine: has joined #ruby
[00:21:04] darix: havenwood: https://ruby-doc.org/core-2.4.2/String.html#method-i-lines - that isnt documented
[00:21:39] apeiros: has joined #ruby
[00:24:39] RougeRR: has joined #ruby
[00:25:31] havenwood: darix: It'd be nice to document, agreed.
[00:27:37] ElDoggo: has joined #ruby
[00:28:58] raatiniemi: has joined #ruby
[00:41:52] nb_bez_______: has joined #ruby
[00:54:22] workmad3: has joined #ruby
[00:54:39] whippythellama: has joined #ruby
[00:56:35] dstrunk: has joined #ruby
[00:56:59] bmurt: has joined #ruby
[00:57:00] guacamole: has joined #ruby
[00:57:35] cagomez: has joined #ruby
[01:01:24] uZiel: has joined #ruby
[01:05:40] kculpis: has joined #ruby
[01:06:13] Psybur: has joined #ruby
[01:08:27] guille-moe: has joined #ruby
[01:09:00] Jameser: has joined #ruby
[01:11:03] DTZUZO: has joined #ruby
[01:11:37] sepp2k: has joined #ruby
[01:11:38] jaegerca: has joined #ruby
[01:11:41] jaegerca: If I had a bunch or Articles that belonged to Categories in my Blog - would you perfer Blog::Category and Blog::Article, or Category and Article, or BlogCategory and BlogArticle?
[01:12:41] jaegerca: (I am crossposting this in rails because I am curious about opinions)
[01:15:24] Papierkorb: jaegerca: I don't use Rails. Though for that, I'd use a structure akin to Model::Category, Model::Article, ..
[01:15:26] jaegerca: has left #ruby: ()
[01:15:27] guacamole: has joined #ruby
[01:15:30] jaegerca: has joined #ruby
[01:15:50] Papierkorb: jaegerca: Basically, I always do WhatItIs::TheThingItself
[01:16:29] jaegerca: Papierkorb: But you would keep article and blog on the "top level" of the Model namespace.
[01:16:35] Papierkorb: Keeps the hierarchy flat, clutter to a minimum, and keeps naming-spam low
[01:16:37] jaegerca: or article and category rather
[01:17:05] jaegerca: Papierkorb: What if you expect this application to grow quite large - and other things end up with categories?
[01:17:40] jaegerca: I ask because I always seem to regret not namespacing in every project, but I feel I end up just making more namespaces than I should be before I actually need them.
[01:17:49] Papierkorb: There's nothing wrong with a Model::FooCategory
[01:18:27] dar123: has joined #ruby
[01:18:27] Papierkorb: It's X::Y, rarely deeper than that (by design). I don't count a top-level module (for the lib or the application) in that
[01:18:33] jaegerca: Papierkorb: I tend to agree, but it seems cluttery to me - just from a ocd sort of viewpoint.
[01:18:53] Papierkorb: From my experience, it works really good for small to mid-size applications
[01:19:26] Papierkorb: mid-size is <100k SLOC. Don't have much experience after that, though I guess it needs another hierarchy layer at that point
[01:20:07] jaegerca: I think I would like to end up exploring microservices more with my code using docker and DevOps, then using services as "namespaces" instead.
[01:20:08] Papierkorb: jaegerca: If it looks cluttery to you, then you don't have proper rules in place.
[01:20:21] jaegerca: Papierkorb: That could be true
[01:20:23] Papierkorb: I employ a strict naming convention
[01:20:35] jaegerca: What convention is that?
[01:21:02] alfiemax: has joined #ruby
[01:21:35] Papierkorb: E.g., the module is never plural. `Model`, not `Models`. Naming overlap is not a bug, but a feature: `Importer::User` and `Model::User` is great
[01:22:38] jphase: has joined #ruby
[01:22:39] jaegerca: Papierkorb: How many models do you think you end up with on some of your larger projects?
[01:22:48] Papierkorb: And if you have something that doesn't fit anywhere, it doesn't fit anywhere. Create a new module for that. If it turns out to be bad, moving a class around is easy
[01:22:52] mkroman: has joined #ruby
[01:24:51] Papierkorb: jaegerca: I don't employ strict MVC, counting in models doesn't make much sense
[01:26:58] csk157: has joined #ruby
[01:27:38] jaegerca: Papierkorb: Ok, well I appreciate your answers!
[01:27:54] apeiros: has joined #ruby
[01:28:44] Papierkorb: jaegerca: Embrace the chaos if there is no possible order. Don't solve local issues globally, and don't solve global issues locally.
[01:29:29] ElDoggo: has joined #ruby
[01:29:53] Papierkorb: jaegerca: And if you want a well-understood hammer, see SOLID is .. well .. more often than not .. solid
[01:30:16] Papierkorb: Except when it overcomplicates things and then it's fragile. ah well.
[01:30:39] ElDoggo_: has joined #ruby
[01:31:29] hahuang65: has joined #ruby
[01:32:04] jaegerca: Papierkorb: "Don't solve local issues globally, and don't solve global issues locally" I like that
[01:32:08] jaegerca: What is SOLID?
[01:32:38] ElDoggo__: has joined #ruby
[01:33:22] Papierkorb: google "SOLID principles", there are posts on it for ruby, though it originated in Java (coined by the GOF 'Gang of Four'). Basically, they're patterns on how to model your classes
[01:33:46] jaegerca: Papierkorb: Oh, I love Gang of Four, I have the ruby version right here!
[01:34:41] idefine: has joined #ruby
[01:36:51] knight33: has joined #ruby
[01:41:12] enterprisey: has joined #ruby
[01:42:39] apeiros: has joined #ruby
[01:43:31] eckhardt: has joined #ruby
[01:43:35] orbyt_: has joined #ruby
[01:50:15] cagomez: has joined #ruby
[01:52:38] arescorpio: has joined #ruby
[01:54:00] PresidentBiscuit: has joined #ruby
[01:54:17] idefine: has joined #ruby
[01:55:44] jphase: has joined #ruby
[01:59:37] guacamole: has joined #ruby
[02:00:29] apeiros: has joined #ruby
[02:01:40] mkroman: has joined #ruby
[02:02:26] dar123: has joined #ruby
[02:02:37] idefine_: has joined #ruby
[02:03:08] gizmore|2: has joined #ruby
[02:03:44] idefine__: has joined #ruby
[02:04:41] iMadper: has joined #ruby
[02:05:01] idefine_: has joined #ruby
[02:06:49] znz_jp: has joined #ruby
[02:11:46] d^sh: has joined #ruby
[02:13:59] apeiros: has joined #ruby
[02:14:14] jenrzzz: has joined #ruby
[02:14:14] jenrzzz: has joined #ruby
[02:21:46] idefine: has joined #ruby
[02:21:48] cdg: has joined #ruby
[02:23:15] ElDoggo__: has joined #ruby
[02:26:22] ElDoggo: has joined #ruby
[02:26:38] ElDoggo: has joined #ruby
[02:27:05] vipaca: has joined #ruby
[02:28:08] ElDoggo: has joined #ruby
[02:29:08] raatiniemi: has joined #ruby
[02:30:36] Synthead: has joined #ruby
[02:32:03] Synthead: is there a way to check if n is an index of an array without doing something like n >= 0 && n < a.count ?
[02:32:31] Synthead: i.e. (making this up) s.exists?(2)
[02:38:37] cdg: has joined #ruby
[02:39:47] apeiros: has joined #ruby
[02:43:01] mson: has joined #ruby
[02:46:59] jenrzzz: has joined #ruby
[02:46:59] jenrzzz: has joined #ruby
[02:47:13] Fridtjof: has joined #ruby
[02:47:43] jphase: has joined #ruby
[02:49:16] PresidentBiscuit: has joined #ruby
[02:50:28] chouhoulis: has joined #ruby
[02:51:28] apeiros: has joined #ruby
[02:51:40] Heph_: has joined #ruby
[02:54:24] dstrunk: has joined #ruby
[02:55:00] workmad3: has joined #ruby
[03:00:08] cadillac_: has joined #ruby
[03:05:26] alfiemax: has joined #ruby
[03:07:00] sspreitz: has joined #ruby
[03:07:48] tastytf: has joined #ruby
[03:09:24] jphase: has joined #ruby
[03:13:13] uZiel: has joined #ruby
[03:14:28] alex``: has joined #ruby
[03:20:02] apeiros: has joined #ruby
[03:24:43] Jameser`: has joined #ruby
[03:41:00] enterprisey: has joined #ruby
[03:45:26] eckhardt: has joined #ruby
[03:47:02] Freshnuts: has joined #ruby
[03:49:59] raul782: has joined #ruby
[03:51:57] bmurt: has joined #ruby
[04:03:05] rhyselsmore: has joined #ruby
[04:07:00] arescorpio: has joined #ruby
[04:09:39] guacamole: has joined #ruby
[04:11:28] eb0t: has joined #ruby
[04:14:06] eblip: has joined #ruby
[04:20:36] Xeago_: has joined #ruby
[04:20:43] Pierreb: has joined #ruby
[04:21:45] mozzarel1: has joined #ruby
[04:21:57] Devalo: has joined #ruby
[04:22:20] Jameser: has joined #ruby
[04:22:24] jidar: has joined #ruby
[04:24:14] sunrunner20: has joined #ruby
[04:24:15] quiller: has joined #ruby
[04:24:35] ephemera_: has joined #ruby
[04:24:39] havenwood: has joined #ruby
[04:24:39] havenwood: has joined #ruby
[04:24:49] bogdanteleaga: has joined #ruby
[04:24:54] esObe: has joined #ruby
[04:25:08] fumk: has joined #ruby
[04:25:13] chrisarcand: has joined #ruby
[04:25:13] boshhead: has joined #ruby
[04:25:36] marens: has joined #ruby
[04:25:36] marens: has joined #ruby
[04:25:54] coderphive: has joined #ruby
[04:27:19] alfiemax: has joined #ruby
[04:27:28] Lyfe: has joined #ruby
[04:29:05] csk157: has joined #ruby
[04:29:27] govg: has joined #ruby
[04:29:43] alfiemax_: has joined #ruby
[04:31:57] apeiros: has joined #ruby
[04:36:17] alfiemax: has joined #ruby
[04:37:55] Cyrus: Synthead: Why not try and access s[n] and check if it's nil or not?
[04:46:27] jrm: has joined #ruby
[04:47:31] jxv: has joined #ruby
[04:48:23] gix: has joined #ruby
[04:48:52] ephemera_: has joined #ruby
[04:49:47] benjen: has joined #ruby
[04:49:58] thinkpad: has joined #ruby
[04:53:45] claw: has joined #ruby
[04:55:36] workmad3: has joined #ruby
[04:58:26] Mia: has joined #ruby
[04:58:26] Mia: has joined #ruby
[04:59:03] guacamole: has joined #ruby
[04:59:33] apeiros: has joined #ruby
[05:10:42] EXCHGR: has joined #ruby
[05:15:43] iMadper: has joined #ruby
[05:25:54] hutch34: has joined #ruby
[05:27:25] iamarun: has joined #ruby
[05:29:25] allcentury: has joined #ruby
[05:31:25] enterprisey: has joined #ruby
[05:38:23] k3rn31: has joined #ruby
[05:38:39] Dimik: has joined #ruby
[05:42:23] aupadhye: has joined #ruby
[05:45:54] anisha: has joined #ruby
[05:48:37] jenrzzz: has joined #ruby
[05:48:37] jenrzzz: has joined #ruby
[05:52:07] raul782: has joined #ruby
[05:52:14] houhoulis: has joined #ruby
[05:58:49] [reed]: has joined #ruby
[05:58:49] [reed]: has joined #ruby
[06:04:49] Jameser: has joined #ruby
[06:05:14] apeiros: has joined #ruby
[06:07:26] iamarun: Anyone can point me to ruby rails development ( i am intrested in ruby rails ) have worked in codeigniter
[06:07:51] iamarun: and is there any good tutorial for setting up development environment and bits and bolts
[06:13:38] baweaver: iamarun: #RubyOnRails would be a good channel
[06:13:46] baweaver: Though I would learn Ruby first
[06:13:56] baweaver: unless you've already programmed in another language
[06:13:57] iamarun: yes i know ruby a little
[06:14:20] iamarun: i just went through some tutorials
[06:14:37] baweaver: Eloquent Ruby would be a good book to ensure you're at a good level if you want something to look into first.
[06:14:47] baweaver: What OS are you on?
[06:14:57] iamarun: linux arch
[06:15:38] baweaver: If you translate the Debian package management this should get you going - http://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you
[06:16:18] iamarun: can i ask one question ? do we really need rvm and rbenv
[06:16:29] iamarun: is it important
[06:16:35] iamarun: to have them installed
[06:16:40] baweaver: We don't really keep count of questions :)
[06:16:54] baweaver: It will make it easier on you later on if you need other versions
[06:17:02] baweaver: or if you need to upgrade
[06:17:14] baweaver: package managers are notoriously out of date
[06:19:14] baweaver: It'll make it easier in the long run but slightly harder to get started
[06:19:38] baweaver: For someone just playing with Ruby I don't think it's necessary, but for a developer it probably is
[06:19:52] duderonomy: has joined #ruby
[06:22:11] rabajaj: has joined #ruby
[06:24:25] elomatreb: iamarun: If you're on Arch you're probably OK without them unless you actually need to switch versions, the Arch repos contain up-to-date Ruby versions
[06:25:15] iamarun: @elomatreb thanks
[06:26:06] iamarun: and good IDE for rails
[06:26:11] iamarun: have sublime text
[06:27:15] elomatreb: RubyMine (Jetbrains) is probably the only popular IDE in the classic sense, but it's perfectly reasonable to just use a normal text editor
[06:27:40] elomatreb: The dynamic nature of a lot of Ruby code limits the amount of work IDEs can do for you (e.g. autocomplete)
[06:28:04] dionysus69: has joined #ruby
[06:30:25] chmurifree: has joined #ruby
[06:30:49] csk157: has joined #ruby
[06:32:28] reber: has joined #ruby
[06:36:33] iamarun: okay thanks
[06:43:35] nephelo: has joined #ruby
[06:43:37] jphase: has joined #ruby
[06:50:39] enterprisey: has joined #ruby
[06:52:46] jphase: has joined #ruby
[06:56:17] workmad3: has joined #ruby
[06:57:56] cgfbee: has joined #ruby
[07:00:39] alfiemax: has joined #ruby
[07:05:20] kapil___: has joined #ruby
[07:06:33] jphase: has joined #ruby
[07:09:05] harfangk: has joined #ruby
[07:09:17] apeiros: has joined #ruby
[07:14:36] snickers: has joined #ruby
[07:16:49] iMadper`: has joined #ruby
[07:17:36] allcentury: has joined #ruby
[07:18:57] Jameser: has joined #ruby
[07:20:46] alfiemax: has joined #ruby
[07:21:40] claudiuinberlin: has joined #ruby
[07:21:44] alfiemax: has joined #ruby
[07:22:29] enterprisey: has joined #ruby
[07:35:40] ur5us: has joined #ruby
[07:38:28] DTZUZO: has joined #ruby
[07:40:20] Jameser: has joined #ruby
[07:42:25] quobo: has joined #ruby
[07:47:19] conta: has joined #ruby
[07:54:15] alfiemax: has joined #ruby
[07:58:36] irick: has joined #ruby
[07:58:51] aufi: has joined #ruby
[08:07:00] mn3m: has joined #ruby
[08:07:13] burgestrand: has joined #ruby
[08:11:17] MrBismuth: has joined #ruby
[08:14:37] ta: has joined #ruby
[08:22:24] Jameser: has joined #ruby
[08:32:22] morfin: has joined #ruby
[08:33:34] morfin: i am running rspec to test standalone code also use dotenv(and ActiveRecord). How do i set env to test when running rspec?
[08:33:47] morfin: *when executing
[08:48:07] ur5us_: has joined #ruby
[08:51:10] ur5us: has joined #ruby
[08:52:31] alfiemax_: has joined #ruby
[08:55:14] tomphp: has joined #ruby
[08:56:40] jphase: has joined #ruby
[08:56:47] mikecmpbll: has joined #ruby
[08:57:00] ur5us: has joined #ruby
[08:57:02] workmad3: has joined #ruby
[09:02:22] jphase: has joined #ruby
[09:04:23] jaruga: has joined #ruby
[09:04:52] jaruga: has joined #ruby
[09:05:33] tomphp: has joined #ruby
[09:05:37] allcentury: has joined #ruby
[09:05:51] iamarun: has joined #ruby
[09:11:11] alfiemax: has joined #ruby
[09:11:42] jphase: has joined #ruby
[09:12:43] doublemalt_: has joined #ruby
[09:12:51] ta: has joined #ruby
[09:13:51] doublemalt_: has joined #ruby
[09:14:57] alex``: has joined #ruby
[09:16:04] ur5us: has joined #ruby
[09:19:29] yottanami: has joined #ruby
[09:20:10] yottanami: Whatis the different between def class_name.method_name and def method_name in Ruby?
[09:21:07] mim1k: has joined #ruby
[09:21:35] tobiasvl: yottanami: one defines a class method and the other an instance method
[09:22:18] reber: has joined #ruby
[09:26:23] jenrzzz: has joined #ruby
[09:26:23] jenrzzz: has joined #ruby
[09:27:11] apeiros: and to be more generic, `def obj.method_name` defines a method for obj itself, while `def meth_name` defines one for the instances of a class/module
[09:27:23] apeiros: class methods being the most prominent use case
[09:27:38] morfin: how i should specify APP_ENV to connect to test database instead of connecting to development one?
[09:28:06] apeiros: >> x = "demo string"; def x.randcase; x.chars.map { |c| rand < 0.5 ? c.upcase : c.downcase }.join; end; x.randcase
[09:28:07] ruby[bot]: apeiros: # => undefined local variable or method `x' for "demo string":String (NameError) ...check link for more (https://eval.in/889944)
[09:28:17] apeiros: >> x = "demo string"; def x.randcase; chars.map { |c| rand < 0.5 ? c.upcase : c.downcase }.join; end; x.randcase
[09:28:22] ruby[bot]: apeiros: # => "DemO StRiNG" (https://eval.in/889945)
[09:28:41] apeiros: morfin: wrong channel? or just lack of context?
[09:29:19] morfin: i have config/boot.rb which perform connect to database, also it loads dotenv, my rspec require it but default env is development. should i specify env in rspec_helper.rb then(before requiring boot.rb)?
[09:29:41] apeiros: a little bird tells me you might be using rails?
[09:29:59] jphase: has joined #ruby
[09:29:59] apeiros: then you're definitively omitting relevant context. lots.
[09:31:33] yCrazyEdd: has joined #ruby
[09:33:04] helpa-bot: has joined #ruby
[09:33:11] csk157: has joined #ruby
[09:34:07] houhoulis: has joined #ruby
[09:34:09] morfin: this part of application is standalone. I have config/boot.rb which 1. Load bundle. 2. Require some classes(like 'mysql2', 'activerecord'). 3. Load config from database.yml(using code similar to one in Rails). 4. ActiveRecord::Base.establish_connection DATABASE_CONFIG[env] but there is one problem: database.yml i need somehow specify environment for rspec to use test instead of development from
[09:34:09] morfin: database.yml
[09:34:40] aufi: has joined #ruby
[09:35:03] helpa: has joined #ruby
[09:35:28] morfin: rspec_helper.rb require config/boot.rb to load all required classes, establish connection etc, of course i can run like this: APP_ENV=test bundle exec rspec but i don't like this idea because i assume rspec would be used only with test environment
[09:35:31] guille-moe: has joined #ruby
[09:35:43] Jameser`: has joined #ruby
[09:36:28] apeiros: set it in one of the rspec exclusive files if it isn't already set
[09:36:41] apeiros: I wouldn't set it unconditionally, otherwise you lose the ability to override
[09:37:47] G: has joined #ruby
[09:39:05] jphase: has joined #ruby
[09:39:08] cdg: has joined #ruby
[09:39:56] kenichi: has joined #ruby
[09:41:42] hs366: has joined #ruby
[09:43:26] tris: has joined #ruby
[09:44:43] Serpent7776: has joined #ruby
[09:49:29] bruno-: has joined #ruby
[09:49:53] p0p0pr37_: has joined #ruby
[09:49:53] p0p0pr37_: has joined #ruby
[09:51:33] Beams: has joined #ruby
[09:52:51] rabajaj: has joined #ruby
[09:52:59] jphase: has joined #ruby
[09:54:46] fullstack: has joined #ruby
[09:56:23] aclark: has joined #ruby
[09:57:07] Kyle__: has joined #ruby
[10:00:53] helpa: has joined #ruby
[10:01:11] SpComb^: has joined #ruby
[10:01:21] sirecote_: has joined #ruby
[10:01:40] TheRealMattM: has joined #ruby
[10:01:41] connor_goodwolf: has joined #ruby
[10:01:42] Cyrus: has joined #ruby
[10:01:53] aupadhye: has joined #ruby
[10:01:59] nikivi: has joined #ruby
[10:02:01] biox: has joined #ruby
[10:02:01] gnarf: has joined #ruby
[10:02:10] baweaver: has joined #ruby
[10:02:12] creeg: has joined #ruby
[10:02:13] Junaos: has joined #ruby
[10:02:14] nikkyjr: has joined #ruby
[10:02:15] leonthemisfit: has joined #ruby
[10:02:15] leonthemisfit: has joined #ruby
[10:02:23] arthurnn: has joined #ruby
[10:02:32] aclark: has joined #ruby
[10:02:44] cgfbee: has joined #ruby
[10:03:14] lxsameer: has joined #ruby
[10:06:26] mgorbach: has joined #ruby
[10:06:29] bokayio: has joined #ruby
[10:06:33] russt: has joined #ruby
[10:06:33] gf3: has joined #ruby
[10:06:36] Axsuul: has joined #ruby
[10:06:48] jphase: has joined #ruby
[10:06:50] halt: has joined #ruby
[10:07:06] mkaito: has joined #ruby
[10:07:15] WebDawg: has joined #ruby
[10:07:29] mim1k_: has joined #ruby
[10:08:18] hfp_work: has joined #ruby
[10:08:36] Exagone313: has joined #ruby
[10:09:14] jottr: has joined #ruby
[10:10:52] bauruine: has joined #ruby
[10:11:12] audy-: has joined #ruby
[10:11:14] tris: has joined #ruby
[10:11:51] justinmcp: has joined #ruby
[10:12:09] ski4x7: has joined #ruby
[10:12:13] ahuman: has joined #ruby
[10:13:32] dcluna: has joined #ruby
[10:16:01] jottr: has joined #ruby
[10:16:16] alfiemax: has joined #ruby
[10:17:00] ski7777: has joined #ruby
[10:17:44] hurricanehrndz: has joined #ruby
[10:18:02] mim1k: has joined #ruby
[10:20:15] ur5us: has joined #ruby
[10:23:27] Klumben: has joined #ruby
[10:23:51] CrazyEddy: has joined #ruby
[10:24:29] tris: has joined #ruby
[10:24:33] infernix: has joined #ruby
[10:25:16] Azure: has joined #ruby
[10:27:08] cadillac_: has joined #ruby
[10:28:24] jenrzzz: has joined #ruby
[10:28:24] jenrzzz: has joined #ruby
[10:29:34] johnny56: has joined #ruby
[10:30:11] alfiemax: has joined #ruby
[10:30:48] alfiemax_: has joined #ruby
[10:32:50] bruce_lee: has joined #ruby
[10:32:50] bruce_lee: has joined #ruby
[10:33:39] DoubleMalt: has joined #ruby
[10:34:06] csk157: has joined #ruby
[10:34:12] jphase: has joined #ruby
[10:42:23] nikkyjr: has joined #ruby
[10:43:25] jphase: has joined #ruby
[10:43:50] mim1k: has joined #ruby
[10:46:30] aufi: has joined #ruby
[10:55:26] tomphp: has joined #ruby
[10:56:15] mim1k: has joined #ruby
[10:58:21] tobiasvl: http://ukupat.github.io/tabs-or-spaces/
[10:58:23] workmad3: has joined #ruby
[10:58:28] tobiasvl: ~100% of ruby repos use 2 tabs
[10:58:41] tomphp_: has joined #ruby
[10:59:30] apeiros: 2 tabs? :D
[11:00:23] apeiros: ACTION sticks to using 3 tabs for indent
[11:00:42] apeiros: ACTION sticks to using 1 tab + 1 space for indent, and tabs for alignment
[11:01:08] tobiasvl: sounds awesome
[11:01:26] michael1: has joined #ruby
[11:01:49] jphase: has joined #ruby
[11:02:49] apeiros: yeah, it's proven to increase engagement by users a lot! also the emotional level skyrocks!
[11:03:03] apeiros: the effects are truly amazing :D
[11:04:59] iamarun: has joined #ruby
[11:05:20] DaniG2k: has joined #ruby
[11:06:26] workmad3: has joined #ruby
[11:06:41] RougeRR: has joined #ruby
[11:15:32] jphase: has joined #ruby
[11:17:00] cabotto: has joined #ruby
[11:18:27] ldnunes: has joined #ruby
[11:24:46] jphase: has joined #ruby
[11:27:41] tcopeland: has joined #ruby
[11:28:14] morfin: i use 2 spaces for indent )
[11:29:17] morfin: i am not sure how would i rip off ActiveRecord migrations to standalone app
[11:31:02] tomphp: has joined #ruby
[11:31:08] mfaeh: has joined #ruby
[11:32:52] apparition: has joined #ruby
[11:37:06] ski7777: has joined #ruby
[11:42:35] ski7777: has joined #ruby
[11:43:02] harrison: has joined #ruby
[11:47:06] charliesome: has joined #ruby
[11:47:20] VladGh: has joined #ruby
[11:47:39] jottr: has joined #ruby
[11:49:25] mark_66: has joined #ruby
[11:52:14] jphase: has joined #ruby
[11:52:54] Quentinius: has joined #ruby
[12:00:49] tomphp: has joined #ruby
[12:01:54] synthroid: has joined #ruby
[12:02:09] Technodrome: has joined #ruby
[12:05:57] jphase: has joined #ruby
[12:07:06] elomatreb: apeiros: Use different width unicode spaces for the different levels of indentation
[12:08:56] mensvaga: has joined #ruby
[12:12:44] cadillac_: has joined #ruby
[12:15:24] jphase: has joined #ruby
[12:16:04] vondruch: has joined #ruby
[12:16:58] jphase_: has joined #ruby
[12:19:05] jphase__: has joined #ruby
[12:19:45] vondruch: has joined #ruby
[12:23:05] conta: has joined #ruby
[12:23:13] yottanami: Is any way to do sum two numbers without removing zeroes before each number? for example 002 + 1 = 003
[12:23:49] b0zz0: has joined #ruby
[12:25:46] evie_hammond: has joined #ruby
[12:26:52] jrafanie: has joined #ruby
[12:27:23] apeiros: elomatreb: ooooh! great idea!
[12:27:43] apeiros: elomatreb: though that requires non-monospaced fonts to take effect
[12:27:44] elomatreb: I can't think of any, can you maybe do normal addition, and then pad the number with 0s again when you want to use it? (e.g. "%02d" would pad an integer with 0s to length 2)
[12:27:53] elomatreb: yottanami: ^
[12:28:20] b0zz0_: has joined #ruby
[12:28:25] apeiros: yottanami: it's important to realize that the leading zeroes never are part of the number to begin with (or infinite number of leading zeroes are always part of it - depending on how you want to view it)
[12:28:37] apeiros: in other words: leading zeroes in numbers are *representation*
[12:28:53] elomatreb: I think php does something like that if you try to increment (++) a string of the form, btw
[12:28:54] apeiros: also note: literals in ruby with a leading zero are octals :)
[12:29:07] apeiros: >> "002".succ
[12:29:08] ruby[bot]: apeiros: # => "003" (https://eval.in/890067)
[12:29:23] KeyJoo: has joined #ruby
[12:30:20] tomphp: has joined #ruby
[12:30:46] bruno-: has joined #ruby
[12:30:57] jenrzzz: has joined #ruby
[12:30:57] jenrzzz: has joined #ruby
[12:33:54] evie_hammond: has joined #ruby
[12:35:01] csk157: has joined #ruby
[12:35:18] Hanmac: the best thing xD
[12:35:18] Hanmac: >> "1.2.9".succ
[12:35:19] ruby[bot]: hanmac: # => "1.3.0" (https://eval.in/890068)
[12:35:49] apeiros: too bad if you want "1.2.10"
[12:36:41] michael1: has joined #ruby
[12:38:50] zautomata: has joined #ruby
[12:40:42] jphase: has joined #ruby
[12:42:59] argoneus: has joined #ruby
[12:43:27] mim1k: has joined #ruby
[12:43:38] argoneus: I have a 'case' operator with about 15 "whens" doing a regex check on a string, basically I'm looking for substrings in the given string, and if there's a match, I want it to give a prepared response
[12:43:49] argoneus: thing is, rubocop complains about too high cyclomatic complexity
[12:43:50] zautomata: has joined #ruby
[12:43:55] argoneus: what's the ruby way to do this?
[12:44:16] elomatreb: If there's no nice higher-level solution to your problem I
[12:44:25] elomatreb: *I'd say disable that lint
[12:44:34] argoneus: ex.: case string\when /keyword/i then 'response'
[12:44:51] argoneus: it's part of a homework so I don't think I can just turn it off
[12:44:58] argoneus: but at the same time I can't think of a better solution
[12:45:32] elomatreb: Technically you can turn it off with a comment (`# rubocop:disable Lint/Whatever`, disables it for that and lower scopes)
[12:45:45] elomatreb: Or did you receive instructions not to do that?
[12:46:06] argoneus: yeah, rubocop shouldn't be touched afaik
[12:46:07] brw: has joined #ruby
[12:46:09] cabotto: has joined #ruby
[12:46:50] elomatreb: Can you extract the matching into a single regex? I.e. have it match and return the keyword in a matching group?
[12:46:52] mtkd: could put the case args in to an array and use each with a block
[12:47:06] elomatreb: Because if you do that you could just use the match data to lookup the message in a Hash
[12:47:27] argoneus: the keywords are wildly different
[12:47:32] argoneus: I need to do a separate lookup for each
[12:47:45] argoneus: I'll try the array approach
[12:48:15] mtkd: [[string, regex, response], [string, regex, response]].each { |a| ... }
[12:48:19] apeiros: isn't it great when externalities require a worse solution?
[12:48:34] elomatreb: That would probably work, but have a word with your instructor/etc about this. These lints are very subjective, and they are designed to be turned off when they're more harm than good
[12:49:09] argoneus: I'll send an email then, because I can't think of a cleaner solution than this
[12:49:40] elomatreb: In this case, you're being forced to increase your codes complexity because of a complexity lint. See the problem?
[12:50:33] apeiros: IMO either the problem can be restructured and be solved in smaller decision trees through the restructuring, or then case/when with 15 when's is better than the array solution
[12:50:51] mim1k: has joined #ruby
[12:50:55] Papierkorb: Or the instructor is looking for an entirely different solution
[12:51:48] cdg: has joined #ruby
[12:51:57] yottanami1: has joined #ruby
[12:52:16] vondruch: has joined #ruby
[12:52:53] kobain: has joined #ruby
[12:55:26] cdg: has joined #ruby
[12:56:46] Psybur: has joined #ruby
[12:57:39] alnewkirk: has joined #ruby
[13:00:55] chouhoulis: has joined #ruby
[13:02:13] tomphp: has joined #ruby
[13:03:54] dinfuehr: has joined #ruby
[13:04:13] mikecmpbll: has joined #ruby
[13:05:56] jphase: has joined #ruby
[13:08:07] PaulCape_: has joined #ruby
[13:11:17] chouhoulis: has joined #ruby
[13:12:00] sepp2k: has joined #ruby
[13:12:46] mson: has joined #ruby
[13:14:59] burgestrand: has joined #ruby
[13:15:02] tomphp: has joined #ruby
[13:16:21] yottanami__: has joined #ruby
[13:20:33] vtx: has joined #ruby
[13:22:15] alfiemax: has joined #ruby
[13:23:24] allcentury: has joined #ruby
[13:24:20] GodFather: has joined #ruby
[13:26:00] raul782: has joined #ruby
[13:28:11] apeiros: has joined #ruby
[13:31:23] raul782: has joined #ruby
[13:32:15] jenrzzz: has joined #ruby
[13:32:26] alfiemax_: has joined #ruby
[13:32:37] DLSteve: has joined #ruby
[13:33:29] mim1k: has joined #ruby
[13:36:17] csk157: has joined #ruby
[13:36:45] DTZUZO: has joined #ruby
[13:37:37] ldnunes: has joined #ruby
[13:37:41] jrafanie: has joined #ruby
[13:40:56] dinfuehr: has joined #ruby
[13:40:58] scorphus: has joined #ruby
[13:41:29] nowhere_man: has joined #ruby
[13:42:16] danielglh: has joined #ruby
[13:45:00] tomphp: has joined #ruby
[13:45:29] biberu: has joined #ruby
[13:46:47] nowhere_man: has joined #ruby
[13:47:35] xuanrui: has joined #ruby
[13:48:20] tsglove: has joined #ruby
[13:48:57] yottanami1: has joined #ruby
[13:49:57] ams__: has joined #ruby
[13:52:47] bruno-: has joined #ruby
[13:55:38] KtC00: has joined #ruby
[13:57:58] iMadper``: has joined #ruby
[14:05:12] mim1k: has joined #ruby
[14:06:20] mgorbach: has joined #ruby
[14:07:51] harrison: has joined #ruby
[14:13:06] uZiel: has joined #ruby
[14:14:38] jxv: has joined #ruby
[14:16:04] polishdub: has joined #ruby
[14:16:17] cabotto: has joined #ruby
[14:17:19] tomphp: has joined #ruby
[14:17:54] johno84: has joined #ruby
[14:18:35] anisha: has joined #ruby
[14:19:52] uZiel: has joined #ruby
[14:20:55] Axy: has joined #ruby
[14:21:03] Technodrome: has joined #ruby
[14:22:20] djbjd: has joined #ruby
[14:26:22] brendan-: has joined #ruby
[14:26:31] tomphp: has joined #ruby
[14:29:25] ta: has joined #ruby
[14:30:10] techn1cs: has joined #ruby
[14:32:27] minimalism: has joined #ruby
[14:32:52] vtx_: has joined #ruby
[14:34:02] jxv: has joined #ruby
[14:34:21] Rapture: has joined #ruby
[14:35:12] houhoulis: has joined #ruby
[14:39:06] veeti: has joined #ruby
[14:39:41] connor_goodwolf: has joined #ruby
[14:40:26] mim1k: has joined #ruby
[14:41:08] iMadper``: has joined #ruby
[14:43:54] pskosinski_: has joined #ruby
[14:44:02] burgestrand: has joined #ruby
[14:44:13] Xeago_: has joined #ruby
[14:45:34] alfiemax: has joined #ruby
[14:45:55] rgs: has joined #ruby
[14:46:43] Gadgetoid: has joined #ruby
[14:47:07] duracrisis: has joined #ruby
[14:47:55] qsx: has joined #ruby
[14:49:04] alfiemax: just noticed something weird
[14:49:32] alfiemax: https://gist.github.com/alfie-max/632c7d4a82652c6eafb14e975a5e6c96
[14:49:39] alfiemax: can someone tell me what's going on..
[14:49:54] orbyt_: has joined #ruby
[14:50:25] scatterp: has joined #ruby
[14:51:17] scatterp: hi i am using ruby 2.2.1 (and i am unable to update at this time) I am trying to download a page over https and each method i try the system freezes up
[14:52:26] chmurifree: has joined #ruby
[14:52:51] elomatreb: alfiemax: Maybe this helps: https://eval.in/890261 - You're assigning the same array object to all keys. To get a Hash that behaves like you expect use the block form, `h = Hash.new { [] }`
[14:54:06] apeiros: elomatreb: I don't think that works as intended
[14:54:08] cagomez: has joined #ruby
[14:54:36] matthewd: scatterp: "freezes"? "the system"?
[14:54:49] apeiros: remember, the block doesn't perform any mutation on the hash on its own
[14:54:55] apeiros: it's just a return value.
[14:54:56] elomatreb: Yeah you're right, nevermind. You need the self-accessing form
[14:55:02] scatterp: matthewd ctrl c works
[14:55:11] apeiros: most likely `h = Hash.new { |h,k| h[k] = [] }` is desired
[14:55:34] elomatreb: Right, I always make that mistake. Hash constructor is confusing as hell
[14:56:12] apeiros: I think it's not, if you remember to think of it as a default value
[14:56:41] matthewd: That actually seems like a useful core extension -- a new class method that does the assignment automatically
[14:56:54] apeiros: (well, certainly confusing the first time you come across it, but IMO it makes sense the moment you think about it)
[14:57:15] elomatreb: apeiros: It's confusing since it does work with integers, and that specific behavior is often shown in tutorials
[14:57:29] elomatreb: Well, numerics
[14:57:55] shinnya: has joined #ruby
[14:58:24] elomatreb: >> h = Hash.new(3); h[:a] += 1; h
[14:58:25] ruby[bot]: elomatreb: # => {:a=>4} (https://eval.in/890279)
[14:58:33] scatterp: matthewd heres the output http://paste.ubuntu.com/25859278/ and code
[14:58:42] darkmorph: has joined #ruby
[15:00:07] apeiros: elomatreb: it "works" with immutables in general. for the very reason that you can't mutate them ;-)
[15:01:12] kculpis: has joined #ruby
[15:01:14] elomatreb: Yeah - but that requires that one understands the principle of immutables. I don't like this behavior, I'd very much enjoy a Hash constructor that Does What I Mean without me having to google for that self-accessing block
[15:01:17] apeiros: they definitively should add a warning to the docs
[15:01:22] apeiros: ACTION just reread them
[15:01:44] apeiros: elomatreb: that's not possible, though. what you mean is very subjective.
[15:02:05] apeiros: and it does a good job of doing what you tell it to do.
[15:02:07] matthewd: scatterp: Is this a VM/container of some sort? Does it have network access?
[15:02:34] apeiros: and blockless with mutables is difficult/impossible since there's no clear way to duplicate the object
[15:03:15] elomatreb: *I don't need blockless, that that wouldn't work is OK with me. But I'd like a block one where I don't have to do the assignment like that myself
[15:03:17] matthewd: apeiros: I agree it's not desirable to change .new -- but I think `def Hash.foo; new {|h,k| h[k] = yield k }; end` would be a frequently-useful shortcut
[15:03:31] elomatreb: ^ Just like that
[15:03:43] apeiros: with the advent of named args, they could be more explicit and have specific arguments to new for "only return this value" and "return and assign this value"
[15:04:23] apeiros: e.g. h = Hash.new default_and_assign: -> { [] }; h[:x]; h # => {x => []}
[15:04:44] apeiros: (better naming welcome of course)
[15:05:04] matthewd: That seems a long way to go just to keep 'new' ¯\_(ツ)_/¯
[15:05:05] apeiros: vs. h = Hash.new default_no_assign: -> { [] }; h[:x]; h # => {}
[15:05:21] apeiros: as said, better naming welcome. or as you said, have a convenience constructor.
[15:05:40] elomatreb: This feels like something activesupport would have hidden somewhere
[15:06:26] cschneid_: has joined #ruby
[15:07:04] jxv: has joined #ruby
[15:07:09] jottr: has joined #ruby
[15:07:47] scatterp: matthewd heres the output http://paste.ubuntu.com/25859278/ and code any ideas?
[15:07:49] matthewd: Even better: def Hash.foo(v = nil); new {|h,k| h[k] = block_given? ? yield(k) : v.dup }; end
[15:08:31] apeiros: why dup and not clone?
[15:08:39] matthewd: [11-01 01:32:04] <matthewd> scatterp: Is this a VM/container of some sort? Does it have network access?
[15:08:57] uZiel: has joined #ruby
[15:09:31] vipaca: has joined #ruby
[15:10:00] matthewd: Mostly just because I default to dup, and didn't really think about it
[15:10:26] scatterp: matthewd no standard ubuntu 16.04 remove the s in https and it works
[15:11:11] matthewd: One could argue that it should be a deep clone, too, for that matter.. I'm only really anticipating the trivial {} and [] cases
[15:11:44] matthewd: scatterp: Can you wget/curl that URL from that machine?
[15:12:20] matthewd: scatterp: It's not a virtual machine? It's a physical computer named "vmi146463" with a "deploy" user?
[15:12:45] rippa: has joined #ruby
[15:13:58] scatterp: matthewd ah sorry its a vps from contabo.com
[15:15:15] impermanence: has joined #ruby
[15:15:45] zcreative_: has joined #ruby
[15:15:47] CrazyEddy: has joined #ruby
[15:16:01] scatterp: what the hell its resolving a ipv6 address :/
[15:16:10] impermanence: I'm solving a coding challenge and in it there are some strings that I know will not change. What is the best Ruby practice on storing these?
[15:16:32] apeiros: impermanence: assign to a constant is a common good practice
[15:16:32] ta: has joined #ruby
[15:17:01] impermanence: I have also seen the method freeze used...(?)
[15:17:10] Immune: has joined #ruby
[15:17:11] elomatreb: And either explicitely freeze those by calling .freeze on them, or use the magic comment that auto-freezes all string literals
[15:17:26] impermanence: magic comment?
[15:17:27] elomatreb: If you just assign them to constants you can still mutate (e.g. append) them
[15:18:27] michael1: has joined #ruby
[15:18:28] elomatreb: # frozen_string_literal: true
[15:18:49] apeiros: that's from ruby 2.4+, right?
[15:18:58] apeiros: ACTION loses track of what's been added when
[15:19:16] elomatreb: I think the comment is since 2.3
[15:19:26] bruno-: has joined #ruby
[15:19:31] scatterp: matthewd when i wget https://raw.githubusercontent.com/scatterp/peatio/master/install1.sh it works when i try to wget most other stuff i get ipv6 addresses and it tries to connect to them and fails
[15:20:20] [[thufir]]: has joined #ruby
[15:20:32] matthewd: Sounds like you have a network configuration/firewall issue, then
[15:20:39] elomatreb: Can't you tell your wget to just use IPv4 only? (wget -4)
[15:21:00] matthewd: If it's resolving and trying to use IPv6, that implies it thinks it will work
[15:21:29] elomatreb: It means your DNS server supports v6 records, if you can actually send traffic depends on the ISP
[15:21:32] marr: has joined #ruby
[15:21:42] elomatreb: (E.g. I can't)
[15:22:02] RougeRRR: has joined #ruby
[15:22:30] ElDoggo: has joined #ruby
[15:22:31] matthewd: elomatreb: Your local system shouldn't try to *use* them if it doesn't believe it has a routable IPv6 address, though
[15:24:25] sepp2k: has joined #ruby
[15:25:02] ElDoggo_: has joined #ruby
[15:26:09] seitensei: has joined #ruby
[15:30:45] scatterp: matthewd thanks all fixed
[15:31:09] reber: has joined #ruby
[15:31:58] mikecmpb_: has joined #ruby
[15:33:00] impermanence: has joined #ruby
[15:34:01] jenrzzz: has joined #ruby
[15:34:01] jenrzzz: has joined #ruby
[15:36:56] tomphp: has joined #ruby
[15:37:07] tsglove2: has joined #ruby
[15:44:05] tsglove3: has joined #ruby
[15:47:22] charliesome: has joined #ruby
[15:49:14] tsglove2: has joined #ruby
[15:49:32] DTZUZO: has joined #ruby
[15:51:33] _aeris_: has joined #ruby
[15:52:19] tsglove3: has joined #ruby
[15:52:44] emerson: has joined #ruby
[15:54:56] tsglove2: has joined #ruby
[15:55:40] cabotto: has joined #ruby
[15:57:17] impi0us: has joined #ruby
[15:57:54] impi0us: has left #ruby: ()
[16:01:16] swills: has joined #ruby
[16:01:16] swills: has joined #ruby
[16:01:29] swills_: has joined #ruby
[16:02:45] mikecmpbll: has joined #ruby
[16:03:07] [Butch]: has joined #ruby
[16:07:20] tsglove3: has joined #ruby
[16:07:23] synthroid: has joined #ruby
[16:07:44] tomphp: has joined #ruby
[16:08:06] conta: has joined #ruby
[16:08:47] Danny1: has joined #ruby
[16:10:19] tsglove2: has joined #ruby
[16:11:29] cagomez: has joined #ruby
[16:12:02] swills: has joined #ruby
[16:12:37] Technodrome: has joined #ruby
[16:13:02] cagomez: has joined #ruby
[16:13:23] Danny1: has joined #ruby
[16:16:59] vtx: has joined #ruby
[16:17:30] mikecmpbll: has joined #ruby
[16:19:21] vtx: hi guys i have just started work on a sinatra application with a few endpoints. now that i have behaviour defined for some of the endpoints, i want to write some spec tests. is there an easy way to introduce rspec to my project? i used `bundle gem <my gem>` to create the intial boilerplate, and i’m curious if a similar solution exists for rspec testing?
[16:19:25] yottanami1: has joined #ruby
[16:22:43] MagnusX: has joined #ruby
[16:22:57] cagomez: has joined #ruby
[16:23:57] matthewd: vtx: https://relishapp.com/rspec/rspec-core/docs/command-line/init-option
[16:27:37] ta: has joined #ruby
[16:27:46] toomer: has joined #ruby
[16:28:22] toomer: Have a problem after moving from ruby 1.8 to 2.0
[16:28:43] toomer: Getting an error : "Could not evaluate: undefined method `each' for "ADDRESS0= NETMASK0= GATEWAY0=":String"
[16:28:57] toomer: var/lib/puppet/lib/puppet/provider/network_route/network_scripts.rb:23:in `exists?'
[16:29:01] toomer: From the code:
[16:29:49] toomer: for route in @resource[:routes]
[16:29:55] matthewd: toomer: Yes, String used to have an each method, and now it doesn't.
[16:29:57] toomer: @memory_values.push(route.strip)
[16:30:02] matthewd: (and for uses each)
[16:30:05] matthewd: ?gist toomer
[16:30:05] ruby[bot]: toomer: https://gist.github.com - Multiple files, syntax highlighting, even automatically with matching filenames, can be edited
[16:31:15] toomer: https://gist.github.com/toomer/8120d565238a7bc107b8923a0c3440cf
[16:31:53] tsglove3: has joined #ruby
[16:32:12] chouhoulis: has joined #ruby
[16:32:20] toomer: matthewd: I don't see each in the line:
[16:32:30] matthewd: toomer: As I said, `for` uses `each`
[16:32:31] toomer: for route in @resource[:routes]
[16:32:51] toomer: Is there a quick way to fix it ?
[16:33:52] ta: has joined #ruby
[16:34:21] matthewd: `for route in @resource[:routes].each_line`, I think?
[16:34:32] matthewd: 1.8 was a long time ago :/
[16:34:56] veeti: has joined #ruby
[16:35:21] SeepingN: has joined #ruby
[16:35:46] matthewd: Using `for` at all is widely considered poor practice, but if that's what's currently in the code, it's safest to leave it for now
[16:35:56] toomer: Not for us, we are telecom company :)
[16:35:56] cabotto: has joined #ruby
[16:36:44] toomer: We are just plan to move from RHEL 6 and ruby 1.8 to RHEL7 and ruby 2.0
[16:37:19] Puffball: has joined #ruby
[16:37:43] toomer: matthewd: Thanks for help
[16:37:48] csk157: has joined #ruby
[16:38:32] Guest73: has joined #ruby
[16:38:45] orbyt_: has joined #ruby
[16:39:25] Papierkorb: Not only "long time ago", but even the support deadline of those versions are a long time ago by now
[16:39:27] chrisarcand: toomer: Out of curiosity, do you use Software Collections to manage your Rubies or just what ships with RHEL?
[16:40:06] toomer: Whatever RHEL ship we use it
[16:40:15] toomer: We can't use rubygems
[16:40:23] raynold: has joined #ruby
[16:40:26] Papierkorb: How's that secure?
[16:40:27] toomer: We can't even use EPEL repo for redhat
[16:40:59] toomer: Whatever we need, we take sources from github or something
[16:41:10] toomer: Then rebuild as RPM and deliver
[16:41:28] Papierkorb: .. can't you rebuild a reasonably recent ruby the same way?
[16:41:35] Dimik: has joined #ruby
[16:42:39] toomer: Will RedHat support us on the ruby version that is diffrent from what they are delivering ?
[16:42:42] toomer: Don't think so
[16:43:00] tsglove2: has joined #ruby
[16:43:06] matthewd: Isn't that exactly what SCL is for?
[16:43:16] chrisarcand: Hence my asking ;)
[16:43:19] Papierkorb: Do they even support ruby? Those ancient versions don't receive any updates of any kind, and haven't for many years
[16:43:54] Danny1: has joined #ruby
[16:43:55] matthewd: chrisarcand: Oh hai! I should pay more attention to who's talking :P
[16:43:56] chrisarcand: They do (disclaimer, I work for Red Hat). That's what SCL is for.
[16:44:10] chrisarcand: matthewd: ^_^
[16:44:18] havenwood: Red Hat Software Collections 2.3 has Ruby 2.3.
[16:44:23] chrisarcand: https://www.softwarecollections.org/en/
[16:44:42] toomer: Ruby 2.3 ???
[16:44:50] toomer: Maybe in 2049
[16:45:01] eam: most folks using RHEL in production roll their own ruby and ship it with their application
[16:45:02] havenwood: toomer: Live in the now.
[16:45:03] tsglove2: has joined #ruby
[16:45:22] eam: you generally don't want to use the distro supplied runtimes as they won't ever be exactly what you want
[16:45:24] matthewd: If you're only using ruby for puppet, though, and your puppet is itself presumably ancient...
[16:45:41] chrisarcand: eam: Yeah; The project I work on currently uses SCL and we're considering that, because the backporting of things in SCL is...complicated.
[16:45:58] Papierkorb: It's just ironic how those ancient programs, which don't receive any updates, make you less secure
[16:46:12] eam: chrisarcand: I say that as someone who's been running RHEL for over a decade at some of your largest customers
[16:46:33] chrisarcand: The point of SCL is to fix what eam is describing though. To have more up-to-date things like Ruby, etc, which get CVEs backported and auto updated on customers' machines.
[16:47:01] toomer: Guys, where do you live ??
[16:47:15] chrisarcand: eam: ^_^ Yup for sure
[16:47:18] eam: toomer: earth!
[16:47:19] Papierkorb: In a industry that's constantly targeted by adversaries toomer
[16:47:26] toomer: It took us 3 years to convince Managment to move from RHEL6 to RHEL7
[16:47:26] Papierkorb: So, basically, all of IT
[16:47:35] toomer: We are still in Java 7
[16:47:45] Papierkorb: .. How's Java7 that bad?
[16:47:56] toomer: Nobody want to spend maney on platform since it's 'Working'
[16:48:05] toomer: They prefer to spend money on something else
[16:48:38] charliesome: has joined #ruby
[16:48:56] [Butch]: has joined #ruby
[16:49:04] eam: often it's not budget so much as time and effort
[16:49:16] toomer: Yes, exactly
[16:49:42] mnemon: eam: time and effort are expensive
[16:49:44] toomer: What is the diffrence for customer if you move from ruby 1.8 to 2.0 or RHEL6 to RHEL7
[16:50:09] toomer: When all your applications that you deliver to customer is Java based
[16:51:30] Danny1: has joined #ruby
[16:51:36] toomer: Upgrading live environments can be difficult :(
[16:52:03] toomer: For example there is no in place upgrade that WORKS in RHEL
[16:52:51] matthewd: IME upgrades get exponentially more painful the longer you leave them
[16:52:56] eam: nor should there be - giving people in-place process instead of tear-it-down-and-rebuild allows them to calcify, operationally
[16:53:04] eam: matthewd++
[16:53:28] eam: this is probably the #1 "feature" of all this cloud garbage
[16:53:36] eam: forcing people to deal with ephemeral systems
[16:53:41] toomer: matthewd: Of course you are right
[16:54:07] matthewd: eam: Ephemeral systems built out of docker containers that you can build once and never touch again... :|
[16:54:19] eam: too real
[16:55:01] toomer: eam: Yes, cloud garbage is much better in that perspective, you don't upgrade you just roll out new one instance
[16:55:14] toomer: Untill you need to upgrade Cloud itself :)
[16:55:42] eam: I threatened (and still might) rpm -e rpm new machines so they cannot be incrementally upgraded
[16:56:34] eam: then people say "but we don't know how to rebuild it" and the fun conversation starts about how you're going to be forced to do that in certain scenarios, so we might as well fix the real issue now
[16:56:50] mnemon: how do you apply simple bug fixes?
[16:56:54] eam: rebuild the host
[16:57:10] Papierkorb: ..or just the container
[16:57:16] eam: yeah, or the container
[16:58:11] eam: imaging a host from bare metal takes <20 minutes and spinning up a container takes <30s if done right
[16:58:38] eam: there is no reason not to rebuild from scratch always, have your CI and build systems producing images
[16:58:43] banisterfiend: has joined #ruby
[16:58:58] eam: there's some mess around persistent data, but that's solvable with process
[16:59:16] eam: and it's a good idea to rebuild your databases periodically too, test your backups, etc
[17:00:02] eckhardt: has joined #ruby
[17:00:17] toomer: Yes, this is much easier then patching and upgrading the host
[17:00:28] toomer: roll out the new one :)
[17:00:38] guacamole: has joined #ruby
[17:00:48] Papierkorb: ...backed by a one-click script using Ansible or whatever
[17:01:02] cagomez: has joined #ruby
[17:01:02] banisterfiend: has joined #ruby
[17:01:52] hahuang65: has joined #ruby
[17:02:42] cagomez_: has joined #ruby
[17:03:18] ycyclist: has joined #ruby
[17:04:01] eam: if you ever find yourself saying "we can't rebuild that" then you absolutely must practice rebuilding it
[17:05:29] chmurifree: has joined #ruby
[17:05:29] mnemon: making the rebuild automatic tends to be hard, and doing it partially manually can be time consuming(vs. incremental upgrades).
[17:05:55] Papierkorb: mnemon: The point is that you know what your host is actually hosting
[17:06:04] mnemon: of course depends on the complexity of the system.
[17:06:43] mnemon: Papierkorb: for the rebuild?
[17:06:58] Papierkorb: Yes. Using Ansible or whatever you like
[17:07:43] Papierkorb: And a bash script before that installs ansible and then kicks that off.
[17:09:17] conta: has joined #ruby
[17:10:12] tomphp: has joined #ruby
[17:11:47] mnemon: Papierkorb: ime, works great with relatively simple and/or stateless systems but can be pretty complex to automate nice rebuilds/upgrade of systems with more persistent data
[17:11:49] imode: has joined #ruby
[17:12:02] toomer: matthewd: Thanks, your changed worked
[17:12:17] toomer: Thanks to you we can stay for next decade on ruby 1.8
[17:12:41] mnemon: data or state ...
[17:12:49] eam: mnemon: I find the "database" problem tends to morph into understanding whether you're prepared for device failure
[17:13:36] Papierkorb: mnemon: we used that to start kubernetes clusters, which then spun up more complex software. At that point, it's the epheremal wild west :)
[17:14:29] ivanskie: has joined #ruby
[17:14:47] ivanskie: how's everybody doing?
[17:15:01] mnemon: eam: in some cases, I mostly work on very "HA" systems and accepting some disruptions on sudden device failure(rare) vs. working around the impact on upgrade(frequent) is different.
[17:15:32] ivanskie: I have a question. I've got ruby installed on windows 10. ruby installer, and msys2 installed as well.
[17:16:04] cadillac_: has joined #ruby
[17:16:05] ivanskie: gems with executables are not getting added to path for some reason. for example i have gtm installed, but when i try to run >gtm it says command not found.
[17:16:44] matthewd: ivanskie: The gem bin directory probably isn't on your path
[17:16:45] ivanskie: ruby is in path, i can run >ruby -v from any command promt, cmd, powershell, cmder. same with >gem ...
[17:17:05] matthewd: `gem env` should tell you where it's putting them
[17:17:37] ivanskie: weird. it has two paths for gems
[17:18:25] matthewd: You're looking for the "executable directory"
[17:18:51] ivanskie: ah, only shows "C:/Ruby24-x64/bin"
[17:19:02] ivanskie: and that is in the path
[17:19:16] matthewd: Does it contain the thing you're trying to run?
[17:19:43] ivanskie: it does not
[17:19:56] matthewd: Wait, what is the thing you're trying to run?
[17:19:58] raynold: ahh it's a wonderful day
[17:20:11] matthewd: https://rubygems.org/gems/gtm doesn't sound like a thing
[17:20:12] ivanskie: matthewd: one of the global gems with executable
[17:20:22] ivanskie: git time metrics
[17:20:49] ivanskie: https://github.com/git-time-metric/gtm
[17:20:54] jsrtr: has joined #ruby
[17:21:09] ivanskie: hmm let me try install rails. and see what happens
[17:21:10] matthewd: ivanskie: And how is that related to ruby?
[17:21:15] ddffg: has joined #ruby
[17:21:19] havenwood: ivanskie: That's not a gem though?
[17:21:56] matthewd: It's written in Go, and is distributed with a Windows installer
[17:22:14] ivanskie: okay I go hide now
[17:22:37] ivanskie: i forgot how i installed it on my macbook lol
[17:23:10] alfiemax: has joined #ruby
[17:24:20] Danny1_: has joined #ruby
[17:24:36] ivanskie: thanks matthewd
[17:25:37] Danny1: has joined #ruby
[17:25:54] anisha: has joined #ruby
[17:26:50] moei: has joined #ruby
[17:26:50] baweaver: has joined #ruby
[17:29:19] mtkd: has joined #ruby
[17:35:29] guacamole: has joined #ruby
[17:35:52] hutch34: has joined #ruby
[17:35:56] jenrzzz: has joined #ruby
[17:35:56] jenrzzz: has joined #ruby
[17:37:06] alfiemax: has joined #ruby
[17:44:43] yottanami: has joined #ruby
[17:49:42] csk157: has joined #ruby
[17:54:50] dalitom: has joined #ruby
[17:55:23] dalitom: hey all, quick easy question
[17:55:38] dalitom: dali = "/home/email.rb\r\n/home/test/"
[17:55:44] dalitom: p dali.split('\r\n')
[17:56:02] dalitom: ["/home/email.rb\r\n/home/test/"]
[17:56:10] ruby[bot]: matthewd: # => "\\r\\n" (https://eval.in/890346)
[17:56:24] matthewd: >> '\r\n' == "\r\n"
[17:56:25] ruby[bot]: matthewd: # => false (https://eval.in/890347)
[17:56:47] jolamb: Is this pattern for object initialization as bad and awful as I think it is? https://github.com/openshift/sprint_tools/blob/master/lib/trello_helper.rb#L122-L125
[17:57:09] ElDoggo: has joined #ruby
[17:57:37] Papierkorb: It's sometimes done, but I'm no huge fan of "opts" hashes in any case :)
[17:57:45] matthewd: jolamb: It has its pros and cons.. though I'd generally do it after the other initializations, not first
[17:57:53] elomatreb: dalitom: Escape sequences don't work in single quotes (except for \' IIRC)
[17:58:11] matthewd: Alternatively: Rails does it... so yes ;)
[17:58:48] dalitom: Thanks guys, that was confusing for a moment
[17:59:44] matthewd: jolamb: Without looking properly, I certainly doubt it's the most questionable thing in that 1500 (!) line file
[17:59:57] jolamb: matthewd: hah, excellent point
[17:59:59] charliesome_: has joined #ruby
[18:00:29] Papierkorb: rubocop must have a field day on that file even with really moderate settings
[18:00:58] jolamb: Papierkorb: matthewd: ok I know there are problems there, bear in mind this is inherited code
[18:01:09] Papierkorb: not blaming you
[18:01:14] elomatreb: Best thing: Not a single doc comment?
[18:01:16] jolamb: that is fairly old, and most frequently updated under emergency conditions :D
[18:01:28] elomatreb: Oh wait nevermind, I'm an idiot
[18:01:30] Papierkorb: elomatreb: "Self documenting code" durr
[18:01:54] jolamb: elomatreb: what Papierkorb said.
[18:02:05] elomatreb: Userstyle set to night mode was still partially applied, comments where white on white background x)
[18:02:06] jamesaxl: has joined #ruby
[18:02:07] jolamb: ACTION bangs head against desk for emphasis
[18:02:27] cagomez: has joined #ruby
[18:02:40] baweaver: Hm, I've seen that question 2-3 times in the past few days
[18:02:47] baweaver: must be some type of recent courseware
[18:03:19] elomatreb: Holy hell the update_roadmaps method
[18:04:06] baweaver: matthewd: Rails does it is not a very convincing argument :P
[18:04:10] Papierkorb: ... that thing is longer than many classes
[18:04:32] elomatreb: ... and the only comments are commented-out code
[18:05:38] matthewd: baweaver: thus: yes [it is bad and awful] ;)
[18:05:50] banisterfiend: has joined #ruby
[18:05:58] jamesaxl: has joined #ruby
[18:06:08] charliesome: has joined #ruby
[18:06:30] jrafanie: has joined #ruby
[18:08:11] jolamb: elomatreb: hah, take a look at this mess: https://github.com/openshift/test-pull-requests/blob/master/test_pull_requests#L1567-L1941
[18:08:17] nowhere_man: has joined #ruby
[18:08:31] jolamb: the code HAS to be stable, because it's so hostile to modification
[18:09:02] orbyt_: has joined #ruby
[18:09:19] Papierkorb: I'm constantly thinking "if X was the only problem this file has", just to think next that this class has all the problems
[18:09:30] jamesaxl: has joined #ruby
[18:10:12] conta5: has joined #ruby
[18:10:49] darkmorph: has joined #ruby
[18:10:56] jolamb: I really have to pick my battles when I work on this stuff, thus why I only asked about that one particular pattern just now
[18:13:17] Papierkorb: jolamb: I'd try to write tests for a single bad-method, then refactor that method into multiple smaller ones. allows you to chunk-wise improve the logic, while you can still get stuff done. Each time with a better peace of mind.
[18:14:15] alfiemax: has joined #ruby
[18:14:15] Papierkorb: Once it's bearable, maybe try splitting that thing into multiple classes - Even at the price of having those classes have funny interdependencies. That'd be the next target then. And if you get to this point, It may be overall acceptable
[18:14:17] troys: has joined #ruby
[18:16:11] jolamb: Papierkorb: yeah, that's the goal. I've started trying to add unit tests, so at least I can verify changes
[18:16:16] jolamb: but there's a lot to test there...
[18:16:49] Papierkorb: no small feat for sure :)
[18:17:48] dalitom: noob question, but I have to ask .....if I do my_var = myfunction(data), next time I call my_var is it going to execute myfunction again ?
[18:18:00] eam: dalitom: no
[18:18:15] eam: the object returned by myfunction() is saved in my_var
[18:23:19] FrostCandy: has joined #ruby
[18:23:50] dinfuehr: has joined #ruby
[18:24:28] FrostCandy: Do @class vars declared outside of a thread get passed to the thread ?
[18:25:56] matthewd: FrostCandy: That question suggests some fundamental misunderstanding. Add some context?
[18:28:00] FrostCandy: Well this guy creates a thread t = Thread.new do - uses @var - end where @var is defined outside the thread
[18:28:38] FrostCandy: So i'm wondering if @var's keep their contents after a thread is created and inside the thread
[18:29:06] matthewd: Instance variables are stored on the instance they belong to, which has nothing to do with threads
[18:29:44] FrostCandy: Ok better question then, how to pass an instance variables contents to a thread?
[18:29:47] matthewd: A block doesn't [generally] change `self` when it's executed, so @var inside a block is [generally] going to use the ivar from the same object that it would outside
[18:29:49] FrostCandy: guess i can look that up.
[18:30:40] FrostCandy: right, but i figured threads would be differnet than normal blocks, like a whole new process
[18:31:57] banisterfiend: yo why does: JSON.parse('{"hello":"\\u0627"}') give teh same result as JSON.parse('{"hello":"\u0627"}') ?
[18:32:21] banisterfiend: JSON automatically converts strings with unicode trigrams into the associated character?
[18:32:29] FrostCandy: just tested with a puts, instance variable is usesable inside the thread.
[18:34:05] FrostCandy: try \\\ , maybe json is making \u0.. creating the same character as the one you pass with \u0
[18:34:52] banisterfiend: my feeling is that json automatically applies its own escaping when interpreting a string?
[18:35:00] banisterfiend: it doesn't just deal with raw strings?
[18:35:04] baweaver: iirc it does some odd things like that.
[18:35:13] baweaver: There are some options on parse to make it stop it, I'd have to find them
[18:36:51] baweaver: Nope, can't find an option for it. Unicode is not a strongsuite of mine :/
[18:37:33] matthewd: Sounds plausible, at least -- it's a JS subset, so \u can only mean what it does in JS
[18:38:14] matthewd: Ah, there's even a pretty picture on https://json.org/ that shows it: https://json.org/string.gif
[18:39:25] mikecmpbll: has joined #ruby
[18:41:09] RickHull: has joined #ruby
[18:41:54] jamesaxl: has joined #ruby
[18:42:16] impermanence: has joined #ruby
[18:42:59] banisterfiend: matthewd thanks, yeah that makes sense
[18:43:04] impermanence: Are there methods that handle modulo arithmetic?
[18:43:06] banisterfiend: was super duper confusing when i encountered it though
[18:43:33] impermanence: e.g. is_divisible? or something similar? or is my only choice % ?
[18:44:57] darkmorph: has joined #ruby
[18:45:42] impermanence: Numeric.modulo.
[18:46:53] RickHull: >> 4.modulo(3)
[18:46:55] ruby[bot]: RickHull: # => 1 (https://eval.in/890355)
[18:46:57] elomatreb: % is not the same as Numeric#modulo, check the behavior if one or more operands are negative
[18:48:15] elomatreb: Actually not true, it *is* equivalent to #modulo, but not to #remainder, nevermind me
[18:51:24] impermanence: I assume that freeze works on Integers, as well? e.g. THREE = 3.freeze
[18:51:38] impermanence: seems to...although in pry I am allowed to reassign...
[18:51:44] impermanence: it throws a warning...
[18:52:10] RickHull: an integer literal like 3 is effectively frozen
[18:52:13] RickHull: you can't assign to 3
[18:52:20] ruby[bot]: RickHull: # => /tmp/execpad-eaff27fa3e23/source-eaff27fa3e23:2: syntax error, unexpected '=', expecting keyword_end ...check link for more (https://eval.in/890356)
[18:52:23] troulouliou_dev: has joined #ruby
[18:53:23] guacamole: has joined #ruby
[18:53:32] RickHull: though, that doesn't really explain things
[18:53:38] impermanence: I have a small program that will be using some numbers and these numbers will be constants. Should I make them constants?
[18:53:51] impermanence: I was planning on doing like: THREE = 3.freeze
[18:53:53] impermanence: or is that stupid?
[18:53:55] RickHull: i think freeze is more about preventing mutation, different from assignment
[18:53:59] havenwood: >> 3.frozen?
[18:54:01] ruby[bot]: havenwood: # => true (https://eval.in/890357)
[18:54:02] matthewd: impermanence: Having a constant named THREE is stupid, yes.
[18:54:17] havenwood: impermanence: Integers are already frozen.
[18:54:49] RickHull: it is good to make constants like BAR = 23 # the length of the bar
[18:55:02] RickHull: rather than have the integer literal 23 in your code
[18:55:05] apeiros: has joined #ruby
[18:55:11] havenwood: (Integers weren't frozen back in 1.9. They have been since 2.0. FWIW.)
[18:55:27] RickHull: what does frozen imply in a nutshell? immutable?
[18:55:35] Guest72603: i learn so much from yall by lurking
[18:55:37] matthewd: RickHull: Yes
[18:55:55] matthewd: Before that, integers were.. interesting
[18:56:11] havenwood: 19>> 42.frozen?
[18:56:12] ruby[bot]: havenwood: # => false (https://eval.in/890358)
[18:56:16] havenwood: 20>> 42.frozen?
[18:56:18] ruby[bot]: havenwood: # => true (https://eval.in/890359)
[18:56:32] matthewd: Though not "actually change the internal value of the integer" interesting, which you can apparently do in Python
[18:56:58] eam: do you want to ☃️.build
[18:57:05] impermanence: matthewd: out of curiosity why do you say that having a constant named THREE is stupid? Because of how uninformative the name is?
[18:57:20] RickHull: 3 is already a constant symbol for the number 3
[18:57:55] matthewd: The point of "you should always use constants, not literals"-type teachings is that you should be *naming a concept*, and then giving its value once
[18:58:31] impermanence: yeah, that's kind of what I thought you were implying. makes sense.
[18:58:49] havenwood: >> 3.object_id # impermanence
[18:58:55] ruby[bot]: havenwood: # => 7 (https://eval.in/890360)
[18:59:07] uZiel: has joined #ruby
[18:59:10] matthewd: MONTHS_PER_YEAR = 12 # useful; TWELVE = 12 # worse than useless
[18:59:23] lxsameer: has joined #ruby
[18:59:45] RickHull: not even wrong :)
[18:59:55] havenwood: impermanence: `3` will always be object id 7 (at least in this version and engine of Ruby). Even when you restart, etc. It's fixed.
[19:00:14] impermanence: >> 3.object_id
[19:00:15] ruby[bot]: impermanence: # => 7 (https://eval.in/890361)
[19:00:26] havenwood: impermanence: The odd numbers are the ids for all the integers.
[19:00:47] RickHull: >> [:foo.frozen?, :foo.object_id]
[19:00:49] ruby[bot]: RickHull: # => [true, 450738] (https://eval.in/890362)
[19:01:06] havenwood: >> ObjectSpace._id2ref 7
[19:01:07] ruby[bot]: havenwood: # => 3 (https://eval.in/890363)
[19:01:21] matthewd: >> 7 >> 1 # 👐🏻
[19:01:22] ruby[bot]: matthewd: # => 3 (https://eval.in/890364)
[19:01:52] RickHull: >> ObjectSpace._id2ref(:foo.object_id)
[19:01:54] ruby[bot]: RickHull: # => :foo (https://eval.in/890365)
[19:02:42] RickHull: >> [:foo.frozen?, :foo.object_id]
[19:02:44] ruby[bot]: RickHull: # => [true, 450738] (https://eval.in/890366)
[19:03:04] RickHull: same interpreter? in different irb runs I get different values for :foo.object_id
[19:03:25] matthewd: >> :bar; [:foo.frozen?, :foo.object_id]
[19:03:26] ruby[bot]: matthewd: # => [true, 450898] (https://eval.in/890367)
[19:04:04] matthewd: >> [:bar.frozen?, :bar.object_id]
[19:04:05] ruby[bot]: matthewd: # => [true, 450738] (https://eval.in/890368)
[19:04:47] matthewd: RickHull: I'd guess it's using an already-loaded environment, then forking for each request -- so the same slot in the symbol table is "next" each time
[19:06:14] jamesaxl: has joined #ruby
[19:06:28] jenrzzz: has joined #ruby
[19:06:28] jenrzzz: has joined #ruby
[19:08:20] sonOfRa: has joined #ruby
[19:10:25] alfiemax: has joined #ruby
[19:13:58] tomphp: has joined #ruby
[19:15:26] govg: has joined #ruby
[19:17:21] workmad3: has joined #ruby
[19:20:23] tomphp: has joined #ruby
[19:20:51] happyface: has joined #ruby
[19:24:28] Nexer: has joined #ruby
[19:25:52] rhyselsmore: has joined #ruby
[19:26:34] ur5us: has joined #ruby
[19:28:15] orbyt_: has joined #ruby
[19:28:50] vipaca: has joined #ruby
[19:29:04] shinnya: has joined #ruby
[19:31:00] mkroman: has joined #ruby
[19:31:24] gigetoo: has joined #ruby
[19:33:39] mtkd: has joined #ruby
[19:35:38] SeepingN: has joined #ruby
[19:35:50] FrostCandy: If I call Myclass.Mymethod(vars) will that automatically creates a new intance of Myclass right? or do I need to do a var = Myclass.new then var.Mymethod(vars) ?
[19:36:20] Papierkorb: FrostCandy: ... No, that won't just create an instance
[19:36:58] RougeRRR: has joined #ruby
[19:38:30] FrostCandy: yikes ok this project is such a mess lol
[19:38:45] goyox86: has joined #ruby
[19:38:49] Technodrome: has joined #ruby
[19:41:15] Caius: FrostCandy: depends on the implementation of Mymethod really
[19:41:33] Caius: if it calls new and assigns the vars passed in, then yes
[19:41:38] Caius: otherwise, no :-)
[19:41:42] FrostCandy: Caius: it's calling a method from a class inside a thread block
[19:42:39] FrostCandy: ah no new call though. I'll fix it by creating a var = myclass.new then using that new instance to call the method. Safer i think
[19:42:43] Caius: FrostCandy: Mymethod would have to explicitly create an instance (look for a call to #new or something inside it)
[19:43:08] Caius: Myclass.Mymethod is different to inst = Myclass.new; inst.Mymethod though
[19:43:21] orbyt_: has joined #ruby
[19:45:20] dstrunk: has joined #ruby
[19:48:56] swills: has joined #ruby
[19:48:57] swills: has joined #ruby
[19:53:08] guacamole: has joined #ruby
[19:53:29] dionysus69: has joined #ruby
[19:54:14] eckhardt: has joined #ruby
[19:55:51] raul782: has joined #ruby
[19:57:53] workmad3: has joined #ruby
[20:00:23] cdg: has joined #ruby
[20:01:50] FrostCandy: Caius: right thanks. Is there short hand for creating a new instance and calling a method like MyClass.new.Mymethod(vars) ? Just curious, can't ask the right question on google.
[20:05:09] matthewd: FrostCandy: You can do that, but it will give you the result of calling the method. Also mymethod has to be defined differently depending on whether you're going to call it on a class or an instance.
[20:06:24] matthewd: FrostCandy: As a general observation, I would recommend against experiment-driven-development when working with threads -- they create a large gap between "works this time" and "works every time"
[20:06:25] FrostCandy: Oh is this where the self.method comes in? I'll look in to that
[20:09:08] i831533: has joined #ruby
[20:09:59] cdg: has joined #ruby
[20:11:37] ycyclist: has joined #ruby
[20:12:30] ycyclist: Please I am wondering about security problems in recent ruby. I see these vulnerabilities presently listed: https://www.ruby-lang.org/en/news/2017/08/29/multiple-vulnerabilities-in-rubygems/
[20:12:59] ycyclist: Is there a specific discussion group or channel for these?
[20:13:37] matthewd: ycyclist: There's #rubygems, and I think a Slack group maybe?
[20:13:40] apeiros: has joined #ruby
[20:13:41] matthewd: Do you have a specific question?
[20:14:23] johno84: has joined #ruby
[20:20:11] csk157: has joined #ruby
[20:21:47] ycyclist: Sorry guys. I was trying to dig through my code.
[20:22:35] ycyclist: I do have a specific question: What is typical for specifying a gem version like that? Can I say something in my Gemspec.lock file, or is it more typical to do something else?
[20:24:46] RickHull: this doesn't require a change to your project code, per se
[20:25:04] RickHull: if you are talking about a gem, you can lock down required_ruby_version in the gemspec
[20:25:33] RickHull: the the project is more like a rails project, then you would want to make sure your production nodes are running a new rubygems
[20:25:54] RickHull: sorry, required_rubygems_version in the gemspec (IIRC)
[20:26:27] RickHull: if you're just playing around in development, then update rubygems in your dev environment(s)
[20:26:30] alfiemax: has joined #ruby
[20:27:17] matthewd: I don't think you can enforce a rubygems version in the Gemfile... though if you're specific enough with the ruby version, that could suffice
[20:27:57] RickHull: note, Gemfile is for bundler, gemname.gemspec is for rubygems
[20:28:02] matthewd: ycyclist: I'd argue that this is outside your application's remit -- just as it's not responsible for checking the current OS doesn't have any known vulnerabilities
[20:28:45] RickHull: http://guides.rubygems.org/specification-reference/#required_rubygems_version=
[20:29:28] synthroid: has joined #ruby
[20:29:55] RickHull: you might be able to specify rubygems-update gem version in your Gemfile ?
[20:30:03] RickHull: that would be kinda gross I think
[20:30:47] eckhardt: has joined #ruby
[20:31:07] ycyclist: Well, we need to upgrade our server situation to avoid these vulnerabilities. It looks like the main thing is specifying a rubygems by this doc: https://www.ruby-lang.org/en/news/2017/08/29/multiple-vulnerabilities-in-rubygems/
[20:31:22] RickHull: yeah, upgrade the server, not your project code
[20:31:31] RickHull: how do you keep your servers updated?
[20:33:13] RickHull: e.g. if you have 3 servers and no automated infrastructure, then ssh in and e.g. apt update/upgrade or sudo gem update --system or whatever is appropriate
[20:33:36] ek926m: has joined #ruby
[20:33:49] RickHull: confirm with gem --version -- though ruby deploys can get complicated in terms of paths and `which gem` is being used
[20:35:18] zapata: has joined #ruby
[20:36:40] ycyclist: We install our own version of ruby for our application.
[20:36:58] ycyclist: That way, we are not affected if the user specifies something different.
[20:37:04] RickHull: what do you have now for `gem env` ? paste on a paste site
[20:37:14] RickHull: you can omit or redact any sensitive info
[20:37:22] ycyclist: Just a minute please.
[20:37:27] sonOfRa: has joined #ruby
[20:38:32] sonOfRa: has joined #ruby
[20:38:58] cdg_: has joined #ruby
[20:40:03] ycyclist: Sorry, I am slow: https://gist.github.com/v-xecamp/a7f5e256f9c61a127bcf51f270ebeb4b
[20:40:12] ycyclist: RickHull above please.
[20:42:52] RickHull: you might not be affected
[20:43:17] RickHull: but you will probably want to confirm `sudo gem env` has the same output and then `sudo gem update --system`
[20:44:07] RickHull: how does ruby/rubygems get installed to /usr/local ?
[20:45:33] nowhere_man: has joined #ruby
[20:45:52] bmurt: has joined #ruby
[20:46:13] jottr: has joined #ruby
[20:49:52] charliesome: has joined #ruby
[20:53:09] ycyclist: Okay, here's the question that I think answers itself. Inside our app, we have this: https://github.com/rubygems/rubygems/blob/master/lib/rubygems.rb.
[20:53:54] ycyclist: It appears we are using 2.5.2 instead of the 2.6.14 you see specified in this file. I wasn't sure if this file was our concoction, but fortunately it looks like it is not.
[20:54:37] ycyclist: So it appears that merely upgrading this to be the one online may get us there, though I suspect it is the entire git source tree for it that we shall need.
[20:55:12] jenrzzz: has joined #ruby
[20:55:31] RickHull: you should not have rubygems lib stuff inside your app
[20:56:02] RickHull: that source code is on your filesystem somewhere, and it depends on what you have installed (i.e. to the filesystem)
[20:56:15] RickHull: changing the string assigned to VERSION in the source code does nothing
[20:57:55] RickHull: in a traditional web shop, this is in the realm of system administration, not development
[20:58:04] RickHull: these days, it's devops or infrastructure
[20:58:06] enterprisey: has joined #ruby
[20:58:18] RickHull: it's generally outside the realm of what your app has control over
[20:58:41] RickHull: is there someone else in your org responsible for maintaining the servers?
[21:00:30] RickHull: again, how does ruby/rubygems get installed to /usr/local ? who set that up?
[21:00:46] eckhardt: has joined #ruby
[21:01:31] eckhardt: has joined #ruby
[21:01:54] alfiemax: has joined #ruby
[21:06:37] charliesome_: has joined #ruby
[21:10:12] conta2: has joined #ruby
[21:13:16] charliesome: has joined #ruby
[21:13:38] imperator: has joined #ruby
[21:14:00] imperator: howdy folks
[21:14:11] imperator: anyone here familiar with Addressable::Template?
[21:14:12] jottr: has joined #ruby
[21:14:25] imperator: I'm trying to generate a url with an optional parameter, not sure how to do it
[21:14:38] imperator: basically, it looks like this: t = Addressable::Template.new("/subscriptions{/sub}/resourceGroup{/rg}")
[21:14:55] imperator: but, "resourceGroup" should be dropped if :rg isn't specified
[21:15:23] imperator: is there a way to do that?
[21:15:42] baweaver: You could always provide a different string to it
[21:16:21] imperator: not sure i follow
[21:17:23] baweaver: that path is a string
[21:17:29] vtx: has joined #ruby
[21:17:30] baweaver: give it a different one if you don't get rg
[21:17:57] baweaver: Otherwise find out if there's an optional segment somewhere in their docs (? looks promising)
[21:19:59] DoubleMalt: has joined #ruby
[21:20:09] imperator: been fiddling with various combinations, but without success
[21:22:28] baweaver: path = rg ? "/subscriptions{/sub}/resourceGroup{/rg}" : "/subscriptions{/sub}/resourceGroup"; Addressable::Template.new(path)
[21:23:02] Technodrome: has joined #ruby
[21:23:03] imperator: yeah, i was hoping for something nicer :)
[21:23:28] cagomez: has joined #ruby
[21:23:30] baweaver: I'd have to read through the docs to find it and this thing looks like kind of a mess to delve :/
[21:25:41] alex``: has joined #ruby
[21:26:45] michael1: has joined #ruby
[21:28:52] ap4y: has joined #ruby
[21:30:15] goyox86: has joined #ruby
[21:34:25] GodFather: has joined #ruby
[21:34:26] imperator: well, i can't get it to stop encoding query params, so that's a problem, too
[21:36:10] vtx: hi guys, in rspec, i am testing a class whose initialize sets up some database connections. when i run my tests, the initialization runs, and fails. this doesn’t cause my tests to fail, but i would like to somehow skip or avoid calling the methods that try to connect to databases, or, make my app think it has obtaind a valid db connection. what should i be doing to achieve this? my application uses `Mongo::Client.new` to connect t
[21:36:34] madgen: has joined #ruby
[21:39:47] millerti: has joined #ruby
[21:40:00] charliesome_: has joined #ruby
[21:40:20] selim: has joined #ruby
[21:42:43] AlexRussia: has joined #ruby
[21:45:45] mtkd: has joined #ruby
[21:46:01] cdg: has joined #ruby
[21:48:24] cagomez_: has joined #ruby
[21:50:10] charliesome: has joined #ruby
[21:51:10] catphish: has joined #ruby
[21:52:13] catphish: is there any normal pattern for returning part way through a method, then resuming it later? i feel like for the first time in my life i need goto
[21:52:38] RickHull: continuation maybe? yield, fiber
[21:53:04] RickHull: look at yield and blocks
[21:53:15] catphish: basically i have a method that parses data from a network socket, but if the socket runs out of data while i'm still parsing it, i don't want to block, i want to return to my main loop, then continue when there's more data on the socket
[21:53:35] RickHull: how do you know how many bytes to read?
[21:53:52] catphish: i don't, that's rather the problem, i have to work it out as i go
[21:54:10] catphish: if i knew, i'd just wait until there was enough data there before i started parsing it
[21:54:19] matthewd: catphish: Threads, or read_nonblock
[21:54:29] catphish: but as it is, i don't know until i'm already parsing it
[21:54:48] RickHull: what are you parsing?
[21:54:55] catphish: https://redis.io/topics/protocol
[21:55:08] catphish: the redis protocol
[21:55:19] matthewd: Wait, why are you parsing the redis protocol?
[21:55:29] catphish: because i'm writing a redis server
[21:55:45] catphish: totally normal tuesday evening activity
[21:56:25] RickHull: it seems to be line oriented, so read until you get a complete line, fail otherwise
[21:56:29] matthewd: What's your goal?
[21:56:48] guacamole: has joined #ruby
[21:57:12] matthewd: There's an easy but limited performance way, and a more painful but more production-able way to do it
[21:57:57] catphish: matthewd: i'll try to be brief, i have some untrusted client applications that want to use redis for caching, i don't want to run a redis instance for each one, so i'm writing a proxy that accepts client connections, authenticates them, then namespaces their keys and puts them in a real redis backend
[21:58:37] RickHull: have a thread own the socket and put complete lines into a queue until failure
[21:59:02] RickHull: the main thread pops the queue and parses complete lines
[21:59:02] qsx: has joined #ruby
[21:59:22] RickHull: since the thread owns the socket, it can do blocking reads or whatever
[21:59:27] catphish: RickHull: right, that's what i want to do, but here's the thing, one command can span many many lines
[22:00:00] catphish: i don't want a thread for every client
[22:00:18] catphish: (i have a personal dislike of lots of threads)
[22:00:21] RickHull: the main thread shouldn't have a problem consuming lines while parsing
[22:00:49] RickHull: catphish: i'd look at elixir personally
[22:01:04] RickHull: this is erlang's bread and butter
[22:01:14] catphish: interesting
[22:01:21] hinbody: has joined #ruby
[22:01:40] catphish: right now i have an instance for each client, it receives one line at a time, that's easy
[22:01:53] matthewd: Thread per client is the easy way
[22:01:53] apeiros: the non-thread-way to do it would be IO.select
[22:02:13] apeiros: and buffer until you have a workable dataset
[22:02:19] catphish: but since a command can span multiple lines, it gets trickier, because i can be half way through parsing and run out of lines
[22:02:49] catphish: apeiros: knowing when i have a workable dataset require parsing the whole thing repeatedly, that's one option
[22:03:01] apeiros: why repeatedly?
[22:03:03] catphish: ie start parsing, if i run out of data, abaondon the parse and start over
[22:03:05] apeiros: have a parser with state
[22:03:31] catphish: apeiros: right, this was my original question, the best way to stop part way through and resume :)
[22:04:10] catphish: i guess what i'm describing is a parser with state
[22:04:55] roshanavand: has joined #ruby
[22:05:15] catphish: matthewd: is the "more painful" way a parser with lots of states?
[22:05:35] catphish: so i parse one line, set the state, return, repeat
[22:06:19] matthewd: Mostly it was the select loop, though yes you'll need that too
[22:06:51] matthewd: I think the point is that you don't return data back -- you call forward
[22:07:03] catphish: i already have a good working event loop that buffers lines and feeds them to a parser instance
[22:07:34] RickHull: Parser#parse_line would update some ivar that tracks the parse output. check Parser#finished? after each call to #parse_line
[22:08:02] catphish: yeah, this is making sense, i think the parser will be unavoidably complicated
[22:08:02] matthewd: Right, so now the parser needs to do something each time it sees a completed message
[22:08:26] RickHull: push the queue of parser outputs :)
[22:08:54] catphish: there are some other fun things, like it's not always line based, sometimes it has a fixed length binary string in there
[22:08:56] matthewd: ^ push parser vs pull parser is a thing
[22:09:12] catphish: but i will start by writing a "parse line" and setting state and go from there
[22:09:51] catphish: this protocol looks cool on paper, but parsing it in a non blocking manner is more painful than i expected :)
[22:10:15] RickHull: probably there is something easy to adapt. it's a fun exercise to think about but I would abandon ship
[22:10:33] catphish: well the only other option is threads
[22:10:34] RickHull: if you want something useful in production
[22:11:00] catphish: or a different programming language, but thats not cool
[22:11:14] RickHull: for example, look at how redis itself does its parsing
[22:11:21] RickHull: why not link to the redis lib?
[22:13:37] RickHull: if you're doing this for cool points, I would research more about TCP messaging and parsing before getting to invested in an early design
[22:14:01] catphish: i'd usually consider myself pretty experienced at this
[22:14:06] hahuang65: has joined #ruby
[22:14:30] catphish: but this multi-line semi-human-readable protocol is quite new to me
[22:14:41] RickHull: where newlines are significant in a TCP stream...
[22:14:46] RickHull: not HTTP -- content-length
[22:14:54] RickHull: what else? gopher?
[22:15:58] catphish: http is nice and easy, only has 3 states really
[22:17:07] matthewd: RickHull: How do you get the content-length though?
[22:17:12] RickHull: actually, I guess HTTP does have significant newlines between headers and body and for header parsing
[22:17:19] RickHull: yeah, whups :)
[22:17:59] apeiros: catphish: for quick & dirty parsing, strscan/StringScanner is pretty nice
[22:19:24] apeiros: and lends itself easily to "just consume as far as you can". depending on the protocol, one annoying part with parsing a stream is figuring whether your current "token" is actually complete (if it's at the end of the buffer)
[22:19:57] catphish: i think i will just start parsing one line at a time and setting state, and see if i get stuck
[22:21:05] matthewd: Other obvious protocols that come to mind are FTP and SMTP
[22:21:23] BTRE: has joined #ruby
[22:21:29] apeiros: bedtime for me. have fun. or try elixir as RickHull suggested. sounds fun too :)
[22:21:52] RickHull: the last time I looked into FTP I resolved never again
[22:21:57] csk157: has joined #ruby
[22:22:16] impermanence: has joined #ruby
[22:23:02] matthewd: RickHull: You don't need the nasty data-connection parts to deal with the base protocol, which is actually simpler/less stateful than SMTP
[22:24:20] benzrf: has joined #ruby
[22:24:59] catphish: for general interest, this is my server class, showing how data comes in, and how i will process it https://paste.ubuntu.com/25861537/
[22:25:23] benzrf: has left #ruby: ("WeeChat 1.9.1")
[22:25:25] catphish: process_r is called any time new data arrives in the receive buffer
[22:25:52] catphish: i'll add a bunch of state to consume_line and i should be ok
[22:26:19] catphish: arrays are the only real annoyance
[22:28:56] cadillac_: has joined #ruby
[22:30:16] RickHull: i can't imagine that @read_buffer does what you want
[22:31:01] noobineer: has joined #ruby
[22:31:10] catphish: it's a read buffer, it just contains that data that's come from a socket but not yet been consumed
[22:31:28] RickHull: let's say my hypothetical redis str sender opens up a connection. and sends a character per second
[22:31:36] hahuang65: has joined #ruby
[22:31:40] havenwood: Any suggestions for piping faster?: https://gist.github.com/havenwood/582b37dd36491f3997dbb3cde1235742
[22:31:47] havenwood: I used all the tricks I know.
[22:32:05] pskosinski_: has joined #ruby
[22:32:05] pskosinski_: has joined #ruby
[22:32:17] catphish: RickHull: in that situation, process_r will be called repeatedly, @read_buffer will look like "a" then "ab" then "abc" each time
[22:32:18] havenwood: Which gets it from a base of about 7.5MiB/s up to 15MiB/s.
[22:32:19] matthewd: havenwood: "y\n"
[22:32:44] Papierkorb: move the $global into a local var, maybe that's a bit faster
[22:32:48] Papierkorb: I'd also pull the constant into one
[22:32:53] havenwood: matthewd: yup, thanks!
[22:32:56] catphish: RickHull: this is why i do nothing until it contains a newline
[22:33:10] havenwood: matthewd: Capacity 2 with \n gets it to 20MiB/s, good stuff.
[22:33:20] RickHull: catphish: how many times do these methods get called?
[22:33:45] catphish: RickHull: in your example, once per second, ie whenever data arrives
[22:33:56] matthewd: havenwood: After that, maybe "y\n" * 2048
[22:34:29] RickHull: ok, seems fine I guess
[22:34:48] tomphp: has joined #ruby
[22:35:16] catphish: RickHull: this concept works extremely well, as long as you know when you have enough data buffered to process it
[22:36:07] jphase: has joined #ruby
[22:36:12] Papierkorb: havenwood: https://gist.github.com/Papierkorb/4caa616ecd96f9426695049f98615e2c Using locals gets it to 41MiB/s for me
[22:36:17] enterprisey: has joined #ruby
[22:36:36] havenwood: matthewd: Well, that takes the cake - "y\n" * 2048, capacity 4096 I'm seeing 2GiB/s.
[22:36:38] al2o3-cr: has joined #ruby
[22:37:06] havenwood: Papierkorb: nice, another good trick
[22:37:13] matthewd: havenwood: Have you considered `system("yes")`? ;)
[22:37:41] havenwood: matthewd: Purely a exercise for "fun", or I'd use GNU yes, no doubt!
[22:38:12] catphish: i just realised, i'm somewhat overcomplicating this problem, the specification says "Clients send commands to a Redis server as a RESP Array of Bulk Strings", so actually i only need to parse 2 data types, and i know the order they will arrive
[22:38:54] havenwood: https://matthias-endler.de/2017/yes/
[22:39:14] Nicmavr: has joined #ruby
[22:39:33] Papierkorb: I'd try with sendfile(3) too
[22:39:50] Papierkorb: Maybe there's a way to make it send a ringbuffer in a cycle
[22:40:07] Papierkorb: zero copy yes, everything else is too slow
[22:40:29] john__: has joined #ruby
[22:40:54] Papierkorb: or if no ringbuffer, maybe it could be instructed to send the same buffer over and over again. Even if there's a roundtrip to ruby, it could be "worthwhile"
[22:43:33] mson: has joined #ruby
[22:45:48] RickHull: catphish: what happens if the stream stalls out -- there are many ways for a socket to die that are nontrivial to detect. does the event loop expire stale connections?
[22:46:17] marr: has joined #ruby
[22:47:29] TinkerTyper_: has joined #ruby
[22:47:32] RickHull: i haven't done much in the trenches of nonblocking io, preferring blocking reads with timeouts. gimme the data or fail the socket in a manageable way
[22:50:34] eckhardt: has joined #ruby
[22:51:16] evie_hammond: has joined #ruby
[22:52:00] RickHull: havenwood: does ?y do anything for you?
[22:52:13] havenwood: RickHull: nope
[22:52:20] havenwood: RickHull: putc also slows it down
[22:52:41] RickHull: I wouldn't think so. came across that syntax for the first time in a long time recently
[22:52:54] RickHull: my ruby-mode doesn't like it
[22:53:15] havenwood: RickHull: it used to be problematic because of different behavior in 1.8 and earlier
[22:53:37] ruby[bot]: havenwood: # => 97 (https://eval.in/890391)
[22:53:46] ruby[bot]: havenwood: # => "a" (https://eval.in/890392)
[22:54:09] baweaver: havenwood: that's just asciing for trouble
[22:54:12] RickHull: 18>> "asdf"[0]
[22:54:13] ruby[bot]: RickHull: # => 97 (https://eval.in/890393)
[22:54:40] havenwood: >> "asdf".chr
[22:54:41] ruby[bot]: havenwood: # => "a" (https://eval.in/890394)
[22:54:50] tcopeland: has joined #ruby
[22:54:55] havenwood: baweaver: wow, i had to read that twice to catch it
[22:54:59] leah2: has joined #ruby
[22:55:00] havenwood: long day...
[22:55:21] noobineer: has joined #ruby
[22:55:56] cdg: has joined #ruby
[22:55:59] Papierkorb: And it's not even friday
[22:59:24] catphish: RickHull: there is a handle_close method it will call if it's defined to let the developer know the connection has failed, if you don't define it, it will just discard your instance
[22:59:34] catphish: which is generally what you want
[23:00:31] RickHull: i can believe it, but blocking read will throw a lot more Errno stuff at you than https://github.com/adamcooke/myxi/blob/master/lib/myxi/eventable_socket.rb#L22
[23:01:01] RickHull: i'm not sure if a nonblocking read might say nope, or if there are timeouts or expiry
[23:02:17] Nicmavr: has joined #ruby
[23:02:47] RickHull: what about something slowloris like? send a character per hour? just wondering what the approach is
[23:05:31] catphish: there are various iterations of this library, and apps based upon it, best practice would be to define a timeout for how long a request can take from the first to the last byte, and how long a connection can be idle (between requests), also a limit on the number of unprocessed bytes in the buffer
[23:06:08] catphish: myxi is quite a primative version of this pattern
[23:06:25] catphish: but the only one that's open source
[23:06:28] thinkpad: has joined #ruby
[23:07:13] catphish: https://github.com/adamcooke/myxi/blob/master/lib/myxi/session.rb#L73 << those are the only errors i've seen the readpartial raise
[23:07:37] catphish: other errors inherit from those
[23:07:59] Kestrel-029: has joined #ruby
[23:07:59] Kestrel-029: has joined #ruby
[23:08:04] RickHull: cool. my main TCP reading was 2-byte or 4-byte binary length-to-follow, so i just needed some concurrency over simple blocking reads.
[23:08:54] catphish: if you're using threads, you can just do a simple read(2).unpack then read(n)
[23:09:31] catphish: with event driven, you basically ignore what's in the buffer until it's > n bytes, then process it
[23:10:38] orbyt_: has joined #ruby
[23:10:46] [[thufir]]: has joined #ruby
[23:10:48] benzrf: has joined #ruby
[23:11:11] benzrf: im using the rmega gem to download a bunch of files from mega.co.nz, and it's working great, except for one thing
[23:11:12] apeiros: has joined #ruby
[23:11:26] benzrf: when i resume a download, it takes a ton of cpu and a pretty long time to verify the integrity of what's downloaded so far
[23:11:33] benzrf: i snooped around in the code a bit and i found this: https://gist.github.com/cea67734c3ea4df0914ae1066f818680
[23:11:44] benzrf: is it just me, or is this something that should be implemented in C and not ruby?
[23:12:11] catphish: openssl is C
[23:12:21] Papierkorb: That doesn't look really efficient, no
[23:12:33] catphish: almost everything in there is just calling openssl C bindings
[23:12:46] benzrf: catphish: yeah, but it's looping _in ruby_ over _each 15-byte chunk_
[23:12:46] veeti: has joined #ruby
[23:12:50] catphish: although that loop looks painful
[23:12:53] catphish: block = data[n..n+15]
[23:12:57] benzrf: is there much overhead in ruby<->c calls?
[23:13:08] Papierkorb: catphish: If a block is small, (Apparently only 16B), then the dispatch will eat the timesave easily
[23:13:19] DTZUZO: has joined #ruby
[23:13:31] catphish: nor much overhead in c calls, but that loop may be sucky, 16 byte chunks
[23:13:31] test: has joined #ruby
[23:14:20] enterprisey: has joined #ruby
[23:14:20] catphish: i'd look into whether cipher.update can take multiple blocks at once
[23:14:21] benzrf: that said, it _is_ managing to chew through about 30M/s - i have no idea whether that's good or bad
[23:14:32] benzrf: still, it's making my fan turn on, and i feel like it shouldnt be
[23:14:37] Papierkorb: That's awful
[23:14:40] benzrf: ok i figured :)
[23:14:49] matthewd: You hope(!) those are 16 byte chunks
[23:14:51] benzrf: i just didnt want to sound presumptuous about how fast things should be
[23:15:12] catphish: i'd try various things to improve that
[23:15:21] benzrf: i wonder if it's still maintained and if i can PR something
[23:15:22] matthewd: Depending on where data's coming from, they could be 16 character chunks. And that's really not going to be the fastness.
[23:15:36] benzrf: last commit jun 12, hm
[23:15:58] benzrf: matthewd: it's dealing with non-text data so id imagine it's not chars
[23:16:09] RickHull: https://github.com/topac/rmega/tree/master/lib/rmega/crypto\
[23:16:15] RickHull: oops, not fixing it
[23:16:17] catphish: hopefully data is a binary string
[23:16:24] RickHull: it's just the mac though right?
[23:17:15] matthewd: Does that update method not accept much larger strings? It sounds like it should.
[23:17:15] catphish: i don't know enough about that to know what it's running though that method
[23:17:34] stephh: has joined #ruby
[23:17:46] catphish: but it does seem that it mostly passes the data in large blocks, like in cipher.update(data) in aes_cbc_decrypt
[23:17:49] benzrf: i dont know anything about any of this - i just poked around in the code til i found where it was doing integrity checks and then went "oh huh an awful lot of this is in ruby"
[23:18:07] catphish: well it's a ruby program :)
[23:18:19] benzrf: usually i do not expect heavy data crunching to be in ruby.
[23:18:28] catphish: but i suspect you need to actually see where it's spending time rather than guessing
[23:18:43] benzrf: maybe the creator hasnt used it on anything bigger than a single 100MB file
[23:18:50] RickHull: benzrf: as noted, this is mostly executed in C
[23:19:07] Papierkorb: RickHull: 16B at a time
[23:19:07] catphish: it is indeed mostly handed off to C, but maybe there's something big that isn't
[23:19:08] RickHull: the ruby lib is a thin wrapper around a C lib
[23:19:13] jphase: has joined #ruby
[23:19:17] catphish: Papierkorb: only in that one method
[23:19:17] RickHull: Papierkorb: that loop is just for the MAC
[23:19:32] catphish: i dont know how much data in in the "MAC" data string
[23:19:46] matthewd: RickHull: Which is surely what's being used "to verify the integrity"
[23:19:47] catphish: if it's large, that would suck
[23:20:00] benzrf: im downloading multiple seasons of a tv show in 1080p
[23:20:04] catphish: i'd check that, it may be the issue if its verifying a large file
[23:20:13] apeiros: has joined #ruby
[23:20:14] benzrf: so ive been doing it incrementally
[23:20:17] catphish: benzrf: maybe not mention that part
[23:20:20] benzrf: and it's been taking forever to finish checking and start actually downloading
[23:20:26] AndBobsYourUncle: has joined #ruby
[23:20:56] PresidentBiscuit: has joined #ruby
[23:20:59] benzrf: i suppose i can turn off integrity check
[23:21:07] benzrf: but id prefer not to realize too late that one of the files got cut off
[23:21:18] matthewd: I think that loop just needs to be changed to use chunks of a sensible size
[23:22:03] catphish: i didn't understand http://ruby-doc.org/stdlib-2.0.0/libdoc/openssl/rdoc/OpenSSL/Cipher.html#method-i-update well enough to understand the implications of that
[23:22:28] catphish: but i don't see why you can't just hand it the full string, correctly padded
[23:22:39] benzrf: ACTION shrugs
[23:22:42] benzrf: i didnt write this :P
[23:23:05] benzrf: be back later
[23:23:06] catphish: in my experience, when a developer suddenly stops doing something simple and fast, and instead does something complicated and slow, there's a reason
[23:23:25] catphish: maybe that reason was purely that he didn't know how to pad it
[23:23:32] catphish: but maybe something more complicated
[23:23:54] matthewd: My guess is either that they hit "data too big to make output buffer" and fell back to a definitely-known-safe value, or yeah, it's the padding
[23:24:36] matthewd: Worst case is changing it affects the actual mac calculation (though I don't think it will), in which case that would be immediately obvious
[23:24:53] Papierkorb: 128Bit =~ 16B ;)
[23:25:13] matthewd: (assuming you have one known-good file)
[23:25:23] Papierkorb: considering openssl, I'm not sure if I were surprised if it didn't handle chunking itself, or if it did
[23:25:50] catphish: block = data + "\x0"*(16-data.bytesize%16); mac = cipher.update(block)
[23:26:07] catphish: i'd try that first
[23:26:28] catphish: actually not that, it will add a whole block needlessly
[23:26:31] catphish: but something like that
[23:26:37] matthewd: Papierkorb: I'd be surprised if it didn't, and I'd be surprised if there weren't some obscure limitations to how it did it. Best of both worlds. :)
[23:26:57] sandroqz: has joined #ruby
[23:29:30] catphish: block = data + "\x0"*((16-data.bytesize%16)%16);
[23:29:33] apeiros: has joined #ruby
[23:29:35] catphish: that will pad it correctly
[23:29:47] catphish: but i don't know if that's the solution :)
[23:29:50] matthewd: catphish: Don't need the inner %
[23:30:36] catphish: matthewd: the negative scares me, but i suspect you're correct
[23:31:06] naprimer3: has joined #ruby
[23:32:26] catphish: there's a scary table on this page https://en.wikipedia.org/wiki/Modulo_operation
[23:33:05] catphish: result depends on programming language, i don't care for it
[23:33:28] RickHull: ruby also has Numeric#modulo which apparently behaves differently from % TIL
[23:34:19] ElDoggo: has joined #ruby
[23:35:50] Technodrome: has joined #ruby
[23:36:23] enterprisey: has joined #ruby
[23:39:21] raynold: has joined #ruby
[23:42:09] catphish: yay, my parser works :) it's much simpler now i know what data types i need to worry about, still messy with all the state but works well
[23:42:53] joast: has joined #ruby
[23:42:56] sagax: has joined #ruby
[23:51:22] nadir: has joined #ruby
[23:56:44] Radar: >> "Gray, James"[/(\w+), (\w+)/, 1]
[23:56:45] ruby[bot]: Radar: # => "Gray" (https://eval.in/890399)
[23:56:47] Radar: >> "Gray, James"[/(\w+), (\w+)/, 2]
[23:56:49] ruby[bot]: Radar: # => "James" (https://eval.in/890400)
[23:57:32] Papierkorb: you mean the capture group selection thing?
[23:59:09] Radar: Yeah, I didn't know you could specify a second argument of a number.
[23:59:28] Radar: I knew about [<regex>] but not [<regex>, <num>]
[23:59:35] s3nd1v0g1us: has joined #ruby
[23:59:43] Papierkorb: that feature is a life changer
[23:59:56] RickHull: it looks like 3 args, two halves of a regex :)