canton7

Activity Graph

Page 1 of 15 | Next »

2019-09-16

[06:23:46] canton7: Remote host closed the connection
[06:24:05] canton7: has joined #ruby

2019-09-14

[23:16:30] canton7: Quit: ZNC - http://znc.in
[23:16:49] canton7: has joined #ruby

2019-08-13

[15:56:52] canton7: still answer based in part on your original question
[15:56:52] canton7: vdl, your original question was "considering an array of strings ["foo", "bar", "baz"],how can I loop over all elements in the array? So that a variable equals "bar", then "baz", then "foo", ...". It sounds like that wasn't actually your question -- in that case, it's worth being clear that your original question is incorrect, otherwise people will
[16:00:38] canton7: ACTION likes havenwood's solution

2019-08-02

[15:12:18] canton7: rushsteve1, haven't you lost the "if (*p)" case?
[15:14:18] canton7: rushsteve1, well if p is null, *p is already a problem. I assume there's a check for that above. The while loop seems to be looping over \0 bytes?
[15:17:15] canton7: d'oh, yes, I had it backwards
[15:17:52] canton7: it does seem redundant...

2019-07-31

[11:23:25] canton7: xco, seems fairly clear and concise?
[14:39:14] canton7: vcavallo, seems odd that it's specifically targeted at refactoring
[14:40:47] canton7: even if it was for any sort of change, I'm not sure I'd find it useful, no. 1) Reviews need to be timely and reliable to be of much worth, 2) The value in a review comes mainly from people who are familiar with the project's coding guidelines and the wide context of the change, neither of which will be known by random people
[14:42:12] canton7: SO only works when the questions being answered, or code being reviewed, is very self-contained and fairly small, as this reduces the effort required by the people helping. That's not the case when reviewing some random code change to a large codebase

2019-07-27

[15:28:18] canton7: P-NuT, your question is a little unclear. rubydns is a DNS *server*. Servers typically return results - they don't fetch them (excluding dealing with upstream servers). What exactly do you want to drill down into?
[15:31:56] canton7: I doubt it is a dictionary - it's probably just printing something that looks like what you see if you print a dictionary
[15:32:18] canton7: just drill down into it. use #class to see what the type is, and either find the docs for that type, or use #methods to see what methods it has

2019-07-21

[20:40:07] canton7: Quit: ZNC - http://znc.in
[20:41:59] canton7: has joined #ruby

2019-07-18

[20:23:35] canton7: what do you want to do with members that are nil? just exclude them entirely?

2019-07-14

[23:20:28] canton7: Quit: ZNC - http://znc.in
[23:24:50] canton7: has joined #ruby

2019-07-08

[23:15:11] canton7: Remote host closed the connection
[23:19:32] canton7: has joined #ruby

2019-07-05

[18:03:38] canton7: I think the trigger was written before github changed that

2019-07-03

[21:05:01] canton7: pinky, https://stackoverflow.com/a/5924541/1086121

2019-06-28

[23:15:59] canton7: Quit: ZNC - http://znc.in
[23:28:22] canton7: has joined #ruby

2019-06-19

[05:27:59] canton7: Remote host closed the connection

2019-06-04

[11:05:31] canton7: depesz, z.flat_map{ |k,v| v.map{ |x| [x, k] }}.to_h
[11:06:37] canton7: you could have done it your way as well, but it's a bit neater to use .flatten(1) instead of .reduce(&:+)

2019-05-31

[12:25:09] canton7: Ping timeout: 252 seconds
[12:26:27] canton7: has joined #ruby

2019-05-21

[14:06:11] canton7: *.net *.split

2019-05-06

[09:37:02] canton7: Quit: ZNC - http://znc.in
[09:37:23] canton7: has joined #ruby
[09:38:06] canton7: Client Quit
[09:54:49] canton7: has joined #ruby

2019-05-03

[21:39:08] canton7: *.net *.split
[22:08:17] canton7: has joined #ruby

2019-04-27

[19:42:20] canton7: comet23, brothers.map{ |x| x[:name] }.include?("steven") or brothers.any?{ |x| x[:name] == "stephen" }

2019-04-23

[11:36:54] canton7: old_relik, this is equivalent: https://dpaste.de/VZwO

2019-04-13

[16:49:57] canton7: *.net *.split

2019-04-08

[18:21:02] canton7: Remote host closed the connection
[18:21:23] canton7: has joined #ruby

2019-03-12

[09:36:18] canton7: Tuor, don't use 'and', use '&&'
[09:36:42] canton7: line 33, you access `params['path']` a *lot*, which means a lot of hash lookups
[09:37:30] canton7: line 7, I'd make 'default_config_file_path' a constant
[09:38:16] canton7: personally as a user I'd expect some sort of warning or message if I supplied a path, but the code decides to ignore it for some reason
[10:06:24] canton7: Bish, the precedence is different. '&&' is meant for combining conditions, 'and' is meant for control flow
[10:06:47] canton7: `puts 1 > -1 and 257 < 256` #=> false, but `puts 1 > -1 && 257 < 256` #=> true

2019-03-09

[20:01:06] canton7: Quit: ZNC - http://znc.in
[20:04:29] canton7: has joined #ruby

2019-03-03

[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:18:01] canton7: also it gives people an easy way to spam me - take the username, append popular email providers
[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:41] canton7: and many times cheaper than fetching all of the information you'll need to show any page once they're logged in
[17:08:45] canton7: xco, use a do...while loop (well in ruby, it's begin ... end while)
[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: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:27:52] canton7: xco, wait, your code doesn't even work?
[17:29:12] canton7: commented, anyway
[17:38:53] canton7: what's the failure?

2019-03-02

[16:57:34] canton7: Darmani, you need to parse the grade into the letter, and the '+' or '-'. First compare the letters. If they're the same, compare the '+' or '-'
[16:59:46] canton7: Darmani, again, you need to parse the grade into the letter, and the '+' or '-'. You don't parse out the letter.
[17:01:59] canton7: Darmani, shall I just keep repeating what I said? I don't think I'm getting anywhere here
[17:02:20] canton7: "Do it this way" "Yes, I'm doing it a different way" "I suggested doing it this way" "I know, I'm doing it a different way"
[17:03:22] canton7: well it really is as simple as I described. If you don't understand what I'm describing, ask: don't say "I came to the same conclusion"...
[17:04:50] canton7: I said to parse out the letter and the symbol. *first* compare the letters, *then* if the letters are the same, look at the symbols
[17:05:13] canton7: so step 1: create variables containing the letter, and the symbol
[17:05:25] canton7: step 2: compare the variables containing *just* the letters. No symbols.
[17:05:40] canton7: step 3: *if* and only if the letters match, then compare the variables containing *just* the symbols
[17:07:22] canton7: Yes. If the letters are *not* the same, return -1 or 1 as appropriate. If the letters are the same, compare the symbols and return -1, 0, or 1 as appropriate
[17:30:48] canton7: Darmani, https://repl.it/repls/WeakRunnyMachinecodeinstruction
[17:33:42] canton7: and if you're serious about the money: https://secure.msf.org.uk/Donate/ :)
[17:56:32] canton7: that's a classic programming problem
[17:56:41] canton7: comes up in all sorts of online code challenge thingies
[17:58:05] canton7: which variant of the problem is yours?
[17:59:20] canton7: iirc they're all slightly gnarly
[17:59:40] canton7: oh, longest repeating substring, not longest substring without repeating characters
[18:00:23] canton7: you can do it yourself, by hand, right?
[18:02:16] canton7: do it by hand, with pencil and paper. Then analyze how you did it
[18:02:30] canton7: turn that into a set of instructions on how to do it, then turn that into code
[18:03:09] canton7: get a physical pencil and a piece of physical paper :)
[18:03:28] canton7: then use them to find the longest common substring in a word
[18:03:41] canton7: then come up with a set of instructions on how to do it, and write them down
[18:04:15] canton7: that's the starting point for any algorithm
[18:04:25] canton7: I always start by sketching things out in a logbook
[18:12:20] canton7: if you're solving "phenomenal" by hand, what do you do? you start at the 'p': uh, no other p's. Same with the 'h'. Reach the 'e': ooh another e! And they've both got 'n' after them, but that's all. The 'n' was part of 'en' so we can skip that. Onto the 'o'...
[18:13:45] canton7: dunno. It doesn't matter: it's the same algorithm, one just has a step to reject substrings of length 1 at the end
[18:14:41] canton7: that's one way of doing it, sure
[18:14:55] canton7: there will be neater ways - googling gave a couple of very terse recursive solutions
[18:27:46] canton7: I did electronics at uni, which had some programming in it
[18:29:04] canton7: figuring out simple algorithms like this is just practice. coming up with the perfect solution requires a bunch of data structures and algorithms knowledge, which a cs uni course will give you
[18:52:10] canton7: what language what?
[18:52:44] canton7: ah, a combination of C and C#
[18:54:54] canton7: yep, they're the two languages I'm paid to write. C for embedded stuff, C# for desktop stuff
[18:55:34] canton7: I picked up ruby at school because it was fun, and still use it for scripts / build scripts / etc, but I don't build anything serious in it
[19:06:29] canton7: heh, that's probably before me time!
[19:27:49] canton7: did you figure out how to do it by hand? could you describe to someone else how to do it by hand?
[19:30:14] canton7: right, so write that down in a gist
[19:30:26] canton7: (going to be afk in about 10 mins - dinner is cooking)
[19:42:26] canton7: Darmani, I'll look in a bit. No cheating: this is my super-naive O(n^3) attempt, just implementing what I'd do by hand: https://repl.it/repls/TallAstonishingGreyware

2019-03-01

[00:14:49] canton7: Quit: ZNC - http://znc.in
[00:15:16] canton7: has joined #ruby

2019-02-12

[19:04:36] canton7: Ping timeout: 240 seconds

2019-02-06

[09:29:53] canton7: TvL2386, that's "whitespace zero or more times, non-greedy match"
[09:30:17] canton7: granted the '?' isn't needed in this case

2019-02-05

[09:08:51] canton7: TvL2386, it would be helpful to see what the stringio contains
[15:19:15] canton7: xco, what makes you think it isn't doing the job?

2019-02-04

[15:31:37] canton7: as far as I've been able to tell, the only difference between "calling a method" and "passing a message" is that you can define what happens if someone calls a method that isn't defined
[15:31:54] canton7: and I guess things like defining new methods at runtime

2019-01-30

[12:42:01] canton7: Quit: ZNC - http://znc.in
[12:42:32] canton7: has joined #ruby

2019-01-29

[16:53:42] canton7: maryo, you call File.open on line 22, and assign that to 'f'. Then you try and open *another* file on line 24, but you don't say that filename to open...
[16:54:25] canton7: maryo, https://dpaste.de/CV6R#L24,26
[16:54:41] canton7: (which is what I sent you yesterday)

2019-01-28

[10:29:55] canton7: AndreYuhai, look at the redo and retry keywords
[16:50:37] canton7: maryo, yes. However, prefer the version of File.open which takes a block - that way it automatically calls close for you
[16:52:20] canton7: maryo, I said it needs a close call too, and to prefer the version of File.open which takes a block
[16:52:35] canton7: you just re-pasted the same code which doesn't call File.close *or* use the version of File.open which takes a block
[16:57:48] canton7: maryo, no, you close it after reading only the first line
[16:57:59] canton7: I did say to prefer the version of File.open which takes a block
[16:59:27] canton7: File.open(a, "r") do |f| ......... end
[17:15:57] canton7: maryo, you deleted 'f.each_line'
[17:16:59] canton7: maryo, https://dpaste.de/jyqK/raw
[17:17:09] canton7: oops, not quite
[17:17:26] canton7: here: https://dpaste.de/DKS7/raw

2019-01-23

[15:53:07] canton7: I've never seen the attraction of the latter form. I need to do far more mental parsing.

2019-01-22

[11:04:41] canton7: because <a> needs to be closed?
[11:05:01] canton7: It isn't self-closing, so it's illegal for it to not be closed?
[11:07:59] canton7: oh, you mean that nokogiri didn't insert the </a> at the end? What did it do?
[11:09:30] canton7: From what you said, it sounded like you were asking why nokogiri had inserted the </a> at the end
[11:09:36] canton7: if that's not what you meant, please clarify
[11:17:02] canton7: what does the result actually look like, character for character?
[11:17:24] canton7: "will have an empty a tag" isn't descriptive enough for me to work out what it actually contains
[11:20:49] canton7: probably because it's illegal to put a table inside a link?
[11:21:57] canton7: although MDN suggests it's legal to put a table in an a
[11:23:41] canton7: and the W3C validator validates it fine
[11:24:38] canton7: huh, and when I run the snipped you posted, it returns "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\">\n<html><body>\n<a href=\"http://google.de\"></a><table><tr><td><span>Test<span></span></span></td></tr></table>\n</body></html>\n"
[11:24:43] canton7: *the snippet
[11:25:02] canton7: so it hasn't stripped the table as you said - but it closed the <a> earlier

2019-01-14

[12:59:03] canton7: catphish, can you give an example of its usage?
[12:59:30] canton7: what would the point of a while loop which does nothing be?
[13:06:02] canton7: ah, gotcha. I think you'll have to write it the same way as in C, with an empty block
[13:09:51] canton7: 'while (process_once) { }' ?
[13:10:54] canton7: yeah, I wasn't thinking

2019-01-12

[22:43:00] canton7: baweaver, looking at the code (haven't tried to run it), looks like it will give the wrong answers if you have ',' or '..' outside of the { }? Also no support for having a literal { or }?
[22:44:27] canton7: might want to put some limitations in the readme then? (the string being expanded can't contain the sequences '{', '}', ',', '..'
[22:46:09] canton7: (also we seem to be going the way of node.js, with 5-line methods being turned into their own packages, complete with code of conduct)
[22:48:11] canton7: well, except that you end up here: https://www.theregister.co.uk/2018/11/26/npm_repo_bitcoin_stealer/
[22:50:11] canton7: yes, but the probability increases with the number of packages in your dependency tree
[22:50:53] canton7: the solution is "don't use a package to provide something you could implement by adding a file or two to your project"
[22:52:44] canton7: of course there's a tradeoff
[22:53:01] canton7: but writing 5 lines of code yourself isn't "burning through a ton of engineer time"
[22:53:27] canton7: and really you need to be checking your dependencies, which burns its own engineer time
[22:54:01] canton7: (license, known issues, whether it's maintained, etc)
[22:54:29] canton7: of course, I was taking an extreme example
[23:39:38] canton7: baweaver, Array#product
[23:42:06] canton7: you can regex that! /((?:|[^\\])(?:\\\\)*){(.+[^\\](?:\\\\)*)}/
[23:42:33] canton7: but, I tend to just go back to a token-based parser with a bit of state to say "in escape" at that point...
[23:43:03] canton7: yeah, you could quite happily use StringScanner for that
[23:43:37] canton7: though I tend to just loop through character by character
[23:44:10] canton7: oops, /((?:^|]^\\].....
[23:44:40] canton7: but, you'll want to be processing your input to remove escapes, which means you want to be copying non-escaped input chars to your output anyway
[23:44:55] canton7: but yeah, not too much difference

2019-01-11

[10:26:53] canton7: Bish, well it does slightly more: `from ? [from].flatten : []`
[10:27:04] canton7: That's the sort of thing that I might put in a little helper method
[10:55:52] canton7: yeah, flattens and provides an empty array as the default value
[12:03:15] canton7: deathwishdave, things like that rarely come out-of-the-box, since "registration" is a word which means something slightly different to everyone which puts it in their requirements...
[12:03:27] canton7: deathwishdave, you'll find tools which help you to build a rails app which can do those things, though

2019-01-10

[15:43:53] canton7: tkonto, 'unless' with two cases gets confusing fast: don't do it
[15:44:39] canton7: you probably want 'if errorcode != 200 && errorcode != 201' or 'if !(errorcode == 200 || errorcode == 201)'
[15:45:11] canton7: and the syntax is 'if errorcode != 200 && errorcode != 201 <newline> retry <newline> end' or 'retry if errorcode != 200 && errorcode != 201'

2019-01-09

[11:20:45] canton7: RougeR, for the same reason that 'workers = result.dig(:work, :workers); workers += `' "doesn't work"
[11:21:09] canton7: in that it increments the 'workers' variable, not the value of result[:work][:workers]
[11:37:01] canton7: but, there's no need for dig here. Just do 'result[:work][:workers] += 1'
[12:03:50] canton7: well, '+=' will expand to 'result[:work][:workers] = result[:work][:workers] + 1'

2019-01-08

[17:46:43] canton7: za1b1tsu, it's about apps vs gems, see some of the articles here: https://www.google.com/search?q=gemfile+gemspec
[17:48:00] canton7: long story short: bundler/gemfile is for locking down the exact versions of gems that your application uses. gemspec is used when creating a gem, is used tell consumers what gems your library depends on, and you specify lax ranges rather than specific versions

2019-01-04

[12:17:35] canton7: adac, give us some sample input and sample output?
[12:23:06] canton7: what's the input?
[12:31:10] canton7: you have two inputs: the regex, and the string the regex is applied to. You've only given us one of those two
[12:33:54] canton7: or something like 's[1..-2].split('|')' . Depends how much you want to check that the input is well-formed
[12:36:54] canton7: ACTION has written regexes to parse regexes more times than he would have liked

2019-01-03

[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"
[11:28:27] canton7: *is the same as "6 minutes + 30 seconds"
[11:29:14] canton7: replace . with / and it works

2019-01-02

[14:47:49] canton7: that's pretty easy to test :P
[14:48:01] canton7: you expected a string when you got an array

2018-12-27

[10:36:19] canton7: Quit: ZNC - http://znc.in
[10:36:46] canton7: has joined #ruby

2018-12-26

[13:41:56] canton7: Quit: ZNC - http://znc.in
[13:42:17] canton7: has joined #ruby

2018-12-14

[11:39:43] canton7: depends whether you want a column that's called 'id' and is the primary key

2018-12-13

[11:07:15] canton7: A comes before a in ascii
[11:07:45] canton7: &>> /[A-z]/.match?('q')
[11:11:00] canton7: &>> /A-z/.match?('[')
[11:11:08] canton7: &>> /[A-z]/.match?('[')
[11:11:16] canton7: ^ note that A-z also catches a bunch of other characters

2018-11-18

[12:59:03] canton7: indeed, because it doesn't appear between the 'begin' and the 'rescue'
[12:59:16] canton7: if you want to catch errors from it, put it in its own begin/rescue block
[13:01:12] canton7: catching different sorts of errors
[13:01:48] canton7: 'rescue OneTypeOfException' ... 'rescue AnotherTypeOfException' ...

2018-11-16

[11:49:09] canton7: grr12314, from phaul's doc: Matches rxp against the contents of $_. Equivalent to rxp =~ $_.. Looking at the doc for =~ (in the same page): "If a match is found, the operator returns index of first match in string, otherwise it returns nil."
[11:49:20] canton7: so yes, it operates on $_, and returns the index of the first match

2018-11-07

[16:49:46] canton7: there's a ternary in there
[16:50:18] canton7: x[n - 1] ? (x.minmax.uniq * '-') : x
[16:53:42] canton7: you pretty much only see it in golf
[17:12:26] canton7: it's also impossible to google for if you don't know what it does, so it's not very discoverable
[17:12:36] canton7: and it's only one char shorter than just using quotes

2018-11-01

[00:10:16] canton7: Quit: ZNC - http://znc.in
[00:10:43] canton7: has joined #ruby

2018-10-05

[10:49:14] canton7: asphyxia, that just means a method which has a single parameter, called 'a'. It could be an array, or anything else: there's no enough information to say

2018-10-04

[16:05:26] canton7: JJonah, that hastebin is empty?

2018-10-03

[09:18:43] canton7: more context?

2018-09-12

[15:29:05] canton7: hash.select{ |k,v| array.include?(k) } ?
[15:31:20] canton7: is values_at guaranteed to return the values in the right order? The docs don't say, but I guess it'd make sense
[15:31:42] canton7: siaw23, or 'array.include?(k.to_sym / k.to_s / whatever)`
[15:48:40] canton7: ah, only looked in the 2.0.0 docs

2018-09-01

[23:08:06] canton7: that makes sense, surely? If someone is depending on a particular version of your gem, you shouldn't be able to just break that
[23:09:46] canton7: but if they let you fix the gemspec, they let everyone else completely break things

2018-08-31

[23:10:15] canton7: Quit: ZNC - http://znc.in
[23:10:35] canton7: has joined #ruby

2018-08-29

[02:42:50] canton7: *.net *.split
[02:56:47] canton7: has joined #ruby

2018-08-17

[21:06:14] canton7: Remote host closed the connection
[21:07:05] canton7: has joined #ruby

2018-08-15

[09:16:21] canton7: Ping timeout: 240 seconds
[09:18:32] canton7: has joined #ruby

2018-08-13

[19:43:31] canton7: we've used gollum with success before

2018-08-12

[16:43:19] canton7: (btw, try and avoid unless...else - it tends to do people's heads in
[16:45:59] canton7: sagax, another way of writing that would be `env = "development" if !ENV.has_key?("NODE_ENV") || !["production", "development", "test"].include?(ENV["NODE_ENV"])`
[17:45:07] canton7: Mike11, Enumerable#slice_before
[17:46:41] canton7: mroutis, try an input of [20, 2, 30, 3, 4, 40, 4, 5, 6] ;)
[17:47:15] canton7: that's not what I said...
[17:48:15] canton7: >> [20, 2, 30, 3, 4, 40, 4, 5, 6].slice_before{ |x| x < 10 }.to_a
[17:48:24] canton7: >> [20, 2, 30, 3, 4, 40, 4, 5, 6].slice_before{ |x| x > 10 }.to_a

2018-07-30

[11:08:04] canton7: Quit: ZNC - http://znc.in
[11:08:23] canton7: has joined #ruby

2018-07-20

[00:15:45] canton7: has joined #ruby