Activity Graph

Page 1 of 18 | Next »


[00:05:45] droptone: Ping timeout: 264 seconds
[03:44:36] droptone: has joined #ruby
[05:09:27] droptone: Ping timeout: 240 seconds
[05:45:50] droptone: has joined #ruby
[06:57:24] droptone: Ping timeout: 240 seconds


[20:30:25] droptone: has joined #ruby
[20:30:37] droptone: Question: if I want to print all the values in a string through interpolation, what's the best way to do this?
[20:30:42] droptone: Sorry, not a string, in a hash
[20:31:07] droptone: For example, myhash = { "bob" => "jim" }, puts "Hello, this is my hash: #{my_hash}"
[20:31:32] droptone: When I do that, it just prints the hex value of the hash in ram I believe, such as 0x0000000dbd1ac0
[20:31:40] droptone: And not the values within the hash
[20:33:23] droptone: Yes, and it appears I'm wrong, if I just try puts "#{my_hash}" in irb it works, it appears it's because I'm using ActiveRecord in this non-rails project
[20:33:36] droptone: It's printing the active record hex value instead of the values within the hash
[20:33:45] droptone: Or the AR record, so scratch that, apologies.
[20:33:50] droptone: Different issue.
[20:42:19] droptone: Looks like with an AR record you can just .inspect it in a string interpolation and it'll print the values
[20:42:38] droptone: anyone happen to know if that's the case without me having to build out a temp environment that includes AR and sets values and all that?
[20:43:02] droptone: apeiros: ok, thanks. So even if it's an AR record and I'm trying to print all values, I simplly .to_s it and it'll list the values.
[20:43:12] droptone: Ok, will do, ty sir.
[21:14:33] droptone: Read error: Connection reset by peer
[21:56:36] droptone: has joined #ruby


[02:40:08] droptone: Ping timeout: 244 seconds


[03:02:02] droptone: Question: Do both .find and .select return arrays, or does .find return the first match?
[03:03:14] droptone: so find returns the first result, and would return nil if not found


[03:56:39] droptone: Question: I've got my text successfully aligning within a <td> via align="center", but I can't seem to get this rails button_to to align center within the cell
[03:56:57] droptone: In the css for the table ID, I've set the text-align: center, that has no effect
[03:57:13] droptone: Is there a specific param for button_to that will align center?
[03:57:20] droptone: I can't seem to find any in documentation.


[22:19:14] droptone: Ping timeout: 260 seconds
[22:36:33] droptone: has joined #RubyOnRails
[22:36:33] droptone: has joined #ruby


[04:11:05] droptone: has joined #RubyOnRails
[04:12:51] droptone: Question: I have an html table in a view and one of the columns is a checkbox, and if the user clicks a "delete" submit button at the bottom of the table, an action is called that contains all of the rows that have a selected check box.
[04:12:57] droptone: Or at least, that's the intended behavior.
[04:13:09] droptone: The question is, how do I assign a unique iD to each checkbox per-row?
[04:13:27] droptone: So that I know which check boxes are checked upon clicking submit?
[05:34:16] droptone: I'm levering check_box_tag like this: <%= check_box_tag "syncval", false, :id => "#{syncval.id}" %>
[05:34:28] droptone: What's the procedure for setting the check boxes to false by default?
[05:34:31] droptone: They're all true by default.
[16:23:37] droptone: Question: I'm attempting to allow users the ability to see their patients in a table, with a checkbox named "Delete?" in the first column of each row, as seen here: https://gist.github.com/anonymous/32b70867ecaf6b05d65629509b8042e1
[16:24:12] droptone: The issue is, when users click "submit", the post params are only passing the first checked entry
[16:24:36] droptone: Can anyone see what I"m doing wrong there?
[16:34:57] droptone: tbuehlmann: I see. So, in the controller the params are to go to, "autodetect#autodetect_result", I'd like to be able to execute a params[:patient].each so I can iterate through all IDs
[16:35:01] droptone: What's the best way to do this?
[16:36:04] droptone: hmm, I suppose I could dynamically put the id of the patient in the param itself, then parse params for any value starting with "patient" and go from there.
[16:43:40] droptone: tbuehlmann: Yes, I got it by making the name dynamic, thank you
[16:50:28] droptone: tbuehlamann: Interesting, let me try that.
[16:50:59] droptone: So what, set the name to "patients[]" and then set the value to the id of the patients?
[16:51:25] droptone: such as <%= check_box_tag patients[], patient.id, false %>
[16:53:25] droptone: I suppose I should declare the array ahead of time.
[16:56:35] droptone: Well, when using the code above, <%= check_box_tag patients[], patient.id, false %>
[16:56:44] droptone: I get "undefined variable patients"
[16:56:57] droptone: and then when I declare it, I'm now getting a "wrong number of arguments" error in the check_box_tag code
[17:05:10] droptone: tbuehlmann: Awesome, that worked.
[17:05:15] droptone: I would have never have guessed that.
[21:12:11] droptone: Question: I'm having trouble finding documentation on placing an arbitrary button_to button in my view that calls a controller#action but using HTTP get instead of post, is this possible or no?
[21:12:50] droptone: disregard, found the docs.
[21:18:12] droptone: good point durexlw, thank you


[04:16:49] droptone: Question: I'm attemping to search an array of hashes to see if specific elemtns within a given hash match any string within an array, as seen here: https://gist.github.com/anonymous/f30f757084bb961965f2093d40f5eda8
[04:21:57] droptone: bazzy: Stack Overflow users usually answer questions within a couple hours if needed.
[06:15:37] droptone: If I want to execute a .each loop on an array, but skip the first index (index 0), is it best to use .each_with_index and then next if index == 0?
[06:15:55] droptone: or is there a better way to do that?
[06:17:57] droptone: Arcaire: ty
[06:29:09] droptone: Random epic statment
[06:31:34] droptone: My bank codes everything in the 1980s verson of logo
[06:32:34] droptone: The web UI takes about 10 minutes to draw as the turtle moves around the screen


[08:23:57] droptone: Does .find return just the first matching result?
[08:27:03] droptone: Ok, so in this context:
[08:27:04] droptone: contacts = [ { "name" => "Jim", "age" => 20 }, { "name" => "Bob", "age" => 25 }, { "name" => "Jim", "age" => 20 } ]; user = { "name" => "Jim", "age" => 20 }; testfind = contacts.find(|con| con["name"].downcase == user["name"].downcase);
[08:27:08] droptone: Just that line.
[08:27:18] droptone: That final find statement would match two entries, the first and the last array index.
[08:30:38] droptone: Right, but did you see how I wasn't clear on which .find of the infinite .find methods I would be researching?
[08:31:16] droptone: Right, but I clearly didn't understand that I needed to know the class to understand the context.
[08:31:20] droptone: Hence me asking the question in the channel.


[06:09:01] droptone: has joined #ruby
[06:09:50] droptone: Question: What's a better way to write if !(provider == "service1" || provider == "test2" || provider == "internal3" )
[06:10:00] droptone: Isn't there a way to leverage .include?
[06:10:29] droptone: like if !provider.includes?("service1", "test2", "internal3")
[06:11:33] droptone: The thing is, I want it to match, not just see if the string exists within provider
[06:13:22] droptone: If I write ["service1", "test2", "internal3"].any? { |name| provider.include? name } that matches even if part of the string is present in provider
[06:13:52] droptone: Disregard, I got it by switching .include? with ==


[14:47:10] droptone: Quit: leaving


[03:29:00] droptone: Do any of you guys work with eager loading much?
[03:35:18] droptone: I simply have a table "patients" that belongs_to users and I want to eager load it to an array in as few SQL queries as possible.
[03:37:26] droptone: Question: I have a table, "patients". It belongs_to User. I simply want to load the contents of "patients" to an array in as few SQL queries as possible. I've been researching eager loading but I can't seem to determine how exactly to accomplish this.
[03:39:07] droptone: Ok, so to be clear, I have user = User.find_by_email("myemail@here.com");
[03:39:29] droptone: Then I want to perform patients = []; patients = Patient.?
[03:39:45] droptone: patients belongs_to user
[03:40:09] droptone: And I want to eager load all patients with a user_id value matching user.id into the patients array
[03:40:38] droptone: So that I can then iterate over patients and it not perform SQL queries to get individual record values
[03:41:21] droptone: huh, so that's it, simply patients = user.patients?
[03:41:24] droptone: or user.patients.all rather
[03:41:48] droptone: haha, ok man, thanks
[03:42:41] droptone: Questino: I'm leveraging AR for this app and I'm attempting to minimize SQL transactions, since profiling indicates most of my activity revolves around SQL transiactions
[03:43:47] droptone: Therefore, I'm essentially attempting to eager load this table into an array so that I can then perform analysis and comparisons on the values of the table while the contents of the table are in ram, without my app having to hit the DB
[03:44:18] droptone: Does anyone current present have experience with such activity?
[03:45:50] droptone: Gaelan: Well yes. to simplify the example, let's say I have a users table, and a patients table that belongs_to user.
[03:45:55] droptone: I'm leveraging AR as my ORM
[03:46:42] droptone: What happened was, I'm getting more customers for my app and I need to speed it up.
[03:47:21] droptone: So I profiled it and it was clear the majority of my activity revolves around SQL DB queries, which are occurring against an Amazon RDS instance
[03:47:40] droptone: right now, the way my app behaves is, simplified:
[03:47:48] droptone: 1) Load a bunch of data from a remote API provider
[03:48:18] droptone: 2) Iterate through the data returned and compare it to the corresponding records on file
[03:48:28] droptone: 3) If needed, perform actions on said data and send them to another API
[03:49:15] droptone: So what I'm trying to do is dump the "patients" table in an object so that I can perform the check-on-iteration in ram instead of having to hit the DB every time
[03:49:50] droptone: I'm trying to figure out the best way to do this minimizing SQL queries
[04:01:05] droptone: Radar: thank you.
[04:05:56] droptone: Ok, so, here's the issue. I'll give it a shot.
[04:06:57] droptone: My app, which leverages AR like Rails which is why I'm asking in here, is getting more customers and I need to speed it up. Right now, I'm trying to minimize the number of SQL queries by dumping the contents of a given table to an object.
[04:08:02] droptone: If I simply leverage a .all as suggested, that's an AR relation, so say I do something simple, patients = User.patients, and then I execute patients.find_by_product_id(1235)
[04:08:20] droptone: I can see that it's still executing a SQL query for that find statement
[04:08:25] droptone: This is what I'm trying to avoid
[04:08:58] droptone: Having said this, I'm not familiar with eager loading, and I've been reading quite a bit on it, but I'm still not entirely sure how to perform what should be a simple action.
[04:09:27] droptone: I'm using the simplified schema users and patients belongs_to :user
[04:09:48] droptone: But if I simply want to eager load all patients with a user_id column that matches user.id
[04:10:10] droptone: Never mind, thank you.
[04:11:47] droptone: So guys, got a question. If I have a User table, and I have a patients table that belongs_to :user, what is the preferred way of eager-loading user.patients to an object to minimize the number of SQL queries needed to load all patients for a given user?
[04:12:10] droptone: Using ActiveRecord, obviously.
[04:13:20] droptone: Yes Radar, becuase every time I ask in #rubyonrails I get commentary like "this sounds like a hack" and "why are you doing this" and "I need code segments" instead of just providing an example, so I figured I'd give it a shot here.
[04:13:41] droptone: It's not a rails question.
[04:16:56] droptone: has left #RubyOnRails: ()


[03:09:09] droptone: and also each patient has its own values
[03:10:10] droptone: the structure that best fits my algorithms is the one described
[03:10:26] droptone: I'm asking how it would be written
[03:10:38] droptone: all good, I've got it, thank you
[04:49:22] droptone: Question: for testing purposes, I'm attempting to load my database tables into hashes. I have one DB table that belongs_to another DB table. For example..
[04:49:55] droptone: I have a root "user" table, then I have an "accounts" table that belongs_to user, then I have a "patients" table that belongs_to "account"
[04:50:29] droptone: ffs, it's for a test I'm doing
[04:50:36] droptone: let's just assuming we don't care about "why"
[04:50:57] droptone: I guess there's no way to do this really since the only relation is the account table itself.
[04:51:12] droptone: ok never mind, I know what to do, thank you.
[05:01:43] droptone: Is it possible to have two belongs_to relations, so you can reference a table via either one foreign key or another?
[05:01:50] droptone: Or is that not recommended?
[05:02:18] droptone: ok, so it's not an ActiveRecord exception to have two belongs_to associations
[05:02:59] droptone: sevenseacat: I'm piloting a NASA spacecraft via Ruby on Rails
[05:03:26] droptone: I'll do that when I need conceptual help Radar, thank you
[05:03:30] droptone: You answered my only question.
[05:04:15] droptone: Ok, fair enough, here's what I'm doing.
[05:04:55] droptone: I have a Ruby app, not Rails, that is getting more customers and I need to speed it up. Profiling with ruby-prof indicates that my MySQL queries to my Amazon RDS instance are taking up the bulk of the time.
[05:05:05] droptone: I'm leveraging ActiveRecord which is why I ask ActiveRecord questions in here, since Rails does the same.
[05:05:31] droptone: And it has been advised I can potentially speed up execution by loading the DB data initially and sticking it in a hash, versues manually making sometimes thousands of DB queries
[05:06:20] droptone: Yes, the app itself is on an EC2 instance
[05:06:33] droptone: hmm, I believe so but I can check.
[05:06:57] droptone: If curious, here's the prof output: https://gist.github.com/anonymous/68a1e07a2ccfdddff6eb75666a6c58bd
[05:07:33] droptone: The queries themselves are responsive, I'm just executing a lot of them per-user depending on how much data the customer has.
[05:07:57] droptone: I understand sevenseacat.
[05:08:30] droptone: Well, I was explaining becuase you asked me to explain.
[06:50:36] droptone: eam: It's going.
[06:50:57] droptone: I'm currently rewriting the code to allow for a "mass DB dump" of sorts on program execution so I don't have to query the DB thousands of times for every user.
[06:51:13] droptone: To see if that improves the profile, since so much of the time seems to revolve around DB queries.
[06:51:46] droptone: If I load all the needed user DB records ahead of time, then only query the DB if a record needs to be updated (and update the hash being used in place of the DB as well), this might improve execution time.
[06:52:31] droptone: most of the time when my program executes, very few DB records need to be updated, usually just a handful
[06:52:36] droptone: but thousands need to be reviewed
[06:59:09] droptone: what are you working on ?
[06:59:15] droptone: anything interesting?
[07:08:15] droptone: that's interesting
[07:08:19] droptone: you're writing it in ruby?
[07:08:42] droptone: doesn't sound like a ruby project
[07:09:04] droptone: what's the definition of blocking?
[07:09:19] droptone: the way memory is organized into chunks?
[07:09:36] droptone: so if buffers fill it breaks vs blocking which is intelligent enough to swap?
[07:10:10] droptone: so since it's a socat between uarts the input stream will fill the buffer
[07:10:52] droptone: that's interesting work
[07:11:08] droptone: what serial devices are you reading data between?
[07:13:48] droptone: well that is interesting work
[07:13:55] droptone: you doing it for work?
[07:17:08] droptone: http://ruboto.org/
[07:17:11] droptone: you ever look at that
[07:17:25] droptone: I guess that's for native apps
[07:17:30] droptone: and you're writing low level code
[07:19:19] droptone: think you can get jruby to load via shebang
[15:30:22] droptone: Here's a question this morning: I'm attempting to load all DB records and store them in an array without having to .each through the entire collection, if this is possible.
[15:30:33] droptone: I'm doing this to reduce the number of SQL queries required to load my data.
[15:30:53] droptone: I'm researching .for_each and find_in_batches
[15:31:34] droptone: my intendent goal is simply my_array = []; load all records for table into an array using the fewest number of SQL queries
[15:57:13] droptone: there's no way to get ActiveRecord to generate a SQL query that can grab most or all of a given table with a single query and then put it in an array?
[15:57:32] droptone: The goal is to limit the number of SQL calls, the Ruby logic to parse that result and put it in an array is fine
[15:59:47] droptone: Well, based on irb output, if you say array = []; array = MyTable.all;
[16:00:08] droptone: If you then do array.each it executes a SQL query for each line since array now just contains an ActiveRecord relation
[16:00:11] droptone: not the actual data
[16:02:15] droptone: So ok, I have a three tables, "patients", "products", and "items"
[16:02:31] droptone: and I have a hash, user_data
[16:03:00] droptone: I want to pre-emtively execute a SQL query via ActiveRecord that fills user_data["patients"], which is an array, with the contents of the patients table
[16:03:05] droptone: with as few SQL queries as possible
[16:03:51] droptone: I was researching AR batch processing
[16:04:19] droptone: Yes, the general guide on AR querying, thank you.
[16:04:31] droptone: This is what I was testing last night:
[16:04:37] droptone: http://api.rubyonrails.org/classes/ActiveRecord/Batches.html
[16:04:56] droptone: leveraging for_each and specifying a batch_size over the record count of the table
[16:05:54] droptone: Ok, I'm reading about eager loading now, thank you.
[16:09:33] droptone: So reading this, no one knows how to specifically have an array called "patients" and eager load the Patient table into it? The condition would be where user_id == user.id, that's all.
[16:12:48] droptone: I actually found what I needed elsewhere
[20:32:50] droptone: eam: interesting
[20:33:07] droptone: Yes, we're leveraging AR and MySQL on an Amazon RDS instance
[22:04:45] droptone: Ping timeout: 246 seconds
[22:05:48] droptone: has joined #RubyOnRails
[22:05:48] droptone: has joined #ruby-offtopic
[22:05:48] droptone: has joined #ruby