POSSCon: Palmetto Open Source Software Conference

I'll be speaking at the new South Carolina OSS conference in Columbia, SC on July 30th -- more details at their website. I plan to talk about the open-source technologies that we use at the SC Budget and Control Board -- mostly Ruby on Rails and mySQL. I'm pretty excited about the conference as its the first of its kind here in Columbia. Should be worth coming to check it out -- oh, and did I mention its free to attend? See you guys there!

Posted by Jason Dew Fri, 11 Jul 2008 23:02:00 GMT


ActiveRecord Bug Squashed

So we decided to use the new dirty record feature of Edge Rails to record the history of records in our new app at work. Turns out that nullable integer fields are always dirty if their current value is NULL. So, I submitted a patch and I'm honored to report that it was accepted and committed into Rails. Its nice to be able to give back to the community.

Posted by Jason Dew Tue, 20 May 2008 22:31:00 GMT


learnSTAT is now open source

I've been teaching a Statistics course at USC for a few years now and so, being the geek that I am, I decided a couple of semesters ago to write some course management software in Rails. I've worked on it on and off since then and I would consider it to be in a semi-usable state at this point. I've used it in my last two semesters without major problems.

The features at this point are

  • course announcements
  • course documents
  • ability to assign multiple choice quizzes
  • quiz statistics, including per question
  • ability to add exam grades

The source is available at git://github.com/jasondew/learnstat.git

Please send any bug reports or feature requests to jason.dew at gmail.

Posted by Jason Dew Sat, 15 Mar 2008 23:15:00 GMT


Calculating IRR

So I decided to give the latest Ruby Quiz a shot. I created an `Algebra` module to deal with finding the root of a function -- using Newton's method.
module Algebra

  class MaximumIterationsReached < Exception
  end

  class NewtonsMethod

    def self.calculate(function, x)
      x - function.evaluated_at(x) / function.derivative_at(x)
    end

  end

  class NewtonsDifferenceQuotient

    def self.calculate(function, x, delta=0.1)
      (function.evaluated_at(x + delta) - function.evaluated_at(x) ).to_f / delta
    end

  end

  class Function

    attr_accessor :differentiation_method, :root_method, :maximum_iterations, :tolerance

    def initialize(differentiation_method=NewtonsDifferenceQuotient, root_method=NewtonsMethod, &block)
      @definition = block
      @differentiation_method, @root_method = differentiation_method, root_method
      @maximum_iterations = 1000
      @tolerance = 0.0001
    end

    def evaluated_at(x)
      @definition.call(x)
    end

    def derivative_at(x)
      differentiation_method.calculate(self, x)
    end

    def zero(initial_value=0)
      recursive_zero(initial_value, 1)
    end

    private

    def recursive_zero(guess, iteration)
      raise MaximumIterationsReached if iteration >= @maximum_iterations

      better_guess = @root_method.calculate(self, guess)

      if (better_guess - guess).abs <= @tolerance
        better_guess
      else
        recursive_zero(better_guess, iteration + 1)
      end
    end

  end

end
and here is the more specific code to calculate the IRR:
require 'algebra'

class IRR

  def self.calculate(profits)
    begin
      function(profits).zero
    rescue Algebra::MaximumIterationsReached => mir
      nil
    end
  end

  private

  def self.function(profits)
    Algebra::Function.new do |x|
      sumands = Array.new
      profits.each_with_index {|profit, index| sumands << profit.to_f / (1 + x) ** index }
      sumands.inject(0) {|sum, sumand| sum + sumand }
    end
  end

end

puts IRR.calculate([-100, 30, 35, 40, 45])
puts IRR.calculate([-1, 1])
puts IRR.calculate([])

Posted by Jason Dew Mon, 11 Feb 2008 18:25:00 GMT


Ruby and Rails Talk

I gave this talk at the Columbia Linux Users Group meeting last night. Thought I would post it here in case anyone wanted to have a look at it.

Rails Talk

Posted by Jason Dew Fri, 14 Dec 2007 23:29:00 GMT


My new favorite website

I know its geeky, but I love it. Its great practice –

refactormycode.com

The general idea is: people post code that they think could be written better and then other people refactor it and get rated on it. How cool!

Posted by Jason Dew Thu, 08 Nov 2007 02:32:00 GMT


Cowboys and Farmers

I can't take credit for this idea and I can't remember the blog post where I read it... but the idea goes something like this: most development groups have cowboys and farmers.

Cowboys live on the bleeding edge of technology and, therefore, tend to bleed at times (normally in the form of overtime). Of course, with risk comes reward. In software development this is increased productivity, more robust products, and programmer happiness.

Farmers, on the other hand, represent stability. They are willing to use the same tools, year after year, and normally produce steady results. They are the risk averse -- willing to do twice the amount of work with a tool that is comfortable rather than try a tool that is more specialized and/or capable.

Obviously, we need some sort of a balance between the cowboys and the farmers. Too much of either type is a recipe for destruction. However, I'm certainly a cowboy. I love learning new tools, especially when they get the job done better than the old tool.

Posted by Jason Dew Sun, 04 Nov 2007 23:25:00 GMT


Common Beginnings

Its funny what a hobby can turn into. Listening to Matz at RubyConf 07 made me reminisce about how I got started programming. He was asked "do you consider yourself to be a scientist or an artist?" to which Matz responded: "a hobbyist." Ruby was just a hobby to him, something he found to be fun and fulfilling. Its kind of the same way I made it into full-time web development. Its what I did on the side because I enjoyed it. Now I feel privileged that I have a job where I can do what I love most of the time. Its nice to find commonalities with people that you respect.

Posted by Jason Dew Sat, 03 Nov 2007 01:17:00 GMT