Skip to content

Instantly share code, notes, and snippets.

View rquadling's full-sized avatar
🦍
No hair cutting during Covid19. Things are getting ... hairy!

Richard Quadling rquadling

🦍
No hair cutting during Covid19. Things are getting ... hairy!
  • Exeter, Devon, UK
View GitHub Profile
@rquadling
rquadling / tfdiags.md
Last active December 6, 2022 12:04
Display the diagnostics from Terraform in a tabular form

Terraform Diagnostics Display

As part of the upgrading from v3 to v4 of the Terraform AWS Provider, I needed to see all the places where I needed to do some work. The standard ouput from Terraform doesn't show all the places where work is required. But, luckily, using the -json option, you get access to all of the information.

The following shell script (written and tested in bash, but should be OK as really, it's only terraform, jq, column, and | that's being used) will output a nicely formatted table showing you the

@rquadling
rquadling / Failed
Created May 15, 2020 12:46
Failed and successful install of AWS Cloudwatch Daemon using Ansible
amazon-ebs: TASK [aws_cloudwatch_logs : Install the AWS CloudWatch Logs daemon] ************
amazon-ebs: task path: /tmp/packer-provisioner-ansible-local/5ebe8377-f9d0-f655-9be8-665b6e0204c8/roles/aws_cloudwatch_logs/tasks/install.yml:26
amazon-ebs: changed: [127.0.0.1] => {"changed": true, "cmd": "python /tmp/awslogs-agent-setup.py -n -r eu-west-1 -c /tmp/awslogs.conf", "delta": "0:00:25.998340", "end": "2020-05-15 12:12:01.446602", "rc": 0, "start": "2020-05-15 12:11:35.448262", "stderr": "", "stderr_lines": [], "stdout": "downloading AgentDependencies.tar.gz with urllib
\u001b[0mAgentDependencies/
AgentDependencies/awslogscli/
AgentDependencies/awslogscli/urllib3-1.25.6.tar.gz
AgentDependencies/awslogscli/jmespath-0.9.2.tar.gz
AgentDependencies/awslogscli/colorama-0.3.7.zip
AgentDependencies/awslogscli/idna-2.8.tar.gz
AgentDependencies/awslogscli/awscli-1.11.41.tar.gz
@rquadling
rquadling / terraform_external_assume_role_aws.md
Last active May 7, 2020 22:34
Get autoscaling group desired capacity within Terraform

My use case is to get the current desired capacity of an autoscaling group so that I can use that in the replacement autoscaling group. I've seen a Cloudformation solution, but that required more understanding than I have at the time.

Initially, I had thought that just returning the JSON from awscli would have been enough, but unfortunately, the result for the data_source.external.result is a list of strings. No numbers, arrays, maps, lists.

So inspired by a comment made by Marin Salinas, I found that Terraform can access local files!

In addition, I am using an assumed role to do the work.

@rquadling
rquadling / mb_str_pad.php
Last active September 5, 2023 09:02
Implementation of a multi-byte equivalent of PHP's str_pad function.
/**
* Multibyte String Pad
*
* Functionally, the equivalent of the standard str_pad function, but is capable of successfully padding multibyte strings.
*
* @param string $input The string to be padded.
* @param int $length The length of the resultant padded string.
* @param string $padding The string to use as padding. Defaults to space.
* @param int $padType The type of padding. Defaults to STR_PAD_RIGHT.
* @param string $encoding The encoding to use, defaults to UTF-8.
@rquadling
rquadling / ProMiReD.md
Last active April 23, 2019 09:13
ProMiReD - One of many different ways to manage migrations and code.

ProMiReD

We needed a way to describe our pipeline deployment approach. How and when are things released. In what order do we modify the code and the database when it is not possible to do them all instantly.

And so we came up with this silly acronym. We know there are probably better approaches, but this has worked very well for us. To the point that our continuous integration and deployment pipelines can run all of these unattended, allowing our developers to develop and our reviewers to review and the poor release monkey can retire from running all those releases by hand.

Pro - Protect migrations

As migrations are developed and versioned using the current timestamp, and prior to Phinx 0.8, we needed to make sure that

@rquadling
rquadling / Dockerfile
Last active October 5, 2020 01:52
Adding XDebug to Bitnami's php-fpm container.
# An example Dockerfile to build a Bitnami PHP-FPM minimal container with xDebug and some other extensions installed.
# Please note, I have cobbled this together from limited understanding as well as dissecting the Dockerfiles that
# Bitnami have used.
#
# If you find problems, or suggestions, PLEASE PLEASE help me and the rest of the community with your comments,
# suggestions, fixes, etc. Let's all learn something new!!!!
#
# If you want to contact me directly, then RQuadling at the Google Mail, and I'll be happy to answer any questions.
@rquadling
rquadling / testCalculator.js
Created January 10, 2018 17:54
Nodeunit test
'use strict';
require('../../../bootstrap.js');
require(rootPath + '/src/js/lib/Calculator.js');
var calculatorDataProvider = {
'Empty calculator': {
amountDue: 0.00,
amountTenderedAfterAmountDueSet: 0.00,
changeGivenAfterAmountDueSet: 0.00,
amountTendered: 0.00,
@rquadling
rquadling / hipchat-v1.sh
Created August 24, 2017 15:33
Send an HTML message to HipChat using v1 of the api via cURL
MESSAGE="
<table><thead><tr><td colspan=\"2\"><b>Build starting</b></td></tr></thead>
<tbody>
<tr><td><b>Tag</b></td><td>${build_tag}</td></tr>
<tr><td><b>Built for</b></td><td>${built_for}</td></tr>
<tr><td><b>Built by</b></td><td>${built_by}</td></tr>
</tbody>
</table>
"
curl -s -X POST \

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@rquadling
rquadling / TestUTF8
Last active August 29, 2015 14:18
Testing PHP and unicode output.
@ECHO OFF
SETLOCAL
REM Force UTF8
chcp 65001
REM Call the script again, as chcp doesn't affect THIS context.
CALL :UTF8ready %0
GOTO Done