« Back to channel list

#ruby - 21 March 2019

« Back 1 day Forward 1 day »
[00:01:16] orbyt_: has joined #ruby
[00:11:04] enix: has joined #ruby
[00:11:12] enix: has left #ruby: ()
[00:14:08] AJA4351: has joined #ruby
[00:15:12] Swyper: has joined #ruby
[00:16:17] gheegh: has joined #ruby
[00:18:00] gheegh: hey all, anyone have a suggestion as to how to "memoize" a dynamic singleton class variable?
[00:19:55] gheegh: I've got a folder that has a bunch of files in it that i'm converting into class methods on a class. I just realized that one of hte problems is that its reloading them from disk every time it's called, versus just 1 time. I need to "memoize" them.. but i'm not sure exactly how to do that. Here's a gist.. imagine the files as something that i'm turning into Arrays..
[00:19:57] gheegh: https://gist.github.com/wflanagan/e34d74a0586c0bd71a46106abd6341c8
[00:20:17] Devalo: has joined #ruby
[00:21:17] minimal_life: has joined #ruby
[00:26:06] kshitij: has joined #ruby
[00:26:53] Swyper: has joined #ruby
[00:39:02] CJKinni: has joined #ruby
[00:39:56] ur5us: has joined #ruby
[00:44:25] havenwood: gheegh: So you're using the Names class as a singleton?
[00:44:58] luminousnine-: has joined #ruby
[00:44:58] luminousnine-: has joined #ruby
[00:45:18] havenwood: gheegh: Have you looked at Ruby's Singleton module?
[00:45:51] gheegh: so, this works.. its just that it seems to reload the method everytime it's called
[00:46:05] havenwood: gheegh: Usually to memoize you do something along the lines of: @remembered ||= do_the_work
[00:46:24] gheegh: that doesn't work in the def from what I can tell
[00:46:41] orbyt_: has joined #ruby
[00:47:13] gheegh: the problem is the name is dynamic
[00:47:42] gheegh: so setting @#{dyanmic_method_name} ||= do_the_work doesn't seem to work
[00:54:18] gix-: has joined #ruby
[00:57:14] Swyper: has joined #ruby
[01:07:27] teclator: has joined #ruby
[01:10:47] orbyt_: has joined #ruby
[01:26:31] al2o3-cr: hey, havenwood
[01:26:51] Azure: has joined #ruby
[01:27:33] al2o3-cr: check coerion
[01:27:41] al2o3-cr: &>> class Hash def coerce(x) [self.values.sum, x] end end; def add(*args) args.sum end; add **{a: 12, b: 12, c: 18}
[01:27:43] rubydoc: # => 42 (https://carc.in/#/r/6j9l)
[01:45:46] Nicmavr: has joined #ruby
[01:52:13] jrafanie: has joined #ruby
[01:54:47] jrafanie: has joined #ruby
[01:58:01] jrafanie: has joined #ruby
[02:01:46] rafadc: has joined #ruby
[02:42:48] jrafanie: has joined #ruby
[02:54:08] mangold: has joined #ruby
[03:04:29] isakovic: has joined #ruby
[03:24:11] Swyper: has joined #ruby
[03:27:05] apparition: has joined #ruby
[03:38:41] i1nfusion: has joined #ruby
[03:49:57] tsm: has left #ruby: ()
[03:52:21] tdy: has joined #ruby
[03:52:26] esrse: has joined #ruby
[03:52:55] havenwood: al2o3-cr: yikes!
[04:10:16] braincrash: has joined #ruby
[04:13:45] sauvin: has joined #ruby
[04:21:46] Devalo: has joined #ruby
[04:46:34] alexeev: has joined #ruby
[04:47:45] segy: has joined #ruby
[04:47:54] x0F: has joined #ruby
[04:53:44] kapil____: has joined #ruby
[04:59:47] Swyper: has joined #ruby
[05:31:06] Devalo: has joined #ruby
[05:31:35] dviola: has joined #ruby
[05:44:05] laaron: has joined #ruby
[05:55:54] t0x: has joined #ruby
[05:56:30] conta: has joined #ruby
[05:57:22] tpanarch1st: has joined #ruby
[06:07:25] Rudd0: has joined #ruby
[06:31:51] bjpenn: has joined #ruby
[06:37:10] za1b1tsu: has joined #ruby
[06:42:47] reber: has joined #ruby
[06:51:09] Swyper: has joined #ruby
[06:53:53] waheedi: has joined #ruby
[06:57:17] clemens3: has joined #ruby
[07:02:03] Renich: has joined #ruby
[07:05:21] iMadper: has joined #ruby
[07:19:38] iMadper: has joined #ruby
[07:19:42] Renich: has joined #ruby
[07:25:51] Dbugger: has joined #ruby
[07:28:05] Tau: has joined #ruby
[07:37:19] andikr: has joined #ruby
[07:53:11] mikecmpbll: has joined #ruby
[07:55:48] Ai9zO5AP: has joined #ruby
[07:59:09] schleppel: has joined #ruby
[08:06:31] rindolf: has joined #ruby
[08:09:51] _joes_: has joined #ruby
[08:16:47] aufi_: has joined #ruby
[08:21:34] TomyWork: has joined #ruby
[08:22:19] lxsameer: has joined #ruby
[08:22:55] laaron: has joined #ruby
[08:29:37] iMadper: has joined #ruby
[08:34:12] foxxx0: has joined #ruby
[08:38:53] Flyingdog: has joined #ruby
[08:39:37] grr12314: has joined #ruby
[08:47:57] _joes_: has joined #ruby
[08:59:41] Swyper: has joined #ruby
[09:02:15] claudiuinberlin: has joined #ruby
[09:02:58] mikecmpbll: has joined #ruby
[09:12:06] _joes_: has joined #ruby
[09:19:08] i1nfusion: has joined #ruby
[09:36:43] deathwishdave: has joined #ruby
[09:37:25] themsay: has joined #ruby
[09:44:30] alem0lars: has joined #ruby
[09:49:45] RougeR: has joined #ruby
[09:49:57] RougeR: does lantins come here at all?
[09:50:20] RougeR: also anyone else got experience with resque, ive got a fair bit and am trying to implement some plugin logic
[09:52:58] vondruch_: has joined #ruby
[09:57:32] alexeev: has joined #ruby
[10:04:50] deathwishdave: has joined #ruby
[10:08:39] AJA4350: has joined #ruby
[10:09:31] Swyper: has joined #ruby
[10:11:07] waheedi: has joined #ruby
[10:16:05] Swyper: has joined #ruby
[10:16:09] zenspider: gheegh: there's pretty simple ways around that... tho looking at your code, I'd start by pulling the File.read out of the define_method. Use the power of the closure.
[10:30:40] vondruch: has joined #ruby
[10:31:33] Devalo: has joined #ruby
[10:33:11] alem0lars: has joined #ruby
[10:47:30] dminuoso: has joined #ruby
[11:00:36] _joes_: has joined #ruby
[11:02:11] dminuoso: Is there a canonical way to feed build flags into native gems?
[11:02:43] stooj: has joined #ruby
[11:04:34] segy: has joined #ruby
[11:05:40] alexeev_: has joined #ruby
[11:07:22] dminuoso: Specifically I see some mention of `gem install ... -- --build-flags [options]` but the behavior of those build flags is not clearly documented.
[11:16:27] Swyper: has joined #ruby
[11:19:41] mangold: has joined #ruby
[11:35:10] dollyrocker: has joined #ruby
[11:35:19] dollyrocker: has left #ruby: ()
[11:37:35] ldnunes: has joined #ruby
[11:40:28] lupine: has joined #ruby
[11:45:14] alexeev: has joined #ruby
[11:45:31] stryek: has joined #ruby
[11:46:39] reber: has joined #ruby
[12:02:55] madhatter: has joined #ruby
[12:03:02] garyserj2: has joined #ruby
[12:05:05] garyserj2: has joined #ruby
[12:11:58] bmurt: has joined #ruby
[12:20:52] m27frogy: has joined #ruby
[12:21:50] clemens3: has joined #ruby
[12:25:21] alexeev: has joined #ruby
[12:39:53] r3m: has joined #ruby
[12:56:28] conta1: has joined #ruby
[12:58:50] deathwishdave: has joined #ruby
[13:00:08] ams__: has joined #ruby
[13:03:01] za1b1tsu: has joined #ruby
[13:07:04] _joes_: has joined #ruby
[13:23:54] jrafanie: has joined #ruby
[13:24:53] adam12: dminuoso: I _think_ it's related to how their extconf.rb file is configured. Options available in --build-flags are related to what enable_config methods are called in extconf.rb.
[13:25:14] adam12: dminuoso: So it's likely up to the library author to provide access to specific build flags.
[13:25:27] adam12: dminuoso: If this is what I think you're referring to, anyways.
[13:33:03] dminuoso: adam12: Gotcha, I was already on that track patching a rather silly written library ruby-oci8 which simply fails to build on nix because the author thought it would be nice to deprecate and remove any dir_config controllable --with-oracle-instantclient flags..
[13:35:57] adam12: dminuoso: Story of my life, since /usr/local/lib isn't in LD_LIBRARY_PATH on FreeBSD.
[13:36:49] dminuoso: adam12: Ah that blows. Same library?
[13:37:36] dminuoso: At least LD_LIBRARY_PATH is patchable with no effort. On nix I dont even have /sbin and some packages have hardcoded paths for that..
[13:38:02] dminuoso: Not that Im trying to compare who is worse off..
[13:38:15] adam12: dminuoso: Nope. I actually don't run into missing flags _too_ often, thankfully. Just some libraries (like sqlite) need a bit of help to compile.
[13:54:23] griffindy: has joined #ruby
[13:56:18] jrafanie: has joined #ruby
[13:59:54] Swyper: has joined #ruby
[14:00:42] Renich: has joined #ruby
[14:04:00] gnufied: has joined #ruby
[14:09:21] segy: has joined #ruby
[14:13:27] mangold: has joined #ruby
[14:16:54] Dbugger: has joined #ruby
[14:17:16] bogn: has joined #ruby
[14:26:39] alexeev: has joined #ruby
[14:28:18] VladGh: has joined #ruby
[14:33:09] Devalo: has joined #ruby
[14:33:59] VladGh: has joined #ruby
[14:37:20] dar123: has joined #ruby
[14:39:13] al2o3-cr: has joined #ruby
[14:39:22] TvL2386_: has joined #ruby
[14:39:53] iNs: has joined #ruby
[14:44:09] Swyper: has joined #ruby
[14:51:59] al2o3-cr: has joined #ruby
[14:53:48] i1nfusion: has joined #ruby
[14:54:27] tdy: has joined #ruby
[15:01:11] mistergibson: has joined #ruby
[15:02:00] bogn: has joined #ruby
[15:02:20] mistergibson: Question: anyone have docs on getting unicorn to listen to multiple IP addresses?
[15:03:53] bogn: has joined #ruby
[15:04:33] bogn: has joined #ruby
[15:08:29] Swyper: has joined #ruby
[15:08:48] bogn: has joined #ruby
[15:09:11] _joes_: has joined #ruby
[15:09:28] polishdub: has joined #ruby
[15:11:19] grilix: has joined #ruby
[15:14:25] c-c: mistergibson: a http-server?
[15:15:17] mistergibson: c-c: yeah, it is a replacement (I'm thinking) for puma
[15:15:49] mistergibson: c-c: I know how to make it do multiple ports on an IP, but I'd rather do A port on Many IPs
[15:16:44] c-c: it sounds like "wha, mu-mu-multiple IP's?!" to me
[15:16:53] c-c: how can your machine have multiple IP's
[15:17:13] t0x: 2 network cards
[15:17:24] naught-fowl: has joined #ruby
[15:17:34] t0x: or maybe he wants load-balancing across a multiple of machines
[15:20:20] beefjoe: has joined #ruby
[15:20:35] havenwood: mistergibson: you should be able to reverse proxy to the Unicorn socket from whatever you'd like
[15:21:07] mistergibson: havenwood: yes, the key though is aligning the workers and IPs to proxy in the first place
[15:21:21] mistergibson: I like HAProxy for that
[15:21:48] mistergibson: I'll dork with unicorn configurator and see if I can bump into a solution'
[15:21:52] alexeev: i think nginx would great resolve your problem
[15:22:56] alexeev: but set host to 0.0.0.0 should also resolve the problem, isn't it?
[15:26:56] Inline: has joined #ruby
[15:27:33] hightower2: has joined #ruby
[15:35:02] Swyper: has joined #ruby
[15:39:40] orbyt_: has joined #ruby
[15:42:12] Swyper: has joined #ruby
[15:42:14] alexeev: has joined #ruby
[15:42:44] alexeev_: has joined #ruby
[15:45:31] rippa: has joined #ruby
[15:46:04] Renich: has joined #ruby
[15:48:53] spiette: has joined #ruby
[16:06:02] madhatter: has joined #ruby
[16:19:32] RougeR: i might be being daft here
[16:19:35] RougeR: but im a bit stuck
[16:20:25] RougeR: how do i access a 'private' instance method when inside a class singleton method
[16:20:54] havenwood: RougeR: from within the instance, or with instance_variable_get
[16:21:07] havenwood: RougeR: have an example snippet you can extract and gist?
[16:21:22] RougeR: havenwood, not really atm. but you might have just answered by question
[16:21:30] RougeR: i could mock soemthing up if this doesnt work
[16:22:00] RougeR: aghh im in a catch 22
[16:22:02] RougeR: okay yeah
[16:22:09] RougeR: let me mock it up and show you
[16:23:33] skryking: has joined #ruby
[16:25:31] i1nfusion: has joined #ruby
[16:32:27] RougeR: havenwood,
[16:32:28] RougeR: https://dpaste.de/fmRs
[16:32:33] RougeR: i think this is accurate
[16:32:48] RougeR: so i want to call a private instance method from inside a class method
[16:33:39] RougeR: cant instantiate new instance of the class from that method either
[16:33:55] RougeR: unless i use metaprogramming which if i can avoid it for something trivial id rather not
[16:34:05] RougeR: if i have to refactor the class, its possible or i can add another way
[16:34:14] RougeR: but i think there is another way
[16:35:19] Swyper: has joined #ruby
[16:36:15] phaul: does update_task depend on any instance_state? Does it read instance variables?
[16:36:58] phaul: if yes, then where would that state come from? if not, then why is it an instance method?
[16:39:54] bjpenn: has joined #ruby
[16:42:26] orbyt_: has joined #ruby
[16:43:35] phaul: it's a bit like calling a method without a receiver. I guess the answer is no. Not possible
[16:43:41] RougeR: it is possible haha
[16:43:44] RougeR: just found a way!
[16:43:53] RougeR: self.allocate.send(:task_update)
[16:44:17] phaul: and what do you think self.allocate is
[16:44:18] RougeR: this callback method gets hit when a task fails properly and can no longer be retried
[16:44:31] RougeR: phaul, creates a new instance of the class without calling initialize
[16:44:43] RougeR: which i cant call, because its doing other things
[16:44:56] RougeR: (i did not write any of this code before, im merely working on it)
[16:45:37] RougeR: so it would be task_update('failed') for example
[16:45:56] RougeR: everywhere else its called its from an instance method
[16:46:07] RougeR: the calback method has to be a class method due to the third party lib
[16:46:38] RougeR: does that make sens?
[16:48:15] phaul: 163339 RougeR | cant instantiate new instance of the class from that method either
[16:48:20] phaul: ACTION shrugs
[16:48:56] Swyper: has joined #ruby
[16:49:01] RougeR: phaul, hm?
[16:50:27] phaul: important thing is you got it working. let's move on
[16:50:39] RougeR: yeah it is, pleased with it.
[16:50:46] RougeR: sure itll get flagged in pr
[16:50:54] RougeR: im having to use instance_variable_set as well :l
[16:51:05] RougeR: thanks for your help, didnt mean to come off snappy if i did.
[16:51:44] Lytol: has joined #ruby
[16:52:50] Brainium: has joined #ruby
[16:58:32] i1nfusion: has joined #ruby
[17:05:35] KeyJoo: has joined #ruby
[17:12:05] orbyt_: has joined #ruby
[17:24:31] duderonomy: has joined #ruby
[17:29:32] Tau: has joined #ruby
[17:30:42] Hanmac: has joined #ruby
[17:31:44] Renich: has joined #ruby
[17:37:46] conta1: has joined #ruby
[17:37:50] lucasb: has joined #ruby
[17:37:55] i1nfusion: has joined #ruby
[17:45:21] orbyt_: has joined #ruby
[17:46:48] Swyper: has joined #ruby
[17:49:25] xco: has joined #ruby
[17:49:55] xco: hello, how do i get an array like this https://gist.github.com/xcobar/35d0c983a68dd4b849744615dd7a5dfa
[17:50:38] phaul: &ri zip, xco
[17:50:38] rubydoc: xco: I found 3 entries matching method zip. Use &list zip if you would like to see a list
[17:51:30] phaul: https://ruby-doc.org/core-2.5.0/Array.html#method-i-zip
[17:52:37] phaul: xco, see the link that should give you an idea, sorry for the bots response
[17:52:55] xco: no worries
[17:53:05] xco: perfect! exactly what i was looking for!!! thank you :)
[17:53:44] gix: has joined #ruby
[17:59:58] alexeev: has joined #ruby
[18:01:13] KeyJoo: has joined #ruby
[18:01:24] Beams: has joined #ruby
[18:01:58] dinfuehr: has joined #ruby
[18:04:31] i1nfusion: has joined #ruby
[18:04:36] vovs03: has joined #ruby
[18:10:52] Devalo: has joined #ruby
[18:12:08] mikecmpbll: has joined #ruby
[18:12:40] waheedi: has joined #ruby
[18:14:00] kyrylo: has joined #ruby
[18:16:18] ruby-lang062: has joined #ruby
[18:17:17] nowhere_man: has joined #ruby
[18:17:28] ruby-lang062: Hello people. I am working on a Sinatra project and I am using gem 'zip' and I am using this method: Zip::OutputStream.write_buffer It works as expected in my machine but when I run the container I have generated, it complains about uninitialized constant Zip::OutputStream
[18:18:06] ruby-lang062: In my code I have the `require 'zip'` and it runs fine on my machine. In the Dockerfile I have installer zlib and also zlibdev but they both are installed already.
[18:18:20] ruby-lang062: I am using ruby 2.3.8
[18:20:03] RougeR: has joined #ruby
[18:25:34] Swyper: has joined #ruby
[18:26:18] xco: is there a way i can convert a string like this "2015-07-11T09:23:00+01:00" to a Ruby Time object?
[18:27:36] al2o3-cr: xco: Time.iso8601 "2015-07-11T09:23:00+01:00"
[18:28:34] al2o3-cr: xco: you have to require 'time' to use that method.
[18:29:06] xco: al2o3-cr: :) Thanks :)
[18:33:30] xco: al2o3-cr: if i do Time.iso8601(some_later_time) - Time.iso8601(some_earlier_time) i get some number (which i think is in seconds) does this subraction take into account timezones?
[18:38:40] al2o3-cr: hmm, not sure.
[18:41:03] al2o3-cr: xco: i don't think it does, tbh.
[18:41:32] al2o3-cr: wait, yes it does.
[18:41:41] xco: i think to be sure i can convert both times to GMT before i do the substraction, that way i get a real value
[18:43:14] Renich: has joined #ruby
[18:43:41] xco: you’re right, it does :) calculated manually :)
[18:44:09] xco: dealing with time is very tricky
[18:44:20] xco: espcially if different timezones are concerne
[18:44:40] havenwood: i don't think i believe in time
[18:44:56] xco: me neither
[18:45:03] reber: has joined #ruby
[18:45:28] xco: sometimes i think about time and my mind gets messed up
[18:45:40] i1nfusion: has joined #ruby
[18:45:46] agent_white: has joined #ruby
[18:45:56] cd: has joined #ruby
[18:46:23] Swyper: has joined #ruby
[18:46:32] englishm: has joined #ruby
[18:46:41] clemens3: has joined #ruby
[18:47:00] englishm: has joined #ruby
[18:47:08] i1nfusion: has joined #ruby
[18:50:19] havenwood: ruby-lang062: Are they the same version? Zip::VERSION
[18:51:20] havenwood: ruby-lang062: `require 'zip/output_stream'` has been in `zip.rb` for 6 years
[18:51:26] havenwood: https://github.com/rubyzip/rubyzip/blame/master/lib/zip.rb#L17
[18:51:56] havenwood: ruby-lang062: does it work if you explicitly?: require 'zip/output_stream'
[18:52:42] havenwood: ruby-lang062: if you `gem open rubyzip` and take a look at `lib/zip.rb`, it has the require as expected?
[18:53:58] havenwood: ruby-lang062: or I guess a little easier to check the file with: gem which zip
[18:54:35] havenwood: cat "$(gem which zip)" | grep output_stream
[19:04:59] tdy: has joined #ruby
[19:05:13] gnufied: has joined #ruby
[19:07:31] xco: has joined #ruby
[19:16:08] claudiuinberlin: has joined #ruby
[19:21:10] SeepingN: has joined #ruby
[19:23:45] wald0: has joined #ruby
[19:41:35] Renich: has joined #ruby
[19:52:33] xco: i have an array like this [a, b, c, d]
[19:53:01] xco: is there a way i can iterate through it and return a + b, c + d
[19:54:12] xco: Array.each_cons(2) will do i think
[19:55:41] teclator_: has joined #ruby
[19:55:47] xco: nope, not workin
[19:56:55] adam12: each_slice(2) maybe
[19:57:36] krawchyk: has joined #ruby
[19:57:43] xco: yup! got it :D
[19:58:17] t0x: has joined #ruby
[20:00:39] yokel: has joined #ruby
[20:05:07] havenwood: each_slice(2).map(&:sum)
[20:19:41] jj9988: has joined #ruby
[20:36:17] ur5us: has joined #ruby
[20:40:22] Devalo: has joined #ruby
[20:44:56] Swyper: has joined #ruby
[20:45:50] i1nfusion: has joined #ruby
[20:47:38] ldnunes: has joined #ruby
[20:49:57] xco: has joined #ruby
[20:51:17] graft: has joined #ruby
[20:57:33] emilford: has joined #ruby
[21:04:05] grilix: has joined #ruby
[21:15:41] Ai9zO5AP: has joined #ruby
[21:26:53] i1nfusion: has joined #ruby
[21:32:28] hightower2: has joined #ruby
[21:34:45] themsay: has joined #ruby
[21:35:28] AJA4350: has joined #ruby
[21:50:18] kyrylo: has joined #ruby
[21:58:29] hightower2: has joined #ruby
[22:02:12] j6p: has left #ruby: ()
[22:06:28] laaron-: has joined #ruby
[22:06:58] hays: has joined #ruby
[22:09:00] hightower2: has joined #ruby
[22:12:16] Renich_: has joined #ruby
[22:14:32] heftig: has joined #ruby
[22:14:49] heftig: has joined #ruby
[22:15:21] heftig: has left #ruby: ()
[22:19:57] Brainium: has joined #ruby
[22:32:12] mikeiniowa: has joined #ruby
[22:34:56] zenspider: ACTION loves each_cons and each_slice soooo much
[22:38:17] Junaos: has joined #ruby
[22:42:35] xco: has joined #ruby
[22:51:00] hightower2: has joined #ruby
[22:51:07] ellcs: has joined #ruby
[22:57:51] ams__: has joined #ruby
[22:59:38] ericboehs: has joined #ruby
[23:02:32] clemens3_: has joined #ruby
[23:04:40] hightower2: has joined #ruby
[23:07:55] i1nfusion: has joined #ruby
[23:19:55] jottr: has joined #ruby
[23:24:40] kyrylo: has joined #ruby
[23:28:52] xco: has joined #ruby
[23:33:09] i1nfusion: has joined #ruby
[23:35:43] jottr: has joined #ruby
[23:38:09] tpanarch1st: has joined #ruby
[23:47:12] naught-fowl: has joined #ruby
[23:49:24] bmurt: has joined #ruby
[23:51:40] jottr: has joined #ruby
[23:52:29] naught-fowl: has joined #ruby
[23:57:42] Swyper: has joined #ruby
[23:59:28] naught-fowl: has joined #ruby