Skip to content

Instantly share code, notes, and snippets.

Coding stuff

Geoff Hayward GeoffHayward

Coding stuff
View GitHub Profile
View AWS-CloudFront-Invalidate-Cache.txt
# First
aws cloudfront create-invalidation --distribution-id ************* --paths "/example/path/*"
# Then take the invalidation ID from the response and verify the progress
aws cloudfront get-invalidation --id ************* --distribution-id *************
public abstract class ExceptionUtils {
public static <T> T wrapCheckedException(final CheckedExceptionThrowingSupplier<T> supplier) {
T suppliedValue = null;
try {
suppliedValue = supplier.get();
} catch (final Exception originalException) {
return suppliedValue;
GeoffHayward /
Created May 15, 2020
Java: Turning a text/plain response to JSON such that an object mapper can work with a non JSON response
import org.springframework.http.HttpRequest;
import org.springframework.http.client.ClientHttpRequestExecution;
import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.http.client.ClientHttpResponse;
public class PlainTextStatisticHttpRequestInterceptor implements ClientHttpRequestInterceptor {
GeoffHayward / automation-run-again
Last active Feb 9, 2021
Automation: Run Again
View automation-run-again
git commit --amend --no-edit
git push -f

A simple Bash scripts to start and stop an EC2 Windows Server.

The script also updates an RDP sub-domain address on CloudFlare.

The required IAM must include:

    "Version": "2012-10-17",
    "Statement": [
GeoffHayward /
Created Dec 10, 2019
Cucumber Compare two datatables
package step_definitions;
import io.cucumber.datatable.DataTable;
import java.util.ArrayList;
import java.util.List;
View .gitconfig
graph = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
View Docker Restart Policy
# Inspect - Prints out the status for each container's policy
for id in $(docker ps -q); do echo "$id$(docker inspect --format='{{.Name}}' $id)" && docker inspect -f "{{ .HostConfig.RestartPolicy.Name }}" $id && echo "------------"; done
# Update (if unset) - Updates the policy for each container to 'alway' if its policy is unset. It also prints out the status for each container
for id in $(docker ps -q); do echo "$id$(docker inspect --format='{{.Name}}' $id)" && ([ -z "\$(docker inspect -f '{{ .HostConfig.RestartPolicy.Name }}' $id)" ] && docker update --restart=always $id; exit 0 ) && docker inspect -f "{{ .HostConfig.RestartPolicy.Name }}" $id && echo "------------"; done
GeoffHayward / Generic
Last active Aug 20, 2019
java get column of multidimensional array
View Generic
private Object[] getColumn(int address, Object[][] from) {
return -> x[address]).toArray(Object[]::new);
private <T> T[] getColumn(int address, T[][] from) {
return (T[]) -> x[address]).toArray(Object[]::new);
GeoffHayward / Setting up MySQL on Ubuntu 18.04
Last active May 28, 2019
Setting up MySQL on Ubuntu 18.04
View Setting up MySQL on Ubuntu 18.04
sudo apt update
sudo apt install mysql-server
sudo mysql_secure_installation
This seems to lock it down to the Ubuntu root user, therefore login using the Ubuntu root user
and run the following.
sudo mysql -u root
DROP USER 'root'@'%';
CREATE USER 'root'@'localhost' IDENTIFIED BY '';