Skip to content

Instantly share code, notes, and snippets.

@digitalronin
digitalronin / git-fresh
Created August 19, 2020 14:04
Ensure my working copy is up to date
#!/bin/bash
# `git fresh`
# Ensure my working copy is an up to date copy of master
set -euo pipefail
git checkout main || git checkout master
git pull
@digitalronin
digitalronin / kd
Last active August 19, 2020 14:01
kd - simple fuzzy-find directory bookmarking tool (I didn't write this, but I can't remember where I got it from)
# shellcheck shell=bash
# vim: ft=sh
# worKDir
function kd() {
local conf="$HOME/.kdrc"
if [[ $# -eq 0 ]]; then
local candidate="$PWD"
while [[ -n "$candidate" ]]; do
for file in Gemfile Procfile .git; do
#!/usr/bin/env ruby
# Script to iterate through our Heroku account to find out what's there
#
# You need to have the heroku command-line tool installed, run `heroku login`
# and authenticate as an admin user of the Heroku account.
require "open3"
require "json"
require "date"

Monolith to Microservices with Kafka Streaming Data Connector

If you're a team developing and maintaining a software [monolith], there's a good chance you're considering or planning a move to an architecture based around [microservices]. I'm not going to go into the various trade-offs involved in that decision in this article, because instead I want to focus on one specific technique that might help you make the transition.

It's relatively straightforward to build a system around microservices if you're starting from scratch, but it can be a lot harder to plan and manage a transition from an existing monolith. The kinds of changes involved can be substantial, and it's hard to keep a live system running smoothly while you fundamentally change how it works.

It's a big shift from an [ACID]-compliant database to a distributed architecture based on [eventual consistency], and keeping data consistent during a long migration, when different information is held in different parts of your system can be particul

Managing secrets with git-crypt

In this article, I'm going to show you how to use git-crypt so that you can safely keep your application secrets in your source code repositories, even if they're public.

The problem with application secrets

Many software projects use secrets, usually to access an external resource. I'm talking about things like database credentials, or keys to external APIs. Your application needs these keys at runtime, so you need to be able to provide them when you deploy your application, or as a step in preparing your deployment environment.

For example, if your application is hosted on Heroku, you might provide an API key to your heroku application using a command like this:

#!/usr/bin/env ruby
# Look for A & TXT records in the main Live-1 Route53 HostedZone, and delete any which
# do not match an existing ingress in the kubernetes cluster
require "open3"
require "json"
require "enumerator"
require "pry-byebug"
create table sample (
id integer,
first_name varchar(255),
last_name varchar(255),
email varchar(255),
gender varchar(255),
ip varchar(255)
);
title weight last_reviewed_on review_in
Onboarding into the Cloud Platform Team
9000
2020-03-31
3 months

<%= current_page.title %>

People Team

Migrating a Rails applicaiton from mysql to postgres

Copy the data

$ brew install pgloader

Fix mysql authentication problem as per: dimitri/pgloader#782 (comment)

#!/usr/bin/env ruby
# These env vars must be in scope before running this script
#
# export AWS_PROFILE=moj-cp
# export TF_VAR_cluster_name="live-1"
# export TF_VAR_cluster_state_bucket=cloud-platform-terraform-state
# export TF_VAR_cluster_state_key="cloud-platform/live-1/terraform.tfstate"
#