Activity Graph

Page 1 of 34 | Next »


[18:49:08] Scriptonaut: Ping timeout: 258 seconds
[18:50:10] Scriptonaut: has joined #ruby


[03:10:38] Scriptonaut: admin123: depends on what you're doing, for loops are rarely used though
[03:11:09] Scriptonaut: there are many different methods to iterate over an array/string/hash/etc, just depends on what you wanna do
[03:12:35] Scriptonaut: .each, .map, .select, .reject, etc
[03:13:18] Scriptonaut: so if you wanted to loop over an array, to collect/keep certain elements, you'd use select. If you wanted to remove certain elements, reject, if you wanted to map/convert the elements to something else, you'd use map
[03:14:16] Scriptonaut: it's a million times nicer than using for/while for everything, though I sometimes use while loops, usually when I'm reading from a socket or something


[23:10:52] Scriptonaut: has joined #ruby
[23:11:04] Scriptonaut: does anyone know of a ruby debugger that will work with ruby 1.8.7?
[23:11:25] Scriptonaut: I am working on this horrible/ancient project, and it's almost impossible to debug stuff without being able to go step by step like I usually do with pry
[23:11:55] Scriptonaut: it's an old ruby project, that had a bunch of old rails 2.0 libraries ripped out and injected into it
[23:32:00] Scriptonaut: adam12: cool, I'll check it out
[23:33:30] Scriptonaut: Eiam: I'll try that
[23:34:29] Scriptonaut: hmm, it installed just fine, but require 'pry' gives me "MissingSourceFile: no such file to load -- pry"


[22:30:18] Scriptonaut: has left #ruby: ()


[16:27:23] Scriptonaut: has joined #ruby
[16:28:25] Scriptonaut: hey all, I wrote a small script to run a command if my site doesn't respond with a "200" 3 times in a row. It was working fine where I wrote it (ruby 2.5 something), but when I put it on a production server running ruby 1.8.7, it just hangs on the "http.request(request)" on line 16.
[16:28:30] Scriptonaut:
[16:28:35] Scriptonaut: Eventually I get a timeout error
[16:29:03] Scriptonaut: anyone know why the code would work in ruby 2.5 and not 1.8.7? I've used net/https plenty of times on ruby 1.8.7 without problems
[16:39:49] Scriptonaut: havenwood: let me test
[16:39:52] Scriptonaut: the timeout takes a long time
[16:43:20] Scriptonaut: Errno::ETIMEDOUT: Connection timed out - connect(2)
[16:44:10] Scriptonaut: that time I got: Timeout::Error: execution expired
[16:44:20] Scriptonaut: havenwood: what did you use before then? I can't remember what I used back in the 1.8 days
[16:44:34] Scriptonaut: I really just need to grab a status code, could do it with curl but would rather not do system calls
[16:47:15] Scriptonaut: I think so too
[16:47:30] Scriptonaut: the googling I did said it might be an ssl version thing
[16:47:46] Scriptonaut: I tried commenting out the http.use_ssl = true
[16:52:29] Scriptonaut: with http or https?
[16:52:47] Scriptonaut: oh it gives me a 200
[16:52:51] Scriptonaut: weird, I thought it would redirect like curl does
[16:52:57] Scriptonaut: using http just hangs
[16:56:02] Scriptonaut: when I curl with http I get a 301
[16:58:22] Scriptonaut: this is really confusing
[16:58:32] Scriptonaut: why would curl give me a 301 and Net::HTTP.get_response give me a 200


[22:52:00] Scriptonaut: has left #RubyOnRails: ()



[19:41:29] Scriptonaut: has joined #RubyOnRails
[19:43:45] Scriptonaut: hey all, I want to get some input from you guys. Every project I've ever worked on, we ran the staging server in a "staging" env, with RAILS_ENV='staging'. Someone I work with thinks that it will cause issues, and wants to run the staging server with RAILS_ENV='production'. What is the standard way to do it nowadays? Run staging in 'staging' or 'production'
[19:46:21] Scriptonaut: my reasoning is that we want different settings for staging, like the log level should be "debug", api's should point to sandboxes, it should read/write to staging buckets, etc. Running it in production would mean that it would run the risk of modifying customer data when we're testing things in staging. The alternative is that we use a single production.rb file for both staging and prod servers,
[19:46:28] Scriptonaut: and then use environment variables to load the various differences. I like the idea of just putting that stuff in staging.rb (or in the credentials.yml file if it's sensitive)


[17:29:07] Scriptonaut: has joined #RubyOnRails
[19:03:42] Scriptonaut: Hey all, I setup a staging server for my rails 5 app. It uses nginx + unicorn. The staging environment is currently identical to the production env file (I haven't actually made a production yet). When I hit the server, I get: ActionView::Template::Error (The asset "application.css" is not present in the assett pipeline). I want nginx to serve up my assets, not the asset pipeline.
[19:03:58] Scriptonaut: Here is my env file staging.rb: (Is there anything obviously wrong in there?)
[19:04:25] Scriptonaut: There is no $RAILS_SERVE_STATIC_FILES env var set by the way
[19:06:39] Scriptonaut: I ran: rails assets:precompile, and my public/assets dir is filled with application-#{some_hash}.css, application-#{some_hash}.js, and then a .gz version of both of those
[22:52:36] Scriptonaut: has left #RubyOnRails: ()


[00:14:18] Scriptonaut: I'm confused, what do you mean not invalid, like it's supposed to produce different keys between ruby processes?
[00:14:29] Scriptonaut: or between console sessions, etc
[00:14:58] Scriptonaut: that's the header
[00:15:02] Scriptonaut: it goes header.payload.signature
[00:15:32] Scriptonaut: header has the meta info about the type of encryption, etc, payload is the actual data, then signature is an encrypted concatenation of the header, payload, and secret
[00:15:37] Scriptonaut: used to verify the payload/header
[00:15:50] Scriptonaut: I suppose I should try decoding it
[00:15:53] Scriptonaut: and see if it for some reason works
[00:16:03] Scriptonaut: the second one is the same too?
[00:16:34] Scriptonaut: oh I see, that's odd, it's not always the case
[00:16:54] Scriptonaut: I'll try decoding and see what I get, thanks
[00:19:10] Scriptonaut: This will give me the perfect excuse to have this part of the codebase rewritten, I was saying we should decode rather than just comparing the encrypted strings
[00:21:17] Scriptonaut: zenspider: I don't know why I didn't think to do that
[00:22:05] Scriptonaut: hmm, never had that need. I use git for diffs most of the time
[00:22:41] Scriptonaut: you could try diffuse
[00:22:49] Scriptonaut:
[02:09:31] Scriptonaut: havenwood: you're right
[02:09:33] Scriptonaut: that's what it was
[02:09:52] Scriptonaut: I'm surprised you were able to deduce that
[02:10:45] Scriptonaut: the only part left that's bothering me, is that an existing dev built a system where he generated tokens like this, sent it to another service we have, and then used the token in a db query to lookup records.
[02:10:55] Scriptonaut: so somehow up until now, those hashes have always been in the same order
[02:11:02] Scriptonaut: but when I do it, I often get different ordered hashes
[02:11:44] Scriptonaut: no idea why when I do it, the key/value order changes regularly, but he managed to do it for months, on the same computer, and kept it in the same order
[02:11:59] Scriptonaut: I assume I will have to rewrite his lookup system that does lookups by the encrypted tokens, I don't see any other way around it
[02:12:14] Scriptonaut: not that it's a very good way of looking things up
[02:13:53] Scriptonaut: the payloads only hold a database record id
[02:14:03] Scriptonaut: but they're signed with a secret
[02:15:57] Scriptonaut: oh, we're just signing it with a raw string, is that not a good idea?
[02:16:14] Scriptonaut: like ENV["JWT_SECRET"]
[02:19:27] Scriptonaut: ah ok, thanks for the example. While working on this feature I noticed this stuff was used in several other places, and it definitely wasn't encrypting the payload. I'll have to check it out to make sure it's nothing that should be secure
[18:39:45] Scriptonaut: has left #ruby: ()


[19:47:30] Scriptonaut: has left #ruby: ()
[23:22:08] Scriptonaut: has joined #ruby
[23:24:03] Scriptonaut: I've had this issue for 2 days, JWT.encode keeps on giving me different tokens when I restart my console. Here's a gist demonstrating it perfectly
[23:24:17] Scriptonaut: giving me different tokens, with the same exact input**


[01:20:15] Scriptonaut: has left #RubyOnRails: ()
[01:20:17] Scriptonaut: has joined #ruby
[01:21:49] Scriptonaut: hey guys, I'm using JWT.encode and passing it a record id. It is generating the same key (as it should), however I've noticed when I restart my console, it will sometimes generate a different key. It only ever generates those two keys (with the same exactly input), one or the other, and I have to restart the console to get it to change (and it doesn't always)
[01:22:19] Scriptonaut: JWT.encode is supposed to generate the same thing every time, as long as the input is the same, but for some reason it's not


[21:27:38] Scriptonaut: has joined #RubyOnRails
[21:32:41] Scriptonaut: hey guys, I'm working on a rails 5 project, and it's filtering my sensitive params in the rails server log, authenticity_token, password, and token. The only part of my config that explicitly tells it to filter is an initializer called filter_parameter_logging.rb, with the line Rails.application.config.filter_parameters += [:password]. Why is it filtering the token ones as well? I don't want it to
[21:32:47] Scriptonaut: filter in development, how can I disable that filtering?


[21:20:42] Scriptonaut: has joined #ruby
[21:57:53] Scriptonaut: has left #ruby: ()


[00:02:15] Scriptonaut: has joined #ruby
[00:57:49] Scriptonaut: I'm having some really strane behavior with overriding a setter method on an object, I've explained the error in the gist I'm about to post, but I'll summarize here. I call super in a method override for a setter method. When I call that method, I get "NoMethoderror: super: no superclass method". However the original method is defined, when I comment out the method override definition I can call it just
[00:57:58] Scriptonaut:
[00:59:30] Scriptonaut: also when I comment out the method override, my_object.methods includes my method. So the error is complaining that there is no superclass method, when there definitely is a superclass method
[01:02:12] Scriptonaut: has joined #RubyOnRails
[01:03:25] Scriptonaut: I'm having some really strange behavior with overriding a setter method on an activerecord object, I've explained the error in the gist I'm about to post, but I'll summarize here. I call super in a method override for a setter method. When I call that method, I get "NoMethoderror: super: no superclass method". However the original method is defined, when I comment out the method override definitio
[01:03:31] Scriptonaut: n I can call it just fine
[01:03:34] Scriptonaut:
[01:03:50] Scriptonaut: also when I comment out the method override, my_object.methods includes my method. So the error is complaining that there is no superclass method, when there definitely is a superclass method
[01:07:08] Scriptonaut: superclass is PgsqlDatabase(abstract), and result of that grep is []. I'm not trying to call a method on the super class though, I'm trying to call the method that existed there before it was overrode
[01:08:18] Scriptonaut: hmm, this is so odd, isn't there a way to call the method that a certain method overrode?
[01:08:45] Scriptonaut: ya, you're right, I wonder what I was thinking. I confused something here
[01:09:10] Scriptonaut: I guess there probably isn't a way
[01:11:10] Scriptonaut: ya, me too, I could have sworn there was a common way to do this
[01:11:31] Scriptonaut: I think maybe I just got so used to using it in descended classes that I started to think I could use it everywhere
[01:12:14] Scriptonaut: ah ya that should work
[01:13:33] Scriptonaut: I think I figured out where I got confused. This is a text-based json column for an active record object. Normally I do this, but rather than super I call read_attribute(:blah)
[01:14:02] Scriptonaut: since this column already comes with a getter/setter out of the gate that parses the json text, I can't simply get rid of it and rely on read_attribute
[01:18:41] Scriptonaut: ya that will work for sure. I think it that level of confusion won't be worth it, I can just rename the original getter/setter, and then keep the current name for the setter override, and add a getter override as well
[01:18:54] Scriptonaut: I think that level**
[01:19:36] Scriptonaut: people won't think to look at the bottom of the file for X.prepend
[01:20:31] Scriptonaut: unless there's a way to do: def self.included(klass); klass.prepend my_method; end
[01:22:59] Scriptonaut: This guy ran into the same issue as me
[01:24:48] Scriptonaut: oh, that's pretty coo
[01:24:53] Scriptonaut: I think I'll do that
[01:25:38] Scriptonaut: ah I see, it's because the method is defined via metaprogramming
[01:25:51] Scriptonaut: in my example
[01:53:49] Scriptonaut: has left #ruby: ()
[01:53:56] Scriptonaut: has left #RubyOnRails: ()


[19:29:36] Scriptonaut: has left #ruby: ()


[21:13:00] Scriptonaut: has joined #ruby
[21:13:36] Scriptonaut: have you guys noticed how in the ruby console, if you override an assignment method, it will always return whatever you assign it to, even if the method returns false?
[21:14:04] Scriptonaut: I have a method that's like: def receive_notifications=(flag); User.current.is_admin? && super(flag); end
[21:14:53] Scriptonaut: in the console however, when User.current is a non-admin user, and I do: my_user.receive_notifications = true, the console prints "true" as the return value, even though I checked, and it's not true
[21:15:02] Scriptonaut: should I raise an error instead?
[22:15:49] Scriptonaut: LadyElusive: no I overrode the receive_notifications= method. THen I call super inside of it. The method returns false, I've tested it, but for some reason the console (only in the console, not when it runs anywhere else) short-circuits and displays the return value as whatever you pass to it. With a normal assignment method this is expected behavior, but I overrode the method and changed how it worked
[22:16:29] Scriptonaut: I'll gist the actual code
[22:19:25] Scriptonaut:
[22:19:30] Scriptonaut: that's odd behavior
[22:22:12] Scriptonaut: I made another gist that demonstrates the weird behavior:
[22:39:29] Scriptonaut: Eiam: exactly
[22:39:33] Scriptonaut: that's why I'm confused
[22:39:38] Scriptonaut: why is the console displaying true, when it's false
[22:40:12] Scriptonaut: no it's not, look at line 6
[22:40:16] Scriptonaut: it returns true
[22:40:47] Scriptonaut: when I do: ret_val = (gu.receive_direct_message_alerts = true), ret_val is assigned true
[22:41:14] Scriptonaut: only in the console though, when I run it on unicorn or even just through the interpreter it returns false
[22:42:15] Scriptonaut:
[22:44:54] Scriptonaut: Eiam: it's a cp_typed_hash on an ActiveRecord 2 model
[22:45:11] Scriptonaut: the method I wrote is to override the setter to prevent non-admins from having that setting set to true
[22:45:40] Scriptonaut: baweaver: it's not
[22:46:02] Scriptonaut: Eiam: I explicitly wrote the setter, the getter was defined by cp_typed_hash
[22:46:11] Scriptonaut: Eiam: yes, I wrote that
[22:46:18] Scriptonaut: and then call super, to the setter that was defined previously
[22:46:23] Scriptonaut: method overriding
[22:46:35] Scriptonaut: I only call super if the user is an admin though
[22:47:07] Scriptonaut: this is an issue with irb, the code is working as it should, it's just that in irb the return value is true when it should be false
[22:47:27] Scriptonaut: I wonder if it's a bug in old irb, this is ruby 1.8.7
[22:50:02] Scriptonaut: I gisted a console session, I am not confusing the getter and setter
[22:50:21] Scriptonaut: I just recreated it in irb with a test class:
[22:50:30] Scriptonaut: there, that's plain ruby, no activerecord, no method overriding
[22:50:36] Scriptonaut: it still has the issue
[22:50:58] Scriptonaut: as you can see, on line 6, the method x= should always return false
[22:51:06] Scriptonaut: however on line 15 it returns true
[22:51:42] Scriptonaut: when I do: t.x = "foo bar", it returns "foo bar"
[22:52:06] Scriptonaut: I'm gonna try in ruby 2.5 and see if the issue is still there
[22:54:05] Scriptonaut: hmm, still happens with ruby 2.5.1. It must just be the way the console is written. I always thought that the => in the console was supposed to denote the return value, but when the method ends with a '=', it returns the RValue no matter what
[22:54:53] Scriptonaut: this was my 2.5.1 run:
[22:55:05] Scriptonaut: oh well, it's not a big deal, the code works. I just thought that was weird
[22:57:33] Scriptonaut: well that would change the behavior because that's totally different code. The assignment in your example wouldn't be dependent on the first argument to &&
[22:57:42] Scriptonaut: that would assign @x to flag no matter what
[22:57:55] Scriptonaut: I came up with an even simpler example
[22:57:57] Scriptonaut: def foo=(bar); false; end
[22:58:08] Scriptonaut: f = true # This returns true
[22:58:13] Scriptonaut: foo = true **
[22:58:34] Scriptonaut: even though the method :foo= just returns false
[22:59:48] Scriptonaut: ya, pretty much. In my actual program I'm not doing condition && foo = bar, I'm just calling super(flag)
[23:02:00] Scriptonaut: this seems like it might be related
[23:03:19] Scriptonaut: someone wrote a blog post about it
[23:15:22] Scriptonaut: I just bundled fine, I wonder if it cached the locations of my gems since they're already downloaded though.
[23:18:29] Scriptonaut: there are various rubygem servers right?
[23:18:36] Scriptonaut: I wonder if the one you usually use is down
[23:18:56] Scriptonaut: same, I mean I think there are various physical servers, depending on your location
[23:19:47] Scriptonaut: ya, I've never had rubygems go down on me
[23:19:51] Scriptonaut: but it could be
[23:20:19] Scriptonaut:
[23:20:25] Scriptonaut: did you just ping that to get it?
[23:20:44] Scriptonaut:
[23:21:20] Scriptonaut: under ANSWER SECTION I got 4 rubygems.orgs, one of them is that one you are hitting
[23:21:34] Scriptonaut: they all have the same values other than IP
[23:21:57] Scriptonaut: I'm hitting the first one on the list, the 128 one you're hitting is the 3rd one
[23:22:29] Scriptonaut: it shows me that everything is operational, I'm hitting it fine
[23:22:35] Scriptonaut: Try hitting that:
[23:22:49] Scriptonaut: oh it doesn't like it when I try to hit it by ip
[23:23:48] Scriptonaut: microservices
[23:27:45] Scriptonaut: do you have a vps or something you could test it out on
[23:27:53] Scriptonaut: some remote server you could try pulling in rubygems from
[23:28:05] Scriptonaut: ah ok, must just be your connection
[23:41:31] Scriptonaut: cthulchu: you just mean to read? You could use awesome_print
[23:41:39] Scriptonaut: that will pretty print all kinds of things
[23:41:47] Scriptonaut: what's puts_r
[23:42:02] Scriptonaut: it's a tiny gem though iirc
[23:42:09] Scriptonaut: I always put awesome_print in my dev dependencies
[23:42:27] Scriptonaut: you could also download it and then just require it as needed I think


[03:18:55] Scriptonaut: has left #ruby: ()


[20:52:20] Scriptonaut: haven't used that in a while
[20:53:34] Scriptonaut: selecting then mapping would incur a penalty because then the alg would become 2n rather than n (O)
[20:54:31] Scriptonaut: Eiam: because I'm looping over an array of object, then doing a db lookup for each one, then determining if the lookup yielded a sufficient result. If it did, then I need to return that result
[20:54:45] Scriptonaut: so I would have to calculate the result a second time once I returned teh element
[20:55:37] Scriptonaut: the lookup api can't take more than one param at a time
[20:55:49] Scriptonaut: so I can't do like Datasets::ICD10.snomedct_map([list, of, codes])
[20:55:59] Scriptonaut: I have to do it one by one
[20:56:19] Scriptonaut: lol, it's postgres, but the module was written that way
[21:15:17] Scriptonaut: ya, true, that's a decent solution, though I'd have to tack a .first on the end of it
[21:24:39] Scriptonaut: that wouldn't be a find_map would it?
[21:24:41] Scriptonaut: since each returns the whole list
[21:26:18] Scriptonaut: havenwood: that would return nil
[21:26:20] Scriptonaut: the thing you wrote
[21:26:31] Scriptonaut: oh n evermind
[21:26:36] Scriptonaut: I had no idea each worked that way
[21:26:47] Scriptonaut: I thought each always returned the original array
[21:26:52] Scriptonaut: unless the block specifies otherwise
[21:27:08] Scriptonaut: I didn't know you could pass an argument to break, that's awesome
[21:27:49] Scriptonaut: I use break all the time, but I didn't know if you passed it a value it would break from the block and return that value
[21:27:57] Scriptonaut: Does next also take a value?
[21:29:13] Scriptonaut: that's literally exactly how I solved my problem lol
[21:29:15] Scriptonaut: what your code is now
[21:29:52] Scriptonaut:
[21:30:18] Scriptonaut: havenwood: do you contribute to ruby?
[21:30:26] Scriptonaut: you were saying "we" when talking about removing features like that
[21:36:51] Scriptonaut: havenwood: nice. You mixed up the dx_code.code and dx_code.code_type in the else statement, but I like that idea better than mine (having an assignment operation inside a conditional)
[21:36:55] Scriptonaut: and ya, I shoulda used .any?