Garth Kerr
  • Home
Garth Kerr

Garth Kerr

23 posts •
Bash

Parsing environment variables with JQ

JQ provides this nifty env input that enables you to reference environment variables using the JQ style query syntax. # prints all envs in JSON format jq -n env And you can use piping

Garth Kerr Garth Kerr
Bash

Bash capture STDOUT to variable without redirecting

Capture CLI to a variable in a bash script without redirecting STDOUT. OUTPUT=$(command --foo "${BAR}" | tee >(cat - >&2))

Garth Kerr Garth Kerr
Bash

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

Garth Kerr Garth Kerr
Bash

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

Garth Kerr Garth Kerr
Ansible

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

Garth Kerr Garth Kerr
Git

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,

Garth Kerr Garth Kerr
Gearman

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

Garth Kerr Garth Kerr
Bash

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

Garth Kerr Garth Kerr
SSL

OpenSSL CSR generation in a single command

If you need to generate a CSR, OpenSSL has a helpful prompt interface for completing the required fields one at a time. However, if you are using automation, collecting STDIN is not always

Garth Kerr Garth Kerr
Nginx

Transport security for HTTP/2 protocol with Nginx

With Google sunsetting the SPDY protocol, and broad support for HTTP/2 shipping with most modern browsers, I began investigating moving our SPDY support over to HTTP/2. Nginx recently released official support

Garth Kerr Garth Kerr
Ansible

Meaningful hostnames with Ansible

Like anyone who spends a good deal of time in a terminal window, switching between machine instances is fairly commonplace. I keep a persistent tmux session open to manage a handful of connections.

Garth Kerr Garth Kerr
PHP

Globally install Composer on OS X 10.11 El Capitan

Update: this also works as expected with macOS Sierra. The El Capitan release of OS X introduces a more strict security model around the concept of root level access to the underpinnings of

Garth Kerr Garth Kerr
PHP

Alias a version for Composer

I previously published instructions on using a specific commit hash for Composer. This is a quick and useful way for referencing the most recent version of our work during the development process. In

Garth Kerr Garth Kerr
AWS

Multiple SSL domains on AWS ELB with Nginx

Is it possible to serve multiple domains (each with a unique SSL certificate) via HTTPS behind a single load balancer on AWS? Yes you can; with TCP and Proxy Protocol. Proxy Protocol allows

Garth Kerr Garth Kerr
JavaScript

Logging client-side JavaScript errors

JavaScript interaction is not usually an option for most modern websites (try accessing some of your favorite sites with JavaScript disabled). Given the matrix of browsers, devices, software versions and extensions, exhaustive testing

Garth Kerr Garth Kerr
PHP

GZIP BSON in MongoDB with PHP or Node.js

I recently needed to store a large number of files (300M, 3-4TB GZIP) on a distributed number of systems, while maintaining index information about each file in MongoDB. Accessing and modify large blocks

Garth Kerr Garth Kerr
PHP

PHP 5.6 on Ubuntu 14.04 with PPA

PHP 5.6 has been in the wild for about a month now. As of October, the major version has received its first patch release 5.6.1 to address several bugs detailed

Garth Kerr Garth Kerr
Apache

Removing response headers with Apache

Some applications will set erroneous headers that have little to no value to the client. In some cases the header may even pose a security risk by exposing environment/version information. In the

Garth Kerr Garth Kerr
PHP

First look: Ubuntu Server 14.04 LTS

I'm always excited to kick the tires of a new supported release (LTS) of Ubuntu. In most cases I will be using the LTS image for 2-3 years to come, possibly longer. Stateless

Garth Kerr Garth Kerr
Apache

Limiting access to ProxyPass Apache resources

The Apache Directory directive allows you to limit access to particular routes, ports, etc. for virtual hosts. However when we are proxying requests, directory path permissions are irrelevant. To limit access to proxied

Garth Kerr Garth Kerr
PHP

Using a specific commit hash for Composer

The way Composer handles versioning with package links is incredibly flexible for managing dependencies in the various stages of development. If we are releasing updates to a shared library or service, we may

Garth Kerr Garth Kerr
PHP

PHP one-line optimizations with Apache on Ubuntu

There are a couple changes I immediately make to the default php.ini configuration when setting up an application server. Before making any modifications, we should backup the package maintainer's version of the

Garth Kerr Garth Kerr
Apache

Enabling http proxy module in Apache on Ubuntu

The Apache proxy module is disabled by default in Ubuntu. Having unused modules enabled has both performance and security implications. That said, in this example we are using: Apache 2.2 Ubuntu 12.

Garth Kerr Garth Kerr
Garth Kerr © 2025
Latest Posts Twitter