#ruby - 21 July 2018
« Back 1 day Forward 1 day »
[04:14:37] Alec: There's this book called "Functional Analysis: Vol 1" - "A gentle introduction" by Dzung Minh Ha - great book but not applicable to probably anyone else here - unfortunately it's long out of print and the versions I can find are hyper-expensive (>£150 damaged book that'll take weeks to get here) - I have reason to believe a PDF of it exists, the publisher's website may be dead and has these weird locked PDFs and I'm Linux, Printer and those A4-k
[04:16:02] Alec: I've got a copy in storage, so one book in like 45-50 boxes 50cm x 45cm x 50cm boxes all books - they're going to want me dead if I take them up on their "access items" thing,
[04:16:42] Alec: If anyone can find a PDF of this I owe you massively; so much so it becomes economical for me to kill you before you have an heir who may inherit the debt, or you and your heir.
[04:21:16] Alec: I've been after this for months, it should go without saying I'm desperate to be posting here. I've even tried a few "specialist forums"
[04:31:45] Alec: mozzarella: no but I could get it if it was guaranteed (within reason) I could read it (there are "test PDFs" in the link, according to what it says if I can read those I can read what I buy)
[04:32:53] Alec: I wish the author hadn't chosen such a shitty and tiny publisher (jackpot on both!) because the book is actually *extremely* good - just no one has bloody heard of it, I found it by dumb luck in the library.
[04:34:41] Alec: Also the author is dead so no appealing to him (hence the "vol 1" over 10 years ago)
[05:29:21] siery: Hey! Is there somebody still using rake to handle your dependencies? Why are there so strng effort on runing bundler if ruby have such a nice task handler already?
[05:34:55] dviola: siery: they kind of do different things, right? bundler is supposed to only manage dependencies and nothing more, rake is more like a general purporse make-like tool
[05:38:32] dviola: I guess there is nothing stopping someone from writing a Rakefile that will call git clone for all the libs they use
[05:39:42] dviola: now whether that is a good idea or not, I don't know, bundler also does other things like locking the versions of gems you use, etc
[05:41:47] siery: dviola: Right, but I see that people prefer using bundler more then rake. I been wandering if there is some reason to this, because bundler is much more complicated in my opinion. I know that bundler can handle pushing gems to the server, right? I am new to ruby, so just wander what wold be better to use for the game I'm writing. Do I need to use bundler to push gems to the rubygems repo?
[05:45:54] dviola: siery: maybe because of Rails, since it default to using bundler and creates a Gemfile in your project's directory
[05:48:07] siery: But this is not the only interface (besides browser) to publish your gems to rubygems?
[05:53:44] dviola: siery: stay around and someone else might be able to answer your other questions, I have to go
[05:54:02] siery: dviola: Thank you. I just ask cause that will mean I can just create a task in rake like :push to automate my commits and still use just one interface for handle all my package related work.
[10:44:03] plp_: is there a way to expose class instance variables to instances of the class but not anything else?
[10:44:44] plp_: closest answers i've found are https://www.ruby-forum.com/topic/3255967 and https://stackoverflow.com/questions/2441524/closest-ruby-representation-of-a-private-static-final-and-public-static-final
[11:34:51] apeiros: plp_: you… don't expect us to read a whole thread to understand what kind of solution you might have found in it, do you?
[11:38:12] plp_: right. sorry. they pretty much just suggest adding attr_accessor, attr_reader, or attr_writer for the class instance var
[11:45:57] konsolebox: i'm getting an idea of what you really want, but i'd rather have you clarify it first
[12:06:23] apeiros: plp_: you want to keep the class state private except for instance of that class, as I understand it
[12:07:02] apeiros: and I think there's no clean way to do that. @@class_variables do that, but sadly they're shared beyond class + instances. they're also shared across descendants.
[12:07:51] apeiros: class Foo; class << self; attr_reader :class_state; private :class_state; end; private def class_state; self.class.send(:class_state); end; end
[12:08:12] apeiros: now you have a private instance method to access the class state. it uses send to bypass the privacy setting of the class method.
[12:19:04] ruby[bot]: plp_: we in #ruby do not like pastebin.com, it loads slowly for most, has ads which are distracting and has terrible formatting. Please use https://gist.github.com
[12:20:22] apeiros: plp_: anyway, check my suggestion. it only slightly deviates from what you already have.
[12:28:05] konsolebox: plp_: i think apeiros's suggestion is the best solution you can have. you can't restrict the class's singleton method for itself, and allow the instance to have special access to it.
[12:28:55] apeiros: plp_: that way? you mean `private def foo`? it's only since def returns a symbol instead of nil. sometime around ruby 2.1 I think?
[12:31:36] apeiros: I should add a !unroll command or somesuch to ruboto so it creates a gist with ; replaced by newlines and proper indent.
[14:25:06] KaffeeJunky123: I have a method that will read user input in a bunch of different units and I've been looking for an easy way to deal with the different units. Basically I just need to be able to call the right input verification function for the unit, is using a hash with unit=>Proc a good solution for this kind of problem?
[14:39:23] apeiros: alternatively have a Verification base class, let unit based classes inherit from it and then have a unit => class hash.
[14:50:03] apeiros: maybe. depends on the complexity of your verifiers. it might save you some lines if you have a lot of repetition which can be saved through inheritance.
[14:50:59] apeiros: anyway, you know the problem domain best, so you'll have to decide what fits your problem better. a unit => proc hash is certainly very versatile anyway. it might make sense to start out that way anyway.
[14:51:52] KaffeeJunky123: apeiros: It's a simple application that calculates ml amounts for different compounds of an e-liquid for vaping
[14:58:35] KaffeeJunky123: apeiros: https://gist.github.com/KaffeJunky123/c45eaabefa2af733231e9f95fd44bc48
[15:00:45] apeiros: print_amounts I'd probably make the arguments kwargs. that way invocations of it are much easier to read and understand what the passed values are about.
[15:05:48] apeiros: re "I should wrap" - yes, that's one way. or you can `input = gets&.chomp`, input will be nil in case of end-of-input.
[15:08:16] KaffeeJunky123: apeiros: I didn't know about that way to use the ampersand, or is it not an ampersand in that context?
[15:16:01] apeiros: KaffeeJunky123: &. is called "safe navigator" and works like ., but it won't raise a NoMethodError if the receiver is nil
[15:16:35] apeiros: hence nil&.chomp will just return nil, even though nil isn't a string and hence doesn't have chomp
[15:19:41] KaffeeJunky123: apeiros: now you've got to start vaping too, so you can test if the end result is okay ;-)
[15:20:12] apeiros: KaffeeJunky123: https://gist.github.com/apeiros/b5f7f16a770fa3d49d6502737516b885
[15:21:20] apeiros: btw., to get stuff aligned, if you use sublime text, there's a plugin "valign". makes that really simple.
[15:21:33] KaffeeJunky123: apeiros: pure thc? why would you want to get rid of the other sweet stuff?
[15:22:03] KaffeeJunky123: apeiros: I use nvim most of the time, trying to migrate to spacemacs thou
[15:22:27] apeiros: alcohol's effect is limited and the side-effects at the level I'd need it are unpleasant
[15:23:20] KaffeeJunky123: apeiros: states that have legalized it should have high quality thc e-liquids
[15:25:15] KaffeeJunky123: apeiros: I would've suggested taking this conversation to a more private place
[15:26:59] apeiros: btw., `Integer(ml, 10) rescue false` is quick and dirty and I absolutely don't recommend on using this pattern
[15:27:38] apeiros: it can hide severe bugs as it indiscriminately suppresses all exceptions below StandardException
[15:38:54] apeiros: KaffeeJunky123: no, on a validation & adaptation gem. it's part of a bigger project, though.
[17:10:05] Demos[m]: totally off topic: does anyone know of a font like fira code but not monospace?
[18:44:04] apeiros: Demos[m]: I use deja-vu for coding, I use the monospace variant, but iirc it has non-monospace variants too. no idea whether that's "like fira" (no idea either how a font would qualify as that)
[18:44:54] Demos[m]: I use Noto Sans UI (or Noto Sans Display on windows, not sure why the name differs)
[22:12:02] jamiejackson: i'm trying to iterate over a hash inline to build a string: https://gist.github.com/jamiejackson/176cf94c7b1766fd7f0f92601ab16586
[22:26:20] ruby[bot]: -bbbb $a:chouhoulis$#ruby-fix-your-connection chouhoulis!*@*$#ruby-fix-your-connection chouhoul_!*@*$#ruby-fix-your-connection chouhou__!*@*$#ruby-fix-your-connection
[22:26:35] ruby[bot]: -bbbb chouho___!*@*$#ruby-fix-your-connection chouh____!*@*$#ruby-fix-your-connection chou_____!*@*$#ruby-fix-your-connection *!*@50-207-64-46-static.hfc.comcastbusiness.net$#ruby-fix-your-connection
[22:30:52] apeiros: also probably another one broken by php's "everything is a template, so just echo"