Activity Graph

Page 1 of 15 | Next »


[23:20:28] canton7: Quit: ZNC -
[23:24:50] canton7: has joined #ruby


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


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


[21:05:01] canton7: pinky,


[23:15:59] canton7: Quit: ZNC -
[23:28:22] canton7: has joined #ruby


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


[11:05:31] canton7: depesz, z.flat_map{ |k,v|{ |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(&:+)


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


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


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


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


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


[11:36:54] canton7: old_relik, this is equivalent:


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


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


[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


[20:01:06] canton7: Quit: ZNC -
[20:04:29] canton7: has joined #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: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?


[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,
[17:33:42] canton7: and if you're serious about the money: :)
[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:


[00:14:49] canton7: Quit: ZNC -
[00:15:16] canton7: has joined #ruby


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


[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


[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?


[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


[12:42:01] canton7: Quit: ZNC -
[12:42:32] canton7: has joined #ruby


[16:53:42] canton7: maryo, you call 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,,26
[16:54:41] canton7: (which is what I sent you yesterday)


[10:29:55] canton7: AndreYuhai, look at the redo and retry keywords
[16:50:37] canton7: maryo, yes. However, prefer the version of 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 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 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 which takes a block
[16:59:27] canton7:, "r") do |f| ......... end
[17:15:57] canton7: maryo, you deleted 'f.each_line'
[17:16:59] canton7: maryo,
[17:17:09] canton7: oops, not quite
[17:17:26] canton7: here:


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


[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\" \"\">\n<html><body>\n<a href=\"\"></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


[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


[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:
[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


[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


[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'


[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'


[17:46:43] canton7: za1b1tsu, it's about apps vs gems, see some of the articles here:
[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


[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


[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


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


[10:36:19] canton7: Quit: ZNC -
[10:36:46] canton7: has joined #ruby


[13:41:56] canton7: Quit: ZNC -
[13:42:17] canton7: has joined #ruby


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


[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


[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' ...


[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


[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


[00:10:16] canton7: Quit: ZNC -
[00:10:43] canton7: has joined #ruby


[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


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


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


[15:29:05] canton7:{ |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


[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


[23:10:15] canton7: Quit: ZNC -
[23:10:35] canton7: has joined #ruby


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


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


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


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


[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


[11:08:04] canton7: Quit: ZNC -
[11:08:23] canton7: has joined #ruby


[00:07:27] canton7: *.net *.split
[00:15:45] canton7: has joined #ruby


[08:42:50] canton7: lucas_, some suggestions on how to get curl to introduce that newline:
[09:11:20] canton7: he didn't hang around for long...
[09:12:25] canton7: _phaul, objects which are equal MUST have equal hash codes
[09:17:00] canton7: _phaul,, mouseover and click ("click to toggle source")
[09:17:15] canton7: and the doc: "Returns a hash value based on this struct's contents"
[09:18:36] canton7: (things like Set and Hash start off using the object's hash code, and if two objects have the same hash code they check #eql? to see if they're actually equal
[13:49:42] canton7: crankharder, wrong channel?
[13:52:11] canton7: I'm sorry? I'm asking crankharder whether he posted in the wrong channel by mistake, as his message doesn't appear to have anything to do with ruby
[13:52:15] canton7: I know I'm in #ruby :P
[13:52:54] canton7: ACTION is very confused
[14:04:41] canton7: and a third person who seems to be fixated on the idea that the person who pointed out what channel this is doesn't know which channel this is...


[13:53:14] canton7: YokoBR, you likely need to have bundler installed?


[11:00:09] canton7: mattb20, first point: you need to set up the expectations *first8
[12:30:20] canton7: >> [[1,[2,3,4]],[5,[6,7,9]]].flat_map{|a,b|[a].product(b)}
[12:30:24] canton7: ACTION shaved a couple of characters off


[14:19:50] canton7: oh, you mean run the rakefile using rake?
[14:23:11] canton7: MagePsycho, there's a parameter you can pass to rake to get it to load a particular file
[14:29:30] canton7: MagePsycho, use a hash
[14:38:55] canton7: MagePsycho, so you want to use a hash but you're not allowed to use a hash?
[16:01:15] canton7: MagePsycho, I'm not sure what the 'set' method does, but it doesn't define a new variable...