depesz

Activity Graph

Page 1 of 2 | Next »

2019-08-06

[05:44:47] depesz: Quit: WeeChat 2.4

2019-06-04

[11:02:57] depesz: hi. i have hash like this: z = {"jump1" => [ 1, 2, 3], "jump2" => [4,5,6] }
[11:03:38] depesz: is there any simple way to convert it to {1 => jump1, 2 => jump1, 3 => jump1, 4 => jump2, 5 => jump2, 6 => jump2 }?
[11:04:00] depesz: one that would work without temprary variables preferably (like .map or something similar) ?
[11:05:11] depesz: phaul: yeah, but then as a key i get [1,2,3], and not 3 separate keys
[11:05:28] depesz: currently i have: map { |k,v| v.map { |n| [n, k] } }.reduce(&:+).to_h
[11:05:43] depesz: oh, that looks promising, canton7
[11:05:56] depesz: thanks a lot
[11:07:01] depesz: oh, didn't know I can pass argumnets to flatten. silly me.

2019-05-28

[20:32:15] depesz: what is the proper way to configure gem, so that it will install to $HOME, by default, and will load from there first ?
[20:37:28] depesz: thanks a lot. works :)
[22:04:37] depesz: balo:i do.

2019-05-21

[13:31:48] depesz: hi. i have a class, which contains method "print". how can I call normal, kernel, print, from within this print?
[13:31:54] depesz: i'd rather not change name of my method
[13:33:53] depesz: ah, thanks. obvious now :)
[14:06:34] depesz: *.net *.split
[14:13:29] depesz: has joined #ruby

2019-05-08

[07:32:11] depesz: kke: .sub(%r{^/?}, "/") ?
[08:01:40] depesz: kke: https://share.riseup.net/#COF2juUD8oINlBUEpwu6Ew ?
[08:03:09] depesz: al2o3-cr:sorry. brain fart.
[08:04:20] depesz: https://share.riseup.net/#Elw8_zRAWBFkuo5CLYcrwA

2019-05-06

[15:11:15] depesz: hi. is there any simple way to split array into array of arrays with up to N elements?
[15:11:26] depesz: i can write a loop, but perhaps there is some idiomatic way to do it
[15:13:11] depesz: adam12: yes, it is. thanks a lot.

2019-04-23

[17:18:27] depesz: i have plain hash. is there any special method to iterate over both keys and values? for now I'm doing: hash.each.to_a.flatten.each
[17:18:34] depesz: but perhaps there is some easier thing?
[17:19:47] depesz: balo: because i need to do the same thing with k and v
[17:19:57] depesz: and i'd prefer not to repeat the code, or have internal loop.
[17:20:07] depesz: it's sanity checking code for hash that will be used later on.
[17:22:02] depesz: well, in my case the check is 2 lines only, so I don't put it in separate function.
[17:22:27] depesz: so for now it is "pretty long line 1" "pretty long line 2", and both of them repeat with the value, and not key.
[17:22:43] depesz: i'll go with hash.to_a.flatten. seems easier.

2019-04-17

[15:08:24] depesz: hi. is there any currently supported formatter for ruby code? i found https://rubygems.org/gems/tidy but it looks to be abandoned
[15:15:40] depesz: any that is recommended?
[15:17:26] depesz: ok. thanks. will check, compare, and see :)

2019-04-16

[12:04:09] depesz: has joined #ruby
[12:04:49] depesz: hi. where can I find explanation of what is &. syntax ? i have something like: x&.downcase&.start_with?('aa')
[12:04:59] depesz: how is that different from x.downcase.start_with?('aa')
[12:06:24] depesz: ah, got it. thanks.
[12:07:21] depesz: phaul:thanks, duckduckgoed it, and got https://en.wikipedia.org/wiki/Safe_navigation_operator#Ruby :)

2018-07-10

[13:30:41] depesz: has left #ruby: ("WeeChat 2.1")

2018-07-02

[18:00:51] depesz: has joined #ruby
[18:01:14] depesz: how can I quickly/sensibly get owner of current stdin? basically what "who -m" does to show user logged on terminal.
[18:01:33] depesz: I'm doing now File.stat('/proc/self/fd/0').uid, but it doesn't look nice.

2018-04-30

[12:41:43] depesz: Quit: WeeChat 2.1

2018-04-25

[12:25:40] depesz: *.net *.split
[12:27:20] depesz: has joined #ruby
[15:01:10] depesz: *.net *.split
[15:03:17] depesz: has joined #ruby

2018-04-10

[11:42:30] depesz: has joined #ruby
[12:02:47] depesz: hi. i have a class, that internally defines module. I'd like to make new class that has *some* of the methods from the module replaced by new code.
[12:02:50] depesz: how can I go about it?
[12:04:41] depesz: it's not mine.
[12:04:53] depesz: basically - i have this gem: https://github.com/lfittl/pg_query
[12:05:39] depesz: internally it has class PgQuery, and in there there is Deparse module. I'd like to make na new class (PgQuery2), which inherits PgQuery, but overwrites some of the methods in Deparse module in it.
[12:06:18] depesz: apeiros: base class/module is not mine. the new one is mine, but Deparse methods seem to be called from parent class (PgQuery), and not my overwrite ...
[12:07:07] depesz: why? copying the whole code doesn't make much sense.
[12:07:45] depesz: i need to deparse sql query, but in nicer way. adding indentation, and other "things"
[12:08:06] depesz: deparse code is there, i just need to modify *some* methods of the class.
[12:08:17] depesz: apeiros: well, then I would have to copy the whole deparse module, which is pretty long.
[12:08:36] depesz: apeiros: well, doesn't seem to be the case.
[12:08:47] depesz: moment, let me show some simple example
[12:10:18] depesz: apeiros: https://gist.github.com/depesz/1c5c7cd07b76503acff265fe73c4de75
[12:10:45] depesz: apeiros: deparse method (called in line 24) will call internally deparse_select().
[12:11:00] depesz: i did overwrite it (and failed), but it didn't change the way it works.
[12:11:04] depesz: sorry about that
[12:11:27] depesz: is there any way to achieve what I need/want?
[12:11:57] depesz: as in: overwrite *some* of methods that are in a module inside class that I'm inheriting from?
[12:13:29] depesz: apeiros: https://github.com/lfittl/pg_query/blob/master/lib/pg_query/deparse.rb
[12:13:44] depesz: deparse method in PgQuery calls Deparse.from() for each item in tree
[12:14:03] depesz: i nested it because that's what i saw in pg_query gem source.
[12:15:31] depesz: apeiros: given the source as it is in here - do you see a way i could have a pgquery2 class that will overwrite just deparse_select ?
[12:15:38] depesz: but keep all other things from normal pgquery ?
[12:15:58] depesz: apeiros: would appreciate. just ping me if/when you'll have time.

2018-01-15

[15:00:46] depesz: has left #ruby: ("WeeChat 1.9")

2018-01-12

[16:05:58] depesz: has joined #ruby
[16:07:18] depesz: Hi. I'm opening pipe to write to program, using: f = IO.popen(%w{some program}, 'w'); then i write data to it. but when I try to f.close my program waits for the other program (the one I sent data to) to end. How can I make it "send end of data" to child, but not wait for it to finish?

2017-09-20

[11:35:52] depesz: has left #ruby: ("WeeChat 1.9")

2017-09-19

[12:32:22] depesz: has joined #ruby
[12:33:12] depesz: hi. what is the sanest library/gem for writing web spider? i'd like something that behaves like simple web browser, handles cookies, and then something that will allow me to easily extract data from fetched html
[12:36:58] depesz: no, no. i just need it to get some webpages, and keep track of cookies/redirects on subsequent calls.
[12:37:34] depesz: in perl i was using WWW::Mechanize and am looking for something similar for Ruby ( I know it doesn't help most of the people, but perhaps you know something about perl)
[12:37:38] depesz: looking at httparty
[12:37:52] depesz: should just handle it transparently for me.
[12:38:50] depesz: nah, i don't need login. at least for now
[12:38:55] depesz: thanks, will check it.
[12:39:30] depesz: ok. one more question. please note that I'm very very new when it comes to ruby
[12:40:02] depesz: i saw something that a person had in a directory with his ruby program, that when he/she ran some command, it automatically installed all required gems. any pointers on what it could be / how to use it?
[12:51:02] depesz: soahccc: thanks.

2017-09-15

[07:52:16] depesz: has left #ruby: ("WeeChat 1.9")

2017-09-14

[10:13:28] depesz: has joined #ruby
[10:13:44] depesz: hi. we have in ruby programs line like: "gem 'aws-sdk', '~> 2'"
[10:14:02] depesz: where can I find information on what is the syntax for version thing?
[10:20:34] depesz: thanks a lot.
[12:30:31] depesz: dminuoso: i am, and was, but needed informationa bout "gem" thing.
[12:31:22] depesz: i've seen ruby script, working in ruby 2.1, that has line "gem ....", despite not requiribng anything earlier, and I didn't know where to find information about it, some docs? what module? I couldn't find it in core
[12:44:56] depesz: i now know - t_buehlmann helped me already (modified his nick to avoid unnessary notification for him)
[12:45:37] depesz: the thing is - how come it's available, if http://ruby-doc.org/core-2.1.6/ doesn't list anything with *gem* ?
[12:46:56] depesz: well, when I need to, yes.
[12:47:09] depesz: as in: i don't use irb, instead i use pry, but not at the moment
[12:47:45] depesz: ah, thanks. helpful.
[12:50:32] depesz: ok. for now my problem is solved. I just wish it was somehow easier to find, instead of asking in here.

2017-05-02

[08:42:11] depesz: has joined #ruby
[08:42:13] depesz: has left #ruby: ()

2017-04-24

[09:16:42] depesz: has joined #ruby
[09:17:09] depesz: has left #ruby: ()

2016-07-14

[14:03:17] depesz: has left #ruby: ("WeeChat 1.5-dev")

2016-07-13

[14:24:49] depesz: hi. i'm reading data from file that is encoed in utf-8, but ruby treats the data as set of bytes, and for string "żółw" returns length of 7
[14:25:02] depesz: what/how can I change so that data loaded will be "understood" as utf8 encoed?
[14:25:28] depesz: apeiros: 2.3
[14:25:40] depesz: I just opened the file, and am reading from it.
[14:27:00] depesz: reading. trying to understand.
[14:28:51] depesz: apeiros: did File.open(path, 'r:UTF-8') but it doesn't seem to help :(
[14:31:07] depesz: moment, I have a problem now, that I can't replicate the problem in smaller program :(
[14:32:17] depesz: undefined method `encoding' for #<File:/home/depesz/x.log
[14:32:27] depesz: toretore: that's for calling file.encoding
[14:34:04] depesz: toretore / apeiros : external utf-8, internal: empty
[14:34:28] depesz: i wonder, could it be because I use read_nonblock ?
[14:34:35] depesz: ^^ apeiros
[14:34:41] depesz: I use read_nonblock on the files
[14:35:19] depesz: ok. this makes sense. is there any way I can convert text, when I'm reasonably-sure(ish) that the data is complete, to utf8 ?
[14:35:56] depesz: apeiros: i'm doing basically fail -f on multiple files, and reading data as it appears.
[14:36:49] depesz: toretore: /ASCII-8BIT/
[14:37:08] depesz: apeiros: ok. how do I do it? I am sure that the data is correct utf8 - how do I convince ruby about it ?
[14:37:37] depesz: apeiros: i am. i write the data.
[14:37:44] depesz: apeiros: yes, and I split the chunks
[14:37:53] depesz: and return only the chunks to further processing - basically each line
[14:38:16] depesz: each read_nonblock adds data to buffer, then I split the buffer by line, and work only on full lines.
[14:38:43] depesz: apeiros: i guess in my case, I can be sure that the encoding is correct, because I never work on incomplete character from input.
[14:39:01] depesz: so, apeiros, yes - I can be sure :)
[14:39:46] depesz: EYS> force_encoding worked like a charm. great.
[14:40:03] depesz: now I just need to figure out why the script ignores last "line" from input
[14:41:09] depesz: toretore: nah, it's "line", not *line*.
[14:41:28] depesz: each "line" to be shown is actually 3 lines from input file.
[14:41:38] depesz: i see the script reads them, but doesn't print last "line"
[14:42:03] depesz: these 3 lines from input, get aprsed into some hash, and then printing shows information as single line of output.
[14:42:32] depesz: no, it is 3 lines input, saw, tested, see it even being added to "queue", but it just doesn
[14:42:36] depesz: no, it is 3 lines input, saw, tested, see it even being added to "queue", but it just doesn't print it.
[14:42:47] depesz: well, it's my fault, some logic is broken in the script - i'll fix it :)
[14:45:46] depesz: i'm so stupid. all works as expected, and correctly.
[14:45:53] depesz: thanks again for the help.

2016-07-12

[16:16:19] depesz: has joined #ruby
[16:16:35] depesz: hi. if/when I do require 'xxx' - how can I see full path to file that got loaded?
[16:19:04] depesz: toretore: cool. thanks.
[16:23:46] depesz: yeah, noticed.

2016-07-03

[08:29:01] depesz: has joined #ruby
[12:25:20] depesz: has left #ruby: ("WeeChat 1.5-dev")

2016-06-01

[09:07:22] depesz: has left #ruby: ("WeeChat 1.5-dev")

2016-05-31

[11:05:47] depesz: has joined #ruby

2016-05-30

[14:54:01] depesz: has joined #ruby
[14:55:22] depesz: hi. I mightbe lacking some vocabulary to explain what I need, but let me show you simple example. Given this input: [["a", "b", "c", "d"], ["9", "8", "7"]], I would like to generate all 12 results: [a, 9], [a,8], [a,7], [b,9], ...
[14:55:58] depesz: but I need a way that will not require me to set specific number of loops inside - it should work with any number of elements in source arrays, on both levels
[14:56:22] depesz: madgen: ok, how to get it? any ready function/method/class/gem?
[14:57:11] depesz: thank you, reading.
[14:58:14] depesz: ah, so i just "stack" products
[14:59:33] depesz: %w{a b c d}.product(%w{9 8 7}).product(%w{x y z}).product(%w{5 6 7 }).map(&:flatten)
[14:59:43] depesz: does this look sensible, or am i missing some easier thing?
[15:00:54] depesz: ok. i think I got it, thank you :)
[15:01:15] depesz: jhass: why? i mentioned, that number of elements/arrays is not fixed.
[15:01:22] depesz: madgen: yeah. looks nicer.
[15:02:49] depesz: jhass: "in source arrays, on both levels"
[15:38:50] depesz: Ping timeout: 244 seconds

2016-05-20

[09:38:18] depesz: has left #ruby: ("WeeChat 1.5-dev")

2016-05-18

[17:41:32] depesz: has joined #ruby
[17:42:01] depesz: is there any way to figure out how much memory is hash using? assuming it's plain hash with string as keys and integer as values.
[17:43:25] depesz: ouch. anything that I could just feed hash to, and it would do the magic?
[17:44:07] depesz: ok. thanks.
[18:05:30] depesz: ok. one more question - is there any way to make stdout automatically flush on each write ?
[18:06:57] depesz: havenwood: thanks.
[22:21:16] depesz: Ping timeout: 252 seconds
[22:24:36] depesz: has joined #ruby

2016-02-05

[10:29:01] depesz: has left #ruby: ("WeeChat 1.4-rc1")

2016-02-03

[18:54:35] depesz: has joined #ruby
[18:55:09] depesz: hi. I'm using Kernel.select() with 2 IO objects. when I get them back, how to I check which one I'm reading from at the moment?
[18:58:15] depesz: drbrain: i know.
[18:58:22] depesz: and I will. but I have to know which is which.
[18:58:42] depesz: because output should go to different places depending on which fh it is.
[18:59:02] depesz: basically, i'm running open3, and getting output from stdout and stderr.
[18:59:50] depesz: ok. fileno seems like better solution. thanks.
[19:00:49] depesz: not sure how threads can help me with distinguishing stdout/stderr from single command.
[19:01:18] depesz: drbrain: apparently i have to run my own reading code, because open3 doesn't work well with timeout.
[19:01:56] depesz: basically i'm trying to convert this code: https://gist.github.com/lpar/1032297 so that it will return stdout and stderr separately
[19:04:24] depesz: i don't see it having redirect to variable.
[19:06:43] depesz: i'm not sure about it. will try to convert first the code from github. if it will fail, will look into spawn, but I'm not sure if I want to deal with pipes.
[19:07:37] depesz: not to mention that I don't understand the example.
[19:07:53] depesz: it seems to read from log_r, but I don't see anywhere that it's being used for anything.
[19:08:33] depesz: undefined method `fileno' for [#<IO:(closed)>]:Array
[19:09:45] depesz: i think that the select() returns something else than I expected. I thought it will be array of IO objects, but it doesn't look that way
[19:10:13] depesz: stupid me.
[19:11:34] depesz: thanks a lot - got to jet. will bookmark spawn() docs, and maybe will get back to it tomorrow.

2016-01-18

[15:45:01] depesz: has joined #ruby
[15:45:56] depesz: hi. i'm hitting strange thing. It looks that when I have "class Discover::AWS", and in that class, I do: ec2 = Aws::EC2::Client.new() - ruby tried to load Discover::AWS::Aws (and probably Discover::AWS::Aws::EC2::Client
[15:46:01] depesz: any idea on why this might be?
[15:49:36] depesz: example: http://fpaste.org/312003/31321711/
[15:51:51] depesz: workmad3: ok, how can I make it use "global" Aws::EC2::Client?
[15:52:01] depesz: or any other class for that matter?
[15:52:28] depesz: well, it is - i have "require 'aws-sdk'" at the beginning
[15:53:07] depesz: workmad3: will check, thank you.
[15:53:34] depesz: hmm .. it seems on work on one server, and doesn't on another.
[15:53:38] depesz: AWS seems to work everywhere.
[15:54:32] depesz: according to docs, it should be Aws: https://github.com/aws/aws-sdk-ruby
[15:55:27] depesz: workmad3: check this: http://fpaste.org/312003/31321711/
[15:55:35] depesz: from all I understand, it should work, shouldn't it?
[15:55:53] depesz: workmad3: reading
[15:56:15] depesz: workmad3: but I'm getting error on uniitialized constant Aws, not AWS
[15:57:14] depesz: =$ gem list aws-sdk | grep 'aws-sdk '
[15:57:16] depesz: aws-sdk (2.2.11, 1.64.0)
[15:57:23] depesz: ok. i see that I have both. maybe that's the problem.
[15:57:39] depesz: how can I make the script use v2 ?
[16:00:35] depesz: havenwood: in the .rb script?
[16:01:40] depesz: havenwood: OK. added before 'require' and it works.
[18:55:27] depesz: has left #ruby: ("WeeChat 1.4-rc1")

2015-12-28

[16:15:34] depesz: has joined #ruby
[16:16:26] depesz: hi. i have array of hashes, and each hash, under specific key ("instances") has array of elements. sometimes one element, sometimes more. is there any simple way to get "all_instances" array that will contains all instances from all hashes in the original array ?
[16:19:38] depesz: havenwood: it's possible. checking
[16:21:17] depesz: havenwood: looks perfect, thanks
[17:07:39] depesz: has left #ruby: ("WeeChat 1.4-dev")

2015-12-21

[06:42:12] depesz: has left #ruby: ("WeeChat 1.4-dev")

2015-12-18

[14:33:23] depesz: has joined #ruby
[14:33:49] depesz: hi. is there any "pretty printer" for ruby? something that would reformat given source code accoring to some set of rules?
[14:35:20] depesz: c355e3b: testing, thanks.
[14:54:16] depesz: has left #ruby: ("WeeChat 1.4-dev")
[15:02:56] depesz: has joined #ruby
[15:02:57] depesz: has left #ruby: ("WeeChat 1.4-dev")
[15:03:51] depesz: has joined #ruby
[15:04:49] depesz: hi. assuming I have string varialbe x, with value of "Something::SomethingElse" - how can I use it to create object of Something::SomethingElse class ?
[15:05:57] depesz: ljarvis: ?
[15:06:18] depesz: searching
[15:06:57] depesz: oh, nice. thanks, ljarvis

2015-06-29

[14:41:09] depesz: has joined #ruby
[14:41:16] depesz: hi. how can I resolve hostname to ip?
[14:41:41] depesz: I seem to be getting some data from Socket.gethostbyname, but the fourth field doesn't look like ip
[14:41:56] depesz: jhass: thanks, checking
[15:10:11] depesz: has left #ruby: ("WeeChat 1.2-dev")

2015-06-11

[13:26:54] depesz: has joined #ruby
[13:27:31] depesz: how can I get full hostname, with domain, of current host? something like "hostname -f", but without requiring executing external programs
[13:29:28] depesz: gethostname returns just first part of fqdn :(. docs mention NI_* options, but I don't see any list of these options
[13:48:51] depesz: found this, looks like working, Socket.gethostbyname(Socket.gethostname).first
[14:03:30] depesz: has left #ruby: ("WeeChat 1.2-dev")

2015-06-10

[13:42:12] depesz: yeah. i missed "require etc". now i'm all good.
[14:22:18] depesz: has left #ruby: ("WeeChat 1.2-dev")