#ruby - 14 March 2018
« Back 1 day Forward 1 day »
[00:28:36] RedNifre: Hi. Is there a way to convert a string with length 14 bytes to an integer and back? Just by interpreting all the bytes as one big number? E.g. 65 should turn into a string with A and 13 NUL bytes.
[00:29:54] RedNifre: I mean I guess I can do it manually somehow but I was wondering if there was an elegant way to do this.
[00:40:37] RedNifre: eam nice, I only have to add a .force_encoding('utf-8') to that to deal with the multi byte characters :)
[00:44:40] RedNifre: Is there a simple way to convert an int to a byte array or do I have to chip away at it with modulo?
[00:47:06] eam: [1919116659, 1663071333, 1684366447, 1936026912, 1701273971, 1868832883, 544483182, 1819043188, 1701344288, 1634038816, 1919248483].pack "l*"
[11:42:37] morfin60: dminuoso, well i just want to find out which objects count is constantly growing
[11:47:15] morfin60: i have Sidekiq performing some tasks and eventually it consumed all memory + all swap
[12:35:53] dminuoso: morfin60: There is a gem called memory_profiler, but I have no experience with it
[12:51:41] morfin60: well, i know some native extension can allocate and do not free memory but there is pretty low chance of this because whole thing consumes bunch of memory
[12:53:03] `derpy: http://ruby-doc.org/stdlib-2.4.1/libdoc/objspace/rdoc/ObjectSpace.html#method-c-trace_object_allocations_start
[12:53:50] dminuoso: morfin60: You can do other things do (just look at the class description), and finally `dump` it into a file (either human readable or json), and then work with that
[12:55:13] dminuoso: morfin60: In my experience the most common cause is somehow maintaing references to objects where you shouldn't (or sometimes where you should be using WeakRef instead)
[12:55:46] dminuoso: morfin60: It's also possible the GC is misbehaving, so be sure to look at it too
[13:11:04] mrproper: Need help with this. I'm using Resolv.getaddress and rescuing from Resolv::ResolvError to see if a hostname exists but this is not handling problems with the DNS server itself (not listening, timeouts, filtered...) how should I control those problems? I can't find any suitable exception in the documentation apart from ResolvTimeout
[13:13:27] mrproper: dminuoso: I'm not trying to rethrow anything. I'm just catching that exception to get a list of hosts not in the dns
[13:16:54] mrproper: dminuoso: so this is part of the code https://gist.github.com/anonymous/a81d252184c62ca71d920a00474a56e7 I check fo a list of hosts and if they are not in the dns I add them to an array to deal with them later. Now, if the dns is not available or I have a timeout or the url of the dns is wrong, the host will be added to the list too
[13:18:35] mrproper: imagine that the ip of the dns server answers to pings but the server is down. I don't want to remove hosts just because of this
[14:08:00] X-Jester: when using something like net-http or rest-client, is there a way to ignore a certain content type? specifically, can i configure one of these libraries to skip downloading a binary file if the link redirects to one? to save time and bandwidth?
[15:45:35] ineb: X-Jester: no, what instance would do the content-type checking? in http, you make a request and get a response (commonly via tcp)
[16:20:59] X-Jester: is there any break between the MIME type being sent and the download continuing, or does it all come together?
[18:15:50] apeiros: and the way you go from one base to another is always the same. a number is built as: ∑ digit * base ** position
[18:21:46] ruby[bot]: mgraf: Please join #RubyOnRails for Rails questions. You need to be identified with NickServ, see /msg NickServ HELP
[18:23:42] mgraf: I'll avoid a long-winded retort – about how Rails is written in ruby, and that this channel should be open to those questions too, and just say: thanks. :-)
[18:26:04] apeiros: mgraf: anyway, you had a question, and you got help. that help was getting directed at a better place.
[18:27:08] mgraf: I disagree, I got an answer, an answer is not _nesessarly_ help, but an answer none the less
[20:46:34] zenspider: I am too? How is that relevant? I'm just saying that being on rails 3.2 these days doesn't make sense
[20:46:52] mgraf: Oh, you're talking about [redacted] - I thought you were talking about my crappy internet
[20:48:12] mgraf: We had a candidate tell us in some really kind words that we needed to upgrade _badly_ (we are aware) - on top of everything, it looks poor to potential canidates...
[20:59:20] zenspider: it doesn't just look poor to candidates... the longer you go, the harder it'll be to upgrade.
[21:00:10] zenspider: mgraf: we're happy to answer unit testing questions here... but not rails questions. If you're gonna ask things like "how do I test my controller action when it does X", then that really isn't a testing question and is more of a rails question
[21:00:41] mgraf: of course... It's insult to injury when we have people turn us down because of it...
[21:00:47] zenspider: I was going to offer my consulting services for said upgrade... but you're also hinting you don't have test coverage... THAT also looks bad to candidates
[21:02:44] zenspider: less than nothing. if you think that means something, THAT means something, but the number is meaningless at this point.
[21:04:03] zenspider: it doesn't say anything about the quality of your tests nor does it say that it is accurate. test coverage tools are a lie. You could have one controller test that winds up hitting all your models and you'll think that they're actually tested. That's a lie.
[21:08:12] mgraf: I completely agree. Our recent (past 1.5 years) - have been very explicit. We're hitting every exception, both red and green path testing. We do have some code that is very old (when we were a scrapy start-up), that covers depricated controllers and models. Our clients are still using (some) of the old endpoints, but we're in the process of yanking them. It just takes time...
[21:16:50] desperek: mgraf, [1,2,3].each do |n| \- n.capitalize (something that's quite logic here) \- if not last -> ',' \ end
[21:21:02] mgraf: I don't want to contribute to the X-Y problem here... What are you trying to do exactly?
[21:21:27] ruby[bot]: +bb dmitriy_!*@*$#ruby-fix-your-connection *!*@18.104.22.168$#ruby-fix-your-connection
[21:23:04] desperek: note i don't want to join them, because i need some more things to do in the loop
[21:23:17] ruby[bot]: mgraf: 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
[21:24:08] mgraf: https://gist.githubusercontent.com/m-graf/700069d40c9c7792fb8bfe479cdfdd4e/raw/8206c7fa2c4256f0aed96f789f5f911571087739/.rb
[21:24:09] ruby[bot]: dminuoso: # => undefined method `init' for [1, 2, 3, 4]:Array (NoMethodError) ...check link for more (https://eval.in/972111)
[21:26:23] mgraf: https://gist.githubusercontent.com/m-graf/60a48816274aaa9bdf133155f739e0c3/raw/1a9f1994100a3343a37c97fc1e08c534922a9506/rb
[21:26:43] zenspider: desperek: why do you think it's ok to come in here and ask a question and then drop a trail of breadcrumbs of extra requirements?
[21:27:00] dminuoso: Yes, because ... is such an obvious visual clue that its an exclusive range over ..
[21:27:03] zenspider: either take our advice and run with it or just stop. Don't expect us to do your work for you one step at a time. we're not psychic.
[21:27:34] zenspider: desperek: no, what you asked initially was "how can i do something in .each only if it's not last element?"
[21:28:09] desperek: mgraf, i want to evaluate everything in an array/hash and then ommit one thing for last one
[21:29:05] zenspider: last_idx = arr.size - 1; arr.each_with_index do |o, i| if i == last_idx then ... else ... end; end
[21:30:08] zenspider: and it isn't what you want to do... you have values. They are evaluated already. You probably mean "process" or something
[21:31:10] mgraf: https://gist.githubusercontent.com/m-graf/caaa5baef0e6d169f4cd817b27c82353/raw/3950fa30754e0f4042e5c1a5bfbd31c64b7188e3/whatever
[21:31:16] ruby[bot]: How to ask the right questions to get you the right answer: https://www.mikeash.com/getting_answers.html
[21:35:38] desperek: zenspider, here's what i can do https://gist.githubusercontent.com/dracconi/349427b3663e7b680f4a0a3b1e54d77b/raw/62bd392c1f26e17116b2ebc580060c36d31813f5/make%2520it%2520work.rb ; i just ask if there's cleaner way to do it. to be precise regarding my question
[21:46:23] zenspider: "Yeeesssss" says the guy who's currently trying to fix my client's test coverage... :/
[23:53:58] RedNifre: My joke project is nearing completion, I just have to create the command line inferface for it. Is there something in the standard library for this or should I just handle ARGV myself?
[23:54:23] RedNifre: (I'm aware of good cli gems, but I want this to be one tiny self contained script)