#ruby - 03 January 2019
« Back 1 day Forward 1 day »
[11:24:41] canton7: Looks like it's interpreting it as a time, and "5 minutes + 90 seconds" is the same as "6 minutes and 90 seconds"
[13:31:10] catphish: is it practical to use a SIGCHLD handler to reap terminated child processes? i was thinking of doing so, but i have a million concerns about race conditions
[13:32:02] catphish: specifically, what happens if a signal arrives during a signal handler execution? will it queue another one?
[13:32:06] tbuehlmann: Swyper: that's a block you're providing as a method argument. you can run the code from the block in your method by calling `yield`. you can also reference it by having `def function(&block)` and using `block`
[13:33:16] catphish: someone writes "pending signals of the same type are not queued", so i'm not sure how this could be used :(
[13:38:15] tbuehlmann: well, you wouldn't pass a string as a block, that could easily be a "regular" argument
[13:39:50] Swyper: I'm trying to make it take an input block with a default value of hello if none is given, and reverse the words
[13:40:14] tbuehlmann: if you just want to reverse something, use a regular argument: def reverse(string = 'hello'); string.reverse; end
[14:13:04] Swyper: yield.reverse! does, but it also reverses the order of the words, I just want the contents of each word to be reversed
[14:13:48] leftylink: and that should tell you that `yield` is evaluating to a string. so you use the variety of string methods at your disposal
[14:16:17] phaul: Swyper: what's the purpose of the string argument? You are not touching it anywhere...
[14:17:20] Swyper: but it probably should not be there cause its doing nothing like you mentioned :P
[14:18:05] Swyper: I originally did not know how to work with blocs when they are passed like this so I was experimenting with different stuff and I did not take it out that is why it was there, but I took it out now
[14:21:36] phaul: there are issues with your code, I don't know how or why it passes or what the task actually was, but that code certainly doesn't look right, I can detail issues with it, or we can take an other approach, you show me the task and I try to give you pointers towards a good solution
[14:33:54] Swyper: Sure, the goal of the code is to reverse the contents of each word in a given bloc phaul
[14:34:10] Swyper: I like both approaches, do you have a counter example for when it would not work ?
[14:53:00] phaul: as a rule of thumb don't use self modifing or destructive methods inside a #map altough it's fine here.
[14:53:59] Swyper: as a rule of thumb don't use self modifing or destructive methods inside a #map altough it's fine here. - why is that a good general practice to follow? phaul
[14:55:42] phaul: #map should be about the return value, in a functional style. we call it for what it returns. #each should be about the side effect it causes, we usually don't care about what it returns but care about what it does. dont mix them
[14:56:08] rubydoc: # => ["HELLO", "WORLD", "HELLO", "WORLD"] ...check link for more (https://carc.in/#/r/5wyb)
[14:56:38] rubydoc: # => ["hello", "world", "HELLO", "WORLD"] ...check link for more (https://carc.in/#/r/5wyc)
[15:12:06] phaul: rubydoc will now go offline for a bit due to electrical wiring fixes. Should be back soon #homehostingsucks
[15:30:59] uplime: is this a bug with rubocop? https://clbin.com/uioXb it's complaining about the unused variable &block but its implicitly getting used by the yield
[19:32:55] djdduty: Hey guys, my Ruby.framework on macOS is missing the universal-darwin18/ruby/config.h and only has universal-darwin17/ruby/config.h, I have made sure I have the most recent version of everything. Anyone else run in to this and know the solution or if I'm asking in the wrong place?
[19:34:39] djdduty: havenwood Attempting to install a gem via a bundle install that is throwing an error about it missing.
[19:35:41] havenwood: djdduty: Most folk on macOS opt to install a newer Ruby alongside the system Ruby to use for their own projects.
[19:35:52] havenwood: djdduty: Here's an example setup: https://ryanbigg.com/2015/06/mac-os-x-ruby-ruby-install-chruby-and-you
[19:37:48] djdduty: But for whatever reason it's still trying to use 2.3 from the System when installing the bundle
[19:38:42] djdduty: looks like it may be related to macOS sdk headers or something, IIRC when I upgraded to mojave I did it before the full release (it was beta), I wonder if that's it.
[19:42:12] djdduty: havenwood I did a `gem update --system` and `gem install bundler` which prompted an overwrite of the bundler in the 2.5.3 directory, went ahead
[19:43:33] djdduty: Looks like my .zshrc has something explicitly adding the ~/.gem/ruby/2.3.0 to my path
[20:18:04] sandelius: comet23 ruby doesn't have a "shorthand" syntax for that, you need to call arr.unshift
[20:23:12] sandelius: ok, I do not like to "monkey-patch" core classes. I would do something like this: (one sec)
[20:29:45] sandelius: Cause that will change it for all array in your entire program. This used på be popular but then people realized bug-hunting is just not worth it. It's pretty cool tho that we can create "operators" on the fly :)
[20:35:45] comet23: what i fail to understand is how could it introduce bugs if the code is bug free to begin with?
[20:37:27] phaul: comet23: imagine the chaos if everybody is randomly adding functionality to classes that everybody uses. If two gems are adding the same methods to array differently, and you depend on both, then you are in screwed
[20:39:15] phaul: yeah. and I define it so that my array shifts all of its contents (numbers) by given number of bits. Because in my domain that feels intuitive
[20:40:13] sandelius: comet23 When the project gets bigger, or many people are working on it, that's when the issues occur. Not not so much about a bug in that method, more about playing detective
[20:51:39] havenwood: Haris: Rubies don't usually get installed with an app. How to best uninstall a Ruby depends on how you installed it.
[20:53:05] Haris: I have to remove bundle installed rubies/gems for redmine 4.x to then be able to install rubies/gems for redmine 3.4.7
[20:53:07] havenwood: Haris: By default, Bundler installs to $BUNDLE_PATH or $GEM_HOME. Gem you install there are intermingled with your other gems in that location. You can use --path to specify a different directory.
[20:54:39] havenwood: Haris: We prefix commands with `bundle exec` to limit the gems to those specified in the Gemfile.lock.
[20:55:06] havenwood: Haris: For deployment, we typically install gems to a /vendor directory locally in the app.
[20:56:32] havenwood: Haris: The Bundler default is &GEM_HOME. Folk often use the --deployment flag in prod for a path of ./vendor.
[20:57:42] Haris: https://www.phusionpassenger.com/library/install/apache/install/oss/rubygems_rvm/#i-have-multiple-ruby-versions-or-gemsets.-does-it-matter-which-one-i-use-to-install-passenger-with?
[20:57:50] havenwood: Haris: If you'd set a --deployment flag (which you haven't) you could run: bundle clean
[20:58:58] havenwood: Haris: I'd not worry about gems you've installed. The way Bundler works it doesn't matter what system gems are installed.
[21:00:23] havenwood: Haris: How are you running your command? What's the command you run that results in the errors?
[21:05:23] havenwood: Haris: Show the command that you run that produces and error, and what that error is?