#ruby - 19 December 2018
« Back 1 day Forward 1 day »
[00:13:18] Inside: Heyo~ cross posting from the #RoR channel, but I am having issues with bundle bumping from one revision of rails to another: https://gist.github.com/Insood/d0a9df88f8ce2e0e1eee1fe8e70f2c46
[00:13:42] Inside: Like the first conflict makes no sense since it looks like actionpack & simple_form should be satisfied..
[00:24:58] Inside: Turns out nuking a single gem from the gemfile that I didn't need anyway fixed everything D
[01:12:37] ruby[bot]: Please join #RubyOnRails for Rails questions. You need to be identified with NickServ, see /msg NickServ HELP
[02:18:30] nchambers: Iambchop: yeah, you were right. i was having a brainfart and forgot bash was doing things to build[release]
[13:34:50] catphish: feature request (unless it already exists): the ability to defer signal handlers until the end of a block
[13:36:10] catphish: i assume one could create this manually by setting up and tearing down signal handlers as needed
[14:29:58] marz_d`ghostman: Any good gem that would make testing concurrency easy? Currently using concurrent-ruby gem in my script
[14:47:29] catphish: the most common signal my applications will see is TERM, and i don't necessarily want a process to exit until it's finished something critical
[14:48:03] catphish: other signals are just used to trigger things, and again i may not want them to happen instantly
[14:49:09] darix: catphish: your signal handler could just set a variable and your event loop could check those variable at the beginning of the next iteration?
[17:00:03] careta: guys, I need too spawn a background process, then after some time "connect" to it and allow the user to interact with it. How can I achieve this?
[17:40:41] Inside: if the interaction & the process occur within the same application, you would use threads..
[17:52:12] Eiam: there was a gem ages ago... it took ruby from one client, passed it over the wire, then ran it on another client
[17:52:16] havenwood: Eiam: reminds me of my old, deprecated ipc futures gem: https://github.com/havenwood/ifuture
[17:54:38] careta: it might be easier just to use expect or something like that and echo at the end of the output
[17:55:59] careta: I don't have control over the other end, I need to interact with a slimmed down shell, not even bash
[17:58:51] phaul: I was practising coding and I made a sudoku solver https://gist.github.com/phaul/1d36018bf925bd212c64671a5ca20217. I tried to write idiomatic Ruby, refactor, and write understandable code, rather than be the fastest. But I also tried to solve all puzzles in acceptable amount of time. Please give me suggestions on how the code could be improved
[18:01:18] Eiam: hah past me trying to document his gemfile # Strictly for development for sane debugging & stepping behavior
[18:35:11] havenwood: phaul: Use `private_constant` instead of the @private comment: https://gist.github.com/phaul/1d36018bf925bd212c64671a5ca20217#file-sudoku-rb-L20
[18:37:03] havenwood: phaul: I prefer `__method__` to `:rows` so you can change the method name without changing the symbol - but I could see not liking that too: https://gist.github.com/phaul/1d36018bf925bd212c64671a5ca20217#file-sudoku-rb-L26
[18:50:06] phaul: I have to say I need to relearn what private means, as private_constant makes 0 sense to me atm.
[18:51:00] phaul: private is that you can;t put explicit receiver on it, right? So what does that mean for a constant
[19:02:12] havenwood: phaul: Yeah, it makes it inaccessible outside the class - unless you use metaprogramming, of course.
[19:03:04] havenwood: phaul: I'd say DRY these up with extract method: https://gist.github.com/phaul/1d36018bf925bd212c64671a5ca20217#file-sudoku-rb-L53
[19:05:34] havenwood: phaul: I'd say #size instead of #count, but you can just use #one? here: https://gist.github.com/phaul/1d36018bf925bd212c64671a5ca20217#file-sudoku-rb-L124
[19:14:53] phaul: the gnarly stuff comes in IterativeDeepening, so based on your reaction so far, I'm expecting a heart attack :)
[19:17:49] havenwood: phaul: I'd say `.flatten` or `.flatten(1)` in place of `inject(:+)` here: https://gist.github.com/phaul/1d36018bf925bd212c64671a5ca20217#file-sudoku-rb-L438
[19:49:44] Zarthus: Eiam: I think so long you're friendly, you keep your usecase small and their time valued, it's a completely valid question
[19:50:13] Eiam: Zarthus: not disputing it as a random thing, but as an actual like ongoing action to just have all your code get reviewed here?
[19:50:42] Zarthus: just make sure your code is presentable. a 500 line gist with no indentation is the rude part.
[19:51:16] WA9ACE: a 500 line gist with no indentation asking "please make this totally not my homework run"
[19:52:25] WA9ACE: with things like slack communities and gitter I'm still surprised to see people making their way to IRC channels tbh
[19:53:23] WA9ACE: Inline I pay for IRCCloud, they have an API level integration to Slack, and you can now connect to IRCCloud and treat it as a bouncer
[19:53:36] WA9ACE: so I'm connected to all my slacks from my IRC client again, even though they killed the IRC bridge
[19:58:48] Eiam: WA9ACE: when you go into an ios dev channel on slack its got 3000 people or more. good luck.
[19:59:17] Eiam: I know most the active people here and have seen and conversed with them off and on for years. hard to do that in slack groups that big
[20:02:12] Zarthus: they already fund development of kiwiirc, inspircd, and servers for freenode and snoonet. the rest of the free time OSS devs won't keep up
[20:34:11] havenwood: https://github.com/yuki24/did_you_mean/commit/2a082a71991f5afe2e27ce9538103eac4c428025
[20:42:46] Scrooge: actually, i realized i asked my question wrong, but method 1 gave me an idea of how i can do it
[21:20:04] kspencer: So I'm pretty sure someone has already noticed this, but ruby-doc.org/core-2.5.*/Struct.html (I did put an asterisk in there because it affects 2.5.0-2.5.3)
[21:20:04] kspencer: But the documentation for Struct asks you to use a 'Customer' constant, which in affected versions of ruby will raise a Dynamic Constant Assignment Error
[21:20:04] kspencer: Which yes, I do know is not a bug, but a feature of 2.5.* but is a bug with the documentation documents. Just letting more people know
[21:21:33] miah: its not asking you to use a constant named Customer, its only using Customer as an example
[21:23:43] miah: i suspect you already have a Customer defined somewhere in your code. when I do this in pry it works fine.
[21:31:16] kspencer: my problem is not with the code I have, its that the docs say its allowed in 2.5 when its not, before with 2.3 i'd get a warning but with 2.5 I'm getting an exception, with the docs, that's a bit of a issue when it says it would be allowed and not saying anything about it causing an exception
[21:36:30] havenwood: kspencer: each time you run that method, you redefine the constant - hence the error
[21:37:21] havenwood: kspencer: this wouldn't have worked in any version of Ruby though - it's not 2.5-specific
[21:37:46] miah: and then in your account method create a instance variable that holds a Account, eg `@account ||= Account.new`
[21:39:32] kspencer: and I don't use rvm or anything because it causes me too many problems with scope when i want something to use the full user etc.
[21:39:50] havenwood: kspencer: It doesn't work on the 30 versions of Ruby I have on this computer. :P
[21:43:34] havenwood: kspencer: It does work. I'll remove the WIP: https://youtrack.jetbrains.com/issue/RUBY-14086
[22:13:36] havenwood: A nice update on the CRuby JIT: https://medium.com/@k0kubun/ruby-2-6-jit-progress-and-future-84e0a830ecbf
[23:22:02] cahoots: hi, i want to get a base 2 number (as a string of 1's and 0's) approximating a decimal number (e.g. 0.1), with as many bits as i want. what's the easiest way to do this?