The next meeting of the Atlanta Function Programming Users Group is going to be Monday, April 6th. All the details are available here.

As I mentioned in my last post, the agenda is to compare implementations of the first 10 Project Euler problems in different functional languages. I look forward to seeing everyone’s problem solutions!

First AFPUG Meeting!

March 2nd, 2010

Last night we held the first Atlanta Functional Programming Users Group meeting at the ThoughtWorks office in Atlanta. I gave a short introduction Haskell, which generated a lot of good questions. You can check out the presentation at the group’s slideshare page.

While the group’s next meetup date wasn’t specifically decided, it should sometime in April. The agenda for the next meeting is to compare solutions to the first 10 Project Euler problems in multiple functional languages. Our door is always open to new members, so come and join us!

The Dark Side of Elastic IPs

February 19th, 2010

Did I inherit thothle.ca?

Google “David Vollbracht”. What domain name comes up? Right now the domain is thothle.ca. In fact, you may even be viewing this page on thothle.ca. This is quite awkward, as I do NOT own thothle.ca. I’m not even Canadian. Nonetheless, I’m writing this post right now on thothle.ca, because it seemed appropriate.

whois thothle.ca

No, I won’t post all the contact info here, but suffice to say the nameservers for thothle.ca are from mydyndns.org. My conclusion: the owner of thothcle.ca was using my Amazon elastic IP and released it. He did not, however, update his dns to reflect that the IP is no longer his. Consequently his domain now points to my website, and has become the #1 page on google when searching for my name.

Conclusion

Obviously this isn’t really Amazon’s fault. They can’t exactly follow up after every IP is released and check where it is pointing now. The best I can do is contact the domain’s owner and hope he’ll change the nameserver config to not point to the IP. Funnily enough, this kind of reminds me of the poor chap who has my old cell phone number… I can empathize now.

Come to the first AFPUG Meeting!

February 16th, 2010

I’m pleased to announce that ThoughtWorks is sponsoring the first Atlanta Function Programming Users Group meeting. All the info is here at our google group page. I’ll be giving a short introduction to the Haskell programming language and then we’ll open up the floor to discussion about the group’s future. If you’re in Atlanta (or can drive there) and you’re interested in Functional Programming, this is the place for you!

Now Hosted on EC2

February 3rd, 2010

I’ve moved the hosting for this blog from my old VPS into Amazon EC2. My calculations indicate this should save me around $9-$10 a month when using a single reserved m1.small instance. This is a pretty good deal since an m1.small instance has over twice as much memory and about 60% more cpu horsepower. The EC2 setup isn’t very complicated, so I’ll give you an overview right here.

I’m running a single elastic ip attached to a single running m1.small instance. I started with the public Fedora Ruby on Rails Web Starter AMI (ami-22b0534b) and lightly customized it to fit my needs. That included installing a few rubygems and mucking about in init.d and chkconfig to get the services starting the way I wanted.

The most complicated part of the setup was separating out some parts of the machine to an EBS volume for persistent storage. In particular, the mysql database needs to be on persistent storage so it is safe if the instance goes down. Also, I wanted any rails apps to be on persistent storage so I don’t have to create a new ami for every single configure change, upgrade, or deployment. All this is achieved simply by putting symlinks to the normal places where these would live in the filesystem and pointing them to the mount point for the EBS volume.

With that done and working the only remaining issue was to ensure that the EBS volume gets attached and mounted. A bit of googling confirmed that creating an init.d script was the generally accepted approach for this, and I found a workable starting point here. That solution relied on the EC2 api tools, which in turn rely on Java which I didn’t relish the idea of installing. Instead I installed the very nice amazon-ec rubygem and rewrote the mountec2vol script on top of it. Voila! Now bringing up a new instance attaches the EBS, mounts it, and then starts any services that needed the volume once it is available.

If you’re interested in the init.d script, you can get it here. It’s limited currently by having the volume id specified in the script, so you have to rebuild the ami to change the volume id. I’ll probably extract that in the future, but it’s doing what I need for now. If you find it useful, let me know!

DynamicTeardown

July 8th, 2009

I ran into a situation while working on DeepTest recently where I wanted an object to start a temporary drb server in the middle of the test and have it be stopped automatically at the end of the test. Ideally, I wanted to encapsulate inside the class itself, which is a fake used for testing and so can be aware of the test framework. Here’s the snippet I ended up with:

module DynamicTeardown
  class <<self
    def dynamic_teardowns
      @dynamic_teardowns ||= []
    end

    def on_teardown(&block)
      dynamic_teardowns << block
    end

    def run_dynamic_teardowns
      while td = dynamic_teardowns.shift
        td.call rescue nil
      end
    end
  end
end

module DRbTestHelp
  def drb_server_for(server)
    drb_server = DRb::DRbServer.new "druby://localhost:0", server
    DynamicTeardown.on_teardown { drb_server.stop_service }
    return DRbObject.new_with_uri(drb_server.uri)
  end
end

class Test::Unit::TestCase
  def teardown
    DynamicTeardown.run_dynamic_teardowns
  end
end

This nice little implementation allows the class to know that it needs to get some teardown done while allowing the test framework to determine when the teardowns are called. So far it’s working great for me.

DeepTest 2.0 in the works

June 24th, 2009

I’ve started on a significant overhaul of DeepTest which will be released as version 2.0 when it’s finished. I thought I’d share some of my plans for what 2.0 will include and some thoughts about what might come versions after. I don’t have a timetable for yet, but work so far is going fairly quickly.

Plans for DeepTest 2.0

  • A revamped distributed DeepTest architecture that will help ease setup and maintenance.
  • A new console user interface that will provide much more information about what is going on during the test run
  • Much better error handling & reporting (no more “Maybe an error was printed above?”!)
  • RSpec integration that doesn’t break with every new release of rspec.
  • Automatic configuration for Rails projects

What comes after 2.0? The next big feature I’d like to implement is support for cloud testing with deep test on EC2. Other than that, the features coming after 2.0 will likely be driven be requests. Is there a feature you’d like to see in DeepTest? Comment here or message me (qxjit) on github and we’ll get it rolling!

Some time ago Tom, a friend, presented a math programming challenge to a me and a few others. The challenge was to create a function that when given a positive number would return a set of all the sets of positive numbers whose sum was the original number. He wasn’t so much interested in the result itself as he was in what sort of techniques were used in the implementation—memoization of course being a choice candidate for this problem. I was toying a lot with Haskell at the time, and since this was fundamentally a math problem, Haskell seemed well suited to the problem too.

Read the rest of this entry

When Philippe and I worked on SystemTimer together we went back and forth about how much to write in Ruby and how much to write in C. Writing purely at the C level gave us more control over what was happening in the Ruby process as we installed and cleared signal handlers and such, but working in Ruby produced far more readable code.

Read the rest of this entry

The Ruby documentation for the lambda method (a.k.a. proc) says “Equivalent to Proc.new, except the resulting Proc objects check the number of parameters passed when called.” This is almost exactly right. There are, however, at least two cases where this turns out to be false.

Read the rest of this entry

Ruby’s timeout method operates by raising a exception, Timeout::Error. Timeout::Error inherits from Interrupt, SignalException, and finally Exception. In particular, it doesn’t inherit from StandardError, which means it isn’t caught by a default rescue clause with no exception class specified. When I first encountered this, I was annoyed that I had to explicitly catch timeout errors anytime I wanted to recover from errors in general, whether they were timeout errors or not. I realized something the other day that changed my opinion on this however.

Read the rest of this entry

In Ruby every object has an object_id that uniquely identifies that object in that particular instance of the Ruby process. Ruby also treats integers as objects—they are instances of Fixnum. For efficiency reasons, though, Ruby implements integers internally as simple values. That is, it doesn’t allocate heap memory for every integer you use, it just passes the value around instead. So how does Ruby generate object ids for all these integers?

Read the rest of this entry

RubyGems and I had a fight. It was about what version of net-ssh we wanted to have installed on my machine. RubyGems wanted the latest (2.0.2) and I wanted a 1.x version (1.1.4). Apparently net-ssh 2 has an issue with sshing into Fedora Core 4, which I needed it to do. Specifically I needed to use capistrano 1.4.1 to deploy an app to Fedora Core 4

Read the rest of this entry

When we first started trying to use distributed DeepTest, we quickly ran into an issue with DRb servers not binding to the correct addresses. DRb does provide a way to bind to 0.0.0.0 to listen to all addresses, but there’s a downside to the way it does it. The url you provide to DRb to accomplish this must omit the hostname (e.g. druby://:0/). DRb then determines what hostname to report to clients by calling getaddrinfo with the empty hostname. Unfortunately for us getaddrinfo didn’t provide a hostname that could be used by our developer machines to connect to the DeepTest servers. For a brief moment we thought we were stuck.

Read the rest of this entry

  class DearSoul
    def self.new(first, last)
      ObjectSpace.define_finalizer(allocate, proc {|id|
        puts "Goodbye, #{first}.  We'll miss you." 
      })
    end
  end

  DearSoul.new("George", "Carlin")