Skip to content

Instantly share code, notes, and snippets.

View strongoose's full-sized avatar
🦕

Dan Strong strongoose

🦕
View GitHub Profile
@strongoose
strongoose / non_us_pound.md
Last active April 28, 2020 09:03
Karabiner-Elements complex rule for non_us_pound

This Karabiner-Elements config catches non_us_pound and shift + non_us_pound keystrokes and sends right_option + 3 and shift + `, respectively, resulting in the key working as expected for UK-localised OSX. This is primarily useful when using standard PC keyboards with a Mac.

Add the json block below to ~/.config/karabiner/karabiner.json under profiles.complex_modifications.rules:

{
    "description": "Hack for correct non_us_pound behaviour",
    "manipulators": [
        {
            "from": {
                "key_code": "non_us_pound"
@strongoose
strongoose / README.md
Last active November 14, 2021 20:07
restic/systemd backups

Restic backups with systemd timers

Restic is a backup service which supports a bunch of cloud backends and incremental backup.

The files in this gist set up scheduled systemd backups using restic to Backblaze B2.

Setup

Install the files:

/etc/systemd/system/backup.service
@strongoose
strongoose / fix-module-providers.md
Last active February 25, 2019 11:54
Instructions for fixing terraform providers in child modules

Fix terraform providers within child modules

The problem

In terraform 0.11.x, providers within child modules are no longer properly supported, e.g. attempting to remove a module which contains the aws provider will result in the following error:

module.<module_name>.<resource>.<resource_name>: configuration for module.<module_name>.provider.aws is not present; a provider configuration block is required for all operations
@strongoose
strongoose / log-json.cljs
Last active February 12, 2019 17:14
ClojureScript: log a JSON object
(defn log-json [obj]
((.-log js/console) (.stringify js/JSON (clj->js obj))))
@strongoose
strongoose / update-packer
Created December 4, 2018 10:38
Packer update script
#!/bin/bash
set -euo pipefail
err() {
1>&2 echo "$@"
exit 1
}
cleanup() {
@strongoose
strongoose / tfsetup.md
Last active February 6, 2019 11:06
Terraform setup

Install terraform with tfenv

brew install tfenv
tfenv --help
tfenv install latest
terraform --version

Install aws-profile

brew install python3

#! /usr/bin/env python
'''
Shrink an elasticsearch index my first moving it to a single node, then calling
the shrink API.
'''
import argparse
import logging
import random
import time
@strongoose
strongoose / source-profile.sh
Last active February 11, 2019 11:47
Export environment variables populated by aws-profile into current shell session
useaws () {
# Usage: useaws <profile-name>
# Exports AWS environment into the current shell
profile=$1
for assignment in $(aws-profile -p "$profile" env | grep '^AWS'); do
export "${assignment?}"
done
}
clearaws () {
2017/02/14 15:21:06 [INFO] Terraform version: 0.8.6 df4bcf64828598a25bd41f00470b2ab3a66f3169
2017/02/14 15:21:06 [INFO] CLI args: []string{"/opt/terraform/terraform-0.8.6", "apply"}
2017/02/14 15:21:06 [DEBUG] Detected home directory from env var: /home/dan
2017/02/14 15:21:06 [DEBUG] Detected home directory from env var: /home/dan
2017/02/14 15:21:06 [DEBUG] Attempting to open CLI config file: /home/dan/.terraformrc
2017/02/14 15:21:06 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2017/02/14 15:21:06 [DEBUG] Detected home directory from env var: /home/dan
2017/02/14 15:21:06 [DEBUG] vertex "module.asg": static expanding
2017/02/14 15:21:06 [DEBUG] DestroyEdgeInclude: Checking: aws_launch_configuration.launch_configuration
2017/02/14 15:21:06 [DEBUG] DestroyEdgeInclude: Checking: module.asg.aws_cloudformation_stack.multi_zone_rolling_upgrade_asg
@strongoose
strongoose / template-initial-create.log
Created February 14, 2017 16:22
template debug logs
2017/02/14 15:03:37 [INFO] Terraform version: 0.8.6 df4bcf64828598a25bd41f00470b2ab3a66f3169
2017/02/14 15:03:37 [INFO] CLI args: []string{"/opt/terraform/terraform-0.8.6", "apply"}
2017/02/14 15:03:37 [DEBUG] Detected home directory from env var: /home/dan
2017/02/14 15:03:37 [DEBUG] Detected home directory from env var: /home/dan
2017/02/14 15:03:37 [DEBUG] Attempting to open CLI config file: /home/dan/.terraformrc
2017/02/14 15:03:37 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2017/02/14 15:03:37 [DEBUG] Detected home directory from env var: /home/dan
2017/02/14 15:03:37 [DEBUG] vertex "module.asg (orphan)": static expanding
2017/02/14 15:03:37 [DEBUG] DestroyEdgeInclude: Checking: aws_launch_configuration.launch_configuration
2017/02/14 15:03:37 [DEBUG] No diff, not a noop