« Back to channel list

#ruby - 16 June 2017

« Back 1 day Forward 1 day »
[00:03:54] hutch34: has joined #ruby
[00:06:34] im0nde: has joined #ruby
[00:11:16] cadillac__: has joined #ruby
[00:12:02] hotpanca_: has joined #ruby
[00:12:05] brent__: has joined #ruby
[00:12:47] Hunter1: has joined #ruby
[00:20:46] charliesome: has joined #ruby
[00:24:32] hotpancakes: has joined #ruby
[00:25:30] hotpancakes: has joined #ruby
[00:26:06] jane_booty_doe: has joined #ruby
[00:26:28] jhack: has joined #ruby
[00:27:20] duderonomy: has joined #ruby
[00:34:29] MrBusiness: has joined #ruby
[00:35:09] Demo318: has joined #ruby
[00:36:38] ruby[bot]: zenspider: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `[]' for nil:NilClass
[00:41:50] zenspider: man. eval.in is a POS
[00:43:54] weathermaker: has joined #ruby
[00:46:14] latemus: has joined #ruby
[00:50:44] jenrzzz: has joined #ruby
[00:51:22] Derperperd: has joined #ruby
[00:51:53] dc4: has joined #ruby
[00:53:56] charliesome: has joined #ruby
[00:55:10] GinoMan2440: has joined #ruby
[00:56:25] ascarter: has joined #ruby
[00:57:12] Cohedrin: has joined #ruby
[01:00:22] Hunter1: has joined #ruby
[01:03:52] brent__: has joined #ruby
[01:04:05] SeepingN: has joined #ruby
[01:05:52] jenrzzz: has joined #ruby
[01:08:24] uZiel: has joined #ruby
[01:14:58] nankyokusei: has joined #ruby
[01:15:25] zing: has joined #ruby
[01:15:29] zing: has left #ruby: ()
[01:17:38] hotpanca_: has joined #ruby
[01:17:43] PorcoRex: has joined #ruby
[01:17:44] hotpanca_: has joined #ruby
[01:17:49] PorcoRex: Good evening.
[01:18:16] gusrub_: has joined #ruby
[01:18:30] mitt3ns: has joined #ruby
[01:20:03] Demo318: has joined #ruby
[01:28:00] haraoka: has joined #ruby
[01:33:59] dtcristo: has left #ruby: ("Kicked by @appservice-irc:matrix.org")
[01:36:58] Cohedrin: has joined #ruby
[01:39:44] arescorpio: has joined #ruby
[01:39:55] ecuanaso: has joined #ruby
[01:40:38] mim1k: has joined #ruby
[01:45:42] hotpanca_: has joined #ruby
[01:46:48] Danny: has joined #ruby
[01:47:37] electrostat: has joined #ruby
[01:50:18] Cohedrin: has joined #ruby
[01:50:33] username: has joined #ruby
[01:56:51] AnoHito: has joined #ruby
[02:01:07] hotpancakes: has joined #ruby
[02:01:34] d^sh: has joined #ruby
[02:02:23] Danny: has joined #ruby
[02:05:33] cdg: has joined #ruby
[02:05:48] hotpanca_: has joined #ruby
[02:18:29] hutch34: has joined #ruby
[02:20:24] genpaku: has joined #ruby
[02:21:17] Cohedrin: has joined #ruby
[02:24:49] Jameser: has joined #ruby
[02:27:49] gothicsouth: has joined #ruby
[02:31:07] Danny: has joined #ruby
[02:34:20] charliesome: has joined #ruby
[02:35:05] mitt3ns: has joined #ruby
[02:36:28] Demo318: has joined #ruby
[02:36:36] bauruine: has joined #ruby
[02:37:31] Danny: has joined #ruby
[02:40:48] hotpanca_: has joined #ruby
[02:42:10] __Yiota: has joined #ruby
[02:42:49] jrafanie: has joined #ruby
[02:43:17] hotpanca_: has joined #ruby
[02:43:53] hotpancakes: has joined #ruby
[02:45:28] ecuanaso: has joined #ruby
[02:49:54] bbdk: has joined #ruby
[02:51:49] muelleme_: has joined #ruby
[02:54:40] hotpancakes: has joined #ruby
[02:55:02] bbdk: hey guys :) i've comming from JS.. and i have a question i would like to know the real diference between ruby and python..
[02:57:16] elomatreb: bbdk: One is Ruby, the other is Python? More concrete pls
[02:57:58] jrafanie: has joined #ruby
[02:58:30] uZiel: has joined #ruby
[03:02:39] jane_booty_doe: has joined #ruby
[03:03:24] whiteline_: has joined #ruby
[03:03:38] uZiel_: has joined #ruby
[03:07:29] bbdk: Sorry, I meant that, I would like to know the pros / cons of ruby ​​since, I am a javascript developer and many people tell me, to go to python and other ruby. So, I came here to hear from you that you are experienced.
[03:08:15] elomatreb: They're not that different in the grand scale of things. Learn both if you're unsure and use what you like better
[03:08:49] Nilium: What do you want to do?
[03:09:42] Nilium: And when you've got that in mind, probably ask communities of both about that
[03:09:53] Nilium: And just leave out the whole "compared to this other language" bit
[03:14:46] lel: has joined #ruby
[03:15:50] nankyokusei: has joined #ruby
[03:16:26] hotpancakes: has joined #ruby
[03:22:23] bauruine: has joined #ruby
[03:28:41] __Yiota: has joined #ruby
[03:29:54] csaunders: has joined #ruby
[03:31:11] igniting: has joined #ruby
[03:37:43] mahlon: has joined #ruby
[03:39:24] Derperperd: has joined #ruby
[03:39:52] djbkd: has joined #ruby
[03:40:47] hotpancakes: has joined #ruby
[03:40:51] Esf: has joined #ruby
[03:41:09] mim1k: has joined #ruby
[03:42:46] Esf: has joined #ruby
[03:42:50] meadmoon: has joined #ruby
[03:44:25] claw: has joined #ruby
[03:45:52] gix: has joined #ruby
[03:50:42] xall: has joined #ruby
[03:53:00] Demo318: has joined #ruby
[03:57:51] jenrzzz: has joined #ruby
[03:57:51] jenrzzz: has joined #ruby
[03:58:34] hutch34: has joined #ruby
[04:03:14] username: has joined #ruby
[04:05:42] birdyondrugs: has joined #ruby
[04:08:38] Ropeney_: has joined #ruby
[04:32:56] ledestin: has joined #ruby
[04:36:26] hotpancakes: has joined #ruby
[04:41:46] mim1k: has joined #ruby
[04:44:16] armyriad: has joined #ruby
[04:46:13] ben_h: has joined #ruby
[04:48:24] d5sx43: has joined #ruby
[04:48:24] xall: has joined #ruby
[04:50:06] astrobunny: has joined #ruby
[04:51:32] uZiel: has joined #ruby
[04:53:32] hotpancakes: has joined #ruby
[04:56:06] rohitpaulk: has joined #ruby
[04:59:19] latemus: has joined #ruby
[05:00:38] username: has joined #ruby
[05:06:50] hotpancakes: has joined #ruby
[05:08:53] bauruine: has joined #ruby
[05:09:20] ascarter: has joined #ruby
[05:12:39] brent__: has joined #ruby
[05:12:46] igniting: has joined #ruby
[05:14:47] aupadhye: has joined #ruby
[05:16:35] hotpancakes: has joined #ruby
[05:17:00] nankyokusei: has joined #ruby
[05:17:12] ecuanaso: has joined #ruby
[05:20:17] Cohedrin: has joined #ruby
[05:27:09] harfangk: has joined #ruby
[05:27:12] _whitelogger: has joined #ruby
[05:28:01] dionysus69: has joined #ruby
[05:30:54] bauruine: has joined #ruby
[05:31:12] KeyJoo: has joined #ruby
[05:35:17] patarr: has joined #ruby
[05:37:40] ecuanaso: has joined #ruby
[05:38:41] jenrzzz: has joined #ruby
[05:38:41] jenrzzz: has joined #ruby
[05:41:15] ben_h: has joined #ruby
[05:42:08] nertzy: has joined #ruby
[05:52:55] burgestrand: has joined #ruby
[05:54:19] Demo318: has joined #ruby
[05:56:46] rohitpaulk: has joined #ruby
[05:57:14] uZiel: has joined #ruby
[05:59:17] jenrzzz: has joined #ruby
[06:00:15] roshanavand: has joined #ruby
[06:00:40] hotpancakes: has joined #ruby
[06:04:08] gothicsouth: has joined #ruby
[06:09:53] ecuanaso: has joined #ruby
[06:15:26] mistnim: has joined #ruby
[06:15:46] mistnim: >> __dir__
[06:15:47] ruby[bot]: mistnim: # => "/tmp/execpad-557ffed6a6a7" (https://eval.in/817442)
[06:16:24] mistnim: did anything change about what __dir__ mean lately?
[06:16:59] Abhijit: has joined #ruby
[06:17:04] mistnim: it seemed to point to the dir where the code is. Now from where you are launching it?
[06:17:15] Abhijit: how can I make my ruby script insist on version and fail completely otherwise?
[06:17:27] Abhijit: ruby version that is
[06:18:25] mistnim: Abhijit, raise an error by checking the version?
[06:18:51] Abhijit: is there anything builtin?
[06:19:00] elomatreb: Yeah, although you probably shouldn't
[06:19:09] Abhijit: why i should not+?
[06:20:13] mistnim: can I ask you what __dir__ gives you? The dir of the file where the code is or the dir from where you are launching that file?
[06:20:22] elomatreb: Well, it depends on the feature. If your script won't work with certain older versions it's probably evident from the error one would get
[06:21:14] Polysics: has joined #ruby
[06:21:19] SeepingN: would the shell dictate which directory is passed as the Current Working Directory?
[06:21:30] elomatreb: And if you hardcode a version check chances are you'll forget it and it would error on newer versions despite being able to work
[06:21:36] SeepingN: (though one would hope they all follow the same conventions)
[06:22:36] ecuanaso: has joined #ruby
[06:22:46] elomatreb: mistnim: http://ruby-doc.org/core-2.4.1/Kernel.html#method-i-__dir__ -- I don't see it referencing the CWD anywhere
[06:23:22] conta: has joined #ruby
[06:23:34] SeepingN: I can see wanting to limit the version of ruby, esp if you don't have time to test it on several major releases. I have found the move from 1.6.7 to 2.0 to be full of surprises, many of which I didn't hit until certain timeout events triggered in production
[06:24:01] elomatreb: 1.6 is ancient though, and included some of the most major changes in Ruby history
[06:24:55] elomatreb: E.g. upgrading from 2.2 to 2.3 was hardly any work for the most part
[06:26:03] hotpancakes: has joined #ruby
[06:27:25] Nilium: I'd be kind of surprised to see anyone who still used 1.6
[06:27:36] mistnim: this is really bad, if you use binding.pry __dir__ becomes ".", that's the opposite of useful for debugging
[06:28:38] dminuoso: mistnim: It's perfectly fine if you know what __dir__ does.
[06:28:51] dminuoso: mistnim: Use __FILE__ if you can't use it in a dynamic context.
[06:29:06] mtkd: has joined #ruby
[06:29:37] mistnim: dminuoso, if I have a function that uses __dir__ than it will fail if launched from pry
[06:29:54] ferr1: has joined #ruby
[06:30:03] cschneid_: has joined #ruby
[06:30:16] ascarter: has joined #ruby
[06:30:21] muelleme_: has joined #ruby
[06:30:29] mistnim: then I have to investigate the problem and it was just pry being tricky
[06:31:04] cschneid_: has joined #ruby
[06:31:34] dminuoso: mistnim: Well the issue is that __dir__ is a method that asks Kernel at runtime.
[06:32:11] dminuoso: Though.. mmm.
[06:34:16] elomatreb: __FILE__ is set by pry, so that probably breaks things
[06:36:00] mtkd: has joined #ruby
[06:36:28] mistnim: in any case, I'm going with DIR = __dir__ on top, and then use DIR instead of __dir__
[06:40:35] hightower2: has joined #ruby
[06:42:37] ecuanaso: has joined #ruby
[06:44:45] mistnim: lol, I really have a troubled relationship with pry. Calling a function play is a bad idea
[06:47:18] ur5us: has joined #ruby
[06:49:35] anisha: has joined #ruby
[06:50:04] hotpanca_: has joined #ruby
[06:50:11] raul782: has joined #ruby
[06:51:21] rohitpaulk: has joined #ruby
[06:54:57] ecuanaso: has joined #ruby
[06:55:43] Demo318: has joined #ruby
[06:58:16] dminuoso: elomatreb: Yeah you are right.
[07:03:21] muelleme_: has joined #ruby
[07:04:37] vondruch: has joined #ruby
[07:08:20] rgr: has joined #ruby
[07:08:41] latemus: has joined #ruby
[07:11:02] biberu: has joined #ruby
[07:11:28] TomyWork: has joined #ruby
[07:11:42] ecuanaso: has joined #ruby
[07:13:35] watersoul_: has joined #ruby
[07:17:42] nankyokusei: has joined #ruby
[07:23:53] jaruga_________: has joined #ruby
[07:25:58] ecuanaso: has joined #ruby
[07:26:31] ltem: has joined #ruby
[07:28:13] ignarps: has joined #ruby
[07:30:08] x86: has joined #ruby
[07:31:15] mark_66: has joined #ruby
[07:32:36] bvcosta: has joined #ruby
[07:33:51] joonty: has joined #ruby
[07:36:09] patarr: has joined #ruby
[07:38:49] solocshaw: has joined #ruby
[07:40:53] sleetdrop: has joined #ruby
[07:42:34] x86: no one alive?
[07:47:01] Ryzokuken: has joined #ruby
[07:47:08] hightower2: Do you have a quality question for us, x86 sir.
[07:48:05] x86: well.. it's not quality question. but: When do you find fun in ruby?
[07:48:47] Ropeney: about 10am most days
[07:48:52] hightower2: always :) it's a language with cleanest/simplest syntax
[07:49:36] x86: I think I am recently too unmotivated.
[07:49:56] x86: It may be not a programming question.
[07:50:24] sleetdrop: has joined #ruby
[07:52:36] pandaant: has joined #ruby
[07:52:52] blackwind_123: has joined #ruby
[08:02:11] Silthias1: has joined #ruby
[08:02:24] Ryzokuken: has joined #ruby
[08:02:31] ecuanaso: has joined #ruby
[08:03:01] bvcosta: has joined #ruby
[08:03:49] charliesome: has joined #ruby
[08:04:04] jenrzzz: has joined #ruby
[08:04:04] jenrzzz: has joined #ruby
[08:05:33] psychicist__: has joined #ruby
[08:11:56] Jameser: has joined #ruby
[08:13:01] ddffg: has joined #ruby
[08:15:15] bauruine: has joined #ruby
[08:20:01] mim1k: has joined #ruby
[08:22:28] bvcosta: has joined #ruby
[08:26:38] ecuanaso: has joined #ruby
[08:27:27] yeticry: has joined #ruby
[08:29:56] Hanmac: has joined #ruby
[08:39:47] nofxxx: has joined #ruby
[08:41:06] rohitpaulk: has joined #ruby
[08:41:17] pandaant: has joined #ruby
[08:44:09] lxsameer: has joined #ruby
[08:48:08] cfec0b8d: has joined #ruby
[08:48:57] nankyokusei: has joined #ruby
[08:50:37] hutch34: has joined #ruby
[08:51:28] elomatreb: has left #ruby: ("Leaving")
[08:51:34] elomatreb: has joined #ruby
[08:51:38] hotpancakes: has joined #ruby
[08:52:25] facest: has joined #ruby
[08:57:19] ecuanaso: has joined #ruby
[08:59:22] rohitpaulk: has joined #ruby
[09:00:25] bvcosta: has joined #ruby
[09:00:58] Beams: has joined #ruby
[09:03:36] ben_h: has joined #ruby
[09:04:26] workmad3: has joined #ruby
[09:06:29] mim1k: has joined #ruby
[09:12:25] Demo318: has joined #ruby
[09:12:40] ecuanaso: has joined #ruby
[09:12:42] marr: has joined #ruby
[09:16:14] chat_: has joined #ruby
[09:17:10] joonty: has joined #ruby
[09:28:06] sysvalve: has joined #ruby
[09:30:00] ecuanaso: has joined #ruby
[09:32:13] jokke: does someone see an obvious reason why the runtime measurement here https://github.com/meso-unimpressed/log_syringe/blob/master/lib/log_syringe/dsl.rb wouldn't work when measuring methods that are called from multiple threads
[09:32:18] nowhereman_: has joined #ruby
[09:34:29] doublemalt_: has joined #ruby
[09:34:55] mim1k_: has joined #ruby
[09:37:01] patarr: has joined #ruby
[09:37:49] Bounga: has joined #ruby
[09:37:58] zenspider: define "wouldn't work"
[09:38:12] jokke: well apparently the measurements are way off
[09:38:48] zenspider: I'm waiting...
[09:40:40] jokke: i have a program that's been running for months single threaded. I implemented a threadpool to it today and i can verify that the total runtime has gone down significantly. If i add up the runtimes of the calls to the method i'm measuring i get a far greater number. Even greater than before the multithreading.
[09:41:18] zenspider: theading takes work. that's expected
[09:41:38] zenspider: threading, even...
[09:42:05] ineb: runtime is faster but measured execution time is slower?
[09:42:36] zenspider: the sum of the thread times > old time > threaded time
[09:42:40] ecuanaso: has joined #ruby
[09:42:59] jokke: ineb: well the thing is i use the same mechanics to measure the total runtime which is basically just a method that creates and joins the threadpool
[09:43:00] im0nde: has joined #ruby
[09:43:38] jokke: zenspider: yes
[09:44:16] dminuoso: jokke: That sounds likely still.
[09:44:31] jokke: here's some code so you get the picture: https://p.jreinert.com/ef48I/
[09:44:51] jokke: https://p.jreinert.com/xtl6aq/
[09:44:51] dminuoso: jokke: Threads introduce context switches, waiting for shared resources, etc. So the overall CPU time can actually go up.
[09:45:09] dminuoso: (Even if total runtime goes down)
[09:45:12] jokke: dminuoso: i'm not measuring cpu time
[09:45:41] jokke: i'm just using started = Time.now; do_stuff; puts Time.now - started
[09:45:43] jokke: basically
[09:46:14] jokke: in one case do_stuff is the method which spawns and joins the threads
[09:46:26] jokke: and in one case it's the actual work done per thread
[09:48:08] bvcosta: has joined #ruby
[09:50:20] jokke: i also wrote log syringe and right now i'm regretting it a bit
[09:50:23] jokke: too much magic
[09:50:38] ineb: you couldve went with the proxy pattern
[09:51:47] solocshaw: has joined #ruby
[09:52:25] ecuanaso: has joined #ruby
[09:52:55] sekmo: has joined #ruby
[09:53:27] jokke: i wanted to be able to separate logging and metrics completely from the application code so that you could remove the files and everything would continue working as before
[09:54:09] ineb: good point
[09:55:09] jokke: but it has its downsides as you can see :)
[09:56:24] ineb: how about a hook then which triggers everytime a method is called to do the measuring?
[09:56:38] ineb: this would separate the logic
[09:57:02] ineb: such hooks can be done with Kernel#set_trace_func
[09:57:08] patarr: has joined #ruby
[09:57:19] jokke: yeah but i've heard it's pretty bad performance wise
[09:57:52] ineb: yeah but maybe its okay if youre app is in testing
[09:58:03] ineb: for production you could simply disable it
[09:59:23] Guest66963: has joined #ruby
[09:59:54] Guest66963: hi. anyone knows here howto configure the ssh credentials when using serverspec?
[10:02:18] pale3: has joined #ruby
[10:04:15] zenspider: ?answers Guest66963
[10:04:15] ruby[bot]: Guest66963: How to ask the right questions to get you the right answer: https://www.mikeash.com/getting_answers.html
[10:04:16] Kug3lis: has joined #ruby
[10:04:28] uZiel: has joined #ruby
[10:06:52] pale3: how to extract last and last parent substring from path. E.g case "/papa-foo/child-foo/grandchild-foo/grandgrandchild-foo/foo", get only "/grandgrandchild-foor/foo"?
[10:07:05] jenrzzz: has joined #ruby
[10:07:14] Guest66963: zenspider, options[:password] ||="<goforurpasswd>"
[10:08:06] xall: has joined #ruby
[10:09:07] umaaji: has joined #ruby
[10:09:50] alamar: has joined #ruby
[10:12:23] ljarvis: pale3: just split on / and join the last 2 entries
[10:13:03] ljarvis: >> "foo/bar/baz".split("/")[-2..-1].join("/")
[10:13:04] ruby[bot]: ljarvis: # => "bar/baz" (https://eval.in/817670)
[10:13:15] ecuanaso: has joined #ruby
[10:13:44] pale3: ljarvis: ok thanks, i am not a ruby dev in any way, so I tried here
[10:13:48] pale3: ljarvis: thx it works
[10:21:33] Fernando-Basso: has joined #ruby
[10:27:05] nertzy: has joined #ruby
[10:28:42] ecuanaso: has joined #ruby
[10:29:58] alamar: has joined #ruby
[10:42:00] ecuanaso: has joined #ruby
[10:42:18] joonty: has joined #ruby
[10:46:00] chouhoulis: has joined #ruby
[10:46:18] acalycine: has joined #ruby
[10:50:11] ryzokuken_: has joined #ruby
[10:52:21] hutch34: has joined #ruby
[10:53:48] zenspider: ljarvis: last takes a length param. url.split("/").last(2).join "/"
[10:54:20] nankyokusei: has joined #ruby
[10:59:29] jrafanie: has joined #ruby
[11:00:23] pale3: zenspider: thats also quite good solution, IMO they are both understandable
[11:00:56] yokel: has joined #ruby
[11:02:33] bvcosta: has joined #ruby
[11:03:23] xenops: has joined #ruby
[11:03:25] alamar_: has joined #ruby
[11:05:41] ecuanaso: has joined #ruby
[11:07:11] marr: has joined #ruby
[11:08:21] zenspider: I wish File had better path manipulators. I've wanted this a few times
[11:08:47] jenrzzz: has joined #ruby
[11:08:47] jenrzzz: has joined #ruby
[11:09:18] Papierkorb: zenspider: Pathname?
[11:10:19] zenspider: yeah... I was just looking at that. don't think so?
[11:10:52] TomyWork: i have a bunch of little sinatra apps. can i use them with xinetd?
[11:10:56] ineb: Pathname can't do it
[11:12:33] bvcosta: has joined #ruby
[11:13:15] zenspider: I never really got into Pathname. Tho I guess I've wanted realpath before
[11:14:11] Papierkorb: I find it much nicer to use than File/Dir. And also easy to test.
[11:14:13] Demo318: has joined #ruby
[11:14:19] ineb: maybe Pathname.new("/usr/bin/ruby").each_filename.to_a[-2..-1]
[11:14:36] nertzy: has joined #ruby
[11:15:16] ineb: pale3: ^
[11:19:14] rohitpaulk: has joined #ruby
[11:19:53] Papierkorb: zenspider: practical example, we have lots of code using Pathname. Then that stuff had to talk through SSH to access remote files. Now there's RemotePathname, which mirrors the Pathname API (Or it inherited from Pathname, dunno), and suddenly, all that code cone work with remote stuff. A migration path is allowing the user to pass in a String or Pathname, and then just use the Pathname converter function to turn whatever into a Pathname for
[11:19:54] Papierkorb: internal use.
[11:24:18] ecuanaso: has joined #ruby
[11:35:33] Seenox: Hi everyone. How can I use this sed in ruby? --> sed -n 's/.*\\s\\([0-9.]\\+\\)/\\1/p'
[11:35:49] sepp2k: has joined #ruby
[11:36:16] Abhijit: has joined #ruby
[11:36:38] Abhijit: i can require 'json' from rails app and irb in my system. but it fails saying cannot load such file -- json if i require 'json' in simple test.rb script
[11:36:51] ecuanaso: has joined #ruby
[11:36:57] daed: Seenox: http://rubular.com/r/iiaYLmq2V6
[11:37:02] daed: Seenox: something like this?
[11:40:27] Seenox: daed: Text would be something like this: http://rubular.com/r/Mh7Xfdd6g6 (Need 2.4.1 from it)
[11:42:20] ryzokuken__: has joined #ruby
[11:45:26] ldnunes: has joined #ruby
[11:45:47] nertzy: has joined #ruby
[11:46:20] syndikate: For testing my ruby modules, should I be using test/unit or minitest?
[11:48:39] ecuanaso: has joined #ruby
[11:48:55] daed: no idea seenox, use rubular to test stuff out
[11:49:11] Seenox: daed: trying...
[11:50:23] bvcosta: has joined #ruby
[11:50:47] kspencer: when you use begin->rescue, is it a bug that my begin code still totally runs even with an exception, or is there a way for it to abort right when it tries to run, as I'm running a db operation and I'm checking for whether there is already a record in the database, but all the code is getting ran instead of just the insert->which should then cause the 'duplicate entry' exception, and run my rescue code (Using
[11:50:50] kspencer: Sequel which exception is Sequel::UniqueConstraintViolation)
[11:51:41] Puffball: has joined #ruby
[11:53:07] simmaniac: has joined #ruby
[11:53:24] warrshrike: has joined #ruby
[11:55:28] warrshrike: im running a bash command like this
[11:55:29] warrshrike: output = "cd #{GL}; java -Xmx2400m -cp cfl2.jar Graph #{Base}/#{name} #{rhsid}" out = `#{output}`
[11:55:45] warrshrike: so i want to have more control over this
[11:56:07] warrshrike: essentially, if the command takes longer than 10 minutes terminate by force
[11:57:52] khaki: has joined #ruby
[11:59:30] Seenox: daed: http://rubular.com/r/pKfBQO2Id0 now I just need to escape the second match.
[12:00:10] anisha: has joined #ruby
[12:00:11] __Yiota: has joined #ruby
[12:00:50] brian_penguin: has joined #ruby
[12:01:57] muelleme_: has joined #ruby
[12:02:21] ineb: warrshrike: maybe use a Timer with timeout condition http://www.rubydoc.info/github/rubyworks/facets/Timer
[12:04:23] psychicist__: has joined #ruby
[12:06:31] aglorei: has joined #ruby
[12:08:28] GinoMan: has joined #ruby
[12:09:31] jenrzzz: has joined #ruby
[12:10:04] synthroid: has joined #ruby
[12:10:11] Abhijit: has joined #ruby
[12:10:31] Abhijit: why this bug https://github.com/flori/json/issues/318 gets fixed with changing my shebang line from /usr/bin/ruby to /usr/bin/env ruby as pointed by one commentor?
[12:10:34] bast: has joined #ruby
[12:10:34] bast: has joined #ruby
[12:11:56] warrshrike: ineb: okay but i mean
[12:11:59] GinoMan2440: has joined #ruby
[12:12:04] warrshrike: how does backticks work?
[12:12:18] warrshrike: does it take over the ruby process?
[12:12:26] warrshrike: in that case how i monitor it?
[12:12:37] warrshrike: or does it spawn a child process
[12:14:12] nertzy: has joined #ruby
[12:14:33] ineb: warrshrike: backticks, they just block and return the output as string as soon as the command finished
[12:15:20] warrshrike: ineb: so can i use a timout condition with that?
[12:15:33] warrshrike: maybe if i use a second ruby thread?
[12:15:35] ineb: warrshrike: if you want more controle over the process, like stdin stdout and so on, you can use Open3
[12:15:51] warrshrike: ineb: i basically just want the timeout condition
[12:16:03] uZiel: has joined #ruby
[12:16:06] ineb: then you can use a timer
[12:16:29] warrshrike: ineb: cool lemme try it
[12:18:28] KeyJoo: has joined #ruby
[12:27:46] __Yiota: has joined #ruby
[12:29:07] bvcosta: has joined #ruby
[12:34:41] pupsicle: has joined #ruby
[12:35:22] Mia: has joined #ruby
[12:35:22] Mia: has joined #ruby
[12:36:44] warrshrike: hey what do i need to 'require'
[12:36:48] warrshrike: to include Timer
[12:41:41] pupsicle: 'facets/timer'
[12:43:27] Benshiro: has joined #ruby
[12:43:37] marr: has joined #ruby
[12:43:46] warrshrike: pupsicle: unresolved...did you mean Time>
[12:45:04] pupsicle: Do you have the facets gem installed?
[12:45:05] gizmore: has joined #ruby
[12:45:11] warrshrike: no sir i do not
[12:48:39] warrshrike: but the larger thing isn't working
[12:48:55] oleo: has joined #ruby
[12:50:03] warrshrike: timer doesnt time out
[12:50:17] warrshrike: when doing `bash` commands with backticks
[12:51:15] warrshrike: any other way to put execution limits on backticks?
[12:51:28] pupsicle: You want a shell command to timeout?
[12:51:53] warrshrike: pupsicle: yup...so im doing this...output = "cd #{GL}; java -Xmx2400m -cp cfl2.jar Graph #{Base}/#{name} #{rhsid}"; out = `#{output}`
[12:52:00] warrshrike: but sometimes it takes hours
[12:52:10] warrshrike: and i want to set timeout to 10 minutes
[12:53:51] hutch34: has joined #ruby
[12:55:10] nankyokusei: has joined #ruby
[12:57:48] warrshrike_: has joined #ruby
[12:57:57] pupsicle: warrshrike: Did you see the Timeout class?
[12:58:17] pupsicle: https://ruby-doc.org/stdlib-2.4.1/libdoc/timeout/rdoc/Timeout.html
[12:59:01] warrshrike_: sorry got DC'D
[12:59:02] warrshrike_: did anyone help?
[12:59:02] warrshrike_: the very first one
[12:59:02] warrshrike_: pupsicle: i followed this example http://www.rubydoc.info/github/rubyworks/facets/Timer
[13:00:35] warrshrike_: pupsicle: you think this would work? Timeout::timeout(TIMEOUT_SECONDS) do slow_api.call end
[13:01:32] pupsicle: If you're using backticks for the shell command, it won't kill that process automatically, but yes.
[13:02:39] simmaniac: has joined #ruby
[13:02:51] warrshrike_: pupsicle: so ti will or wont work with backticks?
[13:04:17] pupsicle: I don't know what you're trying to implement exactly so it's hard to say. Have a read through this https://stackoverflow.com/questions/8292031/ruby-timeouts-and-system-commands
[13:05:01] savoir-faire: has joined #ruby
[13:05:39] mim1k: has joined #ruby
[13:05:51] ryzokuken_: has joined #ruby
[13:05:58] warrshrike_: pupsicle: it worked!
[13:06:06] warrshrike_: but it throws an exception of TIMEDOUT
[13:06:15] warrshrike_: how can i recover from that?
[13:07:18] renchan: has joined #ruby
[13:07:41] meshsmith: has joined #ruby
[13:10:33] Papierkorb: Looks like some people are working on adding a JIT to MRI: https://github.com/vnmakarov/ruby/tree/rtl_mjit_branch#readme
[13:14:51] meshsmith: Does anyone know if Sass can be ran on GIT?
[13:14:56] shynoob: has joined #ruby
[13:15:36] warrshrike_: pupsicle: example? in java you need to either throws in method signature or throw-catch but in ruby i cant tel when sth will throw exp
[13:15:59] warrshrike_: pupsicle: nvm found exp
[13:16:01] Demo318: has joined #ruby
[13:17:57] doublemalt_: has joined #ruby
[13:23:03] konsolebox: Papierkorb: wasn't MRI a JIT already?
[13:24:01] chrisseaton: konsolebox: no MRI's never had a JIT merged into it - there have been some experiments though
[13:24:19] pupsicle: meshsmith: Restate your question.
[13:24:55] konsolebox: well that's good news. because you know MRI can still be made faster.
[13:25:09] meshsmith: K. Does anyone know if SASS, the CSS preprocessor that runs on Ruby, can be ran on Github pages?
[13:25:34] shynoob: Hey there, I am newbie here.. I just want to know if is it important to spend time with Ruby .. understand its constructs.. and then move on to Rails or I'll be just fine and catch up if I am a beginner in web development?
[13:25:52] hightower2: shynoob, knowing Ruby will help you a lot
[13:27:20] haylon: has joined #ruby
[13:27:26] bvcosta: has joined #ruby
[13:29:04] skweek: has joined #ruby
[13:29:10] shynoob: has joined #ruby
[13:29:11] GinoMan2440: has joined #ruby
[13:29:17] pupsicle: meshsmith: If you are using Github Pages' built in Jekyll support, it will. https://github.com/blog/1867-github-pages-now-runs-jekyll-2-2-0
[13:29:29] shynoob: Sorry I got disconnected
[13:29:49] pupsicle: meshsmith: but in general, no.
[13:29:55] cjohnson: shynoob: ruby has a lot of metaprogramming, if you are new to web dev spend a good deal of time just learning the language
[13:30:10] cjohnson: rails is written in ruby so you won't be able ot magically avoid learning the language and only learn the framework
[13:30:13] meshsmith: pupsicle, do I need to install Jeykll on top of Github Pages before I can run Sass, correct?
[13:31:04] meshsmith: This is unfortunate because my shared host only runs up to 1.8
[13:31:11] shynoob: I meant whether I might pick up the language while spending time with Rails or I'll have to actually play with Ruby distinctively? cjohnson,
[13:31:25] pupsicle: meshsmith: A remote git repo is not the same thing as Github.
[13:31:38] pupsicle: git is not github and github is not git.
[13:31:42] cjohnson: shynoob: I would always recommend starting with the basics for any language you aren't familiar with
[13:31:57] cjohnson: rails isn't the only way to write ruby
[13:32:33] DLSteve_: has joined #ruby
[13:32:33] cjohnson: I'd say the same thing for JS and imo JS is much more straight forward of a language to understand
[13:32:39] meshsmith: They sure do a crap job making a distinction because all it takes a single setting change to turn something into a webpage.
[13:33:04] shynoob: And the problem for me is I just wont know how much time I shall give to a specific thing.. and when to move on.. cjohnson,
[13:33:49] shynoob: You know where exactly I should start with? cjohnson,
[13:34:26] cjohnson: shynoob: I had great success learning ruby from these exercises: http://exercism.io/languages/ruby/about
[13:34:43] cjohnson: as well as the ruby exercises here: http://paircolumbus.org/challenges/
[13:35:05] cjohnson: shynoob: then after you get the basics down a good book I'm told is "metaprogramming ruby 2"
[13:35:16] cjohnson: Haven't read it but all my colleagues recommend it
[13:35:30] shynoob: Oh thanks .. Ill check them out ! ASAP
[13:36:24] Ropeney: has joined #ruby
[13:43:46] ryzokuken_: has joined #ruby
[13:45:29] jenrzzz: has joined #ruby
[13:47:05] synthroid: has joined #ruby
[13:47:58] rippa: has joined #ruby
[13:50:48] __Yiota: has joined #ruby
[13:52:38] Silox|: has joined #ruby
[13:56:53] drptbl: has joined #ruby
[14:00:16] Hunter1: has joined #ruby
[14:01:03] sleetdrop: has joined #ruby
[14:03:43] jrafanie: has joined #ruby
[14:04:20] charliesome: has joined #ruby
[14:04:34] arup_r1: has joined #ruby
[14:05:02] cadillac_: has joined #ruby
[14:06:52] cjohnson: What do people recommend for interactive debugging in vim? I know you can use binding.pry but I was hoping to use vim to set breakpoints and step code and such
[14:07:08] cjohnson: I would need rspec integration for command line and passenger integration for web requests
[14:07:42] pupsicle: Just create a macro to insert binding.pry
[14:08:18] cjohnson: I don't see how that gives me vim integration?
[14:08:32] cjohnson: that just gives me a pry prompt on command line when I run rspec
[14:08:45] cjohnson: I'm specifically wanting to use vim's interactive debugger
[14:08:50] brian_penguin: has joined #ruby
[14:09:13] Silthias1: has left #ruby: ()
[14:12:28] Silthias: has joined #ruby
[14:13:08] esfandyar: has joined #ruby
[14:16:32] patarr: has joined #ruby
[14:16:35] esfandyar: has joined #ruby
[14:19:33] bmurt: has joined #ruby
[14:20:59] Polysics: has joined #ruby
[14:21:46] __Yiota: has joined #ruby
[14:25:09] mark_66: has left #ruby: ("PART #elixir-lang :PART #crystal-lang :PONG :adams.freenode.net")
[14:25:49] kspencer: when you use begin->rescue, is it a bug that my begin code still totally runs even with an exception, or is there a way for it to abort right when it tries to run, as I'm running a db operation and I'm checking for whether there is already a record in the database, but all the code is getting ran instead of just the insert->which should then cause the 'duplicate entry' exception, and run my rescue code (Using
[14:25:52] kspencer: Sequel which exception is Sequel::UniqueConstraintViolation)
[14:26:23] shinnya: has joined #ruby
[14:28:32] mim1k: has joined #ruby
[14:29:17] adam12: kspencer: show some code please.
[14:29:21] oleo: has joined #ruby
[14:30:10] kspencer: i'll have to pastebin it later, as i need to get back to work.
[14:30:56] Renich_: has joined #ruby
[14:34:29] __Yiota: has joined #ruby
[14:40:38] patarr: has joined #ruby
[14:41:46] theunraveler: has joined #ruby
[14:47:34] enterprisey: has joined #ruby
[14:53:23] xenops: has joined #ruby
[14:54:56] hotpanca_: has joined #ruby
[14:55:37] hutch34: has joined #ruby
[14:56:07] nankyokusei: has joined #ruby
[14:56:36] pankaj: has joined #ruby
[15:01:01] zerowaitstate: has joined #ruby
[15:02:19] hutch34: has joined #ruby
[15:02:38] TomyLobo: has joined #ruby
[15:04:08] heliumk: has joined #ruby
[15:06:11] brian_penguin: when you rescue exceptions in ruby the code will continue to execute
[15:06:45] brian_penguin: if you were to do something like "rescue MyErrorClass => err"
[15:07:05] brian_penguin: you could do something to save state or log the error and then call "raise err" to stop execution again
[15:08:10] heliumk: has left #ruby: ("Leaving")
[15:08:48] elifoster: has joined #ruby
[15:09:12] arup_r: has joined #ruby
[15:11:26] _joes____: has joined #ruby
[15:12:39] lacuna: has joined #ruby
[15:14:17] hotpancakes: has joined #ruby
[15:16:21] cdg: has joined #ruby
[15:18:11] patarr1: has joined #ruby
[15:21:38] arup_r: Got a question. I was reading https://bearmetal.eu/theden/how-do-i-know-whether-my-rails-app-is-thread-safe-or-not/. In this section *What is and what isn’t thread-safe in Ruby?* the author said final value of this code https://gist.github.com/aruprakshit/406dbd84ca5adeb1b9d2a62aa588be1a is *undetermined*. What did he mean here? because every time i run it, I get final value as 300. I am missing something here. Can u he
[15:22:59] anisha: has joined #ruby
[15:24:51] polishdub: has joined #ruby
[15:24:53] cjohnson: Just because you get 300 doesn't mean it's guaranteed to always be 300
[15:27:05] arup_r: can you explaim why not guranteed?
[15:27:27] elomatreb: arup_r: Imagine: Thread 1 reads the current value, say, 50, but the then the scheduler switches to Thread 2, which also reads 50, adds 1 and writes it back, and it schedules back to Thread 1, which adds 1 to 50 and writes back 51
[15:27:32] elomatreb: So you skipped one add
[15:27:52] pupsicle: That increment operation is not atomic
[15:28:20] elomatreb: It consists of three parts: Reading the value, adding one, and writing it back. It may be interrupted between those
[15:28:38] ljarvis: arup_r: write @n += 1 like this: @n = @n + 1 -- does that make a difference?
[15:28:46] ljarvis: (in your understanding)
[15:29:11] ljarvis: there's 2 things happening here, Ruby just has some syntax sugar for doing it: "+="
[15:31:10] elomatreb: I bet if you run that example a couple of times you'll end up with different values sometimes
[15:31:55] cjohnson: could experiment doing it while the CPU is pegged, that might influence
[15:31:55] arup_r: ljarvis: I know `+=` .. I was just not getting why the final value of @n is not determined.. But elomatreb broke it down and now it is clicking to me.. :)
[15:31:58] millerti: has joined #ruby
[15:33:11] elomatreb: It's a little tricky/dangerous in Ruby since it doesn't actually execute code in more than one thread at a time, which may make unsafe operations seem safer than they are
[15:33:15] belmoussaoui: has joined #ruby
[15:34:12] cschneid_: has joined #ruby
[15:34:27] arup_r: so that is why class variables are not good to use people says ?
[15:35:06] bvcosta: has joined #ruby
[15:35:26] elomatreb: @@class_vars are rarely used because they are confusing and rarely what you actually want, they're not more or less threadsafe than @instance_vars or e.g. module state without locks
[15:35:28] cjohnson: are ruby threads green or does it use real threads?
[15:35:38] brent__: has joined #ruby
[15:35:42] bougyman: depends on the ruby implementation
[15:35:52] cjohnson: standard ruby I guess
[15:36:09] alamar: has joined #ruby
[15:36:26] cschneid_: has joined #ruby
[15:36:29] elomatreb: MRI uses native threads IIRC but due to locking you only get something from them when waiting for IO
[15:36:44] havenwood: cjohnson: System threads in 1.9+. They were green threads in 1.8.
[15:37:32] bougyman: and jruby uses the jvm threading, rubinius is native threads, I believe.
[15:38:45] cjohnson: makes sense, thanks
[15:39:22] havenwood: elomatreb: It can release for things other than IO, but IO is probably the most important. C-ext gems don't have to GIL, etc. Here's a gist to be devilish and bypass it yourself: https://gist.github.com/tenderlove/5733632
[15:39:49] elomatreb: A friend told me numpy in Python does something like that
[15:39:59] havenwood: https://www.jstorimer.com/blogs/workingwithcode/8085491-nobody-understands-the-gil
[15:40:14] AndBobsYourUncle: has joined #ruby
[15:40:47] belmoussaoui: has joined #ruby
[15:41:31] hobodave: has joined #ruby
[15:44:47] cdg_: has joined #ruby
[15:47:07] jenrzzz: has joined #ruby
[15:47:08] jenrzzz: has joined #ruby
[15:49:12] hotpancakes: has joined #ruby
[15:52:16] bauruine: has joined #ruby
[15:55:46] cschneid_: has joined #ruby
[15:58:33] rohitpaulk: has joined #ruby
[15:58:56] cschneid_: has joined #ruby
[16:00:44] username: has joined #ruby
[16:01:36] belmoussaoui: has joined #ruby
[16:03:52] ketan: has joined #ruby
[16:05:33] hotpancakes: has joined #ruby
[16:07:09] ecuanaso: has joined #ruby
[16:08:58] sekmo: has joined #ruby
[16:09:58] ledestin: has joined #ruby
[16:13:25] jrafanie: has joined #ruby
[16:14:55] nitric: has joined #ruby
[16:18:32] gusrub: has joined #ruby
[16:22:31] rohitpaulk: has joined #ruby
[16:23:21] arup_r: yeah so I feel like I needed an @@x var, I go with constants as they feel more reliable.. because it throws error while someone by mistake try to mutate it
[16:23:33] arup_r: when I feel like*
[16:26:23] [Butch]: has joined #ruby
[16:29:59] chalkmonster: has joined #ruby
[16:31:57] hotpancakes: has joined #ruby
[16:34:13] brent__: has joined #ruby
[16:36:43] jrafanie: has joined #ruby
[16:37:58] ascarter: has joined #ruby
[16:41:07] simmaniac: has joined #ruby
[16:41:37] jenrzzz: has joined #ruby
[16:41:43] ascarter: has joined #ruby
[16:44:54] pb122: has joined #ruby
[16:45:00] muelleme_: has joined #ruby
[16:48:40] uZiel: has joined #ruby
[16:48:56] hotpancakes: has joined #ruby
[16:49:10] ascarter: has joined #ruby
[16:49:17] MarkBilk: has joined #ruby
[16:50:51] uZiel_: has joined #ruby
[16:51:10] uZiel: has joined #ruby
[16:51:21] MarkBilk_: has joined #ruby
[16:52:58] hotpancakes: has joined #ruby
[16:53:25] SegFaultAX: has joined #ruby
[16:54:52] eightlimbed: has joined #ruby
[16:56:55] nankyokusei: has joined #ruby
[16:57:36] AndBobsYourUncle: has joined #ruby
[17:00:34] rohitpaulk: has joined #ruby
[17:01:36] kies: has joined #ruby
[17:01:51] gusrub: has joined #ruby
[17:02:30] eightlimbed: im learning about the step method... ruby-doc says it iterates over a range passing each nth element to a block
[17:02:52] hotpancakes: has joined #ruby
[17:02:57] aredridel: has joined #ruby
[17:03:11] eightlimbed: but in this script (https://gist.github.com/loganhasson/8937903) the author called step on an integer
[17:03:19] LBRapid: has joined #ruby
[17:03:29] hotpanca_: has joined #ruby
[17:03:39] eightlimbed: and used two arguments
[17:03:52] pupsicle: has joined #ruby
[17:03:53] eightlimbed: ex: 81.step(1000,9)
[17:04:43] thekingofbandit: has joined #ruby
[17:05:01] unsymbol: has joined #ruby
[17:05:32] znz_jp: has joined #ruby
[17:05:57] baweaver: &ri Integer#step
[17:05:57] `derpy: http://ruby-doc.org/core-2.4.1/Numeric.html#method-i-step
[17:06:37] bvcosta: has joined #ruby
[17:08:23] psychicist__: has joined #ruby
[17:10:08] hotpancakes: has joined #ruby
[17:11:00] eightlimbed: thanks baweaver and derpy
[17:11:10] baweaver: derpy is a bot
[17:12:36] GinoMan1423: has joined #ruby
[17:12:55] blackwind_123: has joined #ruby
[17:13:32] eightlimbed: baweaver do i need to install something beyond the basic ruby installer (i'm running windows) to be able to type &ri Integer#step in the command line?
[17:13:47] baweaver: just take the & off
[17:14:15] Cohedrin: has joined #ruby
[17:14:28] baweaver: https://stackoverflow.com/questions/15697209/how-to-get-the-ruby-documentation-from-the-command-line
[17:14:55] GinoMan1423: has joined #ruby
[17:16:08] hotpancakes: has joined #ruby
[17:16:29] ecuanaso: has joined #ruby
[17:18:48] ornerymoose: has joined #ruby
[17:19:00] hotpancakes: has joined #ruby
[17:19:51] ornerymoose: Hello. Minor issue with my validate() method here and I’m a bit stuck. https://gist.github.com/anonymous/1d37812b221f5b2c22a1f8b9bf00d16e It’s returning all 0’s for that column, and the majority should be 1’s. Any insight as to what I’m doing wrong?
[17:24:13] ruby-lang580: has joined #ruby
[17:25:04] Hanmac: ornerymoose: do you have some test data?
[17:25:29] blackwind_123: has joined #ruby
[17:25:34] elomatreb: Yeah, maybe reduce that example a little more. There's a lot going on there
[17:25:47] Hanmac: hm or is maybe the case sensitive wrong?
[17:26:04] Bounga: has joined #ruby
[17:26:07] ornerymoose: hanmac: actually i accidentially lied. in the SQL query itself on SSMS HBO should return 7856 rows. when i open up the csv there is 7356 items in the HBO column with 1’s (so at least its populating them, but missing roughly 500 1’s)
[17:26:17] ornerymoose: hanmac: thats what i was thinking or maybe some whitespace
[17:26:24] ornerymoose: but doesnt appear to be so in SSMS
[17:27:50] ResidentBiscuit: has joined #ruby
[17:29:11] Bounga: has joined #ruby
[17:29:42] ketan: has joined #ruby
[17:30:24] dionysus69: has joined #ruby
[17:32:41] ornerymoose: elomatreb: you’re right, hopefully this is a bit easier on the eyes: https://gist.github.com/ornerymoose/36fbf193b43c81d3a53c982f45ddfa71
[17:32:57] ornerymoose: Note ‘offering’ is one of the columns returned in the SQL query
[17:34:04] statelesscode: has joined #ruby
[17:34:33] bvcosta: has joined #ruby
[17:35:02] eightlimbed: baweaver: i got the docs installed, this will be very helpful. thank you!
[17:35:47] elomatreb: ornerymoose: You could maybe try printing the values your validate method is getting passed (`p something` is debug print)
[17:38:59] ecuanaso: has joined #ruby
[17:41:05] Bounga: has joined #ruby
[17:42:32] benlieb: has joined #ruby
[17:42:52] ornerymoose: elomatreb: got it, definitely something to do with the data. I’ve updated the gist: https://gist.github.com/ornerymoose/36fbf193b43c81d3a53c982f45ddfa71 and it’s not returning the correct number of rows. Now, question is, is that tacky use of gsub? Should I be fixing the HBO entries in the database instead? (whether it be LTRIM RTRIM etc)
[17:43:01] ornerymoose: and it’s now***
[17:43:29] Hunter1: has joined #ruby
[17:44:01] elomatreb: If you can I don't see why you should work around broken data when you can fix it
[17:44:01] pragmatism: has joined #ruby
[17:44:15] ornerymoose: yeah, fair point
[17:44:24] ornerymoose: appreciate the help
[17:45:36] gusrub: has joined #ruby
[17:45:46] havenwood: Always nice to coax the data towards sanity rather than follow it with your code into insanity.
[17:46:00] ruby-lang580: has left #ruby: ()
[17:46:03] havenwood: If it's your data to munge.
[17:50:20] duderonomy: has joined #ruby
[17:52:05] enterprisey: has joined #ruby
[17:53:04] brent__: has joined #ruby
[17:54:21] ornerymoose: havenwood: very good point
[17:55:12] jenrzzz: has joined #ruby
[17:55:12] jenrzzz: has joined #ruby
[17:55:35] aredridel: has joined #ruby
[17:58:46] gothicsouth: has joined #ruby
[18:00:06] kspencer: adam12: https://paste.ofcode.org/5cLibcJftaXXV9qT9cJfWG
[18:01:48] ivanskie: has joined #ruby
[18:02:03] ivanskie: hows everyone doing
[18:02:36] ascarter: has joined #ruby
[18:04:11] benlieb: has joined #ruby
[18:05:18] ivanskie: have this problem i can't wrap my head around
[18:05:35] ivanskie: thought i'd reach out
[18:05:35] SCHAPiE: has joined #ruby
[18:07:42] elomatreb: Feel free to post what you've got, if someone can help they'll respond
[18:07:49] kspencer: ivanskie: well we don't know your problem without you posting it
[18:08:07] ivanskie: but i thought you guys are so advanced that can read minds across the globe ?
[18:08:11] ivanskie: i'm dissapointed :(
[18:08:13] __Yiota: has joined #ruby
[18:08:25] elomatreb: Only during working hours, it's the weekend
[18:08:38] ivanskie: https://gist.github.com/i5okie/985456ac14ad633a1386301390ffa2c0
[18:08:48] hotpancakes: has joined #ruby
[18:08:52] ivanskie: just trying to figure out how to share a screenshot in least painful way
[18:08:55] kspencer: :| I was just about to say we're not mind readers, as its a general thing that's said in help channels when people ask to ask
[18:09:22] kspencer: imgur or lightshot
[18:09:36] ivanskie: was just kidding. trying to help you help me as they say. get my shit together so the problem makes sense
[18:10:47] ivanskie: http://prntscr.com/fkm31h
[18:10:48] ivanskie: https://github.com/i5okie/pxgMapFetcher/blob/master/lib/device.rb#L47
[18:11:57] ivanskie: thats the screenie from app im working on. in essense i have to download 5 files from 22 devices, so i wrote this to do it for me. also combines the csv files into a single per device.
[18:12:08] ivanskie: the problem came in when realize i have to skip some rows
[18:12:43] Silthias: has joined #ruby
[18:13:00] ivanskie: while checking each row to see if it has a match from either values inside an array. its not working how i want it to. so i think im fucking up the loop there
[18:13:25] patarr: has joined #ruby
[18:13:29] ivanskie: this one: https://github.com/i5okie/pxgMapFetcher/blob/master/lib/device.rb#L70-L84
[18:13:33] ldnunes: has joined #ruby
[18:13:36] hotpancakes: has joined #ruby
[18:14:21] elomatreb: Is it skipping too many, too few, the wrong lines?
[18:14:32] ivanskie: the test code i made, that i mentioned in gist. seem to work partially. it says it skips 27 times, but actually prints out some wrong ones.
[18:14:44] ivanskie: code in the app on repo skips too few.
[18:15:06] aglorei: has joined #ruby
[18:15:06] ivanskie: as you see in screenshot, i need to keep it under 1000, and the code seems to only skip one row
[18:16:10] ivanskie: i think I have an idea of how to fix it, but i want to understand what im doing wrong here.
[18:17:49] elomatreb: Minor thing that pains me: You can do `var += 1` instead of `var = var + 1`
[18:18:48] kspencer: https://paste.ofcode.org/5cLibcJftaXXV9qT9cJfWG <-- here's my problem if anyones got any ideas on why all code in the begin (the insert is anticipated to raise Sequel::UniqueConstraintViolation when there is already the same ip in the database) and all the code in the rescue is ran, which means my log returns empty fields, and runs the Log#import Log#dupe and Log#db functions (which write templated log lines)
[18:18:49] ivanskie: skiplist, right now, includes both numbers and strings. so the numbers are just the individual addresses that should be skipped, but i realized that only the string gets repeated, the numbers in csv files vary. so i patched on the strings ('Max Vac'). so i think i can fix it by using smarter_csv since im already using it elsewhere in the app. and only match against strings, and only in single column, could probably speed the whole thing up a bit.
[18:19:49] d10n-work: has joined #ruby
[18:20:01] Bounga: has joined #ruby
[18:20:27] ivanskie: elomatreb: yah i've taken a bit of a break from ruby stuff, and have been burying my head with learning javascript. so this was just a quick fix when i realized you can't do var++ in ruby lol. i plogize for the pain, but its shared. thanks
[18:21:35] xall: has joined #ruby
[18:22:54] ivanskie: i was about to re-do the gist and just make a repo with extracted functionality with sample files it downloads and the test code thats it.
[18:23:14] ivanskie: don't have time to write a full test with faker on this
[18:23:39] ecuanaso: has joined #ruby
[18:24:18] elomatreb: You want to skip a row of that CSV if it contains one of the entries of the skiplist in any of the fields, did I get that right?
[18:25:17] elomatreb: You said your gist does something incorrect, could share some output?
[18:26:06] mtkd: has joined #ruby
[18:26:08] ivanskie: https://ide.c9.io/i5okie/testbench2000
[18:26:41] elomatreb: I'm at a laptop right now, could you update the gist maybe?
[18:26:44] cadillac__: has joined #ruby
[18:27:11] adam12: kspencer: it looks OK. Stick a log entry into the rescue clause and make sure it's firing.
[18:28:46] kspencer: adam12: there's 2 that are in the rescue clause, all 3 run even when I've deleted the rows
[18:29:51] kspencer: l2f.dupe and l2f.db are both loggers
[18:29:55] ivanskie: https://gist.github.com/i5okie/985456ac14ad633a1386301390ffa2c0
[18:31:51] elomatreb: Maybe print whole row (with `p` instead of puts for debug print) in line 18, so we can actually see what's happening
[18:32:14] cdg: has joined #ruby
[18:33:13] cschneid_: has joined #ruby
[18:33:55] adam12: kspencer: Remind me of the issue again? The rescue clause is always run? or it's never run?
[18:36:05] Demo318: has joined #ruby
[18:36:10] hutch34: has joined #ruby
[18:36:29] kspencer: even if there is no duplicates (DELETE FROM table WHERE `column` LIKE '127.%'; before checking) and then import the ips, the whole begin and the whole rescue clause run, instead of tripping up on just the insert and raising the exception
[18:38:05] kspencer: so when there are no duplicates, it runs the insert and Log.import() yet also runs the rescue clause for each address
[18:41:18] ivanskie: srry had work call
[18:41:34] ivanskie: https://gist.github.com/i5okie/985456ac14ad633a1386301390ffa2c0
[18:42:13] bauruine: has joined #ruby
[18:42:43] elomatreb: The first row in the output is skipped because it contains "2", which is also in your skiplist
[18:43:10] elomatreb: Oh, `count += count` does not seem like what you want btw
[18:43:38] ivanskie: so count =+ count then?
[18:43:42] ivanskie: or what i had before
[18:43:58] elomatreb: No, currently you're adding count to count, effectively multiplying it by two ever time
[18:44:07] elomatreb: You want `+= 1`
[18:44:49] ivanskie: still says 27 lol
[18:45:12] ivanskie: ah thats because i didn't change it in my code just gist
[18:45:22] kspencer: ACTION claps
[18:45:58] ivanskie: thats arbitrary tho. still don't understand the rest.
[18:46:12] ivanskie: so i think i'll just make it more complex and use header
[18:46:24] ivanskie: and match against a single column instead of whole row
[18:46:33] elomatreb: From what I can see every row that is skipped is supposed to be skipped, since they all seem to contain a "2"
[18:46:43] elomatreb: That's probably a good idea, yes
[18:46:45] ivanskie: ACTION eyeroll
[18:47:03] ivanskie: okay well im glad that im not going crazy then. it does exactly what i want it to do.
[18:47:05] ivanskie: just too well
[18:47:24] ivanskie: on the other hand.
[18:47:43] ivanskie: yeah no. i better rewrite this part anyway
[18:47:55] ivanskie: thanks elomatreb!
[18:48:50] kspencer: adam12: any headway?
[18:49:27] adam12: kspencer: tbh it all looks fine, but there's a lot of noise, and it's tough to replicate without seeing schema + data you're importing.
[18:49:45] adam12: kspencer: Maybe capture the exception as well and see if it anything is in the `message` property.
[18:51:07] kspencer: thanks adam12
[18:52:40] dviola: has joined #ruby
[18:54:18] cfec0b8d: has joined #ruby
[18:57:46] nankyokusei: has joined #ruby
[18:58:26] muelleme_: has joined #ruby
[19:00:12] ascarter: has joined #ruby
[19:01:21] j0bk: has joined #ruby
[19:02:10] patarr1: has joined #ruby
[19:04:59] omab: has joined #ruby
[19:07:19] minimalism: has joined #ruby
[19:09:57] govg: has joined #ruby
[19:12:20] jenrzzz: has joined #ruby
[19:12:20] cdg: has joined #ruby
[19:12:31] arup_r: has joined #ruby
[19:16:51] mtkd: has joined #ruby
[19:19:03] blackwind_123: has joined #ruby
[19:20:08] Bounga: has joined #ruby
[19:20:35] govg: has joined #ruby
[19:20:48] sekmo: has joined #ruby
[19:25:41] cadillac_: has joined #ruby
[19:26:32] jakew: has joined #ruby
[19:29:26] jenrzzz: has joined #ruby
[19:29:26] jenrzzz: has joined #ruby
[19:29:31] osboxes: has joined #ruby
[19:30:21] ketan: has joined #ruby
[19:31:27] hobodave: has joined #ruby
[19:33:31] patarr: has joined #ruby
[19:33:35] blackwind_123: has joined #ruby
[19:38:10] skweek: has joined #ruby
[19:39:40] skweek: has joined #ruby
[19:39:52] blackwind_123: has joined #ruby
[19:44:49] cdg_: has joined #ruby
[19:46:10] patarr: has joined #ruby
[19:47:49] hosttor: has joined #ruby
[19:48:11] mtkd: has joined #ruby
[19:49:01] lxsameer: has joined #ruby
[19:52:24] eightlimbed: has joined #ruby
[19:52:26] latemus: has joined #ruby
[19:56:33] ^mtkd: has joined #ruby
[19:56:40] lacuna: has joined #ruby
[19:58:31] GinoMan: has joined #ruby
[20:01:51] cadillac_: has joined #ruby
[20:04:11] patarr: has joined #ruby
[20:06:50] santoxxcc: has joined #ruby
[20:07:03] lacuna: has joined #ruby
[20:07:34] igniting: has joined #ruby
[20:07:35] khaki: has joined #ruby
[20:08:07] solocshaw: has joined #ruby
[20:08:44] blackwind_123: has joined #ruby
[20:09:39] gnufied: has joined #ruby
[20:09:57] santoxxcc: can i ask things about rhe ruby language sometimes right? i'm newbie
[20:10:43] Zarthus: you could even ask about ruby, the gem
[20:11:03] Zarthus: chances are you'll find people here who know more about the programming language than the gem though
[20:11:47] santoxxcc: so if i want to talk about the gem and not about the language i'm not in the right place right? jaja
[20:11:56] JoshS: has joined #ruby
[20:12:09] santoxxcc: just kidding
[20:12:41] ResidentBiscuit: has joined #ruby
[20:13:01] santoxxcc: ok is nice to count on you guys
[20:13:10] Zarthus: the real question is how many questions can you think of regarding the gem
[20:13:51] elomatreb: How about 1. Where can I find some, I hear they're rather valuable
[20:14:14] j0bk: hi I have a doubt about the ruby gem
[20:14:18] j0bk: (joking)
[20:14:38] santoxxcc: i wish that the rocks in my garden were ruby gems :(
[20:14:38] kspencer: Id like some gems to pay off my student loans
[20:14:50] blackwind_123: has joined #ruby
[20:15:21] Zarthus: no amount of gems can pay off your crippling debts, kspencer
[20:15:23] havenwood: open $(gem search "^ruby$" -d | ag Homepage | sed -e 's/^[[:space:]]*//' | cut -d" " -f2)
[20:15:48] havenwood: https://banisterfiend.wordpress.com/
[20:15:59] santoxxcc: i still green
[20:16:07] santoxxcc: better start to read
[20:16:51] bauruine: has joined #ruby
[20:17:14] dlitvak: has joined #ruby
[20:17:30] santoxxcc: just to get out of doubts
[20:17:40] santoxxcc: what does the code from above?
[20:17:48] kspencer: Zarthus: I've only got 1300ish a few gems should take care of it
[20:18:03] Zarthus: That's pretty nice.
[20:18:20] KeyJoo: has joined #ruby
[20:19:02] Zarthus: kspencer: A wild guess is that it opens a bunch of pages in your browser
[20:19:02] Zarthus: i'm not familiar with ag nor open
[20:19:16] Zarthus: ah open is a file
[20:19:47] santoxxcc: but i looks that it searchs for something
[20:19:48] havenwood: Zarthus: It opens just that gem's website.
[20:19:59] havenwood: Zarthus: ag is the silver searcher
[20:20:04] __Yiota: has joined #ruby
[20:20:10] havenwood: Zarthus: brew install ag
[20:20:19] ur5us: has joined #ruby
[20:20:26] havenwood: https://github.com/ggreer/the_silver_searcher
[20:20:27] gothicsouth: has joined #ruby
[20:20:37] havenwood: You could swap grep for ag there.
[20:21:01] Bounga: has joined #ruby
[20:21:07] havenwood: It's just slower and less intuitive than ag, a newer but very nice option.
[20:21:56] Zarthus: The command name is 33% shorter than ack, and all keys are on the home row!
[20:21:58] Zarthus: I'm convinced.
[20:22:16] havenwood: function gem_site() { open $(gem search "^$1$" -d | grep Homepage | sed -e 's/^[[:space:]]*//' | cut -d" " -f2) }
[20:22:30] havenwood: gem_site YOUR_GEM_HERE
[20:22:33] santoxxcc: in the book that i'm reading says that te ruby community is ver nice and friendly
[20:22:50] jaruga_________: has joined #ruby
[20:23:19] havenwood: Zarthus: ^ there, ag removed
[20:23:19] havenwood: and a function to call for any gem
[20:23:19] havenwood: gem_website http
[20:23:19] havenwood: err, gem_site
[20:23:21] havenwood: whatever you want to call the function
[20:23:45] havenwood: Or you could do it in Ruby. ;-P
[20:23:50] havenwood: This isn't #shell after all.
[20:23:57] havenwood: ACTION scolds himself
[20:24:15] Zarthus: You could write a sh parser in ruby and pretend it was normal all along
[20:25:21] mostlybadfly: has joined #ruby
[20:26:37] patarr: has joined #ruby
[20:29:33] Emmanuel_Chanel: has joined #ruby
[20:33:20] santoxxcc: has joined #ruby
[20:33:41] santoxxcc: anyone know Matz in here?
[20:33:57] ivanskie: but can someone tell me what im doing wrong here?
[20:34:08] hobodave_: has joined #ruby
[20:34:24] ivanskie: {{skiplist.map{|s|row[col]==s}}.include?(true)}
[20:34:30] havenwood: santoxxcc: Lots of folk in here have met Matz. He's nice.
[20:34:55] santoxxcc: I would like to meet him some day
[20:34:56] username: has joined #ruby
[20:34:58] santoxxcc: even if is in chat
[20:35:14] havenwood: ivanskie: use #any?
[20:35:14] havenwood: santoxxcc: Come to RubyConf in New Orleans this Fall.
[20:35:19] j0bk: ivanskie what's the error?
[20:35:26] cadillac_: has joined #ruby
[20:35:27] havenwood: santoxxcc: Or drop by the mruby gitter.
[20:35:40] havenwood: santoxxcc: https://gitter.im/mruby/mruby
[20:35:50] ivanskie: unexpected '}', expectin +> syntax error
[20:35:59] poloych: has joined #ruby
[20:36:04] j0bk: the last }
[20:36:07] santoxxcc: havenwood: i'll check it out, thanks!
[20:36:11] nerglish: has joined #ruby
[20:36:16] santoxxcc: let me try that code
[20:36:21] santoxxcc: let me see it
[20:36:44] j0bk: the error is }}.
[20:36:49] j0bk: you need just one
[20:37:00] santoxxcc: that's true
[20:37:17] j0bk: }}.include? -> }.include?
[20:37:31] nerglish: If I have a rake task defined astask process: :environment do
[20:37:42] nerglish: what does :environment do here?
[20:38:02] j0bk: RAKE_ENV
[20:38:03] baweaver: loads the entirety of Rails with it.
[20:38:23] baweaver: though #RubyOnRails may be a better place to ask.
[20:39:07] santoxxcc: skiplist.map {|s| row[col] == s}.include?() i think should be
[20:39:20] santoxxcc: i'm newbie anyway
[20:39:28] havenwood: ivanskie: You can use #any? something like: skips.any? { |skip| skip == row[col] }
[20:39:46] ivanskie: https://gist.github.com/i5okie/6148c48a20df09fdd4c837c554ae0140
[20:39:51] havenwood: but the logic is so simple, why not just include?
[20:40:25] havenwood: skiplist.include? r
[20:40:56] ivanskie: lol wait what
[20:41:05] havenwood: ivanskie: ^ just that, nothing else (if this is really all your logic)
[20:41:08] ivanskie: you mean i've been an idiot this whole time
[20:42:16] santoxxcc: i don't get it
[20:42:25] santoxxcc: why just skiplist.include?
[20:43:11] ivanskie: this is something i was working on earlier.
[20:43:44] ivanskie: originally i had a row from csv. i iterated over every single thing in that row, and checked against everything in skiplist.
[20:43:56] havenwood: santoxxcc: With the more convoluted one you're doing stuff you don't need to like: [true, true, false, false, true].include? true
[20:44:04] ivanskie: then later decided only need to do it for one column. but in my head still stick to doing the old logic
[20:44:11] ivanskie: this does it right
[20:44:12] havenwood: santoxxcc: All that's actually being done is to see if the skiplist includes r, whatever that is.
[20:45:05] ivanskie: https://github.com/i5okie/pxgMapFetcher
[20:45:11] ivanskie: look at screenshot.
[20:45:24] dances_with_taco: has joined #ruby
[20:45:52] ivanskie: i have a list of crap to ignore (skiplist).. im processing up-to 5 csv files at a time and saving into single csv file, while making sure to skip the crap that i dont need
[20:46:36] jrafanie: has joined #ruby
[20:47:08] santoxxcc: havenwood so you are just checking if "r" exist inside the array? that's all the logic?
[20:47:26] ivanskie: r is a single string
[20:47:50] pupsicle: has joined #ruby
[20:47:52] apeiros: if you repeatedly check whether something exists in an array, you should consider using a set for the test
[20:48:35] santoxxcc: then i suppose you want to ignore some elements in another array so you could just use reject to create a new array with usefull elements
[20:48:47] santoxxcc: like when developing a sumaryzer
[20:48:49] ivanskie: before i was passing the whole row, and doing. row.each do r -- skiplist.each do s. if r==s -- skip. and it wasnt working... now i just do. skiplistinclude?(row[1])
[20:48:58] bmurt: has joined #ruby
[20:49:06] ivanskie: apeiros set?
[20:49:20] apeiros: &ri Set ivanskie
[20:49:20] `derpy: ivanskie: http://ruby-doc.org/stdlib-2.4.1/libdoc/set/rdoc/Set.html
[20:50:25] eightlimbed: has joined #ruby
[20:50:53] ivanskie: hm. could do. but would have to convert each row from csv into set and do that check, then push it into the new csv file
[20:51:07] ivanskie: this way its organically array in array out
[20:51:38] ivanskie: block above sits inside CSV.process array of arrays
[20:51:41] apeiros: as I understood it you have one array which remains the same, and you test each row of the csv whether one cell of it is in said constant array. no?
[20:52:17] santoxxcc: i understand that too
[20:52:18] apeiros: haven't looked at your code yet, though. so maybe I misunderstood what I read.
[20:52:50] roshanavand: has joined #ruby
[20:54:12] workmad3: has joined #ruby
[20:54:29] ivanskie: just updated my repo: https://github.com/i5okie/pxgMapFetcher/blob/master/lib/device.rb#L20-L72
[20:55:29] apeiros: wow, you call the variable referencing the csv handle "row"?
[20:55:31] ivanskie: apeiros that is what im doing now after havenwood'ssuggestion
[20:55:35] apeiros: that's mighty misleading…
[20:55:59] ivanskie: everything got confused here
[20:56:06] apeiros: https://github.com/i5okie/pxgMapFetcher/blob/master/lib/device.rb#L20
[20:56:07] ivanskie: in gist i called it row[1]
[20:56:16] apeiros: no. see link.
[20:56:17] doublemalt_: has joined #ruby
[20:56:25] apeiros: line 20 of your gist.
[20:56:26] __Yiota: has joined #ruby
[20:56:30] ivanskie: https://github.com/i5okie/pxgMapFetcher/blob/master/lib/device.rb#L47
[20:56:35] apeiros: oh, repo-file actually
[20:56:50] apeiros: I'm not talking about line 47.
[20:57:24] ivanskie: line 20 there is not related to this question
[20:57:38] apeiros: I wasn't saying it was related to your question
[20:57:42] j0bk: dat 75 lines def :P
[20:58:06] ivanskie: wait but line 20 that is a row
[20:58:13] apeiros: no it's not
[20:58:21] hutch34: has joined #ruby
[20:58:33] ivanskie: then i don't understand how ruby works with CSV lines
[20:58:38] nankyokusei: has joined #ruby
[20:59:04] apeiros: the way you use it
[20:59:07] apeiros: csv << line
[20:59:09] meshsmith: has joined #ruby
[20:59:19] ivanskie: row.inspect. would be [] with each value in csv
[20:59:24] apeiros: you don't call your arrays "array_item << item"
[21:00:01] ivanskie: apeiros you are correct, but i believe there's been a miscommunication
[21:00:18] apeiros: I believe there's been a misnaming :-p
[21:00:34] ivanskie: misnaming when explaining my problem
[21:00:39] j0bk: I believe #ufo
[21:00:48] ivanskie: #ufo is coming
[21:00:54] apeiros: ivanskie: as you stated yourself, it's unrelated to your problem
[21:01:26] j0bk: guys what's the question?
[21:01:29] ivanskie: reset --hard. (thanks)
[21:01:49] ivanskie: found a solution. apeiros is now suggesting to use set instead of map on array
[21:01:56] j0bk: if contents.length == 0 that?
[21:01:58] bauruine: has joined #ruby
[21:02:13] apeiros: ivanskie: @skiplist
[21:02:22] ivanskie: turn skiplist into set
[21:02:52] ivanskie: ultimately its just semantics though right?
[21:02:59] apeiros: also your naming is wrong
[21:03:09] ivanskie: not line 20
[21:03:12] apeiros: you have it skipList once and skiplist another place
[21:03:21] apeiros: ruby's variable names are case sensitive
[21:03:23] ivanskie: i blame my workflow
[21:03:26] santoxxcc: has joined #ruby
[21:03:37] ivanskie: i can explain if you care
[21:04:00] apeiros: well, yeah, line 20 too, but that's about csv vs. row.
[21:04:00] apeiros: i.e. that's a semantical misnaming
[21:04:05] apeiros: ivanskie: I don't
[21:04:14] j0bk: santoxxcc wrong window :P
[21:04:15] apeiros: santoxxcc: need help? :-p
[21:04:22] j0bk: do you want to close? /quit
[21:04:28] apeiros: santoxxcc: try /quit
[21:04:55] ivanskie: apeiros thanks. i'll go back and clean up everything once i confirm the thing works and change skiplist to set
[21:05:05] apeiros: good luck :D
[21:05:20] apeiros: once it runs, write some tests. then try to get it to readable code ;-)
[21:05:37] j0bk: ivanskie use OOP
[21:05:50] j0bk: that looks like a bash script
[21:06:03] ivanskie: where did you find skipList?
[21:06:22] j0bk: def fetchMaps(uids, savepath, skipList=[])
[21:06:24] apeiros: your editor lacks a find command? https://github.com/i5okie/pxgMapFetcher/blob/master/lib/device.rb#L15
[21:06:49] ivanskie: ah thank you
[21:07:08] ascarter: has joined #ruby
[21:07:24] j0bk: apeiros you are the most patient guy around the universe
[21:07:49] apeiros: j0bk: thanks. sadly not always, though
[21:12:40] ivanskie: j0bk i'm trying
[21:12:56] ivanskie: j0bk open to suggestions
[21:13:19] ivanskie: this is the most "ambitious" ruby program i've written to date.
[21:13:24] ivanskie: outside of any rails stuff
[21:14:33] ivanskie: and its broken again
[21:17:11] latemus: has joined #ruby
[21:18:26] __Yiota: has joined #ruby
[21:18:44] ivanskie: ok so skiplist sits inside Site class, and populated when Site is initialized from config file.
[21:19:56] ivanskie: thought i could just access it from Device class without passing to my method everytime i run it
[21:21:21] patarr: has joined #ruby
[21:21:26] antgel_: has joined #ruby
[21:21:28] ivanskie: with activemodel it'd be easy.
[21:21:38] Bounga: has joined #ruby
[21:21:52] ivanskie: but i haven't learned how to use class / modules properly yet
[21:22:21] apeiros: good opportunity then
[21:23:10] apeiros: you should also learn about scopes it seems
[21:23:30] apeiros: scopes = boundaries of where variables are accessible
[21:23:45] ivanskie: scopes between class and modules.
[21:24:03] apeiros: scopes *of things
[21:24:50] ivanskie: i see what i did wrong here
[21:25:25] j0bk: var = "hello"; things.each{ |var| puts var}; puts var
[21:25:27] j0bk: like this
[21:26:23] j0bk: var lives inside and outside of the each
[21:26:25] apeiros: also "where can I access which @instance_variable"
[21:26:51] apeiros: Device's @skiplist seems unused f.ex.
[21:26:54] ivanskie: yeah im good with scopes between blocks or methods and inside modules etc..
[21:27:27] ivanskie: you are right i just removed it a bit earlier
[21:28:52] ivanskie: okay so.. in my program. each site object has multiple device objects.. thought i realize not in the same way as activemodel does it.
[21:29:12] ivanskie: damn i need to get out of rails in my head lol
[21:29:18] ivanskie: i learned rails before ruby
[21:29:20] enterprisey: has joined #ruby
[21:29:25] ivanskie: messing me up a bit
[21:29:40] ivanskie: i want to do Site.skiplist
[21:29:52] apeiros: that'd be a class method
[21:30:16] j0bk: def Site.skiplist; end
[21:30:27] j0bk: or self.skiplist
[21:30:33] apeiros: ACTION prefers the latter
[21:30:44] j0bk: yep for refactors
[21:30:51] ivanskie: and would work if this was activemodel. but i dont have that relationship between device and site. @devices is just an array of objects inside Site object. so i can't do Parent.skiplist
[21:31:15] ketan: has joined #ruby
[21:31:21] apeiros: j0bk: also for grep and less typing
[21:31:44] ivanskie: i have class Device < Site. but honestly i dont know what im doing there and if it even makes any sense at all
[21:32:04] ivanskie: multiple sites, each site has multiple devices
[21:32:04] apeiros: you say that Device is a subclass of Site
[21:32:14] apeiros: then no, that doesn't make sense
[21:32:14] j0bk: ivanskie what do you want to do?
[21:32:24] ivanskie: j0bk was talking about doing OOP. thats what im trying to do here
[21:32:26] apeiros: inheritance means "it's similar in its shape"
[21:32:34] d10n-work: has joined #ruby
[21:32:35] Tagami[m]: has joined #ruby
[21:32:47] ivanskie: yes and device has nothing in common with site in that regard.
[21:32:58] ecuanaso: has joined #ruby
[21:32:58] apeiros: then don't inherit
[21:33:03] j0bk: yes, but you need to think what do you want to model before thinking in OOP
[21:34:10] ivanskie: in my mind if i pass @skiplist to every device, or everytime i run fetchMaps method on each device.. its inefficient. im thinking @skiplist is common thing between all devices per each site. so one site -- one skiplist.
[21:34:14] bmurt: has joined #ruby
[21:34:41] apeiros: so class Site has an instance variable @skiplist
[21:34:49] apeiros: and Site has an instance variable @devices
[21:34:54] apeiros: one site, many devices, right?
[21:35:12] apeiros: now you just need the proper datatype of @devices
[21:35:16] ivanskie: so i should make class Devices
[21:35:20] apeiros: Array and Hash are the common collection classes
[21:35:51] apeiros: most people are too lazy to write their own collection classes, but it'd often make sense.
[21:36:14] ivanskie: this is a simple problem case here so dont need to over complicate it. but im trying to learn ruby not just write a dirty scrip that does the job
[21:36:33] apeiros: I do tend to call them DeviceList or something else more explicit, since people tend to miss the difference between Device and Devices
[21:36:54] ivanskie: i've spent about 4 days on this so far
[21:36:56] apeiros: &ri SimpleDelegator ivanskie
[21:36:57] `derpy: ivanskie: http://ruby-doc.org/stdlib-2.4.1/libdoc/delegate/rdoc/SimpleDelegator.html
[21:37:28] apeiros: &ri Forwardable ivanskie
[21:37:28] `derpy: ivanskie: http://ruby-doc.org/stdlib-2.4.1/libdoc/forwardable/rdoc/Forwardable.html
[21:37:40] apeiros: those are useful to implement your own collection classes
[21:38:44] __Yiota: has joined #ruby
[21:38:52] apeiros: but yeah, I'd probably not focus on collection classes yet
[21:39:02] apeiros: write the scalar classes first
[21:39:36] ivanskie: k going to do device.fetchMaps(@uids, @savepath, @skiplist) for now. just to get the project going (i actually need to do something with the end csv for work lol). then practice this
[21:39:42] ivanskie: ok looks like that fixed it.
[21:40:22] apeiros: ok, maybe yes :)
[21:41:04] ivanskie: if this was rails i'd just do device.fetchMaps and that'd inherit the instance variables of the site that it belongs to
[21:41:21] apeiros: no, rails doesn't inherit ivars either
[21:41:29] apeiros: no idea where you have that from :)
[21:41:33] ski4x7: has joined #ruby
[21:41:39] bauruine: has joined #ruby
[21:41:45] apeiros: it does have inheritable ivars. but that's a different thing.
[21:42:09] j0bk: ActiveRecord != Rails; classes != models
[21:42:22] ivanskie: i mean to say that.. i'd have access to device.site.skiplist
[21:42:39] apeiros: through the relation, yes
[21:42:45] apeiros: and that one doesn't happen magically either
[21:42:54] apeiros: what do you think rails does behind the scenes? :)
[21:42:59] ivanskie: maaaagicccc
[21:43:09] apeiros: no. argument passing.
[21:43:37] cadillac_: has joined #ruby
[21:43:39] ski4x7: has joined #ruby
[21:44:01] apeiros: and it's got nothing to do with inheritance. at all.
[21:44:04] ivanskie: so essentially. device gets site and its ivars
[21:44:21] apeiros: not really.
[21:44:36] ivanskie: i should take a look at activerecord
[21:44:49] apeiros: device's class knows it's got a relation to site and provides a method to access the related site.
[21:45:19] apeiros: you still have to go through site to get the skiplist. you don't have it in device itself.
[21:45:21] patarr: has joined #ruby
[21:45:52] ivanskie: what you said above about classes!=models. it took me a few to figure out what difference between class and methods is. and still in my head class is a model (trying to break that).
[21:46:11] Guest85918: has joined #ruby
[21:46:11] kp666[m]: has joined #ruby
[21:46:11] johnson[m]: has joined #ruby
[21:46:11] M107262[m]: has joined #ruby
[21:46:11] torarne: has joined #ruby
[21:46:11] heftig: has joined #ruby
[21:46:11] aviraldg: has joined #ruby
[21:46:11] jonjits[m]: has joined #ruby
[21:46:11] intermo[m]: has joined #ruby
[21:46:12] dman[m]: has joined #ruby
[21:46:12] turt2live1: has joined #ruby
[21:46:12] voltai[m]: has joined #ruby
[21:46:12] Giphy[m]: has joined #ruby
[21:46:12] KevinMGranger: has joined #ruby
[21:46:15] apeiros: actually j0bk said that ;-)
[21:46:18] testnick[m]: has joined #ruby
[21:46:19] velu_aon[m]: has joined #ruby
[21:46:19] el_ocho[m]: has joined #ruby
[21:46:26] ivanskie: okwhen j0bk said that
[21:46:30] apeiros: (they're right, of course, though models < classes)
[21:47:16] j0bk: models < Object == "classes"
[21:47:29] apeiros: no, models are classes
[21:47:35] apeiros: that's what I meant
[21:47:50] ski7777: has joined #ruby
[21:47:54] quobo: has joined #ruby
[21:47:55] ivanskie: thats how i got that
[21:48:13] ivanskie: class ModelName
[21:48:44] ivanskie: which then inherits from application::activerecord if i remember correctly
[21:48:58] apeiros: ActiveRecord::Base
[21:49:17] apeiros: or any subclass thereof
[21:49:35] ivanskie: this is a great excercise
[21:49:43] ivanskie: the ruby code was writing.
[21:49:52] ivanskie: spend 4 days, to save 2 hours
[21:50:07] ivanskie: now it does it what i need it to do in 2mins
[21:50:58] ivanskie: 24 devices, each 3-5 csv files.. and these 3-5 files would have to be renamed or put in its own folder, etc etc. now just run code --> 24 ready csv files.
[21:51:29] ivanskie: then need to add code to zip it and a couple other files, and then can just email the zip file to schneider
[21:51:40] apeiros: shouldn't it be 72-120 csv files?
[21:51:55] ivanskie: if done manually yes
[21:52:09] eblip: has joined #ruby
[21:52:26] def_jam: has joined #ruby
[21:54:14] ivanskie: here's what this is. have 24 PDUs, these have APC PowerXpertGateway nic cards in them, each PDU has two breaker panels, each panel has up to 40 breakers. each is measured. now we need to access this info in a DCIM tool. but DCIM tool needs a device definition file, which says how to talk to said device, and which sensors (or data points) to import.
[21:54:25] SeepingN: has joined #ruby
[21:54:38] ivanskie: so easier way would be SNMP, but these devices don't output all the data in SNMP, but do output complete data to MODBUS
[21:55:04] ivanskie: modbus is old, u have to send packet [command, unit id, register]
[21:55:12] ivanskie: so you have register map tables.
[21:55:55] ivanskie: all that just to explain that each of those. 5 files is a register map for specific unit id. and unit id is mentioned in file name. but otherwise each csv file has the same structure
[21:56:26] __Yiota: has joined #ruby
[21:56:37] ivanskie: so what im doing here is, downloading each file, injecting unit id, and combining all into a single csv file.
[21:57:08] ivanskie: so instead of 72-120 csv files, we get 24
[21:57:56] ivanskie: skiplist was an afterthought because, schneider came back and said. uhm we can't do more than 1000 sensors per device for performance reasons.
[21:58:24] ivanskie: ACTION facepalm
[22:00:30] gusrub: has joined #ruby
[22:00:35] ivanskie: now that i have these 24 files, and filtered to less than 800 data points each now. i can send to schneider and wait for them to make a device definition file for us..
[22:00:38] __Yiota: has joined #ruby
[22:01:30] ivanskie: need this script/program because if someone changes/moves/adds/removes a breaker, have to repeat the above process
[22:01:40] ivanskie: hense the need for my app
[22:02:34] apeiros: sounds like something fun to write :)
[22:02:45] ivanskie: only if it didn't take 4 days.
[22:02:50] ivanskie: i was starting to get burnout
[22:02:57] ivanskie: get burntout
[22:03:07] apeiros: burned out?
[22:03:18] hutch34: has joined #ruby
[22:03:32] Guest85918: has joined #ruby
[22:03:49] ivanskie: this whole thing started with trying to write a powershell script because i can't install ruby on corp machines.
[22:04:14] ivanskie: shit didn't work, not as experienced in powershell.
[22:04:22] ivanskie: so then manager said fine do what u need to do.
[22:04:33] dionysus69: has joined #ruby
[22:04:39] ivanskie: then took a day to figure out that i need digestauth and not simpleauth
[22:04:53] ivanskie: one thing after another basically
[22:05:21] ledestin: has joined #ruby
[22:05:24] ivanskie: once you spend more time on trying to solve the problem in code, than it would take you to do manually.. you get stress.
[22:05:30] ecuanaso: has joined #ruby
[22:05:48] patarr: has joined #ruby
[22:07:57] ivanskie: whew. now i can start refactoring and cleaning the shit code up.
[22:08:43] ivanskie: i'm a wannabe ruby/rails/js web developer...
[22:09:21] dionysus69: has joined #ruby
[22:10:07] ivanskie: i wonder if this counts as junior dev.
[22:12:19] gusrub: has joined #ruby
[22:14:06] FastJack: has joined #ruby
[22:15:21] __Yiota: has joined #ruby
[22:15:36] ivanskie: just pushed working code
[22:16:41] ivanskie: oh yeah also have multiple sites
[22:18:19] patarr: has joined #ruby
[22:21:05] konsolebox: has joined #ruby
[22:22:41] Bounga: has joined #ruby
[22:28:22] cschneid_: has joined #ruby
[22:28:53] cschneid_: has joined #ruby
[22:30:36] Uranio: has joined #ruby
[22:32:44] Cohedrin: has joined #ruby
[22:33:37] segy: has joined #ruby
[22:34:20] ddffg: has joined #ruby
[22:35:11] ivanskie: wondering why its so quiet, then remembered its friday.
[22:35:26] ivanskie: Happy Friday everybody!
[22:36:38] gothicsouth: has joined #ruby
[22:38:26] jjunior_: has joined #ruby
[22:40:05] muelleme_: has joined #ruby
[22:40:37] jenrzzz: has joined #ruby
[22:40:37] jenrzzz: has joined #ruby
[22:43:28] AnoHito: has joined #ruby
[22:44:17] eb0t: has joined #ruby
[22:45:16] segy: has joined #ruby
[22:45:39] eb0t_: has joined #ruby
[22:45:42] santoxxcc: has joined #ruby
[22:46:18] santoxxcc: i don't know if this can be done
[22:46:20] santoxxcc: first_name, last_name = name.split(/\s+/)
[22:46:31] santoxxcc: is that ok?
[22:47:20] ruby[bot]: Why don't you try it and see for yourself?
[22:49:10] ivanskie: i've seen something like that done actually
[22:49:15] santoxxcc: Correct me if i'm wrong, but the fist element of the array that is the value is going to the first_name and the next element to last_name
[22:51:50] baweaver: you're assuming a lot santoxxcc
[22:52:21] baweaver: what if they have a name like Dr. Bill White
[22:52:38] baweaver: or William Cumberbatch III
[22:52:39] santoxxcc: wouldn't work?
[22:52:53] ivanskie: first_name, last_name = name.split(/\s+/)
[22:53:04] baweaver: split on spaces will give you however many words are there
[22:53:04] ivanskie: https://repl.it/IpWu/0
[22:53:28] Brent___: has joined #ruby
[22:53:39] baweaver: but only capture the first two
[22:53:52] baweaver: so in my case, Brandon A Weaver, it'd be first name Brandon last name A
[22:53:55] baweaver: which is incorrect.
[22:54:26] elifoster: has joined #ruby
[22:54:46] santoxxcc: so would be like 4 placeholders?
[22:54:56] baweaver: names are fun.
[22:56:06] Papierkorb: santoxxcc: to make matters even more fun, rarely, but some ppl don't even have nor first or no last name at all. Ask the user for both separately
[22:57:22] Papierkorb: santoxxcc: not to mention that some people have multiple last names, so you can't even get away with assuming that all but the last word are first names
[22:58:19] baweaver: they inherit a ton of family names in some cases.
[22:58:44] santoxxcc: i should make code for all those cases?
[22:58:56] baweaver: Make a text field for last and first names
[22:59:06] baweaver: let them figure it out, that's the easy path
[22:59:12] santoxxcc: like a if..elsif construct?
[22:59:30] nankyokusei: has joined #ruby
[23:00:35] santoxxcc: Then i'll ask the user to only put first and last names
[23:01:19] zepy_aq: has joined #ruby
[23:02:14] gothicsouth: has joined #ruby
[23:02:20] santoxxcc: what's better? use initialize() to define object variables or use attr_accessor?
[23:03:11] baweaver: Read on what both of them do.
[23:03:17] Papierkorb: santoxxcc: Both do different things. In #initialize you can initialize @instance vars to some value (hence the name), with attr_accessor and friends you define accessor methods to those instance variables
[23:03:27] santoxxcc: has joined #ruby
[23:03:36] hutch34: has joined #ruby
[23:04:27] herbmillerjr: has joined #ruby
[23:06:24] belmoussaoui: has joined #ruby
[23:07:00] sneakerhax: has joined #ruby
[23:10:18] bauruine: has joined #ruby
[23:14:50] eightlimbed: has joined #ruby
[23:15:11] postmodern: has joined #ruby
[23:15:36] t-recx: has joined #ruby
[23:15:37] Cohedrin: has joined #ruby
[23:17:08] helpa-bot: has joined #ruby
[23:17:41] Truenigma: has joined #ruby
[23:19:07] helpa-bot: has joined #ruby
[23:19:22] Utkarsh_: has joined #ruby
[23:19:41] t-recx_: has joined #ruby
[23:19:53] Kug3lis_: has joined #ruby
[23:20:10] m4rCsi: has joined #ruby
[23:20:11] P1ro_: has joined #ruby
[23:20:20] tw1sted_: has joined #ruby
[23:20:41] ahuman: has joined #ruby
[23:21:09] helpa-bot: has joined #ruby
[23:21:27] abort: has joined #ruby
[23:21:30] devyn_: has joined #ruby
[23:21:31] Sp4rKy_: has joined #ruby
[23:21:39] lucas: has joined #ruby
[23:21:46] _mak: has joined #ruby
[23:21:55] montyboy_: has joined #ruby
[23:21:58] santoxxc1: has joined #ruby
[23:22:01] chaos95_: has joined #ruby
[23:22:08] swills_: has joined #ruby
[23:22:23] ejnahc_: has joined #ruby
[23:22:25] matled-: has joined #ruby
[23:23:08] helpa-bot: has joined #ruby
[23:23:24] Bounga: has joined #ruby
[23:24:56] ishigoya-: has joined #ruby
[23:25:09] helpa-bot: has joined #ruby
[23:25:16] Radar_: has joined #ruby
[23:25:16] shortdudey123_: has joined #ruby
[23:25:18] elem: has joined #ruby
[23:25:42] santoxxc1: what's good for the brain pain?
[23:26:25] icedragon: has joined #ruby
[23:26:26] FifthWall_: has joined #ruby
[23:26:35] theRoUS: has joined #ruby
[23:26:37] d^sh: has joined #ruby
[23:26:43] phreakocious: has joined #ruby
[23:26:44] nchambers: has joined #ruby
[23:27:10] helpa: has joined #ruby
[23:27:15] Guest66963: has joined #ruby
[23:27:19] xMopxShell: has joined #ruby
[23:27:28] cajone: has joined #ruby
[23:27:37] vqrs: has joined #ruby
[23:27:40] nathani: has joined #ruby
[23:27:46] al2o3-cr: has joined #ruby
[23:27:53] borei1: has joined #ruby
[23:28:05] BTRE: has joined #ruby
[23:28:53] cschneid_: has joined #ruby
[23:28:59] Raboo: has joined #ruby
[23:30:03] veloutin: has joined #ruby
[23:31:03] reinh1: has joined #ruby
[23:31:03] belmoussaoui: has joined #ruby
[23:31:03] maxmanders: has joined #ruby
[23:31:40] ionte: has joined #ruby
[23:32:07] ketan: has joined #ruby
[23:33:20] cout: has joined #ruby
[23:34:35] michael_mbp: has joined #ruby
[23:38:11] brent__: has joined #ruby
[23:38:40] Nuck: has joined #ruby
[23:40:01] jenrzzz: has joined #ruby
[23:40:02] jenrzzz: has joined #ruby
[23:46:36] Qommand0r: has joined #ruby
[23:47:12] pupsicle: has joined #ruby
[23:50:46] charliesome: has joined #ruby
[23:55:17] Bhootrk_: has joined #ruby
[23:56:21] Cohedrin: has joined #ruby
[23:57:59] gothicsouth: has joined #ruby