Brad's Blog

web dev, django, running, food, or whatever

Calculate a Week Range for a Date 2013-03-07

Math with dates and date ranges is often fun & enlightening! As a testament to the fun of calculating dates (particularly ranges of dates), I present the following: Given a date, how would you find the range of dates that describe the week during which your original date lies? In other words, assume today is March 7, 2013 (and it is... for now anyway). Can you answer these two questions: What was last Sunday's date? What will be the ...

How to use a turning lane 2013-02-23

Stop in the middle of the road Slowly turn half-way into the turning lane Wait forever

The Minimum Working Thing 2013-02-08

This was originally a guest post that appeared on Nibletz. The original link is here: http://nibletz.com/2013/02/08/minimum-working-guest-post/ I've been pondering this post for a long time. Any student of startups is probably familiar with the phrase Minimum Viable Product. It's really a simple idea, and I think it embodies an important philosophy for anyone starting a company. The idea is that your product (whatever it is; e.g. a service, a physical thing ...

Division By Zero 2012-11-23

In a former life (while a GA in graduate school), I was forced to had the pleasure to teach elementary and intermediate algebra. These courses are essentially the algebra curriculum you should learn during High School in the United States. Unfortunately, many college-bound students don't master the material, and find themselves in a remedial class during their college career. That's the class I was teaching. There are many concepts that are difficult for students to understand, but one ...

Vim: Jumping around! 2012-11-12

So what happens when you open a file in vim, and you're presented with lots of content? Say, 5000 lines of something. Well, I typically start searching for things: /keyword. That works great when you know what you're looking for. But it breaks down quickly when you don't. So, today's vim post is about moving faster through pages of text. Jumping to a line number I have line numbers turned on by default (:set nu, if ...

Let's be a better vim user 2012-11-04

It's November. For many, that means a month of writing (NaNoWriMo). For others, that's a month of cultivating a fine moustache (Movember). I, however, am making an effort to become a better vim user. Call it NoVIMber or VIMmember or whatever. I'll try to periodically blog about what I'm doing, but I'm not making any promises (other than to force myself to be more productive). I've been using vim for a long time (since ...

Customizing Django's password_change view 2012-10-30

If you have a site where users have the traditional username/password combination, you've got to provide some way to let users change their password. Luckily, this is fairly easy to do with Django. The auth app comes with a password_change view that does what you'd probably expect. It's also fairly easy to set up. You add a line similar to the following to your root URLConf: url(r'^accounts/', include('django.contrib.auth.urls')), You also ...

Thoughts on PyArkansas 2012-10-28

I make a decent effort to keep up with what's happening in the Python comunity, but—gosh darnit—it's hard! I think that's why conferences exist. They give you a day or two to focus solely on meeting people and catching up with what's going on in the community. I particularly like the smaller, regional events like the one I attended this weekend: PyArkansas. Here's a few reasons why: Cost: Smaller, regional conferences tend to ...

Django Models & Mixins for cleaner code 2012-09-26

I've been using Mixins lately to DRY-ly make certain behavior available to several different Django models. If you're not familiar with mixins, there's a great discussion over on StackOverflow. Here's a simple example to illustrate what I've been doing. In building Work for Pie, we've got a UserProfile model that looks something like this: class UserProfile(models.Model): user = models.OneToOneField(User) tagline = models.CharField(max_length=140) biography = models.TextField() avatar_url = models.URLField(max_length ...

Fixing Bugs. 2012-09-25