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

Posted by: terryhowe | June 29, 2017

Automating Jenkins Configuration

What makes automating configuration of Jenkins so hard is there are so many ways to do it.  The easy and mindless way is to configure up a jenkins server and save xml configuration files.  To recreate the configuration you just need to automate the install and copy in the configuration file.  This works great until things start getting complicated like maybe you want to configure a job.  There are a lot of files associated with a single job.

Another approach is to use the Jenkins CLI which is great for some things, but you will quickly find that it is very limited.  There are a lot of things that cannot be configured the CLI.

Yet another approach is to use the web UI to set various configuration values.  This works well for some things, but not everything is available through that interface.

If you start on any of these paths you most likely end up with a combination of all three, but the best answer is to just use the groovy as much as possilble.  You may need to use some of the other approaches, but groovy is by far the comprehensive and it will be easier to support.

I’m going to post up some examples on github for automating Jenkins with groovy using ansible.

Posted by: terryhowe | June 29, 2017

My First Node.js Package

I’ve been trying out a lot of different Node frameworks lately and to get to know the frameworks, I’ve been implementing a text 3D maze for each one.  I tried out React, Meteor, and Express.  Each one of these uses the exact same text rendering logic so I decided to use a node package to share the code across projects.

Which happened to be my first Node.js package.  I’d like to expand the project so that it would be useful as a simple text maze out of the box.  Right now it expects you to create a database of rooms that represent the maze.  Ideally the user would pass a reference to a database and it would be able to render a maze from that.

Posted by: terryhowe | June 29, 2017

Redis Test Drive

I’ve wanted to test drive Redis for a while.  It seems like often when I’m standing up some application it uses Redis, so what is all the hype about.  I went through the tutorial today and wrote a simple application.  Initially I was not terribly impressed since the types of data structures you can store are pretty simple.  There are several different basic data structures that you can use like a list, set, hash,… but each one is pretty much name value.  What I loved about Mongo is you can jam a complex data structure in and get it out and one shot and Redis doesn’t do that.  What is cool about it is the speed for data set and get since it is best used as a replacement for something like memcache.  I also like the idea of simple pub/sub messaging for simple IPC.

Posted by: terryhowe | June 29, 2017

Dependency Injection for Testable Code

One of the easiest ways to make code testable is to use dependency injection.  For example if you need to create an object with some application level configuration you could either have your configuration class as a singleton or pass the configuration into to the class constructor.  If you pass the configuration into the class with dependency injection, it is much easier to test.  Your test code can create various mock configuration classes to test various scenarios.  Sometimes I feel making code testable causes me to make different design decisions, but I think having easily testable code is more valuable.


Posted by: terryhowe | June 10, 2017

Ubuntu 16.04 Headphones Not Working

I get into  a state sometimes where the headphones just ill not register.  I think it is some lock file that prevents the headphones from being detected.  To fix this:

alsactl restore

I think the key thing is to boot the PC with the headset plugged in and first attempt to plug/unplug if they do not work.  If that fails, try the above command.

Older Posts »