Skip to content

Instantly share code, notes, and snippets.

View mtranter's full-sized avatar

Mark Tranter mtranter

View GitHub Profile
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Privacy Policy for "Eleventh Hour" App</title>
</head>
<body>
<h1>Privacy Policy for "Eleventh Hour" App</h1>
<p><strong>Last Updated:</strong> 9th August 2023</p>
@mtranter
mtranter / Program.cs
Last active October 10, 2022 03:02
Producer per message tests
// See https://aka.ms/new-console-template for more information
using System.Text;
using Confluent.Kafka;
class Program
{
class ByteArraySerializer : ISerializer<byte[]>
{
public byte[] Serialize(byte[] data, SerializationContext context)
@mtranter
mtranter / dynamodb_table_v1.tf
Last active December 14, 2021 10:23
Terraform Modules Blog
locals {
key_attributes = [
for k in [var.hash_key, var.range_key] : {
name = k.name
type = k.type
} if k != null
]
gsi_attributes = flatten([
for gi in var.global_secondary_indexes : [
for k in [gi.hash_key, gi.range_key] : {
@mtranter
mtranter / delete-athena-tables.sh
Created December 22, 2020 05:48
Bash script to bulk delete athtena tables
aws glue get-tables --database-name lyne --max-results 100 \
| jq '.TableList[].Name' \
| tr '\n' ' ' \
| xargs -I {} echo "aws glue batch-delete-table --database-name lyne --tables-to-delete {}" \
| sh -
@mtranter
mtranter / circle.yml
Created May 13, 2020 04:01
Terragrunt Orb - Draft
version: 2.1
description: Publish Infrastructure with terragrunt
orbs:
terragrunt:
commands:
plan:
parameters:
target_dir:
type: string
@mtranter
mtranter / programIO.scala
Last active March 14, 2019 00:02
Death of Tagless Final - Exploration of some ideas from here: https://skillsmatter.com/skillscasts/13247-scala-matters
package yfp.io
import cats.effect.IO
import cats.MonadError
import cats.implicits._
import yfp.ContravariantKleisli
import scala.util.Try
trait Persistence {
@mtranter
mtranter / App.scala
Created January 11, 2019 23:19
Pure FP Scala Example
package com.trizzle
import cats.effect.IO
import cats.implicits._
import cats.{Applicative, Monad, MonadError}
import org.http4s.{Response, Status}
// Error ADT
sealed trait InvalidTopupReason
case object InvalidAmount extends InvalidTopupReason
@mtranter
mtranter / DynamoSink.scala
Created September 28, 2018 04:31
Dynamo Akka Streams
import akka.Done
import akka.stream.stage.{AbstractInHandler, GraphStage, GraphStageLogic}
import akka.stream.{Attributes, Inlet, SinkShape}
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBAsync
import com.amazonaws.services.dynamodbv2.model.{BatchWriteItemRequest, PutRequest, WriteRequest}
import com.gu.scanamo.{DynamoFormat, Table}
import scala.collection.JavaConverters._
import scala.concurrent.Future
@mtranter
mtranter / expr.scala
Created May 29, 2018 23:09 — forked from calincru/expr.scala
Expression problem in Scala
// The expression problem is a new name for an old problem. The goal is to
// define a datatype by cases, where one can add new cases to the datatype and
// new functions over the datatype, without recompiling existing code, and while
// retaining static type safety (e.g., no casts).
// (Philip Wadler)
import scala.language.implicitConversions
object ExpressionProblem extends App {
@mtranter
mtranter / TaskMonad.cs
Created May 21, 2018 02:17
C# Task Monad(ish) - A POC.
using System;
using System.Reflection;
using System.Threading.Tasks;
namespace TaskMonad
{
public static class TaskMonad
{
public static Task<B> Select<A, B>(this Task<A> task, Func<A, B> f) => task.ContinueWith(t => t.IsCompleted ? f(t.Result) : throw t.Exception);