#ruby - 29 July 2016
« Back 1 day Forward 1 day »
[03:43:14] irregular: just want to double check but do method parameters with default values always have to be at the end of a method signature?
[03:46:02] irregular: banisterfiend:ok thanks. i'll ping him and i guess get an answer in the morning
[03:48:17] irregular: hmm i am getting syntax error, unexpected '=', expecting ')' but if I switch all the variables with defaults to the end it works
[03:50:31] banisterfiend: irregular: you get a sntax error when you do htis in 2.3.1? def hello(a=1, b); end ?
[03:51:41] irregular: def fill_form(a=1,b,c=2); end doesn't work but def fill_form(b, a=1,c=2); end works
[03:52:17] irregular: so i was assuming the ordering is though issue but i also have some confidence my coworker wouldn't push that if that didn't work hmm
[03:53:22] banisterfiend: irregular that's not valid in any ruby version. But just having default, non-default is fine
[03:54:35] banisterfiend: your original code is default, non-default. That's valid. But the code you just posted now (fill_form) is different, that's default, non default, default. That's not valid
[03:55:43] irregular: actually the code i pulled is like so def fill_form(a,b,c,d,e=1,f,g=1) end but I'm sure that's also not valid
[04:02:15] irregular: is fill_form(a,b,c,d,e=1,f) valid? (this compiles fine for me though), just feeling out the rules here
[04:31:21] jorvis: I'm completely new to Ruby, but needed to modify someone's gem. When I run the script which calls it I don't see the change. Do gems need to be rebuilt/compiled if the code changes, and how? The file I changed (if it helps with rebuild syntax) is: /var/lib/gems/1.9.1/gems/sequenceserver-1.0.8/lib/sequenceserver/sequence.rb
[04:39:12] jorvis: I also tried "# gem build sequenceserver.gemspec" and got rebuild output but my change doesn't seem to be evident
[09:12:29] dminuoso: How would you name an exception that denotes a remote service cannot service an automated request, requiring me to fill out a form and request the information that way instead?
[09:27:25] Zarthus: yeah, if you require human interaction you'd probably be showing the exception message to the user
[09:34:14] Zarthus: some things (like an infinite loop) is often wrapped in a begin/rescue with multiple nested rescues
[09:34:50] Zarthus: Generally speaking though, you want your begin-rescue block to be as small as possible.
[10:55:31] ruby[bot]: pard: # => /tmp/execpad-5f75b2940416/source-5f75b2940416:7: syntax error, unexpected end-of-input, expecting ke ...check link for more (https://eval.in/613862)
[10:55:45] ruby[bot]: pard: # => /tmp/execpad-da7f6443ed1a/source-da7f6443ed1a:2: syntax error, unexpected tIDENTIFIER, expecting key ...check link for more (https://eval.in/613863)
[11:02:44] ruby[bot]: pard: # => /tmp/execpad-cd79c2763d4d/source-cd79c2763d4d:2: void value expression ...check link for more (https://eval.in/613869)
[11:11:09] Mon_Ouie: Use the STDIN constant only if you specifically need to reference the actual standard input, the global variable can be changed e.g. to redirect the input stream
[11:14:03] Mon_Ouie: Probably since you can't usually do that with other types of inputs. You could still argue the other way, e.g. for testing purposes.
[11:15:04] rubirc: https://youtu.be/8bZh5LMaSmE?t=1039 does anyone why her minitests are so fabulously colored?
[11:16:55] al2o3-cr: Mon_Ouie: this is what i was attempting: f = STDIN.fcntl(Fcntl::F_GETFL); f = f | Fcntl::O_NONBLOCK; STDIN.fcntl(Fcntl::F_SETFL, f)
[11:19:09] Mon_Ouie: I think I would. Have you also looked into io/console? I think it has methods to do this without you using fcntl directly.
[11:50:11] al2o3-cr: Mon_Ouie: I think i can make it work with STDIN.read_nonblock seeing that setting flags on STDIN as no effect anyway.
[12:04:33] ruurd: This implies that ' is faster than " (because it does not invoke the interpolation logic)
[12:54:07] jobat: Has anyone tried any game dev stuff in ruby? I came across gosu on github and was intrigued
[13:05:49] dminuoso: jobat: Ruby is not designed to be fast or efficient at solving problem. It's designed to be fast and efficient at writing code.
[13:06:50] Zarthus: you could write a small console game for fun using ruby but I wouldn't go further than that
[13:16:35] dminuoso: Any more elegant solution to strip any whitespace from the end of a string than gsub(/[[:space:]]\Z/, '') ?
[13:18:53] dminuoso: But for what its worth, I stared at this for a while to understand why rstrip wouldn't work.
[13:22:22] jobat: yeah, I realised about halfway through typing. Still pressed enter though, like a fool.
[13:22:53] Zarthus: I don't think #rstrip should strip those personallly speaking, especially since it's easier to extend a method than to subtract from it
[13:22:56] dminuoso: jobat: The sheer amount of headaches I got when I started Ruby development on OSX is unbelievable.
[13:23:28] dminuoso: Until I realized there was some key combination that by default generated nbsp on OSX.
[13:23:30] Zarthus: (in addition: the amount of breakage this change *could* produce would be through the roof, and it wouldn't be obvious)
[13:23:59] dminuoso: Zarthus: Which is why it will never happen, I know how the core developers in Ruby react to such patches.
[13:25:10] Zarthus: personally though, if this is your only case, I'd just roll with str.rstrip.replace(..., '')
[13:25:20] dminuoso: But then again, rstrip would have to be extended to encompass all whitespace characters in all encodings.
[13:26:15] dminuoso: Zarthus: Also, the nbsp comes from a mechanize based module that scrapes websites... :o)
[13:27:37] jokke: in celluloid is there some kind of id for the actor? I want to have a unique id for log messages per actor
[13:27:40] jobat: I think I remember having to use something similar with some ancient version of grep
[13:30:09] Zarthus: i agree, but I tend to wrap up regexes into some compiled variable/constant or method most of the time
[13:30:56] dminuoso: Zarthus: The key issue is that it may not immediately be obvious when you sometimes use \s and sometimes \S.
[14:07:04] ellisTAA: im building an app kinda like instagram and i was thinking id store the images on s3 … does this sound like a good idea? then id just send the user the url for their browser to display the img?
[14:52:41] Mattx: Hey, I have a function defined in the global (Object?) scope. and I want to know if it's callable from the inside of a method in a class. The name of the function is in a variable myfunc
[14:53:05] Mattx: So for instance I tried methods.include?(myfunc) and respond_to?(myfunc), but both return false
[14:54:14] ljarvis: yeah, i just mean it's not really global, so you can't access it except from main (without some meta hacking)
[14:54:45] ljarvis: if you want to define a method available everywhere your best bet is to include it into the Kernel module
[14:56:13] Morxander: I compilled/installed Ruby 2.0.0-p684 from source but I need to install Ruby-dev too but when I do through apt-get it needs to install ruby again too which will conflict my installation
[14:57:03] OTORelic: morxander, im pretty sure if you remove youre ruby and install ruby-dev it will have a dependency on a ruby version
[14:57:56] Morxander: I have to work with this patch 684 and I dont know which patch avalible on the ubuntu repo
[14:58:33] fergal_: hi guys, i’m trying to download a zip that contains an executable, but when i download and unzip it with ruby, the executable file is not marked as executable. however, when i download and unzip it manually, the executable is marked as executable. i’m not sure why this is the case, is there something extra i have to do when unzipping the file via ruby to maintain executable permissions on files?
[14:58:41] Mattx: dminuoso, what's the default class/module when you don't specify one? is it Kernel?
[14:59:24] Mattx: I believe my function is defined there, and I want to check before I run it from a variable (myfunc = :function_name)
[14:59:30] dminuoso: Mattx: But it gets added to the singleton class (!) of the main object, which gets created during VM initialization.
[15:00:22] ljarvis: Mattx: fwiw (and im not trying to bust your balls), you should refer to them as methods, ruby doesn't have functions per say
[15:00:28] dminuoso: Mattx: And note this is not pedantry, but accuracy - understanding this removes the magical bits of statements like: def self.blah; ...; end
[15:00:45] Mattx: it works as I expected, I should be doing something wrong in the real code. I'll double check
[15:01:06] OTORelic: fergal_ if your doing it in a ruby script and know the name just hardcode the permissions change for the executable after the unzip happens
[15:01:30] ljarvis: Mattx: im confused at what you want, you say "it works as expected", so you expect this not to work?
[15:01:49] Mattx: dminuoso, yeah, I know what you mean. I wanted to make it clear the "function" doesn't beloing to a class I have defined. it was "global" (belonging to main or whatever it's called)
[15:04:07] Mattx: alright, that's the problem them. in pry it works as I thought it would, but the real code is obviously run in ruby (not pry)
[15:07:28] Mattx: in the real code when I run method(:descriptive) I get #<Method: Repository(Object)#descriptive>
[15:11:58] Morxander: I can't bundle "Failed to build gem native extension. /usr/local/bin/ruby extconf.rb " does anyone knows what to do?
[15:30:17] wcarss: anyone here have experience with doorkeeper? or know a channel that would be more specific
[15:32:59] wcarss: I run a server that uses doorkeeper for authorizing oauth applications, and someone has sent a request to me to add an application with a query parameter in it
[15:33:26] wcarss: not a dynamic one, just a static parameter to say what the source of the arrival is
[15:33:50] wcarss: doorkeeper doesn't allow dynamic query parameters, but I don't see anything that says they disallow static ones
[15:34:27] havenwood: wcarss: Since it's an OAuth 2 provider for Rails, the #RubyOnRails channel would be a bit more specific.
[16:53:50] Dysp: Why am I getting NoMethodError: NoMethodError: undefined method `extract_values' for KincomLoader:Module?
[16:54:41] Dysp: If I add :extract_values to module_function, then it works. But that makes the function public, right? I don't want that. Load_file should be the only public method here.
[16:58:55] drbrain: Dysp: include makes methods in the module appear as instance methods in the including class
[17:02:31] Dysp: drbrain: Thank you. Do you have any great resources on how to build these hierarchies? I find it extremely necessary to understand, but also so incredible hard to comprehend
[17:04:39] Dysp: I think I am going to build this first and then reread it to try to refactor it. It is hard to understand all the concepts; I've learnt a lot from it, but it is a little abstract for a complete programming newbie like myself.
[17:05:17] Dysp: But, back to my original problem. Still getting NoMethodError: undefined method `extract_values' for KincomLoader:Module
[17:13:51] Dysp: Could separate it, though. But I wanna keep it a little simple, then I can also get more files (gosh) when the others become a little too complex
[17:14:11] drbrain: in the `test_kincom_loading` test you call the method directly on KincomLoader, so in my view you're testing the module directly
[17:14:52] drbrain: in my gist the first method, include_module, is what I start with for testing modules
[17:15:10] drbrain: it works great so long as the module doesn't have any state that might conflict with minitest
[17:15:31] drbrain: when the module starts having extra state I'll switch to the test-only class version so the module's functionality stays isolated
[17:18:24] drbrain: since the module methods aren't accessible without adding module_function I would test them separate
[17:18:58] drbrain: then, for XerciseClass tests, only have enough of a test to make sure they get called
[17:20:39] Dysp: Yes, I will be splitting them up. Thank you for you help. Would you have any interest in looking through the repository and point out stuff that is stupid and should be made differently?
[17:22:01] Dysp: I mean, I could just share it in here and ask; and even thought I am definetly not creating a potential new Facebook, I still wanna keep some things at least a tiny bit disclosed.
[18:18:40] joevandyk: this is taking up 500MB of memory.. anyone have any ideas on how to optimize it?
[18:19:10] joevandyk: even before the to_json, building an array of 450k fairly small hashes is taking up about 400MB of memory
[18:25:06] joevandyk: drbrain: when i run memsize_of on the result (before turning into json), i get 5171712
[18:27:15] eam: joevandyk: lots to pick from. I mostly use ruby-mdbm, but that's more because I'm familiar with the backend tech than for any technical reason
[18:40:58] joevandyk: i had the idea to try to use a lazy collection, but https://github.com/brianmario/yajl-ruby/issues/144 :(
[18:44:35] crazydiamond: Hi. What I'm doing wrong during Command-T VIm plugin installation, if what I get is this: http://dpaste.com/1TXFRNQ ?
[23:50:21] nofxx: Noon... hey, how to add --with-cflags= opt in a Gemfile? Really have to type `bundle config build.gemname --with-cflags=....` in everymachine?