Skip to content

Instantly share code, notes, and snippets.

Lawrence Jones lawrencejones

Block or report user

Report or block lawrencejones

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
lawrencejones / logger.rb
Created Sep 6, 2019
Simple logfmt logger in Ruby
View logger.rb
# frozen_string_literal: true
require "logger"
require "values"
module App
module Logger
class ContextualLogger <, :context)
def log(**kwargs)
lawrencejones / 11
Last active May 17, 2019
Stolon sentinel locking up due to etcd
View 11
λ (lab) ~> kl stolon-main-sentinel-backend-stolon-main-sentinel-78d4d597c2lsv -f
2019-05-16T02:57:57.750Z INFO cmd/sentinel.go:1962 sentinel uid {"uid": "f3e6c1b3"}
2019-05-16T02:57:57.850Z INFO cmd/sentinel.go:80 Trying to acquire sentinels leadership
2019-05-16T07:19:41.806Z ERROR cmd/sentinel.go:100 election loop error {"error": "lost watcher waiting for delete"}
2019-05-16T07:19:51.806Z INFO cmd/sentinel.go:80 Trying to acquire sentinels leadership
2019-05-16T07:25:43.371Z ERROR cmd/sentinel.go:1815 error retrieving cluster data {"error": "context deadline exceeded"}
PC=0x45ae01 m=0 sigcode=0
lawrencejones / 01-disable.bash
Last active May 2, 2019
Upgrade process for PG9.4 -> 11
View 01-disable.bash
#!/usr/bin/env bash
all-databases() {
cd /tmp && sudo -u postgres psql -U pgbouncer pgbouncer -c 'show databases;' -p 6432 | grep -Po '^ gc_\S+'
disable-databases() {
xargs -n1 -I _DATABASE_ sudo -u postgres psql -U pgbouncer pgbouncer -p 6432 -c 'disable _DATABASE_;'
lawrencejones / verify_commit.go
Created Mar 28, 2019
Script to verify no data loss with a HA PG cluster
View verify_commit.go
package main
import (
lawrencejones / create-database
Created Jan 18, 2019
Create a MySQL replica from external host in GCP
View create-database
#!/usr/bin/env bash
ACCESS_TOKEN="$(gcloud auth print-access-token)"
# Parameters
REGION="europe-west1" # "europe-west4"
DATABASE_TIER="D2" # "db-n1-standard-2"
lawrencejones / output
Last active Jan 14, 2019
Example of exporting Route53
View output
λ (lab) ~> aws route53 list-resource-record-sets --hosted-zone-id Z1B93ASNBC3G25
"ResourceRecordSets": [
"Name": "",
"Type": "A",
"TTL": 300,
"ResourceRecords": [
lawrencejones / main.go
Created Jan 9, 2019
Annotate configmaps with author
View main.go
package main
import (
kitlog ""
lawrencejones / looker.bash
Last active Dec 13, 2018
Looker API helper
View looker.bash
# Source this file ($ source <file-namne>) in your terminal to load all the
# functions.
# First run the looker-login using the client ID and client secret to generate
# an API token. Once you have your API token, run:
# $ export LOOKER_API_TOKEN=<your-token>
# This will enable use of looker-curl.
lawrencejones / verify.rb
Created Dec 12, 2018
Fiddling with secret key svc2svc auth
View verify.rb
#!/usr/bin/env ruby
require "securerandom"
require "benchmark"
require "openssl"
class Svc2Svc
def initialize(count: 1000)
@keys = { SecureRandom.hex }
@services = keys.each_with_object({paysvc_live: [], paysvc_sandbox: [], banking: []}) do |key, services|
You can’t perform that action at this time.