Darwin, Humanism and Science

On Saturday I had the good fortune to be able to attend a conference entitled “Darwin, Humanism and Science“, held at London’s Conway Hall. For those not able to attend here is a short roundup of what happened:

Richard Dawkins starts us off

The conference kicked off with a quick introduction from BHA President Polly Toynbee, after which Professor Dawkins took to the stage. His lecture revolved around the concluding paragraph of Darwin’s On the Origin of Species, which can be read online for free here (the relevant passage starts “Thus, from the war of nature …”). Dawkins analysed each segment of the text in turn, giving us his insights into its meaning and slipping in some fascinating information about our modern-day understanding of evolution, such as how we know that all species in the world today must be descended from a single progenitor.

The professor left some time for questions at the end of his lecture. He had commented on the lamentable state of the public’s understanding of science, proffering the alarming statistic that some 18% of the British population believes that the Earth orbits the Sun once a month (presumably we go around faster in February), which lead me to ask him what we can do to combat this. His answer was to “get out more”.

Referring to the role scientists have to play in the public’s awareness and understanding of science, rather than (I hope) to my social life, he made the point that scientists and educators must make greater efforts to reach out to the public and disseminate not only the knowledge that modern science has obtained, but the joy that this knowledge can bring. It was a point that was returned to time and again throughout the day.

Insidious Creationism in Education

Following Professor Dawkins were two quick talks about the teaching of evolution in schools – first from a European perspective from Professor Charles Susanne, and then from a British one from James Williams. Though both highlighted the growing influence Creationist organisations are having on educational materials, Mr Williams’ speech was for me the more alarming:

Quickly firing through a series of ridiculous materials showing how children and dinosaurs once lived and played together, and even an endearing image of Jesus cuddling a small Velociraptor, Williams showed how creationist books, comics and literature represent an “intellectual abuse of children”. Entitled “Insidious Creationism”, his talk opened our eyes to the battle being waged over children’s education, in this country and around the world. I for one am very pleased that we have people like Williams fighting in our corner, and for his troubles he was presented with the rather dubious prize of an Atlas of Creation.

Human understanding of Evolution

After lunch we were treated to talks from Johan De Smedt and Dr Michael Schmidt-Salomon. Johan’s talk revolved around the three themes of essentialism, teleology and the design stance. Tackling these in turn he described the biases inherent within us that give these ideas more prominence in our mental model of the world than they deserve, especially when we are young.

Dr Schmidt-Salomon rebutted the idea that evolution can be objected to on moral grounds. Though it may seem obvious that a moral objection to a natural phenomenon does not make it any less real, he reminds us that there are those who disagree. His most impressive moment though was in revealing his efforts to turn Ascension Day into Evolution Day, aided by a spectacularly bizarre music video featuring Charles Darwin as an unlikely rock star:


Hinduism and The Two Cultures

For me an unexpected highlight of the day came in the form of Babu Gogineni’s description of the devastating effect that some interpretations of Hinduism are having on science in India. He described how many Hindus believe that modern science backs up Hinduism’s central tenets, and can therefore turn their backs on further progress made by the scientific community. It was a startling and eye-opening description, and one could feel his frustration at how quackery and superstition are considered more important (or at least more profitable) than science and understanding in India today.

The conference was rounded off by what seemed a short talk from Professor A C Grayling. This was the first time I had heard Grayling speak, and the calm lucidity with which he spoke made his 45 minutes seem more like 5. Speaking on the ‘two cultures’ – that of science and that of the humanities – he referred to a lecture given by C P Snow some 50 years ago decrying the divergence of these two cultures, and the widening communication gap between them. Snow’s original point was that this divergence was getting in the way of solving the world’s problems – 50 years later Grayling points out that we still have some way to go in closing that gap.

The ‘Special’ Dinner

In the evening a special dinner was laid on for the speakers and delegates attending the conference (today was just one day in a week of Humanism conferences). For some reason they let some of the unwashed masses in too, and so it was that I sat down with a delightful group of fellow conference-goers to enjoy a good meal punctuated by good conversation.

After we had eaten Professor Grayling presented Professor Dawkins with an award in recognition of his efforts in spreading rationality and clear thinking around the world, and in return Dawkins read out a modern day episode of Jeeves and Wooster, albeit with a rather Atheistic stance. I’m not sure whether or not he penned the parable himself but it was extremely well written and its British humour well received.

All too soon the coffee came round and it was time to leave. Overall the day was very well run and extremely enjoyable. A wise gentleman on my table was moved to remark that “it was the best 8 quid I’ve ever spent”. Amen.

ExtJS Textmate bundle

** Update 2: I’ve recently cleaned up the bundle, removing stale snippets. It’s now located at https://github.com/edspencer/Sencha.tmbundle

** Update: Added extra instructions when downloading the bundle instead of git cloning it. Thanks to TopKatz for his help**

I develop on both OSX and Windows machines, and my editors of choice are Textmate and the excellent Windows clone E. One of the great things about Textmate is its bundle support, which allows you to create reusable code snippets (among other things).

I’ve got a good collection of these built up so thought I’d make them available on Github. You can install it like this:

Mac OSX:

cd ~/Library/Application Support/TextMate/Bundles
git clone git://github.com/edspencer/Sencha.tmbundle.git


cd C:Documents and Settings{YOUR USERNAME}Application DataeBundles
git clone git://github.com/edspencer/Sencha.tmbundle.git

If you don’t have git installed you can simply download the bundle as a zip file, and extract it into the directory as above. You need to rename the extracted directory to something like extjs.tmbundle or it won’t show up. If you do go the git route you can of course cd into that git directory at any point and use git pull to update to the latest bundle version.

I’ll give one example of the usefulness of snippets like these; here’s the Ext.extend snippet from the bundle:

 * @class ${1:ClassName}
 * @extends ${2:extendsClass}
 * ${5:Description}
${1:ClassName} = function(config) {
  var config = config || {};
  Ext.applyIf(config, {
  ${1:ClassName}.superclass.constructor.call(this, config);
Ext.extend(${1:ClassName}, ${2:extendsClass});

${3:Ext.reg('${4:xtype}', ${1:ClassName});}

To use this you can just type ‘extend’ into a JS file in TextMate/E and press tab. The snippet takes you through a few editable areas such as the name of your new class, the name of the class you’re extending, xtype definition and description, then dumps the cursor inside the Ext.applyIf block. The actual characters typed are these:

extend [tab] MyWindow [tab] Ext.Window [tab] [tab] mywindow [tab] Special window class [tab]

Which produces this:

 * @class MyWindow
 * @extends Ext.Window
 * Special window class
MyWindow = function(config) {
  var config = config || {};
  Ext.applyIf(config, {
  MyWindow.superclass.constructor.call(this, config);
Ext.extend(MyWindow, Ext.Window);

Ext.reg('mywindow', MyWindow);

Hopefully it’s obvious how much time things like this can save when generating repetitive, boilerplate code. The extend snippet is one of the larger ones but even the small ones are very useful (pressing c then tab is much nicer than typing console.log(”); each time).

Any suggestions/contributions are welcome. Thanks go to rdougan for his contributions and organisation also.

There is also another ExtJS textmate bundle available at http://hakore.com/extjs.tmbundle/, written by krzak from the Ext forums.

Don’t forget the wurst

So it came to be realised during Rails Camp 08 that the world was sadly lacking in William Shatner based list apps. Thankfully, the Railslove guys (plus Rany) have come to the rescue with don’t forget the wurst. If you’re looking for something delightfully random in your life, you may have just found it.

Check out my Shatner’s greatest hits list and Ask William about a few of the items – he will furnish you with compelling and thoughtful answers.

DRYing up your CRUD controller RSpecs

A lot of what we do in Rails boils down to simple Crud. If you’re in the habit of developing admin sections to allow your clients to control the front end of their site, you’ll probably have noticed that these controllers in particular tend to all look the same. There are quite a few ways to DRY up the controller itself – using something like make_resourceful, for example, but what about your RSpec files?

Robby Russell recently posted a short article about RSpec’s Shared Example Groups. Take a look at his post or at the RSpec documentation (it’s not scary) to see how they work in more detail, but they basically allow you to share your it “should” do ….. end blocks, enabling them to be reused multiple times.

When you think about it, every time we spec a basic CRUD controller, we’re doing the same thing – we should be able to just do something like this:

require File.dirname(__FILE__) + '/../../spec_helper'

describe Admin::ContactsController do
 before(:each) do
   @model = 'Contact'

 it_should_behave_like "CRUD GET index"
 it_should_behave_like "CRUD GET show"
 it_should_behave_like "CRUD POST create"
 it_should_behave_like "CRUD PUT update"
 it_should_behave_like "CRUD DELETE destroy"
 it_should_behave_like "CRUD GET edit"

Well luckily for you we can! I’ve been using this pattern with most of my CRUD-based controllers for a while now. You just set up the model’s name at the top (and in the case above perform the login_as_admin helper method to log the user in), and for each action in the controller use a specialised shared example group. The example groups all know how to understand your @model definition in before(:each) and map it to the various expectations that the CRUD specs run.

The great thing about this approach is that you can just dump these into your spec file and update them later if you need to. For example if you need to paginate the index action instead of the default find(:all) the shared example group will test, just remove the it_should_behave_like(“CRUD GET index”) and add your own describe block – the rest of the it_should_behave_like lines can stay as they are.

This approach works especially well if you take the approach to CRUD controllers where you create a CrudController class and subclass your CRUD controllers from it – e.g. from the example above:

class Admin::ContactsController < Admin::CrudController


My Admin::CrudController reflects on the name of the ContactsController subclass here and figures everything out without me having to do any work. This works because almost all of my Admin section code works the same way. If I need to diverge from the default CRUD behaviour, I just redefine the particular action in Admin::ContactsController:

class Admin::ContactsController < Admin::CrudController
  def index
    #my alternative implementation

I personally prefer this approach over the more declarative alternatives such as make_resourceful because I feel more in control this way. That said, I’m open to persuasion 🙂

Anyway the code for the shared example groups is on Github at http://github.com/edspencer/rspec-crud-controller-shared-example-groups. There’s only one file there – just chuck in in your spec directory and add this line to spec_helper.rb:

require File.expand_path(File.dirname(__FILE__) + "/crud_controller_matchers")

Apart from the magic going on in the CrudSetup module at the top of that file, there’s nothing special going on here, so you can tweak the examples to your particular approach. There’s a good chance some of that code could be written more cleanly so please feel free to suggest changes / fork the file on Github.

UPDATE – Actually no, ignore the FUD about make_resourceful above, it works remarkably well with very few modifications to the shared groups – I’ll post those up as soon as I’m done.

Git clone vs Git submodule

Having recently made the switch from svn to git, I wanted to achieve what svn externals did (and what Piston did better). Turns out this is pretty simple, for example to get rails on edge:

%d bloggers like this: