« Back to channel list

#ruby - 03 March 2019

« Back 1 day Forward 1 day »
[00:04:14] jmcgnh: has joined #ruby
[00:09:40] t0x: has joined #ruby
[00:22:50] mangold: has joined #ruby
[00:35:14] cnsvc_: has joined #ruby
[00:39:16] minimal_life: has joined #ruby
[00:42:39] al2o3-cr: phaul: how's the gist going?
[00:43:12] phaul: I was with family today, haven't even started it
[00:43:20] phaul: started bit of refactor
[00:43:37] phaul: probably something for tomorrow
[00:45:01] phaul: should be easy enough. thinking about it gave one of those heureka moments about design, that when you realize it you just know it's right.
[00:46:18] phaul: so there was this class handling the Evaluation commands. Sending, receiving stuff and handling the bot command. many responsibilities.
[00:48:09] phaul: then I realized. I just need an object that's getting a request, and has a response method and gives you a reponse. (all objects request - service - response - with single responsibility)
[00:48:40] phaul: then it should be easy to generalize over sending stuff to carc in
[00:49:13] ogres: has joined #ruby
[00:50:12] ogres: has joined #ruby
[00:50:35] al2o3-cr: phaul: Nokogiri(open(url)).css('td').map(&:text).reject(&:empty?).join("\n").gsub(/\n\n\n/, "\n\n") then pass that to your evaluator. happy days :)
[00:50:52] al2o3-cr: don't forget to error check and shit.
[00:52:23] phaul: I know I'm weird but Im a firm beleiver in "sandi metz code" and shit. mainly shit. but the bot code is 100 % reek-ed
[00:52:44] phaul: https://github.com/troessner/reek
[00:53:52] al2o3-cr: regex != parse
[00:54:40] al2o3-cr: phaul: oh, and have a good day!
[00:56:18] phaul: btw what do you mean by regex != parse?
[00:56:58] phaul: I mean I think I 100% agree with that statement, but why did you point it out?
[00:57:08] wildermind: has joined #ruby
[00:59:12] al2o3-cr: meaning regex is more than enough.
[01:01:05] phaul: I see. That's valid point.
[01:03:18] rubydoc: stderr: -e:2:in `<main>': undefined method `foo' for main:Object (NoMethodError) (https://carc.in/#/r/6egn)
[01:03:23] rubydoc: stderr: -e:3: syntax error, unexpected end (https://carc.in/#/r/6ego)
[01:03:30] rubydoc: stderr: -e:2:in `<main>': undefined local variable or method `foo' for main:Object (NameError) (https://carc.in/#/r/6egp)
[01:03:54] rubydoc: stderr: -e:4: unterminated regexp meets end of file (https://carc.in/#/r/6egq)
[01:04:24] rubydoc: stderr: -e:2:in `<main>': uninitialized constant Ob (NameError) (https://carc.in/#/r/6egr)
[01:05:00] rubydoc: parser error at position 0 around `t'
[01:06:15] phaul: as the grammar gets more and more complex, though, parslet scales nicely. and it's still readable
[01:06:40] phaul: bunch of regexps at this scale would be simply horrendous
[01:06:41] al2o3-cr: overkill imo :)
[01:07:32] al2o3-cr: why? regexp matches or doesn't. simple
[01:07:51] phaul: not that, the regexp itself.
[01:08:14] al2o3-cr: not a chance
[01:09:01] phaul: start with & then ri (or for other commands something else) then ruby class name following ruby rules then . then ruby method name following ruby method name rules
[01:09:42] al2o3-cr: phaul: then use YARD::Registry then some tweaks.
[01:10:23] phaul: yeah that's the thing I missed I think derpy was using, but I went down an other path
[01:11:10] al2o3-cr: even so, simple ruby can sort that.
[01:11:24] phaul: tbh for me parslet is really not more overhead than regexps. I was already familiar with it
[01:11:47] al2o3-cr: cool beanz :)
[01:13:02] phaul: during the years I wrote more compilers than programs to compile ;)
[01:13:28] al2o3-cr: phaul: nice :)
[01:13:54] al2o3-cr: phaul: you still sailing?
[01:14:11] phaul: skipping this year, I have no money
[01:14:36] phaul: will need to work. the boat is ashore in Shampton
[01:15:08] phaul: such is life.. blame brexit
[01:17:20] al2o3-cr: phaul: does this time out; `trap(:XCPU) { abort "expired" }; Process.setrlimit(:CPU, 5, -1); loop {}`
[01:19:18] phaul: hm. I saw you executing it before. I have no idea what it does...
[01:19:49] phaul: &>> trap(:XCPU) { abort "expired" }; Process.setrlimit(:CPU, 5, -1); loop {}
[01:19:54] rubydoc: stderr: playpen: timeout triggered! (https://carc.in/#/r/6egs)
[01:20:21] phaul: interesting. this is different from the previous response
[01:20:48] al2o3-cr: phaul: yeah, i upped the time by 3 seconds.
[01:21:27] al2o3-cr: &>> trap(:XCPU) { abort "expired" }; Process.setrlimit(:CPU, 2, -1); loop {}
[01:21:29] rubydoc: stderr: playpen: application terminated abnormally with signal 31 (Bad system call) (https://carc.in/#/r/6egt)
[01:26:20] whathappens: has joined #ruby
[01:28:58] al2o3-cr: &>> 2**64-1 == [-1].pack('l!').unpack1('l!')
[01:28:58] rubydoc: # => false (https://carc.in/#/r/6eh4)
[01:29:09] al2o3-cr: &>> 2**64-1 == [-1].pack('l!').unpack1('Q')
[01:29:10] rubydoc: # => true (https://carc.in/#/r/6eh5)
[01:29:24] al2o3-cr: &>> 2**64-1 == [-1].pack('l!').unpack1('J')
[01:29:24] rubydoc: # => true (https://carc.in/#/r/6eh6)
[01:30:19] al2o3-cr: &>> [-1].pack('Q').unpack1('Q')
[01:30:20] rubydoc: # => 18446744073709551615 (https://carc.in/#/r/6eh9)
[01:32:19] tdy: has joined #ruby
[01:35:21] al2o3-cr: &>> require 'fiddle'; include Fiddle; X = Class.new; Pointer[dlwrap IO][16,8] = -Pointer[dlwrap X]; IO.ancestors
[01:35:21] rubydoc: # => [IO, X, Object, Fiddle, Kernel, BasicObject] (https://carc.in/#/r/6eho)
[01:40:09] al2o3-cr: &>> require 'fiddle'; include Fiddle; X = Class.new; Pointer[dlwrap IO][24,8] = -Pointer[dlwrap X]; IO.ancestors
[01:40:09] rubydoc: # => [File::Constants, Enumerable, Object, Fiddle, Kernel, BasicObject] (https://carc.in/#/r/6ei2)
[01:41:10] duderonomy: has joined #ruby
[01:44:11] jdawgaz: has joined #ruby
[01:45:46] lupine: has joined #ruby
[01:51:02] bmurt: has joined #ruby
[02:12:19] apparition: has joined #ruby
[02:19:23] Onwarion_re: has joined #ruby
[02:44:43] akem: has joined #ruby
[02:53:59] blackmesa1: has joined #ruby
[03:04:22] bambanx: has joined #ruby
[03:05:26] bambanx: has joined #ruby
[03:07:33] bambanx: has joined #ruby
[03:08:08] cthulchu: has joined #ruby
[03:24:47] cschneid: has joined #ruby
[03:25:42] Renich: has joined #ruby
[03:56:12] jaddison: has joined #ruby
[04:08:19] mangold: has joined #ruby
[04:10:35] braincrash: has joined #ruby
[04:36:51] Onwarion: has joined #ruby
[04:39:37] apparition: has joined #ruby
[04:43:22] armyriad: has joined #ruby
[05:03:26] xrexeon: has joined #ruby
[05:04:46] KeyJoo: has joined #ruby
[05:11:05] segy: has joined #ruby
[05:11:15] jaddison: has joined #ruby
[05:12:10] jaddison: has joined #ruby
[05:12:50] jaddison: has joined #ruby
[05:13:39] jaddison: has joined #ruby
[05:14:29] jaddison: has joined #ruby
[05:15:08] jaddison: has joined #ruby
[05:29:39] rippa: has joined #ruby
[05:40:24] v01d4lph4: has joined #ruby
[05:54:11] _whitelogger: has joined #ruby
[06:12:09] _whitelogger: has joined #ruby
[06:25:54] cschneid: has joined #ruby
[06:37:06] mangold: has joined #ruby
[06:58:44] orbyt_: has joined #ruby
[07:08:47] whathappens: has joined #ruby
[07:24:26] am0123: has joined #ruby
[07:44:48] reber: has joined #ruby
[07:53:29] ravenousmoose: has joined #ruby
[07:57:51] laaron: has joined #ruby
[08:05:57] sameerynho: has joined #ruby
[08:17:23] fluxAeon: has joined #ruby
[08:18:56] agent_white: has joined #ruby
[08:40:13] apparition: has joined #ruby
[08:43:42] ytti: has joined #ruby
[08:44:09] ytti: rubocop wants me to change Proc.new to proc, fair enough, but if I do that, my tests fail, and I'm not sure I understand why
[08:44:21] ytti: failing line is like: Proc.expects(:new).returns(credentials)
[08:44:32] ytti: i don't get why that fails, and how to fix it
[08:47:47] ytti: proc.expects({}).returns(credentials) -- certainly isn't the way to fix it
[08:55:21] cschneid: has joined #ruby
[09:07:50] aqd: has joined #ruby
[09:22:47] clemens3: has joined #ruby
[09:24:18] blackmesa1: has joined #ruby
[09:28:02] dellavg__: has joined #ruby
[09:32:40] blackmesa1: has joined #ruby
[09:37:11] Dbugger: has joined #ruby
[09:43:44] cristof: has joined #ruby
[09:45:32] hightower2: has joined #ruby
[09:48:02] blackmesa: has joined #ruby
[10:09:25] cschneid: has joined #ruby
[10:11:27] phaul: ytti: what's the code you had before / after?
[10:11:33] ruby[bot]: phaul: I don't know anything about mvce
[10:12:07] phaul: Please provide a Minimal, Complete, and Verifiable example: https://stackoverflow.com/help/mcve
[10:13:01] conta: has joined #ruby
[10:19:06] blackmesa: has joined #ruby
[10:21:27] szulak_: has joined #ruby
[10:29:57] Inline: has joined #ruby
[10:30:56] Pisuke: has joined #ruby
[10:39:27] cristof: has joined #ruby
[10:42:30] mangold: has joined #ruby
[11:18:03] ytti: phaul, Proc.new => proc, the mocha test fails, because the code on longer calls Proc class to create an instance
[11:18:19] ytti: phaul, it's really mocha issue in testing
[11:23:03] phaul: I don't know. I don't know mocha. But if you link the source code you had before, you have after, and the erro message printed, I or someone else can take a look and try to help. But informal description of the issue doesn't help. The code has all the details, and the full error message also. You might think that that's all irrelevant, and it might be so, but giving as much information as possible can't hurt.
[11:23:14] mangold: has joined #ruby
[11:32:06] duncan_bayne: has joined #ruby
[11:34:00] duncan_bayne: Hi :) On my system, File.stat('/tmp').writable? returns true when run under MRI 2.5.1, but false when run under JRuby 9.1.7.0. This means that Dir.tmpdir is failing under JRuby, because it thinks /tmp isn't writable.
[11:34:35] duncan_bayne: I suspect I'm running into an obscure bug here, but couldn't find anything obvious.
[11:34:50] duncan_bayne: Has anyone seen this behaviour before?
[11:41:15] ytti: phaul, i see where you're coming from, but i think in this case just knowing mocha is 'Proc.expects(:new).returns(credentials)' and it works, and changing source code from Proc.new to proc, breaks it, is actually all the data needed to solve the problem, as it's very specific to Mocha, it is even plausible that you just can't test 'proc' with Mocha, and I'm better using Proc.new with # rubocop:disable
[11:41:46] ytti: phaul, the logic why it breaks is fairly simply, code being tested is not instansiating Proc class
[11:55:46] yokel: has joined #ruby
[12:00:40] jdawgaz: has joined #ruby
[12:07:45] Fernando-Basso: has joined #ruby
[12:11:53] duncan_bayne: has left #ruby: ("gives up for the night")
[12:38:54] cschneid: has joined #ruby
[12:42:14] Sembei: has joined #ruby
[12:46:35] crankharder: has joined #ruby
[12:53:43] darth-chatri: has joined #ruby
[12:59:40] cristof: has joined #ruby
[13:00:28] cristof: has joined #ruby
[13:01:46] ua_: has joined #ruby
[13:05:22] szulak_: has joined #ruby
[13:06:28] am0123: has joined #ruby
[13:20:33] lucasb: has joined #ruby
[13:34:18] AJA4350: has joined #ruby
[13:57:12] crankharder: has joined #ruby
[14:17:57] cristof: has joined #ruby
[14:33:59] crankharder: has joined #ruby
[15:07:15] crankharder: has joined #ruby
[15:10:15] cschneid: has joined #ruby
[15:14:18] houhoulis: has joined #ruby
[15:24:51] conta: has joined #ruby
[15:57:30] Sylario: has joined #ruby
[16:00:47] cschneid: has joined #ruby
[16:09:46] xco: has joined #ruby
[16:11:18] xco: Hi. I’m trying to generate unique usernames for users. Currently I’m using the part before the @ of their emails but to make it truly unique i’m generating some random characters (two characters) then adding it to the email
[16:11:33] xco: so a user with an email like user@email.com
[16:11:37] xco: will have a username like
[16:11:49] xco: user_xP
[16:11:57] xco: or user_9h
[16:12:21] xco: i don’t like this _xx part that i’m generating
[16:12:37] xco: instead i thought of something like generating a digest of the timestamp
[16:12:47] xco: which will always be unique right?
[16:13:20] xco: the problem with the digest is they won’t be easy to remember/memorise
[16:13:24] xco: question is
[16:14:01] xco: how do i generate a truly unique value
[16:14:05] xco: that’s short
[16:14:10] xco: and easy to remember in Ruby
[16:14:50] canton7: firstly, isn't being unique across your site enough? you don't need something that's globally unique - just something that doesn't already exits in your database. That's a much easier ask, as you can generate something, check if it's in your database, and if it is then generate something else
[16:15:18] canton7: secondly, can't you let users pick their own usernames? I know I wouldn't want the bit at the start of my email being my username - it's got my full name in it, and I don't want to share that with random people
[16:16:10] sariyar: has joined #ruby
[16:17:49] xco: i like your second point
[16:18:01] canton7: also it gives people an easy way to spam me - take the username, append popular email providers
[16:18:22] xco: as far as the first point is concerned. i’m trying to avoid hitting the db, since like you said, first i have to check if a username exist in the db, that might be expensive
[16:18:32] xco: that’s actually what i’m doing
[16:18:38] xco: and want to find ways to avoid that
[16:18:38] canton7: nah, this is only done on sign-up. that's rare.
[16:19:06] canton7: and doing a read on an indexed column like that is going to be *significantly* cheaper than inserting the username you finally decide on...
[16:19:33] xco: very good point
[16:19:41] canton7: and many times cheaper than fetching all of the information you'll need to show any page once they're logged in
[16:19:55] xco: thanks :)
[16:39:05] evdubs: has joined #ruby
[16:39:38] DTZUZO: has joined #ruby
[16:57:19] orbyt_: has joined #ruby
[17:00:38] ravenousmoose: has joined #ruby
[17:05:31] tdy: has joined #ruby
[17:06:31] xco: i need help refactoring this https://gist.github.com/xcobar/cf68273f70a55b432805d2ae8e4b7c04
[17:06:45] xco: i want to get the auth["info"]["email"].tr('.', '_').split('@')[0] duplication out
[17:06:53] xco: any help?
[17:08:45] canton7: xco, use a do...while loop (well in ruby, it's begin ... end while)
[17:09:48] xco: can you please comment on my gist, or here? im not sure wat you mean
[17:09:52] xco: canton7: please?
[17:10:31] SeepingN: has joined #ruby
[17:11:35] canton7: xco, begin email_prefix = ...... end until User.where(username: email_prefix).empty?
[17:12:20] canton7: actually, isn't that the same as your code? Are you sure you need line 4 in your gist at all?
[17:13:42] xco: for the User.where(username: email_prefix) part
[17:14:28] Cavallari: has joined #ruby
[17:16:53] whathappens: has joined #ruby
[17:16:55] luminous: has joined #ruby
[17:19:41] canton7: xco, no, you don't, it turns out
[17:20:21] canton7: wait, one sec
[17:21:30] canton7: xco, yeah, you can use begin email_prefix = ...... end until User.where(username: email_prefix).empty?
[17:23:22] xco: i don’t think that would work
[17:23:41] xco: there’s a + random_chars appended to the email_prefix
[17:23:53] xco: and there are two email_prefix
[17:27:52] canton7: xco, wait, your code doesn't even work?
[17:29:12] canton7: commented, anyway
[17:34:21] xco: thanks!
[17:34:26] xco: this looks clean
[17:34:39] xco: but my test suite is failing so i’ll keep it and find a way around it
[17:34:43] xco: maybe modify it a bit
[17:38:00] alem0lars: has joined #ruby
[17:38:53] canton7: what's the failure?
[17:41:06] davidfetter: has joined #ruby
[17:41:39] davidfetter: has left #ruby: ()
[17:48:50] cschneid: has joined #ruby
[17:49:02] ravenousmoose: has joined #ruby
[17:52:43] xco: with this change my test stalls :/
[18:01:46] s3nd1v0g1us: has joined #ruby
[18:02:27] marmotini_: has joined #ruby
[18:05:37] Caius: has joined #ruby
[18:23:29] Dbugger: has joined #ruby
[18:34:16] Joufflu: has joined #ruby
[18:34:23] crankharder: has joined #ruby
[18:36:04] cnsvc_: has joined #ruby
[18:39:40] am0123: has joined #ruby
[18:42:31] jcarl43: has joined #ruby
[18:50:27] jaddison: has joined #ruby
[18:51:01] xco: has joined #ruby
[18:53:04] jaddison: has joined #ruby
[18:53:46] jaddison: has joined #ruby
[18:55:33] jaddison: has joined #ruby
[18:56:06] jaddison: has joined #ruby
[19:08:51] orbyt_: has joined #ruby
[19:10:07] havenwood: xc, oh they left?
[19:11:16] havenwood: I was going to suggest extracting an ALNUMS constant and #random_chars, #email_prefix and #duplicate methods.
[19:11:30] havenwood: And using #exists? over !#empty?
[19:11:58] havenwood: commented on the gist in any case
[19:17:21] aqd: has joined #ruby
[19:20:39] cschneid: has joined #ruby
[19:20:58] duckpuppy: has joined #ruby
[19:27:21] tdy: has joined #ruby
[19:28:32] conta: has joined #ruby
[20:13:52] cschneid: has joined #ruby
[20:20:10] nwradio: has joined #ruby
[20:21:01] agent_white: has joined #ruby
[20:29:09] dviola: has joined #ruby
[20:31:11] reber: has joined #ruby
[20:36:37] fredmorcos: has joined #ruby
[20:38:02] DoctorMonocular: has joined #ruby
[20:38:43] DoctorMonocular: hey I'm having some trouble here. For whateve rreason my mind just refuses to generate what I am guessing is an obvious recursive solution. I have this hash: https://gist.github.com/PeteMichaud/c12e495f143f57b8a8cf712736a3dff1
[20:38:55] DoctorMonocular: and I want to output all the possible combinations of those 4 dimensions
[20:40:34] houhoulis: has joined #ruby
[20:42:44] phaul: DoctorMonocular: https://gist.github.com/phaul/f1ce16349c79b6c33f85b1bce2357a5c
[20:43:16] phaul: if you mean the cartesian product
[20:43:37] DoctorMonocular: damn, that's great
[20:43:44] DoctorMonocular: didn't know there was a built in method
[20:44:47] DoctorMonocular: then I can zip that result with the original keys and get the labels back too
[20:44:56] phaul: there is also repeated_combination, repeated_permutation combination permutation methods np
[20:49:13] ur5us: has joined #ruby
[21:04:16] crankharder: has joined #ruby
[21:07:30] hightower3: has joined #ruby
[21:23:17] Riviera-: has joined #ruby
[21:24:21] crankharder: has joined #ruby
[21:39:55] orbyt_: has joined #ruby
[21:56:20] ellcs: has joined #ruby
[22:09:39] jaddison: has joined #ruby
[22:10:32] dmwit: has left #ruby: ("this language isn't even ruby =(")
[22:11:18] cschneid: has joined #ruby
[22:12:59] laaron: has joined #ruby
[22:15:06] ellcs: has joined #ruby
[22:41:17] AJA4350: has joined #ruby
[22:46:12] ua_: has joined #ruby
[22:47:59] bambanx: has joined #ruby
[22:48:02] cd: has joined #ruby
[22:48:55] clemens3_: has joined #ruby
[22:49:09] bambanx: has joined #ruby
[22:49:10] duckpuppy: has joined #ruby
[22:50:36] bambanx: has joined #ruby
[22:52:25] orbyt_: has joined #ruby
[23:07:23] tdy: has joined #ruby
[23:35:19] themsay: has joined #ruby
[23:40:24] themsay: has joined #ruby
[23:49:36] themsay: has joined #ruby