#ruby - 05 October 2017
« Back 1 day Forward 1 day »
[07:38:54] rakm: how would I do a while/until look where I assign to an object to a variable and call a method that has a satisfactory return value?
[07:40:37] rakm: but the point is that my get_random_number method returns a number, and i want to call a method on it, but i want to assign the number to the variable
[07:48:38] rakm: tobiasvl that was just a (bad) example. here's something more realistic: https://paste.pound-python.org/show/BJgPyvf98tP6zCVs1TeK/
[07:50:33] rakm: i have to assign x the first time manually to do that. is there an equivalent oneliner?
[08:35:45] Harzilein: so, many gems and their constituting objects implement the api needed for pp... which makes me wonder if there are alternative pp renderers with, say, html output or something
[10:08:13] Harzilein: darix: i don't want to format code, i want to tap into objects where helpful programmers thought of a pp based presentation. that data would be useful to me when i could control the formatting more
[10:08:51] Harzilein: darix: naturally before i go and write a formatter myself, i want to look if someone already did that
[10:10:50] Harzilein: darix: rouge is for formatting _source code_. i don't want to format source code. as for the building html from it part: i can build html myself well enough. the important part is that i'd prefer to stay ignorant of the pp particulars when there's a gem that already interfaces in the same way as pp does
[10:12:28] Harzilein: so pp works by providing a bunch of callbacks and passing the pp object into a pretty_print function that calls those. i'd have expected at least a dozen formatters based on that very api, providing the same callback methods as pp does
[10:15:44] Harzilein: darix: to repeat: i _do not_ want source pretty printing. just because something is called a pretty printer it would _not_ involve source highlighting. thank you but no thanks.
[16:11:47] havenwood: fChanX: It's not particularly good for GUI bindings or high FPS-related things.
[16:12:07] havenwood: fChanX: It's not a system language or embeddable (though there's mruby for the latter).
[16:15:51] setient: what about crystal or using ruby llvm stuff to compile down to a binary :) i am kidding.
[16:24:37] cschneid_: Is there a gem or helper to edit Gemfiles? Operations like: "insert <xyz gem> after <existing gem> into <dev, test> groups"?
[16:33:22] cschneid_: darix: trying to automate the setup of a lot of docker images, with different versions of gems & such - basically a CI type system, but locally. "Here's the base Gemfile, but then plug in unicorn plz".
[16:36:22] cschneid_: interesting. Looking, but it may end up with me just doing silly sed commands...
[20:36:56] eam: prutheus: you should be aware, circumventing a captcha in this way may constitute a felony
[20:40:05] eam: you've read the terms of service on that page? It's not criminal to ignore terms of service (civil matter, reasonable outcome of winning) but it can potentially be criminal to bypass a restriction mechanism -- the captcha
[20:43:45] teatime: prutheus_: if you're in the US, the CFAA can be read to make all kinds of ridiculous things criminal.
[20:44:29] prutheus_: well, that is no problem at all, because I do not bypass the captcha illegally. I view it and enter the code manually. So this is legit in sense of the captcha is blocking violential access.
[20:48:11] eam: you may find your theories don't hold when push comes to shove, but hey, no skin off my back
[20:50:33] eam: prutheus_: their terms request that you not scrape and the captcha is a restriction mechanism attempting to enforce those terms. Violating their terms isn't criminal, but bypassing a control mechanism may be
[20:51:18] prutheus_: ok, but this is my problem i think ^^ could you please help me breaking the captcha problem i meintioned?
[20:52:45] havenwood: prutheus_: We have this nasty thing called the DMCA that criminalizes circumventing even feeble technical protections for copyrighted work.
[20:53:24] havenwood: prutheus_: If you can lawfully do what you're trying to do, maybe look at Selenium.
[20:53:38] eam: interestingly though, and contrary to the claims on that page, I do not think the content in question is under copyright
[20:54:23] eam: for two reasons: 1) can't copyright facts, and 2) California is one of the states which generally prohibits its government from copyrighting its own works
[20:55:57] teatime: a lot of times that second thing is gotten around by hiring a private contractor to create the work.
[21:00:58] prutheus_: problem is that noone want to use selenium for web scraping :D it is also too slow
[21:01:17] prutheus_: i mean i get mechanize nearly workiiiiiiing, there is just one little blob missing to get my problem solved i think
[21:03:31] eam: well I have to thank you because this conversation reminded me to pay my 2017 property taxes ...
[22:12:09] havenwood: rakm: but you could check the arity of the current method and call it again with different arguments - where do the alternative arguments come from?
[22:13:08] havenwood: rakm: You'll have to show some code or describe more what you're doing for us to give better answers.
[22:13:41] havenwood: rakm: You can check what your current method allows for parameters from inside the method like above ^
[22:16:50] havenwood: >> def example argument, another_argument = nil, keyword: true; method(__method__).parameters end; example 42 # rakm
[22:16:51] ruby[bot]: havenwood: # => [[:req, :argument], [:opt, :another_argument], [:key, :keyword]] (https://eval.in/874600)
[22:17:38] rakm: havenwood something like this: https://paste.pound-python.org/show/WEOIno7vnL008Qy0ASWP/
[22:17:52] rakm: was wondering if instead of recalling the method, i could use retry to any advantage
[22:19:05] havenwood: rakm: So you have a recursive method and are looking for possible better solutions?
[22:22:40] rakm: basically, i get person ids from a different source, but the update could fail (in some external code) if the person doesn't meet some conditions
[22:23:14] rakm: getting a random person is expensive, which is why i memoize it and have a refresh option
[22:24:06] rakm: i'd like to configure it to run multiple times with an variable that only exists in that method's scope. it looked like retry would be able to do it
[22:24:47] havenwood: rakm: yeah, if you want to change one thing and retry, that might be a good way to go
[22:25:13] rakm: i don't want to keep a count in an @ivar, since that @ivar will not be relevant outside this method
[22:25:31] rakm: i guess i can keep a counter (for number of retries) and pass it in as an argument..
[22:31:50] havenwood: >> def example; meth = :explode; begin; send(meth, 'rakm'); rescue NoMethodError; meth = :puts; retry; end; end; example
[22:32:47] havenwood: rakm: instance variables aren't required ^, but anything you set in the rescue will get stomped on if redefined *after* the `begin`.
[22:34:46] RickHull: Hi, I'm trying to debug this travis failure, which I think is an old bug in some combination of Ruby 2.1, rubygems, and bundler versions https://travis-ci.org/rickhull/loremarkov/jobs/283055198
[22:35:16] RickHull: `bundle install` fails with NoMethodError: undefined method `spec' for nil:NilClass
[22:35:38] RickHull: These look related: https://github.com/bundler/bundler/issues/3558 https://github.com/bundler/bundler/pull/3559
[22:36:45] RickHull: here is my .travis.yml -- the failing run corresponds to `rvm: - 2.1.2` https://github.com/rickhull/loremarkov/blob/master/.travis.yml
[22:37:50] RickHull: I'm planning on updating to newer rvm entries. 2.0 is EOL'd I think, but it also doesn't hurt to test against it
[22:45:58] RickHull: it looks like travis now supports installing without bundler; trying that since I have no deps