greenhat

Activity Graph

Page 1 of 1

2017-05-05

[15:00:32] greenhat: Ping timeout: 260 seconds

2017-05-02

[14:46:33] greenhat: Ping timeout: 264 seconds
[14:49:22] greenhat: has joined #ruby
[14:49:22] greenhat: has joined #RubyOnRails

2017-03-29

[02:32:50] greenhat: Ping timeout: 268 seconds
[02:35:20] greenhat: has joined #ruby
[02:35:20] greenhat: has joined #RubyOnRails

2017-03-24

[18:02:49] greenhat: has joined #ruby
[18:02:49] greenhat: has joined #RubyOnRails

2016-04-21

[17:19:15] greenhat: *.net *.split

2016-04-18

[15:43:22] greenhat: Ping timeout: 260 seconds
[15:44:43] greenhat: has joined #RubyOnRails
[15:44:44] greenhat: has joined #ruby

2016-04-15

[05:27:28] greenhat: Ping timeout: 264 seconds
[05:33:02] greenhat: has joined #ruby
[05:33:02] greenhat: has joined #RubyOnRails
[20:17:22] greenhat: Ping timeout: 260 seconds
[20:24:17] greenhat: has joined #ruby
[20:24:17] greenhat: has joined #RubyOnRails

2016-04-13

[11:41:31] greenhat: has joined #ruby
[11:41:31] greenhat: has joined #RubyOnRails
[20:47:12] greenhat: *.net *.split

2016-03-11

[03:30:12] greenhat: Ping timeout: 260 seconds

2016-03-10

[19:04:40] greenhat: drale2k: I generally prefer to save the user input unmodified and sanitize/linkify/etc at display time.
[19:06:16] greenhat: drale2k: That gives you a log more flexibility going forward. Perhaps one day you want to export the raw data, or change your linkifier, etc.

2016-03-09

[00:49:57] greenhat: apt-get install sqlserver
[02:36:35] greenhat: Take a look at the spec DSL included with minitest. It is my personal preference.
[02:37:56] greenhat: If nothing else the comments are worth reading for lulz https://github.com/seattlerb/minitest/blob/master/lib/minitest/spec.rb
[02:45:05] greenhat: Anyway, that's what I use.

2016-03-08

[17:14:50] greenhat: has joined #ruby
[17:14:50] greenhat: has joined #RubyOnRails
[20:15:07] greenhat: siaw: after_create will run after the object is saved to the database, so the capitalization is not persisted.
[20:15:18] greenhat: siaw: Try using before_create
[20:22:36] greenhat: You need to assign the results of the capitalization back to name.
[20:34:44] greenhat: siaw: That isn't possible with those methods.

2016-03-03

[03:26:31] greenhat: Ping timeout: 260 seconds

2016-02-28

[17:47:21] greenhat: renegadeandy: If you require 'open-uri' then you can open a URL just like a file. So I bet you could do self.photo = open(url).
[17:57:27] greenhat: renegadeandy: are you saving your object after setting photo?
[18:04:23] greenhat: Just reading your SO question. I don't think you want to use paperclip in the case of the default image. It would download and store multiple copies of the default image.
[18:09:25] greenhat: Yeah. Just what I was typing - I would just store the photo url in a separate `canned_url` attribute, and have a method like `def photo_url; canned_url || photo.url; end`
[18:10:22] greenhat: That hides the implementation behind a method - rather than exposing the implementation via event.photo.url.
[18:10:38] greenhat: Law of demeter FTW.
[18:27:08] greenhat: flip_digits: I've never heard of a book specifically on consuming apis. General programming and architecture books help.
[18:28:00] greenhat: flip_digits: Typically in a rails app you want to call 3rd party services in a background job - so you would use one of these https://www.ruby-toolbox.com/categories/Background_Jobs
[18:28:36] greenhat: You would handle the entire request/response in the background job including error handling.
[18:40:51] greenhat: flip_digits: It depends entirely on the api and they error and the usecase.
[18:41:32] greenhat: flip_digits: Maybe you email the user about the error (credit card declined). Maybe you just retry every 10 minutes, etc.

2016-02-27

[21:36:30] greenhat: Ping timeout: 268 seconds
[22:53:56] greenhat: has joined #ruby
[22:53:56] greenhat: has joined #RubyOnRails
[23:04:58] greenhat: Ping timeout: 276 seconds
[23:05:00] greenhat: has joined #RubyOnRails
[23:05:01] greenhat: has joined #ruby

2016-02-19

[16:47:01] greenhat: What does your params hash look like?
[16:47:35] greenhat: I'm guessing you want something like params.require(:email).permit(:to, :from, :template, :content)
[16:49:57] greenhat: Given that you aren't using mass assignment in that code I don't think strong params buys you much anyway.
[16:52:37] greenhat: https://rurounijones.github.io/blog/2009/03/17/how-to-ask-for-help-on-irc/

2016-02-17

[09:52:54] greenhat: has joined #ruby
[09:52:54] greenhat: has joined #RubyOnRails

2016-02-02

[19:12:04] greenhat: *.net *.split

2016-01-31

[12:25:06] greenhat: *.net *.split
[12:29:42] greenhat: has joined #RubyOnRails
[12:29:44] greenhat: has joined #ruby

2016-01-29

[21:03:18] greenhat: TIL the hard way if you call two different controller actions in a controller test any ivars set in the first action are still set in the second action.
[21:03:42] greenhat: Apparently a new controller instance isn't used for each action. Doh.

2016-01-27

[20:37:28] greenhat: ror15: Did you mix in the factory_girl methods? https://github.com/thoughtbot/factory_girl/blob/master/GETTING_STARTED.md#configure-your-test-suite
[20:43:08] greenhat: ror15: Also, hardcoding counts (where you expect Contact.count) to equal 1 will eventually bite you. You just just check that Contact.count has gone up by one.
[20:43:34] greenhat: With minitest you would use assert_difference. I don't know the rspec equivalent.
[23:24:27] greenhat: Huh. As a consultant I've never seen good rails code.
[23:24:39] greenhat: Of course nobody calls a consultant when things are going well.
[23:27:21] greenhat: a1fa: No doubt. But I've talked to some of them and for the most part they give me a thumbs up.

2016-01-26

[17:27:53] greenhat: I'm using standard transactional minitest tests on this rails project. Is there any callback or method I can override to write some stuff to the DB before the transaction is opened when a test runs?
[17:29:24] greenhat: I know that's basically what fixtures are, but this project is using factories, and I don't really want to use a fixture just for this case.
[17:32:17] greenhat: Yeah. I know. The tests would run 16x faster if I only need to setup the data once.
[17:33:30] greenhat: I use pundit.
[17:34:13] greenhat: reckoner, nope. Don't really know what those are.
[17:34:54] greenhat: reckoner, Are you wondering about using pundit outside of controllers?
[17:36:11] greenhat: reckoner, You should be able to just include Pundit in any object you want, and you get the helper methods.
[17:36:58] greenhat: reckoner, Or you can just new up the policy you want - PostPolicy.new(user, post).destroy? - for example.
[17:44:27] greenhat: The pundit helper methods (#authorize, #policy) expect there to be a #current_user method available to know what user to authorize the action against.
[17:49:19] greenhat: reckoner, you can implement a `pundit_user` method that does the right thing. By default `pundit_user` just delegates to `current_user`
[17:50:44] greenhat: reckoner, No problem. I suggest reading the pundit code too. It is really lightweight and pretty easy to understand.

2016-01-20

[05:50:40] greenhat: Your `it "does not send an email"` test isn't testing an email isn't sent.

2016-01-19

[04:38:42] greenhat: I cannot grok what that's supposed to do. The code indentation is pretty wild.
[04:39:45] greenhat: Has no tests.
[07:06:08] greenhat: It depends entirely on your app, but one way to keep it simple is a bg job and a flash message like "1000 users queued for removal."
[07:08:00] greenhat: Ha. There's nothing that prevents your user from nav'ing back to the index page anyway. I wouldn't be able to sleep knowing a I wrote a synchronous request that takes 10+ seconds :)
[16:07:32] greenhat: lacrymology: Take a look at factory girl's after(:build) callbacks.
[16:16:14] greenhat: Yes, lazy attributes might work. I usually figure out factory girl through trial and error - try something, set a break point in the test and examine the data and see if it did what I want.
[16:16:32] greenhat: Lazy attrs usually work, and when they don't the callbacks can get you there.
[16:39:55] greenhat: I have used pundit on an old system that already had some cancan. Pundit is super simple and doesn't interfere.
[17:07:46] greenhat: I use polymorphic belongs_to and have one table for images. Works pretty well. It does get a bit sketchy if you start having divergent business logic for different types of images.
[17:09:01] greenhat: Now we have several subclasses of Image using STI, so we have a polymorphic belongs_to to an STI images table and some crazy image factory stuff. I'm not proud.
[19:59:51] greenhat: Maybe it makes IRC really really slow.
[21:55:58] greenhat: It looks like adding methods in a rake file just adds those methods to Object, even if you declare the methods in a rake namespace.
[21:56:09] greenhat: Is that right?
[21:58:47] greenhat: Is there a suggested way to create functions in a rake file where they don't get added to the global namespace?

2016-01-17

[22:53:34] greenhat: *.net *.split
[22:58:03] greenhat: has joined #ruby
[22:58:03] greenhat: has joined #RubyOnRails

2016-01-13

[00:29:12] greenhat: Ryn each test in the scope of a transaction and the before(all) data should be clean for each test, right?
[17:02:50] greenhat: Quit: ZNC - http://znc.in
[17:13:53] greenhat: has joined #ruby
[17:13:53] greenhat: has joined #RubyOnRails

2016-01-06

[04:59:00] greenhat: I used to manually compile rubies and manually update symlinks. Then I discovered RVM and it was great. Then bundler made most of RVM unnecessary for me and I switched to chruby and ruby-build and it is great.
[04:59:32] greenhat: I hope one day native OS packages will get their act together and I won't need any ruby version managers at all, and it will be great.
[05:01:54] greenhat: Yeah. Gentoo does a fair job too. But arch and gentoo are fairly niche :)
[05:02:23] greenhat: I do use the brightbox ppa in production.
[05:02:38] greenhat: I guess I should re-phrase that to "when osx gets its act together".
[18:59:45] greenhat: Consider Heroku if that's a possibility and you don't want to learn to be a sys admin overnight :)
[19:31:04] greenhat: Review the docs for Enumerable, Array, and Hash and you are well on your way.

2015-12-29

[15:28:07] greenhat: direnv is great. ./bin is only in your path when you are in your project directory.
[15:48:01] greenhat: Victory. I think I managed to configure an entire rails app using env vars. Not that easy.
[15:48:24] greenhat: If you aren't using heroku anyway.
[15:49:08] greenhat: There appears to be no single place where you can define all the env vars. As far as I can tell. Using ubuntu servers.
[15:50:02] greenhat: Because I'm playing with docker, and the easiest way to configure docker containers is with env vars.
[15:50:46] greenhat: Currently the app is running on ubuntu servers. Would like to give docker a go.
[15:51:22] greenhat: Overall it seems like the easiest way to decouple your app from your platform.
[15:52:07] greenhat: If you have a platform that can run ruby and you can set env vars it can probably run the rails app.

2015-12-28

[19:40:06] greenhat: was seeing the same issue with rgeo-geojson - cannot install the latest but it is listed on the website

2015-12-23

[15:20:54] greenhat: has joined #RubyOnRails
[15:21:16] greenhat: has joined #ruby
[17:14:17] greenhat: jdeen: Are your presenters plain ruby objects?
[17:14:49] greenhat: jdeen: If so I suggest putting them in app/presenters, not app/views/presenters.
[17:15:50] greenhat: jdeen: Then you put your tests in spec/presenters and inherit from whatever the standard unit tests inherit from (I assume. I use minitest)

2015-01-08

[23:34:07] greenhat: Spring hangs a lot after updating to 4.1.9. Is that happening to anyone else?

2014-06-29

[01:44:13] greenhat: benlieb: Generally things that can be done in application code should be done there. Most validation for example. Some things can only be done properly on the DB though - like uniqueness checks.
[01:45:08] greenhat: So, it boils down to using the right tool for the job and most often that is the application code.
[01:54:09] greenhat: I haven't had to use them much. If you are writing an app on top of a legacy db I think they can be useful.
[01:54:54] greenhat: I've been tempted to use a view in place of a few heinous joins we've got though. Haven't tried it out yet.
[01:56:14] greenhat: There could be a significant performance advantage using a view depending on the DB being used. But so far performance of the joins isn't a problem.
[02:01:10] greenhat: benlieb: It should just treat it as any other table. Just create a model with a matching name.

2014-06-14

[19:26:08] greenhat: mozzarella: Yes, it is the same thing.

2014-04-18

[23:23:16] greenhat: Just upgraded to rails 4.1. Every time I run rake assets:precompile new files with different fingerprints are generated, but I haven't changed any files.

2013-03-08

2013-02-08

[00:52:57] greenhat: If you are copying a file so big you need a progress bar there's probably significant overhead in encrypting and decrypting the file through scp.
[00:53:09] greenhat: Would be interesting to time them and see the difference.
[00:56:33] greenhat: reppard: Ah. In that case USB is slow enough that the encryption time would be negligible.
[01:06:21] greenhat: Interesting.
[01:10:04] greenhat: The overhead depends on how fast scp can move data vs how fast the disks are.
[01:10:30] greenhat: If scp can keep the usb2 pipe full there wouldn't be much overhead. On fast disks there would be more.
[01:19:37] greenhat: My buddy just pointed me to pv http://www.cyberciti.biz/open-source/command-line-hacks/pv-command-examples/
[01:19:53] greenhat: Gives progress bars on data moving through a pipe.