Seenox

Activity Graph

Page 1 of 1

2017-10-10

[10:54:27] Seenox: has joined #ruby

2017-10-09

[11:11:46] Seenox: Quit: Connection closed for inactivity

2017-10-05

[06:44:55] Seenox: has joined #ruby

2017-09-30

[08:46:12] Seenox: Quit: Connection closed for inactivity

2017-09-18

[10:21:08] Seenox: has joined #ruby

2017-09-15

[22:17:32] Seenox: Quit: Connection closed for inactivity

2017-09-08

[10:28:05] Seenox: Quit: Connection closed for inactivity
[21:17:47] Seenox: has joined #ruby

2017-08-15

[11:56:02] Seenox: has joined #ruby
[19:03:13] Seenox: *.net *.split
[19:03:36] Seenox: has joined #ruby

2017-08-11

[17:14:54] Seenox: Quit: Connection closed for inactivity

2017-08-07

[06:55:11] Seenox: has joined #ruby

2017-08-05

[14:05:08] Seenox: Quit: Connection closed for inactivity

2017-07-19

[07:08:04] Seenox: has joined #ruby

2017-07-14

[16:50:17] Seenox: Quit: Connection closed for inactivity

2017-06-20

[00:17:18] Seenox: *.net *.split
[00:23:13] Seenox: has joined #ruby

2017-06-16

[11:35:33] Seenox: Hi everyone. How can I use this sed in ruby? --> sed -n 's/.*\\s\\([0-9.]\\+\\)/\\1/p'
[11:40:27] Seenox: daed: Text would be something like this: http://rubular.com/r/Mh7Xfdd6g6 (Need 2.4.1 from it)
[11:49:11] Seenox: daed: trying...
[11:59:30] Seenox: daed: http://rubular.com/r/pKfBQO2Id0 now I just need to escape the second match.

2017-05-31

[06:49:29] Seenox: Hello everyone. I am trying to use CURL in Ruby like this: https://gist.github.com/Seenoxx/8f5505238abd885862ec86b79e581eee -- My code is missing the --cacert --cert --key part in the ruby part though. Any help is appreciated. :)
[07:07:24] Seenox: zenspider: Thanks, I will need to change it to PUT and DELETE, etc. soon. I'm just testing it.
[07:07:46] Seenox: zenspider: Hmm, seems like I need to add some attr in req_options section.
[07:09:43] Seenox: Yeah... I've changed my code a little bit and got this: `initialize': wrong argument (String)! (Expected kind of OpenSSL::X509::Certificate) (TypeError)
[07:12:18] Seenox: matthewd: SSL/HTTPS request with PEM certificate, it is!
[07:31:22] Seenox: matthewd zenspider: Thanks to both of you. Problem solved.
[07:31:32] Seenox: matthewd zenspider: Final working version: https://gist.github.com/Seenoxx/cf0cd190e31533bba7cb75405ff22ab4
[07:35:48] Seenox: elomatreb: Local and behind 2 proxies?
[07:42:11] Seenox: elomatreb: Yes, the API will reject invalid hostnames and IPs anyway. But thanks for the suggestion.
[07:50:25] Seenox: zenspider: Earlier you mentioned that you would use open-uri instead for GET requests. Any reason in particular? (Just being curious)
[07:57:22] Seenox: elomatreb: I see. Thanks.

2017-05-29

[12:34:53] Seenox: Quit: Page closed
[12:36:41] Seenox: has joined #ruby

2017-05-19

[10:55:20] Seenox: Ping timeout: 260 seconds
[11:42:15] Seenox: has joined #ruby

2017-05-16

[04:59:19] Seenox: Ping timeout: 260 seconds
[06:33:22] Seenox: has joined #ruby
[06:49:33] Seenox: Hello. I am trying to use json.parse and json.dump but I think I am stuck... Can someone please check this for me and tell me what I am doing wrong? Thanks => https://gist.github.com/anonymous/61cd20b063d57dd5c04a70ae3b5affc7
[06:56:56] Seenox: Burgestrand: It worked! Thanks for the explanation.
[06:57:32] Seenox: Now I know why it used to convert my hash to string...
[06:58:28] Seenox: Burgestrand: Thank you. One more quick question regarding this: Is it also the same for other functions? For example: puts #{body} vs. puts body?
[07:01:08] Seenox: Burgestrand: No matter if it's a hash or array or object or anything else?
[07:02:07] Seenox: Burgestrand: https://eval.in/795957 ?
[07:03:40] Seenox: Burgestrand: Thanks a lot as always you're so helpful with great explanations.

2017-05-15

[06:43:21] Seenox: has joined #ruby

2017-05-12

[04:26:50] Seenox: Ping timeout: 260 seconds

2017-05-11

[06:38:13] Seenox: has joined #ruby

2017-05-10

[07:31:50] Seenox: Ping timeout: 260 seconds
[07:43:01] Seenox: has joined #ruby
[12:11:14] Seenox: Ping timeout: 260 seconds
[12:48:25] Seenox: has joined #ruby
[15:08:34] Seenox: Ping timeout: 260 seconds

2017-05-08

[08:02:17] Seenox: Hello everyone. Sorry if this is a very simple question, but how can I add " in a puts? for example puts ""Hello""?
[08:06:00] Seenox: Burgestrand: Hello again my beloved teacher!
[08:06:27] Seenox: Burgestrand: I have something like this, but I need to add " at the beginning of my output and ", at the end of it.
[08:06:31] Seenox: https://gist.github.com/anonymous/3db66e1232a2c552d590be42d1c64b93
[08:08:26] Seenox: Burgestrand: My script outputs something like this for the "hosts" : [{"Name"=>"git"}, {"Name"=>"ntp"}, {"Name"=>"synfacts"}]
[08:09:00] Seenox: Burgestrand: Then I need to read all the "Name" values, add " before everyone of them and add ", at the end of it and then use it for another purpose.
[08:09:46] Seenox: without space after ,
[08:10:02] Seenox: Also add another, at the end of it.
[08:11:06] Seenox: Burgestrand: You mean from the source arrays? It won't be any in them, they are puppet classes names.
[08:11:33] Seenox: Burgestrand: One second please.
[08:12:17] Seenox: Burgestrand: https://gist.github.com/anonymous/42827516a862be875ce2caaa535661ce
[08:14:29] Seenox: Burgestrand: I will then use this output in another one like the "hosts" I have above to add multiple values.
[08:16:17] Seenox: Burgestrand: https://eval.in/789277
[08:16:59] Seenox: Burgestrand: If you look at the output, it is missing a starting " and also an ending ",
[08:18:17] Seenox: Burgestrand: Can you please explain what mistake I am making here?
[08:20:34] Seenox: Burgestrand: Hmm, I can't understand you. You mean the output is a mess?
[08:22:04] Seenox: Burgestrand: to explain a little bit more about it, the script should have a variable like this and then we add our own name at the end of it to use it like this: hammer hostgroup update --title MANUALLYADDEDTITLE --puppet-classes "THEOUTPUTWEHAVE","MANUALLYADDEDNAME"
[08:22:39] Seenox: Burgestrand: Exactly.
[08:23:11] Seenox: Burgestrand: Am I still making a mess here or I am good to go?
[08:24:34] Seenox: Burgestrand: I think in this particular thing, it will be ok.
[08:25:22] Seenox: Burgestrand: Can you please explain what exactly \ did in that puts?
[08:26:04] Seenox: Burgestrand: so I can use \ "," to it and it will add the ending comma?
[08:27:01] Seenox: Burgestrand: Since the data coming from another command in a json format, I think it will be safe to use it like that, or maybe I am lost here.
[08:27:57] Seenox: Burgestrand: That's true... How to avoid such a thing in general?
[08:32:52] Seenox: Burgestrand: For example before the last step, I put it through shelljoin?
[08:35:17] Seenox: Burgestrand: So in the end, the third value in hash will be ineffective?
[08:36:09] Seenox: Burgestrand: the name, or quoted in the hash array?\
[08:36:33] Seenox: Burgestrand: I see.
[08:39:03] Seenox: Burgestrand: Thanks a lot for your time and help every single time!
[08:39:24] Seenox: Burgestrand: I really appreciate it. Thanks man.
[08:41:17] Seenox: Burgestrand: :) haha.
[08:45:21] Seenox: Burgestrand: At the end it worked very great. https://gist.github.com/anonymous/4824d1c58dff0cfca93254af53fce98f
[08:46:10] Seenox: Burgestrand: Now I just need to add shellescape before the last step.
[08:49:00] Seenox: Burgestrand: The first output is like this: https://gist.github.com/anonymous/cd12350a7672e5f40e41e947b15365c3
[08:49:22] Seenox: Burgestrand: I can still call the name key and get the values without removing the IDs, right?
[08:50:12] Seenox: Burgestrand: Great!
[08:52:11] Seenox: Burgestrand: What would be the difference in my case? Isn't it same?
[08:56:44] Seenox: Burgestrand: ah I missed that "s".
[08:57:33] Seenox: Burgestrand: Perfect. thanks for the tip.
[09:01:47] Seenox: Burgestrand: lol
[09:02:56] Seenox: Burgestrand: The downside is it doesn't return the output as text, what is the advantage?
[09:03:29] Seenox: Burgestrand: I had another case in my script that I had to end it with 2>/dev/null
[09:05:01] Seenox: Burgestrand: https://gist.github.com/anonymous/7bab3155b373b1a12d5d49281f982989
[09:05:25] Seenox: Burgestrand: So in this case, I could use exec instead and avoid 2>/dev/null?
[09:07:42] Seenox: Burgestrand: Also using system, I can't do the same thing with for example in this case "hammer"?
[09:08:42] Seenox: Burgestrand: I see. So in my case it wouldn't be correct.
[09:09:33] Seenox: Burgestrand: True or false, as in if the command exists or not?
[09:10:29] Seenox: Burgestrand: What if the program outputs a text regardless of success or fail?
[09:11:27] Seenox: Burgestrand: Got it.
[12:22:59] Seenox: I am trying to compare two arrays, but am stucked... https://gist.github.com/anonymous/b28819c4f945b638040ebd518dfa9372 Can anyone please check and tell what am I doing wrong?
[12:23:02] Seenox: Burgestrand: ^

2017-05-03

[10:28:34] Seenox: Ping timeout: 260 seconds
[13:02:50] Seenox: has joined #ruby

2017-05-02

[07:01:58] Seenox: Hello. What is the best way to read a json file line by line and convert datas into hashes of hashes?
[07:03:01] Seenox: ljarvis: Thanks, going to read it now.
[07:03:52] Seenox: ljarvis: Yes, I will show you an example in a minute.
[07:06:20] Seenox: ljarvis: https://pastebin.com/vVYmqSSA
[07:07:37] Seenox: ljarvis: What I want to do is to read this type of json file line by read, and add each block into hashes.
[07:07:44] Seenox: line by line*
[07:11:59] Seenox: allisio: Thanks. Let me read about it quickly.
[07:13:09] Seenox: allisio: I think I've already tried that but the hashes were not in the right format after using it.
[07:13:46] Seenox: hostgroup_json_file = File.read('hostgroup.json') hostgroup_hash = JSON.parse(hostgroup_json_file)
[07:21:56] Seenox: allisio: You're right. I've just copied a little part of my original json file. I've tried JSON.parse again now.
[07:22:47] Seenox: Seenox: It seems to work correctly.
[07:26:35] Seenox: allisio: Thank you again.
[07:44:54] Seenox: allisio: I think I am lost again. I've successfully added each block of JSON into hashes. Now I want to select for example only hashes with a specific keys. What did I do wrong here? https://gist.github.com/anonymous/e4349eb54a72f1956d287cc134752452
[07:59:26] Seenox: al2o3-cr: Values, sorry. Is it a better idea to use .select? Like this for example: https://gist.github.com/anonymous/ee806e719b2df997f450e1d7f152f455
[08:11:10] Seenox: Burgestrand: 'host_hash' is a hash of hashes in my case. So first I need to separate keys and values and then work with them? Something like this for example: https://gist.github.com/anonymous/2c1622dea53b912f3d4bdf6f06cc6690
[08:19:30] Seenox: Burgestrand: Thanks! Exactly what I needed. What if I've another nested_hash inside a nested_hash for example? Should I break it again with .each?
[08:20:36] Seenox: Burgestrand: Sure. One moment please.
[08:29:12] Seenox: Burgestrand: Here is my hash for example: https://gist.github.com/anonymous/9651b2498191d31de0bec2b0af5c55b8
[08:30:11] Seenox: Burgestrand: It will be 5000 hashes inside a hash.
[08:31:11] Seenox: Burgestrand: Should I avoid each and use select and map in this example? I want to remove all hashes which doesn't contain a certain value from a specific key.
[08:31:58] Seenox: Burgestrand: No they don't have that first key.
[08:33:26] Seenox: Burgestrand: When I use host_hash.each do |each_host|, then it returns each block of those hashes.
[08:33:49] Seenox: Burgestrand: Which looks like what I've sent you as example of my hash.
[08:35:02] Seenox: Burgestrand: Hmm, I am lost I think. should I do 'puts host_hash.class' ?
[08:35:32] Seenox: Burgestrand: Array
[08:36:44] Seenox: Burgestrand: Exactly. They should be converted into list of hashes first?
[08:38:16] Seenox: Burgestrand: That's how I imported them from a json file: https://gist.github.com/anonymous/5c40254cc2a74b71a9f7f81b79c8328a
[08:39:11] Seenox: I've renamed it to host_array.
[08:50:56] Seenox: Burgestrand: https://gist.github.com/anonymous/b58dba4ea1bef37acd4d94c0e73e3687
[08:52:27] Seenox: Burgestrand: Did I do something terribly wrong?
[08:52:41] Seenox: Burgestrand: No, but I got an error.
[08:53:03] Seenox: Burgestrand: `block in <main>': undefined method `dig' for #<Hash:0x00000001c03770> (NoMethodError) from test.rb:12:in `keep_if' from test.rb:12:in `<main>'
[08:54:23] Seenox: Burgestrand: I am on 1.9.1
[08:55:31] Seenox: Burgestrand: Worked. but just returned [].
[08:56:52] Seenox: Burgestrand: as in my example, I want to keep each of hashes (or Array?) that contains that Debian in hostgroup_name in it.
[08:58:15] Seenox: Burgestrand: Awesome! It worked.
[08:58:29] Seenox: Burgestrand: [6, 16, 48, 50]
[08:59:19] Seenox: Burgestrand: So it will be ok to work with them for further data editing in it as arrays?
[09:02:13] Seenox: Burgestrand: Thank you so much! It worked perfectly. https://gist.github.com/anonymous/a2cbae60c592acf12aec74dd836cca1f
[09:02:55] Seenox: Burgestrand: You will be an amazing teacher one day! So patient and helpful. That's really great.
[09:05:28] Seenox: Burgestrand: Did we use .map to run through each block of arrays?
[09:07:07] Seenox: Burgestrand: The example was too much for a newbie like me! lol
[09:07:34] Seenox: Burgestrand: So in my example, we could just use p production_hosts ?
[09:07:59] Seenox: Burgestrand: "IF" we wanted to just print the whole block.
[09:08:36] Seenox: Burgestrand: I see. So we used .map to print only 'ID's from the remaining hosts?
[09:09:12] Seenox: Burgestrand: Gotcha. Thanks again.
[09:09:54] Seenox: Burgestrand: I will have to work more with my data and further filter it and see how far I can go with it.
[09:11:06] Seenox: Burgestrand: With your help, for sure! It always help a lot to have someone like you that can explain stuff in human language so to say!
[09:11:47] Seenox: Burgestrand: I will definitely use their help in the future too.

2017-04-27

[12:18:07] Seenox: has joined #ruby
[12:18:50] Seenox: Hello. What is the best way to have a "grep" like functionality in a ruby output?
[12:19:51] Seenox: apeiros: ruby file.rb | grep "xx" ?
[12:20:13] Seenox: apeiros: Thanks.
[12:26:46] Seenox: apeiros: Are there any other way to implement something like that in a ruby file itself?
[12:39:12] Seenox: apeiros: Sorry for late reply. Yes, I need to figure that out first.
[12:40:05] Seenox: apeiros: The goal is to read manifest.mf files data, sort them, clean them and pass it to another file.
[13:17:32] Seenox: kke_: Yeah, thanks.
[14:51:57] Seenox: apeiros: Thanks.