Blog looks different

I finally got around to doing a redesign. It is blue.

July 17, 2010

Comments

Busy

Work has been pretty life consuming and has kept me from updating the blog recently. But since it’s the Memorial day weekend and I have some motivation to put things on the Internet, I’m going to post random pictures I’ve taken with hipstamatic. I bought hipstamatic this week after seeing my more saavy coworkers use it.

boots

It's been raining

I took this is in Montgomery station. It was raining a lot this week, which helped further justify buying rainboots.

sophy

Sophy texting

I’ve been able to spend more time with Sophy lately. We haven’t been doing a lot of knitting together though.

Hopefully I’ll get around to making the blog look different tomorrow. I think it’s time for a different layout.

May 29, 2010

Comments

Delegation

It’s been a long while since I’ve done any coding related blogging, so I thought I’d write about something I learned recently.

Delegation is one of those object-oriented programming concepts that I don’t think about as much as say, inheritance or polymorphism, but it’s a sensible thing that makes code cleaner.

Last week I found out about ActiveSupport#delegate, which can be used to delegate an object’s method to another object’s method. Here’s a simple example:

I have coworkers with severe allergies. We’re going to assume that a coworker has one severe allergy for my simple example. This seems to be true so far, no one I’ve worked with has had more than one, send them to the emergency room, allergies.

Here’s the two classes, with Coworker wanting to delegate the instance method severe_allergy_description to SevereAllergy:

class SevereAllergy < ActiveRecord::Base
  def description
    "The reaction to #{name} is #{reaction}."
  end
end

class Coworker ActiveRecord::Base
  has_one :severe_allergy

  def severe_allergy_description
    severe_allergy.description
  end
end

I’ve seen the above pattern a lot. Instead we could do this:

class Coworker ActiveRecord::Base
  has_one :severe_allergy

  delegate :description :to => :severe_allergy, :prefix => true
end

Let’s use it:

coworker = Coworker.create(:name => "CK")

coworker.create_severe_allergy(:name => "cats", :reaction => "death")
coworker.severe_allergy_description # => "The reaction to cats is death."

I’m pretty surprised I haven’t seen this used before, seeing as it’s been around since Rails 2.2.

Next up, I hope to make the blog prettier to improve my sad css skills, master javascript, familiarize myself with jQuery and make more cookies at work.

March 21, 2010

Comments

I'm Officially Employed

It took a while, but the visa issues have been taken care of and I’m happy to say that I’m working at Square. It’s been crazy busy and pretty exciting. I’ve enjoyed being able to work with a bunch of really smart people and Chris again (who is really smart as well).

I’ve been working on a real blog post as well, so that will show up soon. I’m off to bed after a long day.

March 17, 2010

Comments

More Projects

The February Lady Sweater is done and looks like this:

February Lady Sweater

See how it goes nicely with my living room wall?

I’m happy with it overall. The button holes I made were way too big, so I ended up sewing part of them closed. I think I would have made the yoke a little longer if I were to do it over again.

In an effort to use up a bunch of stashed Cascade 220, I’m attempting to knit owls. I’m knitting a size large in hopes of getting an extra small. So far, it’s a little on the big side, but I think it will fit. Otherwise, Sophy gets it in exchange for all the nice things she’s given me. :)

Half Done Owls

A sleeve and body in a pile on the floor

I started knitting a Robin’s Egg Blue hat today for a friend’s neighbor who was just diagnosed with cancer. It’s my first hat, so I’m excited to see how it works out. The hat needs to be done by the end of February, so owls is on hold until it is finished.

Unrelated to knitting, I’ve found a new job! Pretty much the best job ever. I haven’t started yet because there’s still some visa related issues that need to be settled, but I’m looking forward to working on some cool stuff, learning how to be a morning person again, doing Ruby professionally again (even though it’s been a short hiatus) and giving the Erlang book I borrowed back.

I wonder how many programmers besides me use a new job as an excuse to buy cute dresses?

January 31, 2010

Comments