Brad's Blog

web dev, django, running, food, or whatever

Published: 2014-01-27

WORS 5k at Stanky Creek

running trails

Yesterday I ran the 5k portion of the winter off-road race series. It was at Stanky Creek (aka Nesbit Park), which is one of my favorite local trail-running locations. As expected, the pace for this race was a bit slower than the 3k, and I had a good time running this one. Apparently, I'm going to keep writing about this WORS experience, so here's some thoughts about race number two: wow. There were a lot of people. I ...


Published: 2014-01-05

WORS 3k in the bag

running

Today, I completed my second-ever organized race. It was the Winter Off Road Race Series 3k in Overton Park. The weather was pretty amazing (34ºF and raining), but I dressed for it and had a great time. Being only my second race, there's a few things that I thought were interesting about this particular race. Lots of kids! I was somewhat amazed at the number of kids that ran this race; many of them probably around 10-12 years old ...


Published: 2013-12-31

Looking Back. Looking Forward.

personal professional review year end

I don't often write one of those year-end summary blog posts, but 2013 was so incredible on so many levels, I thought I'd break with (a lack of) tradition and start something new before the year's completion. Failures I actually grew up in a culture that seeks to limit or eliminate failure. In other words, failure is bad. Avoid at all costs. I still struggle with this mindset, even though I know it's absolutely wrong. Therefore ...


Published: 2013-12-29

The little things

generators lambda map python

I ran across an interesting line of code today, and thought I'd share some insights. First, though we need a little context. Imagine reading several lines of data from a csv file (using python's built-in csv module). You'll typically have some code that looks something like this: import csv with open('data.csv', 'rb') as csvfile: reader = csv.reader(csvfile) for row in reader: # Do some stuff with each row, # where the row is a list of ...


Published: 2013-11-15

problems with django_extension's graph_models?

django django_extensions python

I recently ran into an issue when trying to generate an image of my project's models using django_extension's graph_models command. Unfortunately, googling for the error didn't turn up any solutions, so I'm dumping some info here (just in case!). some background For the record, I was using django_extensions, version 1.2.5 (the latest release as of this post), and Django 1.4.2 (yeah... it's old) Running the following command:$ ./manage.py graph_models my_app ...


Published: 2013-10-12

Getting the Most out of ack

ack grep tools

ack is an amazing tool. If you're not familiar with it, it's a lot like grep (the official site is at beyondgrep.com). It's a command-line tool that helps you find things in files, particularly source code. However, like a lot of command-line tools, it's all-too-easy to learn just the basics and forget that many of these tools can do so much more! Without further ado, here are a few of the ways I frequently use ...


Published: 2013-09-12

An Attribute by any other name...

__gettattr__ attributes descriptors programming properties python

Let's explore some python attributes, shall we? (note: this is python 2.7.x) Attributes Let's consider a simple class, N, with a single attribute, numbers containing values 0 - 9. class N(object): numbers = range(10) # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] We can create an instance of this class, then perform some operations on the attribute (like accessing or setting its values). >>> n = N() >>> n.numbers # get the value of the ...


Published: 2013-05-19

Metrics with Django and Redis

django django-redis-metrics metrics redis

So, you've got a shiny new Django-powered site, and now you'd like to start recording metrics. Perhaps you've read The Lean Startup, and you know you've got to know how people are using your site in order to know what to improve. Perhaps you're just a data nerd and you like to count things. Either way, there are ton's of ways to measure things on your site. You could use third-party applications like Google ...


Published: 2013-05-09

String Theory

fun physics running strings

I'm not a physicist, but I've got some views on string theory that I'd like to share. Here goes: Brad's String Theory: Axiom I While in motion, strings will become untied, regardless of advanced techniques employed to fasten them. Brad's String Theory: Axiom II When at rest (i.e. upon completion of aforementioned motion), strings will be resistant to any attempt at unfastening. These statements are, to best of my knowledge, universally true, based on ...


Published: 2013-04-07

Django Manager Testing Woes

django managers mock models python testing

I've recently run into some strange behavior while testing some custom Django managers. While, I can't list all of the exact code (it's not open source), I'll try to list some simple examples that illustrate the problem so (hopefully), this post will be helpful for others. To get started, assume I have the following Model and Manager: class DefaultThingManager(models.Manager): def things(): # A custom method that retrieves some set of DefaultThing # objects. This doesn't ...