#ruby - 26 March 2018
« Back 1 day Forward 1 day »
[00:03:43] crankharder: how can I debug a ruby process (rails console - idle. not doing anything.) that pegs my CPU? i've done this in the past by systematically removing huge chunks of the app, and gems/initializers/etc, but I would think there might be a better way to introspect what is happening in the process that is causing all this CPU usage.
[00:23:17] mozzarella: crankharder: https://ruby-doc.org/stdlib-2.5.0/libdoc/profiler/rdoc/Profiler__.html
[08:16:51] Bish: dminuoso: i tought my colleages functional programming with success, and now i have to read code like this
[08:16:54] Bish: let allData = [...(new Set(data.map(o => o.values.map(v => v)).reduce((a, cur) => a.concat(cur),)))].sort((v1, v2) => v1-v2)
[17:59:11] cagomez: I'm creating a subclass of an ActiveRecord model at runtime. is there a massive amount of overhead in doing this? My subclass just defines a new method, which I then call
[18:01:19] yxhuvud: Dunno about overhead, but be certain to give it a name and not have it be anonymous.
[18:02:27] balo: cagomez: depends. do you create it once per request or once per boot? what do you think about profiling and measuring it? maybe it has overhead for you but if you have slower db queries maybe it's insignificant...
[18:03:09] balo: although it can also have some cognitive overhead for the next person who reads the code. i am sure i would ask it: why is this happening? :D
[18:03:54] balo: and before you think you write a long comment to explain it... how could you make it more explicit what and why is it happening what you call?
[18:04:00] cagomez: yxhuvud: this is what I have going on. as you can see, I have a circular reference if I don't use `::Fruit` https://hastebin.com/buzeyusuvu.rb
[18:10:32] phaul: cagomez: I'm confused by your code but it might be me. 1. why can't you use inherit with ::Fruit ie class Fruit < :: Fruit? That's not circular dependency?
[18:11:12] phaul: 2. how is Class.new different run time than class keyword? they are defined together so they run together?
[18:11:27] cagomez: phaul: you're right to be confused. this whole ordeal turns out to be unnecessaru
[19:35:14] newbie|2: Hi, I would like to let users enter a regex and then my bot looking in the log to see if it match something, I know this is vulnerable to malicious regex that take years to complete and other thing, but is there a way, for example, to limit the maximum time it take to 5 seconds and if it take more, cancel the operation? is there a lib for that?
[20:37:00] conceivably: It compares them by character codes!? When is that ever the intended result?
[20:47:47] cjohnson: newbie|2: Just make sure you use a tool to properly escape $REGEX as a command line argument
[20:48:01] cjohnson: Don't just concat user input there or they will be able to run arbitrary commands haha
[20:55:35] mrpdd: what's the fastest way to get the intersection of 2 arrays? I feel like ary1 & ary2 is not performing well (ruby 1.9.3)
[20:57:11] cjohnson: mrpdd: Don't micro-optimize, if you are having performance problems in your app, profile the entire thing and then optimize by starting with teh biggest time wasters and work your way down
[21:13:40] mrpdd: cjohnson: thanks. I'm just breaking my brain here with these arrays (they're pretty big) - newrelic tells me like 20% of the time is spent there.
[21:27:06] Bobi: do i need to instal IRC “client” on my computer for successfully using this chat system?
[21:28:07] havenwood: Bobi: Most people use a standalone irc client. Some use a terminal or web browser based client.
[21:30:39] Bobi: i dont know i read somewhere that i need to install irc client on Windows if i want to get onto the real-time IRC channels here
[21:31:19] havenwood: Bobi: This is a real-time channel. How are you currently connected? A browser client if fine but most folk who hang out here much go with a real irc client.
[22:26:44] zenspider: anyone know if you can block an IP address on heroku? or some other form of mitigation? I’m running out of free dynos on our website and it looks like someone on comcastbusiness is pinging our slack app constantly
[22:36:58] havenwood: zenspider: I've seen a buildpack for whitelisting ips. It seems there should be one for blacklisting them.
[22:40:46] seydar: havenwood: thank you! both of those work for processing in-person cards as well, right?
[22:42:37] seydar: for some reason i thought if i used square, i *had* to use their database system as well
[22:45:11] havenwood: seydar: Nope, you can do card transactions only if you like. You don't *have to* use any of the other services.
[22:48:00] eam: in like 2003 I wrote a cpanel replacement in ruby using cgi.rb (before rails!!) for a small shared webhosting company and that company failed ultimately because all the card processing services were too much of a PITA to work with
[22:53:29] havenwood: zenspider: Looks like this dated middleware has a fairly simple strategy: https://github.com/mje113/rack-ip_filter/blob/master/lib/rack/ip_filter.rb#L27-L31
[22:55:57] zenspider: havenwood: not sure that'll help, given that it requires the dyno to run to do.
[22:56:13] zenspider: it's a nodejs app (slackin for allowing our members to sign up to slack automatically)
[22:56:38] miah: ive always been a fan of runit because its super simple and you can install it into existing systems. systemd is solid too though.
[22:57:41] havenwood: zenspider: It's kinda odd there are a couple whitelist buildpacks but neither does blacklist...
[23:00:52] havenwood: seydar: Ruby 2.6.0-preview1 is out and it has a JIT! Welcome to the future. :-)
[23:01:45] seydar: i'm not used to seeing TWO version whose second digit is odd. 2.4.3 is the current stable, i take it?
[23:04:12] havenwood: seydar: Yeah, semi-semantic versioning now--just always released on Christmas. No more patch versions.
[23:04:49] havenwood: seydar: They changed the way versioning is done with Ruby 2.1+: https://www.ruby-lang.org/en/news/2013/12/21/ruby-version-policy-changes-with-2-1-0/
[23:05:17] havenwood: seydar: 2.5 is latest. 2.4 is fully supported. 2.3 is in maintenance mode. 2.2 is past end of life.
[23:08:32] seydar: okay, i think i follow. everyone is encouraged to use 2.5 (or 2.6 for the bold), 2.4 is just there because it once was, and we begrudgingly support 2.3
[23:10:22] seydar: and the major VMs are YARV, rbx, jruby, and i guess mruby exists and is available
[23:13:02] lupine: I tried to support it ages ago, but it had too many differences to YARV - and even jruby
[23:13:44] zenspider: rbx is insane at this point. so you'd think it'd be in good company... but no. it's poison
[23:15:29] seydar: also according to the website, rbx has now shifted to being a platform for building languages? i gotta catch up with brixen
[23:28:28] ramfjord: I still use rvm for dev occasionally, but mostly I just used docker compose and the ruby-X or managed images with ruby installed
[23:37:28] zenspider: docker is a whole other beast. it's like the opposite of homebrew+rvm. everything is installed into separate virtualized containers. I wouldn't go that route for normal coding, personally
[23:54:31] seydar: i have angered the rvm gods. i want to install 2.6 (or at least 2.5), but rvm isn't listing it as an option: http://lpaste.net/4809775914483187712