mwlang

Activity Graph

Page 1 of 38 | Next »

2018-10-31

[17:01:36] mwlang: has joined #RubyOnRails
[17:03:46] mwlang: I think I’ve forgotten something subtle about ActiveRecord. Why would deleting a child record that belongs to a parent class issue a DELETE for the parent record? The child class depends on the the parent, so if parent is being destroyed, sure, delete the child, but not the other way around...
[17:04:31] mwlang: has joined #ruby
[17:29:28] mwlang: I figured it out.
[17:29:51] mwlang: I started a transaction block, deleted all the child records, then deleted the parent record at the end of that transaction block.
[17:30:23] mwlang: it’s the call to delete the parent record that’s triggering the FK constraint on the child table (whose records I’ve already deleted…)
[17:30:55] mwlang: the DBMS just isn’t seeing the record as deleted yet, so it’s the DBMS raising the FK constraint error, not AR.
[19:16:14] mwlang: broppk: 12 years later, Ruby is still my go-to language of choice and I don’t see myself giving it up any time soon. I do some Node JS, but mostly within context of a Rails project, which means React and Webpack, etc. tied into a Rails-driven backend serving the databased JSON to the JS frontends.
[19:16:40] mwlang: In short, my experience is Ruby makes for some pretty good glue.
[19:19:57] mwlang: most of the latest JS stuff is still arm’s length for me. I can usually do all the JS I need with simple jQuery widgets written in coffeescript. If I need more, I usually step up to VueJS instead of React, Webpack and all that. Only two projects are utilizing the heavier weight JS tooling.
[19:21:22] mwlang: I guess it all goes back to the RJS days of Rails and since that big ball of mud, I’ve always tried to keep external components to a bare minimum.
[20:06:01] mwlang: Quit: mwlang

2018-09-13

[00:39:54] mwlang: has joined #ruby
[03:04:27] mwlang: Ping timeout: 240 seconds

2018-08-11

[13:33:45] mwlang: has joined #RubyOnRails
[13:34:49] mwlang: How do I turn off logging ActiveJob in Rails 5? The method used in Rails 4 and everything I can google says “ActiveJob::Base.logger = Logger.new(nil)” but this is not doing the trick any more
[13:36:21] mwlang: It may be that resque is injecting the info into the log since I’m seeing… “Performing BroadcastOrderBookJob (Job ID: 168a169c-11f1-4ee6-9af7-fa13ffcf907d) from Resque(default) with arguments:” rather than ActiveJob proper?
[13:45:07] mwlang: nevermind, it turns out that placing the code in an initializer file was the trick vs. placing it in application.rb or in the environments/*.rb files.
[13:53:44] mwlang: Quit: mwlang

2018-05-31

[01:52:23] mwlang: Quit: mwlang

2018-05-30

[17:31:08] mwlang: has joined #ruby
[17:32:47] mwlang: is there a gem out there supporting .Net’s signalr websockets? I’m having trouble tracking one down.
[17:33:53] mwlang: majuk I can compile and build nokogiri gem on a 1st and 2nd edition Raspberry Pi
[17:34:18] mwlang: it may not be horse power of the arm board, but rather a lack of necessary system packages.
[17:39:00] mwlang: havenwood: You are the queen - that package indeed has a signalr client in it.
[17:46:43] mwlang: gizmore: sequel gem will let you interact with the DBMS with ruby hashes.
[17:47:29] mwlang: and with that library, it’s all symbols instead of strings.
[17:48:07] mwlang: ok, gotcha. FWIW, I prefer symbols for hash keys over strings.
[17:49:11] mwlang: I learned a lot of good Ruby tricks from the Sequel source. Definitely worth a study.
[17:49:58] mwlang: neat idea.
[17:50:15] mwlang: where do you hook the autoloader in?
[18:04:23] mwlang: I don’t know if “associative array” is correct term for a Hash. key/value mapping seems more appropriate.
[18:11:57] mwlang: havenwood: that may be it for me as well.
[18:36:06] mwlang: why switch from SipHash24 to 13? performance?
[20:02:18] mwlang: havenwood: embed #ruby irc channel in irb console!? You gotta build that! I can just see it now…an interactive Ruby shell that emits IRC messages as they come through while you’re working on something…and you can reply back with simple command => irc :ruby, “yeah, I got it.”
[20:05:37] mwlang: for any of you that are into crypto currencies and trading on exchanges, I put out a new open source gem that wraps cobinhood’s api: https://github.com/mwlang/cobinhood I’d love some feedback on how to improve this code (aside from the most obvious: writing some specs for it…)
[20:07:18] mwlang: speaking of writing specs, for open source projects that may have sensitve server exchanges, what’s the typical approach to implementing? last thing I want to do is accidentally expose my private API keys through VCR cassettes and/or other means of fixture capturing.
[20:20:35] mwlang: Good points on all, but I didn’t understand one: Frozen string literal magic comment?
[20:21:43] mwlang: Ah! That’s a new feature to me.
[20:22:14] mwlang: does it go in every file or just the primary lib/cobinhood.rb file?
[20:23:01] mwlang: what’s practically gained from freezing all the literal strings?
[20:30:35] mwlang: learnt a couple of something new today!
[20:32:07] mwlang: I’ve been using !~ and =~ for quite some time just because I like it better than reading “match?” but an performance boost is enough for me to change.
[20:32:45] mwlang: truth be told, most time lost on the actual API call/response than anywhere else.
[20:35:12] mwlang: now that I did not know!
[20:39:03] mwlang: good point. I forgot that one.
[20:42:59] mwlang: *havenwood all suggestions adopted.
[20:43:22] mwlang: thanks. how was the structuring? was it easy to follow?
[20:45:03] mwlang: on the frozen literal string magic comment, if I add that, I should remove the #freeze call, right? https://github.com/mwlang/cobinhood/blob/master/lib/cobinhood/client/rest/api_endpoints.rb#L43 for example.
[20:50:25] mwlang: havenwood: thanks for that detailed look and feedback. I definitely wasn’t expecting that and really appreciate it. I’m probably going to do a few more of these for various exchanges, esp. if the current ones out there royally suck like the cobinhood_api one did.
[20:50:57] mwlang: kucoin comes to mind. terrible implementation of a ruby wrapper on the existing gem.
[20:52:49] mwlang: one other performance idea: someone told me to switch the Faraday default adapter to Typhoeus. any opinions here on the merits of that suggestion?
[21:00:53] mwlang: hmmm…are you sure about “ ENV::[] always returns a String” ? I just tried this in IRB console: ENV["SOMETHING"] => nil
[21:04:58] mwlang: apeiros: thanks for clarifying.
[21:05:20] mwlang: I just simply did ENV[“SOMETHING”].to_s
[21:06:27] mwlang: but you know…better idea is to change where I call #to_s
[21:07:09] mwlang: if only nil.empty? => true
[21:07:40] mwlang: all I needed to know at the point of using an api_key is whether it was blank/empty or not.
[21:08:11] mwlang: *sigh* any ideas they *didn’t* bolt on?
[21:08:31] mwlang: rails is a two-edged sword, for sure.
[21:09:56] mwlang: that’s all I really need. sweet and simple.
[21:12:25] mwlang: pushed a new version with the nitpicks cleaned up. @Eiam this is where I’m using that #to_s: https://github.com/mwlang/cobinhood/blob/master/lib/cobinhood/client/rest/auth_request_middleware.rb#L10
[21:12:40] mwlang: line #6 sets it, line #10 uses it.
[21:15:10] mwlang: because there’s a public set of endpoints that do not require an api_key
[21:15:24] mwlang: if I raised it then, it would prevent using the library without an api_key
[21:15:54] mwlang: this way, error’s raised only first time an endpoint requiring the key is called.
[22:26:13] mwlang: @Jiaoyin original investor as in pre-pre ICO investor? :-o
[22:26:34] mwlang: @Jiaoyin What I produced is just Ruby API wrappers to the Cobinhood API
[22:27:02] mwlang: I needed it for algorithimic trading bots I’m building.
[22:28:47] mwlang: Ah. I’ve been a long-term “investor” from point of view of simply holding and growing COB stack simply trading the gap in the spreads on the platform.
[22:29:18] mwlang: trying to automate what I’ve been doing manually until now.
[22:29:50] mwlang: Ah. welcome to the Ruby community.
[22:30:20] mwlang: If you’re into cryptocurrencies, you may also like another open source Ruby project I have going: https://github.com/mwlang/crypto
[22:30:43] mwlang: I do. They seem to have a great team and constantly working on improving the platform.
[22:30:59] mwlang: their marketing needs help, but they’re getting better there.
[22:32:32] mwlang: they’re fun and keeps me busy.
[22:37:09] mwlang: Jiaoyin: thanks! you, too.

2018-05-04

[08:06:51] mwlang: has joined #ruby
[17:50:37] mwlang: Ping timeout: 265 seconds
[19:51:42] mwlang: has joined #ruby
[20:33:57] mwlang: Ping timeout: 264 seconds
[20:40:15] mwlang: has joined #ruby
[20:49:30] mwlang: Quit: mwlang

2018-03-26

[20:26:10] mwlang: has joined #ruby
[20:48:03] mwlang: Quit: mwlang

2018-03-17

[17:33:20] mwlang: Quit: mwlang

2018-03-16

[19:34:57] mwlang: has joined #ruby

2017-12-01

[18:05:08] mwlang: has joined #ruby
[18:05:08] mwlang: has joined #ruby-offtopic
[18:05:23] mwlang: has joined #RubyOnRails
[18:06:52] mwlang: So I’m building my first Rails 5.1 app with ActionCable subscription. I can successfully trigger a broadcast from a web browser that will eventually update back to the browser client that triggered the action (like the demo chat program).
[18:07:24] mwlang: but when I fire up rails console and submit a broadcast, it never reaches the browser client that is subscribed to the channel.
[18:08:04] mwlang: Is this because of the rails server and consoles running in separate threads?
[18:08:54] mwlang: My goal is to have a background job running every 5 ~ 10 seconds that will send a trigger a broadcast to all subscribed clients.
[18:09:51] mwlang: So a background job via ActiveJob that’s running in it’s own worker is never going to successfully trigger broadcasts to the server connected clients?
[18:11:44] mwlang: ok, one sec.
[18:18:28] mwlang: decided to open-source it…nothing proprietary in the app…need a couple minutes to get it published so I can gist some code properly.
[18:20:19] mwlang: crap, I think I just found the problem....
[18:20:42] mwlang: cable.yml has adapter: async instead of adapter: redis
[18:38:34] mwlang: hiya, baweaver - hope all’s well with you.
[18:48:14] mwlang: dminuoso: the adaptor was the problem!
[18:50:05] mwlang: isn’t that puppy open source?
[18:50:21] mwlang: Ah, it’s a snake… (just looked it up)
[18:50:33] mwlang: I don’t mess with snakes. only precious gems.
[18:55:28] mwlang: maybe one day…colloquy has been my standby for far too many years now.
[19:14:11] mwlang: Quit: mwlang
[19:16:31] mwlang: has joined #ruby
[19:16:31] mwlang: has joined #ruby-offtopic
[20:10:14] mwlang: has joined #RubyOnRails
[20:31:30] mwlang: Quit: mwlang
[21:23:33] mwlang: has joined #ruby
[21:23:33] mwlang: has joined #ruby-offtopic
[21:36:46] mwlang: Quit: mwlang
[21:44:44] mwlang: has joined #ruby
[21:44:44] mwlang: has joined #ruby-offtopic
[21:59:08] mwlang: has joined #RubyOnRails
[22:07:27] mwlang: Ping timeout: 240 seconds

2017-11-24

[17:15:54] mwlang: has joined #ruby
[17:15:54] mwlang: has joined #ruby-offtopic
[17:16:05] mwlang: has joined #RubyOnRails
[17:22:51] mwlang: Quit: mwlang

2017-09-26

[00:21:22] mwlang: Quit: mwlang

2017-09-25

[22:24:55] mwlang: has joined #ruby
[22:24:55] mwlang: has joined #ruby-offtopic
[22:25:06] mwlang: has joined #RubyOnRails
[22:25:48] mwlang: is it possible for a rails session that’s a database/activerecord store to be explicitly set by passing the session_id in on URL?
[22:26:20] mwlang: For example, we want to implement Google Docs preview functionality whereby a logged in user can view a document.
[22:27:12] mwlang: since the request for the document’s data payload is coming from docs.google.com, we need docs.google.com to “auto-login” to the user’s current session.
[22:39:56] mwlang: blindMoe: in config/application.rb, set config.active_record.default_timezone = :local
[22:40:13] mwlang: and you’ll also want to set the timezone you want while you’re at it: config.time_zone = "CET"
[22:40:18] mwlang: (for example)
[22:42:01] mwlang: I’m reasonably sure the second setting is crucial to getting the behavior you want.
[22:42:18] mwlang: albeit it’s been a while since I’ve fiddled with these settings.
[22:45:02] mwlang: ok, monkeying with UTC in the DB probably isn’t the solution you want anyway…if you have multiple timezones serviced by the app, it’s best to keep it UTC in the DBMS.
[22:46:33] mwlang: If you’re running in a cluster and the expectation is each server serves a specific timezone, then my thought would be to try setting the server’s timezone so that it’s cronjob scheduler is firing the midnight tasks at midnight local time for that server.
[22:49:26] mwlang: Greetings

2017-09-03

[01:23:11] mwlang: Quit: mwlang
[07:12:36] mwlang: has joined #ruby
[07:12:36] mwlang: has joined #ruby-offtopic
[07:23:07] mwlang: Quit: mwlang

2017-09-02

[14:48:18] mwlang: has joined #ruby
[14:48:18] mwlang: has joined #ruby-offtopic
[14:50:06] mwlang: I’m trying to use Time.at(1504227567) to get back the right value in UTC timezone. The problem is, I’m getting back that time interpreted to my local timezone. How do I cast the local time to correct UTC time?
[14:52:38] mwlang: actually, I just realized the fallacy of my reasoning…casting the local time to UTC with #utc appears to be the number I expected.
[14:53:12] mwlang: I was thinking initially that the integral value was in UTC terms to begin with.
[14:53:30] mwlang: so getting a local time out of that initially would be an incorrect result.

2017-08-15

[01:35:54] mwlang: has joined #ruby
[01:35:54] mwlang: has joined #ruby-offtopic
[01:41:22] mwlang: Quit: mwlang

2017-08-11

[00:38:21] mwlang: has joined #ruby
[00:38:21] mwlang: has joined #ruby-offtopic
[02:12:48] mwlang: Quit: mwlang
[02:23:39] mwlang: has joined #ruby
[02:23:39] mwlang: has joined #ruby-offtopic
[02:23:45] mwlang: Client Quit

2017-08-10

[14:06:34] mwlang: has joined #ruby
[14:06:34] mwlang: has joined #ruby-offtopic
[14:07:02] mwlang: has joined #RubyOnRails
[14:08:08] mwlang: For years, I have always kept database.yml in .gitignore and out of the repo, but I’m working my first Heroku hosted project since ~2008 and it seems that database.yml must be checked into repo for a successful heroku deployment.
[14:08:58] mwlang: So my question: How are others that host to Heroku handle this because what I’m finding is my team’s struggling to remember to keep their local changes out so that the production relevant version stays put in the repo.
[14:21:18] mwlang: matthewd: I think you have a point about “not needing to make local changes” we’re all connecting to postgresql, but one’s on Linux, another on macOS and another is running his posgresql server in one VM while running the rails app in another, so I guess we’ll have to go to environment variables to hold user, host, password values.
[14:40:00] mwlang: fryguy: what does that magic script look like? Am I presumely correctly it’s a bash script?
[14:44:29] mwlang: fryguy: alright, I’ll find a way to do it with bash if the client’s not open to doing ERB with environment variables in the file.
[15:16:38] mwlang: Quit: mwlang
[15:17:10] mwlang: has joined #ruby
[15:17:10] mwlang: has joined #ruby-offtopic
[15:33:41] mwlang: has joined #RubyOnRails
[16:04:58] mwlang: Quit: mwlang
[16:10:05] mwlang: has joined #ruby
[16:10:05] mwlang: has joined #ruby-offtopic
[16:10:26] mwlang: has joined #RubyOnRails
[20:31:50] mwlang: Quit: mwlang
[20:33:00] mwlang: has joined #ruby
[20:33:00] mwlang: has joined #ruby-offtopic
[20:33:08] mwlang: has joined #RubyOnRails
[21:56:07] mwlang: Quit: mwlang

2017-08-08

[02:32:11] mwlang: has joined #ruby
[02:32:11] mwlang: has joined #ruby-offtopic
[02:32:28] mwlang: Client Quit

2017-08-07

[19:10:27] mwlang: has joined #ruby
[19:10:27] mwlang: has joined #ruby-offtopic
[19:10:37] mwlang: has joined #RubyOnRails
[19:14:49] mwlang: Just implemented this change to root route definition today. Haven’t deployed to production yet. Would love a sanity check on this idea: https://gist.github.com/mwlang/1ae93907b6ebcb156fdc0db6e0de3cfa
[19:15:19] mwlang: basically, we’re getting hammered with non-HTML requests on the home page route.
[19:16:09] mwlang: Many of those are easily captured with nginx but a few are getting through still. so this is an attempt to gracefully “NO-OP” the few that do.
[21:35:22] mwlang: Quit: mwlang

2017-07-24

[13:50:58] mwlang: has joined #ruby
[13:50:58] mwlang: has joined #ruby-offtopic
[13:51:08] mwlang: has joined #RubyOnRails
[13:55:03] mwlang: I’m working on a background job (activejob) that syncs tables/data between two ActiveRecord connections. My problem: The initializer that makes the second AR connection doesn’t run so the sync job references the primary connection for both sets of AR Models. I was able to “solve it” by copying the initializer code to establish the 2nd connection to the job’s perform method, but this is awfully hacky. What’s the correct way to fire the
[13:55:04] mwlang: initializer code before the job runs? FYI, here’s the gist of the working job: https://gist.github.com/mwlang/c954dfeeaf4656847c5b43b2d86004fb
[17:57:40] mwlang: Quit: mwlang
[18:10:53] mwlang: has joined #ruby
[18:10:53] mwlang: has joined #ruby-offtopic
[18:11:14] mwlang: has joined #RubyOnRails
[18:11:50] mwlang: cagomez: put foreman in your development group of your Gemfile
[19:07:50] mwlang: Quit: mwlang
[20:55:28] mwlang: has joined #ruby
[20:55:28] mwlang: has joined #ruby-offtopic
[21:27:36] mwlang: has joined #RubyOnRails
[21:28:20] mwlang: Quit: mwlang

2017-07-21

[18:29:52] mwlang: has joined #ruby
[18:29:52] mwlang: has joined #ruby-offtopic
[18:31:02] mwlang: has joined #RubyOnRails
[18:32:47] mwlang: I have a gem that is loading a bunch of javascripts and stylesheets into rails asset pipeline. It works in Rails 5.0, but does not work in 5.1 and when I run rake assets:precompile, it’s definitely not picking up the gem’s provided assets. Any idea what specifically changed between 5.0 and 5.1 as far as correctly injecting resources into the assets pipeline?
[20:56:49] mwlang: Quit: mwlang

2017-07-19

[02:31:43] mwlang: has joined #ruby-offtopic
[02:31:44] mwlang: has joined #ruby
[03:48:13] mwlang: Quit: mwlang

2017-07-18

[16:25:08] mwlang: has joined #ruby
[16:25:08] mwlang: has joined #ruby-offtopic
[16:25:24] mwlang: has joined #RubyOnRails
[16:25:55] mwlang: I’m just curious (seeking ideas): How would you refactor this? https://gist.github.com/mwlang/09958e44a202654783e4b24348e9d754
[16:27:18] mwlang: basically, the code’s stopping a delete of a party record if it’s referenced in a number of different scenarios (read: tables)
[16:34:49] mwlang: _moep_: review contents of unicorn-5.3.0/gem_make.out to see what specifically failed
[16:36:21] mwlang: on second thought, re-reading the error chain, if I had to guess, you’re using bundle exec and the unicorn gem isn’t listed there.
[16:36:36] mwlang: “there” meaning the project’s Gemfile
[16:38:24] mwlang: _moep_: what’s the output of: bundle list | grep unicorn
[16:39:47] mwlang: _moep_: yet, “bundle install” worked previously?
[16:53:32] mwlang: _moep_: no. bundle install does it for you
[16:54:15] mwlang: greengriminal: try: spring stop
[16:54:24] mwlang: then try tests again.
[16:55:12] mwlang: not sure if that’s your issue or not, but frequently when test or development start behaving differently from each other, spring is the culprit for me.
[22:48:16] mwlang: Quit: mwlang

2017-07-06

[11:56:46] mwlang: has joined #ruby
[11:56:46] mwlang: has joined #ruby-offtopic
[12:16:27] mwlang: has joined #RubyOnRails
[12:17:12] mwlang: stormbytes: also, %w(foo bar baz).include?(x)
[12:20:14] mwlang: when exactly does Rails assign an ID to a session when using database store? Or better, yet, which gem is session implemented in so I can go through the source…trying to track down a weird bug where user sessions seem to get swapped and I think it has to do with a bad session setup sequence in my app controller in which sessions don’t quite behave the way I think they do.
[12:32:40] mwlang: stormbytes: if you’re doing Rails development, check out coffeescript
[12:41:48] mwlang: dminuoso: yeah, I think I figured it out. You have to actually set something on the session (i.e. session[:last_visited] = Time.now) before a unique session.id is generated.
[12:44:45] mwlang: yeah. I need to talk to the client about this one…the original app injects an intermediate UserSession object that attempts to link user_id to session_id, but it’s generating gobs of basically empty records.
[12:45:19] mwlang: I personally don’t see any benefit to this approach at all.
[13:47:13] mwlang: Quit: mwlang
[13:47:40] mwlang: has joined #ruby
[13:47:40] mwlang: has joined #ruby-offtopic
[14:20:29] mwlang: Quit: mwlang

2017-07-04

[15:29:10] mwlang: the original was built back in 2007, so I can’t say I’m too surprised to see “old school” thinking colliding with how AR was intended to work.
[16:14:32] mwlang: Quit: mwlang
[16:16:12] mwlang: has joined #ruby
[16:16:12] mwlang: has joined #ruby-offtopic
[16:16:24] mwlang: has joined #RubyOnRails
[16:45:31] mwlang: Quit: mwlang
[16:46:03] mwlang: has joined #ruby
[16:46:03] mwlang: has joined #ruby-offtopic
[20:38:58] mwlang: Quit: mwlang