ntt

Activity Graph

Page 1 of 1

2019-03-13

[09:37:14] ntt: Disconnected by services

2019-02-25

[08:17:21] ntt: has joined #ruby
[08:19:17] ntt: Hi, I'd like to extract all values from an Hash with a predefined key. The hash is composed by other hash. Example: h = { :node1 => { :ip => 1.2.3.4, ....}, :node2 => { :ip = 2.3.4.5,...}, ...} , how can I extral all "ip" values in an Array?
[08:19:49] ntt: flatten
[08:20:02] ntt: but it seems I need to know the "level"
[08:21:03] ntt: nope... But i'm going to read the doc. is this the right way to do whis?
[08:22:20] ntt: ok. thank you
[08:36:04] ntt: baweaver: thank you. I'm reading the doc. I do not understand if there is the possibility to traverse a very complex Hash reading the value of only one key (in my case "ipaddress") without using map on each sub-hash
[08:36:57] ntt: but the Hash is very complex, with multiple Hash inseide
[08:37:53] ntt: but should I use map on each value?
[08:38:23] ntt: ok... just a moment... I'll give you a more complex example
[08:39:42] ntt: https://paste.centos.org/view/ed3572f0
[08:40:03] ntt: I need to extract only ipaddress values
[08:42:10] ntt: just one array with all ipaddresses (without the key, only values)
[08:45:45] ntt: wow... ok. I'll give a try. Really thank you
[08:47:30] ntt: sure. I'm reading documentation on your github repo
[08:47:44] ntt: it works :) thank you
[08:48:40] ntt: I think it's a good idea pass only environment[:nodes] instead the complete hash. This can reduce the complexity and cpu cycles
[08:49:42] ntt: ok... but I'd like to use best-practices in my code if possible
[08:52:29] ntt: unfortunately the only information I have is that I have to search in environment[:nodes] (instead of the complete hash)
[08:52:45] ntt: but the number of nodes is small (around 30)
[09:08:25] ntt: al2o3-cr: thank you

2019-02-02

[10:13:23] ntt: Ping timeout: 245 seconds

2019-01-30

[09:13:56] ntt: Hello, how can I pass a variable to the match() method? example: str="/myregex$/"; x.match(str)
[09:14:06] ntt: obviously my example doesn't work
[09:19:15] ntt: x is a string in my case
[09:19:41] ntt: and str should be the regex.... probably the name of the variable is not so good
[09:22:36] ntt: I need to use a variable to save the regex because the regex is variable
[09:28:19] ntt: ok. so I can do rx="a" and then x.match(/#{a}/)
[09:29:42] ntt: yes. it works
[09:29:44] ntt: thank you
[09:32:32] ntt: jammanbo: here is the complete line in my code: myarray.select{|x| x.match(/#{rx}$/)}
[09:33:01] ntt: so basically I'm trying to see if a string ends with another, because each element of the array is a string
[09:34:45] ntt: no. rx is just a simple string
[09:57:00] ntt: jammanbo: thank you

2019-01-29

[10:49:55] ntt: has joined #ruby
[10:51:12] ntt: Hello, I'm trying to initialize a new model in a rails application and I'd like to insert a lot of default values. Can I create an hash like default_params = {...} and using it to initialize the model? Furthermore, I need to merge default_params with params I pass through the constructor. Please, someone can help me?
[10:53:16] ntt: tbuehlmann: thank you. Sure, they are always the same. Furthermore, I need to merge my default_params with some params I need to pass as arguments in the new() method. How can I merge in order to have only one hash?
[10:54:57] ntt: ok. But the problem is that I have an Hash as default_params and searching on google I found that I can use the method "instance_variable_set". Is this correct?
[10:57:00] ntt: yes. I have a looong hash like default_params = {....}. I need to initialize my model with this default_params and others that I'm going to add as params in the new() method
[11:05:29] ntt: what is "public_send" ?
[11:06:23] ntt: NoMethodError: undefined method `range' for #<VExtension:0x0000000005b7b808>
[13:55:52] ntt: hello, is there a way to make mandatory an attribute in a class? I cannot use ActiveRecord validation because I inherit table structure from an existend db and I cannot write directly on the database (through save() method).
[13:57:06] ntt: I'd like to return an error if I don't pass some params to the new() method and not create the istance of the object

2018-11-06

[08:37:19] ntt: has joined #ruby
[08:37:36] ntt: Hi, I'm trying to use Devise and I'd like to know if it is possible to use current_user in before_action? basically I added an attribute (.admin) to the model User, and I'd like to use something similar to "before_action current_user.admin?". Please, someone can give me some advice? Thank you
[08:43:15] ntt: tbuehlmann: actually I have an error: "undefined local variable or method `current_user' for ContractCategoriesController:Class". My syntax is: "before_action current_user.admin?, except: [:show, :index]"
[08:44:30] ntt: how can I solve?
[08:45:30] ntt: ok, so I have to define a method in the application controller
[08:52:47] ntt: tbuehlmann: I'm trying but it seems that if my private method in the application controller returns false, before_action doesn't consider this
[08:55:16] ntt: if the private method returns false, I'd like that CRUD actions will not be permitted
[08:58:05] ntt: ok... I'm sorry
[09:56:03] ntt: Ping timeout: 252 seconds

2018-07-23

[07:04:18] ntt: Remote host closed the connection

2018-07-20

[00:07:02] ntt: *.net *.split
[00:15:38] ntt: has joined #ruby

2018-07-16

[01:00:57] ntt: Ping timeout: 240 seconds
[01:03:04] ntt: has joined #ruby

2018-07-13

[10:10:32] ntt: has joined #ruby
[10:10:45] ntt: Hi, it is possible to encapsulate an ssh terminal through cable in a rails application? Basically I have a scenario where the server can connects via ssh to an (shh) client, and I need to see the ssh console in the browser. Is this possible?

2017-06-22

[07:59:37] ntt: has joined #RubyOnRails
[07:59:37] ntt: has joined #ruby
[16:07:50] ntt: Ping timeout: 240 seconds

2017-06-21

[08:51:34] ntt: has joined #ruby
[11:19:35] ntt: Ping timeout: 240 seconds
[12:58:22] ntt: has joined #ruby
[13:12:30] ntt: Ping timeout: 240 seconds
[14:13:03] ntt: has joined #ruby
[16:07:20] ntt: Ping timeout: 246 seconds

2017-06-07

[21:29:24] ntt: Ping timeout: 240 seconds

2017-05-30

[09:51:03] ntt: has joined #ruby

2017-05-26

[13:03:36] ntt: has joined #ruby
[13:04:43] ntt: Hi, I'm searching a way to read the name of interfaces on a linux centos 7 box with ruby 1.9. Someone can help me? I'm able to read IP with Socket::getaddrinfo(Socket.gethostname, "echo", Socket::AF_INET).map { |x| x[3] } but I don't understand how to read the interface name

2016-07-16

[05:55:53] ntt: has joined #ruby
[06:44:16] ntt: Ping timeout: 264 seconds
[07:13:12] ntt: has joined #ruby
[07:17:33] ntt: Ping timeout: 240 seconds

2016-07-15

[15:34:46] ntt: has joined #ruby
[15:36:00] ntt: Hi, I'm trying to launch a ruby script from crontab. In the script there is IPTABLES="sudo /sbin/iptables". If I try to launch the script from the console all works but if I try lo use crontab the iptables part doesn't works. Someone can help me please? I'm using ruby 1.8.7 with rvm
[16:23:39] ntt: Hi, I'm trying to launch a ruby script from crontab. In the script there is IPTABLES="sudo /sbin/iptables". If I try to launch the script from the console all works but if I try lo use crontab the iptables part doesn't works. Someone can help me please? I'm using ruby 1.8.7 with rvm. I think it is a permission problem with the command iptables
[16:29:23] ntt: jhass: in the script there is a part where I read the iptables status. If I execute the script from the console variables are correctly filled. If I execute the script from crontab variables are empty. I have something similar to v = (%x[#{IPTABLES} -t mangle -vnx -L '_AUTH_IN_...... )
[16:29:47] ntt: where IPTABLES="sudo /sbin/iptables"
[16:30:08] ntt: obviously the user that runs the script has permission for sudo without password
[16:32:45] ntt: CROND[21797]: (cloud-user) CMD (/bin/bash -l -c 'ruby /home/cloud-user/owcpm/lib/custom_workers/cp_upkeep.rb -d >> /tmp/cp_upkeep.log')
[16:32:51] ntt: jhass: this is the only log
[16:38:18] ntt: /bin/bash -l -c 'ruby /home/cloud-user/owcpm/lib/custom_workers/cp_upkeep.rb -d 2>&1 /tmp/cp_upkeep.log'
[16:38:18] ntt: I'm trying with this row in crontab:
[16:38:19] ntt: I see that the script start but cp_upkeep.log is empty
[16:38:22] ntt: What I'm wrong?
[16:39:14] ntt: so.... no errors? How is this possible?
[16:40:18] ntt: How can I redirect stderr to stdout and stdout to cp_upkeep.log?
[16:40:56] ntt: yes... But I don't know how to concatenate
[16:41:13] ntt: ok... I'm sorry
[16:43:34] ntt: jhass.... I see the same as with only stdout redirection
[16:45:35] ntt: http://pastebin.com/aZhhkBQN
[16:49:24] ntt: jhass: can you check the gist?
[16:50:25] ntt: I'm trying with this
[16:50:25] ntt: r = (%x[#{IPTABLES} -vnL -t nat])
[16:50:33] ntt: it works if executed from console
[16:50:44] ntt: not if launched with crontab
[16:59:09] ntt: jhass: I think the problem is crontab. Created a crontab row = */1 * * * * /bin/bash -c -l 'sudo touch /var/www/html/test_cron' <--- This cronjob is executed with the user "cloud-user". It has sudo permission without insert the password. If I try from bash, I can create the file test_cron without insert the password. If I launch from crontab this doesn't work
[18:38:54] ntt: Ping timeout: 246 seconds