When you are coding, you should try to separate out the things that change from the things that stay the same. This isn’t my idea, but it is worth tip’n here as I just saw a really good, simple example of this…

Read the rest of this entry

Fortune...

July 8th, 2008

I got his when I logged into one of my OpenBSD boxes today. Interestingly true…

Read the rest of this entry

In my previous post (Spec Behaviour not Implementation) I went on a froth roll about why you should treat controller actions as black boxes. Here I give an all to common example of why this is good and how you can write specs that won’t break at the most trivial change.

Read the rest of this entry

This has been said a lot, and doesn’t really need repeating by someone like me, but, as this is a tips page, I should put it here.

Read the rest of this entry

This tip is coming to you from a frustrated developer having to read someone else’s specs….

Read the rest of this entry

You would expect any professional to know their stuff, for a Ruby on Rails beginner, this is no less important.

Read the rest of this entry

Here is how to convert the microsoft way of storing color values (which looks like 16777215 for white) into the familiar RGB CSS style HEX values (which look like #FFFFFF) in Ruby.

1
2
3
4
5
6
7
8
def long_to_rgb_hex_string(val)
  r = "%x" % (val % 256)
  g = "%x" % ((val / 256) % 256)
  b = "%x" % ((val / 65536) % 256)
  "#" + [r,g,b].collect { |c| c.to_s.ljust(2, '0')}.to_s
end

long_to_rgb_hex_string(2093422) # => #6ef11f

Or Grant Hutchins gave this as an option from the comments:

1
2
3
def long_to_rgb_hex_string(val)
  sprintf(#%06x’, val)
end

Any other good options? :)

blogLater

Mikel

RSpec Story xhr problem

June 6th, 2008

If you are using RSpec stories (and if you are not, why not?) you might run into this little problem. doing an xhr :post returns ArgumentError: wrong number of arguments (4 for 3)

Read the rest of this entry

This tip actually applies to every open source project out there… it is, how do you ask a question that will get you the maximum chance of a good answer?

Read the rest of this entry

When you are making a rails site, you sometimes need to get to the session hash or the params hash and see just what got sent back to the browser, but going in, editing the template and reloading is just a PITA, here is a quick tip that can help you have that (and any other) information no more than a click away, at any time, and any view….

Read the rest of this entry

Even though they got my name wrong :) Gregg Poolak and Jason Seinfield have a fantastic podcast that you all should subscribe to.

Read the rest of this entry

When I was learning Ruby on Rails, this site by Raaum was a god send.

Read the rest of this entry

Ruby is a really dynamic language, and you can do a lot of cool things, one of them is a Struct (Structure) that allows you to make throw away objects that you can call methods on….

Read the rest of this entry

If you are using BE DE DE or TE DE DE, then you will get situations in your specs or tests where you want to be able to just create a valid model of another type to test against. This is where factories and builders come in handy.

Read the rest of this entry

If you use Rails, you sometimes get a situation where the custom error messages just don’t work, here is how you can fix it…

Read the rest of this entry