Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
set -uxo pipefail
VOICE='Serena (Premium)'
export LIFTWIZARD_FILE_MATCH_RULE_RERECORD=true
function checkLocalModification {
git diff --quiet
EXIT_CODE=$?
@Override
protected void registerHealthChecks(@Nonnull Environment environment)
{
super.registerHealthChecks(environment);
environment.healthChecks().register("healthy", new HealthCheck()
{
@Override
protected Result check()
{
@motlin
motlin / Main.java
Last active October 12, 2022 01:57
Java for testing syntax highlighting
import java.util.Arrays;
public class Main
{
public static void main(String[] args)
{
MyInterface myInterface = new ConcreteClass();
ConcreteClass concreteClass = new ConcreteClass();
AbstractClass abstractClass = new ConcreteClass();
# https://stackoverflow.com/a/2116892
git reflog expire --all --expire=now
git gc --prune=now --aggressive
# https://stackoverflow.com/a/14729486
git -c gc.reflogExpire=0 -c gc.reflogExpireUnreachable=0 \
-c gc.rerereresolved=0 -c gc.rerereunresolved=0 \
-c gc.pruneExpire=now gc --aggressive --prune=now
@motlin
motlin / more-intellij-flow-annotations.md
Last active February 24, 2022 23:21
Thoughts on IntelliJ's @flow analysis and null checking

Thoughts on IntelliJ's @Flow analysis and null checking

IntelliJ has an inspection called Java | Code style issues | Can use bounded wildcard that is helpful for ensuring that parameter types are permissive as they ought to be. In the screenshot below, the Inspection is warning on the usages of INPUT and OUTPUT, and I'm about to select the auto-fix on OUTPUT.

image

IntelliJ has an inspection called Java | Abstraction issues | Type may be weakened which can warn in many locations. Like the previous inspection, it is helpful for ensuring permissive parameter types. Here, inputs could be a Collection instead of a List.

image

IntelliJ's @Flow

IntelliJ's implementation of external annotations is excellent. They put @NotNull annotations on JDK methods and warn on violations.

image

When browsing the JDK code, these annotations appear grayed out, but embedded in the code.

image

HashingStrategy<Person> strategy =
HashingStrategies.fromFunction(Person::getSystemId);
MutableSet<Person> people =
new UnifiedSetWithHashingStrategy<>(strategy);
MutableList<Person> people = ...;
MutableList<Person> res1 = people.distinct();
MutableList<Person> res2 = people.distinct(HashingStrategies.fromFunction(Person::getSystemId));
MutableList<Person> res3 = people.distinctBy(Person::getSystemId);
public interface HashingStrategy<E>
{
int computeHashCode(E object);
boolean equals(E object1, E object2);
}
MutableBag<Color> bag = people.countBy(Person::getFavoriteColor);