« Back to channel list

#ruby - 25 February 2019

« Back 1 day Forward 1 day »
[00:01:36] phaul: ACTION is thinking maybe when there is an error we should just let it die and spill the error on stderr instead of the extra work to move it over to stdout. And we should report back stderr.
[00:03:51] s3nd1v0g1us: has joined #ruby
[00:03:51] clemens3: has joined #ruby
[00:05:25] c-c: phaul so you type command but it won't show errors in the console?
[00:05:39] phaul: nah Im pondering about the bot
[00:05:51] rubydoc: # => (https://carc.in/#/r/6d0t)
[00:06:20] phaul: it could report back syntax error correctly with carc.in I think
[00:08:32] mangold: has joined #ruby
[00:09:51] xco: has joined #ruby
[00:15:37] doomspork: has joined #ruby
[00:41:57] rubydoc: has joined #ruby
[00:42:07] rubydoc: stderr: -e:3: syntax error, unexpected rescue (https://carc.in/#/r/6d14)
[00:42:16] phaul: there we go :)
[00:45:07] rubydoc: has joined #ruby
[00:45:16] rubydoc: stderr: -e:3: syntax error, unexpected end (https://carc.in/#/r/6d15)
[00:46:15] phaul: hm. not perfect but it will do
[00:52:14] Sembei: has joined #ruby
[01:05:12] bruul: has joined #ruby
[01:11:23] heino: has joined #ruby
[01:11:31] heino: has left #ruby: ()
[01:30:04] code_zombie: has joined #ruby
[01:39:11] _whitelogger: has joined #ruby
[01:45:12] Nicmavr: has joined #ruby
[02:08:07] eblip: has joined #ruby
[02:18:56] Renich: has joined #ruby
[02:24:25] sleetdrop: has joined #ruby
[02:29:34] donofrio_: has joined #ruby
[03:20:31] wilbert: has joined #ruby
[03:26:47] sleetdrop: has joined #ruby
[04:02:00] wolfshappen: has joined #ruby
[04:09:33] braincrash: has joined #ruby
[05:03:23] v01d4lph4: has joined #ruby
[05:12:15] rippa: has joined #ruby
[05:21:23] duckpuppy: has joined #ruby
[05:28:08] xlued: has joined #ruby
[05:59:57] mangold: has joined #ruby
[06:09:11] _whitelogger: has joined #ruby
[06:14:44] laaron: has joined #ruby
[06:15:19] conta: has joined #ruby
[06:16:37] volkov: has joined #ruby
[06:19:13] reber: has joined #ruby
[06:42:02] tdy1: has joined #ruby
[06:42:42] aupadhye: has joined #ruby
[06:46:17] aufi: has joined #ruby
[06:58:11] barg: has joined #ruby
[06:58:24] barg: are there three different 'byebug's that people use?
[07:04:54] armyriad: has joined #ruby
[07:07:53] rprimus: has joined #ruby
[07:14:53] barg: the thing that david rodriguez wrote, is that pry-byebug, or byebug?
[07:19:42] nakuku: has joined #ruby
[07:24:16] clemens3: has joined #ruby
[07:27:55] al2o3-cr: barg: byebug
[07:30:23] al2o3-cr: pry-byebug uses byebug.
[07:43:19] armyriad: has joined #ruby
[08:04:32] laaron: has joined #ruby
[08:05:23] tdy2: has joined #ruby
[08:17:21] ntt: has joined #ruby
[08:19:17] ntt: Hi, I'd like to extract all values from an Hash with a predefined key. The hash is composed by other hash. Example: h = { :node1 => { :ip =>, ....}, :node2 => { :ip =,...}, ...} , how can I extral all "ip" values in an Array?
[08:19:36] baweaver: What have you tried?
[08:19:49] ntt: flatten
[08:20:02] ntt: but it seems I need to know the "level"
[08:20:06] baweaver: Do you know how map works?
[08:20:21] clemens3: has joined #ruby
[08:21:03] ntt: nope... But i'm going to read the doc. is this the right way to do whis?
[08:21:11] baweaver: &>> [1, 2, 3].map { |v| v * 2 } # Map makes a new list by transforming elements using a function, in this case doubling each number
[08:21:11] rubydoc: # => [2, 4, 6] (https://carc.in/#/r/6d34)
[08:22:05] baweaver: &>> {a: 1, b: 2, c: 3}.map { |k, v| v * 2 } # With a hash it gives you the key and the value
[08:22:06] rubydoc: # => [2, 4, 6] (https://carc.in/#/r/6d35)
[08:22:20] ntt: ok. thank you
[08:22:42] baweaver: So in your case, it'd be something like: values.map { |name, info| ... }
[08:22:53] baweaver: See if you can figure it out from there
[08:23:22] baweaver: This is one of the most powerful tools you'll use in Ruby - https://ruby-doc.org/core-2.6.1/Enumerable.html
[08:23:40] baweaver: Enumerable is in Array and Hash as a way to do all sorts of things to collections
[08:24:09] baweaver: The main ones you'll use are: map, select, find, reduce
[08:25:31] baweaver: If you want a fun way to learn all of that: https://www.youtube.com/watch?v=x3b9KlzjJNM
[08:26:32] teclator: has joined #ruby
[08:28:19] doitliao: has joined #ruby
[08:28:45] doitliao: any body online?
[08:29:09] baweaver: or perhaps we're not
[08:29:31] baweaver: You'll have more luck leading with your question though :)
[08:30:42] cgfbee: has joined #ruby
[08:36:04] ntt: baweaver: thank you. I'm reading the doc. I do not understand if there is the possibility to traverse a very complex Hash reading the value of only one key (in my case "ipaddress") without using map on each sub-hash
[08:36:38] baweaver: ntt: Do you only want the IP?
[08:36:57] ntt: but the Hash is very complex, with multiple Hash inseide
[08:37:08] baweaver: That's not really too complex.
[08:37:17] baweaver: Break it down a bit, you have a hash with nested hashes
[08:37:29] baweaver: the key is the name of the node, and the value is its configuration
[08:37:53] ntt: but should I use map on each value?
[08:38:05] baweaver: So when using map, ask the configuration what the IP is
[08:38:13] baweaver: It's a hash, how do you get a single value from a hash?
[08:38:23] ntt: ok... just a moment... I'll give you a more complex example
[08:39:42] ntt: https://paste.centos.org/view/ed3572f0
[08:40:03] ntt: I need to extract only ipaddress values
[08:41:01] baweaver: You should probably lead with that
[08:41:32] baweaver: So you only need ipaddress?
[08:41:39] baweaver: Not network?
[08:42:10] ntt: just one array with all ipaddresses (without the key, only values)
[08:43:02] baweaver: So really you only need the nodes
[08:43:20] baweaver: Can you use other gems?
[08:44:05] baweaver: Xf.trace(:ipaddress).get_value(hash)
[08:44:20] baweaver: data.map(&Xf.trace(:ipaddress).get)
[08:44:51] baweaver: https://github.com/baweaver/xf
[08:45:45] ntt: wow... ok. I'll give a try. Really thank you
[08:46:32] baweaver: Traces basically go down through a hash until it can finally find a key that matches
[08:46:41] baweaver: or key and value, but that's a different thing.
[08:47:30] ntt: sure. I'm reading documentation on your github repo
[08:47:44] ntt: it works :) thank you
[08:48:05] baweaver: The two articles up top explain how it works
[08:48:40] ntt: I think it's a good idea pass only environment[:nodes] instead the complete hash. This can reduce the complexity and cpu cycles
[08:49:02] baweaver: Yeah, trace is slow-ish because of how it works
[08:49:17] baweaver: Though to be fair it won't matter unless you have something like 10k nodes or more
[08:49:33] baweaver: and even then, maybe a quarter second
[08:49:42] ntt: ok... but I'd like to use best-practices in my code if possible
[08:50:30] baweaver: The answer to what's the best way to do something is: it depends
[08:50:39] mikecmpbll: has joined #ruby
[08:51:14] baweaver: Now if there were a way to potentially know what those paths are you could use dig instead.
[08:52:29] ntt: unfortunately the only information I have is that I have to search in environment[:nodes] (instead of the complete hash)
[08:52:45] ntt: but the number of nodes is small (around 30)
[08:52:47] baweaver: but my advice for sysadmin type tasks: optimize for writing time, not runtime, until it becomes an actual issue.
[08:53:57] V1s1ble: has joined #ruby
[08:54:51] V1s1ble: I'm trying to figure out how to map through dictionary and only produce one dict with lists of sub values: https://bpaste.net/show/c2fc6656e374
[08:54:56] baweaver: for 30 nodes the time difference is non-existent
[08:55:35] V1s1ble: The tricky part is merging the values/lists...
[08:56:05] baweaver: So merge based on similar keys?
[08:56:06] al2o3-cr: ntt: for that example in plain ruby; h[:nodes].map { |k,v| v.values }.map { |ipaddress:, **| ipaddress }
[08:56:34] baweaver: Hash#merge is nice for that.
[09:01:20] baweaver: V1s1ble: https://bpaste.net/show/9b308d3810ec
[09:01:31] baweaver: reduce / each_with_object is good for that type of problem
[09:02:05] baweaver: grep can take a regex (it uses === for compares)
[09:02:18] baweaver: Then just reduce it into a hash with arrays as the default value
[09:08:25] ntt: al2o3-cr: thank you
[09:11:10] V1s1ble: baweaver, cool thanks.
[09:15:40] al2o3-cr: since weechat upgraded to 2.4 it doesn't leave a space between nick when using tab completion. damn annoying.
[09:40:05] queip: has joined #ruby
[09:48:01] phaul: al2o3-cr: same here. Also if I do double tab (on nick complete) it started inserting some emoji junk that I don't have fonts for
[09:50:34] al2o3-cr: phaul: hmm, i don't have that problem with double tab, just the space issue :(
[09:50:48] phaul: must be some script then I have installed
[09:53:53] segy: has joined #ruby
[09:55:42] al2o3-cr: phaul: /set weechat.completion.nick_completer ": "
[09:56:43] phaul: al2o3-cr: works! thanks
[10:00:08] ellcs: has joined #ruby
[10:02:17] wolfshappen_: has joined #ruby
[10:03:44] SuperL4g: has joined #ruby
[10:07:50] Fischmie1: has joined #ruby
[10:08:34] Linuus: Does foreman restart processes if they crash?
[10:17:24] apparition: has joined #ruby
[10:19:38] rubydoc: has joined #ruby
[10:32:43] lxsameer: has joined #ruby
[11:00:21] conta: has joined #ruby
[11:03:08] phaul: has joined #ruby
[11:03:17] rubydoc: has joined #ruby
[11:08:37] crankharder: has joined #ruby
[11:12:08] phaul: has joined #ruby
[11:12:28] rubydoc: has joined #ruby
[11:15:02] KeyJoo: has joined #ruby
[11:20:09] phaul: has joined #ruby
[11:21:53] rubydoc: has joined #ruby
[11:22:29] marmotini_: has joined #ruby
[11:30:15] cisco: has joined #ruby
[12:05:39] mikecmpbll: has joined #ruby
[12:10:33] al2o3-cr: has joined #ruby
[12:20:54] queip: has joined #ruby
[12:24:52] Nicmavr: has joined #ruby
[12:25:03] nowhere_man: has joined #ruby
[12:33:23] stooj: has joined #ruby
[12:39:11] _whitelogger: has joined #ruby
[13:10:48] houhoulis: has joined #ruby
[13:18:38] crankharder: has joined #ruby
[13:33:36] Paraxial: has joined #ruby
[13:37:49] paraxial7: has joined #ruby
[13:37:54] AJA4350: has joined #ruby
[13:38:07] xrexeon: has joined #ruby
[13:38:54] segy: has joined #ruby
[13:42:33] bijan_: has joined #ruby
[13:42:52] tuor: has joined #ruby
[14:09:57] doomspork: has joined #ruby
[14:18:19] bijan_: has joined #ruby
[14:19:33] lucasb: has joined #ruby
[14:27:14] doomspork: has joined #ruby
[14:30:51] jcalla: has joined #ruby
[14:31:49] ryouba: has joined #ruby
[14:32:19] ryouba: is there an 'automated' way (i.e. in a loop inside the initializer or so) to creat attr_accessors for a clasS?
[14:33:34] phaul: sure. inside the class it's just code. attr_* statements are just method calls. You can put them in a loop
[14:34:20] Rapture: has joined #ruby
[14:36:46] phaul: &>> class X; %i(a b c).each { |sym| attr_accessor(sym) }; end; x = X.new; x.a = 1; x.b = x.a; x.c = x.a + x.b
[14:36:49] rubydoc: # => 2 (https://carc.in/#/r/6d4p)
[14:37:40] crankharder: has joined #ruby
[14:41:42] ryouba: phaul: sooo ... everything i'm doing in https://gist.github.com/sixtyfive/38831212415f262ebac2b0136cae16b6 is perfectly fine to do? or is any of it a bad idea?
[14:44:24] segy: has joined #ruby
[14:44:54] phaul: it's fine. but why store something that holds cells inside Entry instead. Like Array or Hash. Probably Array. and then just index []
[14:45:57] phaul: simpler loop would be ('@' .. 'AL').each do |col_letter| ...
[14:47:03] ryouba: phaul: because the cell values are only my input. i plan on adding some methods inside of the Entry class that do stuff with those cell values and produce the output. not sure about the name 'Entry' yet...
[14:48:42] ryouba: wow, nice! thank you for that loop! i didn't think it'd work like that, too. i still feel like it's advanced magic anyways (that it knows to wrap from Z to AA)
[14:51:25] ixti: has joined #ruby
[15:01:08] v01d4lph4: has joined #ruby
[15:01:17] hightower2: has joined #ruby
[15:01:23] phaul: ryouba: https://gist.github.com/070c8bb9ba6fb9a7f11c5755f177f190
[15:01:56] hightower2: Hey folks how would I produce a pointer to a function? E.g. I have an instance method myobj.something() and I want to pass 'something' around like I would pass a block
[15:02:22] phaul: myobj.method(:something)
[15:04:12] barg: was pry invented in between the two? so, byebug then pry then pry-byebug?
[15:04:12] hightower2: phaul, fabulous, thanks!
[15:04:26] hightower2: just brilliant
[15:05:53] havenwood: barg: you can just check the repos, but the order of invention should be pry, byebug, pry-byebug. there were other debuggers for earlier versions of Ruby.
[15:06:05] Sylario: has joined #ruby
[15:06:16] barg: where does a repo gvie away the date of creation?
[15:06:41] havenwood: barg: just look at the first commit
[15:06:45] havenwood: they have dates
[15:06:49] gnufied: has joined #ruby
[15:07:08] Xeago_: has joined #ruby
[15:20:27] jobewan: has joined #ruby
[15:26:49] spacesuitdiver: has joined #ruby
[15:27:08] polishdub: has joined #ruby
[15:29:36] bijan_: has joined #ruby
[15:32:25] barg: pry-byebug initial commit is june 2012 https://github.com/deivid-rodriguez/pry-byebug/commits/master?before=283357cb5837022096373851950a69b37f0a4f8a+455
[15:32:57] barg: byebug initial commit is march 2013 https://github.com/deivid-rodriguez/byebug/commits/master?after=af25ece0b5a43fd857d19a45206653d0c402cd10+2659
[15:33:25] barg: So pry-byebug precedes byebug, (at least looking at initial commit)
[15:35:16] barg: havenwood: what made you think the order was pry, byebug, pry-byebug?
[15:38:16] havenwood: barg: i knew pry preceded the others from memory and presumed the byebug plugin followed the gem, but wasn't sure.
[15:38:26] yokel: has joined #ruby
[15:39:02] havenwood: barg: any particular reason you're curious?
[15:39:52] barg: i'd like to know why there is a pry-byebug and a byebug, is one meant to be an improvement on the other?
[15:41:10] conta: has joined #ruby
[15:43:14] conta: has joined #ruby
[15:43:29] tdy2: has joined #ruby
[15:43:31] jmcgnh: has joined #ruby
[15:44:00] z64: barg: pry-byebug is tooling that implements byebug https://github.com/deivid-rodriguez/pry-byebug/blob/master/pry-byebug.gemspec#L24
[15:44:14] havenwood: barg: the pry plugin does depend on the byebug gem, fwiw: https://github.com/deivid-rodriguez/pry-byebug/blob/master/pry-byebug.gemspec#L24
[15:45:23] havenwood: z64: oh wow, you beat me to the same line :)
[15:46:11] Linuus: Does anyone know if foreman restarts processes if they crash?
[15:49:44] barg: if I want to use pry-byebug, am I meant to do both require 'pry' as well as require 'pry-byebug' or is just require 'pry-byebug' fine?
[15:49:58] barg: I notice that pry-byebug doesn't require that I also require 'byebug'
[15:51:37] Emmanuel_Chanel: has joined #ruby
[15:58:55] Bish: has joined #ruby
[15:59:01] Bish: there is nothing in default ruby that makes
[15:59:19] Bish: [{a:3}].map {|x| x[:a] } less cumbersome, right?
[15:59:41] phaul: .values ?
[16:00:06] Bish: phaul: im guessing u know what i want?
[16:00:23] phaul: maybe not :)
[16:00:50] phaul: ah I missed the first pair of []
[16:00:56] havenwood: &>> >> [{a: 3}].map { |a:| a }
[16:00:57] rubydoc: stderr: -e:2: syntax error, unexpected >> (https://carc.in/#/r/6d5g)
[16:01:59] havenwood: Bish: Assuming there are more keys?
[16:02:16] havenwood: &>> [{a: 3}].flat_map &:values
[16:02:18] rubydoc: # => [3] (https://carc.in/#/r/6d5h)
[16:02:33] Bish: |a:| holy shit that works?
[16:02:34] wolfshappen: has joined #ruby
[16:02:42] havenwood: &>> [{a: 3}].map { |a:| a }
[16:02:43] rubydoc: # => [3] (https://carc.in/#/r/6d5i)
[16:06:41] Fusl: has joined #ruby
[16:09:19] conta: has joined #ruby
[16:11:16] Bish: what is actually the reason hashes dont have method access to it's contents?
[16:11:29] Bish: as long as they're symbols
[16:11:45] Bish: because of things like {to_h:1}
[16:13:33] bruul: has joined #ruby
[16:19:39] leftylink: probably. though I guess you can do something like...
[16:19:55] leftylink: &>> require 'ostruct'; h = {a: 5}; OpenStruct.new(**h).a
[16:19:58] rubydoc: # => 5 (https://carc.in/#/r/6d5k)
[16:20:19] crankharder: has joined #ruby
[16:20:40] leftylink: though you cannot do the same with something like to_s
[16:20:46] leftylink: &>> require 'ostruct'; h = {to_s: 5}; OpenStruct.new(**h).to_s
[16:20:47] rubydoc: # => "#<OpenStruct to_s=5>" (https://carc.in/#/r/6d5l)
[16:21:03] leftylink: so doing that will still cause some surprises
[16:24:39] leftylink: ... and just found out that the ** are not needed in either of those example
[16:25:03] leftylink: learn something every day
[16:33:23] conta: has joined #ruby
[16:40:34] GodFather: has joined #ruby
[16:41:13] gix: has joined #ruby
[16:43:41] conta: has joined #ruby
[16:45:40] segy: has joined #ruby
[16:50:00] cisco: has joined #ruby
[17:02:16] govg: has joined #ruby
[17:04:05] tpanarch1st: has joined #ruby
[17:17:18] cthulchu: has joined #ruby
[17:20:26] jcarl43: has joined #ruby
[17:27:14] [Butch]: has joined #ruby
[17:29:29] eb0t_: has joined #ruby
[17:31:11] cd: has joined #ruby
[17:35:15] ixti: has joined #ruby
[17:35:30] szulak_: has joined #ruby
[17:44:55] Eiam: has joined #ruby
[17:47:26] doitliao: has joined #ruby
[17:51:29] ravenous_: has joined #ruby
[17:52:18] bruul: has joined #ruby
[17:53:22] ravenous_: has joined #ruby
[17:54:21] ravenous_: has joined #ruby
[17:55:28] sameerynho: has joined #ruby
[17:58:31] ravenous_: has joined #ruby
[18:00:17] sagax: has joined #ruby
[18:00:20] doitliao: has joined #ruby
[18:02:20] bijan_: has joined #ruby
[18:03:58] \void: has joined #ruby
[18:09:07] rubydoc: has joined #ruby
[18:09:16] _phaul: has joined #ruby
[18:09:51] bijan_: has joined #ruby
[18:09:52] conta: has joined #ruby
[18:12:16] Net: Should env vars be changable at runtime?
[18:12:33] Net: that is, should setting constants to env vars at the top of module/class definitions be avoided?
[18:13:06] v01d4lph4: has joined #ruby
[18:19:43] _phaul: env vars don't seem to reflect changes from the parent process anyways. that's not a ruby thing
[18:20:50] _phaul: export AA=1; ruby -e 'sleep 3; p ENV["AA"]' &; AA=2
[18:21:28] Net: _phaul: but env vars can be set within the process
[18:21:53] _phaul: yeah but it's a local change anyways, it won't be reflected outside
[18:22:04] Net: so it seems advantageous to me to be able to change env vars at runtime and see their effect without re-interpreting modules & classes
[18:22:50] Net: I'm looking at class Foo; BAR = ENV['BAR'] and wondering if it's a bad idea
[18:23:32] bijan_: has joined #ruby
[18:26:25] _phaul: child processes would inherit the changed environment though. So it's legit to change env vars
[18:28:24] cisco: has joined #ruby
[18:36:59] SeepingN: has joined #ruby
[18:38:16] agent_white: has joined #ruby
[18:39:36] bijan_: has joined #ruby
[18:48:09] bijan_: has joined #ruby
[18:50:07] ravenous_: has joined #ruby
[18:50:34] sagax: how to make real thread in ruby? not green thread
[18:51:14] havenwood: sagax: Ruby threads are system threads in Ruby 1.9+.
[18:51:16] Renich: has joined #ruby
[18:51:30] havenwood: sagax: With the caveat that in CRuby, there's a global VM lock (GVL, previous GIL).
[18:55:17] sagax: how to make thread in ruby without GIL?
[18:55:26] Renich: has joined #ruby
[18:55:31] sagax: or ruby 1.9+ can this?
[18:57:36] nowhere_man: has joined #ruby
[18:58:04] lytol_: has joined #ruby
[18:58:25] Net: What's the point of multi threading ruby if the GIL blocks parallel execution?
[19:01:13] havenwood: sagax: Here's a three-part article that goes into some detail about the GVL: https://www.jstorimer.com/blogs/workingwithcode/8085491-nobody-understands-the-gil
[19:01:54] havenwood: sagax: JRuby or TruffleRuby do not have a GVL. With CRuby it'll sometimes block parallel execution, but not always.
[19:02:21] havenwood: Net: Things like IO release the GVL, which is really handy for doing the slowest things in parallel.
[19:02:23] hiroaki_: has joined #ruby
[19:02:41] Net: havenwood: I see
[19:03:25] leftylink: hmm, I wonder if using backticks in &>> would be unwise
[19:03:29] leftylink: &>> `echo hi`
[19:03:32] rubydoc: # => "hi\n" (https://carc.in/#/r/6d6u)
[19:03:34] havenwood: sagax: You *can* release the GVL manually with Fiddle in CRuby: https://gist.github.com/tenderlove/5733632
[19:04:37] tdy2: has joined #ruby
[19:05:02] leftylink: huh, turns out backticks weren't necessary for the point I needed to make
[19:05:14] havenwood: sagax: Typically, nobody does. Though it's not uncommon to do so in C extensions.
[19:08:13] sagax: thanks to all
[19:14:57] colegatron: has joined #ruby
[19:26:52] wilbert: has joined #ruby
[19:36:55] lucasb: has joined #ruby
[19:41:28] gnufied: has joined #ruby
[19:42:18] conta: has joined #ruby
[19:43:14] Renich_: has joined #ruby
[19:47:04] ivanskie: has joined #ruby
[19:51:51] phaul: leftylink: it's carc.in. that takes any risks. For the bot it's strings.
[19:53:06] phaul: I _think_ carc.in puts you in a fresh docker image per request but I'm not sure.
[19:53:14] phaul: &>> `ls -a`
[19:53:16] rubydoc: # => ".\n..\n" (https://carc.in/#/r/6d7a)
[19:56:20] leftylink: I wanted to demonstrate waiting on IO (and therefore still benefitting from threads in the presence of the GVL) with `sleep 5` but it turns out Kernel.sleep also qualifies
[19:56:45] phaul: ah. ok. I misunderstood you point nm
[20:01:12] jmcgnh: has joined #ruby
[20:02:46] TomyLobo: has joined #ruby
[20:06:58] sriehl: has joined #ruby
[20:08:25] cnsvc: has joined #ruby
[20:12:32] Net: any suggestions for namespacing files to avoid conflicts with gems?
[20:24:48] doitliao: has joined #ruby
[20:32:17] alem0lars: has joined #ruby
[20:32:53] ravenous_: has joined #ruby
[20:32:54] dviola: has joined #ruby
[20:34:57] ivanskie: has joined #ruby
[20:51:43] jmosco: when doing a unit test, I keep getting a character not in range error, but I do not get that error when running the same test outside ruby
[20:51:56] jmosco: https://pastebin.com/RBeLn3g9
[20:51:57] ruby[bot]: jmosco: we in #ruby do not like pastebin.com, it loads slowly for most, has ads which are distracting and has terrible formatting. Please use https://gist.github.com
[20:53:37] jmosco: https://gist.github.com/jonmosco/a57751fbdceb1dec27faa61c2232d1df
[20:57:53] mozzarella: what do you mean outside ruby?
[20:58:32] jmosco: just running the `zsh -c` will do what I expect and return 0
[20:58:48] jmosco: same test but wrapped in the testing framework fails
[21:06:17] al2o3-cr: jmosco: chmod +x /usr/local/opt/kube-ps1/share/kube-ps1.sh and try again.
[21:11:30] jobewan: has joined #ruby
[21:14:35] ged_: has joined #ruby
[21:15:43] leftylink: jmosco: note that when I do `zsh -c "echo $'\u2388 '"` I get a snowflake-like symbol, whereas if I do `env LC_CTYPE=C zsh -c 'echo $"\u2388"'` , I get "zsh:1: character not in range". You may wish to check whether that environment variable (or any of the related environment variables) are set as you expect them to be
[21:18:19] leftylink: where "the related environment variables" are I assume the ones output by `locale` command
[21:19:23] bruul: has joined #ruby
[21:19:49] Fernando-Basso: has joined #ruby
[21:23:51] lunarkitty: I'm curious, are there any new gui gems that have potential?
[21:38:02] tdy2: has joined #ruby
[21:42:38] v01d4lph4: has joined #ruby
[21:45:30] mahlon: has joined #ruby
[21:48:09] conta: has joined #ruby
[21:49:38] spacesuitdiver: has joined #ruby
[21:50:01] hahuang65: has joined #ruby
[21:50:24] jmosco: al2o3-cr: same error
[21:51:50] jaddison: has joined #ruby
[22:02:47] wolfshappen: has joined #ruby
[22:06:03] Swyper: has joined #ruby
[22:06:03] s3nd1v0g1us: has joined #ruby
[22:08:57] SeepingN_: has joined #ruby
[22:09:50] spacesuitdiver: has joined #ruby
[22:11:44] govg: has joined #ruby
[22:11:46] aef: has joined #ruby
[22:12:26] Renich: has joined #ruby
[22:13:42] Fischmop: has joined #ruby
[22:15:00] spacesuitdiver: has joined #ruby
[22:21:22] donofrio: has joined #ruby
[22:25:37] wilbert: has joined #ruby
[22:39:18] mahlon: has joined #ruby
[22:45:11] ged: has joined #ruby
[22:47:28] Swyper: has joined #ruby
[22:49:35] ellcs: has joined #ruby
[22:56:15] doitliao: has joined #ruby
[22:59:58] naeemarsalan: has joined #ruby
[23:00:38] naeemarsalan: hey guys, quick question, cannot seem to find the answer.... its driving me insane
[23:01:58] naeemarsalan: So an rest api returns value of an array like this <Oxidized::Node::Stats:0x00000001dcc228>
[23:02:47] naeemarsalan: what is this var type and and someone point to the correct doc or wiki :D
[23:03:21] ramfjord: has joined #ruby
[23:04:00] mozzarella: has joined #ruby
[23:04:40] noboruma: has joined #ruby
[23:05:07] Nicmavr: has joined #ruby
[23:09:55] phaul: naeemarsalan: have you tried googling it?
[23:10:42] naeemarsalan: @phaul, yes i tried hash array, class array but nothing quite like this
[23:11:11] phaul: https://www.rubydoc.info/gems/oxidized
[23:11:21] phaul: https://www.rubydoc.info/gems/oxidized/0.9.0/Oxidized/Node/Stats
[23:13:15] naeemarsalan: https://www.rubydoc.info/gems/oxidized/Oxidized/Node/Stats Returns: (Hash, Array) — Hash of stats for every status or Array of stats for specific status
[23:13:51] naeemarsalan: But how can i work with that value, if i set it to a var or even as an array ruby throws an error
[23:14:43] phaul: paste your code you tried and the error you are getting
[23:17:27] naeemarsalan: https://pastebin.com/nUeyjGFz
[23:17:28] ruby[bot]: naeemarsalan: we in #ruby do not like pastebin.com, it loads slowly for most, has ads which are distracting and has terrible formatting. Please use https://gist.github.com
[23:17:54] phaul: ignore that for now I'll look at pastebin
[23:18:42] phaul: ah. I get what's happening
[23:18:51] naeemarsalan: thanks its a very silly attempt but im kinda of ideas...
[23:19:06] naeemarsalan: just nudge me in the right direction :P
[23:19:48] phaul: so. when the API returns an object that doesn't define a nice inspect method ruby default's it to the string with the class name and memory/address/object_id thingy
[23:19:57] phaul: let me demonstrate:
[23:20:11] phaul: &>> class X; end; p X.new
[23:20:12] rubydoc: # => #<X:0x000055e59ec84ce8> (https://carc.in/#/r/6d8z)
[23:20:42] phaul: That's just the default string it gives for x.inspect. It's not the object x. It's just a string.
[23:21:14] phaul: if I did:
[23:21:44] phaul: &>> class X; def inspect 'hello!!'; end; end ; p X.new
[23:21:44] rubydoc: stderr: -e:2: syntax error, unexpected tSTRING_BEG, expecting ';' or '\n' (https://carc.in/#/r/6d90)
[23:22:57] havenwood: &>> class X; def inspect; 'hello!!' end end; p X.new
[23:22:58] rubydoc: # => hello!! (https://carc.in/#/r/6d91)
[23:23:24] phaul: thanks havenwood
[23:23:24] havenwood: "#<#{self.class}:#{sprintf "%#018x", object_id << 1}>"
[23:24:22] havenwood: &>> class X; def inspect; "#<#{self.class}:#{sprintf "%#018x", object_id << 1}>" end end; X.new
[23:24:23] rubydoc: # => #<X:0x000055feefb9fb10> (https://carc.in/#/r/6d92)
[23:24:27] havenwood: &>> class X; end; X.new
[23:24:27] rubydoc: # => #<X:0x0000556ac514b970> (https://carc.in/#/r/6d93)
[23:26:14] naeemarsalan: right okay, would i have to define inspect in the api and then i will be able to get the values as normal json most likely?
[23:30:16] phaul: no. Have you tried calling get on it?
[23:30:29] tdy2: has joined #ruby
[23:31:33] naeemarsalan: how would i do that?
[23:32:02] naeemarsalan: how would i even set that as a class?
[23:33:24] phaul: something returned the object that when printed looked like <Oxidized::Node::Stats:0x00000001dcc228>. That object can receive a get (according to the docs). Then it will return a hash.
[23:40:06] Swyper: has joined #ruby
[23:45:06] naeemarsalan: has joined #ruby
[23:45:11] naeemarsalan: Well i tried a few combination and nothing, so its http://url/nodes/stats.json returns an array like { "NodeName" : "#<Oxidized::Node::Stats:0x00000001dcc228>", ....}
[23:45:19] fluxAeon: has joined #ruby
[23:45:58] Radar: naeemarsalan: Can we see some code that will cause this same issue to happen on our machines?
[23:46:49] naeemarsalan: well the project is located here, I'm just making spa https://github.com/ytti/oxidized-web
[23:47:15] naeemarsalan: https://www.rubydoc.info/gems/oxidized/Oxidized/Node/Stats#get-instance_method
[23:47:20] blackmesa: has joined #ruby
[23:47:27] Radar: spa? Like with the water, jets and the bubbles?
[23:48:05] naeemarsalan: single page application :)
[23:48:17] naeemarsalan: that would simpler aha
[23:48:20] Radar: ?mcve naeemarsalan
[23:48:21] ruby[bot]: naeemarsalan: Please provide a Minimal, Complete, and Verifiable example: https://stackoverflow.com/help/mcve
[23:49:28] naeemarsalan: let me a spin up docker container with latest version, pretty application is fine
[23:54:35] armyriad: has joined #ruby
[23:54:41] MyMind: has joined #ruby
[23:56:55] naeemarsalan: ill pick this up tmrw, thanks anyways guys
[23:58:36] spectra: has joined #ruby
[23:58:41] cnsvc_: has joined #ruby
[23:59:05] t0xik: has joined #ruby