- Allow templates to access the “get_url” function
- Create an endpoint to serve your own static pages yourself
I had posted about a recursive maze solver earlier. This is an iterative solution to that problem.
This was… not straightforward. There’s a couple of Python modules out there for this. I ended up using
sqlalchemy. I needed to edit some files in
/usr/local/etc, and then symlink them to
I set up my Django project to use MySQL, so that I could use a list in a JSONField. Little did I know that accessing elements of that list by their index would be another problem entirely. There are two confounding things. First, in Jinja2, you can access a for-loop index with the
loop.index0 keywords, but in a Django project, you need to use
forloop.counter or forloop.counter0`. The trailing zero on those keywords specify a zero-indexed counter rather than a one-indexed counter. The second thing is that you need to provide a custom template tag in order to cleanly access elements in a JSONField list by their index.
I wanted to store a variable list of things in a Django Model. One way to do that is to create another Model, another way is to use a JSON field in your current Django Model. Unfortunately, the default SQLite3 database does not support JSON fields, and you will need to set up a MySQL database.
A few months ago I worked on a Rails application and got acquainted with SASS. I found that I really prefer using SASS over CSS to the extent that it’s worth the overhead of learning another tool’s quirks. Here, I’ll describe what worked for me using SASS with Django.
Today I learned about a state machine compiler and code generator. It provides a small DSL that you can use to describe a state machine and the transitions between the states, which will be compiled to create a number of classes, and then all you have to do is provide the code for the actions. Here, actions, states, and transitions are defined terms that are described in the documentation for the smc tool.
Earlier this year, when I was looking for work, I got the same recursive maze problem three interviews in a row. Recursion is cute and clever, but you generally want to use iterative solutions in production.
I had trouble posting to my Rails server from an Angular controller until I found this SO post. In
/app/controllers/application_controller.rb I added the following code.
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
cookies['XSRF-TOKEN'] = form_authenticity_token if protect_against_forgery?
# In Rails 4.2 and above
super || valid_authenticity_token?(session, request.headers['X-XSRF-TOKEN'])
In this post, I’ll discuss options for building a watercolor kit, and provide some introductory reading material.
I started working in watercolor in 2016. I heard the quote by Annie Dillard, “How we spend our days is, of course, how we spend our lives.” and thought that I should make an effort to carve out more time for art, before I don’t have any time left to carve. I decided to work more in watercolor because, for me, it strikes a balance between range of expression, time, and space. Also, although I’ve done art my whole life, I’ve tended to shy away from color because of it’s difficulty. Focusing on watercolor has allowed/forced me to learn more about color.