Archive for the ‘Uncategorized’ Category.

Code that doesn’t suck

Once in a while I manage to belt out a bit of code that doesn’t suck. This is a post with one example. I have a csv file with a bunch of rows of data that need to be added to a database. I’m using the django python framework to develop a web front-end for the database, so using django to add bulk data from a csv file seemed like a good idea too. Here is some code:


#-------------------------------------------------------------------------------
def buildModel( model, row ):
# constuct an instance of the model
m = model()

# get a list of the fields in the model
fieldList = [ f.name for f in m._meta.fields ]

# add data to the fields
for i, fieldName in enumerate( fieldList ):
setattr( m, fieldName, row[i] )

return m

#-------------------------------------------------------------------------------
def loadData( fileName, appName, modelName ):
import csv
from django.db.models import get_model

# fetch the relevant model
model = get_model( appName, modelName )

# open file using csv module
csvReader = csv.reader( open( fileName ) )

# loop over every line in the csv file
for row in csvReader:
# create a model object using the data in row
o = buildModel( model, row )

# save company
o.save()

The loadData() method processes the csv file row by row. buildModel() takes advantage of the direct correspondence between the order of items in the row with the fields of the django model. The returned model is then save()’d to the database.

Nothing special, just worked out small and neat.

Free Scrum tools

I’m a fan of Agile and Scrum.

Today I had to setup a scrumboard at work. I was looking for something free and online. I settled on using SeeNowDo. It looks like it does Scrum in a way that is familiar to me from my previous workplace.

I also quite like the look of Pivotal Tracker. This looks like it more focussed on managing a story backlog, so it may be useful for sprint planning.

I’ve heard that JIRA has worked well for people, but it seemed a bit heavyweight for my purpose since it requires a server. What tools do other people use for scrumboards?

Moment Pendulum

I have uploaded another version of our second biomechanics tool, the Moment Pendulum.

As with the previous tool, the Vector Summator, it was written using haXe in FlashDevelop. Development has been largely driven by my dad, Geoff Strauss, for use in his courses at Curtin University. The main task of the tool is to allow students to enter data about the forces that act on a limb that pivots around a joint. The tool calculates the torque moments generated by each force and sums them to provide the resultant torque in the system.

Die Walküre

Verbatim Senshuken

This is pretty cool. Saw it on reddit.

Game of Life

Devil’s Tuning Fork

Shatner Awesome

A Universe From Nothing

LCROSS impact on Friday night

Looks like I’ll be out tomorrow night, but if you are at home, you may want to watch news of the LCROSS impact at about 11:31:19 GMT (19:31:19 Perth time). I usually follow these things on SpaceFlightNow and NASA TV. Also, the LCROSS Flight Director’s blog.

The LCROSS, as I understand it, is a mission to fire a large object at the surface of the moon. It is estimated the object will impact the moon at around 9000km/h and that approximately 150 tonnes of material will be dislodged from the moon’s surface. The aim is to scan the debris from orbit and determine the presence of water.

Seems like a brute-force way of doing science.