Skip to content

Instantly share code, notes, and snippets.

View jon-ruckwood's full-sized avatar

Jonathan Ruckwood jon-ruckwood

  • London, England
View GitHub Profile
@jon-ruckwood
jon-ruckwood / config.ini
Last active October 5, 2021 10:17
Git config and hook to add trailer automatically to commit messages
# Requires branch named in format `zz/key-1234/some-short-desc
# Results in commit with trailer:
# TASK: KEY-1234
#
[trailer "task"]
key = "Task: "
ifExists = replace
ifMissing = add
cmd = git rev-parse --abbrev-ref HEAD | awk -F/ '{ print toupper($2) }'
@jon-ruckwood
jon-ruckwood / github-composite-action-example.yaml
Created August 11, 2021 08:35
Example of using "uses" in a composite action
# .github/actions/composite-example/action.yaml
runs:
using: composite
steps:
- uses: actions/setup-node@v2
with:
node-version: "16"
- shell: node {0}
run: |
console.log(process.version);
@jon-ruckwood
jon-ruckwood / kubernetes_tips_and_tricks.md
Created June 1, 2021 15:30
Tips and tricks for Kubernetes

Kubernetes Tips & Tricks

Easier handling of multiple configurations

  1. Place configs under ~/.kube/contexts, i.e.
$ tree ~/.kube/contexts
/Users/jon/.kube/contexts
├── config-dev
@jon-ruckwood
jon-ruckwood / Java14RecordExample.java
Created April 25, 2020 11:12
Compile with `--enable-preview`
public class Java14RecordExample {
public static void main(String[] args) {
var p = new Person("Boz", "Scaggs");
System.out.println("toString(): " + p);
System.out.println("---");
System.out.println("Howdy " + p.name() + "!");
}
}
@jon-ruckwood
jon-ruckwood / RecordExample.java
Created January 17, 2020 11:55
Java 14 record example, compile and run with `--enable-preview`
public class RecordExample {
public static void main(String[] args) {
Interval i = new Interval(1, 2);
System.out.println("interval: " + i);
}
record Interval(int begin, int end) {
}

Keybase proof

I hereby claim:

  • I am jon-ruckwood on github.
  • I am jonruckwood (https://keybase.io/jonruckwood) on keybase.
  • I have a public key ASD48-tGDeaPKLmIraDUETGDE-w5eHJnNvkHlpRX1w377go

To claim this, I am signing this object:

package main
import (
"strings"
"golang.org/x/tour/wc"
)
func WordCount(s string) map[string]int {
counts := make(map[string]int)

Dependencies

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>io.zipkin.brave</groupId>
                <artifactId>brave-bom</artifactId>
                <version>5.6.0</version>
                <type>pom</type>
                <scope>import</scope>
@jon-ruckwood
jon-ruckwood / JUnit5IgnoreException.java
Created May 16, 2018 12:16
Mini JUnit5 extension simulating the useful expected exception functionality of JUnit4
@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
public @interface IgnoreException {
Class<? extends Throwable>[] value();
}
public class IgnoreExceptionExtension implements TestExecutionExceptionHandler {
@Override
public void handleTestExecutionException(ExtensionContext context, Throwable throwable) throws Throwable {
IgnoreException annotation = context.getRequiredTestMethod().getAnnotation(IgnoreException.class);
@jon-ruckwood
jon-ruckwood / Java9AndJava10TheKeyPartsNotes.java
Last active May 9, 2018 07:59
Notes on Venkat Subramaniam's Java 9 and Java 10: The Key Parts
// Java 9
// JDK improvements
Stream#takeWhile // `limit` using a predicate, i.e. `break`
Stream#dropWhile // `skip` using a predicate, i.e. `continue`
Stream#iterate // emulate a for-loop with a stream, e.g. (not previously possible)