Skip to content

Instantly share code, notes, and snippets.

View nipafx's full-sized avatar

Nicolai Parlog nipafx

View GitHub Profile
nipafx / .gitconfig
Created August 8, 2023 15:04
My Git aliases
View .gitconfig
st = status --branch --short
look = log --graph --pretty='%C(red)%h%Creset %C(green)%ad%Creset %C(yellow)%<(15,trunc)%an%Creset %s %C(bold blue)%D%Creset' --date=format-local:'%d.%m.%Y %H%M'
look-close = log --graph --pretty='%C(red)%h%Creset %C(green)%cd%Creset %C(yellow)%<(15)%cn%Creset %C(bold blue)%D%Creset%n %C(dim green)%ad%Creset %C(dim yellow)%<(15)%an%Creset %s' --date=format-local:'%d.%m. %H%M'
hist = log --pretty='%C(red)%h%Creset %C(green)%cd%Creset %C(yellow)%<(12,trunc)%an%Creset %s %C(auto)%D%Creset' --date=format-local:'%Y-%m-%d %H:%M'
wat = !git look -15
cd = checkout
patch = -c interactive.diffFilter='diff-highlight | less -FRX --tabs=4' add --patch
unstage = reset HEAD --
unstage-patch = reset HEAD --patch
nipafx /
Last active May 18, 2022 10:00
Non-asyncronous EA Async example
// Two examples [1, 2] from EA Async written without async/await or
// (Completable)Futures as straight-forward blocking code. If the
// callers want to do something concurrently to `Store::buyItem`,
// they just put that call into a new virtual threads.
public class Store {
private final Bank bank = new Bank();
private final Inventory inventory = new Inventory();
nipafx /
Last active July 9, 2021 11:04
Counting Red Nodes in a Colored Tree
import java.util.concurrent.atomic.AtomicLong;
// implementation of
public class Tree {
public static void main(String[] args) {
var tree = new Red(
new Black(
nipafx /
Last active February 21, 2024 16:58
Creating multiline strings in JS, Groovy, Kotlin, and Java

#1 Split "one", "two" across two lines



Onboard JavaScript requires us to break the code formatting.

nipafx /
Created May 27, 2020 07:49
Optional vs null && Stream vs loop
package org.codefx.lab;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.function.Function;
import java.util.function.UnaryOperator;
class Lab {
nipafx / example.xml
Created April 30, 2020 08:53
Configuring Maven's copy-dependencies MOJO
View example.xml
<!-- executed during build -->
<version><!-- currently 3.1.2 --></version>
<!-- with this ID, the command above picks up the config -->
<!-- if `process-sources` doesn't match your needs -->
nipafx /
Last active August 16, 2019 12:02
JPMS Maturity Model

Maturity Model

Libraries, frameworks, and tools (IDEs, build tools) have widely varying support for the JPMS. I would like to create a model that makes it easy to judge a project for what it can and can't (yet) do - both for users and maintainers.

Conditions can usually be split into those for libraries/frameworks and those for tools, but that's not clear cut. Bytecode analysis tools, for example, may fall into both categories. So always look at both categories, and check which conditions apply to a given project.

This is work in progress - feedback welcome!

Level 0 - Denial: Don't break!

nipafx / GridDemoTest.kt
Last active August 21, 2018 14:00
Running Selenium tests once per grid node
View GridDemoTest.kt
@SeleniumGridConfiguration(url = "")
class GridDemoTest {
fun demo(driver: WebDriver) {
val homeUrl = driver.findElement(By.className("img-hyperlink")).getAttribute("href")
nipafx / #1-services-uses
Last active January 12, 2018 15:51
All services used by JDK 9.0.1
View #1-services-uses
nipafx /
Last active November 30, 2017 10:06
Get the major Java version on Java 8 and earlier and on Java 9 and later
* You can copy, modify, distribute and perform the work, even for commercial
* purposes, all without asking permission.
import java.lang.reflect.Method;
public class JavaVersionSniffer {