#ruby - 05 April 2018
« Back 1 day Forward 1 day »
[00:03:14] ruby[bot]: havenwood: # => invalid value for Integer(): "03j2r09" (ArgumentError) ...check link for more (https://eval.in/983944)
[06:23:15] law: hey all, I'm trying to debug an older rails app, and back-port the concept of a 'staging' environment into it where there was none before
[06:23:45] law: a lot of this has looked like opening up the .yml files under config/, finding the ones that had 'production', 'common', 'development' sections, etc, and adding a 'staging' section
[06:23:59] law: I've done that for every file I could find under config, but still my app crashes on startup
[06:24:51] law: is there a way to further debug which component is lacking the concept of a 'staging' section, so I can fix it?
[06:28:07] Radar: from /var/mycorp/microservices/vendor/bundle/ruby/2.1.0/gems/rift-0.9.4/lib/rift/client/railtie.rb:18:in `each'
[06:29:47] mikhael_k33hl: I can't seem to raise a custom exception/error: https://gist.github.com/marzdgzmn/9814f23f38918f8af446a26254b0e98d
[06:30:29] mikhael_k33hl: line 65 is executed, but line 66 which raises and exception/error doesn't seem to be executed or it is but I'm not catching/rescuing it correctly
[06:54:23] law: there's a bunch of config files NOT in config/ that have environment stuff in them, I'll modify those and see if that doesn't help
[07:09:23] law: out of curiosity, is there a way to configure the 'thin' app server to only use a single socket for all its server-subprocesses?
[07:10:05] law: my preference is for it to act more like unicorn - one socket-file, multiple workers hanging off that socket
[07:56:48] mikhael_k33hl: I have a thread-safe array that I want to pass on a singleton that acts as an observer that should delete an element when the thread is done. How do I pass that array?
[07:59:08] apeiros: you pass it like any other object? or why do you think there'd be anything special?
[08:01:08] mikhael_k33hl: apeiros: So it'll be pass by reference eh? thought it would be passed by copy
[08:03:13] dminuoso: mikhael_k33hl: So if you do `p(a)` it passes the *reference* inside a by value.
[08:04:09] dminuoso: Ive pondered about this a lot and discussed this with many people. Formally Ruby is call-by-value is you see variables as containing references
[08:05:26] apeiros: ruby doesn't have references the way other languages have them, so "pass by reference vs pass by copy" is not a meaningful consideration
[08:06:13] apeiros: and what happens internally (in cruby the VALUE being copied) is an implementation detail and immaterial to the question
[08:06:44] apeiros: dminuoso: yes, but again, not the same as in other languages. or how do you dereference them?
[08:07:44] dminuoso: apeiros: It has the advantage to be easier to understand from an evaluation strategy point of view
[08:08:07] dminuoso: apeiros: when I say "reference" I mean it in a generic sense, more like pointer. perhaps `reference` is a bit too overloaded.
[08:10:46] apeiros: the point is that a question like "is ruby pass-by-value or pass-by-reference" implies ruby had a different way of how the variable system actually works. it's not a meaningful question since ruby does not.
[08:13:17] apeiros: maybe there is a well defined term for what ruby does. given that many OO languages work this way.
[08:14:31] dminuoso: apeiros: in the "variables are pointers to objects" view, you can apply strict evaluation order of call-by-value, that is arguments are reduced before substituted, and not get confused.
[08:17:27] apeiros: I mean you're correct. it is pass-by-value in that it's impossible to have `a = x; a_obj_id = a.object_id; some_method(a); a_object_id != a.object_id` (obviously without dirty tricks à la evil.rb/fiddle)
[08:20:16] apeiros: hrmpf, I'll use the term "referenced/referencing", maybe we can substitute it for something better later
[08:23:07] apeiros: probably still poor: https://gist.github.com/apeiros/bf3ddb3d332dc01ac43840e0d08b382d
[08:31:30] dminuoso: apeiros: Can you elaborate on what you mean by "the value which is passed is the object, not the variable"
[09:10:38] kke: weird. Pathname.new('/tmp').glob('*') says undefined method glob for #<Pathname..> on 2.4.2 but not on 2.5.1. from the docs it looks like it was already there at least in 2.1.0.
[09:16:37] kke: looks like Pathname.glob('/tmp/*') does pretty much the same thing so that will have to do.
[10:22:20] TheOnlyBouncer: Good day, question, my system just upgraded my ruby version and now my installed gem applications don't work anymore (still pointing to the old ruby version), any tips on fixing this?
[12:29:52] kke: Logger.new($stdout).instance_variable_get(:@logdev).dev.isatty <-- must be a prettier way
[12:33:02] apeiros: or you mean once you only have the logger instance? it's not unlikely that in that case, there's no nicer way, and you might even have to guard against isatty not being present
[12:33:24] apeiros: after all, Logger is supposed to abstract away where you're logging to. it might be something which does not have a isatty method
[12:36:22] kke: also it could just be some "logger-compatible" object which does not have the same internals, so .instance_variable_get is going to break
[13:54:29] Bish_: i want to have text versons of html sides , how do i get a xpath that gives me all text nodes and all a nodes
[13:56:24] Bish_: this is my current approach, but it finds a tags doubled, one time as text node an one time as alink
[17:13:10] hays: can someone help with figuring out how to use this gem, specifically how to make the connection have KEEPALIVE enabled? https://github.com/rmodbus/rmodbus
[17:13:34] hays: I think maybe there is something in the underlying implementation that I need to activate
[17:50:22] hays: if I want to rescue from every error is it usually recommended to just to StandardError?
[17:56:30] al2o3-cr: >> require 'objspace'; ObjectSpace.each_object(Exception.singleton_class).to_a - ObjectSpace.each_object(StandardError.singleton_class).to_a
[17:56:31] ruby[bot]: al2o3-cr: # => [SystemStackError, NoMemoryError, SecurityError, NotImplementedError, LoadError, SyntaxError, Script ...check link for more (https://eval.in/984580)
[18:02:42] hays: yeah im being a bit lazy but in this case I don't think it matters too much, I just don't want to rescue something if something totally nuts happens
[18:03:15] hays: in this case, I'm setting some socket options, and it appears that they are OS specific, so if it doesn't work im just issuing a quick diagnostic message and moving on
[18:03:54] hays: on my system NameError is thrown, but I don't know for sure its always going to be NameError
[18:07:57] al2o3-cr: it could raise a number of exception Errno::ENOPROTOOPT, ArgumentError etc depending on the circumstances
[18:09:12] havenwood: hays: On the right there's a nice visual representation of core error classes: https://go.gliffy.com/go/publish/5152080
[18:11:54] havenwood: hays: Consider `warn` instead of `STDERR.puts`, since #warn respects silencing warnings.
[18:16:17] havenwood: hays: Consider keyword arguments when you have as many as four args, especially if one might be ommitted.
[18:17:13] al2o3-cr: i remember months back you were trying to change some internal @io instance variable, can't specifically remeber what it was now.
[18:20:37] havenwood: hays: Then you can call the method with just the last arg, like: set_keepalive keepcnt: 10
[18:26:21] hays: that's a minor issue--i'll have to make sure my colleague finally updates that ruby version on the system
[18:27:13] havenwood: hays: 2.2 and earlier are not supported versions, so they don't even receive bugfixes or security patches.
[18:31:28] havenwood: hays: A 1.9.3 app should run just fine on 2.0. I don't recall those upgrades being a pain at all.
[18:34:08] hays: havenwood: thankfully I don't need to support those versions too much. when I do I'll sometimes just monkeypatch in the things im using from 2.x as long as its not too much to deal with
[18:34:58] hays: al2o3-cr: yeah. although this is usually just test/startup code so latest/greatest isn't really a priority
[18:35:15] hays: if I was really trying i'd probably learn to use a tool like bundle to get more control over the environment
[18:35:53] hays: did I understand you correctly that rescue already rescues Standard error? but then I guess rescue => e rescues more?
[18:39:44] hays: Ahh, I read about it now I understand. As long as I dont rescue Exception => e im good
[18:42:49] hays: like lets say I don't want to assume a default but instead issue some kind of ArgumentError
[19:06:01] hays: sorry--I had a very strange bug that somehow surfaced when I changed the way I was calling that constructor
[19:10:12] hays: its not worth you reading about it :) basically for some reason a .json file with IP overrides got corrupted (not sure how this happened, it was working yesterday) and this meant an IP wasn't being passed in. So the code was working.
[19:36:49] kevinburke: hi there, can I ask a dumb question? i've been running dtrace on my executing ruby process
[19:38:13] kevinburke: a file in globalid-0.3.7/lib/global_id/global_id.rb calls "require 'global_id/uri/gid'". the file we are looking for is adjacent, in globalid-0.3.7/lib/global_id/uri/gid.rb. but instead of looking there, we stat all ~300 rubygems for <gemname>/lib/global_id/uri/gid.rb
[20:02:46] leitz: Pathname#to_path didn't come around until Ruby 1.9 it seems. So you have to fudge a bit to get Ruby-from-source to compile on a CentOS 6 box.