Archive for Languages

RailsconfEurope 2007

I’m a little late in mentioning this, but I recently spoke at RailsconfEurope about Rails Refactoring. It was a tutorial talk, and I thought that it went very well. I think the presentation is up on O’Reilly somewhere; I’ll link if I can find it.

Overall, the conference was really good. Berlin is an amazing city and the majority of the talks were really good. Of special note were the ones by Dr. Nic, Topfunky, and Evan Phoenix. Their talks about ruby magic, css generation, and rubinius were really well done.

Comments

GoRuCo

The speaker list has been announced for Gotham Ruby Conference (GoRuCo), and I’m happy to inform you that I’m one of the speakers. I’ll be filling your brains with all sorts of information related to context, mocks, and stubs. The rest of the lineup is very strong; this looks like it will be an awesome conference.

Comments

Nyc.rb turns 3!

Well, last Tuesday nyc.rb turned three years old. Of course, we were not content with just turning three, so we decided to start taping our presentations also (By we, I mean me, because I have a video camera and turned it on). Francis gave a testing clinic, while yours truly gave a talk on refactoring. Both talks are available on Motionbox (the Rails video site at which I work) at this playlist.

To make things easier for you, I’ve also embeded the videos after the jump. Francis’s video is first with mine second. Sorry for the occasional fuzzy video quality, I’m still not good at filming presentations.

Read the rest of this entry »

Comments

CRUD Presentation

The slides from my CRUD Presentation to nyc.rb are now up. Lee Nussbaum snagged the audio, so I’ll sync that up over the next few days and post that too. If you’ve seen DHH’s presentation, this one is pretty much the same thing. In fact, many of the slides look fairly similar. I hope you don’t mind, DHH :-).

Comments (4)

Use Session Sparingly (or The Benefits of Flash)

As tempting as it is to use it for everything, the rails session should be used sparingly. In reading through the code for my current project, I noticed that we are using the session for storing return urls and query strings when doing login redirects. This is bad.

Read the rest of this entry »

Comments

Ruby Reminder: Array Subtraction

Just a reminder when working with arrays of objects generated with Active Record.

[Model.find(1), Model.find(2), Model.find(3)] -
  [Model.find(1)] != [Model.find(2), Model.find(3)]

This does not behave as you would expect, because array subtraction compares elements on their object ids. Each find generates a new object, with a new id, so subtraction does not work. To get the behavior desired, do this instead:

to_be_removed = [Model.find(1)].map{|m| m.id}
[Model.find(1), Model.find(2), Model.find(3)].
  delete_if{|m| to_be_removed.include?(m.id)}

It’s not as beautiful, but it gets the job done.

Comments (1)

Picks and Keyboards

I read an article a few years ago, I believe in Guitar World, written by famed Phish guitarist Trey Anastasio. In it, he explained that one of the keys to being great at guitar is to know how to get to ‘C’ from any other note on the fretboard. Once this is known, he explains, this knowledge can be transferred to every other key.

So what does this have to do with programming? A lot I believe. Read the rest of this entry »

Comments

Ruby Makes It Easy

Oh ruby, you make my job so simple. I need a class method you’re lacking, and you just let me add it to you.

class Array
  def map_with_index(procedure=null)
    result = []
    if block_given?
      each_with_index {|item, i| result[i] = yield(item, i) }
    elsif procedure
      each_with_index {|item, i| result[i] = procedure.call(item, i) }
    else
      result = self
    end
    return result
  end
  alias :collect_with_index :map_with_index
end

[1, 2, 3, 4].map_with_index {|elem, i| elem + i } => [1, 3, 5, 7]

See how easy that was?

Comments

« Previous entries Next Page » Next Page »