phaul

Activity Graph

Page 1 of 14 | Next »

2019-01-20

[09:52:26] phaul: has joined #RubyOnRails

2019-01-19

[10:13:10] phaul: wrong language? :)
[10:14:14] phaul: slices an array
[10:14:18] phaul: &ri slice
[10:14:24] phaul: ri Array#slice
[10:14:29] phaul: &ri Array#slice
[10:16:21] phaul: I'm always confused by fake code, taking everything literarily...
[10:17:42] phaul: ?fake xco
[10:18:58] phaul: just when asking ask with runable code, ppl will take your interpretation as real code
[10:26:30] phaul: c-c I think you missed the splat.
[10:26:54] phaul: there goes the one char saving :)
[10:33:02] phaul: &list slice
[10:33:46] phaul: interesting that Symbol has it.
[10:34:49] phaul: though symbol has all sorts of String ops now.
[10:50:28] phaul: these are all workable approaches but they give you slightly different behaviour. you need to consider whether a single (inmutable) attack object is ok per name or you need one dynamically ( newly created ) on each lookup by name.
[10:51:27] phaul: then you can think about the interface, which is an orthogonal question. Separate class, or same class class methods for lookup by name. All can work whichever interface you like better
[10:58:04] phaul: that's fine, but is there a reason that m.name is not already a downcased sym?
[10:58:20] phaul: would simplify your program a lot..
[11:15:03] phaul: group_by puts an array of objects into each groups in case there are more objects to go in a group
[11:16:07] phaul: &>> (1..10).group_by(&:even?)
[11:17:10] phaul: are you going to have a single Attack per name?
[11:18:36] phaul: are you on 2.6?
[11:19:17] phaul: move_list.to_h { |attack| [attack.name, attack] }
[11:19:44] phaul: or move_list.to_h { |attack| [attack.name.downcase.to_sym, attack] }
[11:21:23] phaul: I would avoid global vars at all cost
[11:22:49] phaul: Are these attacks inmutable? Just one object per name in the entire system? Or different attack Objects per name, just not in this list?
[11:25:03] phaul: let me code up something quickly that shows one idea...
[11:30:35] phaul: https://gist.github.com/43e909939a0c7bad0996a4b4e276d790
[11:36:48] phaul: but there are many ways to skin a cat
[11:39:49] phaul: one immediate advantage is that the commonality between certain attack types can easily be DRYed by moving them into a common superclass
[17:07:30] phaul: desperek: it doesn't seem like camping has a lot of traction. https://github.com/camping/camping/commits/master seems about ~20 check ins in the past 4 years. what's the appeal? If you want something small, why not roda?
[19:51:58] phaul: noboruma: can you elaborate a bit more? Where do you want to see the colours? What interface are you talking about? terminal? web? neither?
[19:56:33] phaul: https://github.com/sickill/rainbow an other one https://github.com/fazibear/colorize
[20:00:19] phaul: noboruma: is printing strings (in colour) what you want? you also said in place.. which makes me wonder you need more terminal control
[20:10:09] phaul: noboruma: Im sorry I don't fully follow. You can split up a string and then apply colours to sub strings and concatenate them back together. Colour here is really nothing more that inserting a bunch of ANSI escape sequences under the hood.

2019-01-18

[02:00:22] phaul: *.net *.split
[08:28:39] phaul: za1b1tsu: works fine if the module comes first
[08:29:57] phaul: pretty much
[08:32:23] phaul: it depends on what you are doing. making the code dependent on require order is not good practise. means that you have strong coupling between the things in those files
[08:33:25] phaul: but if they are strongly coupled mmaybe they are always required together. maybe expose a single top level file that outside world can require and that requires the former two in the right order
[08:48:03] phaul: za1b1tsu: or thinking about it. you could just require the ones that needs the other in that file :) simples ...
[12:08:15] phaul: al2o3-cr: just found a bug in ruby[bot] , wanna see?
[12:20:27] phaul: ok.. now Im getting confused.
[12:20:39] phaul: the bug was:
[12:20:46] phaul: ast>> `testing`
[12:21:08] phaul: which is obviously wrong.
[12:21:44] phaul: but seems that RubyVM::AbstractSyntaxTree also doesn't handle Kernel#` well
[12:24:08] phaul: &>> RubyVM::AbstractSyntaxTree.parse("`testing`")
[12:24:31] phaul: &>> pp RubyVM::AbstractSyntaxTree.parse("`testing`")
[12:25:40] phaul: maybe XSTRING is backticked string?
[12:29:18] phaul: ACTION expected to see method call
[12:33:52] phaul: RougeR: sounds reasonable to me, what's the issue?
[12:41:58] phaul: al2o3-cr: it's an acient old bug in ruby[bot] that rubydoc has inherited
[12:42:55] phaul: https://github.com/phaul/yarr/blob/evaluate/lib/evaluator.rb#L20 <- the bug
[12:53:18] phaul: but that shows that ripper agrees with rubyvm, it's an xtrsing. neither does method call to Kernel#`
[12:53:27] phaul: &ri Kernel#`
[12:59:14] phaul: maybe at the instruction sequence level...
[13:17:17] phaul: ok. here's a challange. given a string '`' using sub, susbtitute ` with \`.
[13:31:44] phaul: yeah. this is sooo broken. to_json also replaces \ with \\ when sending the request up. And on the server side you end up with %q`\\\\`testing`\\\\` which is again broken
[13:32:21] phaul: &>> require 'json'; '\\'.to_json
[13:34:37] phaul: yes that's correct
[13:35:18] phaul: ah. I shouldn''t look at the json serialized number of \ because the server surely desireilizes it!
[13:35:47] phaul: so confusing :)
[13:39:23] phaul: json is called on a hash, the hash has the string
[13:41:45] phaul: I'm just gonna push a refactor + specs + fixes in a second... let's see if this works.. /me fingers Xed
[13:46:30] phaul: &ast>> `testing`
[13:51:59] phaul: but include won't work there as the module is above the class in the ancestry
[13:52:15] phaul: prepend instead of include
[13:55:52] phaul: ok, maybe Im misunderstanding you
[13:56:17] phaul: let me show you the template string its using
[13:56:59] phaul: https://github.com/phaul/yarr/blob/evaluate/config/yarr_sample.yml#L48
[13:57:38] phaul: isn't it the same issue though? whatever delim Im using I need escape logic for the user code if it contains the delim?
[14:00:50] phaul: RougeR: you can include a module of the singleton_class of the object I guess
[14:00:58] phaul: let me try that..
[14:02:56] phaul: https://gist.github.com/791068846bffc49195620fb43dd62cb2
[14:03:38] phaul: or prepend, as al2o3-cr did, depending on which method you want to win
[14:04:30] phaul: then prepend
[14:08:00] phaul: ACTION afk
[14:37:54] phaul: al2o3-cr: ah, because the module is included in between the class and the singleton class. makes sense
[14:38:57] phaul: jarlopez: what sort of assertions on the args?
[14:39:12] phaul: maybe you just need .with not a block
[14:48:10] phaul: there is hash_including https://relishapp.com/rspec/rspec-mocks/v/3-8/docs/setting-constraints/matching-arguments
[14:49:20] phaul: for the multiple receives : https://relishapp.com/rspec/rspec-mocks/v/3-8/docs/basics/spies
[15:14:23] phaul: jarlopez: https://gist.github.com/9c919bb9b2dd4810d62e21f8c3f0ed4b took me a while :)
[18:38:02] phaul: ?botsnack
[19:09:47] phaul: Quit: bye
[19:11:08] phaul: has joined #ruby-offtopic
[19:11:08] phaul: has joined #ruby

2019-01-17

[22:15:44] phaul: kashike: https://gist.github.com/b8c74df6fe603e40187d2f19c813e818 ?
[22:21:22] phaul: group_by makes it get the deepest ones...
[22:21:56] phaul: goup_by actually groups them by depth ( count of / assuming that that's the path separator )
[22:22:05] phaul: then max get the deepest group
[22:24:38] phaul: it will not get directories that are not as deep but still leaf
[22:25:37] phaul: do you want the directories that don't have any child directory (leaf)? instead of what you said the deepest ones?
[22:26:52] phaul: right. so you don't want the deepest ones. you want the ones without sub directory
[22:33:41] phaul: kashike: np, gist updated. try again
[22:36:45] phaul: np. i just simplified the gist a tiny bit. There is a directory? method on Pathname directly

2019-01-16

[01:06:00] phaul: Scriptonaut: what's GlobalUser.superclass and what is GlobalUser.superclass.instance_methods.grep /receive_direct_message/
[01:07:29] phaul: doesn't matter. super calls superclass
[01:09:14] phaul: there is module prepend and rails used to do method alias chain
[01:09:43] phaul: https://stackoverflow.com/questions/3695839/ruby-on-rails-alias-method-chain-what-exactly-does-it-do
[01:10:03] phaul: quick google I havent actually read this, but should point you in the right direction anyway
[01:11:25] phaul: module prepend is the modern way of doing this
[01:11:52] phaul: override it in a module that you prepend, and in that module you *can* call super
[01:16:28] phaul: &>> class X; def f; 1; end; end; module Y; def f; super * 10; end; end; X.prepend(Y); X.new.f
[01:22:56] phaul: it doesn't have to be at the bottom of the file it can be right next to your method
[01:24:29] phaul: &>> class X; def f; 1; end; self.prepend(Module.new { def f; super * 10; end; }); end; X.new.f
[16:47:26] phaul: no I think it's the Rakefile. you should run it with verbose out and try to get the logs from that
[16:49:25] phaul: my heroku knowledge is really foggy I only tried it once in the past. Can you not set how to run rake via some environment variables?
[16:50:15] phaul: it seems you can just give it normal switches https://devcenter.heroku.com/articles/rake
[16:52:28] phaul: or try heroku run rake --trace assets:precompile
[16:57:43] phaul: yeah Im not too familiar with heroku, sorry... I was hoping to get a backtrace somehow, but I'm not sure how.
[17:45:04] phaul: c00l. important thing is that it works
[18:05:27] phaul: evening sandelius
[20:59:09] phaul: Hoffman: you are using a private API which I don't think was meant to be used to check for equality. There diff description is "empty", only a newline.
[21:01:22] phaul: Hoffman: https://github.com/rspec/rspec-support/
[21:04:18] phaul: I mean looking at the diffing method it seems they try to format for RSpec output only considering how it would look if it has to print a diffable object mismatch. They don't seem to care about extra newlines not being in the actual strings they are diffing.
[21:05:18] phaul: I meant on that gihub project page the first sentence is : Not intended for direct use.
[21:08:45] phaul: ponzii: yes modules cannot be instatiated. But they can be mixed in into classes. In that case their instance variables will belong to the instance of the class
[21:12:27] phaul: hm there are two kind of modules. Modules that are meant to be mixed in and modules that are meant to be used on their own. (and some whacky ones that can do both). Bot each kind is a self contained unit that's sensible on its own.
[21:14:17] phaul: Just the ones that are mixins exist to be mixed in. There is some tying there sometimes with what the mixing in class should implement. That's usually well documented. Examples: Comparable wants <=>. Enumerable wants each.
[21:17:02] phaul: maybe not self contained but the best option for what it does: implement some common aspect of classes that would have been replicated in all classes otherwise, but something that is tightly coupled with the class. Like being Comparable is a good example. Common task, but the actual class know how to do <=>.
[21:18:01] phaul: let's talk about the other question you asked. instance vars outside of Module scope. can you link the line on github?
[21:20:40] phaul: what line number are you looking at?
[21:23:37] phaul: https://banisterfiend.wordpress.com/2010/11/23/what-is-the-ruby-top-level/
[21:25:30] phaul: they just become instance vars of main
[21:27:30] phaul: ponzii: it is an instance of class Object
[21:27:59] phaul: &>> @a = 1; [self, self.instance_variable_get :@a]
[21:28:30] phaul: &>> @a = 1; [self, self.instance_variable_get(:@a)]
[21:29:42] phaul: np. If that's how you feel, Im not trying to convince you otherwise
[21:34:16] phaul: devil_tux: definately second out of the two
[21:44:52] phaul: &ri String#<<, Hoffman
[21:46:42] phaul: or be perly ( if it's even perly) on the last line: @instance << x and return false
[21:47:42] phaul: no. use and
[21:47:45] phaul: that's the point
[21:49:01] phaul: and precedence is such it is meant to chain thing like do this and do that. && is meant to be used for &&ing booleans
[21:57:55] phaul: going back to version 2. we haven't talked about why you disliked it.. To me that is the obvious solution
[22:01:12] phaul: but if it's not always truthy the two programs are not even doing the same!
[22:01:26] phaul: al2o3-cr: what's the example of falsey?
[22:02:10] phaul: &>> '' << '...'
[22:05:13] phaul: because obviously you want to append '...' to all those ( including nil )
[22:09:42] phaul: well, sometimes you don't formally establish the preconditions, just go with your gut feeling of what they probably meant
[22:16:59] phaul: yeah. and is more idiomatic there but don't do any of that
[22:24:07] phaul: Hoffman: bang does not mean self modifiying or destructive methods.
[22:28:18] phaul: there are booleans, true and false. and apart from that values are either truthy and falsy
[22:29:35] phaul: al2o3-cr: you want to start the philosophical discussion of what it means to be a boolean. Ok what's the definition of a boolean
[22:30:35] phaul: Here's my definition: booleans are true and false and they exist in Ruby
[22:52:06] phaul: btw nil << '...' is not falsey
[22:52:24] phaul: it doesn't even run. That't not what falsey is
[23:00:11] phaul: sure, in the heat of the discussion it was said as a falsey example. thats all
[23:01:38] phaul: in which case neither code works
[23:04:25] phaul: right. so from the which code is better you managed to conclude that the question was incomplete, and the methods are all broken. Congrats to all
[23:13:42] phaul: he said it. he wants to append '...' to string arrays. its just that the channel is really found itself being pedantic on preconditions for instance variable values all of a sudden
[23:25:37] phaul: al2o3-cr: you really are the fiddling wizzard :) now iterate it
[23:27:47] phaul: you have double include
[23:39:04] phaul: I was rooting for Ronnie for a long time, but these days I'm less interested in snooker.. two much depends on a single bad or unfortunate shot. usually there is no coming back at top level

2019-01-15

[00:01:56] phaul: is that cookpad.com?
[00:17:25] phaul: Thanks havenwood I add them on my list
[00:18:32] phaul: I don't think it matters as you always have to factor in the living costs. If an apartment is 3000$ pcm in SF it doesn't really matter if I get twice the salary...
[00:19:57] phaul: as a reference, I was paying ~650 GBP for my flat per cm 2 years ago in the lovely Watford
[00:20:12] phaul: (lovely is sarcasm)
[00:27:06] phaul: hm Js is not my strong side. I did quick experiment projects like playing with react, but here (airbrake) I don't feel myself qualified.
[00:28:52] phaul: maybe I should take my boat over to SF! :) that would be a hell of a sail !
[22:06:46] phaul: Read error: Connection reset by peer
[22:22:55] phaul: has joined #ruby-offtopic
[22:22:55] phaul: has joined #ruby

2019-01-14

[11:21:10] phaul: you can run shell commands like `ls -a`
[11:21:45] phaul: &ri Kernel#`
[11:33:56] phaul: exec replaces the current process with the one you point to. it's a lower level primitive. To implement `` you need exec but you also need fork, and capturing the child processs output. `` does a lot more
[11:34:10] phaul: &ri Kernel#exec
[12:53:20] phaul: &ast>> 'testing'
[12:53:41] phaul: &ast20>> 'testing'
[13:10:46] phaul: while in ruby is a keyword not a method. and it has a body not a block
[13:11:02] phaul: loop on the other hand is a method.
[13:37:26] phaul: ACTION confused
[13:38:14] phaul: i expected undefined local variable or method _
[13:39:16] phaul: or _=_ :)
[13:41:51] phaul: &>> a=0; f=->{a+1<3}; _ while f[]; p :hello
[17:50:00] phaul: echo gogo | sed s/./x/ # => xogo
[17:50:22] phaul: sed works the same way
[17:54:22] phaul: I mean sure. go for it :)
[21:32:13] phaul: baweaver: how are things?
[21:35:30] phaul: same. brought up rubydoc ast to use the new 2.6 RubyVM for ASTs instead of ripper.
[21:37:50] phaul: I saw it. I started followin you on github, it came up on my dashboard . or whatever the root url is called
[21:38:01] phaul: Neat little project
[21:40:42] phaul: yeah, I saw al2o3-cr's example yesterday. seamed like it can do anything
[21:42:30] phaul: I need to find a job at some point... I tried honeypot.io that was a disaster :(
[21:43:55] phaul: backend, DB, Ruby ... mainly Ruby. Im ok with Rails too
[21:44:22] phaul: or sinatra or roda, or stuff not even we related
[21:46:12] phaul: these days I have a feeling things are moving towards react.js client side apps, not much logic left on server side. and while it's very logical, it does not interest me that much
[21:46:31] phaul: or other js libraries not just react
[21:46:43] phaul: that's the one I "know" (tried)
[23:26:06] phaul: booring.. then it took an interesting turn :)
[23:29:06] phaul: ACTION wanted to make that ^ pun last time it was on, but missed my chance
[23:32:54] phaul: oh, al2o3-cr I was afk, when you asked. yes rubydoc has parslet
[23:36:38] phaul: np. https://github.com/phaul/yarr/blob/master/lib/yarr/input_parser.rb
[23:51:45] phaul: atm Im hangin out at my father's which is in Hungary, but Im looking for something in south England
[23:52:30] phaul: my dream is to find a remote job :) with only occasional turning up in London or something
[23:54:09] phaul: baweaver: was that what you mean? I'm not sure I got what you were asking

2019-01-13

[17:44:33] phaul: i removed that form tag from outside and I can confirm the params are correctly sent up to the post handler
[17:44:59] phaul: the outside post tag screwed up firefox and made the submit a GET request.
[17:45:24] phaul: you might not be on firefox, so you might see slightly different behaviour
[17:45:37] phaul: but it was wrong anyway
[17:53:27] phaul: what is the error that you are now getting/
[17:54:13] phaul: read carefully the error report. the word student
[17:55:13] phaul: sudent vs student
[17:56:46] phaul: our brains are programmed to fix spelling errors for us, it's really hard to spot especially if you wrote it
[17:57:27] phaul: dont. its very typical in programming,
[17:57:35] phaul: happens to everybody
[18:03:39] phaul: np. I dont know your background, but what you are working with after 2 weeks is pretty impressive. I would argue that you are maybe progressing too fast. Is this some course exercise? Did you have a programmer background ?
[18:15:46] phaul: let me think
[18:20:29] phaul: I think this bit is conceptually broken: <% if(post.id == answer.id) %>
[18:20:32] phaul: <%= answer.studentanswer%>
[18:20:34] phaul: <% end %>
[18:22:02] phaul: the post is the question. the answer might be filled in might not, but shouldn't it be something like post.id == answer.post_id ? what is the id column of the answer table?
[18:23:17] phaul: yeah, I get that part Im confused by the ids being equal? Is the answer.id a reference into post ? ( if so it's better to call it post_id )
[18:24:34] phaul: right. usually ppl call foregin keys, like <other_table>_id, it just confused me that's all. but now I get it
[18:27:25] phaul: you could have a hidden form input with the id encoded in its value.
[18:28:25] phaul: <input type="hidden" name="post_id" value="<%=post.id%>" />
[18:28:59] phaul: then read post_id out of params in the sinatra handler
[18:39:52] phaul: do you mean in the controller side?
[18:40:12] phaul: we send up params[post_id]
[18:41:29] phaul: push you code up to github, I take a look
[18:45:56] phaul: ah, ok. no problem
[18:51:04] phaul: you have to have =
[18:51:12] phaul: <%= post.id %>
[18:51:22] phaul: and you have to move it inside the form tag
[18:51:55] phaul: the way form submitting works is that it gathers all input from the same form tag as the submit button was pressed in
[19:11:05] phaul: you are welcome, if you feel stuck in the future #ruby is the place :)
[19:52:50] phaul: &>> RUBY_VERSION
[19:53:02] phaul: &>> (1..)
[19:53:27] phaul: thanks jhass