Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jiffle
jiffle / refactorsafe-enum-kotlin.kts
Created September 9, 2021 08:09
Refactor-Safe Enum Pattern in Kotlin
import com.fasterxml.jackson.annotation.JsonValue
enum class AccountStatus(@JsonValue val text: String) {
PENDING("Pending"),
ACTIVE("Active"),
EXPIRED("Expired"),
CANCELLED("Cancelled");
companion object {
private val valuesByText = values().associateBy { it.text }
@jiffle
jiffle / strikt-cheatsheet.md
Last active March 2, 2023 15:44
Strikt Cheatsheet

Tricks and tips for using Strikt assertions

Strikt is very powerful, however it is sometimes hard to find particular methods. This is a handy cheatsheet.

Basics

Top-level assertions

expect, expectThat, expectCatching and expectThrows

@jiffle
jiffle / git-tricks.md
Created August 26, 2018 11:07
Git History Rewriting Tricks

Git History Rewriting Tricks

Removing incorrectly committed files from the last commit

This uses a Soft Reset to revert the commit, leaving the commit modifications as local working copy changes:

git reset --soft HEAD^ or git reset --soft HEAD~1

@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

@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-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 / Evolving REST Services.md
Last active July 9, 2024 16:20
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.