Floyd’s Thoughts…

Because Everything is Interesting!!!

Archive for August, 2008

Using jQuery in Rails apps

without comments

jQuery is an alternative to the Prototype JavaScript library that is gaining some real traction these days.

jQuery is a fast, concise, JavaScript Library that simplifies how you traverse HTML documents, handle events, perform animations, and add Ajax interactions to your web pages. jQuery is designed to change the way that you write JavaScript.

jQuery also sports an elegant model of method chaining where almost all methods return an instance of the object they are called on, this means you do do stuff like:

	$("p.surprise").addClass("ohmy").show("slow");

The only problem is I love using Rails which has many helper methods that make using Ajax really easy which use the Prototype JS library, so ncluding jQuery as well as Prototype is not only a pain it also means i’m doubling the amount of javascript i ship with each page.

Fortunatly the problem has been solved via a cool rails plugin called jrails.

jrails is easy to install (script/plugin install http://ennerchi.googlecode.com/svn/trunk/plugins/jrails) and replaces all the calls to Prototype with calls to jQeury allowing you to remove prototype from your application without loosing any of the rails magic.

Written by Floyd Price

August 16th, 2008 at 11:03 pm

Productivity Tip

without comments

This is less of a tip and more a of my own metaphorical “Kit up the Back Side” that happened to me a few weeks ago.

While looking for some software to audit the applications i had on my Mac came across Slie.

Now slife doesn’t audit apps it actually monitors and records the activity of applications that you use.

What makes slife so useful is that it renders the data about your application usage in a timeline representing the day, so you get an idea of which application consumed most of your time.

slife-screenshot.png

My expectation of the slife results for a common day would be some email and browser activity in the morning followed my some hard core TextMate activity up until lunch where email, soduko and safari would be used, come the afternoon another good block of TextMate, sprinkle a bit of NetNewsWirs across the entire day and there you go, another productive day from me ;-)

Well this is all good an well but the reality is somewhat different, the results actually show that i spend much more time in mail and safari and a hell of a let less time in TextMate, for me this is a real kick up the back side! I value my time and investing so much of it in “Surfing” or “Emailing Friends” is not a good us of my valuable time.

I now run slife all the time, and review my own activity at least on day a week.

Net result : I now spend more time “working” so i can get my task done sooner… which gives me more time to surf ;-)

Written by Floyd Price

August 14th, 2008 at 11:01 pm

Posted in Agile,Coding,OS X

Estimating – I love estimating.

without comments

Estimating is one of those tasks that really takes it out of the whole team, hours or even days of reviewing stories and estimating the effort is hard work.

The temptation is to crack on and keep going until the task is done however I can’t stress enough the importance of taking time away from this process to recharge and re-engage with the subject mater.

Some techniques for making the process less onerous (if thats possible):

Story Rotation
Often teams will follow a story list as it define by the BA, which in my opinion can lead to less informed estimates, having discussed the attributes of one story only to be presented with another similar story can often lead to dismissive estimations where in isolation the story may reveal more detail.

Take Breaks
Accept that a fresh mind is better at dealing with problems, taking a break is one of the most productive things you can do.

Give everyone a stage to express their opinion
So often the dev lead will take up most of the air space while more “junior” members of a team will sit nodding (or nodding off). Give your whole team a chance to engage in this process after all you will expect them to work in this project right?

Have Fun
Enjoy the process by making it fun! Use novel gestures for estimating or high five when you all agree, whatever it is you guys do that is fun, do it and do it more often, having a laugh will make the most onerous of tasks less so.

Estimating has to be one of the tasks i “enjoy” the least however, its value is without question.

Written by Floyd Price

August 14th, 2008 at 10:45 pm

Daily Dose #3

without comments

More estimating today! Calculating velocity tomorrow… Joy!

Y Combinator’s Demo Day Summer 2008
Some y-combinator startups show of there stuff.

YUI 3 Preview
Personally i prefer ExtJS but more choice in this area is good for all.

AppStore Developer TapTapTap Publishes Sales Figures
Interesting stats from TapTapTap – Makes me think I should building IPhone apps ;-)

Written by Floyd Price

August 14th, 2008 at 9:00 pm

Something I didn’t know Yesterday #2

without comments

Rails (or should i say ActiveSupport) adds a blank? instance method to object that encapsulates the nil? || empty? check that I find myself doing all the time.

A quick review of the source show that the empty? method is added to the following:

  # An object is blank if it's nil, empty, or a whitespace string.
  # For example, "", "   ", nil, [], and {} are blank.
  #
  # This simplifies
  #   if !address.nil? && !address.empty?
  # to
  #   if !address.blank?

The full source is actually very simple (I Love Ruby)

class Object
 
  def blank?
    if respond_to?(:empty?) && respond_to?(:strip)
      empty? or strip.empty?
    elsif respond_to?(:empty?)
      empty?
    else
      !self
    end
  end
end
 
class NilClass #:nodoc:
  def blank?
    true
  end
end
 
class FalseClass #:nodoc:
  def blank?
    true
  end
end
 
class TrueClass #:nodoc:
  def blank?
    false
  end
end
 
class Array #:nodoc:
  alias_method :blank?, :empty?
end
 
class Hash #:nodoc:
  alias_method :blank?, :empty?
end
 
class String #:nodoc:
  def blank?
    empty? || strip.empty?
  end
end
 
class Numeric #:nodoc:
  def blank?
    false
  end
end

Written by Floyd Price

August 13th, 2008 at 8:46 pm

Installing Ruby Enterprise Edition on CentOS 5.2

with 2 comments

Installing Ruby 1.8.6 on CentOS is not as easy as you would hope. The YUM repositories do not have anywhere near the latest version of ruby so you are forced into installing from source, which means locating and installing many dependancies before building ruby itself.

I have found myself building ruby several times on a new CentOS box after realizing that i had missed a dependancy that was required to use rails or some other ruby component.

I was going to write up a step by step guide to installing Ruby 1.8.6, Rails, MySql, etc… on CentOS 5.2 (and i may still do this) however i have found that the guys who wrote Phusion Passenger have also build a version of Ruby that as well as having a lower memory footprint has a convenient installer that takes the pain out of building from source.

Here are my steps for installing Ruby Enterprise Edition on CentOS 5.2

* 1. ssh into CentOS using your favorite ssh client.
* 2. cd /usr/local/src
(this is where I downloaded the source to you can do this anywhere i guess)
* 3. sudo wget http://rubyforge.org/frs/download.php/41040/ruby-enterprise-1.8.6-20080810.tar.gz
(this is the latest version at the time of writing this post)
* 4. tar xzvf ruby-enterprise-1.8.6-20080810.tar.gz
* 5. sudo ./bin/ruby-enterprise-1.8.6-20080810/installer

The last step starts the convenient installer process that will build everything you need from sources.

I found that first time the script ran i didn’t have MySql or PostgreSQL development header files so i installed them using

* sudo yum install postgresql-devel.i386
* sudo um install mysql-devel.i386

After running the install script again it completed with no errors (you could have just ran the gem install again rather than installing the whole of ruby…)

The great thing about this installer is that it isolates the installation and does not touch any system files so it will not screw up any of your existing ruby installs.

We have been using Ruby Enterprise Edition on one of our projects for a few weeks now and i have to say that it works really well, and it also includes the recent security patches for ruby – sweet!

Oh don’t let the name put you off Ruby Enterprise Edition is actually Open Source – Yay ;-)

Written by Floyd Price

August 13th, 2008 at 8:04 pm

Posted in CentOS,Rails,Ruby

Daily Dose #2

without comments

Spent the best part of the day estimating development effort for an upcoming project… Yarn.

CMS Rails Kit
Ben Curtis has released a new CMS Rails Kit.

The Ruby Hoedown in 10 minutes
The guys from Rails Envy give a quick review of the Ruby Hoedown.

Ruby Visual Identity Team
Want to show the world that you love Ruby? Get a high quality Ruby image for your website.

ar-extensions 0.8.0 released!
Some handy extensions to Active Record that now work with Rails 2.1

Written by Floyd Price

August 13th, 2008 at 1:22 pm

Internet Radio on iTunes

without comments

Today I realized that I have become totally dependent on the Internet Radio support in iTunes when coding at night!

I spend a good amount of time in the office when the other guys have gone home (dedication ey?) and having a random (usually Dance Music) internet radio station blasting out from across the office creates a fantastic coding environment.

Although, I guess you do need to be the sort of person who likes to code to Music.

I’ve spent the last 4 hours listening to a station called Puls which is the sort of non stop dance music that makes you smile :-)

Try it…

Written by Floyd Price

August 12th, 2008 at 9:45 pm

Passenger (mod_rails) Preferences Pane for OS X

without comments

If like me you have started using Phusion Pasenger for development sites as well as production sites and you are fortunate to work on a Mac, you will really appreciate the Passenger Preferences Pane by Eloy Duran.

Using it, is as simple as…

Step 1 Point it at your rails folder.

Step 2 Give it a host name to use.

Step 3 LOL, there is no Step Three

Written by Floyd Price

August 12th, 2008 at 8:52 pm

Posted in OS X,Rails

Something I didn’t know Yesterday

without comments

Using the SVN client you can pass –xml to most of the commands to get a response in XML!

This is great for apps that use the SVN Client API and need to parse the response, for example…

svn log http://svn_url --xml

Will produce a nice XML version of the SVN log.

For good measure you can also use the verbose option to extract even more information…

svn log http://svn_url --xml -v

Pretty cool ey?

Written by Floyd Price

August 12th, 2008 at 8:23 pm

Get Adobe Flash playerPlugin by wpburn.com wordpress themes