Skip to content

Instantly share code, notes, and snippets.

@jiffle
jiffle / gradle-cheatsheet.gradle
Last active October 5, 2017 07:54 — forked from jahe/gradle-cheatsheet.gradle
Gradle File with Many Common Examples
// imports a couple of java tasks
apply plugin: "java"
// List available tasks in the shell
> gradle tasks
// A Closure that configures the sourceSets Task
// Sets the main folder as Source folder (where the compiler is looking up the .java files)
sourceSets {
main.java.srcDir "src/main"
@jiffle
jiffle / GradleCheatsheet.md
Last active April 14, 2024 10:00 — forked from qrman/GradleCheatsheet.md
Cheatsheet of Gradle Commands and Config

Command Cheatsheet

  • Convert Maven build to gradle

    gradle init

  • Initialise new project folder structure (Java example)

    gradle init --type java-library

@jiffle
jiffle / Java 8 Cheatsheet.md
Last active February 17, 2017 15:53
Cheatsheet for Java 8 Lambda syntax

Java Lambda Syntax

As an expression

(Person p) -> p.getGender() == Person.Sex.MALE
    && p.getAge() >= 18
    && p.getAge() <= 25

As a local variable

@jiffle
jiffle / Java 8 Patterns Cheatsheet.md
Last active May 3, 2022 15:48
Cheatsheet of Standard Design Patterns implemented using Java 8 Lambdas

Design Patterns implemented in Java 8

These patterns are implemented using Java 8 Lambdas (together with Project Lombok annotations).

Factory Pattern

Factory I : No Parameter Constructor

Enum class:

@jiffle
jiffle / Spock Cheatsheet.md
Last active May 9, 2024 14:19
Spock Useful Patterns Cheatsheet

Spock Useful Patterns Cheatsheet

Adding sequences of behaviour to Mocks and Stubs

The >>> operator allows a sequence of values to be returned:

myMock.someCall() >>> ['first value', 'second value', 'third value', 'etc']

This returns each string in turn. Behaviour (such as throwing exceptions) in closures cannot be used by this operator.

The &gt;&gt; operator allows value or behaviour (closures) to be returned

@jiffle
jiffle / Effective Email Cheatsheet.md
Last active February 20, 2023 10:30
Effective Email Style Cheatsheet

Military Style For Effective Email Communications

The military structure their communications for maximum clarity and conciseness. These are the key points to write emails in an fffective manner:

1. Prefix Email subject with keyword

Format: STATUS - Message Title

Status keywords:

@jiffle
jiffle / Evolving REST Services.md
Last active October 13, 2022 09:33
Evolving REST Services and Backward Compatibility

Evolving Rest Services and Backward Compatibility

My aim is to define a set of rules that can be used to decide whether an incremental data change is backwardly compatible or not, list things to beware of for a particular change, and mitigations that can be put in place.

Clearly it is assumed that the services will be using API versioning, and that a major API version number change would allow any required change to that API. The scope of this document is to explore what changes can be made within a single API version.

Main Release Management models

There are four main release management models, each of which has its own requirements and challenges in versioning the APIs.

@jiffle
jiffle / Kotlin-Nullability-Cheatsheet.md
Last active March 28, 2023 12:18
Kotlin Nullability Cheatsheet

Kotlin provides significantly improved support for nullable (and non-nullable) types.

These are all the language and Kotlin library features that help support working with nullable types:

Fundamentals

Non-nullable type declaration:

var a: String = "abc"
@jiffle
jiffle / kotlin-language-cheatsheet-part1.md
Last active March 3, 2018 15:28 — forked from dodyg/gist:5823184
Kotlin Programming Language Cheat Sheet Part 1

Kotlin Programming Language - Part 1

Kotlin language website is at https://kotlinlang.org.

All the codes here can be copied and run on Kotlin online editor.

Basics

  • You do not need ; to break statements.
  • Comments are similar to Java or C#, /* This is comment */ for multi line comments and // for single line comment.
@jiffle
jiffle / Kotlin Coroutines Cheatsheet.md
Last active June 20, 2018 05:16
Guide on Kotlin Coroutines for muggles

Core Language Methods

Block method Returns Thread Notes
launch Job From Pool parameter
async Deferred From Pool parameter Use await to get result
withTimeout value from Coroutine From Pool parameter
thread Null New thread Not a coroutine, but same as launch

Launch Methods