Skip to content

Instantly share code, notes, and snippets.

@clarkdave
clarkdave / rabbitmq-queue-metrics.rb
Last active November 24, 2020 16:45
Monitoring thousands of queues with Datadog
#!/usr/bin/env ruby
require 'datadog/statsd'
require 'json'
statsd = Datadog::Statsd.new('localhost', 8125)
queue_fields = %w(
consumer_utilisation
consumers
@clarkdave
clarkdave / sorbet_sigil.rb
Last active September 3, 2023 14:31
RuboCop / Sorbet sigil rule
# typed: true
# @prettier
require 'sorbet-runtime'
# Put this somewhere like lib/rubocop/cop/lint/sorbet_sigil.rb and then
# require it in .rubocop.yml:
#
# require:
# - ./lib/rubocop/cop/lint/sorbet_sigil.rb
@clarkdave
clarkdave / load-balanced-pgbouncer-ecs.tf
Last active March 16, 2023 20:08
[Terraform] Load balanced PgBouncer service on Amazon ECS
#
# Reference implementation of a load balanced PgBouncer service on Amazon ECS
#
# see: https://engineering.loyaltylion.com/load-balanced-pgbouncer-service-on-amazon-ecs-f02120d1733e
#
resource "aws_lb" "pgbouncer" {
name = "${var.environment}-pgbouncer"
internal = true
load_balancer_type = "network"
@clarkdave
clarkdave / createPages.ts
Created April 15, 2018 13:11
TypeScript + Gatsby node API
import { resolve } from 'path'
import { GatsbyCreatePages } from './types'
const createPages: GatsbyCreatePages = async ({
graphql,
boundActionCreators,
}) => {
const { createPage } = boundActionCreators
const allMarkdown = await graphql(`
@clarkdave
clarkdave / multi-line-regex-grep.md
Created April 5, 2018 22:33
multi line regex grep
brew install pcre2

find . -type f | xargs pcregrep -M 'pattern'
@clarkdave
clarkdave / link.md
Last active November 14, 2017 14:01
macOS British PC keyboard layouts
@clarkdave
clarkdave / ecs-task-events-to-cloudwatch-logs.py
Created June 29, 2017 22:27
(AWS Lambda) Send ECS Task events to CloudWatch Logs
# This lambda function can be linked with CloudWatch events to send Task state changes to
# a CloudWatch Logs stream
#
# This is highly recommended as, in my experience, the API does *NOT* return all state change
# events; this is the only way to reliably see them all
import os
import time
import json
import boto3
@clarkdave
clarkdave / bootstrap-chef-server-12.sh
Last active June 29, 2017 20:07
[CHEF] Bootstrap a Chef Server 12
#!/bin/bash -ex
# Use this script template to bootstrap a Chef Server (version 12)
#
# - bootstraps the Chef server using chef-solo and the official chef-server cookbook
# (https://github.com/chef-cookbooks/chef-server)
# - uses Lego (acme client) to generate and renew an SSL certificate for the server
# - installs the manage (web ui), push jobs and reporting addons (free for < 25 nodes)
# - configures a few sane defaults (no sign ups from web ui)
#
@clarkdave
clarkdave / ecs-interactive-console.sh
Last active August 21, 2024 08:09
ecs-interactive-console
#!/bin/bash -e
##
# Use this annotated script a base for launching an interactive console task on Amazon ECS
#
# more info: https://engineering.loyaltylion.com/running-an-interactive-console-on-amazon-ecs-c692f321b14d
#
# Requirements:
# - `jq` must be installed on both the client and server
##
@clarkdave
clarkdave / keybase.md
Created February 12, 2017 23:28
keybase.md

Keybase proof

I hereby claim:

  • I am clarkdave on github.
  • I am clarkdave (https://keybase.io/clarkdave) on keybase.
  • I have a public key ASAAW7KQ7BqcEQjDD--DhGxAF_Ufz_IT71BmARZuxJotRwo

To claim this, I am signing this object: