RequireJS and Django

I just finished converting one of my projects over to using RequireJS. I've been moving towards more Javascript heavy stuff lately and keeping all of the dependencies in order has begun to get very messy. RequireJS seemed to be the standard way of managing this, so I decided to give it a try on one of my side projects (which will hopefully go live soon-ish).

RequireJS basically gives you about as close as you're going to get to includes in other languages implemented in Javascript. Overall it works very well, with just a couple of small, easy to ...

→ read more

Private Read The Docs With Private Github Repo

I did a bit of experimenting with setting up a local, private read the docs server to use at work for documenting our Django apps which do not have public code. This is pretty easy once you know what to do, but the steps you need to take may not be immediately obvious. Start out by setting up your own Read The Docs stuff as documented.

After that, create a file and add in ALLOW_PRIVATE_REPOS = True there. This setting will allow you to use x-oauth-basic urls for your github repos.

Now go to your github project's settings ...

→ read more

File Iteration With python-mock

I came across a unit test situation recently where I did not want to litter my project with test files for reading. I did some looking and python-mock has a way to mock open, but there are a couple of things to watch out for. What is documented there doesn't quite work right off the bat. The documentation shows this:

with patch('', mock_open(read_data='bibble'), create=True) as m:
    with open('foo') as h:
        result =

Simple enough. Except right away, that actually needs to be, at least on Python 2.7 ...

→ read more

A New Project and More KnockoutJS

I've begun a new side project. This one might actually get finished and permanently hosted, even. The main purpose of the project is for me to play with Django Rest Framework and more KnockoutJS. So far I'm really liking both. Django Rest Framework is proving to be much easier to work with than Tastypie once I need to break away from the standard. I find splitting the serializers out from the views/endpoints and being able to route by request method to be far more flexible.

KnockoutJS also continues to be flexible and provider cleaner, more maintainable UI ...

→ read more

Playing With KnockoutJS

I've been trying to build up my front end dev skills a bit lately and get to know some of the front end JavaScript frameworks out there better, or in some cases, at all. The most interesting thing I've been working with lately is KnockoutJS. The short description of what it does is that rather than hand writing all of the event bindings using jQuery or whatever you like, you add a bit of extra markup in the HTML and a few simple, mostly single line variable declarations/assignments in your JavaScript. Knockout then handles the event binding ...

→ read more

Things I've learned

So I've learned some things since my last post on here.

For one, people actually come to my little website. I did not know this. I haven't run any usage tracking stuff for a long time and just kind of figured it's a tiny blog thing which I don't advertise and I'm not famous, so it must get like 2 hits per year. I got bored and set up Google Analytics a few days ago and it turns out more people visit each day than I thought did in a year. Not tons. Not even ...

→ read more

Django Project Structure Test

I've started a second small to mid sized project to go along with Djukebox. I'm using this to test something out with Django projects to see what I prefer. With Djukebox I just made it a proper installable app that you can install with pip (if I put it on pypi). I like this because then you can easily start a project called whatever you want, which does anything you want, and add Djukebox to it. It also makes it easy to distribute without tying myself or anyone else to a specific project structure, you set up your ...

→ read more

Track data editing finally added to Djukebox

I finally got done adding track editing data to Djukebox. I can't remember when I started on this, but I believe it was well over 6 months ago. I had a lot of delays and not much free time in getting it done. I took two calculus classes, had my employer shut down all in house software development and lay off the entire team and so had to find a new job, and had a baby. It's been a long time coming, but the functionality is finally added.

I learned some things while adding the new features. I ...

→ read more

CoffeeScript FIrst Impression

Today I tried to use CoffeeScript for the first time. Some of the other guys at my new job like it and it's not often that you are encouraged to use more cutting edge, less supported, less proven technology so I figured I'd give it a try on my current work project.

So far I'm not impressed. Maybe it's because I don't really dislike JavaScript in the first place, but I don't feel like what I've gained outweighs what I've lost. The syntax is a bit more terse and I've gained ...

→ read more

Two Scoops of Django

I recently bought the beta of Two Scoops Of Django based on all of the good reviews and recommendations it's getting fro people who know way more about Django than me. I haven't read it all in depth, but I've read most of it and at least glossed over the rest and so far it was well worth the $15.

The explanations of how and when to use the Class Based Views were excellent. The official documentation hasn't been very clear on them, so I've avoided them. In my personal case I still think they ...

→ read more

Python Tic-Tac-Toe AI

Not too long ago I began talking to a company which will remain unnamed for now about a Django dev job. Part of their hiring process is to write single player a tic-tac-toe game where the computer always wins in Python. The hiring is on hold over the holidays, but I figured I'd get a head start and document it here for fun.

I start with a couple of basic classes, Board, Player, and AIPlayer.

class Board(object):
    """A tic tac toe board"""

    wins = ((0,1,2), # rows
            (0,3,6), # columns
            (1 ...
→ read more

Python Unicode Gotcha

I was peer reviewing a bug fix for some code at work the other day and learned something about Python and encoded Unicode. It makes sense now, but when I first saw the fix my initial thought was that there's no way that's what is going wrong. It turns out that once you've encoded a Unicode string, perhaps to utf8, you can chop off just part of the bytes of a single Unicode character using string slices.

>>> u = u'A string with some random unicode \u0200 \u0202. There it is.'
>>> u
u'A string with ...
→ read more

Djukebox Gets Handlebars and a REST API

I recently reworked the Djukebox UI. It's still ugly, but it uses way cooler things behind the scenes. The original incarnation had a main page which housed the player, a hidden iframe for uploading new tracks while letting the user continue browsing and listening, and another iframe for the current page content so that the player could keep playing while the user clicks around through lists of tracks and albums.

It worked pretty smoothly, but it's not cool and new. This is an old, hacky way of doing things. The point of Djukebox is to be a playground ...

→ read more

Control Panel Development Is Underway

I have begun work on a new control panel app for the CMS used for I got to learn a little about how django.contrib.admin works since I dug into its code to see how the dynamic urlconf creation happens and how model registration is handled. For bscontrolpanel entire views are registered rather than single models. This can be a bit more work, but it allows for streamlined, user friendly control panel views to be built, housed with the app they belong to, but appear dynamically in the control panel and all live under a common base ...

→ read more

A New Look and Reworked Back End

The site has a new look. I completely scrapped the old html and css and started from scratch. I'm terrible with picking colors so I used a bootstrap them from BootSwatch and then went to work on the layout. I made changes to the back end to hopefully let me expand this more as time goes on. The blog section is now one app while the projects are their own app rather than being hacked into the blog stuff. I'm hoping to find time to take the projects section and tie into github and bitbucket APIs, add file ...

→ read more