Snippet: Shuffle an Array

Posted by kev Tue, 20 Mar 2007 07:47:00 GMT

class Array
  def shuffle
    sort { rand(3) - 1 }
  end
end

arr = (1..10).to_a
# => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
arr.shuffle
# => [1, 8, 6, 10, 9, 3, 7, 2, 5, 4]
arr.shuffle
# => [3, 7, 10, 4, 5, 8, 2, 6, 9, 1]

Posted in , ,  | 7 comments

ARTS and Test::Unit get a bit cosier

Posted by kev Fri, 23 Jun 2006 14:50:00 GMT

I was able to find Nathaniel Talbot to talk about why installing ARTS makes tests run during migrations and other rake tasks and as a consequence we’ve squashed the bug.

Feel free to update your ARTS plugin. Note that the latest copy does have regex matching for content.

Posted in , ,

RailsDay Post Mortem: Advisr

Posted by kev Sun, 18 Jun 2006 03:20:00 GMT

Oh my god, it’s over.

I had an amazing time working with Damien Tanner and Ezra Zygmuntowicz. We wrote what we think is a better approach to ticket tracking and we’re calling it Advisr.

The idea is that everyone thinks their bug is important, that’s why they post it. Advisr lets people say how much a defect effects them or if they think they’d use a feature and gives advice to developers where the most important tickets really are.

Go take a look. I’m going to sleep. Good night folks, and happy Rails Day!

Posted in ,  | no comments

Want to test your RJS?

Posted by kev Sun, 28 May 2006 21:27:00 GMT

It’s coming. Check back tomorrow for the guide and information.

    assert_rjs :alert, 'Hi!'
    assert_rjs :assign, 'a', '2'
    assert_rjs :call, 'foo', 'bar', 'baz'
    assert_rjs :draggable, 'draggable_item'
    assert_rjs :drop_receiving, 'receiving_item'
    assert_rjs :hide, "post_1", "post_2", "post_3"
    assert_rjs :insert_html, :bottom, 'posts', "Here's text from insert_html"
    assert_rjs :redirect_to, :action => 'list'
    assert_rjs :remove, "post_1", "post_2", "post_3"
    assert_rjs :replace, :bottom, 'This is something to replace'
    assert_rjs :replace_html, "This is something for replace_html"
    assert_rjs :show, "post_1", "post_2", "post_3"
    assert_rjs :sortable, 'sortable_item'
    assert_rjs :toggle, "post_1", "post_2", "post_3"
    assert_rjs :visual_effect, :highlight, "posts", :duration => '1.0'

Posted in , ,

Spiders Invade Gruff Graphs

Posted by kev Wed, 29 Mar 2006 23:31:00 GMT

As part of my work at Mingle, I’ve modified Gruff to do spider graphs.

Spider graph using Gruff

And of course, like everything in Gruff, it’s fully themable.

37signals themed graph using Gruff

I’m going to get the patch to Geoff when it’s ready for release.

Posted in , ,  | no comments | no trackbacks

San Diego Ruby Users Group Revival

Posted by kev Sun, 26 Mar 2006 02:17:00 GMT

Following my Rails for Designers article, I’ve gotten several people in the San Diego area who would like to start the San Diego Ruby (and Rails!) Users Group back up. Mingle has graciously agreed to host, and we’re working out times right now. I’ll be getting access to the old mailing list soon. If you’re interested in getting information about the group, please send me an email at kevin dot clark at gmail dot com and I’ll keep you informed.

Update: I’ve got a mailing list up.

Update #2: If you want to get caught up, check out the archives here.

One more: If you want to weigh in on when the meeting should be (Wednesday or Thursday nights), mosey on over the the SDRUG Availability Poll.

Posted in , , ,  | no comments | 1 trackback

Integration Tests in Rails

Posted by kev Sat, 04 Mar 2006 22:08:00 GMT

Damien Tanner, fellow Caboose member has written an excelent intro to Integration Tests over at his blog.

It says what I’ve been trying to convince my brain to understand for the last week. It’s really worth a read, so go look. Mark integration tests up to as more thing that should be on my Rails Best Practices Doc.

Posted in ,  | no comments | no trackbacks

Using Growl for SVN Notices

Posted by kev Fri, 10 Feb 2006 05:50:00 GMT

We’re an all Mac office at Mingle, so I thought it might be nice to recieve updates to svn (commit messages and such) via Growl.

I’ve hacked together a little script to do just that. Right now I think there’s a bug in DNS-SD which keeps me from searching for people running growl, but searching for peole on iChat (on Bonjour) is fine. I’m going to test it at work tomorrow, clean up the code a bit, and you should have a screencast and code sometime this weekend if I can fix the bug with DNS-SD.

Posted in , ,  | 4 comments | 2 trackbacks

Rails Best Practices, Tips and Tricks

Posted by kev Tue, 07 Feb 2006 01:32:00 GMT

Last week I accepted a job with Mingle.com. The work is exciting (all Rails) and the team is excellent.

Because Rails is a young framework, I thought it would be helpful to write up what I consider best practices when coding with it both for my new coworkers and the web at large. Here’s my current draft. Feel free to critique and comment. I’m very open to suggestions.

Read more...

Posted in , , ,  | 17 comments | 3 trackbacks

On Mock/Stub Nomenclature

Posted by kev Wed, 18 Jan 2006 21:17:00 GMT

In the wake of my own confusion on the differences between mocks and stubbs, Martin Fowler has posted a nice summary of the differences between various types of objects used in testing.

via Robby Russell.

Posted in ,  | no comments | 1 trackback

Older posts: 1 2 3 4