<?xml version="1.0" encoding="UTF-8"?><!-- generator="WordPress/2.5.1" -->
<rss version="0.92">
<channel>
	<title>chrisspenblog</title>
	<link>http://www.chrisspen.com/blog</link>
	<description>knowledge through programming</description>
	<lastBuildDate>Sat, 28 Jan 2012 11:53:31 +0000</lastBuildDate>
	<docs>http://backend.userland.com/rss092</docs>
	<language>en</language>
	
	<item>
		<title>Online Variance Calculation in Python</title>
		<description>Since I couldn't easily find this code anywhere, I figured I'd post it here for quick reference:



"""
2012.1.25 CKS
Incremental calculation of both the mean and variance.
http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
"""
import unittest

## Dumb slow mean/variance formulas.

def mean(seq):
    return sum(seq)/float(len(seq))

def variance(seq):
    m = mean(seq)
    return sum((v-m)**2 for v ...</description>
		<link>http://www.chrisspen.com/blog/online-variance-calculation-in-python.html</link>
			</item>
	<item>
		<title>Persisting Django&#8217;s Test Database</title>
		<description>After running Django unittests, it may sometimes be useful to manually inspect the test database after unittests are complete. I was working on a complicated network model, trying to resolve an elusive bug in a unittest, and in this specific instance, I thought running a manually written SQL query would ...</description>
		<link>http://www.chrisspen.com/blog/persisting-djangos-test-database.html</link>
			</item>
	<item>
		<title>Passwd: Authentication token manipulation error</title>
		<description>I was doing some work with an inherited Kerberos setup, when I noticed my Kerberos-based SVN login suddenly stopped working. Attempting to ssh into the machine revealed the cause:

WARNING: Your password has expired.
You must change your password now and login again!

Fair enough. I personally find password expiration a huge annoyance ...</description>
		<link>http://www.chrisspen.com/blog/passwd-authentication-token-manipulation-error.html</link>
			</item>
	<item>
		<title>Restricting Write Access to Django Admin</title>
		<description>Django has a great auto-generated administration interface. It's saved me countless hours of development time and makes basic data maintenance a breeze. Although it's designed to be extensible, it's not without it's quirks and hurtles. Fortunately, most of these can be overcome with a little code inspection. One of these ...</description>
		<link>http://www.chrisspen.com/blog/restricting-write-access-to-django-admin.html</link>
			</item>
	<item>
		<title>How to Extract a Webpage’s Main Article Content: The Unicode Edition</title>
		<description>When I originally wrote html2text.py, my focus was only on extracting English text from webpages, so I didn't give much thought to handling Unicode. Ignoring anything but ASCII would suffice. However, I was recently commissioned to extend the script's functionality to use Unicode, so it could extract text in nearly ...</description>
		<link>http://www.chrisspen.com/blog/how-to-extract-a-webpage%e2%80%99s-main-article-content-the-unicode-edition.html</link>
			</item>
	<item>
		<title>How To Install MBROLA Voices For Use With Festival On Ubuntu</title>
		<description>Festival is a great text-to-speech engine. MBROLA also contains some impressive voice files that have notably higher quality than Festival's default voices. Both of these systems are packaged in Ubuntu, and even though Festival can use MBROLA's voice files, as of Ubuntu 10.04, there doesn't seem to be a package ...</description>
		<link>http://www.chrisspen.com/blog/how-to-install-mbrola-voices-for-use-with-festival-on-ubuntu.html</link>
			</item>
	<item>
		<title>Ubuntu Flash Drive Encryption Script</title>
		<description>I was researching methods to encrypt USB flash drives, to protect personal data in the event they're lost or stolen, and I found a few good write-ups on the subject using tools available in Ubuntu. Although the current distribution of Gnome includes pretty good support for auto-detecting and prompting for ...</description>
		<link>http://www.chrisspen.com/blog/ubuntu-flash-drive-encryption-script.html</link>
			</item>
	<item>
		<title>How To Remotely Backup A Web Server With No Install</title>
		<description>I was researching simple methods for backing up a basic Linux web server, and I found an excellent script that handles files and databases, and also dumps everything to a remote server. I was looking for something a bit less complicated and overkill than Bacula, but more comprehensive than simply ...</description>
		<link>http://www.chrisspen.com/blog/how-to-remotely-backup-a-web-server-with-no-install.html</link>
			</item>
	<item>
		<title>Implementing a Simple Machine Learning Intelligence to Play Rock-Paper-Scissors in Javascript</title>
		<description>Rock-paper-scissors is not a complicated game. However, there are some that not only enjoy the game, but take pride in professing skill at it. But is it possible to have skill at rock-paper-scissors?

In the real world, where a human plays against a human, "cheating" is relatively easy. A player can ...</description>
		<link>http://www.chrisspen.com/blog/implementing-a-simple-machine-learning-intelligence-to-play-rock-paper-scissors-in-javascript.html</link>
			</item>
	<item>
		<title>Handling PostgreSQL Integrity Errors in Django</title>
		<description>I have some basic Django code that attempts to insert a new record into a PostgreSQL database. It's wrapped in a try/except statement in case a unique constraint is violated, in which case I'll typically ignore it and move on.

So the general pattern is:

from django.db import IntegrityError
import models
try:
   ...</description>
		<link>http://www.chrisspen.com/blog/handling-postgresql-integrity-errors-in-django.html</link>
			</item>
</channel>
</rss>

