Archive for the ‘Programming’ Category

How to copy a file really slowly using Python

August 8, 2013 Leave a comment

Just realized that the poor performance I was seeing when downloading a file from Rackspace Cloudfiles to a local drive was due to shutil.copyfileobj without specifying a buffer size.  As I found out, the default buffer is 16k (just in case you’re running on a 640k server), increasing it to 1MB sped up the process from 17.8 seconds to 0.8 seconds, with 5MB down to 0.3 seconds (for files averaging about 3-4MB).

So remember: always supply a buffer size, and the 60x speed increase can be yours too!

Categories: Programming, Python

Why Developers Keep Making Bad Technology Choices

July 19, 2012 Leave a comment

Why Developers Keep Making Bad Technology Choices

Categories: Programming

Sessions on new programming languages

July 18, 2012 Leave a comment

Over the past couple of days I attended several OSCON sessions on new (to me) programming languages:

  • CoffeeScript is a scripting language that compiles into JavaScript.  It looks very clean and uses whitespace/indentation just like Python does, which is great.
  • Erlang was not completely new to me, but I had not understood the overall architecture of the Erlang environment and its similarities to an operating systen.
  • Clojure, a Lisp dialect, seems the least practical for day-to-day use, but is also the most different and interesting to me.

Simple Sudoku solver in Python

July 6, 2012 Leave a comment

Since a new “hardest” Sudoku puzzle was just announced, I finally wrote my own Sudoku solver in Python.  I based it on some ideas from Peter Norvig’s Sudoku solver, but ended up writing everything from scratch.  The code is available on github.

Categories: Fun Stuff, Programming, Python

Tracking down potential bug in PyISAPIe

March 27, 2012 Leave a comment
Categories: C, Programming, Python Tags:

Shenandoah National Park Oral History Collection

March 13, 2012 Leave a comment

A project I’ve worked on over the last few years is now online at  It is a collection of oral history recordings and transcripts, delivered through a custom interface built on MDID3.

See the official announcement at

Categories: Programming Tags:

Udacity CS373 Localization Problem

March 1, 2012 Leave a comment

I’m taking the Udacity CS373 Programming a Robotic Car class.  Below is my solution to the localization homework problem in unit 1 that was due yesterday.  Note that this is not the complete program, just the homework portion.

world_width = len(colors[0])
world_height = len(colors)

p = [[1. / (world_width * world_height)] * world_width
     for i in range(world_height)]

def sense(p, Z):
    q = [
                pcol * (sensor_right if scol == Z else (1 - sensor_right))
                for pcol, scol in zip(prow, crow)
            for prow, crow in zip(p, colors)
    norm = sum(sum(row) for row in q)
    return [[col / norm for col in row] for row in q]

def move(p, motion):
    ym, xm = motion
    return [
                p_move * p[(y - ym) % world_height][(x - xm) % world_width]
                + (1 - p_move) * p[y][x]
                for x in range(world_width)
            for y in range(world_height)

for me, mo in zip(measurements, motions):
    p = move(p, mo)
    p = sense(p, me)

Instead of looping, I make use of list comprehensions, which I think is a cleaner solution.

Categories: Programming, Python Tags: , ,