« Back to channel list

#ruby - 15 August 2018

« Back 1 day Forward 1 day »
[00:03:52] jayjo: I'm working with a rails application and I'm struggling to whitelist IPs correctly - I think it's because of how rails is assigning the remote IP address
[00:03:55] jayjo: here is the script I have: https://bpaste.net/show/a29dcd765c40
[00:04:37] jayjo: This is a gitlab server running in a docker container... where does assign the remote IP address here?
[00:05:45] jayjo: in this instance - what is HTTP_X_FORWARDED_FOR ?
[00:08:33] dviola: is there anything bad in this code? https://gist.github.com/diegoviola/6450adcb022237de21f50f8625e7d60a
[00:20:36] orbyt_: has joined #ruby
[00:26:39] bonhoeffer: has joined #ruby
[00:27:21] bonhoeffer: i remember a selenium enabled web automation capability where I could view and troubleshoot the browser while the script ran
[00:27:50] bonhoeffer: but all i can figure out how to do now is run save_and_open_screenshot -- is there something more interactive
[00:36:52] bonhoeffer: has joined #ruby
[00:39:00] cagomez: has joined #ruby
[00:47:20] zenspider: dviola: I think it is a bit more complicated than it needs to be... but also, it seems like it's a bit too narrowly focused? Why would you have a string of JUST brackets to check if it is balanced or not?
[00:47:46] zenspider: pairs.keys.include? -> pairs.has_key?
[00:48:00] zenspider: each_with_object isn't necessary at all.
[00:48:08] zenspider: I'd push the pairs hash up to a constant
[00:50:14] dviola: zenspider: yep
[00:50:35] Radar: dviola: What is the result of balanced?("((()") ?
[00:50:39] zenspider: I don't like the check on line 11 for the same reason as line 9... but I think I'd just push the check from 12 to be your check for 11
[00:50:45] dviola: Radar: false
[00:50:54] Radar: dviola: Are you certain?
[00:51:06] bonhoeffer_: has joined #ruby
[00:51:20] zenspider: yeah. I should say: I'm ONLY evaluating the ruby itself... not the validity of it :P
[00:51:20] Radar: https://gist.github.com/radar/cdb774a82ed14289182bf25cb56a5334
[00:51:23] Radar: Because my test isn't passing.
[00:51:31] Radar: And I'm pretty confident that I am not wrong.
[00:52:15] zenspider: ACTION always likes seeing minitest in the wild... 
[00:52:27] Radar: zenspider: I've been trying to use it more + more for little scripts like this.
[00:52:44] dviola: Radar: oh, it's true
[00:52:47] dviola: you're rigth
[00:52:51] zenspider: yup. pretty much the only time I use minitest/spec style is for 1-liners in here
[00:52:51] Radar: dviola: :D :D
[00:53:05] zenspider: easy to say: describe Array do ... end
[00:54:07] zenspider: makes me think that there should be a quick tweak to allow for top level asserts for exactly this sort of thing
[00:56:59] dviola: thanks, I'll think more about this problem
[00:57:24] zenspider: test driven will definitely help
[00:57:55] s2013: has joined #ruby
[00:58:27] Radar: dviola: want to see my version?
[00:59:01] Radar: dviola: https://gist.github.com/radar/81ac67ed2d30fed88917f4ff3ea9b0c2
[00:59:13] Radar: Oops, missed the constant.
[00:59:49] Radar: TL;DR: check for open brackets, and then only check that there are equivalent closing brackets.
[01:02:40] dviola: very nice
[01:08:25] dviola: interesting
[01:11:21] bonhoeffer: has joined #ruby
[01:12:28] desnudopenguino: jayjo: i'm messing around with setting up an AWS EC2 instance with some ruby stuff, and with sinatra running thin, somehow my local ip is showing up in the log, not my ISP provided ip
[01:17:33] drbrain: has joined #ruby
[01:24:41] s2013: has joined #ruby
[01:26:25] ur5us: has joined #ruby
[01:30:02] bonhoeffer: has joined #ruby
[01:32:54] hays_: has joined #ruby
[01:33:13] hays_: bear with me--i have made a gem, and I get whining when I install it that my dependencies dont have versions
[01:33:33] hays_: but--when I add versions it complains about something else
[01:34:05] hays_: how should I be specifying versions in gem dependency lists
[01:36:32] Casstorm: has joined #ruby
[01:38:32] jtdowney: has joined #ruby
[01:44:19] r3m: has joined #ruby
[01:44:39] desnudopenguino: hays_: give us more info concerning what it is complaining about.
[01:46:21] hays_: yeah, sorry. hit a hiccup. I made an s.executables = Dir["{bin}/*"] and it doesnt like the bin/ in that so i need to fix that to reproduce the error
[01:49:31] chouhoulis: has joined #ruby
[01:56:58] hays_: desnudopenguino: WARNING: open-ended dependency on gserver (>= 0) is not recommended
[01:57:14] hays_: WARNING: open-ended dependency on activerecord (>= 0)
[01:59:53] bmurt: has joined #ruby
[02:00:03] hays_: so do I add ~> 0 to those?
[02:13:51] t0x: has joined #ruby
[02:20:35] s2013: has joined #ruby
[02:20:45] Radar: hays_: It'd be helpful if we could see this problem happening on our machine.
[02:26:24] redlegion: has joined #ruby
[02:26:57] redlegion: has joined #ruby
[02:27:47] lxsameer: has joined #ruby
[02:31:01] hays_: am I misunderstanding bundle? I am running bundle install and it doesn't seem like some of the gems are installing
[02:32:03] hays_: it seem slike it is "using" the gem from a github repo, but not installing it somehow
[02:32:12] rootsudo: has joined #ruby
[02:34:29] hays_: crazy enough, bundle exec irb shows the gem installed, but straight irb does not.
[02:43:01] Radar: hays_: just curious: do you want help with this or not?
[02:44:32] hays_: yes, but I don't really know how to help with your request
[02:45:14] Radar: hays_: Give us some code that goes "boom" on your machine and we'll see if it goes "boom" on our machine.
[02:45:35] Radar: " it doesn't seem like some of the gems are installing" <- or at least _some_ information about how you came to such a conclusion
[02:45:47] Radar: "but not installing it somehow" <- proof? details?
[02:46:16] hays_: ok. well I have a Gemfile. it has a list of gems. one of them is to a private github repository
[02:46:39] hays_: that one does not show up in gem list, but it shows up if I do bundle exec irb
[02:47:03] hays_: however, the gems that are public. those seem to install in system/rbenv ruby
[02:47:06] Radar: RubyGems "gem list" command has no idea about GitHub gems. Only Bundler knows that.
[02:47:47] hays_: so if its a rubygem it installs it in the system, but if its a github gem it somehow keeps it isolated within the bundle tool?
[02:48:00] Radar: Bundler will install it to a different path iirc.
[02:48:20] hays_: curious. ok
[02:48:45] Radar: My local Rails is installed at: /usr/local/opt/asdf/installs/ruby/2.4.2/lib/ruby/gems/2.4.0/gems/rails-5.2.0
[02:48:47] hays_: with the other problem, I took a guess at it, and seemed to get it to build/install the gem without warnings
[02:48:58] Radar: A GH gem that I have installed is: /usr/local/opt/asdf/installs/ruby/2.4.2/lib/ruby/gems/2.4.0/bundler/gems/gem-name-goes-here-0c799877560f
[02:49:20] Radar: what do you mean "without warnings"? Were you expecting warnings?
[02:49:50] hays_: i was getting warnings when I ran gem build foo-1.0.gemspec
[02:50:04] hays_: erm thats a garbage gemspec name. I meant foo.gemspec
[02:50:16] hays_: it didn't seem to like unversioned gem depedencies
[02:50:24] Radar: Can you show us the warnings?
[02:50:49] hays_: WARNING: open-ended dependency on gserver (>= 0) is not recommended
[02:51:12] hays_: so for that one I added '~>0' and it seems to be OK now
[02:51:19] Radar: Right. So that's because you've not specified a gem version dependency so it's going to install _any_ version of that gem, which is probably not what you want.
[02:51:33] hays_: but I was getting the same warning for nokogiri, activerecord, and mysql2
[02:51:37] Radar: maybe 2.0 will work with your app, but would 1.0? You should lock it down like ~> 1.0
[02:53:08] hays_: i made activerecord ~> 5.2
[02:53:41] hays_: not sure if that's reasonable
[02:53:50] hays_: mysql ~> 0.5
[02:53:53] Radar: [12:51:37] <Radar> maybe 2.0 will work with your app, but would 1.0? You should lock it down like ~> 1.0
[02:53:56] Radar: Up to you to decide.
[03:00:26] kapil___: has joined #ruby
[03:02:25] bonhoeffer_: has joined #ruby
[03:11:13] braincrash: has joined #ruby
[03:13:14] dtzuzu: has joined #ruby
[03:26:31] ryu-: has joined #ruby
[03:33:14] _whitelogger: has joined #ruby
[04:00:14] gnufied: has joined #ruby
[04:12:56] xall: has joined #ruby
[04:16:37] diego1: has joined #ruby
[04:20:09] s2013: has joined #ruby
[04:24:42] ur5us: has joined #ruby
[04:28:26] lxsameer: has joined #ruby
[04:31:15] memo1: has joined #ruby
[04:38:07] tolerablyjake: has joined #ruby
[05:02:56] blood: has joined #ruby
[05:03:32] blood: Anyway to copy xml namespaces -> remove namespaces -> do some xpath queries -> copy back namespaces?
[05:03:48] blood: using Nokogiri
[05:10:26] samort7: has joined #ruby
[05:17:52] sleetdrop: has joined #ruby
[05:26:35] maufart__: has joined #ruby
[05:27:06] lxsameer: has joined #ruby
[05:32:22] hays_: has left #ruby: ()
[05:39:15] r3m: has joined #ruby
[05:43:52] r3m: has joined #ruby
[05:55:20] tbuehlmann: has joined #ruby
[05:57:46] xall: has joined #ruby
[05:59:49] sauvin: has joined #ruby
[06:00:58] armyriad: has joined #ruby
[06:11:01] mojtaba: has joined #ruby
[06:11:28] Mike11: has joined #ruby
[06:13:30] KevinSjoberg: has joined #ruby
[06:13:40] sauvin: has joined #ruby
[06:24:04] t0x: has joined #ruby
[06:27:11] Freshnuts: has joined #ruby
[06:27:43] dionysus69: has joined #ruby
[06:45:38] iMadper: has joined #ruby
[06:59:23] clemens3: has joined #ruby
[07:00:35] LiftLeft: has joined #ruby
[07:23:15] ur5us: has joined #ruby
[07:30:04] Dbugger: has joined #ruby
[07:34:58] alex``: has joined #ruby
[07:35:11] mihael_k33hl: has joined #ruby
[07:35:49] mihael_k33hl: It's my first time creating a gem, is it acceptable to name it like john-ruby? https://guides.rubygems.org/name-your-gem/ Cause I'm gonna be creating this gem and future gems under the namespace john?
[07:37:54] cats: has joined #ruby
[07:43:33] sina: has joined #ruby
[07:47:44] ferhaty: has joined #ruby
[07:50:57] apeiros: mihael_k33hl: yes, it's acceptable. it's then expected to have `require 'john/rsymc'` and provide a constant John::Rsymc (though I guess you meant rsync)
[07:53:22] mihael_k33hl: apeiros: Yeah, it's rsync, sorry about that. Thanks man. I don't think the rsync gem is being actively updated though so I'll just create my own. :)
[07:55:14] t0xik: maybe it doesnt need to be updated
[07:56:27] mihael_k33hl: t0xik: Oh yeah, the owner said it's on a stable state. But a lot of people are trying to add some features/functionalities that they need for it.
[07:56:46] mihael_k33hl: t0xik: that includes me hehe :)
[08:00:23] amelliaa: has joined #ruby
[08:02:50] mikecmpbll: has joined #ruby
[08:19:03] reber: has joined #ruby
[08:23:19] alex``: has joined #ruby
[08:26:51] KevinSjoberg: has joined #ruby
[08:31:52] mikecmpbll: has joined #ruby
[08:37:17] Hobbyboy: has joined #ruby
[08:47:05] jottr: has joined #ruby
[08:47:51] redlegion: has joined #ruby
[08:48:33] klaas: has joined #ruby
[08:55:09] dbugger_: has joined #ruby
[08:59:47] Beams: has joined #ruby
[09:00:29] mojtaba: has joined #ruby
[09:01:14] dhollin3: has joined #ruby
[09:02:20] tristanp: has joined #ruby
[09:14:06] lxsameer: has joined #ruby
[09:16:42] zipkid_: has joined #ruby
[09:17:14] bove_: has joined #ruby
[09:18:00] codepete_: has joined #ruby
[09:18:07] strmpnk_: has joined #ruby
[09:18:32] canton7: has joined #ruby
[09:18:42] barq: has joined #ruby
[09:23:57] Dabo: has joined #ruby
[09:24:28] khomesh24: has joined #ruby
[09:55:55] Blaguvest: has joined #ruby
[10:01:13] Mike111: has joined #ruby
[10:05:18] rootsudo: has joined #ruby
[10:06:53] p4p0l0: has joined #ruby
[10:19:17] gensym: has joined #ruby
[10:21:01] ruby[bot]: -bb User458764!*@*$#ruby-fix-your-connection *!*@62.147.220.187$#ruby-fix-your-connection
[10:21:30] gensym: hi, I want evertime I call YAML.load_file(filename) to print the filename for debugging purpose. How can I register a "before" hook or something similar?
[10:21:40] Radar: gensym: puts filename
[10:22:34] ruby[bot]: Next question, please!
[10:22:46] gensym: @Radar i dont want to change all places where YAML.load_file(filename) is called, hence the the "before" hook
[10:23:02] Radar: gensym: how many places out of curiosity?
[10:23:45] gensym: many, but that doesnt really matter. Its for DRY
[10:24:56] apeiros: gensym: `module YamlFilePrinter; def load_file(name); puts name; super; end; end; YAML.singleton_class.prepend YamlFilePrinter`
[10:25:01] nickjj: has joined #ruby
[10:25:33] gensym: @apeiros thanks, I will try that
[10:29:43] mikecmpbll: has joined #ruby
[10:29:53] gensym: @apeiros works! great!
[10:44:46] aupadhye: has joined #ruby
[10:48:25] mojtaba: has joined #ruby
[10:52:19] mojtaba: has joined #ruby
[11:04:01] maufart__: has joined #ruby
[11:08:05] bonhoeffer: has joined #ruby
[11:08:23] wildermind: has joined #ruby
[11:17:57] jottr: has joined #ruby
[11:22:22] bonhoeffer_: has joined #ruby
[11:32:40] mojtaba: has joined #ruby
[11:43:44] fmcgeough: has joined #ruby
[11:47:05] moei: has joined #ruby
[11:49:10] AJA4350: has joined #ruby
[11:51:34] bauruine: has joined #ruby
[11:56:20] p4p0l0: has joined #ruby
[11:56:51] vondruch_: has joined #ruby
[11:57:37] EXCHGR: has joined #ruby
[12:05:05] sticaz: has joined #ruby
[12:06:14] sameerynho: has joined #ruby
[12:16:23] Azure: has joined #ruby
[12:30:06] MuffinPimp: has joined #ruby
[12:48:03] MuffinPimp: has joined #ruby
[12:53:49] blackmesa: has joined #ruby
[13:00:58] gnufied: has joined #ruby
[13:01:45] p4p0l0: has joined #ruby
[13:01:55] conta: has joined #ruby
[13:05:05] tristanp: has joined #ruby
[13:06:35] blackmesa: has joined #ruby
[13:10:42] bonhoeffer: has joined #ruby
[13:14:19] cadillac_: has joined #ruby
[13:14:45] gray_-_wolf: has joined #ruby
[13:19:40] bonhoeffer_: has joined #ruby
[13:22:06] blood: has joined #ruby
[13:22:55] blood: Is there a way to ignore namespaces while querying xpath using Nokogiri? I cannot remove all namespaces from the document as it breaks the application that I am using.
[13:29:02] blood: hrmm seems like setting default_namespace on root node works
[13:29:32] blackmesa1: has joined #ruby
[13:36:46] GodFather: has joined #ruby
[13:44:47] kinduff: has joined #ruby
[13:44:53] dtzuzu: has joined #ruby
[13:46:49] kinduff: has joined #ruby
[13:47:56] snickers: has joined #ruby
[13:48:22] raggi: has joined #ruby
[13:54:11] Emmanuel_Chanel: has joined #ruby
[14:03:40] VladGh: has joined #ruby
[14:04:28] darix: blood: if you only have one namespace ... yes
[14:04:31] darix: then you can do that
[14:04:52] discopatrick: has joined #ruby
[14:05:17] bonhoeffer: is there a smart “with” block
[14:05:38] ged: has joined #ruby
[14:05:47] bonhoeffer: so if I have @myobject i don’t have to do @myobject.start @myobject.next_thing @myobject.another_thing
[14:06:04] imhajes: has joined #ruby
[14:06:19] blood: darix: yea I tried storing all namespace definitions then resetting them before write and nokogiri crashes =)
[14:06:20] bonhoeffer: want something like “with @myobject { .start .next_thing .stop}
[14:06:34] blood: would be nice to just say ignore namespace during a xpath query
[14:06:46] bonhoeffer: like all things, i’m probably approaching the design pattern wrong
[14:07:07] Alina-malina: has joined #ruby
[14:07:26] imhajes: any one help me cinch irc bot?
[14:08:13] darix: blood: but you can have thins like <foo:bar><foobar:bar /></foo:bar> ... now you do //bar ... which one do you refer to?
[14:08:45] bonhoeffer_: has joined #ruby
[14:09:41] blood: https://gist.github.com/bloodmc/c618d978316d0e2756b5b7d1fbfa5e03
[14:09:47] blood: pasted 2 examples in this file
[14:10:07] blood: how would I query in xpath (nokogiri) for line 8 and line 25
[14:10:16] blood: using namespaces
[14:10:21] bonhoeffer__: has joined #ruby
[14:12:17] darix: ACTION tries to remember where his code is for xpath with namespace
[14:14:27] blood: nokogiri really needs an option to disable namespace requirements assuming you have xml with namespace only in root
[14:14:45] blood: Pretty sure REXML does not do this
[14:14:48] Nicmavr: has joined #ruby
[14:14:51] blood: but REXML is painfully slow
[14:16:02] darix: blood: //xmlns:filter-name
[14:16:08] Rapture: has joined #ruby
[14:16:09] darix: blood: //xmlns:cookie-name
[14:16:14] conta: has joined #ruby
[14:17:04] darix: that xmlns is a short hand for the default namespace
[14:17:37] blood: I can do the following if i remove namespaces /weblogic-web-app/session-descriptor/cookie-name
[14:18:41] blood: and /web-app/filter[filter-name='psfilter']
[14:19:00] darix: yeah now you need to prefix things with xmlns: and be done
[14:19:12] blood: so with namespaces it would be //xmlns:cookie-name and //xmlns:filter[filter-name='psfilter'] ? I leave out the root?
[14:19:24] chouhoulis: has joined #ruby
[14:19:38] darix: you might need //xmlns:filter[xmlns:filter-name='psfilter']
[14:19:46] darix: otherwise yes
[14:19:51] darix: blood: hint. binding.pry
[14:19:54] darix: and play around with it :P
[14:19:56] blood: so i always leave out parents?
[14:20:03] darix: blood: you can. but it doesnt matter
[14:20:05] darix: you can also do
[14:20:14] imhajes: has left #ruby: ()
[14:20:20] darix: /xmlns:weblogic-web-app/xmlns:session-descriptor/xmlns:cookie-name
[14:20:33] darix: blood: binding.pry :P
[14:20:53] blood: Problem is, im working on a puppet module for this and handling namespaces is annoying
[14:21:01] blood: I think I may just go back to REXML
[14:21:12] kapil___: has joined #ruby
[14:21:19] blood: requiring namespace when only the root has it is ridiculous
[14:22:29] blood: no idea what binding.pry is, I've literally only worked on ruby for a few days. I'm a java dev =)
[14:23:03] bmurt: has joined #ruby
[14:23:06] Cthulu201: has joined #ruby
[14:25:02] darix: blood: https://gist.github.com/darix/7b6422a4334937fcd6e0cc193d9721f8
[14:25:52] blood: Nokogiri doesn't like this
[14:25:54] blood: Error: /Stage[main]/Main/Xml_fragment[remove_psfilter]: Could not evaluate: ERROR: Invalid expression: //xmlns:[filter-name='psfilter']
[14:26:04] blood: that is wrong
[14:28:35] ByronJohnson: has joined #ruby
[14:29:08] blood: darix: https://github.com/bloodmc/xml_fragment/blob/master/lib/puppet/util/xml_file.rb#L14
[14:29:29] blood: however I'm now getting rid of remove_namespace call as it breaks things
[14:36:31] Inline: has joined #ruby
[14:46:57] mroutis: has joined #ruby
[14:48:19] akaiiro: has joined #ruby
[14:54:53] mojtaba: has joined #ruby
[14:57:58] bijan_: has joined #ruby
[14:58:15] snuz: has joined #ruby
[15:02:53] blood: darix: solved issues by switching to css instead of xpath
[15:03:15] blood: well not all =)
[15:04:33] blood: filter[filter-name='psfilter'] Can I do something similar with css?
[15:06:18] s2013: has joined #ruby
[15:06:46] aufi: has joined #ruby
[15:17:23] r29v: has joined #ruby
[15:20:31] memo1: has joined #ruby
[15:20:33] Eiam: has joined #ruby
[15:22:12] dellavg: has joined #ruby
[15:23:56] za1b1tsu: has joined #ruby
[15:26:11] sameerynho: has joined #ruby
[15:28:54] fmcgeough: has joined #ruby
[15:31:31] [Butch]: has joined #ruby
[15:34:07] Zaab1t: has joined #ruby
[15:34:15] Mike11: has joined #ruby
[15:38:20] drale2k_: has joined #ruby
[15:38:44] vondruch: has joined #ruby
[15:43:54] tolerablyjake: has joined #ruby
[15:44:43] polishdub: has joined #ruby
[15:56:46] dminuoso: has joined #ruby
[15:56:54] dminuoso: Is there a way to have bundler only build a specific dependency from a Gemfile?
[15:57:36] dminuoso: In particular I want to use build the dependencies in multiple docker layers as to not screw myself too much when I decide to add a dependency.
[15:59:05] cagomez: has joined #ruby
[15:59:47] sonOfRa: has joined #ruby
[16:02:02] bmurt: has joined #ruby
[16:04:06] wildermind: has joined #ruby
[16:06:22] beeman: has joined #ruby
[16:08:49] jcarl43: has joined #ruby
[16:15:47] bijan_: has joined #ruby
[16:22:47] lxsameer: has joined #ruby
[16:23:30] havenwood: dminuoso: I can't think of a nicer way than giving the gem a group and using the --with=GROUP flag.
[16:24:53] dminuoso: havenwood: I suppose I could at least toss the native extensions into a group..
[16:24:53] dminuoso: That would rid me of most the pain.
[16:27:09] gr33n7007h: has joined #ruby
[16:31:09] cats: has joined #ruby
[16:32:39] lxsameer: has joined #ruby
[16:42:49] lxsameer: has joined #ruby
[16:52:38] lxsameer: has joined #ruby
[16:52:55] orbyt_: has joined #ruby
[16:54:36] mroutis: has joined #ruby
[16:56:42] bijan_: has joined #ruby
[17:00:42] dminuoso: invalid gem: package is corrupt, exception while verifying: undefined method `size' for nil:NilClass (NoMethodError) in /usr/local/bundle/cache/ruby-oci8-2.2.5.1.gem
[17:00:44] dminuoso: ACTION kicks back
[17:00:46] dminuoso: ACTION breathes
[17:02:50] lxsameer: has joined #ruby
[17:06:04] eckhardt_: has joined #ruby
[17:07:36] havenwood: dminuoso: Does nuking the cache from orbit improve the outlook?
[17:08:24] dminuoso: havenwood: Better yet, running it *again*
[17:08:32] dminuoso: So now I have a non-determistic bug fucking with my docker container.
[17:08:41] dminuoso: ACTION sighs
[17:08:57] dminuoso: Probably should valgrind bundler.
[17:09:01] dminuoso: Who knows what goes on there.
[17:10:07] bijan_: has joined #ruby
[17:12:36] lxsameer: has joined #ruby
[17:13:49] bonhoeffer: has joined #ruby
[17:14:44] bonhoeffer: i’m still wondering the ideal ruby design pattern when an object is repeatedly called: want something like “with @myobject { .start .next_thing .stop}
[17:14:44] bonhoeffer: something like that
[17:15:40] apeiros: some_foo.tap { |x| x.start; x.thing; x.whatever }
[17:16:26] apeiros: though personally I'll just do `@myobject.start; @myobject.thing; @myobject.whatever`. IMO easier to read.
[17:22:14] bonhoeffer_: has joined #ruby
[17:22:32] lxsameer: has joined #ruby
[17:22:45] bonhoeffer_: apeiros: thanks for the feedback
[17:23:09] apeiros: oh, right, there's of course also .instance_eval
[17:23:13] havenwood: bonhoeffer: There's a proc composition proposal for 2.6 that'd let you do: https://gist.github.com/havenwood/612d910cb8d7c3b5caf9ffaa16f3427f
[17:23:21] apeiros: @myobject.instance_eval do start; thing; whatever; end
[17:24:22] havenwood: bonhoeffer_: This bit implements Proc#>> for Ruby 2.5 and earlier: https://gist.github.com/havenwood/612d910cb8d7c3b5caf9ffaa16f3427f#file-proc_composition-rb-L1-L5
[17:25:08] havenwood: bonhoeffer_: (I'd also just do it in three lines though.)
[17:26:23] doubledup: has joined #ruby
[17:27:38] za1b1tsu: has joined #ruby
[17:27:42] bijan_: has joined #ruby
[17:27:52] SeepingN: has joined #ruby
[17:30:31] herbmillerjr: has joined #ruby
[17:32:31] lxsameer: has joined #ruby
[17:34:46] dviola: has joined #ruby
[17:36:00] bijan_: has joined #ruby
[17:36:45] havenwood: Oh, I take it back. You want to apply the method to the receiver, not method return value. Nevermind me!
[17:42:37] lxsameer: has joined #ruby
[17:44:16] bijan_: has joined #ruby
[17:45:09] mikecmpbll: has joined #ruby
[17:48:50] bijan__: has joined #ruby
[17:48:51] graphene: has joined #ruby
[17:52:43] lxsameer: has joined #ruby
[17:53:29] bijan_: has joined #ruby
[17:58:57] bonhoeffer_: has joined #ruby
[17:59:36] cadillac_: has joined #ruby
[18:02:45] lxsameer: has joined #ruby
[18:05:44] bijan_: has joined #ruby
[18:10:41] bijan_: has joined #ruby
[18:12:41] lxsameer: has joined #ruby
[18:12:59] lytol_: has joined #ruby
[18:13:12] bonhoeffer: how do i require a whole folder?
[18:13:35] bonhoeffer: Dir["/path/to/directory/*.rb"].each {|file| require file }
[18:17:20] alex``: has joined #ruby
[18:18:50] bijan_: has joined #ruby
[18:19:48] drale2k_: has joined #ruby
[18:22:40] lxsameer: has joined #ruby
[18:23:34] agent_white: has joined #ruby
[18:28:37] SeepingN: does that not work?
[18:29:30] apeiros: bonhoeffer: use glob instead of [], it takes a block directly
[18:29:45] SeepingN: back in the day I had a pack of gems to load but we had... issues... so I had something htat basically did that same thing
[18:29:46] havenwood: bonhoeffer: Dir.glob '/path/*.rb', &method(:require)
[18:30:15] apeiros: also, as of 2.4 I think, you can provide a `base: "some/dir"` which is stripped from the yielded value. useful for requires as they should be relative to a path in $LOAD_PATH (aka $:)
[18:30:22] havenwood: apeiros: Indeed!!
[18:30:57] havenwood: bonhoeffer: Dir.glob '*.rb', base: '/path', &method(:require)
[18:31:30] apeiros: I have *so* *fucking* *many* Dir.glob loops where I do: `base = "some path"; Dir.glob(base+"/whatever/*") do |path| rel = path[base.size..-1]; …` (or similar, might be off by one :D)
[18:31:55] bijan_: has joined #ruby
[18:32:41] lxsameer: has joined #ruby
[18:35:34] drale2k_: has joined #ruby
[18:36:11] bijan__: has joined #ruby
[18:42:45] lxsameer: has joined #ruby
[18:43:47] graphene: has joined #ruby
[18:49:00] bijan_: has joined #ruby
[18:51:13] ruby[bot]: has joined #ruby
[18:51:13] ChanServ: +o ruby[bot]
[18:52:35] lxsameer: has joined #ruby
[18:54:51] dionysus69: has joined #ruby
[18:58:28] bonhoeffer: has joined #ruby
[18:59:54] KevinSjoberg: has joined #ruby
[19:01:05] drale2k_: has joined #ruby
[19:06:10] bonhoeffer: has joined #ruby
[19:07:18] bijan_: has joined #ruby
[19:11:15] gizmore: has joined #ruby
[19:11:38] gizmore: typo... good evening :)
[19:12:40] apeiros: php instead of ruby is quite the typo ;-p
[19:12:42] jhass: has joined #ruby
[19:12:53] gizmore: apeiros: i wanted to join php channel too
[19:12:58] gizmore: but confused syntax
[19:13:12] gizmore: i like php and ruby and c++ and js and java
[19:13:18] gizmore: and ObjectiveC
[19:14:02] gizmore: currently doing some php for a friend and at work
[19:14:48] gizmore: but ruby is so much more elegant you know
[19:15:00] gizmore: and the people here are more sane
[19:15:09] apeiros: dunno, php is very high on my list of languages I expressly do not want to work with
[19:15:22] apeiros: atm I think the only one higher up as a language is plsql
[19:16:01] gizmore: php is not that bad... the performance of mod_php is quite nice on apache imho
[19:16:10] gizmore: and it has primitive type hinting \o/
[19:16:17] apeiros: oh, if performance was an issue, I'd not use ruby either :D
[19:16:27] gizmore: i want to make a new game with ruby maybe
[19:16:41] bijan_: has joined #ruby
[19:16:58] gizmore: or learn python and make it with a friend.... or restart in C++.... or patch my PHP framework a lot.... or continue my ruby framework
[19:17:13] Zarthus: modern php is pleasant to work with, it's the people that are ass.
[19:17:16] gizmore: either way.... i wanna code "GDO - Gizmore Data Objects"
[19:17:32] Zarthus: ..Is that a copy of PDO?
[19:17:34] gizmore: yeah... php got quite good over the years.... there are still ugly quirks, but you know them
[19:17:43] gizmore: no... i didnt know of PDO when i did v1
[19:18:19] gizmore: GDO6(PHP) is way more sane and slim .... GDO6(Ruby) is also started, but currently on ice
[19:18:25] gizmore: GDO6(Ruby) is test driven
[19:18:27] bonhoeffer_: has joined #ruby
[19:18:48] gizmore: https://github.com/gizmore/gdo6
[19:18:53] mojtaba: has joined #ruby
[19:18:58] gizmore: ah this is php maybe -.-
[19:19:12] gizmore: https://github.com/gizmore/GDO (ruby port)
[19:19:48] gizmore: https://github.com/gizmore/gdo/blob/master/spec/gdo_spec.rb
[19:20:29] graphene: has joined #ruby
[19:21:35] snuz: has joined #ruby
[19:31:57] Freshnuts: has joined #ruby
[19:32:50] alex``: has joined #ruby
[19:37:21] Zaab1t1: has joined #ruby
[19:42:15] bijan_: has joined #ruby
[19:48:03] LiftLeft: has joined #ruby
[19:48:08] drale2k_: has joined #ruby
[20:02:06] s2013: has joined #ruby
[20:03:36] s2013: has joined #ruby
[20:07:06] tolerablyjake: has joined #ruby
[20:09:38] jottr: has joined #ruby
[20:37:21] s2013: has joined #ruby
[20:38:56] orbyt_: has joined #ruby
[20:43:30] bmurt: has joined #ruby
[20:46:04] t0xik: has joined #ruby
[20:46:49] alex``: has joined #ruby
[20:49:08] bsamorim: has joined #ruby
[20:49:47] bsamorim: Hi, folks! I'm having a tough time understanding YARV's garbage collection dynamics
[20:50:16] havenwood: bsamorim: Say more about what part you're trying to understand?
[20:50:16] nowhere_man: has joined #ruby
[20:51:07] bsamorim: If I start up a irb session and fire up a method that takes ~1 min to complete and consumes ~4.5% of my memory, at the end of it, the memory consumption from the method persists
[20:51:36] havenwood: bsamorim: Does it go down if you manually run?: GC.start
[20:51:58] bsamorim: havenwood: I tried that, but it didn't have any effect
[20:52:15] havenwood: bsamorim: Is there no garbage to collect?
[20:52:18] bsamorim: If I fire up the method once again, the memory eventually goes down, and then back up again
[20:52:52] havenwood: bsamorim: Show your `GC.stat` before and after?
[20:53:03] bsamorim: havenwood: k, wait a minute
[20:53:23] bsamorim: before and after the first method invocation, or the second?
[20:54:18] bsamorim: k, just a sec
[20:54:30] havenwood: bsamorim: If it's shareable, code to reproduce might help someone spot the issue as well.
[20:55:11] zenspider: why are you assuming this has to do with GC?
[20:55:25] bsamorim: havenwood: sure, I'll share
[20:55:33] zenspider: can we back up? what have you done to investigate why a single method takes a minute?
[20:55:47] zenspider: memory might have nothing to do with this. memory "persisting" is normal for a lot of code
[20:55:59] bsamorim: zenspider: because the code is really just performing a 'rest-client' request
[20:56:10] lxsameer: has joined #ruby
[20:56:14] zenspider: so? what have you done to isolate this to memory?
[20:56:31] zenspider: rest-client is networking. that has lots of external dependencies that might time out
[20:56:37] zenspider: does 1 + 1 take a minute?
[20:56:59] zenspider: is it JUST irb?
[20:57:10] havenwood: RestClient and HTTParty can also take a huge amount of memory compared to other HTTP clients in Ruby.
[20:57:16] bsamorim: zenspider: You're absolutely right - I haven't done a thorough investigation. I just assumed that ruby's most popular http client wouldn't have such weird memory cost
[20:57:17] zenspider: (like, try `ruby -rwhatever-you-need -e 'some code'`
[20:57:33] zenspider: "most popular"
[20:57:42] havenwood: bsamorim: RestClient isn't as solid as you imagine.
[20:57:53] havenwood: bsamorim: Note the memory use part of this article: https://twin.github.io/httprb-is-great/
[20:58:24] havenwood: direct link: https://twin.github.io/httprb-is-great#memory-usage
[20:58:27] bsamorim: havenwood: there's the pastebin https://dpaste.de/8cPU
[20:58:42] bsamorim: I'll paste the method definition as well
[20:58:43] s2013: has joined #ruby
[20:58:45] havenwood: bsamorim: I personally avoid RestClient and HTTParty.
[20:59:02] havenwood: bsamorim: I'd prefer Net::HTTP, Typhoeus, HTTP.rb, etc.
[20:59:39] bsamorim: havenwood: wish I met you 2000 lines of code ago :(
[20:59:43] havenwood: bsamorim: Here's a spreadsheet comparing Ruby HTTP client features, fwiw: https://docs.google.com/spreadsheets/d/1vPlk6nMIFa3sI5ISl7zZ5r6lDNpVQX6Jxi3ksXCyVbs/edit
[20:59:54] havenwood: I should add upload and download base memory usage.
[20:59:58] havenwood: ACTION makes a note.
[21:00:27] zenspider: gah. look at the timings here https://github.com/httprb/http
[21:00:31] bsamorim: havenwood: so this most likely has nothing to do with GC? haha thank god!
[21:00:33] zenspider: that's horrific for restclient
[21:00:44] havenwood: zenspider: srsly
[21:01:08] zenspider: I don't understand this line tho "using native parsers and a clean, lightweight implementation, http.rb achieves the best performance of any Ruby HTTP library which implements the HTTP protocol in Ruby instead of C:"
[21:01:27] zenspider: oh. n/m. I understand how I misread it.
[21:01:32] zenspider: I have to say... I hate the name of this gem.
[21:02:17] zenspider: I also highly suspect the methodology of this benchmark as being slightly bogus... but not when the numbers are an order of magnitude different
[21:02:33] zenspider: "DISCLAIMER: Most benchmarks you find in READMEs are crap, including this one. These are out-of-date. If you care about performance, benchmark for yourself for your own use cases!" hah! fair
[21:02:38] bsamorim: havenwood, zenspider: thank you guys very much for the help!
[21:05:03] zenspider: yup yup. no prob. good luck
[21:08:29] LiftLeft: has joined #ruby
[21:09:52] jdsampayo: has joined #ruby
[21:10:40] r29v: has joined #ruby
[21:12:06] jdsampayo: Hello, how can I pack an Array of bytes (from Java) like the BigInteger Java constructor, in Java with [-75, 78, 103, -51, 31, -56, 80, -22] you can get the BigInteger 13064493699747565802. In Ruby, I have tested all the pack (c, v, l, i, C, c*, cccc, etc) without any success
[21:12:27] jim80net: has joined #ruby
[21:13:44] zenspider: packing an array gives you a binary string. IS that what you want? or do you want the bigint?
[21:15:02] jdsampayo: Maybe my question was bad, I would want to create the BigInteger from the array, like in Java: BigInteger big = new BigInteger(1, new byte[]{ -75,78,103,-51,31,-56,80,-22 });
[21:19:16] jottr: has joined #ruby
[21:22:02] zenspider: holy shit. I figured it out.
[21:22:04] zenspider: >> a = [-75, 78, 103, -51, 31, -56, 80, -22]; a.pack("C*").unpack("Q>*")
[21:22:10] ruby[bot]: zenspider: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `[]' for nil:NilClass
[21:22:20] zenspider: what?!? screw you bot
[21:22:31] zenspider: => [13064493699747565802]
[21:22:59] zenspider: last * is not needed either
[21:23:28] jdsampayo: hahaha the bot
[21:23:29] zenspider: translation: big endian unsigned long long
[21:23:32] apeiros: BigInteger in Java is a 64bit int?
[21:23:47] apeiros: or arbitrarily large like ruby's Bignum (now just Integer)?
[21:23:58] jdsampayo: Java sources has this description: "The magnitude is a byte array in <i>big-endian</i> byte-order: the most significant byte is in the zeroth element."
[21:24:01] zenspider: iirc it's arbitrary... it happens to fit in this case
[21:24:20] apeiros: zenspider: btw., this error still means that eval.in failed, tho. but the message is crap.
[21:24:56] apeiros: Q is only long long (64bit)
[21:25:10] zenspider: I don't think this code will work with all input... but I don't think there IS a way to make it work with all input. bigint is not explicitly supported since it is internal to ruby
[21:25:19] apeiros: I think if you want to convert arbitrarily large, you have to roll your own. not too difficult, though.
[21:25:22] zenspider: unsigned long long
[21:25:52] jdsampayo: guess I can use .unpack1("Q>") for this purpose to avoid the Array
[21:25:54] zenspider: yeah. I think if you did "Q>*" you can then math them up with a fold
[21:26:02] apeiros: >> [-75, 78, 103, -51, 31, -56, 80, -22].reverse.map.with_index { |v,i| (v < 0 ? v+256 : v)*(2**(8*i)) }.sum
[21:26:05] jdsampayo: Thanks zenspider, I was struggling for hours
[21:26:08] ruby[bot]: apeiros: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `[]' for nil:NilClass
[21:26:11] snickers: has joined #ruby
[21:26:30] zenspider: bot... I will murder you
[21:26:41] apeiros: ...eval.in. not the bot.
[21:28:01] zenspider: whatever happened to _why's sandbox code? IIRC it was too messy to make it back into ruby
[21:28:49] apeiros: yeah, I'd still love to have an embeddable secure ruby interpreter
[21:29:14] apeiros: secure as in: you can limit what it has access to
[21:29:22] zenspider: >> a = [-75, 78, 103, -51, 31, -56, 80, -22]; a.pack("C*").unpack("N*").inject { |n,m| (n << 32) + m }
[21:29:23] ruby[bot]: zenspider: # => 13064493699747565802 (https://eval.in/1047906)
[21:29:26] cthulchu: how do we autofix the formatting in vscode?
[21:29:32] zenspider: WHY DID THAT WORK?!?
[21:29:42] zenspider: anyhow. there's a portable way to do bigint
[21:30:49] zenspider: Sandbox.disable :disk, :network # would be nice
[21:34:48] sspreitz: has joined #ruby
[21:36:22] za1b1tsu: has joined #ruby
[21:38:18] jdsampayo: has joined #ruby
[21:39:04] jdsampayo: omg you guys found three solutions in some seconds, still a long path for me to walk...
[21:53:49] jottr: has joined #ruby
[21:54:51] kaleido: has joined #ruby
[21:57:34] mojtaba: has joined #ruby
[22:01:02] exchgr`: has joined #ruby
[22:06:15] mojtaba: has left #ruby: ()
[22:07:24] alex``: has joined #ruby
[22:11:44] jottr: has joined #ruby
[22:17:10] bmurt: has joined #ruby
[22:18:06] orbyt_: has joined #ruby
[22:36:55] tolerablyjake: has joined #ruby
[22:46:36] ellcs: has joined #ruby
[22:48:05] zenspider: is there some way to build / install graphviz on OSX that doesn't segfault like mad??
[22:48:18] zenspider: seems data dependent for sure... but totally innocuous stuff
[22:50:07] SeepingN: or macports
[22:50:16] SeepingN: according to their own page
[22:50:22] SeepingN: https://graphviz.gitlab.io/download/
[22:56:12] sanscoeur: has joined #ruby
[22:56:50] lxsameer: has joined #ruby
[22:59:37] baweaver: Heyo, opened an issue on the Ruby style guide: https://github.com/rubocop-hq/ruby-style-guide/pull/725
[22:59:41] baweaver: Could use some eyes
[23:02:50] zenspider: SeepingN: that addresses how to install. it doesn't address segfaults at all. the homebrew build is pretty terrible
[23:07:44] zenspider: it's disheartening that graphviz has ~1000 issues open
[23:07:53] Radar: patches welcome
[23:07:56] Radar: ACTION ducks
[23:08:23] zenspider: it's such bitrot. and my favorite competitor to it, which had much better (but slower) layout was killed off by graphviz popularity
[23:09:04] zenspider: I have a LOT of scripts that generate graphs tho... this sucks
[23:09:27] Radar: Time to write your own?
[23:10:23] duderonomy: has joined #ruby
[23:14:06] tty: has joined #ruby
[23:16:54] yorickpeterse: has joined #ruby
[23:19:28] zenspider: fuck that. no.
[23:19:44] zenspider: HELL no. I don't have a PhD in this shit.
[23:21:39] dviola: gnuplot? :P
[23:22:48] zenspider: doesn't even remotely do the same thing. I have some old code for that too somewhere...
[23:22:56] al2o3-cr: how about gruff?
[23:23:22] dviola: oh, I see
[23:23:29] sonOfRa: has joined #ruby
[23:26:10] zenspider: hrm. I don't know gruff. url?
[23:26:43] al2o3-cr: https://github.com/topfunky/gruff
[23:26:47] dviola: sorry, I don't know what you're doing with graphviz
[23:27:52] zenspider: wait. you mean ... yeah. no. that's also doing charting, not graphing.
[23:28:27] zenspider: I'm really surprised to see it has semi-recent commits. that thing is ancient. very early seattle.rb days
[23:29:41] al2o3-cr: yeah, was about to say it's probably not what you need.
[23:30:14] zenspider: ugh. everything either conflates graphs with charts or is java or D3
[23:30:24] graphene: has joined #ruby
[23:50:35] orbyt_: has joined #ruby