Posted by: terrylhowe | February 19, 2018

Ansible Dump Variables

I’m often looking for the way to dump the variables available to ansible and I used to have a role just to do that, but sometimes a role is more than you need.  Sometimes just dumping them will do:

- hosts: localhost
      - debug:
          msg: "{{ vars | to_nice_json }}"


Posted by: terrylhowe | February 19, 2018

Permanently Remove Siri etc from Dock

Every time I reboot, siri, maps, etc reappear on the dock and I have to remove them again.  Very annoying to have apps that I am not using keep showing up on the dock.  To permanently remove them from the dock, disable and enable system integrity protection:

sudo /usr/libexec/PlistBuddy -c "delete:add-app" \
sudo /usr/libexec/PlistBuddy -c "delete:add-doc" \
Posted by: terrylhowe | January 26, 2018

The Biggest Problem with Django is the File Layout

The Django file layout is problematic because by default it generates a single,, and Everyone seems to assume that is the way it has to be and these files either get gigantic or code that is model or view code gets thrown in arbitrary helper or utility classes.

Ruby on Rails when you add a generate a new object you get several files. There is generally a model, controller and test file as well as several view files. I could definitely see people arguing that RoR generates too many files, but it is rare to get a file that is unmanageably large. It is also rare that model or view code creeps into other classes compared with Django.

One thing you can do to combat this is just break the files up into smaller files. You do not have to have a single monolithic `` and to maintain compatibility, you can use __all__ in your For example with two models for run and config:

$ ls tasks/models

The file is set up for compatibility if you are willing to maintain that:

$ cat */models/__ini*py
from tasks.models.task_config import TaskConfig
from tasks.models.task_run import TaskRun

__all__ = [
'TaskConfig', 'TaskRun',

The user can still use the models the same way:

from tasks.models import TaskConfig

The same is true of the other monolithic files. There are other advantages to breaking this single file for everything rule too:

  1. You are a bit less likely to have merge conflicts
  2. You are a bit more likely to actually add tests if there is plenty of room or an empty file
  3. It is a lot easier to understand
Posted by: terrylhowe | January 25, 2018

Member and Method Names Static vs Dynamic

Naming members and methods of classes is a little different when you bounce from statically to dynamically typed languages.  When working in a statically typed language, good member and method names are generally as short as possible.  For example, if you had a BankAccount class, the account number gets stored in a member named number and adding money to the account is done with a deposit() method.  If you are programming with a dynamically typed language where you can’t necessarily find all the usages of these members and methods, you need names that are a lot more unique.  You would be better off storing the account number in a member named something like bank_account_number and using a method like bank_deposit().  These names seem annoyingly redundant, but using specific names make it way easier to find all the usages of the members and methods.

Posted by: terrylhowe | January 19, 2018

Delete merged git branches

How to delete merged git branches:

git branch -a --merged |
egrep -v "(^\*|master|develop|stage)" |
sed -e 's,remotes/origin/,,'|
while read BRANCH
 git push --delete origin $BRANCH
Posted by: terryhowe | November 9, 2017

Django Version

I’m always trying to remember how to check the Django version, so it goes like this:

python shell <<!
import django
Posted by: terryhowe | November 8, 2017

Rendering erb

I’m always forgetting the erb syntax for what exactly renders a line and what does not. I really didn’t want to be working on erb today, but here I am doing just that:

<% %>

Executes the ruby code within the brackets.

<%= %>

Prints something into erb file.

<% -%>

Avoids line break after expression.

I know I’ve done this a couple times where I’m confused by this error message and searching the web for the solution.  All I see is a bunch of purple links because I’ve been here before.  The problem is some import somewhere and it is outlined in the stack trace right there.  Look at the entire stack trace not just that message.

django.core.exceptions.AppRegistryNotReady: Apps aren’t loaded yet.

Posted by: terryhowe | July 28, 2017

Migrating from Legacy pypi Python Package Upload

It is pretty hilarious how bad the instructions are from pypi on uploading from the legacy interface.  There are better instructions on how to use the legacy interface than how to use the new interface.  Presumably, your .pypirc looks something like:

index-servers =


Supposedly, all you need to do to remove the repository entry.

Posted by: terryhowe | July 14, 2017

Mysql connects to socket instead of localhost

The funny thing about running the mysql client -h localhost is it tries to connect to the socket if you do that.  If you actually want to connect to localhost, you need to specify

Older Posts »