Activity Graph

Page 1 of 7 | Next »


[06:05:51] riceandbeans: Quit: leaving


[22:49:55] riceandbeans: has joined #ruby
[22:51:12] riceandbeans: What's the correct way to do this, I'm spacing, foo = ['one','two','three'] foo.each do | bar | baz = `biff -f #{bar}` end
[22:57:10] riceandbeans: ugh, "#{bar}"
[22:57:19] riceandbeans: Couldn't focus with kids screaming in my ears
[23:04:20] riceandbeans: baweaver: Sorry, I'm just....going nuts from kids right now, but I'll try to explain
[23:04:47] riceandbeans: I have a series of hosts, I need to iterate through them to find a subset that meet a certain condition that is determined by output of a shell command
[23:05:19] riceandbeans: From those hosts I then need to do a mapping of one column to another column across the various hosts
[23:06:31] riceandbeans: Well the part here was that I needed to get info per host and so I was iterating on hosts and shoving them into the shell command


[18:34:06] riceandbeans: Quit: leaving


[16:49:54] riceandbeans: *.net *.split


[02:01:29] riceandbeans: has joined #ruby
[02:01:29] riceandbeans: Changing host


[22:01:17] riceandbeans: Ping timeout: 255 seconds


[23:16:11] riceandbeans: has joined #ruby
[23:17:13] riceandbeans: What's the net/http version of curl -s -i -H "Accept: application/json" example.com/routehere
[23:20:07] riceandbeans: https://bin.disroot.org/?7f3da819d3bcf444#p+znpiw8LgyE+45QBj/TStSDf+wSq2FBNuXqJqgH4D8=


[15:20:25] riceandbeans: Ping timeout: 246 seconds


[02:11:04] riceandbeans: has joined #ruby
[02:11:11] riceandbeans: Hey, stupid question, forgive me
[02:11:23] riceandbeans: I'm trying to port a gem that works on other OSes to make sure it works on my OS
[02:11:44] riceandbeans: I cloned the git repo and I'm doing work with it, but I want to make the code using the gem default to my git repo to validate it's actually working as intended
[02:12:01] riceandbeans: It's a component sucked into Rails so I just want the ONE gem to be subbed out
[02:12:09] riceandbeans: What's the best way to go about doing that


[08:11:17] riceandbeans: Quit: leaving


[07:01:20] riceandbeans: http://dpaste.com/1JSNGMD I'm out of ideas, how would you reduce the ABC of that method?
[07:04:33] riceandbeans: baweaver: assignment branch conditional
[07:04:49] riceandbeans: there's some math problem that says I'm stupid for making that method too complicated
[07:05:16] riceandbeans: I've reduced it from like 50/15 from the previous iteration to 24.1/15
[07:05:20] riceandbeans: So, I think I'm doing ok
[07:05:26] riceandbeans: Still the goal is <= 15
[07:05:44] riceandbeans: It's for a Puppet module
[07:06:04] riceandbeans: Similarities?
[07:06:44] riceandbeans: https://github.com/meltwater/puppet-cpan/blob/554d408927febf080eafeeb616337776a48e6c14/lib/puppet/provider/cpan/default.rb#L28
[07:06:49] riceandbeans: That's the starting point
[07:08:14] riceandbeans: shit you're right I have an idea hold on
[07:17:29] riceandbeans: baweaver: http://dpaste.com/1RD8XJV
[07:17:40] riceandbeans: baweaver: down to 18/15
[07:17:58] riceandbeans: I change force to this
[07:18:11] riceandbeans: @force = resource.force? ? 'CPAN::force' : ''
[07:18:34] riceandbeans: Because nothing says this module has made me lose sleep and want to smash things like a ternary operator
[07:24:56] riceandbeans: it lowered the score though
[07:44:02] riceandbeans: baweaver_away: http://dpaste.com/223H262
[07:47:44] riceandbeans: andi: don't do that
[07:47:57] riceandbeans: andi: you're going to end up with a monstrous maniest
[07:48:31] riceandbeans: andi: I worked at a place that did that for nagios setups, the puppet runs took 20+ minutes
[07:52:23] riceandbeans: Well, we had like 30,000 entries build into this massive manifest


[10:28:14] riceandbeans: has joined #ruby
[10:28:38] riceandbeans: When using rubocop, how would you tackle ABC complaints?


[19:09:53] riceandbeans: has joined #ruby
[19:10:16] riceandbeans: other than being less likely to accidential interpolation, is there a performance benefit at all to using '' instead of ""?
[19:12:16] riceandbeans: I'll be damned.....https://stackoverflow.com/questions/1836467/is-there-a-performance-gain-in-using-single-quotes-vs-double-quotes-in-ruby
[19:12:26] riceandbeans: double quotes are actually marginally faster than single quote
[19:12:55] riceandbeans: I'm still going to use single when no interpolation needed, but I'm somehow surprised by the result


[22:30:44] riceandbeans: Ping timeout: 272 seconds


[02:38:39] riceandbeans: Ping timeout: 265 seconds
[02:52:10] riceandbeans: has joined #ruby


[03:56:55] riceandbeans: has joined #ruby
[03:56:55] riceandbeans: Changing host


[08:12:57] riceandbeans: Ping timeout: 240 seconds


[16:57:02] riceandbeans: What do you guys think of the design of this?
[16:57:03] riceandbeans: https://github.com/motdotla/digitalocean/blob/master/lib/digitalocean.rb
[16:57:41] riceandbeans: I look at it and hate the single file aspect and feel like I'd rather it broken into a file for each major section of the API, but also I want to do something similar but make it more generic
[16:58:14] riceandbeans: I want to make something supporting multiple backends, but maybe single file for each of the entire backends is better, :\ I don't know
[17:03:15] riceandbeans: dminuoso: and please don't take this as me shitting on someone else's code, because I know my code will look like shit to plenty of people, but I wanted a nice example to base something on, and I saw that and didn't like it
[17:03:30] riceandbeans: some kind of horrifying inheritance?
[17:04:13] riceandbeans: No, this is someone else's
[17:05:32] riceandbeans: I had this one gem to do something, it did like 75% of what I wanted, but the missing part irked me, and they stopped supporting it, so I was going to do my own thing with it, but I figured I'd make it generic and support various providers, and then I looked around for other rest clients in ruby that I'd used, so I looked at vultr because the gem works fine for my use and I looked at the code and it
[17:05:38] riceandbeans: was exactly like the above
[17:06:09] riceandbeans: I kind of wanted to probe the water and see if it was just me disliking the style used or if it was generally frowned upon, because I'd rather do best practice
[17:06:26] riceandbeans: so, the one I thought looked a little better to model on is this
[17:06:54] riceandbeans: https://github.com/coinbase/coinbase-ruby/blob/master/lib/coinbase/wallet/client.rb
[17:07:43] riceandbeans: I don't know that inheriting NetHTTPClient is really necessary, but it basically has no external dependencies and mostly works
[17:11:26] riceandbeans: dminuoso: what do you think of that one in comparison for style?
[19:01:55] riceandbeans: dminuoso: did you see the last code link I put up?
[19:12:57] riceandbeans: ruby on windows is weird, I used it before to muck with the registry


[11:03:19] riceandbeans: Changing host
[11:03:19] riceandbeans: has joined #ruby
[11:03:20] riceandbeans: has joined #ruby


[01:05:20] riceandbeans: Ping timeout: 240 seconds
[01:05:43] riceandbeans: has joined #ruby
[16:17:12] riceandbeans: Ping timeout: 255 seconds


[08:45:07] riceandbeans: has left #ruby: ()
[09:00:38] riceandbeans: has joined #ruby
[09:00:49] riceandbeans: how would you go about finding a memory leak in a ruby script?
[09:01:46] riceandbeans: I'm using mechanize, pg, and not much else and the memory use has gone from 5MB to 175MB and it's still going
[10:30:39] riceandbeans: zenspider: looping thousands of times, parsing data with mechanize, some database interactions, repeat
[10:31:20] riceandbeans: zenspider: but you're probably right, it's down to 150Mb
[10:47:21] riceandbeans: I am on a tiny VPS lol


[23:18:40] riceandbeans: has joined #ruby
[23:19:49] riceandbeans: I have a variable foo that has a string value, I then have a later line that says foo ||= "bar#{count}" for times when the regex didn't work and I'm going to adjust the regex later but I want to get most of it out of the way, but the ||= with puts statements shows that it overrides the value every single time, what would cause that?
[23:30:30] riceandbeans: apeiros: I have puts statements, I'm using mechanize but some things fail, so I have at the end a placeholder using ||= but it's auto assigning it every time
[23:34:32] riceandbeans: what's the difference?
[23:37:39] riceandbeans: apeiros: one sec
[23:40:02] riceandbeans: about to gist
[23:41:50] riceandbeans: https://gist.github.com/strangelittlemonkey/b0d46bd1fa1ba47692c177c98fa7c276
[23:43:03] riceandbeans: ignore that, that's not even being executed
[23:43:50] riceandbeans: god damn it, forgot a =
[23:44:37] riceandbeans: I hate when I botch one character while tired and screw everything up
[23:46:03] riceandbeans: :P yeah, thanks, s/=/== and like magic it actually works as it's supposed to
[23:54:30] riceandbeans: market: https://ruby-doc.org/core-2.2.0/Array.html#method-i-uniq


[01:46:45] riceandbeans: Remote host closed the connection


[19:30:29] riceandbeans: Ping timeout: 264 seconds
[19:31:32] riceandbeans: has joined #ruby


[02:52:28] riceandbeans: what do you guys think of rubocop?
[04:25:57] riceandbeans: shevy: can I get your opinion on a rubocop recommended correction on some code?
[04:28:21] riceandbeans: shevy: https://github.com/cburnette/boxr/blob/master/lib/boxr/folders.rb#L144
[04:28:39] riceandbeans: shevy: rubocop says result is useless and should be show as such be being prepended with _
[05:34:26] riceandbeans: shevy: sorry I misread, response is useless
[05:51:53] riceandbeans: shevy: also, missing top level documentation?
[05:52:00] riceandbeans: what's that mean?
[05:58:15] riceandbeans: like line one should be # This class will rescue kittens
[05:59:57] riceandbeans: shevy: http://pastebin.com/E010dKLj
[06:00:06] riceandbeans: should I remove the references to self?
[06:00:16] riceandbeans: whatever ruby[bot]
[06:01:04] riceandbeans: I mean, s/self.//g
[06:12:44] riceandbeans: what are you talking about?
[06:16:54] riceandbeans: what the hell does the skin color have to do with code?
[06:17:11] riceandbeans: code is fucking code
[06:43:04] riceandbeans: gogo_: do you have a think against databases?
[06:54:31] riceandbeans: is there a .to_s!
[06:54:41] riceandbeans: or do you have to say, foo = foo.to_s
[06:55:00] riceandbeans: it feels like there has to be a less ugly way of saying that
[06:56:33] riceandbeans: is there a less ugly way to do that?
[16:18:34] riceandbeans: if you do foo = get(uri) instead of foo, response = get(uri) what would happen?
[16:32:59] riceandbeans: so it is sort of necessary to use it in order to keep unwanted data out of another variable
[17:19:54] riceandbeans: shevy: if you only want to keep the first element of the array is it cleaner to do arr1, arr2 = whatever, or to do arr1 = whatever and then chop off everything but the first element?
[20:04:49] riceandbeans: shevy: you got a sec?
[20:12:37] riceandbeans: https://gist.github.com/strangelittlemonkey/1bc72bd86f7ad0b3ccd770b8f72bb8f0
[20:12:42] riceandbeans: what is a better way to solve that
[20:16:05] riceandbeans: well, the complaint was that in this manner, for larger arrays it would have to scan the last array every time and be increasingly slow
[20:22:34] riceandbeans: shevy: I see it as a valid complaint, but don't know how to address it
[20:23:40] riceandbeans: I mean, if it was guaranteed to be numeric, and if you did a binary search in the array each push to insert in numerical order I guess maybe it would be faster for larger arrays?
[20:41:33] riceandbeans: jhass: al2o3-cr can you explain to me the idea in general for what you would do?
[20:44:08] riceandbeans: so it's just a data type that doesn't allow duplicates
[20:44:46] riceandbeans: what if you didn't have a data type that magically allowed that though?
[20:45:24] riceandbeans: well, doesn't it have to perform the same underlying scan on the array?


[19:59:31] riceandbeans: has joined #ruby
[19:59:41] riceandbeans: is it perfectly plausible to have an array of a new struct type?
[20:00:11] riceandbeans: I mean, foo = Struct.new ( .... )
[20:00:26] riceandbeans: bar = foo.new
[20:00:58] riceandbeans: baz.push(bar)
[21:12:18] riceandbeans: jhass: let's say i wanted to do something like this
[21:12:50] riceandbeans: User = Struct.new(:username,:password,:homedir,:shell)
[21:13:12] riceandbeans: file = '/etc/passwd'
[21:13:23] riceandbeans: File.open(file) do |line|
[21:13:54] riceandbeans: I don't know, some magic in there, with foo = User.new
[21:14:10] riceandbeans: and having an array like users and doing users.push(foo)
[21:14:22] riceandbeans: and then consuming users somewhere else
[21:17:05] riceandbeans: jhass: what if it wasn't just a few users though, what if it was say....8000
[21:18:06] riceandbeans: right, but making an array of new classes like that, would that eat ram and be useless?


[19:20:25] riceandbeans: Quit: leaving


[11:06:25] riceandbeans: Ping timeout: 260 seconds
[11:10:19] riceandbeans: has joined #ruby


[08:50:42] riceandbeans: if you do require_relative 'dir/file' do you have to specify .rb or is it implied?
[19:25:38] riceandbeans: two things, one how similar is the ruby pty to perl expect, and two will ruby pty work on windows when invoking a windows binary through a shell out that make end up requiring powershell?
[19:30:46] riceandbeans: does ruby have expect?
[19:31:20] riceandbeans: basically, launch shell, send shell command, create regex for prompt that will be returned, on matching regex send new command, loop


[00:00:44] riceandbeans: like config_option = true, config_option.value = 'foo' ?
[00:02:34] riceandbeans: ok, I can accept that
[00:02:44] riceandbeans: nil vs non nil
[00:02:46] riceandbeans: simple enough
[00:03:13] riceandbeans: >> v = -1; v.nil?
[00:03:25] riceandbeans: >> v = 0; v.nil?
[00:03:39] riceandbeans: >> v = ''; v.nil?
[00:03:51] riceandbeans: ...ok...I think I'll be good then, just worried about edge cases
[00:05:08] riceandbeans: it doesn't help that it's for a giant config file so spotting an error is a needle in a hay stack
[00:05:14] riceandbeans: I need to get it right


[23:56:30] riceandbeans: what's a safe way to check if a variable exists?
[23:58:09] riceandbeans: no that ain't it
[23:58:22] riceandbeans: I think I want if defined?(foo)
[23:59:21] riceandbeans: well, basically I have an ERB file, I just want some chunks of template to exist if a variable is set, if the variable isn't set to anything I don't care and it doesn't need to go in the template


[21:37:26] riceandbeans: is rdoc the main/preferred auto documentation generator?
[21:42:46] riceandbeans: apeiros: which is better?
[21:43:21] riceandbeans: better being !apeiros.preference
[21:43:25] riceandbeans: just kidding-
[21:43:44] riceandbeans: better being more commonly accepted in the community, easier to use, more extensive in coverage
[21:48:42] riceandbeans: my friend learned ruby by memorizing the stdlib and core
[21:49:10] riceandbeans: he couldn't write much, but if I asked him if there was something related to x, y, or z he could rattle it off and I could use it
[21:49:52] riceandbeans: you have to use it and practice it to be good at it
[21:50:12] riceandbeans: also, you have to not do anything I ever talk about to be good at it


[20:11:16] riceandbeans: given json, what's the best way to report an error if any key has a nil/'' value
[20:12:09] riceandbeans: right now I'm having a method do foo.each do |x| return true unless x.nil? end
[20:13:04] riceandbeans: I'm half awake and realize it's wrong
[20:14:32] riceandbeans: it's parsed json but you can reference it like foo['bar']
[20:14:58] riceandbeans: I just need to make sure the value is something at the moment
[20:16:39] riceandbeans: I'm just trying to write a method to validate an API that's accepting json and returning json
[20:17:12] riceandbeans: no, an empty string is not something
[20:17:34] riceandbeans: ' ' would be something, it would fail, but it would be something
[20:21:02] riceandbeans: I'm not opposed to better ideas for checking
[20:22:15] riceandbeans: for instance, I want a json blob to be able to create a user by an API, but I have to check that the username doesn't already exist and create it, but if the username passed in is '' or nil, then it won't work
[20:52:02] riceandbeans: apeiros: when I do values instead of each I don't hit binding.pry statements in the block
[20:52:52] riceandbeans: apeiros: wait, is it supposed to be foo.values.each?
[20:53:41] riceandbeans: changing .values to .values.each returned the correct response...


[15:17:03] riceandbeans: Ping timeout: 244 seconds
[15:18:13] riceandbeans: has joined #ruby
[21:03:39] riceandbeans: anyone ever loaded IRB and done rand(12) in place of rolling 1d12?
[21:04:00] riceandbeans: I guess rand(1..12) would be more accurate
[21:06:03] riceandbeans: Ox0dea: I was using it for D&D
[21:06:41] riceandbeans: >> rand(1..12).3times
[21:21:58] riceandbeans: ericli: no, but it's called a predicate method
[21:22:05] riceandbeans: ericli: it usually means it returns a boolean
[21:22:25] riceandbeans: ericli: there is no hard requirement to though, but it's sylistic


[22:48:54] riceandbeans: what's the best way to do a negative include?
[22:49:19] riceandbeans: variable.include? 'stuff' but I want the inverse
[22:49:41] riceandbeans: if variable.include? 'stuff' false
[22:50:05] riceandbeans: I mean, I could do true unless variable.include? 'stuff'; true
[22:50:34] riceandbeans: return true unless variable.include? 'stuff'; false
[22:50:47] riceandbeans: but it feels like I can write that neater
[23:00:23] riceandbeans: havenwood: alas, this isn't rails
[23:00:29] riceandbeans: I don't get why my code isn't working
[23:01:12] riceandbeans: so I'm using mixlib::shellout and getting a string back that contains a blurb
[23:01:29] riceandbeans: it's either a bunch of lines or just one line that pretty much says you have no licenses
[23:02:03] riceandbeans: so............... return true unless foo.stdout.include? 'No licenses'; false
[23:02:29] riceandbeans: so what I typed, when it SHOULD be false, is returning true
[23:02:55] riceandbeans: but I think the ! may be the easy way out here...
[23:03:32] riceandbeans: but isn't return then redundant?


[01:23:00] riceandbeans: I'm not using sinatra like that at the moment
[01:23:07] riceandbeans: course I may be doing it wrongtoo
[01:23:17] riceandbeans: I'm using sinatra as a prototype for the moment
[01:23:33] riceandbeans: I'm ultimately doing my API in Rust with Iron


[23:25:26] riceandbeans: can you ensure data types in a struct?
[23:26:04] riceandbeans: like Foo = Struct.new( :bar, :baz ) where :bar is Fixnum and :baz is Bool ?
[23:30:46] riceandbeans: what's the best way to do it if you want correctness constraints?
[23:30:50] riceandbeans: a class instead of a struct?
[23:43:06] riceandbeans: shevy: actually, I'm not sure how to go about this
[23:43:43] riceandbeans: shevy: if I'm receiving json data, is it worth taking it and making a struct/class out of it, then referring to attr in them, or just parse the json and refer to it as keys of the json and leave it like that?
[23:51:14] riceandbeans: it's just dumb json being throw at an API


[01:56:39] riceandbeans: Read error: Connection reset by peer
[01:56:47] riceandbeans: has joined #ruby