Karma tests with AngularJS + RequireJS

Setting up testing is usually a little painful – but setting up testing when you’re using some kind of weird Angular + Require setup is even worse! Furthermore, the Karma documentation is a little bit terse, so it’s hard to tell exactly what combination of configuration settings will get you your intended result. Here’s how I accomplished this. File Hierarchy Here is a typical, sample hierarchy. My top-level directory is something like /opt/some-app.
Read more

Django Tastypie: Tips, Tricks, and Troubleshooting

Tastypie is one of the most popular REST API frameworks for Django, and surprisingly easy to get up and running if you’re already working with Django’s Models. It can, however, be a bit difficult to debug, and produce some cryptic error messages. Here are a couple of tasks I’ve had to figure out while working with this framework, tips for troubleshooting, and some general reflections. Table of Contents Adding Fields to a Resource Mapping Attributes of an Object through a Reverse Relationship Filtering via Through Relationships Self-Referential Resources Adding Fields to a Resource It seems simple enough – and it is – but there are really a number of ways to do it, so you have to decide which is most appropriate for your use case.
Read more

Internationalization with Django, Backbone, Underscore templates, and Sass (LTR and RTL languages)

Let’s be honest: No developer wakes up in the morning and thinks, “Oh goody! Today I get to internationalize my giant website with tons of content and files. I bet supporting right-to-left languages is going to be a blast.” However, I’m here to tell you that it’s not nearly as bad as you would expect. In fact, Django makes it downright easy to do. Unfortunately, there’s not a lot of information on the web about internationalizing (also known as i18n) in Django besides the official documentation.
Read more

Building a Parse Tree Editor in d3 with Tree Layout (Pt. 1 - Display)

“In this way, the Athenians came to the circumstances under which they grew in power.” The first sentence from Thucydides’ Pentecontaetia. This is a long post and chances are you only need information from part of it. Here’s a table of contents: Background Trees: In Linguistics and in d3 Our Incoming Data Dependencies Base Code Our HTML Our Main for Require.js Our JS Base Key Functions Initialize Module Convert Data Render SVG canvas Update Tree to Use our Data External Resources
Read more

Set up Nginx and uWSGI

When browsing the web, I often read that setting up nginx with uWSGI is incredibly easy to set up and get running. I absolutely did not find it so, as I had to deal with a lot of configuration issues. So here’s how I finally got these components working together on an instance of Ubuntu 12.04. I ultimately hook this up to Django, but I’m sure the general principle would apply to other python frameworks with a WSGI interface.
Read more