Page 1 of 2 | Next »
[22:24:33] AndreYuhai: Hey there, I have a class and I am including a module to create database tables. But for example I will need more than 2 create table methods each of them creating a different table. How can I separate them using namespaces or modules? I got a bit confused.
[22:29:08] AndreYuhai: I mean how can I use my create_table method like ModuleName.create_table ? Because when I make it a class method then I can not use the instance variable from the class in which I am including the module.
[21:19:59] AndreYuhai: Hey there, how do I throw an exception out of my function? Just like in Java like public int foo () throws ...
[21:29:47] AndreYuhai: leftylink: Nope, to be more clear, I have a class called "Database" using the gem "Mysql2" and in that class I have a function called insert_into_table. So I am using this "Database" class in another class to insert some data into my table.
[21:30:10] AndreYuhai: But when the data is duplicate I get an exception. I want to pass this exception to the calling class
[15:23:49] AndreYuhai: Hey there, I hava an address column in my database table, I would like to extract the country, city and state names. How would I go about it given that there is not a pattern to use regexp.
[15:24:33] AndreYuhai: I've tried to look up for a gem and I've found one called city-state but does not seem to work.
[13:09:09] AndreYuhai: Hi there, how do I loop through months instead of all all the days withing the two months?
[13:09:50] AndreYuhai: for example : 2019, 05 -> 2019, 07 I want to loop through 2019, 05 / 2019, 06 / 2019, 07
[23:11:41] AndreYuhai: hey there I am tryinng to scrape aliexpress and there is this slidebar to prevent bots. But even though I can slide it using watir I still get an error. And sometimes I get it even when I try manually, any idea as to why and how to prevent it? https://imgur.com/a/FudHjFW
[17:23:32] AndreYuhai: Hi there, I am using Watir to navigate to Aliexpress but sometimes I get this slidebar to slide it to right, however even if slide it manually I still get the error message in the picture. Any idea as to why? This even happens when I am not using watir or any other automation but just manually navigating to Aliexpress https://imgur.com/a/FudHjFW
[18:26:48] AndreYuhai: How do I keep selecting from the nodeset that I have in hand using xpath? For example I am looking for an a tag in h2. I've selected h2 but a is not the immediate element after h2, how do I select it?
[00:29:10] AndreYuhai: phaul: I wrote the setter for my instance variable as you suggested. But why can I not use it in my initialize? I mean it didn't work this way.
[08:16:30] AndreYuhai: phaul: Can you take a look at this ? https://paste.ofcode.org/RqAXcvvqpf9Z46XUjre7Q3
[08:20:24] AndreYuhai: phaul: Yes, this does not work. It simply assigns the values to the instance variables without evaluating them with my setter methods as if they don't exist.
[08:31:45] AndreYuhai: phaul: Yes I did. I converted them into self.method=(foo) but they still get set directly.
[08:35:59] AndreYuhai: phaul: When I set the value using the method like obj.file_date = '04/01/2019' then it works and gives me => '2019-04-01' but I don't know why in initialization it does not work.
[08:40:56] AndreYuhai: phaul: Now it works. Thank you. But what is the difference between using self.method and @variable_name? Because one uses the setter method we wrote and the other one just assigns the value and I didn't even have a attr_accessor
[08:44:12] AndreYuhai: phaul: Hahaha thank you, I added it to my watch list! :) Thanks for the help!
[09:42:24] AndreYuhai: How do I escape a single quote in my string with gsub or etc.? :D gsub("'", "\'") does not work
[20:13:00] AndreYuhai: Hello there, I am using mysql2 gem. I want to insert NULLs when the string is empty. How to achieve this? I mean if I do string interpolation in my INSERT query then I will have quotes but when NULL put in quotes it is not treated as NULL.
[20:13:28] AndreYuhai: I couldn't come up with a good way of implementing this idea and I couldn't find anything on the Internet.
[20:14:58] AndreYuhai: the default is already NULL. but then if I skip that in my INSERT query then what if in a case where the string is not empty. Because INSERT query is hard coded.
[20:17:19] AndreYuhai: Oh, maybe I could just put strings in quotes before interpolating them in insert query so that I can also convert empty strings to NULL! I will try that and see.
[21:57:43] AndreYuhai: How to check if a string is just containing white space? Strip does not help.
[22:38:16] AndreYuhai: havenwood: This is actually what I was looking for just now. I guess using this regexp : /\A\s*\Z/ does not work for
[22:43:00] AndreYuhai: I don't know why it does not work but I just figured it out. Hopefully the first string I got had this  . :D
[23:27:53] AndreYuhai: How can I check a value or change it before I assign it to my instance variable that is declared with attr_accessor? Should I override variable_name= ?
[16:49:36] AndreYuhai: Hello there, I have a script and I want it to run everyday. And the script needs user input. Can I do it without using cronjob or sleep?
[17:00:54] AndreYuhai: havenwood: Well, I don't know if there is any pros or cons to sleep so I wanted to ask whether there are other ways to do it. The input would either be two dates or one date (that day's date). So I also do not know whether I can also get the date automatically for the cronjob. But I am searching and I will also check that gem. Thank you :)
[17:06:15] AndreYuhai: havenwood: But would it still do that if we specify an exact date? Instead of saying 24 hours. I mean by checking the actual date and etc.
[18:19:44] AndreYuhai: havenwood: Yes, for example sleeping for a period of time and checking the date constantly, for example sleeping for a few hours instead of 24. Sorry for the delay by the way.
[18:25:41] AndreYuhai: havenwood: Oh that is a good idea as well. I guess I will go with the cronjob but I will also check the timer gem. Thank you. By the way would there be any consequence of using 'sleep' on the server side compared to cronjobs?
[18:28:44] AndreYuhai: havenwood: Okay, thanks for the help. :) I will also check the timers gem and then decide which one to use.
[14:07:29] AndreYuhai: Hello there, I am trying to get all the links from a web page using mechanize. The question is when the link is something like "http://foo.com/#bar" this link is okay but when the link also has spaces like "http://foo.com/#bar qux" then it gets '#' and 'space' characters gets replaced with '%23' and '%20'. Is there any way to prevent this or should I switch to addressable gem?
[14:17:32] AndreYuhai: havenwood: but the '#' doesn't get decoded back, right? I mean when it is space and %20 when you navigate to that link space becomes a space in the address bar again. But hashtag does not get decoded.
[14:22:08] AndreYuhai: havenwood: But for example: 'https://avc.com/%23post-18810' This says page not found.
[14:32:08] AndreYuhai: havenwood, jhass So what I was trying to say is when I use mechanize and get the links if there is this fragment part then URI module encodes it, but I guess it shouldn't be encoded then.
[14:32:37] AndreYuhai: And it only encodes when you have space too. I mean if you do not have any space then it does not encode.
[14:33:29] AndreYuhai: For example if you have "...com/#section" this does not get encoded, but "...com/#section ruby" gets encoded as "23%section%20ruby"
[14:40:36] AndreYuhai: I mean if I don't fix it then the URL I request is wrong so I can't view that page.
[14:49:08] AndreYuhai: jhass: Oh, that is right though. Haha, I can just ignore the fragment as you said since it doesn't really make sense anyway to have the fragment.
[14:50:39] AndreYuhai: jhass: I am not really scraping the content though. I am just trying to get all the links from each page using BFS just for fun. The page is my blog page blog.andreyuhai.com
[15:01:11] AndreYuhai: jhass: Well, actually I just tried it. Since URI encodes even the fragment part then URI module does not recognize the fragment part afterwards haha. Even to_s returns the encoded string. I will try with addressable and see.
[21:31:58] AndreYuhai: Hello there, I have this example string "J & M AUTO BODY" that I need to add to my query string for making requests. But using CGI.escape or URI.escape does not work as expected. CGI.escape gives me "J+%26+M+AUTO+BODY", URI.escape gives me "J%20&%20M%20AUTO%20BODY". Is there a way to escape '&' instead of gsub and etc.?
[21:38:28] AndreYuhai: havenwood: I just want to escape ampersand properly as it should be. & => %26
[21:38:55] AndreYuhai: I mean gsub works as well but I was wondering whether there is any other way.
[21:42:20] AndreYuhai: havenwood: This worked as expected but I didn't know about that second parameter. Thanks I will check out the docs.
[16:41:33] AndreYuhai: I have an each loop and then I am rescuing an exception inside the loop within a begin-end block. I want to redo the current iteration in rescue block, so putting redo will execute the each block again and not the begin block, right?
[10:39:47] AndreYuhai: Hello there, I want to select a range from the array which will be from the index number 1 to the last index. I've tried this: arr[1..] and this worked on irb, but then RuboCop warns me on RubyMine. Is that expression correct?
[11:03:42] AndreYuhai: al2o3-cr: should I create the rubocop.yml file for each project separately? Because I can't find it.
[11:10:21] AndreYuhai: al2o3-cr: Thank you. Now I've created them but in rubocop.yml it says inherit from rubocop_todo.yml but in todo there is nothing about AllCops
[12:11:51] AndreYuhai: al2o3-cr: Oh I didn't know about that method. Sure that is even better what I needed was just to drop first index (table header :D)
[19:48:25] AndreYuhai: Hey there, is there any way to open a CSV file and then just fill in the necessary cells? For example the cell at 4th row and 6th column.
[19:48:58] AndreYuhai: So far I have been reading the CSV file and then changing whatever I want and then writing the whole file back.
[19:55:45] AndreYuhai: rindolf: if yes, sometimes the cells are empty so it wouldn't be the same size. The cell to be inserted with the new value can be either empty or there may be another value.
[10:28:04] AndreYuhai: Hello there, I am using Mechanize and I sometimes get 503 exception. I am rescuing this exception but how can I make it sleep(5) and try again as long as it gets this exception?
[10:28:43] AndreYuhai: I can just sleep and try it again by simply putting agent.get url inside the rescue block but what I want is a loop to do that as long as it gets that code
[03:22:41] AndreYuhai: Hello how can I write the xPath for this HTML https://paste.ofcode.org/a2egTxG6tEeKP8QFmaT3qJ I want to get the a tag. Is there any other way besides "//section[@class='pv-contact-info__contact-type ci-email']/div/a" ?
[23:06:56] AndreYuhai: Hello there anyone knows how I can solve these kind of captchas ? Containing only numbers. https://screenshots.firefox.com/EvV2UpRBTCgSEqjr/hacumre.diyanet.gov.tr
[23:09:42] AndreYuhai: Zarthus: we can say so :) But since there are already bots solving these, I would like to figure that out. :D
[19:44:21] AndreYuhai: Hi, how can we test stuff on Travis which requires username and password? Any sources?
[13:14:36] AndreYuhai: Hello, does an instance object get garbage collected when I assign something else to the same variable which was holding the referred object before? Or how does this works? Any sources?
[13:34:48] AndreYuhai: tbuehlmann: Thank you. ^^ I was wondering whether it would take so much memory because I instantiate an object a lot of times but always assigning it to the same variable.
[11:51:17] AndreYuhai: Hi, I have a JSON string from Instagram's page and I've created a class for that. https://dpaste.de/UvYE
[11:56:18] AndreYuhai: Guess I would have to create a class for edge objects too and then put the method there.
[22:03:11] AndreYuhai: apeiros: well, what if I wanted to run core.rb directly? Would it work in this situation?
[22:03:46] AndreYuhai: I mean for example just below the code we could create an instance an run a method of that class which also runs that "login" method