Joined June 2011
·

Chip Castle

Chip Castle Dot Com, Inc.
Chip Castle Dot Com, Inc.
·
Santa Rosa Beach, FL
·
·
·

The site is now located at http://unixcasts.com.

Hey ianmusc - You might try Cygwin to get you started. Hope that helps.

Posted to Replace conditional with Null Object over 1 year ago

Really nice approach. You can clean up User#price if you do something like this:

class NoSubscription
  def charge
  end

  def price
  end
end

class User
  include ActiveModel::Model
  attr_accessor :credit_card, :subscription

  def subscription
    @subscription || NoSubscription.new
  end

  def charge
    subscription.charge(credit_card)
  end

  def price
    subscription.price
  end
end

However, I would be careful adding wrapper methods like User#charge and User#price because this tends to lead to God models, especially when working with classes like User, Order, etc.

In general though, your suggestion prevents nil checks and removes conditionals, and that's an excellent improvement!

Cool. I posted a tip similar to this in the past, with some nice suggestions by other devs: https://coderwall.com/p/o5qijw.

@carwin - Interesting. I think @mislav just posted about that at https://coderwall.com/p/uo_big. Nice tip!

@mislav - Great tip! I definitely need to check out your pair command and also gh-auth. Very cool work there. On a related note, I tried tmate this week with a co-worker and it was really easy to use for pairing as well.

Really nice work. Would you mind elaborating on why you check for 'seconds < 45' as opposed to 60?

@tdl - Agreed. I didn't know about the -c option for the uniq command, so thanks for sharing that!

Posted to My Workspace over 1 year ago

You need bigger speakers! ;-)

Posted to Rake task list in Rails over 1 year ago

@slothbear - Good suggestion, as I didn't notice that some tasks were missing. Unfortunately, that didn't work on my system, though (OS X):

☺ rake -T -A db
invalid option: -A
chip@macbook ~/code/project 1.9.3-p194 [master]
☹ rake -V      
rake, version 0.9.2.2
Posted to Non-destructive Vim piping over 1 year ago

Very nice!

I ran into this before and it took me an embarrassingly long time to figure out. This is really helpful. Nice post!

@larrywilliamson - thanks for the suggestion, since others might run into the same issue. Here's more info in case anyone is interested:
http://stackoverflow.com/questions/28881/why-doesnt-sort-sort-the-same-on-every-machine

@orangetux, Thanks! You might want to check out Drew Neil's project: https://github.com/nelstrom/vimprint

Posted to A Software Architect over 1 year ago

I couldn't have said it better. Great stuff, Chris!

Achievements
929 Karma
71,936 Total ProTip Views