Activity Graph

Page 1 of 17 | Next »


[14:22:52] phaul: you can limit the loop to prime factors of size if you want to
[14:25:41] phaul: &>> require 'prime';
[14:29:20] phaul: if it repeats a*b times then (thing * b) it also repeats a times
[14:32:47] phaul: yeah. It was just an idea. I am not saying that's the way you should do it
[15:20:16] phaul: &>> require 'prime'; 'abcabc'.yield_self { |s| s.length.prime_division.any? { |p, _| p < s.length && s[0,p] * (s.length / p) == s } }
[15:22:00] phaul: no. p number of elemems startting from 0
[15:22:24] phaul: 0...p would be the same
[15:23:30] phaul: oh. wait a minute...
[15:23:41] phaul: &>> require 'prime'; 'abcdabcd'.yield_self { |s| s.length.prime_division.any? { |p, _| p < s.length && s[0,p] * (s.length / p) == s } }
[15:24:17] phaul: exactly the thing you mentioned above on substring not being prime length
[15:35:12] phaul: it would also be broken for prime length single char strings like 'aaa' assuming that's supposed to be repeating
[15:35:42] phaul: "ytti | but premature optimsation is source of great many evil" :D
[16:09:37] phaul: grr12314: correct. before p and length / p were the wrong way around it was there to make 'abc' false.
[16:10:10] phaul: I mean before; when ..
[16:11:52] phaul: philosophical question. does 'a' repeat :) ?
[16:13:31] phaul: I guess not. but 'aa' does


[15:33:37] phaul: you can use the "new" hash syntax
[15:33:58] phaul: {:a => 'xxx'} is the same as {a: 'xxx'}
[15:34:54] phaul: you could splat the hash, but that's not exactly the same
[15:35:04] phaul:**params)
[15:37:39] phaul: &>> def f(a:, b:) 'hi'; end; h = {a: 1, b: 2}; f(**h)
[15:37:55] phaul: &>> def f(a:, b:) 'hi'; end; h = {a: 1, b: 2, c: 3}; f(**h)
[15:45:07] phaul: fyber: if you know that your hash exactly contains the args for the method than splat. ^, just be aware of that error I demonstrated
[15:48:58] phaul: that's just a wrong method definition.
[15:49:08] phaul: &>> def f(a:, b:, q=[]) 'hi'; end
[18:35:53] phaul: ? what happened al2o3-cr ?
[18:36:50] phaul: ah. England


[14:00:18] phaul: index % 5
[14:00:43] phaul: &>> [1,2,3,4,5][13 % 5]
[14:06:41] phaul: c-c arr.length is certainly nicer as, but 5 == 5 :)
[17:04:13] phaul: &>> fake Hacker.say_something_smart
[17:04:55] phaul: &fake Hacker.say_something_smart
[18:00:04] phaul: how do you specify --jit for rails db:seed ?
[18:02:26] phaul: havenwood: thanks
[18:21:46] phaul: I'm doing a bulk import of 'stuff about 200_000_000 of them in a loop.. I think it's a good candidate for it


[11:57:55] phaul: jim4: have a look at
[11:59:56] phaul: class vs module is an orthogonal question, it's a design decision not a packaging one. Namespacing you code is a good idea.
[12:28:24] phaul: << saves 4 bytes of source code
[18:53:59] phaul: try, PeterNewbie
[18:54:29] phaul: leftylink: :) 1 second diff
[18:59:44] phaul: PeterNewbie: that's just the bots way of ensuring that broken user input can be printed


[17:52:17] phaul: I've flagged the arch package out of date.
[20:14:36] phaul: kaleido: for a start = is assignment == is equality check. Further more numbers are not strings. and they not match string wise
[20:15:23] phaul: &>> 1.kind_of?(Numeric) # kaleido
[20:15:33] phaul: &>> '1'.kind_of?(Numeric) # kaleido
[20:56:00] phaul: &fake TvShows::TheITCrowd.quote
[23:36:25] phaul: al2o3-cr: Ronnie's performance was unbelievable. I just watched the final on yt. And against Mark Allan 6-0.
[23:36:47] phaul: And against Robertson


[13:54:09] phaul: Tuor: why don't you raise something that has the info about the error instead of using globals to store the error?
[13:57:40] phaul: RuntimeError can have a message raise message, just raise it, and when rescue, rescue it into a variable, then you can get your message via #message
[14:09:40] phaul: *.net *.split
[17:04:40] phaul: ?rails hello_world
[22:05:44] phaul: Celmor: it's probably to do with keyword arguments.
[22:06:30] phaul: f({:a => 1}) is the same as f(:a => 1) is the same as f(a: 1)


[10:48:28] phaul: you could maintain a Set with contents, and use Set#include?
[10:49:09] phaul: if your character set is limited for instance ascii you can implement hash with an array of include? flags mapping ords to bools
[10:49:16] phaul: that would be constant time
[10:50:33] phaul: you can try built in Set then. but that will require some data before it starts outperforming what you have now
[10:53:53] phaul: very hard to tell, but you can test. Use Benchmark on it, and you will see
[10:57:27] phaul: what i found about optimization is that ppl are incredibly bad at predicting why their code is slow. Whithout profiling its pointless to even think about optimizing. (Obviously don't implment ridiculous things, but just doing sensible code is enough) If you find your program slow, then profile. What you thought the reson your program being slow is never the actual reason
[10:58:46] phaul: I meant everybody
[10:58:58] phaul: me included
[11:01:15] phaul: I don't beleive that. You can calculate run time costs. That's one thing. The actuall complexity in the computer, being IO blockedor CPU limited, or cache limited, or memory bandwidth.. Are all only measurable
[11:08:59] phaul: I suggest you try ruby prof in combination with [kq]cachegrind to visualize your runtime costs.
[11:10:53] phaul: something like this


[16:42:00] phaul: do two methods equal if for the same input they produce the same output or if the source code matches? Moreover do they equal if the source code doesn't match but have onlyy insignificant differences like varibale naming or indentation? Also Is this the same as solving the halting problem
[16:50:10] phaul: no, Im pondering aloud. waheedi asked about this, and I'm not sure what constrainsts they had for their question
[16:52:00] phaul: I suspect knowing if they output the same would actually be equivalent to solving the halting problem
[16:52:07] phaul: which we know is impossible
[16:57:41] phaul:
[17:02:32] phaul: @ruby[bot] also works sometimes ^. if it doesn't rubydoc works with &>>
[17:03:54] phaul: depends on, which had been flaky in the past
[21:26:25] phaul: naezy: I'm assuming you are talking about rails. They have a dedicated channel
[21:26:31] phaul: ?rails naezy
[21:39:38] phaul: Quit: :wq
[21:42:49] phaul: has joined #RubyOnRails
[21:42:49] phaul: has joined #ruby-offtopic
[21:42:49] phaul: has joined #ruby


[11:37:37] phaul: &ri, works now
[11:38:10] phaul: but SHA256 is not accessible becasue it's done by const_missing
[11:39:33] phaul:
[11:44:28] phaul: (and not documented)


[23:18:43] phaul: ah. 256 is not allowed in class namesin my parser. sorry havenwood I fix it
[23:19:19] phaul: &ri Digest::SHA
[23:19:22] phaul: &ri Digest::SHA256
[23:21:00] phaul: ruby syntax rules are super complex :)



[14:30:07] phaul: merijn: I recommend reading an introductory book
[14:31:03] phaul: merijn:


[11:05:04] phaul: backreferences are also in ruby
[11:08:04] phaul: &>> "comment_xls".gsub(/(.*)_(.*)/, '\2 \1')
[11:08:21] phaul: problem is how you put the upcase on it
[11:08:44] phaul: '\2'.upcase is just '\2' :)
[14:02:41] phaul: &ri TracePoint
[14:02:51] phaul: ryouba: ^
[14:20:28] phaul: &ri TracePoint#method_id, ryouba
[14:20:37] phaul: or callee_id
[16:54:23] phaul: how about class MyError < StandardError; def initialize(hash, *args) super(args); @hash = hash; end; attr_reader :hash; end ?
[16:54:59] phaul: i forgot to splat args in super. but you get the idea...
[17:05:18] phaul: oh you mean set variable and check it in exception handler? for a start that assumes that the context of the raise is accesible at the catch
[17:06:54] phaul: I see, we agree.
[18:24:36] phaul: not fine. but that's the world we live in ;)
[20:10:46] phaul: &url, leftylink
[20:12:31] phaul: I dont know if this can do what you wanted, but now we have it :)


[10:24:12] phaul:
[11:18:35] phaul: al2o3-cr, leftylink ^
[11:54:06] phaul: map over the outer array with reject?
[11:57:34] phaul: yes that won't work. but & is just a shorthand for a longer block passing syntax
[11:58:14] phaul: compact doesn't take out empty strings iirc
[11:58:26] phaul: &>> [''].compact
[11:59:23] phaul: ctp: .map(&:thing) is just .map { |elem| elem.thing }
[12:04:56] phaul: &>> [['a', ''], ['', 'b']].map { |sub_array| sub_array.reject(&:empty?) }
[12:38:50] phaul: &fake Matz.quote
[13:12:42] phaul: ctp, that would work
[13:22:27] phaul: the thing I don't like about it is the way you handle mutation
[13:23:47] phaul: feels like one of the map! could be map. but maybe .each { ... .each { gsub! would be clearer
[13:25:55] phaul: &>> x = [['a']]; x.each { |sub_array| sub_array.each { |string| string.gsub!('a', 'b') } }; x
[13:26:27] phaul: to me this more clearly communicates that we are just iterating, and changing in place inside the iteration
[19:21:30] phaul: ah, Tom Stuart vids. I love them.
[19:25:04] phaul: monads is a fairly obscure concept and most struggle with it for a while. I tried to explain it to ppl in the past and failed miserably :)


[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: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:
[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?
[01:01:05] phaul: I see. That's valid point.
[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:07:51] phaul: not that, the regexp itself.
[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:10:23] phaul: yeah that's the thing I missed I think derpy was using, but I went down an other path
[01:11:24] phaul: tbh for me parslet is really not more overhead than regexps. I was already familiar with it
[01:13:02] phaul: during the years I wrote more compilers than programs to compile ;)
[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: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:20:21] phaul: interesting. this is different from the previous response
[10:11:27] phaul: ytti: what's the code you had before / after?
[10:12:07] phaul: Please provide a Minimal, Complete, and Verifiable example:
[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.
[20:42:44] phaul: DoctorMonocular:
[20:43:16] phaul: if you mean the cartesian product
[20:44:56] phaul: there is also repeated_combination, repeated_permutation combination permutation methods np


[10:39:54] phaul: leftylink: if you come up with a way on to load a gist, I integrate it into rubydoc the same way as &ast>>, &asm>> etc works it could be &gist>>
[11:14:01] phaul: yeah, that's what leftylink was playing with ^
[11:14:13] phaul: it's a good idea, but I don't think it's possible
[11:14:29] phaul: I mean grabbing it using
[11:15:24] phaul: but.. I could grab it myself. that shouldn't be security risk. It's just web requests, based on strings.
[11:15:40] phaul: yeah. ok. I'll do this


[13:53:19] phaul: You get a fairly quick response if you come in asking for help. If you come in for a rant it depends. Sometimes ppl are not in the mood
[14:22:05] phaul: &>> {'a' => { 'b' => { 'c' => 1 } } }.dig('a', 'b', 'c')
[14:24:15] phaul: gensym: ^
[14:28:24] phaul: dig works under the assumption that the hash either contains right data. the last level there contains 1, which is not right for looking up 'd' in it.
[14:28:37] phaul: s/either//
[14:29:22] phaul: &>> {'a' => { 'b' => { 'c' => {} } } }.dig('a', 'b', 'c', 'd')
[14:30:02] phaul: so question there is why the value 1 under 'c' if you expect hash under it (to look up 'd') ?


[14:17:13] phaul: &ri Array#shift, hightower3
[15:43:43] phaul: what's wrong with 1.digits.count ?
[16:38:23] phaul: bougyman: There is module nesting
[16:38:33] phaul: and that's orthogonal to inheritance
[16:39:25] phaul: &ri Module.nesting
[16:41:44] phaul: you split on '::' which is what nesting is, and you also deal with ancestors, which is inheratnce. Those are completely disparate things
[16:51:55] phaul: &>> module A; module B; module C; class D; def self.x; Module.nesting.first; end; end; end; end; end; A::B::C::D.x
[16:53:16] phaul: or Module.nesting[1] for the outer scope.
[16:54:59] phaul: &>> module A; module B; module C; class D; def self.x; Module.nesting[1]; end; end; end; end; end; A::B::C::D.x
[16:59:04] phaul: bougyman: the gist did self.class.ancestors.first which confused me. can you explain what that bit of code is supposed to do?
[17:39:56] phaul: &asm>> a = 1; b = 2; a, b = b, a
[18:07:39] phaul: I _think_ self.class.ancestors.first is just self.class. To get the parent class there is .superclass
[18:09:58] phaul: that^ is until al2o3-cr arrives with Fiddle :D
[21:46:13] phaul: zenspider: true
[21:51:07] phaul: based on what they said tho, I _think_ they wanted self.class.superclass. as they wanted parent?


[01:48:14] phaul: never seen timing out like that before
[01:49:21] phaul: &>> :test.to_s
[03:15:28] phaul: Ping timeout: 245 seconds
[03:17:10] phaul: has joined #RubyOnRails
[03:17:10] phaul: has joined #ruby-offtopic
[03:17:10] phaul: has joined #ruby
[15:21:22] phaul: Ping timeout: 244 seconds
[15:21:42] phaul: has joined #RubyOnRails
[15:21:42] phaul: has joined #ruby-offtopic
[15:21:42] phaul: has joined #ruby


[00:26:10] phaul: Ping timeout: 250 seconds
[00:27:29] phaul: has joined #RubyOnRails
[00:27:29] phaul: has joined #ruby-offtopic
[00:27:29] phaul: has joined #ruby


[09:48:01] phaul: al2o3-cr: same here. Also if I do double tab (on nick complete) it started inserting some emoji junk that I don't have fonts for
[09:50:48] phaul: must be some script then I have installed
[09:56:43] phaul: al2o3-cr: works! thanks
[11:00:33] phaul: Ping timeout: 244 seconds
[11:03:08] phaul: has joined #RubyOnRails
[11:03:08] phaul: has joined #ruby-offtopic
[11:03:08] phaul: has joined #ruby
[11:08:18] phaul: Ping timeout: 244 seconds
[11:12:08] phaul: has joined #ruby-offtopic
[11:12:08] phaul: has joined #ruby
[11:12:09] phaul: has joined #RubyOnRails
[11:19:14] phaul: Ping timeout: 250 seconds
[11:20:09] phaul: has joined #ruby
[11:20:10] phaul: has joined #RubyOnRails
[11:20:10] phaul: has joined #ruby-offtopic
[14:33:34] phaul: sure. inside the class it's just code. attr_* statements are just method calls. You can put them in a loop
[14:36:46] phaul: &>> class X; %i(a b c).each { |sym| attr_accessor(sym) }; end; x =; x.a = 1; x.b = x.a; x.c = x.a + x.b
[14:44:54] phaul: it's fine. but why store something that holds cells inside Entry instead. Like Array or Hash. Probably Array. and then just index []
[14:45:57] phaul: simpler loop would be ('@' .. 'AL').each do |col_letter| ...
[15:01:23] phaul: ryouba:
[15:02:22] phaul: myobj.method(:something)
[15:59:41] phaul: .values ?
[16:00:23] phaul: maybe not :)
[16:00:50] phaul: ah I missed the first pair of []
[18:12:23] phaul: Ping timeout: 268 seconds
[19:51:51] phaul: leftylink: it's that takes any risks. For the bot it's strings.
[19:53:06] phaul: I _think_ puts you in a fresh docker image per request but I'm not sure.
[19:53:14] phaul: &>> `ls -a`
[19:56:45] phaul: ah. ok. I misunderstood you point nm
[23:09:55] phaul: naeemarsalan: have you tried googling it?
[23:11:11] phaul:
[23:11:21] phaul:
[23:14:43] phaul: paste your code you tried and the error you are getting
[23:17:54] phaul: ignore that for now I'll look at pastebin
[23:18:42] phaul: ah. I get what's happening
[23:19:48] phaul: so. when the API returns an object that doesn't define a nice inspect method ruby default's it to the string with the class name and memory/address/object_id thingy
[23:19:57] phaul: let me demonstrate:
[23:20:11] phaul: &>> class X; end; p
[23:20:42] phaul: That's just the default string it gives for x.inspect. It's not the object x. It's just a string.
[23:21:14] phaul: if I did:
[23:21:44] phaul: &>> class X; def inspect 'hello!!'; end; end ; p
[23:23:24] phaul: thanks havenwood
[23:30:16] phaul: no. Have you tried calling get on it?
[23:33:24] phaul: something returned the object that when printed looked like <Oxidized::Node::Stats:0x00000001dcc228>. That object can receive a get (according to the docs). Then it will return a hash.