Search JSON array with JQ

JQ is a powerful command-line JSON processing tool. It's super fast (C), provides solid documentation, and is easy to use. In this example, given a JSON object from a file, curl response; we look through an array nested inside an object, and return a matching object within the array. I…

Iterating over an array of bash variables

I had a requirement for a bash script to check for required variables before running a function. Rather than creating a conditional block for each required variable (or in my case, needing to dynamically change them), let's do something that's more terse and maintainable. The example covers a few bash…

Using Ansible templates to maintain partial file blocks

Ansible provides some excellent utilities for maintaining single lines and partial blocks of text. Both modules have support for handling template and fact variables, and a variety of options to support your use case. Here are a couple of examples using each module. Using the lineinfile module for a single…

Delete multiple git branches matching a prefix

Important: this is a potentially destructive command. Please proceed cautiously and at your own risk. I'll sometimes leave local git branches around a bit longer than I should. And, depending on your workflow, you may occasionally have a handful of ephemeral branches that need to be cleaned up. In this…

Install PHP 7 on Ubuntu 14.04 with Gearman support

PHP 7 has been out long enough now that it has seen a couple of patch releases, which is about the time I will start evaluating an upgrade. PHP 7 can have some significant performance benefits from previous versions, so I was eager to give it a try. With the…

Bash completion for Consul nodes on Ubuntu

After making the jump to Ubuntu as my preferred distribution, I've admittedly become addicted to bash completions (aka autocomplete, tab completion, typeahead). Bash completions provide immediate hints for common commands, and even the options associated with them. For example, a quick \t\t (double-tap of the tab key) after the…