Articles

Uniq for Array or Hash with a Deeply Nested Structure

Most people have had some experience with ruby’s built in #uniq method for Arrays. Internally, this method finds the unique items in the array by creating a hash internally, and this internal comparison is done with the #eql? method. If an item in the array is a Hash, then #eql? simply uses the object_id, generated by the #hash method, to determine whether it is equal to another object in the array. There are many solutions online each with s light variations and goals.

reboot

My blog had been running on an ancient web host account for years without incident, when one day, my mongrels collapsed. However, I was extremely busy, and even a little apathetic towards the site. The holiday break gave me a chance to move it the content over to a modern install of Mephisto. If you’re actually visiting the site, you’ll notice I even barreled through a new CSS setup with Blueprint as my wingman. However, I’m still missing some things:

is LOST on yet?

I needed to know, so I wrote one of those trendy single page apps: is LOST on yet?. Naturally, the source is on github. It’s really pretty amazing actually:

def is_lost_on_yet?
  @is_lost_on_yet ||= {:answer => "no", :reason => "returns on Jan 21st, 9PM ET"}
end

I have about 20 days to finish the site :)

Update: I forgot to mention, it even has JSON support!

Blog focus

I'm going to change the focus of this blog. Not that it ever really had much focus before, but it was called 'Rails Tales' and my plan was to talk about developing applications with Ruby on Rails. But lately, at Entertonement (where I'm a web developer), I've been more interested on understanding our users and decreasing bounce rate. This has revealed some interesting things that I want to

Integrating Mint and Mephisto

John Nunemaker, top ruby blogger of 2008, just posted about RailsTips.org’s awesomely expanded footer. If you click through to the full post, you’ll see his custom plugin pulling the most popular articles from his Mint stats.

Welcome to the New Site

I’ve maintained a blog since sometime in May of 2005. As with many blogs, posting regularity varied. Sometimes it was daily, sometimes a month or two would go by with nothing new at all.

This is something different.

The content on the old site changed over time, just like it’s author. Interests come and go, technologies that were once shiny and new have lost some of their shine. I stopped writing short posts that were mostly links to other people’s content, and starting writing longer articles. I did some interviews, and a bunch of book reviews.

Refreshed, realigned and ready for 2009

It was over 2.5 years ago I did anything major to toolmantim.com. For the last 2.4 years I’ve wanted to redesign it and the past 1.5 years I’ve wanted to re-code it.

Wrapping a Method in Ruby

Let’s say you have a Ruby class with a method you’d like to wrap—for debugging or performance timing—and, since you don’t control where the class is instantiated (think overriding a method in Rails’ ActionPack), just creating a subclass and using super isn’t going to work.

Let’s take a look at two mixin patterns; one a ubiquitous naming hack and one a bit of esoteric Ruby inheritance trickery.

First, let’s set the scene. Let’s say we have a method, Widget#render_on:

router plugin released, hacking, and magic

Today I (finally) released my Rails router implementation as a plugin named krauter (all apologies to any German citizen who may be offended!  I didn't mean to be a racis– er...nationalist?).   Take a look at the code over at my Github account: http://github.com/jeremymcanally/krauter

I'm also hacking on a few other projects you should be looking for soon if you're interested...

Rspec domination

Wycats is pushing this poll everywhere. As of Jan 02, RSpec is dominating at 53%

Wonder if this means anything for the future of the Rails default test framework…?

Mepisto to WordPress Converter | Rails Fire

Mepisto to WordPress Converter

As a recent experiment, I tried converting a blog from Mephisto to WordPress. After some quick Googling, I found out that Jason Gill had already largely solved the problem.

Unfortunately, his solution didn’t completely work for me because I didn’t want to launch Mephisto to do it and I have an aversion with that much code in a controller. Even if it’s just going to be run once. Even if it’s just locally. I know, I have a problem. Anyway, I wanted to launch it from the command line also.

I had been planning to move the Rails Envy blog to a different server and saw this as a good opportunity. The plan was to migrate the blog offline and put it on a separate subdomain (something like omgbeta.railsenvy.com). Once everything is totally working, I’d just point the main dns over. This is a fairly good strategy regardless of the application (blog, app, etc). First, though, I had to get that script working. Here’s what I came up with:

Post to Twitter Post to Delicious Delicious Post to Digg Digg This Post Post to Facebook Facebook Post to Reddit Reddit This Post

No related posts.

Images: