Skip to content

Instantly share code, notes, and snippets.

View rnorth's full-sized avatar

Richard North rnorth

View GitHub Profile

Testcontainers general principles

Tips for developing/maintaining Testcontainers forks:

  • Some general tips (most important at the top):
    • Have an easy-to-use API that is simple for people to use and read
    • Make common tasks intuitive and nice to use. Make less common tasks possible, but not at the expense of the common tasks. It's better not to support a niche feature than to degrade the common features.
    • Guide people towards doing sensible things, rather than letting them fall into traps.
    • Be idiomatic for the language and framework
  • Give users coarse-grained tools rather than a fine-grained bag of components to figure out how to assemble
@rnorth
rnorth / gist:7019921
Created October 17, 2013 06:23
Quick example of using Quasar channels. Must run using the Quasar JVM agent. https://github.com/puniverse/quasar/ Example output: 'Hello 1' -> 'Hello 2' -> 'Hello 3' -> 'Hello 4' -> 'Hello 5' -> 'Hello 6' -> 'Hello 7' -> 'Hello 8' -> -> 'Hello 1' 'Hello 9' -> -> 'Hello 2' 'Hello 10' -> -> 'Hello 3' 'Hello 11' -> -> 'Hello 4' 'Hello 12' -> -> 'He…
import co.paralleluniverse.fibers.Fiber;
import co.paralleluniverse.fibers.SuspendExecution;
import co.paralleluniverse.strands.SuspendableRunnable;
import co.paralleluniverse.strands.channels.Channel;
import co.paralleluniverse.strands.channels.Channels;
import jsr166e.ForkJoinPool;
import java.util.concurrent.ExecutionException;
import static java.lang.String.format;
cat cp.txt | grep /Users | while read line 115ms
tr ":" "\n"
end | sort | uniq | sed 's/.jar/-sources.jar/g' | while read jar
unzip -p $jar
end | wc -l
@rnorth
rnorth / _notes.md
Last active July 18, 2017 15:20
2.0 API refactor thoughts

Testcontainers v2.0 API changes - idea 1

This is a rough sketch of how a revised API for Testcontainers could look - don't read too much into it.

Key goals:

  • How it works should be simple and obvious for the benefit of users and contributors
  • Don't lose too much in-IDE 'discoverability' of the API when compared with the current implementation
  • Break dependency on JUnit to allow usage with other testing frameworks
  • Have separate APIs for configuring containers and using a running container
package com.example;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testcontainers.containers.BrowserWebDriverContainer;
import org.testcontainers.containers.DockerComposeContainer;
@rnorth
rnorth / mvn-release
Last active September 7, 2016 11:02
Alternative tool for performing Maven Releases - simpler and easier to reason about
#!/usr/bin/env bash
# Maven release helper. Copyright (c) 2016 Richard North <rich.north@gmail.com>
# Usage: mvn-release.sh PROFILES
# where PROFILES should be any maven profile activations to pass through, e.g. `-PprofileA`
#
# Based on this article: https://axelfontaine.com/blog/final-nail.html
#
# IMPORTANT: follow setup steps in that article for required POM configuration settings
set -o errexit
@rnorth
rnorth / bc
Last active August 3, 2016 00:49
Boxcar push notification shell script
#!/bin/bash
# Sends a Boxcar push notification through the Boxcar HTTP API
# Usage examples
# $ bc # Just sends a notification with title 'bc'
# $ bc "Done" # Sends a notification with title 'Done'
# $ echo foobar | bc # Sends a notification with title 'bc' and message body 'foobar'
# $ echo foobar | bc "Done" # Sends a notification with title 'Done' and message body 'foobar'
#
# Expects a file ~/.boxcar to exist with content like
@rnorth
rnorth / pure-theme.fish
Last active May 4, 2016 20:45 — forked from jonathanmarvens/pure-theme.fish
Pure themed prompt for Fish shell, with display of last command duration and time of day
###########################################
# Copyright (c) 2014 Jonathan Barronville #
# Minor tweaks by Richard North #
# License: MIT. #
###########################################
function fish_prompt
set last_command_status $status
echo ''
@rnorth
rnorth / qmvn
Last active February 1, 2016 09:04
qmvn
#!/usr/bin/env bash
# qmvn (quick maven)
#
# Maven wrapper script to accelerate the build of multi-module projects
# This script detects which modules have been modified since the last build, and executes maven in `-amd -pl ...` mode.
# This means only modules with changes to source code or their POMs, or which depend on a changed module, get built.
# See this page for details of how these flags accelerate the build:
# http://blog.sonatype.com/2009/10/maven-tips-and-tricks-advanced-reactor-options/
#
# Authors:
@rnorth
rnorth / hello_ratpack.sh
Created August 28, 2013 20:18
A ratpack web application in a shell script - just requires groovy (2.1+?) and JDK 1.7+ on the local machine.
#!/usr/bin/env groovy
@GrabResolver("http://oss.jfrog.org/artifactory/libs-snapshot")
@Grab("org.ratpack-framework:ratpack-groovy:0.9.0-SNAPSHOT")
import static org.ratpackframework.groovy.RatpackScript.ratpack
ratpack {
handlers {
get {
response.send "Hello ratpack!"