Uncategorized

Processing with Squirrelfish

SquirrelFish MascotIf you’re looking for some worthy code to run under your shiny new fast JavaScript register-based bytecode interpreter you might want to go play processing.js. Smoove.

Uncategorized

Comments (0)

Permalink

Logging From Your Rails Models

I just spent five minutes figuring out how to log from a model class in Rails (or any class that isn’t a controller or view). Y’see, there is no “logger” method on an ActiveRecord for instance.  Once again Robby to the rescue with an oblique mention of the RAILS_DEFAULT_LOGGER global. I love that guy.

Related: I wonder what Jamis circa ‘05 was talking about when he said:

Note: logging is a bad example here, because Rails already has very good support for logging. Furthermore, recent Rails releases support a service keyword, for declaring and using system-global services in the same manner described here.

Huh? Service keyword?

Uncategorized

Comments (1)

Permalink

Ruby Symbol#to_proc — Don’t Forget It!

This is your code:

puts %w{A B}.collect{|e| e.downcase}.inspect

This is my cooler code:

puts %w{A B}.collect( &:downcase).inspect

This is how the Ruby Extension Project makes it work:

class Symbol
  def to_proc
    proc { |obj, *args| obj.send(self, *args) }
  end
end

This is the explanation.

This is the love (see day 38).

Don’t ever forget this.

Uncategorized

Comments (0)

Permalink