Integer.returns_many lets you return 7.somethings

In my last post I mentioned my love of all things ActiveSupport. I’m particularly fond of how it modifies the core Integer class to easily convert between units of time:

Time.now + 7.days
=> Thu Aug 23 04:05:54 UTC 2007

Time.now – 1.month
=> Tue Jul 17 04:06:12 UTC 2007

Recap: ActiveSupport is a Rails library that modifies core Ruby classes with handy utility methods like the ones above.

Anyways, I love this syntax, and began wondering how it could be re-applied to other objects. My first idea – what about retuning an arbitrary number of objects, of any class? Wouldn’t it be neat to return 7.somethings?

It turns out you can do just that.

ActiveSupport for PHP - Ruby style

One of the things I miss most from Rails is ActiveSupport, the module that modifies Ruby’s core classes (numbers, strings, more) with handy utility methods. They tie so well into the language, most Rails developers don’t realize they aren’t core methods.

Here’s a few examples:

>> 'hello_world'.camelize
=> 'HelloWorld'

>> 7.days.ago
=> Sun Aug 05 20:53:12 -0400 2007

>> 'purple people eater'.ends_with?('eater')
=> true

Is it possible to port this left-to-right style of coding to PHP?

Blog redesign (So long Reddish)

As you may have noticed, my blog’s gone through a bit of a renovation. I thought it was time to put Reddish to rest. It’s being used by way too many blogs these days (100+ by my count), and I felt it’s worth having my own unique look and feel on the web.

A couple of key improvements I think are worth discussing:

Less contrast. Softer colours, and easier on the eyes.

Large font size. Monitors are getting bigger and bigger. Forget about the 800 vs 1024 resolution debate – what about moving beyond 12 point fonts?

Tabs that work. The navigation links (“blog” / “projects” / “about”) on my last design didn’t properly promote a tabbed effect. This time, it’s abundantly clear what the links do, and which tab is active.

Boring stuff down below. I don’t want to bombard visitors with content 95% of them will never look at. Blogroll, archives – they’re down below the active article.

What do you think?