Skip to content

Instantly share code, notes, and snippets.

View nealeu's full-sized avatar

Neale Upstone nealeu

  • Wormhole Technology Ltd
  • Cambridge, UK
View GitHub Profile
let dynamoDb = new AWS.DynamoDB.DocumentClient(dynamoParams);
if (process.env.XRAY_DYNAMO) {
const AWSXRay = require("aws-xray-sdk-core");
if (process.env.IS_OFFLINE) {
AWSXRay.setLogger(console);
}
AWS = AWSXRay.captureAWS(AWS);
dynamoDb = AWSXRay.captureAWSClient(dynamoDb);
}
@nealeu
nealeu / docker-compose.yml
Last active August 22, 2019 09:36
Fake metdata.google.internal for GCP images with docker-compose
version: "3"
services:
metadata0:
image: nginx:alpine
volumes:
- ./metadata-db0:/usr/share/nginx/html:ro
command: [nginx-debug, '-g', 'daemon off;']
db0:
@nealeu
nealeu / gist.md
Created June 6, 2024 13:05
Setting log level for com.mongodb.internal.diagnostics.logging.SLF4JLogger doesn't work

Problem

Running with Spring Boot, I get logs like this

c.m.i.d.l.SLF4JLogger : Command "insert" started on database "test" using a connection with driver-generated ID 3 and server-generated ID 13 to localhost:32795. The request ID is 13 and the operation ID is 11. Command: {"insert": "jobExecution", "ordered": true, "txnNumber": 1, "$db": "test", "$clusterTime": {"clusterTime": {"$timestamp": ...}

where c.m.i.d.l.SLF4JLogger refers to com.mongodb.internal.diagnostics.logging.SLF4JLogger.

I want to disable this logging, but if I change log4j2.xml to add:

@nealeu
nealeu / build.gradle
Created June 12, 2024 07:59
Parallel sourceset for Gradle Groovy build avoidance
sourceSets {
testWip {
groovy {
srcDirs = ['src/test/groovyWip']
compileClasspath = sourceSets.test.compileClasspath + sourceSets.main.compileClasspath
runtimeClasspath = sourceSets.test.runtimeClasspath + sourceSets.main.runtimeClasspath
}
}
}
@nealeu
nealeu / spread-changes-to-prev-commit.sh
Last active September 6, 2024 17:17
Copilot (mostly) written script to spread commits back to the previous mod of that file
#!/bin/bash
# This gets the list of files changed in the last commit, resets the last commit,
# stages the changes for each file, and then creates a fixup commit for each file.
# Finally, it rebases the fixup commits onto the earliest commit in the list of unique commit hashes.
# It's useful if you have done a load of fixes in response to a review, and then want to apply
# them to the appropriate commits so that the history makes sense.
ROOT=$(git rev-parse --show-toplevel)
pushd $ROOT
@nealeu
nealeu / Dockerfile
Last active October 17, 2024 08:18
Run MySQL in docker with latency to simulate network
# Dockerfile - saved in ./docker/mysql-with-traffic-control
FROM mysql:5.7-debian
# Add MySQL APT repository key
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B7B3B788A8D3785C
# Install iproute2 for the `tc` command (NOTE ; instead of & because update still complains about key)
RUN apt-get update; apt-get install -y iproute2 && rm -rf /var/lib/apt/lists/*
# Copy the latency script into the container
@nealeu
nealeu / FluentParamTest.java
Created February 27, 2025 15:55
Idea as to how to do Spock like tabular tests - consider how this could be better in Kotlin DSL
package com.example.springsecurityexamples;
import static com.example.springsecurityexamples.Todo.Chain.values;
import java.math.BigInteger;
public class Todo {
void parameterizedTest() {
values(1, "a", BigInteger.TEN)