#ruby - 28 January 2019
« Back 1 day Forward 1 day »
[08:40:16] Knappe: Hi, is there a way in ruby, maybe utilizing the IO class, to get behaviour like the tail tool from Linux? I'd like to read only the last n lines of a log file. The logfile can have >20k line at times and it would be really expensive to read the whole file when I know the information I want must be in the last 50 lines or so.
[10:28:04] AndreYuhai: Hello there, I am using Mechanize and I sometimes get 503 exception. I am rescuing this exception but how can I make it sleep(5) and try again as long as it gets this exception?
[10:28:43] AndreYuhai: I can just sleep and try it again by simply putting agent.get url inside the rescue block but what I want is a loop to do that as long as it gets that code
[10:32:19] khalella: im trying to get a clue as to what is missing here. im getting an error "rake aborted! LoadError: cannot load such file -- rake/pathmap /var/lib/gems/2.3.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:274:in `require'"
[10:39:48] jhass: especially since it errors out on trying to load a part of rake, which is loaded before Bundler gets a chance to restrict the load paths
[10:40:52] jhass: https://github.com/ruby/rake/commit/f804fc2b56558100f840d2341823e74f25fc1e4a#diff-dbc34d9d73d6859840ceb61605d344c0
[10:41:18] jhass: so your AS version is either too old or your rake version is to new, depending on how you want to put it
[10:41:29] jhass: either restrict to an older rake version in your Gemfile or update your AS version
[10:42:23] jhass: well or maybe something else triggers it actually, given the trace part you showed is just the by AS overwritten version of require
[10:49:28] jhass: just remove that line and if that doesn't work out replace it with require 'rake/ext/string'
[11:02:57] catphish: i have a strange bug whereby i have a gem that uses readline to ask a user for some input, if i run the gem's bin directly, all is well, but if i run it via rubygems's wrapper, readline randomly prints "\r" to my screen when i've entered a line of text
[11:19:59] Dwarf: Hello folks. I'm trying to use OpenSSL and I want to use a client certificate, but it seems the server (in this case, an IRC server) is not receiving the client certificate. Code is as follows: https://p.bcome.nl/?8607c13436915bc0#A1bVmEiDM1l3vu7iuFRFq3gF6NzAJfNg1fi//+H5B80=
[11:21:18] Dwarf: Admittedly the docs at https://ruby-doc.org/stdlib-2.4.5/libdoc/openssl/rdoc/OpenSSL/SSL/SSLContext.html aren't really clear on what to use to send a client certificate. Perhaps what I'm looking for is client_cert_cb?
[16:43:29] maryo: I have a open call for reading a file, something like this https://dpaste.de/kMWZ does it really need a close call too?
[16:50:37] canton7: maryo, yes. However, prefer the version of File.open 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 File.open 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 File.open which takes a block
[16:56:06] maryo: canton7, sorry about it. Just bit confused about this file operations. Does this close call looks valid now? Please suggest -> https://dpaste.de/COkA
[16:59:13] maryo: canton7, sorry I am bit new here. Could you please show me an example on what you mean
[17:01:14] phaul: maryo: when you open a file / keep open the file, internally a structure is created a file descriptor aka IO object that keeps track of how far you have read into the file, what position to read next etc. That's how read_line calls can progress through a file. opening is for creating this tracking structure, and closing is destroying this tracking structure
[19:22:04] catbusters: I'm trying to use Ruby to parse some HTML, and I'm getting some text that looks like this: "they're in a"
[19:36:02] havenwood: catbusters: Nokogiri is a gem. It's the most popular Ruby HTML parser. CGI is in the stdlib.
[19:37:16] havenwood: catbusters: I wasn't sure if you were already using Nokogiri. Yeah, it's a good way.