#ruby - 21 May 2016
« Back 1 day Forward 1 day »
[00:12:13] chrisseaton: If I'm using semantic versioning for a gem, then writing "~> 0.1" in an application using that gem is wrong isn't it? Because it would allow 0.2 and I can't guarantee the interface for that. Or does RubyGems already know about that?
[00:15:13] jhass: minor is said to be backwards compatible but 0. says anything goes anywhere, not sure which you're referring to
[00:16:00] chrisseaton: Right so if I say ~> 0.1, does RubyGems knows that since anything goes, it can't use 0.2 for that dependency?
[00:17:47] jhass: would be a bit counterproductive anyway, given there are authors that make the normal promises for 0. versions already
[08:32:46] soud: what book/resource do you guys recommend to learn ruby for someone with prior programming knowledge?
[08:34:28] Zarthus: soud: I learnt it by basically just doing it, it's a bit weird to wrap your head around initially but the docs are, well, *good enough* to get you started. There's also a very basic learn ruby thing on the site
[08:34:58] Zarthus: it'll get you familiar with some of the immediate differences (puts over println, blocks are a thing, symbols)
[08:36:24] Zarthus: now just to add some irony, I have a question about how I'm having trouble navigating the docs ;) I'm currently navigating the YAML/Store page of the docs, and #initialize supports yaml_opts - I however see no indication of what options are valid. Is there a magic trick I'm missing here, or is it "go dive in the source code"? http://ruby-doc.org/stdlib-2.2.3/libdoc/yaml/rdoc/YAML/Store.html
[08:37:45] Zarthus: soud: if you don't learn by doing, I think !books may be a command, but there's only one way to find out and it might make me look like a fool
[08:51:40] Zarthus: https://github.com/tenderlove/psych/blob/master/lib/psych/handler.rb#L16 Guess this is the best answer I'm going to get
[12:05:13] moss: awer: here is something https://www.linode.com/docs/websites/ror/ruby-on-rails-apache-debian-8
[12:05:53] shevy: awer source! but only if you have a sane base system "wget ftp://ftp.ruby-lang.org/pub/ruby/2.3/ruby-2.3.1.tar.xz"
[12:06:49] awer: theres a word press scanning tool im trying to run that complains because the version of ruby im using is too old
[12:08:28] awer: i need to test some vulnerable flags with an application and therfore i have to resolve this ruby issue
[12:09:18] awer: can i simeplyy download from here ? - https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.1.tar.gz
[12:15:58] awer: after compiling how do you set the compliled ruby version to be the default globally?
[12:30:01] shevy: they are using that for university structure here - in the bioinformatics department :\
[12:40:09] jhass: if I learned anything from religion than that mindless repetition is supposed to be good
[13:21:51] ruby783: I have a quick noob question. In "Eloquent Ruby" i read that it is more advisable to write for example >var = var.upcase< as opposed to >var.upcase!<. Can someone explain in laymens terms why that is? Cheers :)
[13:25:51] ruby783: I mean in know the difference between upcase and upcase! in a sense that the one with the bang will alter the variable while the first doesnt
[13:25:52] jhass: ruby783: the difference is that .upcase returns a new string with the changes, while .upcase! modifies the existing string in place
[13:26:05] jhass: so, say someone gave you the value of var. They still may hold a reference to it themselves, with the latter now you modified the value not only for yourself but also for them.
[13:29:03] ruby783: Hmm i think I'm getting closer to understanding it, thank you for your answer. Just to clarify, wouldn't var = var.upcase also alter the assignment of var and thus the value someone else is still holding?
[13:29:40] elementaru: you mean var=var.upcase will only hold true inside that method, whereas var.upcase! will change var's value outside method as well?
[13:30:22] jhass: ruby783: no, a local variable is a reference to an object, other people can only hand you the object, not the "variable" so to speak
[13:30:49] jhass: you update what the variable points to, not the object you've been given and assigned to it initially
[13:32:50] jhass: ruby783: you need to separate what a variable and an object is. A variable points to an object, it's not the object itself
[17:20:39] sean_: Hello! I have a question. If I am using Array#include? and I have a custom #== implemented on the objects in my array, is my custom #== method supposed to be called?
[17:40:08] habitullence: Hi guys, looking for someone to critique my code https://gist.github.com/habitullence/b416782da630b829e01de28a032c046a
[17:46:42] jhass: I think it's a little non-obvious though, I'd make sure it's inside def place_upstream_in_front or so
[17:48:55] jhass: say we start with [a, b, c] a is the client, b received the request, handed it to c which is your upstream, then you'll get [c, a, b], reading backwards a didn't pass the request to c
[17:50:34] habitullence: Yes, so there's an lb you don't see here and this is a list of upstream app servers
[17:51:31] habitullence: I guess what I was wondering is if there's a way of magically combining these two lines so I'm not referring to the same variable three times, just define it once.
[17:52:36] jhass: well since you don't care about order you could [response.headers['X-Upstream-Addr'], '10.0.15.20:8484', '10.0.15.21:8484'].uniq, given you trust the header
[17:52:54] habitullence: That would mean having a method like rotate that took the IP header instead
[17:53:46] habitullence: it's proxying round robin though so for the test I'd have to go through in order
[19:07:09] jbird00: I have a person class and a number of lines the person should wait in, but they're not sure which line they're supposed to be in, only the lines know. Is the correct approach to make an array of Line classes and methods like Line::for?(some_person) and just loop until it's true and return that class?
[20:13:40] dreinull: jhass so I'm not missing some basic knowledge, it just doesn't exist. I was wondering.
[20:25:51] henrydangprg: I'm a complete beginner at Ruby, and I'm a bit confused. Can anyone help me out a bit?
[20:29:46] elemenn: I have abc, and I have string, and I want to check if every char of string is in the abc
[20:29:53] henrydangprg: So in this code snippet (http://pastebin.com/dAftcr7j), In line 15, the block is called on the ruby_tree instance, but why isn't the entire tree printed out? (because of line 24)
[20:29:54] ruby[bot]: henrydangprg: we in #ruby do not like pastebin.com, I reposted your paste to gist for you: https://gist.github.com/62781fd71f98799a86b1a1dcb271520b
[20:29:54] ruby[bot]: henrydangprg: pastebin.com loads slowly for most, has ads which are distracting and has terrible formatting.
[20:39:19] henrydangprg: Oh, I see. I mis-read the initialize. It calls it recursively on the children, (which are Reia and MacRuby).
[20:39:46] elemenn: jhass close enough, I'm doing JS at freecodecamp and convert the puzzles to ruby
[20:40:21] elemenn: thanks, I was playing with .index and .each_char, but your method suggested me where I was making a mistake
[20:41:00] henrydangprg: jhass: just to be clear, what does "self" refer to in line 15? It refers to the ruby_tree variable, right?
[20:42:05] jhass: important distinction to get right, variables refer to objects, they aren't the objects themselves
[20:49:10] henrydangprg: Jhass, thanks a lot for your help, after you clarified that, everything just clicked into place.
[21:45:03] elemenn: I mean what confuses me that 'tikrinam' method doesn't recognize vars defined in its parent method
[21:49:11] borodin: anybody know anything about nokogiri? I'm trying to read an html document - the docs about noko are very helpful for parent/child relationships, but not for sibling relationships
[21:49:27] adaedra: elemenn: you could pass them as parameters, or, if you're in a class, instance variables
[21:51:11] borodin: like, my document has <dl><dt>...</dt><dd>...<dd><dt>...</dt><dd>...</dd></dl> so I need to associate the first dt.text with the following dd.text, then the next dt.text with the next dd.text