« Back to channel list

#ruby - 10 November 2017

« Back 1 day Forward 1 day »
[00:00:15] Azure: has joined #ruby
[00:00:58] jphase: has joined #ruby
[00:03:28] nofxx: has joined #ruby
[00:06:02] ramfjord: has joined #ruby
[00:06:22] kies: has joined #ruby
[00:06:50] nofxx: has joined #ruby
[00:08:48] millz: has joined #ruby
[00:10:20] nofxx: has joined #ruby
[00:12:30] jphase: has joined #ruby
[00:12:43] RickHull: quite the moniker...
[00:12:54] GodFather: has joined #ruby
[00:13:47] jphase_: has joined #ruby
[00:14:38] nofxx: has joined #ruby
[00:17:13] paul0: has joined #ruby
[00:18:32] c-c_: I improved the ui refresh to work like eam suggested
[00:18:40] c-c_: many LOC eliminated
[00:18:42] c-c_: excellent
[00:18:46] c-c_: https://gist.github.com/csmr/87eae0fa218efba43f9fc661b270ceb4
[00:18:51] c-c_: thanks eam!
[00:20:06] postmodern: has joined #ruby
[00:20:16] RickHull: argh is a great variable name xD
[00:20:34] c-c_: yeah some rows are from the tread based try even
[00:20:46] RickHull: you could also have that be the name of your error method. argh!("it's hosed")
[00:21:15] elomatreb: Almost as good as "blargh"
[00:21:24] c-c_: eargh - error argh
[00:21:37] nofxx: has joined #ruby
[00:21:57] elomatreb: Also: https://github.com/mperham/sidekiq/blob/master/lib/sidekiq.rb#L52
[00:24:26] jenrzzz: has joined #ruby
[00:24:26] jenrzzz: has joined #ruby
[00:26:07] RickHull: c-c_: may I suggest https://github.com/rickhull/lager for debug logging
[00:26:17] nofxx1: has joined #ruby
[00:26:35] RickHull: you can do @lager.debug { "all kinds of stuff" } with little impact if the log_level is e.g. WARN
[00:26:42] RickHull: and no need to comment stuff out
[00:27:34] nowhere_man: has joined #ruby
[00:28:47] sucks: has joined #ruby
[00:28:49] RickHull: it's a very thin wrapper around Logger, mostly for UX convenience
[00:28:51] c-c_: yeah I just put all "utilities" in one module as functions
[00:29:02] c-c_: its kinda soup
[00:29:18] c-c_: I'm hoping I can make it into separate modules later
[00:29:35] al2o3-cr: has joined #ruby
[00:29:35] RickHull: that is the best approach IMHO. default to a bag of stuff and separate as needed
[00:29:39] c-c_: but the idea with p_dbg I can add some flag to test if output desired
[00:29:41] c-c_: thats all
[00:29:43] RickHull: rather than imagining a grand hierarchy up front
[00:30:04] c-c_: - so I can disable p_dbg output with one flag
[00:30:42] RickHull: with @lager, alternately, you just disable output by setting log_level
[00:30:56] RickHull: and by using a block, you ensure that the string you passed, when disabled, isn't evaluated
[00:31:03] c-c_: I do things like $stderr.reopen(Logfile, "w+") for logging output
[00:31:53] RickHull: by passing the log message as a string, rather than inside a block, you are creating that string even when flag==false
[00:32:34] c-c_: sure, its just not outputted
[00:32:57] RickHull: that means you end up tempted to comment out all the debug logging "for performance"
[00:33:14] c-c_: performance has to come from somewhere else
[00:33:15] RickHull: well why is commented out in your gist?
[00:33:46] RickHull: er, maybe it's not :)
[00:33:52] RickHull: i just double checked
[00:33:58] c-c_: if you uncomment it, the frame counter pushes into your input and you can't type single letter messages
[00:34:43] c-c_: \r clears the row on the screen, not sure what it does for the input buffer, but when you hit enter, theres something other than the last typed char in the buffer
[00:34:54] RickHull: with Lager, you can say in your class file: log_to $stdout # or /tmp/log.txt
[00:35:26] c-c_: the idea with current row 24 is it refreshes the frame # in real time
[00:35:47] c-c_: iow, the number "runs" on the last row of the screen
[00:36:42] c-c_: and the delay between the frames comes from row 28
[00:36:51] RickHull: I don't quite understand the interference problem you're having, but I would suggest you solve it sooner rather than later. I expect you are going to need extensive trace/debug logging going forward
[00:37:18] c-c_: hmm, I wonder what youre referring
[00:38:13] RickHull: one common pattern is to log a basic trace to stdout, while the game uses something else for user IO
[00:38:26] RickHull: kind of like opening the console on a FPS game
[00:38:46] RickHull: or maybe you want STDIN and STDOUT for user input
[00:38:55] RickHull: and log to STDERR by default, or just a file
[00:39:13] RickHull: but it sounds like your informative log messages are interfering with user IO
[00:39:18] c-c_: I think I've just implented minimal ui refresh at settable rate independent of user input in a ui, + stateserver and engine processes, and spawning, daemonizing and IPC of such
[00:40:19] c-c_: I will use curses on the output actually
[00:40:31] c-c_: but the input is just a nonblocking read from stdin atm
[00:40:46] c-c_: raw mode is possible in the future
[00:40:54] RickHull: also, I understand best practice is to use $stdout rather than the constant STDOUT
[00:41:04] RickHull: that way you can reassign the global if need be
[00:41:19] RickHull: it's a tiny bit of hax flexibility
[00:42:28] c-c_: hehe this thing is a tiny piece of hax
[00:43:05] RickHull: hax all the way down
[00:43:12] milardovich: has joined #ruby
[00:43:26] RickHull: && self.hax!
[00:44:21] mim1k: has joined #ruby
[00:44:23] c-c_: cleanup and git-ification later
[00:44:34] milardov_: has joined #ruby
[00:44:55] alveric3: has joined #ruby
[00:46:28] Jameser: has joined #ruby
[00:49:14] c-c_: So this is what the game runner class looks like
[00:49:19] c-c_: https://gist.github.com/csmr/a3c26033e86019f941c1e603e44729f9
[00:50:04] RickHull: you shouldn't need to pass self to p_dbg right?
[00:50:40] c-c_: yes, its the only way I could figure how to get the instances class and pid right
[00:51:34] c-c_: I mean, instance id
[00:51:39] RickHull: when you pass self to p_dbg, wouldn't it be the exact same as self inside the p_dbg definition?
[00:51:53] Technodrome: has joined #ruby
[00:52:32] c-c_: RickHull: this is how it works https://gist.github.com/csmr/226ef7eb5ee4ea9de4f15d1e41bb904a
[00:52:49] c-c_: I tried to use Kernel.caller, but it returns call stack array
[00:53:24] RickHull: I would: def p_dbg(msg, prepend=true)
[00:53:43] RickHull: and where you don't want to put the object details, call p_dbg(msg, false)
[00:53:58] RickHull: otherwise p_dbg(msg) suffices
[00:54:16] RickHull: also consider keyword args
[00:54:25] RickHull: def p_dbg(msg, prepend: true)
[00:54:29] c-c_: outputs "SpyOps::Engine 47168440261980: got msg UI: 1"
[00:55:09] RickHull: hm, maybe this is some mixin strangeness that I'm not used to
[00:55:35] c-c_: its just passing the object
[00:56:04] RickHull: if self.respond_to?(:p_dbg) then within p_dbg, i can't see how self would be different than obj
[00:56:30] RickHull: but I'm probably not considering all the ins, outs, and what-have-yous
[00:57:01] c-c_: because p_dbg is in module Helpers, and self can be instance of Engine, Ui or just plain GameRunner
[00:57:29] RickHull: ok, fair enough. I hate mixins :)
[00:57:38] c-c_: its just a require
[00:58:27] RickHull: still, consider a keyword arg: def p_dbg(msg, obj: nil)
[00:58:34] c-c_: the top of todo list is actually 'fix module structure' but I think there needs to be more fleshed out before that can be done
[00:58:41] RickHull: i would use nil rather than empty string for a default value
[00:59:07] RickHull: this would force your calls to look like p_dbg(msg, obj: self) where you want obj
[01:00:44] c-c_: without default object, it just outputs the string
[01:00:50] c-c_: the idea indeed
[01:01:05] fishcooker: has joined #ruby
[01:01:21] RickHull: I'm just saying, empty string is kind of a weird default
[01:01:27] RickHull: and then you test for empty string
[01:01:37] RickHull: nil is a more common default for such a case
[01:01:47] c-c_: test is for prepending to the arg msg
[01:02:06] c-c_: ok I see it now
[01:02:22] c-c_: hm, it must have worked with '+' before, better fix that
[01:03:03] RickHull: to more fully illustrate my point, you could make the default be an empty array and test for that
[01:03:06] RickHull: but why would you?
[01:03:30] RickHull: nil is commonly used, and false less so
[01:04:46] RickHull: when any object may be passed in, what's special about an empty string? what is that supposed to indicate?
[01:04:48] cdg: has joined #ruby
[01:04:58] RickHull: an empty string is truthy, while nil and false are falsey
[01:07:39] mtkd: has joined #ruby
[01:08:38] RickHull: where the default says "did they pass something in", it's better to use a falsey value when the answer is no
[01:08:45] c-c_: So there, a disableable instance id debug printer https://gist.github.com/csmr/226ef7eb5ee4ea9de4f15d1e41bb904a
[01:09:15] RickHull: you can even say `if obj` :)
[01:09:29] RickHull: and again, consider making obj a kwarg: def p_dbg(msg, obj: nil)
[01:09:32] c-c_: not sure if should return just erm, 'return'
[01:10:11] c-c_: I've been taught to prefer expanded if testing
[01:10:25] RickHull: `unless @debug_message_disabled`
[01:10:38] jphase: has joined #ruby
[01:11:12] c-c_: return if @debug_print_bool
[01:11:17] RickHull: an if/unless that doesn't fire returns nil
[01:11:23] c-c_: what ever would be the correct way to name that flag
[01:11:37] RickHull: i would just use @debug
[01:11:45] RickHull: and add a subterm only as needed
[01:12:05] c-c_: I try to postfix with expected type or unit
[01:12:21] c-c_: semi-polish
[01:12:32] RickHull: it's your funeral ;)
[01:13:44] nertzy: has joined #ruby
[01:14:09] RickHull: I'm being very much tongue-in-cheek -- use your judgment :)
[01:14:09] c-c_: things like state_srv_pid and @refreshdelay_secs make things readable and quick
[01:14:13] jphase: has joined #ruby
[01:14:33] RickHull: yes, readability is generally my top concern
[01:15:18] c-c_: I still have to try to get the daemon cleanup working correctly. You can't see it but as it is they try to snuff each other if one dies https://gist.github.com/csmr/a3c26033e86019f941c1e603e44729f9
[01:16:12] kryptoz: has joined #ruby
[01:16:22] cdg: has joined #ruby
[01:17:05] eregon: has joined #ruby
[01:17:20] cagomez: has joined #ruby
[01:17:37] c-c_: also I wonder how to rename the init process that runs the ui to something related to the UI instance that takes over, other than the init.rb filename - so it looks cool in the the process tree!
[01:18:49] zanoni: has joined #ruby
[01:18:59] RickHull: c-c_: I'm not sure you're right about the value of `self` in a mixed-in method: https://gist.github.com/rickhull/462ca3c81f7e1f860de8788b17d32497
[01:19:32] c-c_: what if printer in Foo
[01:19:45] JsilverT: has joined #ruby
[01:19:54] c-c_: you want myself "Hi!"
[01:20:15] c-c_: -> "Bar pid 3424234432: 'Hi!'"
[01:20:36] c-c_: uh, s/pid/id/
[01:21:32] c-c_: well, lot to clean before the gitification and ul to gh
[01:21:41] RickHull: can you confirm the behavior?
[01:23:18] RickHull: it's clear that self is the instance of Bar
[01:23:26] RickHull: thus, there is no need to pass self explicitly
[01:24:40] sucks: has joined #ruby
[01:25:21] pwnd_nsfw`: has joined #ruby
[01:25:34] c-c_: it does work
[01:25:40] milardovich: has joined #ruby
[01:25:45] c-c_: but then the obj just is replaced with self
[01:26:01] c-c_: and you can't print plain msg rows
[01:27:19] RickHull: that's where i would change the second arg to prepend=false
[01:27:35] RickHull: er, prepend=true
[01:27:46] c-c_: I think the real 'way' would be to try to get Process.pid to print the correct process
[01:27:58] c-c_: but I gotta .zzZ
[01:28:02] RickHull: i'm just saying, don't pass self
[01:30:27] dcluna: has joined #ruby
[01:38:25] enterprisey: has joined #ruby
[01:42:39] cdg: has joined #ruby
[01:42:44] b100s: has joined #ruby
[01:43:59] kryptoz: has joined #ruby
[01:44:04] b100s: hi2all; is it safe to use something like this http://paste.org.ru/?t231gw in web-app to do some periodic job?
[01:44:08] ur5us: has joined #ruby
[01:45:31] RickHull: it's quite simplistic, and it depends on what the block is and what you do with the Thread
[01:45:48] RickHull: but the pattern itself seems reasonable
[01:46:12] RickHull: how do you plan on halting execution or tracking errors?
[01:47:24] juggler: has joined #ruby
[01:49:42] b100s: RickHull, it's going to execute forever, every let's say few hours; tracking errors - is good thought, i didn't think about it yet; defenetly it is not critical job and in case of fail i will just write some err message in log and let main thread to do it's main job as before
[01:50:14] b100s: RickHull, what is important, in my opinion, it's shared database object
[01:50:30] RickHull: I don't know what you mean by that
[01:51:03] b100s: i'm not sure which way should i use it; if i do use it and in the same momen main thread will use it... some strange things may happens
[01:51:31] b100s: RickHull, i have some instance of class which do http requests to DB
[01:51:34] RickHull: if this is just a toy or an exercise, then play around with it
[01:51:51] RickHull: if this is a production app, then maybe consider some more mature background patterns
[01:52:02] RickHull: job schedulers, etc
[01:53:10] RickHull: whether this works well or not depends on what block you pass to it, and what you do with the thread that is returned
[01:53:34] RickHull: error handling, etc
[01:54:16] RickHull: for periodic tasks, I prefer a short running script with an external cron-like scheduler
[01:54:24] RickHull: rather than a long-running ruby process
[02:03:55] guardianx: has joined #ruby
[02:05:57] b100s: RickHull, yep, thanks
[02:09:51] bmurt: has joined #ruby
[02:11:57] ur5us: has joined #ruby
[02:13:07] milardovich: has joined #ruby
[02:18:11] paul0: has joined #ruby
[02:19:41] rkoller: has joined #ruby
[02:21:09] astronavt: has joined #ruby
[02:22:44] waveprop: wat tha fahk
[02:28:17] waveprop: i guest you can't use Rack::Response in each middleware ?/
[02:28:43] waveprop: doing it manually works, of course. like everything else in life
[02:28:53] waveprop: ACTION moves on
[02:29:17] veeti: has joined #ruby
[02:32:18] cagomez: has joined #ruby
[02:36:16] Hexafox[I]: has joined #ruby
[02:36:39] mkaito: is there a more succinct way to do `foo = bar.baz if bar` ?
[02:38:46] jackjackdripper: has joined #ruby
[02:38:51] havenwood: mkaito: Do you want to set foo to nil if no bar? Or must foo not be set to nil and remain unchanged in that case?
[02:39:24] mkaito: it should remain unchanged, or I'd just use bar&.baz
[02:39:55] jphase_: has joined #ruby
[02:40:43] havenwood: mkaito: nope, nothing more succinct
[02:41:09] mkaito: figures. thanks :)
[02:44:43] mim1k: has joined #ruby
[02:47:36] PaulCapestany: has joined #ruby
[02:50:44] gizmore|2: has joined #ruby
[02:54:00] Wirehead_Wannabe: has joined #ruby
[02:54:01] uZiel: has joined #ruby
[02:59:03] konsolebox: has joined #ruby
[02:59:54] d^sh: has joined #ruby
[03:03:08] sucks: has joined #ruby
[03:04:10] cdg: has joined #ruby
[03:05:04] imode: has joined #ruby
[03:12:16] guacamole: has joined #ruby
[03:13:08] JsilverT: has joined #ruby
[03:13:36] coffeecupp: has joined #ruby
[03:14:29] nofxx: has joined #ruby
[03:21:39] orbyt_: has joined #ruby
[03:24:01] kryptoz: has joined #ruby
[03:25:37] alfiemax: has joined #ruby
[03:44:58] BiHi: has joined #ruby
[03:50:27] coffeecupp: has joined #ruby
[03:52:13] cdg: has joined #ruby
[04:01:02] JsilverT: has joined #ruby
[04:01:30] Scriptonaut: has joined #ruby
[04:02:18] sucks_: has joined #ruby
[04:02:54] Scriptonaut: hey, any of y'all do some amateur gamedev in ruby? I was thinking I wanted to make a little game/physics engine in ruby. I got one in es6 I was gonna port to ruby, but not sure what to use. I've heard of gosu, but it seems like gosu does a lot for you, and I want to implement pretty much everything myself (collision detection/resolution, asset loading, game state, sprites, etc)
[04:03:17] Scriptonaut: anyone know of a good library to use that will let me make a window, draw polygons
[04:07:23] JsilverT: has joined #ruby
[04:11:43] RickHull: I would guess that Gosu will let you dive down into primitives
[04:11:54] RickHull: and it's probably a better place to start for exploring
[04:13:08] Scriptonaut: RickHull: ya I just found a guide on getting started with gosu, and it actually doesn't have very much stuff (which is what I want)
[04:13:16] Scriptonaut: however, it has a huge userbase, and very few bugs from what I gather
[04:13:20] Scriptonaut: so it's basically the perfect platform
[04:13:37] RickHull: grip it and rip it!
[04:13:47] Scriptonaut: all it has is a window with a main loop and callbacks (awesome), 2d graphics and text, sound samples/music, and keyboard and mouse input
[04:13:55] Scriptonaut: ya, I'm pretty stoked that it didn't take me very long to find something so promising
[04:18:51] paulf__: has joined #ruby
[04:25:40] jenrzzz: has joined #ruby
[04:30:11] _whitelogger: has joined #ruby
[04:38:20] gix: has joined #ruby
[04:45:18] mim1k: has joined #ruby
[04:52:18] uZiel: has joined #ruby
[04:57:07] govg: has joined #ruby
[04:58:45] Technodrome: has joined #ruby
[04:59:58] lexruee: has joined #ruby
[05:11:25] ahrs: has joined #ruby
[05:12:29] Scriptonaut: has left #ruby: ()
[05:14:10] JsilverT: has joined #ruby
[05:14:37] JsilverT: has joined #ruby
[05:16:05] anisha: has joined #ruby
[05:16:44] JsilverT: has joined #ruby
[05:18:59] dionysus69: has joined #ruby
[05:20:32] mjolnird: has joined #ruby
[05:21:50] enko: has joined #ruby
[05:27:28] iamarun: has joined #ruby
[05:32:11] JsilverT: has joined #ruby
[05:43:43] mim1k: has joined #ruby
[05:44:18] zipace: has joined #ruby
[05:45:55] nolakat: has joined #ruby
[05:49:46] alex``: has joined #ruby
[06:02:52] tao_: has joined #ruby
[06:05:01] jenrzzz: has joined #ruby
[06:05:02] jenrzzz: has joined #ruby
[06:08:04] dinfuehr: has joined #ruby
[06:10:13] reber: has joined #ruby
[06:11:47] vipaca: has joined #ruby
[06:11:50] Exhiled: has joined #ruby
[06:14:19] jenrzzz: has joined #ruby
[06:14:19] jenrzzz: has joined #ruby
[06:21:45] kculpis: has joined #ruby
[06:28:07] Technodrome: has joined #ruby
[06:28:46] andikr: has joined #ruby
[06:29:31] LocaMocha: has joined #ruby
[06:34:52] Exhiled: has joined #ruby
[06:35:04] alfiemax: has joined #ruby
[06:39:28] vipaca: has joined #ruby
[06:39:38] bkxd: has joined #ruby
[06:47:02] aufi: has joined #ruby
[06:49:08] dminuoso: Short of using fiddle, do you see a way to obtain the number of arguments passed?
[06:49:10] dminuoso: (Without using splat args.
[06:49:38] dminuoso: Reason is I want to implement a clean rubyland autocurrying methods.
[06:50:19] RickHull: how does it work with fiddle?
[06:50:26] dminuoso: Right now what I do is: def m(*args) ->(a, b, ...) { ... }[*args]; end
[06:50:48] dminuoso: But that has the problem that the arity of the inner lambda cannot be probed.
[06:51:13] dminuoso: def m(*args) ->(a, b, ...) { ... }.curry[*args]; end
[06:52:22] dminuoso: And I want to constrain the outer method somehow, say def m(a=nil, b=nil); end, but that makes it impossible to know whether a or b have in fact been passed or not.
[06:52:24] dionysus69: has joined #ruby
[06:53:16] dminuoso: asm>> def f(a) v = 1; end
[06:53:17] ruby[bot]: dminuoso: I have disassembled your code, the result is at https://eval.in/896875
[06:58:17] wolakkk: has joined #ruby
[06:58:39] coffeecupp: has joined #ruby
[07:03:39] mtkd: has joined #ruby
[07:05:47] alfiemax: has joined #ruby
[07:08:12] anas: has joined #ruby
[07:10:51] ramfjord: has joined #ruby
[07:22:38] rabajaj: has joined #ruby
[07:25:31] paulf__: has joined #ruby
[07:27:23] iamarun: has joined #ruby
[07:28:37] conta: has joined #ruby
[07:29:00] cdg: has joined #ruby
[07:37:32] hs366: has joined #ruby
[07:42:51] Exhiled: has joined #ruby
[07:45:53] jenrzzz: has joined #ruby
[07:46:13] c0ncealed: has joined #ruby
[07:49:08] ramfjord: has joined #ruby
[07:52:52] hs366: has joined #ruby
[07:57:10] hs367: has joined #ruby
[08:05:38] coffeecupp: has joined #ruby
[08:05:42] biberu: has joined #ruby
[08:07:12] michael3: has joined #ruby
[08:08:59] enterprisey: has joined #ruby
[08:17:44] alfiemax_: has joined #ruby
[08:19:49] claudiuinberlin: has joined #ruby
[08:23:39] ShekharReddy: has joined #ruby
[08:25:30] Dimik: has joined #ruby
[08:25:54] mark_66: has joined #ruby
[08:28:47] iamarun: has joined #ruby
[08:29:47] iamarun: has joined #ruby
[08:30:19] cdg: has joined #ruby
[08:41:36] ur5us: has joined #ruby
[08:44:54] anisha: has joined #ruby
[08:59:52] Silthias: has joined #ruby
[09:00:38] Silthias2: has joined #ruby
[09:04:59] Emmarof: has joined #ruby
[09:05:54] Emmarof: has left #ruby: ()
[09:06:14] guille-moe: has joined #ruby
[09:06:42] kinlo: has left #ruby: ()
[09:07:18] Gabemo: has joined #ruby
[09:13:13] lexruee: has joined #ruby
[09:16:44] bemep64: has joined #ruby
[09:17:04] bemep64: has left #ruby: ()
[09:24:25] cdg: has joined #ruby
[09:25:57] profetes_: has joined #ruby
[09:26:01] shinnya: has joined #ruby
[09:27:00] paulf__: has joined #ruby
[09:28:17] jaruga: has joined #ruby
[09:28:47] burgestrand: has joined #ruby
[09:30:10] ams__: has joined #ruby
[09:32:19] Serpent7776: has joined #ruby
[09:32:58] stoffus: has joined #ruby
[09:35:26] mim1k: has joined #ruby
[09:41:42] wolakkk: has joined #ruby
[09:42:44] gigetoo: has joined #ruby
[09:47:09] larcara: has joined #ruby
[09:49:51] ShalokShalom: has joined #ruby
[09:49:59] Beams: has joined #ruby
[09:52:22] mn3m: has joined #ruby
[09:58:23] quobo: has joined #ruby
[10:00:08] samuel02: has joined #ruby
[10:04:17] adlerdias: has joined #ruby
[10:06:25] adlerdias: has left #ruby: ()
[10:14:36] rabajaj: has joined #ruby
[10:14:53] nowhere_man: has joined #ruby
[10:15:02] GodFather: has joined #ruby
[10:16:40] zanoni: has joined #ruby
[10:17:13] samuel02: has left #ruby: ()
[10:21:07] Silthias: has joined #ruby
[10:23:16] ShalokShalom_: has joined #ruby
[10:23:52] ur5us: has joined #ruby
[10:24:53] apofis: has joined #ruby
[10:36:52] ramfjord: has joined #ruby
[10:38:53] mim1k: has joined #ruby
[10:42:57] gregf_: has joined #ruby
[10:56:49] ldnunes: has joined #ruby
[11:04:47] mim1k: has joined #ruby
[11:08:11] qqmash: has joined #ruby
[11:15:37] growp: has joined #ruby
[11:25:35] guille-moe: has joined #ruby
[11:27:31] jottr: has joined #ruby
[11:32:21] yeticry: has joined #ruby
[11:40:34] enterprisey: has joined #ruby
[11:42:56] Technodrome: has joined #ruby
[11:46:24] tvw: has joined #ruby
[11:46:38] ferr: has joined #ruby
[11:46:47] Psybur: has joined #ruby
[11:47:24] ferr: has left #ruby: ()
[11:56:08] kryptoz: has joined #ruby
[11:57:23] duckpuppy: has joined #ruby
[11:58:03] darkmorph: has joined #ruby
[11:59:55] matthewd: dminuoso: I haven't read context, but maybe you want: `def foo(a = (no_a = true), b = (no_b = true))`
[12:00:36] guacamole: has joined #ruby
[12:07:39] nowhere_man: has joined #ruby
[12:07:47] ldnunes: has joined #ruby
[12:09:16] anas: has joined #ruby
[12:11:32] paulf__: has joined #ruby
[12:23:28] raynold: has joined #ruby
[12:25:18] tcopeland: has joined #ruby
[12:32:39] tomphp: has joined #ruby
[12:32:42] adlerdias: has joined #ruby
[12:32:45] mostlybadfly: has joined #ruby
[12:35:39] truenito: has joined #ruby
[12:35:48] kryptoz: has joined #ruby
[12:43:43] adlerdias: has left #ruby: ()
[12:43:49] _lyte_: has joined #ruby
[12:44:43] aScottishBoat: has joined #ruby
[12:49:46] eszett: has joined #ruby
[12:50:27] milardovich: has joined #ruby
[12:57:18] Psybur: has joined #ruby
[12:57:37] kryptoz: has joined #ruby
[13:00:53] argoneus: why is it not possible to do ary << yield val?
[13:01:07] argoneus: is it because yield val is a function
[13:03:21] argoneus: I have code that looks like
[13:03:31] apeiros: if I understand your question correctly, then because the syntax doesn't allow it. you have to be explicit.
[13:03:35] apeiros: ary << yield(val)
[13:03:58] argoneus: ah, okay, that works
[13:06:36] dminuoso: argoneus: Its invalid with methods as well
[13:06:45] ruby[bot]: dminuoso: # => /tmp/execpad-b83802d2cf08/source-b83802d2cf08:2: syntax error, unexpected tIDENTIFIER, expecting key ...check link for more (https://eval.in/897211)
[13:06:50] dminuoso: >> a + b(c)
[13:06:51] ruby[bot]: dminuoso: # => undefined local variable or method `a' for main:Object (NameError) ...check link for more (https://eval.in/897212)
[13:06:54] cdg: has joined #ruby
[13:07:14] kryptoz: has joined #ruby
[13:08:04] alex``: has joined #ruby
[13:08:14] eszett_: has joined #ruby
[13:08:18] hinbody: has joined #ruby
[13:09:21] jottr: has joined #ruby
[13:12:42] kryptoz: has joined #ruby
[13:13:05] PaulCape_: has joined #ruby
[13:14:04] eszett: has joined #ruby
[13:14:15] larcara: has joined #ruby
[13:18:16] synthroid: has joined #ruby
[13:18:27] ldnunes: has joined #ruby
[13:19:03] Defenestrate: has joined #ruby
[13:24:09] eszett: has left #ruby: ("Leaving")
[13:24:49] hightower2: has joined #ruby
[13:25:31] Barrt: has joined #ruby
[13:26:45] ramfjord: has joined #ruby
[13:31:27] nadir: has joined #ruby
[13:31:37] milardov_: has joined #ruby
[13:32:57] marr: has joined #ruby
[13:37:04] aScottishBoat: What's the craic this morning lads
[13:39:28] marr: has joined #ruby
[13:42:12] alfiemax: has joined #ruby
[13:44:57] rippa: has joined #ruby
[13:46:41] Silthias1: has joined #ruby
[13:47:27] guille-moe: has joined #ruby
[13:48:01] kotk: has joined #ruby
[13:48:14] Technodrome: has joined #ruby
[13:49:10] jphase: has joined #ruby
[13:49:43] mson: has joined #ruby
[13:50:09] jphase: has joined #ruby
[13:50:33] guardianx: has joined #ruby
[13:55:12] alex``: has joined #ruby
[13:58:27] Bish: has joined #ruby
[13:58:40] synthroid: has joined #ruby
[13:59:34] synthroid: has joined #ruby
[14:00:27] yeticry: has joined #ruby
[14:00:30] synthroid: has joined #ruby
[14:01:20] synthroid: has joined #ruby
[14:01:50] kotk: has joined #ruby
[14:03:10] synthroid: has joined #ruby
[14:04:03] synthroid: has joined #ruby
[14:04:12] guardianx: has joined #ruby
[14:06:02] tomphp: has joined #ruby
[14:06:22] jrafanie: has joined #ruby
[14:06:33] oleo: has joined #ruby
[14:07:02] Defenestrate: has joined #ruby
[14:08:51] nolakat: has joined #ruby
[14:09:37] tcopeland: has joined #ruby
[14:14:55] ek926m: has joined #ruby
[14:21:18] milardovich: has joined #ruby
[14:26:01] krawchyk: has joined #ruby
[14:28:35] DLSteve: has joined #ruby
[14:30:51] tomphp: has joined #ruby
[14:31:32] jottr: has joined #ruby
[14:38:20] Silthias: has joined #ruby
[14:39:29] nicolas: has joined #ruby
[14:42:07] Defenestrate: has joined #ruby
[14:42:07] Defenestrate: has joined #ruby
[14:42:13] Silthias1: has joined #ruby
[14:44:08] gnufied: has joined #ruby
[14:45:19] iamarun: has joined #ruby
[14:47:06] petto: has joined #ruby
[14:49:54] MystiqueEnigma: has joined #ruby
[14:57:15] Rapture: has joined #ruby
[14:58:30] Silthias: has joined #ruby
[14:58:40] synthroid: has joined #ruby
[14:59:19] JsilverT: has joined #ruby
[14:59:46] charliesome: has joined #ruby
[15:00:01] herbmillerjr: has joined #ruby
[15:00:49] apparition: has joined #ruby
[15:01:02] polishdub: has joined #ruby
[15:02:34] milardov_: has joined #ruby
[15:03:47] synthroid: has joined #ruby
[15:04:25] nicolas: has left #ruby: ("Konversation terminated!")
[15:04:55] aScottishBoat: has joined #ruby
[15:06:26] MystiqueEnigma: has left #ruby: ()
[15:06:28] elphe: has joined #ruby
[15:07:30] aScottishBoat: Anyone who can help me with Rails help? I can't connect to their irc room
[15:07:46] aScottishBoat: I want to access my rails app using my outward-facing IP address from my GCE VM.
[15:08:06] uZiel: has joined #ruby
[15:08:35] ccooke: aScottishBoat: If you type "/join #RubyOnRails" that should get you to their channel
[15:10:00] aScottishBoat: I just had to reidentify myself. (doh)
[15:10:11] nofxx1: has joined #ruby
[15:10:46] ccooke: no problem
[15:10:47] jottr: has joined #ruby
[15:11:52] Barrt: has joined #ruby
[15:15:55] orbyt_: has joined #ruby
[15:16:04] iamarun: has joined #ruby
[15:20:57] zautomata: has joined #ruby
[15:24:17] alfiemax: has joined #ruby
[15:24:35] aScottishBoat: Well, my question still stands because #RubyOnRails is 100% dead atm.
[15:24:44] aScottishBoat: if anyone can offer some Rails help :)
[15:25:11] coderphive: All the rails r belong 2 us
[15:25:56] larcara: aScottishBoat, did you start server binding the 0.0.0.0 or the public ip?
[15:26:00] burgestrand: aScottishBoat from a rails-standpoint it should be sufficient for you to start the server by binding it to `0.0.0.0` (should bind it to all network interfaces, not just default loopback)
[15:26:14] coderphive: first of all
[15:26:29] coderphive: aScottishBoat: Are you using a web server?
[15:26:54] ramfjord: has joined #ruby
[15:27:14] coderphive: Because you really shouldn't be allowing rails to just serve traffic in production. It's not a web server.
[15:27:17] aScottishBoat: coderphive, no, I'm just `bundle exec rails s -b 0.0.0.0 -p 80` atm, but I get `sudo: bundle: command not found`
[15:27:33] coderphive: Bundler isn't installed
[15:27:34] aScottishBoat: No, I'm doing a POC for my employer. Building ManageIQ from source
[15:27:42] coderphive: aScottishBoat: what OS are you on?
[15:27:56] aScottishBoat: `36:bundler (1.15.4)`
[15:28:10] aScottishBoat: gem list | grep -n "bundler" # => 36:bundler (1.15.4)
[15:28:21] coderphive: aScottishBoat: do `cat /etc/*release*
[15:28:29] coderphive: without the tick
[15:29:00] dionysus69: has joined #ruby
[15:29:20] aScottishBoat: https://gist.github.com/naltun/46113c5bf43ed663b874d7b5a060a61c
[15:29:31] coderphive: good old CentOS. piece of garbage
[15:29:50] aScottishBoat: only cuz there are no Fedora GCE images -_-
[15:29:58] aScottishBoat: personally, I use Debian/Ubuntu + Antergos
[15:30:09] Technodrome: has joined #ruby
[15:30:14] coderphive: Debian/Ubuntu/CoreOS > *
[15:30:24] coderphive: anyway, I digress
[15:30:39] coderphive: You need to install bundler
[15:30:46] aScottishBoat: coderphive, xD But anyways, bundler works just not with sudo
[15:31:03] coderphive: type bundle, what happens
[15:31:06] aScottishBoat: bundler -v # => Bundler version 1.15.4
[15:31:23] coderphive: okay, then bundler is not in your sudo path
[15:31:24] aScottishBoat: The latest bundler is 1.16.0, but you are currently running 1.15.4.To update, run `gem install bundler`Could not locate Gemfile
[15:31:25] bigkevmcd: has joined #ruby
[15:31:31] cschneid_: has joined #ruby
[15:31:34] aScottishBoat: That's what I thought. I'm not sure how to add it though
[15:31:57] coderphive: well, Bundler shouldn't be executed as root :)
[15:32:09] aScottishBoat: I get this when I run `rails s -b...` without sudo
[15:32:13] coderphive: I think it actually shoots you a sweet message about that
[15:33:03] coderphive: You want to do a bundle install --deployment
[15:33:10] coderphive: so it stores your gems locally
[15:33:24] aScottishBoat: https://gist.github.com/naltun/116ffaf8aa4c18ff42fc95d55429035a
[15:34:48] coderphive: does netstat -a show anything else binding to port 80?
[15:34:57] moei: has joined #ruby
[15:35:06] coderphive: Sorry - let's reset
[15:35:17] coderphive: A) you need to run on a non-privileged port
[15:35:57] coderphive: B) In order to run rails in prod under port 80 you need to use Nginx + Unicorn or something similar to proxy requests to your app
[15:36:12] aScottishBoat: It doesn't need to be port 80.
[15:36:26] aScottishBoat: Oh wait, I just `bundle exec rails s -b 0.0.0.0 -p 3000` and it worked
[15:36:31] coderphive: then launch it on an unprivileged port
[15:36:36] coderphive: or a port > 1024
[15:36:51] coderphive: Do you want me to explain that to you?
[15:37:03] coderphive: (Why it worked)
[15:37:09] aScottishBoat: Sure, learning is good.
[15:37:31] coderphive: 1-1024 are privileged ports (ports that need to be run as root)
[15:37:58] coderphive: > 1024 are unprivileged ports which can be run as any user
[15:38:21] coderphive: In > 1024 you jail that user somehow and then proxy requests from a web server TO it
[15:38:25] coderphive: (in production)
[15:38:54] aScottishBoat: Man, coderphive you're awesome. Thanks mate
[15:39:26] dminuoso: "privileged" ports was such a silly concept honestly.
[15:39:26] duckpuppy: has joined #ruby
[15:39:44] dminuoso: Whoever came up with the idea deserves to be shot, hanged, cruficied, clone back to life and killed again.
[15:40:02] aScottishBoat: Why is it that bad dminuoso?
[15:40:13] aScottishBoat: Mind you: I've done a bit of web dev, but networking is not my domain.
[15:40:43] coderphive: dminuoso That's not true
[15:40:43] dminuoso: aScottishBoat: Do you know what the intend was?
[15:41:07] coderphive: Privileged ports have a very viable existence
[15:41:29] coderphive: Although I can understand why the concept is frustrating to a developer
[15:41:44] dminuoso: It's to promote the idea, that if you connect to a remote service, and it was listening to such a "privileged port", that you could trust the service more, because it took administrative rights to listen to that port.
[15:41:44] dminuoso: In reality it tells you nothign.
[15:41:49] uZiel: has joined #ruby
[15:41:57] coderphive: dminuoso that's not true
[15:42:02] coderphive: Can you cite that?
[15:42:20] dminuoso: A service is not more trustworthy just because it implies whoever is running it has root access.
[15:43:03] coderphive: I think you miss the point
[15:44:09] milardovich: has joined #ruby
[15:44:12] coderphive: It's about user separation, which is fairly effective, and abiding by the principal of least privilege
[15:44:30] aScottishBoat: Principal of Least Privilege... never heard of it. What's that coderphive?
[15:44:48] coderphive: Mostly a Linux concept, but fairly universal overall
[15:45:05] coderphive: Basically you give a user the least about of privilege they need to perform their job
[15:45:11] coderphive: In automation this is pretty key
[15:45:52] coderphive: Your app may run as the user "puma" in the group "puma". Maybe it owns a directory called "/opt/puma".
[15:46:29] coderphive: The implication is that if I find a way to hack whatever your app is, all I have access to is that directory and nothing else on the system
[15:46:42] veeti: has joined #ruby
[15:47:11] coderphive: the concept of privileged ports isn't as cut and dry as dminuoso put it, but they're somewhat correct
[15:47:35] dminuoso: coderphive: https://www.w3.org/Daemon/User/Installation/PrivilegedPorts.html
[15:47:39] coderphive: ie: in respect to a web server - nginx runs as the user "nginx", so how does it bind to a privileged port?
[15:47:46] dminuoso: I'd say that is as good a citation as it can get.
[15:48:18] Barrt: has joined #ruby
[15:48:27] coderphive: nginx spawns a process that handles requests. That process _only_ handles requests and is run as root through systemd
[15:48:37] dminuoso: coderphive: But feel free to provide evidence to the contrary.
[15:48:54] coderphive: everything else is run under nginx (ie, the more potentially vulnerable parts of the code)
[15:49:38] coderphive: I think nginx has actually revised this to it binds the port to the service and then exits
[15:49:49] coderphive: so it all has to be setup through systemd
[15:50:31] darix: coderphive: having the app be able to write its code is just stpuid
[15:50:42] darix: and sadly many tools do that
[15:50:53] coderphive: Yeah, I'd agree
[15:51:01] darix: so my gitlab package e.g. has root:gitlab u=rwX,g=rX,o= as permission set
[15:51:16] darix: and only tmp/ and public/ have partially gitlab:gitlab u=rwX,g=rX,o=
[15:51:17] coderphive: idk, I'm an infrastructure automator, so I do this stuff a lot differently than most of you probably do :P
[15:51:49] darix: coderphive: i am a packager who likes secure over convenient packages ;)
[15:52:17] dminuoso: ACTION pokes jokke with a monad
[15:52:19] coderphive: But, if someone is just totally frustrated and I can't help them, I'd rather they settle with some sort of compromise
[15:52:39] coderphive: not that what they're doing is good, but it's better than being the worst :P
[15:52:50] elbuki: has joined #ruby
[15:52:53] jokke: what stubbing lib would you recommend for minitest. i need something like rspec's instance_double(...) and allow(foo).to receive(...)
[15:53:21] jokke: i tried Spy but i hate the interface
[15:54:00] aScottishBoat: Not sure -- guys?
[15:54:05] dminuoso: jokke: Doesnt minitest have Object#stub ?
[15:54:28] jokke: dminuoso: i need to be able to check if the method has been called
[15:54:39] jokke: and if so with what args
[15:55:02] jokke: i'm unit testing something that reads from and writes to sockets
[15:55:13] jokke: so i'm stubbing out the socket
[15:55:40] dminuoso: "unit testing", "need to check if the method has been called"
[15:56:00] dminuoso: White box unit testing?
[15:57:32] jokke: what do you mean
[16:02:10] jokke: another thing: what happens with stderr in IO.popen?
[16:02:21] nogic: has joined #ruby
[16:02:40] jokke: i thought it would be forwarded to STDERR but seems like it goes nowhere
[16:05:12] burgestrand: jokke how about using IO.pipe and reading the data in the other end?
[16:05:21] burgestrand: (as opposed to stubbing it out)
[16:05:59] burgestrand: jokke also check out open3 (https://ruby-doc.org/stdlib-2.4.1/libdoc/open3/rdoc/Open3.html)
[16:07:09] cschneid_: has joined #ruby
[16:08:02] coderphive: HOLD THE PHONE
[16:08:06] truenito: has joined #ruby
[16:13:40] Barrt: has joined #ruby
[16:16:54] gregf_: has joined #ruby
[16:19:50] cagomez: has joined #ruby
[16:22:56] vipaca: has joined #ruby
[16:23:01] remix2000: has joined #ruby
[16:23:07] alfiemax: has joined #ruby
[16:25:33] milardov_: has joined #ruby
[16:26:28] milardov_: has joined #ruby
[16:27:55] AnoHito: has joined #ruby
[16:32:36] alfiemax: has joined #ruby
[16:32:54] synthroid: has joined #ruby
[16:33:28] profetes__: has joined #ruby
[16:34:57] jaruga: has joined #ruby
[16:36:18] marr: has joined #ruby
[16:38:08] jokester_: has joined #ruby
[16:38:41] quobo: has joined #ruby
[16:39:56] synthroid: has joined #ruby
[16:41:23] truenito: has joined #ruby
[16:41:23] kryptoz: has joined #ruby
[16:44:00] armando: has joined #ruby
[16:45:05] PaulCapestany: has joined #ruby
[16:45:13] Barrt: has joined #ruby
[17:02:32] bigkevmcd: has joined #ruby
[17:03:40] troys: has joined #ruby
[17:06:38] raynold: has joined #ruby
[17:06:58] milardovich: has joined #ruby
[17:08:48] tomphp: has joined #ruby
[17:11:21] sucks: has joined #ruby
[17:12:33] milardov_: has joined #ruby
[17:14:00] truenito: has joined #ruby
[17:14:17] jottr: has joined #ruby
[17:15:54] larcara: has joined #ruby
[17:16:18] larcara: has joined #ruby
[17:17:07] jenrzzz: has joined #ruby
[17:17:07] jenrzzz: has joined #ruby
[17:17:33] jrafanie_: has joined #ruby
[17:21:36] mniip: has joined #ruby
[17:23:12] cagomez: is a variable declared in a begin block accessible in the an exception rescue? eg item = db_op; rescue RecordInvalid => e; puts items.errors; end
[17:23:28] nowhere_man: has joined #ruby
[17:26:08] elbuki: has joined #ruby
[17:27:08] ramfjord: has joined #ruby
[17:28:16] sucks: has joined #ruby
[17:33:06] alfiemax: has joined #ruby
[17:33:23] Exhiled: has joined #ruby
[17:35:35] roamingdog: has joined #ruby
[17:39:52] stoopidmunkey: has joined #ruby
[17:41:11] Caius: cagomez: it should be, but only if the error was raised after it was assigned
[17:42:31] cagomez: Caius: in my case, db_op is a transaction that calls yet another method db_op2. db_op2 is blowing up and doesn't return an object
[17:43:05] Caius: If it errors before the assigment (ie, calling the code after =) then the variable won't have been set
[17:43:57] cagomez: ah I see. is the exception text the same as what would have been on the item itself? in other words, is `RecordInvalid => e` the same as what would have been in item.errors ?
[17:44:06] Caius: https://gist.github.com/caius/7a2241080007c190a7ea064da7024511
[17:44:13] Caius: no, e is the exception object that's raised
[17:44:32] hopsoft: has joined #ruby
[17:44:51] Caius: If RecordInvalid stores the errors on itself, you might be able to use that
[17:44:55] cagomez: yup Caius , that's exactly what's happening
[17:45:16] cagomez: yes, I can see a Validation Error on e
[17:46:28] claudiuinberlin: has joined #ruby
[17:47:45] cagomez: what do you think of this Caius? https://hastebin.com/iqehavujaq.rb
[17:48:15] Caius: That would work, sure :-)
[17:48:57] Caius: I'd be tempted to try and add it as a validation to the model so it adds the error before saving & saves you having to rescue it
[17:49:10] Caius: But there's many ways to skin that cat, and sometimes you just need it to work :-D
[17:49:36] cagomez: yes this is the latter case, for sure. a bunch of legacy code to work around
[17:50:53] tomphp: has joined #ruby
[17:51:01] cdg: has joined #ruby
[17:51:24] imode: has joined #ruby
[17:53:23] Asher: has joined #ruby
[17:54:43] al2o3-cr: has joined #ruby
[17:58:53] Sparky2: has joined #ruby
[18:00:54] Sparky2: I have questions
[18:01:22] Sparky2: First, is this a fair definition? % - Percent - doesn't do percentages when used in ruby math, instead does some weird jiggery pokery with remainders.
[18:03:54] Sparky2: Second, when I define the usage of (), in my early days of learning, is it fair for me to say that it holds arguments?
[18:05:51] Eiam: has joined #ruby
[18:08:00] tomphp_: has joined #ruby
[18:10:30] baweaver: Sparky2: It's called modulo - http://ruby-doc.org/core-2.4.0/Integer.html#method-i-25
[18:10:57] jokke: i'll just ask again
[18:11:07] jokke: what stubbing lib would you recommend for minitest. i need something like rspec's instance_double(...) and allow(foo).to receive(...)
[18:12:14] baweaver: Sparky2: re (), what now? Explain
[18:12:17] petto: has joined #ruby
[18:12:19] Barrt: has joined #ruby
[18:12:33] baweaver: jokke: Haven't really used Minitest or I'd answer
[18:12:57] ramfjord: has joined #ruby
[18:13:22] nowhere_man: has joined #ruby
[18:13:59] sucks: has joined #ruby
[18:14:03] baweaver: Articles like this are popping up in Google for it - https://semaphoreci.com/community/tutorials/mocking-in-ruby-with-minitest
[18:14:18] jokke: baweaver: lucky you
[18:14:24] jokke: minitest is pita
[18:15:56] cagomez: Caius : return an invalid record with its errors; https://apidock.com/rails/ActiveRecord/RecordInvalid . gonna use e.record.errors :)
[18:16:00] baweaver: No need to be snarky.
[18:16:17] orbyt_: has joined #ruby
[18:16:39] Sparky2: baweaver: I've been studying for a few days, and so far I've learned that () will hold arguments, example: def number (arg1, arg2)
[18:16:54] Sparky2: baweaver: I was wondering I I missed something with the ()
[18:17:19] baweaver: To be fair you could also write that as: def number a, b
[18:17:22] mim1k: has joined #ruby
[18:17:26] baweaver: the parens aren't required
[18:17:30] baweaver: but they clarify intent
[18:17:57] baweaver: It's a way to pass or define arguments
[18:18:16] baweaver: Also used arbitrarily in math scenarios to override order of operations
[18:18:36] baweaver: or getting a method called on a range: (1...5).each
[18:18:37] Sparky2: Oh boy, when people told me that ruby has various ways of doing things.... they weren't kidding
[18:18:43] baweaver: or several other things
[18:19:13] baweaver: Hence me thinking that describing parens as holding arguments was kind of odd
[18:22:13] jokke: Sparky2: there's a style guide though
[18:23:58] milardovich: has joined #ruby
[18:24:16] baweaver: https://github.com/bbatsov/ruby-style-guide
[18:24:22] baweaver: Typically that one.
[18:24:39] baweaver: Rubocop and other editor linters typically build from it
[18:26:33] Exhiled: has joined #ruby
[18:30:48] jrafanie: has joined #ruby
[18:31:07] mim1k: has joined #ruby
[18:34:18] Dimik: has joined #ruby
[18:37:00] Cohedrin: has joined #ruby
[18:39:26] shinnya: has joined #ruby
[18:43:01] Exhiled: has joined #ruby
[18:45:04] johnny56_: has joined #ruby
[18:48:51] darkmorph: has joined #ruby
[18:48:59] Sparky2: Could someone send me some broken code please?
[18:49:18] Sparky2: Nothing super complex, maybe 30 lines or so
[18:50:12] michael3: has joined #ruby
[18:50:23] kies: has joined #ruby
[18:51:15] havenwood: Sparky2: Whatcha looking for broken code for?
[18:51:28] mim1k: has joined #ruby
[18:51:38] Sparky2: havenwood: So I can try to fix it.. you know, a learning proccess
[18:53:17] xco: has joined #ruby
[18:53:18] havenwood: Sparky2: Sure, I'll give you a small example. Sec.
[18:55:37] dviola: has joined #ruby
[18:56:49] wilbert: has joined #ruby
[18:57:17] Bish: Sparky2: like syntax error?
[18:58:12] Barrt: has joined #ruby
[18:58:23] Sparky2: My lesson that I'm doing basically told me to find ruby code example and try to understand it, but I thought it would be more fun to unsderstand and fix code that isn't working
[19:01:20] guacamole: has joined #ruby
[19:01:42] roadrunneratwast: has joined #ruby
[19:02:08] alfiemax: has joined #ruby
[19:02:22] mim1k: has joined #ruby
[19:03:29] havenwood: Sparky2: https://gist.github.com/havenwood/1a11c66dd128dbb42df7a79a6f2d85e4
[19:03:57] Xiti: has joined #ruby
[19:04:03] havenwood: Sparky2: If you run this code like `ruby sparky.rb` you'll see the tests fail. Once you've fixed the code, all the tests should pass.
[19:07:03] vipaca: has joined #ruby
[19:07:37] Sparky2: havenwood: Okay, so I have some research do do on classes and assert
[19:08:52] roadrunneratwast: has left #ruby: ()
[19:09:19] uZiel: has joined #ruby
[19:09:44] mim1k: has joined #ruby
[19:10:31] Cohedrin: has joined #ruby
[19:11:01] dminuoso: What method name for <*> ?
[19:11:31] jackjackdripper: has joined #ruby
[19:12:09] dminuoso: (.ap is a bit too general, as I want something that only applies to strong lax monoidal functors)
[19:14:59] havenwood: dminuoso: hmmmm
[19:15:12] Psybur: has joined #ruby
[19:15:32] jackjackdripper: has joined #ruby
[19:16:11] Sparky2: havenwood: I've totally not covered most of the uhmm.. tools? Right, those tools aren't in my coding toolbelt yet, so I'm having to do a bit of googling to figure out what a lot of it does
[19:17:03] havenwood: dminuoso: .squish, i dunno!
[19:18:06] havenwood: splat sammish?
[19:20:29] ur5us: has joined #ruby
[19:20:42] jenrzzz: has joined #ruby
[19:20:42] jenrzzz: has joined #ruby
[19:21:56] mim1k: has joined #ruby
[19:24:43] kies: has joined #ruby
[19:25:13] Barrt: has joined #ruby
[19:31:39] xco: has joined #ruby
[19:35:02] Barrt: has joined #ruby
[19:36:19] sucks_: has joined #ruby
[19:36:58] sucks_: has joined #ruby
[19:37:15] A124: has joined #ruby
[19:37:38] enterprisey: has joined #ruby
[19:40:43] johno84: has joined #ruby
[19:41:31] wilbert: has joined #ruby
[19:42:38] mim1k: has joined #ruby
[19:43:43] RickHull: has joined #ruby
[19:44:40] Barrt: has joined #ruby
[19:45:54] ramfjord: has joined #ruby
[19:45:57] uZiel: has joined #ruby
[19:46:08] anisha: has joined #ruby
[19:47:38] PaulCapestany: has joined #ruby
[19:47:55] mikecmpbll: has joined #ruby
[19:47:57] nopolitica: has joined #ruby
[19:48:21] jrafanie: has joined #ruby
[19:49:56] jenrzzz: has joined #ruby
[19:54:49] guille-moe: has joined #ruby
[19:55:09] weaksauce: has joined #ruby
[19:56:22] cdg: has joined #ruby
[19:56:41] Freshnuts: has joined #ruby
[19:57:48] mim1k: has joined #ruby
[19:58:06] ur5us: has joined #ruby
[19:58:27] Psybur: has joined #ruby
[20:07:29] Xiti: has joined #ruby
[20:09:43] mim1k: has joined #ruby
[20:13:18] Sightes: has joined #ruby
[20:14:33] cdg_: has joined #ruby
[20:18:07] Rapture: has joined #ruby
[20:26:22] guacamole: has joined #ruby
[20:26:26] troulouliou_div2: has joined #ruby
[20:26:58] zautomata: has joined #ruby
[20:32:37] AnoHito: has joined #ruby
[20:33:12] DTZUZO: has joined #ruby
[20:43:52] stoopidmunkey: has joined #ruby
[20:44:16] xco_: has joined #ruby
[20:46:03] stoopidmunkey: has joined #ruby
[20:47:31] Barrt: has joined #ruby
[20:49:16] ozcanesen: has joined #ruby
[20:50:51] synthroid: has joined #ruby
[20:51:45] minimalism: has joined #ruby
[20:52:36] orbyt_: has joined #ruby
[20:58:21] michael3: has joined #ruby
[20:59:33] mim1k: has joined #ruby
[21:01:03] synthroid: has joined #ruby
[21:04:14] urk187: has joined #ruby
[21:05:18] ramfjord: has joined #ruby
[21:08:11] tomphp: has joined #ruby
[21:08:33] ozcanesen: has joined #ruby
[21:10:06] mochiyoda_: has joined #ruby
[21:15:48] mim1k: has joined #ruby
[21:17:09] tomphp: has joined #ruby
[21:17:30] |ifei5g00d: has joined #ruby
[21:18:35] |ifei5g00d: has joined #ruby
[21:21:44] br0d1n: has joined #ruby
[21:23:29] cagomez: has joined #ruby
[21:23:55] enterprisey: has joined #ruby
[21:25:34] synthroid: has joined #ruby
[21:28:50] stoopidmunkey: has joined #ruby
[21:29:23] mostlybadfly: has joined #ruby
[21:29:52] mim1k: has joined #ruby
[21:29:55] pilne: has joined #ruby
[21:32:19] PaulCape_: has joined #ruby
[21:35:09] tlaxkit: has joined #ruby
[21:37:54] yusuf34: has joined #ruby
[21:38:48] PaulCapestany: has joined #ruby
[21:41:36] yusuf34: has left #ruby: ("Leaving")
[21:42:06] PaulCapestany: has joined #ruby
[21:47:16] orbyt_: has joined #ruby
[21:51:16] Cohedrin: has joined #ruby
[22:05:28] yabbes: has joined #ruby
[22:13:41] xco: has joined #ruby
[22:16:30] alveric4: has joined #ruby
[22:18:40] dkotlica: has joined #ruby
[22:18:48] dkotlica: has left #ruby: ()
[22:19:23] p0p0pr37: has joined #ruby
[22:20:13] mim1k: has joined #ruby
[22:20:48] br0d1n: has joined #ruby
[22:21:29] thinkpad: has joined #ruby
[22:23:39] jaruga: has joined #ruby
[22:24:03] FrostCandy: has joined #ruby
[22:24:20] InfinityFye: has joined #ruby
[22:25:42] FrostCandy: I have a line like :query => params[:search][:query], I want to see if [:query] is present, if not then put '' in :query. something like this :query => ((params[:search][:query].present?) ? params[:search][:query] : '') would that work?
[22:26:22] apeiros: FrostCandy: do you care about present but nil/false?
[22:26:33] apeiros: if not, params.dig(:search, :query) || ''
[22:26:50] apeiros: assuming you're actually talking about a nested hash, and not ActionController::Params
[22:27:15] FrostCandy: oh i think it is actionController actually
[22:27:23] FrostCandy: i guess this was a rails question :P
[22:27:26] havenwood: FrostCandy: Will `params.key?(:search) #=> true` always be true?
[22:27:45] havenwood: >> nil.to_s
[22:27:46] ruby[bot]: havenwood: # => "" (https://eval.in/897756)
[22:27:53] FrostCandy: no , if :search doesn't exist i want to use a ''
[22:28:14] FrostCandy: params.key?(:search) could be non-existant so false
[22:28:22] havenwood: FrostCandy: Then I like apeiros' solution. since it's slightly more straightforward than: params.dig(:search, :query).to_s
[22:28:26] jenrzzz: has joined #ruby
[22:28:38] havenwood: Though that ^ works too
[22:30:08] FrostCandy: oh ok I see what you did. Can you write if statements in ruby like php ? So x = ((true) ? 1 : 0)
[22:30:24] RickHull: yes, the ternary operator
[22:30:32] havenwood: FrostCandy: you can, but you don't need it here
[22:30:43] FrostCandy: nope, apeiro's solution is correct for me here.
[22:32:25] apeiros: /nick apeiro
[22:32:34] apeiros: since apparently, that's me now
[22:32:45] duckpuppy: has joined #ruby
[22:32:53] eckhardt: has joined #ruby
[22:33:02] havenwood: sounds refreshing, maybe an apertif
[22:33:27] jenrzzz_: has joined #ruby
[22:33:32] apeiros: ACTION hands havenwood an i, just for good measure
[22:34:04] havenwood: ACTION joins the drop rando letters club
[22:34:09] adaedra: /nick apéro
[22:34:18] banisterfiend: has joined #ruby
[22:34:31] apeiros: sadly not valid :(
[22:37:15] FrostCandy: apeiros: undefined method `dig' for #<ActionController::Parameters - like you said , is there an alternative for rails or should i ask in a ralis forum
[22:37:21] weaksauce: has joined #ruby
[22:38:25] apeiros: you can always patch monkey sense into rails
[22:38:31] apeiros: but yeah…
[22:38:33] apeiros: ?rails FrostCandy
[22:38:33] ruby[bot]: FrostCandy: Please join #RubyOnRails for Rails questions. You need to be identified with NickServ, see /msg NickServ HELP
[22:39:05] elphe_: has joined #ruby
[22:46:09] xco: has joined #ruby
[22:49:03] havenwood: Or PR it into Rails. :-)
[22:49:24] apeiros: ACTION never prs again to rails
[22:50:25] dminuoso: apeiros: Or you could use my lens library!
[22:50:46] dminuoso: view(queryL, params) :o
[22:53:41] dminuoso: apeiros: https://gist.github.com/dminuoso/32666faa0dbfe7c0448bc34ded75b579
[22:54:01] apeiros: I better don't read the code :-p
[22:54:02] dminuoso: This can be neatly adapted to also support "conditionally" traversing.
[22:54:10] dminuoso: apeiros: Just look at the end for usage.
[22:54:13] dminuoso: Ignore the implementation.
[22:54:41] dminuoso: apeiros: It's kind of like Hash#dig but in a far more general and composable way.
[22:55:12] apeiros: I think somebody implemented something like xpath for ruby. forgot the name, though
[22:56:39] elomatreb: When you think "I want to probe this Hash with XPath" you should reevaluate your life decisions
[22:57:20] apeiros: arbitrary object tree
[22:57:23] dminuoso: elomatreb: Im not entirely convinced. Much like dig or lenses they encompass the idea of separating the "how do I get there" with "applying it" and "using it"
[22:57:32] dminuoso: apeiros: Yeah, and lenses are even more general.
[22:57:33] apeiros: for debugging, I can actually imagine that being quite nice
[22:57:59] apeiros: for other things, demeter might want to have a word with you
[22:58:09] apeiros: (though, I actually tend to ignore demeter quite a bit)
[22:58:17] dminuoso: apeiros: What I just did is the most basic functionality that allows you to take a lens (Which just focuses on a single object in some arbitrary structure), and then set lets you change that exact value, view lets you see it, and over lets you change it.
[22:59:05] dminuoso: And its done in a way that you can just combine lenses (much like lenses in optics can just be placed behind each other to combine effects)
[22:59:20] apeiros: sounds nice
[23:00:35] RickHull: dminuoso: NameError: undefined local variable or method `w' for L:Module
[23:00:41] RickHull: when I pasted into irb
[23:01:06] dminuoso: RickHull: Ohh sorry one sec, mishap during vim
[23:01:24] dminuoso: RickHull: replace that w with s
[23:01:40] dminuoso: Argh one moment let me fix it
[23:01:41] jenrzzz: has joined #ruby
[23:03:08] RickHull: dminuoso: any opportunity to slip in something like: w.(t, f)
[23:03:09] dminuoso: RickHull: https://gist.github.com/dminuoso/095dc1c99165f0c76a82c8ea36af9757
[23:03:35] dminuoso: RickHull: That shows various usages.
[23:03:41] mim1k: has joined #ruby
[23:04:54] dminuoso: RickHull: Oh I fail at reading. should have been `w` not `f`. Its a bit hard to read the ruby version of it.
[23:05:32] tvw: has joined #ruby
[23:05:51] dminuoso: https://gist.github.com/dminuoso/4079510005d0aa988cdd5a849fcf6362 this is the current version.
[23:06:31] darkmorph: has joined #ruby
[23:07:42] RickHull: ya know, they make these things called github repos... ;)
[23:07:42] Xiti: has joined #ruby
[23:09:10] RickHull: can we rename s to w, f to t, and t to f?
[23:09:19] RickHull: and L107 will be w.(t, f)
[23:10:26] dminuoso: s to w is fine, but why f<>t?
[23:10:32] RickHull: that will make your WTFs per line of code go up
[23:11:03] adaedra: ops, they're doing nasty things
[23:12:07] dminuoso: RickHull: I decided to not make a repo until I have studied the more magical lens things in Haskell
[23:12:41] RickHull: i've saved all your prior versions so I can still shame you with them
[23:12:54] dminuoso: That's fine, it's not as much about shame really.
[23:13:40] dminuoso: -> (get, set, to_functor, transform) { to_functor.(get.(transform)).fmap(-> (f) { set.(f, transform) })}.curry[*args]
[23:13:43] dminuoso: Perhaps thats slightly better
[23:14:27] RickHull: to my eyes, for sure
[23:18:27] cschneid_: has joined #ruby
[23:20:58] mim1k: has joined #ruby
[23:21:08] dminuoso: RickHull: So how about it. Got any solution for tackling those lambdas?
[23:21:47] RickHull: er, what's the problem? I doubt I will be helpful and my WTFs / LoC is still too high
[23:22:33] RickHull: I really like this stuff but I need to study it more before it is sensible to me
[23:22:47] RickHull: and I'm working on mruby stuff which is a whole different ballgame
[23:24:23] duckpuppy: has joined #ruby
[23:28:57] jenrzzz: has joined #ruby
[23:28:57] jenrzzz: has joined #ruby
[23:29:26] Lytol: has joined #ruby
[23:29:59] Xiti`: has joined #ruby
[23:32:16] duckpuppy: has joined #ruby
[23:33:57] jenrzzz: has joined #ruby
[23:34:10] dminuoso: RickHull: https://gist.github.com/dminuoso/b1f4e6ce6c273c1ab29b5443a3f50560
[23:34:12] dminuoso: I want to be able to do this.
[23:34:45] dminuoso: class Module; def defc(name, lmbda) define_method name { |*args| lmbda.curry.instance_exec(*args, &self) }; end; end;
[23:34:51] dminuoso: this is not enough because I still need that self.
[23:35:06] dminuoso: And I dont know how to get that self back in.
[23:36:34] dminuoso: About the only thing I can think of is rigging .curry
[23:37:19] RickHull: the most I can contribute right now is a name for your project https://en.wikipedia.org/wiki/Lambada
[23:37:43] matthewd: Which self to the what?
[23:37:53] cagomez: has joined #ruby
[23:37:53] dminuoso: Ohh I could just do instance_exec(*args, &lmbda.curry)
[23:38:23] dminuoso: o/ matthewd
[23:40:18] blackmesa: has joined #ruby
[23:40:37] darkmorph: has joined #ruby
[23:41:37] dtzuzu: has joined #ruby
[23:45:15] mson: has joined #ruby
[23:46:48] dminuoso: matthewd: https://eval.in/897769
[23:48:08] dminuoso: Or even https://eval.in/897772
[23:49:08] bmurt: has joined #ruby
[23:49:24] bronson_: has joined #ruby
[23:49:42] matthewd: dminuoso: https://eval.in/897773
[23:50:03] darkmorph: has joined #ruby
[23:52:08] dminuoso: matthewd: Ohh, instance_method. Nice trick.
[23:52:22] dminuoso: This is lovely thanks.
[23:52:39] matthewd: Yeah AFAIK that's the only fiddle-less way to convert a proc to a lambda
[23:53:03] matthewd: And as we already know that name is about to be overwritten, we're free to shove something else in there for a moment ¯\_(ツ)_/¯
[23:54:12] jenrzzz: has joined #ruby
[23:54:12] jenrzzz: has joined #ruby
[23:55:16] _main_: has joined #ruby
[23:56:18] _main_: has joined #ruby
[23:58:18] romain_t: has joined #ruby
[23:58:41] RickHull: what is being achieved here?
[23:59:27] ur5us: has joined #ruby
[23:59:47] RickHull: I can see how [1,2,3].app.(4) appends 4 (while print-debugging?)
[23:59:59] dminuoso: RickHull: Autocurrying methods