## KrzaQ

Activity Graph

Page 1 of 4 | Next »

### 2019-08-22

[00:56:35] KrzaQ: *.net *.split
[01:13:38] KrzaQ: has joined #ruby

### 2019-06-05

[12:15:55] KrzaQ: I'm on Windows, and TCPSocket.new seems to take a bit over 1 second to create a socket, consistently
[12:16:01] KrzaQ: am I doing something wrong?
[12:19:51] KrzaQ: hm, it seems that when I change 'localhost' to '127.0.0.1' it drops dramatically, to ~15-20ms
[12:20:05] KrzaQ: possibly timer resolution
[12:30:36] KrzaQ: well, thanks for being good ducks :)
[12:30:42] KrzaQ: it works great now

### 2019-05-19

[02:04:05] KrzaQ: I'm using the sequel gem and I have a bit of a problem: I want to create a table from a schema of another table I'd dumped, but I don't see a way to do this programmatically. Is rewriting the create_table methods manually the only option?

### 2019-03-19

[06:59:24] KrzaQ: Ping timeout: 252 seconds
[07:03:23] KrzaQ: has joined #ruby

### 2018-12-21

[16:55:33] KrzaQ: is there somethign like .first_or(val) for arrays/enumerables? I want to streamline getting data from containers
[17:13:49] KrzaQ: good point
[17:15:21] KrzaQ: In my case I wanted to get a proper value, but anything that would allow me getting a point-free chain would be preferred over wrapping the chain in parens or naming variables
[17:17:51] KrzaQ: I would say it makes for very clear intent if you're doing just data manipulation and can fit it short code
[17:18:45] KrzaQ: I guess I can yield_self on the array to avoid polluting the scope
[17:22:35] KrzaQ: havenwood: remove /edit.
[17:23:33] KrzaQ: heh, I totally forgot about that
[17:23:47] KrzaQ: thanks, that's exactly what I wanted
[17:24:48] KrzaQ: I use it quite a lot, actually, but rarely with arrays
[17:25:26] KrzaQ: recent advent of code made me wish for array fetch that wouldn't interpret negative indices
[17:28:37] KrzaQ: I mean, it was trivial to monkey patch it into the class, but I would prefer not having to do that (and not doing it outside of a toy puzzle code)
[18:21:21] KrzaQ: in the case I wanted? nil, basically I wanted to build a grid out of arrays, and to cut the edge cases by having out-of-bounds access return nil

### 2018-12-17

[04:51:23] KrzaQ: let's say I have n = 4; what do I .send to n to assign to it? n.send(:=, 42) doesn't work
[04:51:39] KrzaQ: I'm trying to generate methods for yesterday's advent of code riddle
[04:52:02] KrzaQ: it seems all other operators work like that, but not this one
[04:55:03] KrzaQ: oh, so that's how it works
[04:55:19] KrzaQ: no wonder it doesn't have the power to do this
[04:55:27] KrzaQ: any idea how I can approach this, though?
[04:59:20] KrzaQ: hm, will look after day 17 is done, thx
[07:18:12] KrzaQ: welp, so I even made top 100 with Ruby
[07:23:47] KrzaQ: leftylink: actually, I think I don't need the binding to be replaced, basically I'm doing: https://gist.github.com/KrzaQ/a60b5e23ec84806ac768b1ca0fdb9a4d
[07:24:15] KrzaQ: I need something like a.ignore_arg(b) that returns b
[07:24:21] KrzaQ: I don't think there's something like that, though
[07:25:50] KrzaQ: I guess I can cheat a little and add noop to the Integer class
[07:33:40] KrzaQ: ok, I can live with that for an aoc problem
[07:34:31] KrzaQ: or I could make the function generator check if it's being passed a symbol or a proc/lambda/whatever callable
[07:49:13] KrzaQ: Eh, I'll leave it be
[07:49:29] KrzaQ: I won't be able to make much shorter, if any, and I don't want the readability to hurt too badly
[07:50:30] KrzaQ: That's how it looks now: https://github.com/KrzaQ/AdventOfCode2018/blob/master/solutions/day16/main.rb

### 2018-12-03

[05:49:07] KrzaQ: if I want a jit here and now, what are my options, if any? Googling ruby with jit now only gives me 2.6 results

### 2018-09-04

[06:26:10] KrzaQ: has joined #ruby
[06:26:40] KrzaQ: it's a bit disappointing that array returned by Time.to_a cannot be used to initialize a new time object
[06:27:07] KrzaQ: I just want to set the hour to something I want, is it not possible in plain Ruby?
[06:51:06] KrzaQ: yes, my point is I want to change one of those values
[06:51:33] KrzaQ: I went with arr = my_time.to_a; arr[2] = the_hour_i_want; Time.new *arr[0...6].reverse
[06:52:54] KrzaQ: nor my time is relative to Time.now
[06:53:13] KrzaQ: I just wanted t.hour = x
[06:53:51] KrzaQ: double fun is that t.to_a can't be used to initialize new Time object :(
[06:56:37] KrzaQ: hm, I'll always bundle activesupport in the future
[06:57:05] KrzaQ: my software is deployed on a corporate server behind a gazillion firewalls
[06:58:04] KrzaQ: well, my solution works, even if it's ugly and doesn't account for timezones
[06:58:13] KrzaQ: I just wanted to rant a bit ;)
[06:58:32] KrzaQ: I mean, this is something that could perhaps use improvement
[06:59:49] KrzaQ: Speaking of, I'm not certain this FAQ makes sense: https://ruby-doc.org/core-2.4.1/Time.html Time.at(1234).strftime "%M:%S" will break for any number over 3600

### 2018-08-08

[23:02:49] KrzaQ: *.net *.split

### 2018-07-10

[02:19:26] KrzaQ: Ping timeout: 260 seconds
[02:21:40] KrzaQ: has joined #ruby

### 2018-06-21

[14:51:56] KrzaQ: I'd like to add error reporting to an existing app. Is there a way to add a global uncaught exception handler, so that I wouldn't have to wrap everything in begin/rescues?
[14:52:28] KrzaQ: Basically, I'm looking for something like php's set_exception_handler()
[15:24:08] KrzaQ: at_exit seems to do most of the job, but it doesn't catch threading errors
[15:25:13] KrzaQ: I guess it's a fair requirement, thanks
[15:26:09] KrzaQ: but how would I know it was uncaught?
[15:44:21] KrzaQ: I'm creating a gem to send errors to backtrace.io (kinda like sentry)
[15:44:47] KrzaQ: ideally, I want it to be plug-and-play in your script without changing the app
[15:47:52] KrzaQ: well, if an exception was caught I cannot really know if it's an error or part of their workflow anyway
[15:48:05] KrzaQ: so in this case, modifying the application seems like the only choice to me
[15:48:18] KrzaQ: crashing errors are kind of a no-brainer :)
[15:48:36] KrzaQ: sure, it shouldn't
[15:49:05] KrzaQ: Also, you're right, even if it's an error, if they caught it, it might mean they don't want to hear about it
[18:22:49] KrzaQ: Kernel.exit causes $! to be not nil, can I differentiate it somehow? [18:23:20] KrzaQ: I only want to do at_exit stuff if there's an uncaught exception [18:24:57] KrzaQ: apeiros: sure. But now I wonder if the exclusion list is going to grow [18:26:18] KrzaQ: apeiros: if$! and $!.class <= StandardError [18:26:23] KrzaQ: does that make sense to you? [18:28:01] KrzaQ: Very well, I'll leave it as it is and classify futher later [18:29:28] KrzaQ: Maybe I'll make an exclusion list for now ### 2018-05-29 [02:47:05] KrzaQ: *.net *.split [02:48:12] KrzaQ: has joined #ruby ### 2018-05-05 [14:50:53] KrzaQ: I have a bunch od datetimes in Poland/Warsaw timezone. Is there a way to instruct DateTime.parse that this is the timezone? Dates look like '08/04/2018 22:45:00' [14:53:10] KrzaQ: This particular date has been parsed as 2018-04-08T22:45:00+00:00, though it should be +02:00 [15:00:35] KrzaQ: Hm, it seems I can do this using Time.parse and ENV["TZ"], though I'm getting +00:00 and +01:00, instead of +01:00 and +02:00 respectively [15:04:18] KrzaQ: ropeney: I'd have to create logic that determines whether I'm in DST or not [15:04:47] KrzaQ: so yeah, I can, but it's a little more effort than I thought [15:11:27] KrzaQ: Went with this: [15:11:32] KrzaQ: date = Time.parse d [15:11:34] KrzaQ: offset = date.gmt_offset == 0 ? 1 : 2 [15:11:36] KrzaQ: Time.parse "#{d}:+0#{offset}:00" [15:12:47] KrzaQ: ropeney: I don't see a parsing functionality there [15:16:57] KrzaQ: If you're speaking about tz.utc_to_local(Time.utc(2005,8,29,15,35,0)) then I have to get to those numbers from my date string. So I'd have to parse it myself [15:17:56] KrzaQ: hm, I guess [15:18:05] KrzaQ: let's see [15:23:42] KrzaQ: it worked out of the box here [15:24:26] KrzaQ: I should use local_to_utc though [15:25:15] KrzaQ: hm, but now the resultant time doesn't have the offset set [15:27:23] KrzaQ: What I'd like to get is essentially 2018-04-08T22:45:00+02:00 [15:27:36] KrzaQ: I'll browse tzinfo docs [15:27:43] KrzaQ: Surely there will be something ### 2018-04-25 [12:25:42] KrzaQ: *.net *.split [12:27:20] KrzaQ: has joined #ruby [15:01:12] KrzaQ: *.net *.split [15:03:17] KrzaQ: has joined #ruby [16:47:51] KrzaQ: does Ruby's formatting have something like printf's %*d, where * would make it accept size from the params? [16:48:29] KrzaQ: i.e. '%0*d' % [3, 4] would result in '004' [16:49:36] KrzaQ: I find it difficult to google for this, and I forgot I could check sprintf instead [16:49:45] KrzaQ: yeah, will do [16:50:13] KrzaQ: yeah, I know that [16:50:29] KrzaQ: But I didn't think to google the latter, and the former isn't very google-able [16:50:31] KrzaQ: thanks, though :) ### 2018-04-10 [14:30:21] KrzaQ: Ping timeout: 268 seconds ### 2018-03-07 [13:34:31] KrzaQ: I'd like to "explode" path into array of folder/file names. I.e. 'C:\foo\bar\baz.txt' -> [ 'C:\ [13:34:44] KrzaQ: I'd like to "explode" path into array of folder/file names. I.e. 'C:\foo\bar\baz.txt' -> [ 'C:\', 'foo', 'bar', 'baz.txt [13:34:55] KrzaQ: ffs. Sorry, my ' is next to my enter key [13:35:08] KrzaQ: I think you get the gist of it, though :/ [13:35:41] KrzaQ: ^ Is there anything like that in Ruby? I'd really rather avoid regexes for this [13:36:17] KrzaQ: hmm, because I didn't think it through, apeiros ;) [13:36:33] KrzaQ: awesome, thanks dminuoso :) [13:37:26] KrzaQ: I actually want the inner directory name, but I'll likely want to use the rest of the path in the future [13:38:00] KrzaQ: I'm getting the paths from Dir[foo] ### 2018-01-10 [03:48:28] KrzaQ: has joined #ruby ### 2017-12-17 [11:04:03] KrzaQ: tobiasvl: the c++ solution finishes in a second or two, so I didn't bother optimizing it better ### 2017-12-16 [22:11:00] KrzaQ: I have a question about my solution to yesterday's advent of code puzzle. With .lazy, it takes ~60 seconds on my computer to compute, without it's about 30% faster, but eats like 10 gigs of ram. Am I doing something horrendously wrong? [22:11:02] KrzaQ: https://github.com/KrzaQ/AdventOfCode2017/blob/master/day15/main.rb ### 2017-12-14 [16:11:36] KrzaQ: hm, is this bot open sourced? I'd like to host an instance [16:15:02] KrzaQ: I'm mainly interested in making the eval part safe [16:15:52] KrzaQ: I mean, I have an eval(input) in my rbot, but obviously I can't allow anyone to access that [16:16:18] KrzaQ: I guess that's a solution too [16:16:26] KrzaQ: welp, thanks :) ### 2017-12-10 [07:01:07] KrzaQ: Does ruby have something like https://dlang.org/phobos/std_range.html#only ? I'd like to do a.only resulting in [a] [07:18:20] KrzaQ: doesn't break pretty function chains [07:22:40] KrzaQ: Array multiplication was my use case. ([a,b,c].chain.chain.chain * 10).chain.chain.chain vs [a,b,c].chain.chain.chainonly.map{*64}.first.chain.chain.chain [07:23:22] KrzaQ: missed a dot there, but I think it's readable anyway [07:34:44] KrzaQ: I literally said it [07:34:45] KrzaQ: I'd like to do a.only resulting in [a] [07:35:16] KrzaQ: possibly not an array/range [07:35:23] KrzaQ: /enumerable [07:35:57] KrzaQ: in D 10.only is pretty much equal to [10]. [07:36:33] KrzaQ: I didn't see anything similar in Ruby's docs, but I asked to be sure [07:37:51] KrzaQ: yeah, that's what I went with [07:38:42] KrzaQ: I just wondered whether I'm duplicating existing functionality [07:39:24] KrzaQ: RickHull: the way you said it implies that there are kinds of objects that already have .wrap_in_enumerable functionality. Have I misunderstood it? [07:40:01] KrzaQ: Now my aoc solution is a straight line of chains :) [07:40:31] KrzaQ: but that breaks pretty chains [07:42:37] KrzaQ: I'm a fan of how D handles this [08:19:35] KrzaQ: https://mlomnicki.com/yield-self-in-ruby-25/ that's kind of what I wanted, lol [17:35:10] KrzaQ: yeah, I linked an article about it later [17:35:37] KrzaQ: yield_self is exactly what I want, because right now I have .to_array.map{...}.first ### 2017-12-08 [09:39:29] KrzaQ: What is the gem I should use for grammar parsing? I used to play with Citrus, but it seems to be abandoned, and returns a string instead of a match tree when I call its parse method [11:00:31] KrzaQ: sounds like aoc to me :> [11:00:38] KrzaQ: why not use hash.fetch with a default? [11:05:13] KrzaQ: method_missing, maybe? [11:05:18] KrzaQ: that's what I used [11:13:52] KrzaQ: not without losing elements [11:14:21] KrzaQ: arr[a...b] [11:14:27] KrzaQ: a and b being indexes [11:14:47] KrzaQ: >> [1,2,3][1..2] ### 2017-11-16 [12:52:20] KrzaQ: I want to upload a fairly large file over https. Normally, I'd use the httpclient gem, but I want to show upload progress as it goes - does anyone know if it's feasible with it, or if there's an alternative? [14:14:12] KrzaQ: it's an api, I just want to show the progress in the client app [14:15:16] KrzaQ: I have a ruby script that does post('https://...', myfile.zip) [14:15:27] KrzaQ: I want to show progress of this upload [14:16:40] KrzaQ: I didn't see anything in the docs, though the examples were mostly html-download-takeaction oriented [14:18:22] KrzaQ: HTTP response only. HTTP requests are not supported. [14:18:31] KrzaQ: even so, I don't want to track the download, but upload ### 2017-11-14 [17:17:17] KrzaQ: I'd like to dump the whole command used to run my script (it's ruby path/file.rb args args args). ARGV only contains args, what should I use? [17:20:59] KrzaQ: ok, great [17:21:55] KrzaQ: ['ruby',$0, ARGV].flatten.join(' ') <-- does that sound legit?
[17:23:24] KrzaQ: Great, thanks for the help!
[17:27:33] KrzaQ: I'm willing to take that bet for my case, but if you have a better solution, please share :)

### 2017-09-02

[00:38:36] KrzaQ: Ping timeout: 246 seconds
[00:39:49] KrzaQ: has joined #ruby

### 2017-08-08

[02:18:22] KrzaQ: Ping timeout: 255 seconds
[02:25:08] KrzaQ: has joined #ruby

### 2017-08-07

[17:58:26] KrzaQ: Are there any popular jiting interpreters for ruby? I tried googling, but found some niche projects, mostly looking old. I'd love to have something like pypy

### 2017-07-26

[02:19:33] KrzaQ: Excess Flood
[02:21:12] KrzaQ: has joined #ruby

### 2017-06-27

[09:35:05] KrzaQ: *.net *.split

### 2017-06-22

[18:08:32] KrzaQ: Is there a way to take all but one element from an enumerable? something like [0...-1]. I can use it, but it forces me to place it in the same line as another call in a call chain and I like the visual feel of new call in chain being in a separate line
[18:10:10] KrzaQ: well, .reverse.drop(1).reverse would work, but it's not pretty either
[18:26:33] KrzaQ: I'm using it on map result
[18:26:37] KrzaQ: and it works
[18:26:52] KrzaQ: huh, really?
[18:28:00] KrzaQ: well, I don't care about performance, I'm manipulating like few dozen bytes
[18:28:15] KrzaQ: but yeah, it does seem that map returns an array, which is new to me

### 2017-06-20

[00:14:45] KrzaQ: Excess Flood
[00:14:52] KrzaQ: has joined #ruby
[00:16:59] KrzaQ: *.net *.split
[00:22:46] KrzaQ: has joined #ruby

### 2017-06-14

[04:31:09] KrzaQ: Can I have the %03d functionality while using %{name} to format my strings? Something like '%{03d:foo}' % { foo: 1 }
[04:34:29] KrzaQ: the problem with % is that it's really difficult to google if you don't know the name for it :)
[04:36:04] KrzaQ: It works, thanks again :)
[04:38:16] KrzaQ: and what if my question was about #{}?
[04:38:29] KrzaQ: (it wasn't, but I'm curious)
[04:40:44] KrzaQ: okay, so it basically puts eval(code).to_s in place of #{code}?
[04:40:59] KrzaQ: ^ might be pseudocode
[04:42:36] KrzaQ: I meant it conceptually
[04:43:21] KrzaQ: It does execute the code, at least for me
[04:47:22] KrzaQ: I did try something to that effect and puts was executed

### 2017-06-13

[10:58:50] KrzaQ: I want to install ruby on a Windows machine that cannot connect to the internet, but the new rubyinstaller requires 'ridk install' that attempts to download msys2. How can I install this offline?
[11:07:53] KrzaQ: it's a machine connected to production plotter that doesn't seem to have non-windows drivers and I am hoping to use ruby to generate documents to be plotted
[11:08:17] KrzaQ: the machine isn't connected to the internet due to company policy, I can only RDP to it
[11:09:11] KrzaQ: that's it?
[11:09:16] KrzaQ: well, I can do that
[11:09:59] KrzaQ: if it works, it works
[11:10:11] KrzaQ: it's unlikely to be touched for years once set up

### 2017-06-02

[18:36:00] KrzaQ: Are questions about windows rubyinstaller in scope of this channel?
[18:41:52] KrzaQ: I have an offline (I can only remote desktop to the server, there's no internet access) installation of ruby 2.4 by rubyinstaller2. How can I install gems?
[18:43:09] KrzaQ: I googled it, but I'm not sure if [1] is still a correct way to do this.
[18:43:11] KrzaQ: [1]: http://help.rubygems.org/kb/rubygems/installing-gems-with-no-network
[18:44:15] KrzaQ: Ok, thank you :)

### 2017-05-05

[07:40:12] KrzaQ: What is the 'Data' constant? I can't use it in my scripts because they yell at me for redefining a constant, but it contains now data
[07:43:29] KrzaQ: too bad such a common name is restricted like that

### 2017-04-21

[08:41:50] KrzaQ: has joined #ruby

### 2017-04-10

[11:52:12] KrzaQ: has left #ruby: ()

### 2017-03-20

[20:29:13] KrzaQ: *.net *.split

### 2017-03-15

[15:41:25] KrzaQ: Ping timeout: 256 seconds
[15:45:47] KrzaQ: has joined #ruby

### 2017-03-12

[08:08:06] KrzaQ: Ping timeout: 240 seconds
[08:13:18] KrzaQ: has joined #ruby