Skip to content

Instantly share code, notes, and snippets.

View kreiger's full-sized avatar

Christoffer Hammarström kreiger

View GitHub Profile
@kreiger
kreiger / .gitconfig
Created February 26, 2025 11:56
Git config
[pull]
rebase = true
[push]
default = simple
autoSetupRemote = true
followTags = true
[init]
defaultBranch = main
[merge]
conflictStyle = zdiff3
@kreiger
kreiger / javahome
Last active October 28, 2022 14:51
Run command with JAVA_HOME set to given version, e.g. `javahome 8 java -version`, or symlink it as e.g. `java8home`, `java17home` and run as `java8home java -version`
#!/bin/bash
# Run command in JAVA_HOME for given version, e.g. `javahome 8 java -version`.
# Or symlink it as e.g. `java8home`, `java17home` and run as `java8home java -version`.
java_homes_dir=/usr/lib/jvm
java_home_name_prefix=java-
if [ ! -d "$java_homes_dir" ]; then
echo "Please edit $0 and set java_homes_dir and java_home_name_prefix"
@kreiger
kreiger / class-tree-toolwindow-plugin.groovy
Last active June 30, 2022 22:42
Intellij Live plugin Tool Window with tree of classes with method returning classes
import com.intellij.codeInsight.javadoc.JavaDocUtil
import com.intellij.icons.AllIcons
import com.intellij.ide.DataManager
import com.intellij.ide.util.treeView.NodeRenderer
import com.intellij.navigation.ItemPresentation
import com.intellij.navigation.NavigationItem
import com.intellij.openapi.actionSystem.ActionManager
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
#!/bin/bash
function usage {
echo -e "\nUsage:\n\tgit clone-sibling [<remote>] <name>"
exit 1
}
function parse_arguments {
remotes="$(git remote)"
events {}
http {
include mime.types; # Correct content-types for css, et.c.
server {
listen 80;
root /var/www; # Where the www root is
index index.html index.htm;
resolver 127.0.0.11; # Docker DNS
location /api {
FROM openjdk:14-alpine AS base
RUN addgroup app
RUN adduser -u 1000 -G app -D app
USER app
WORKDIR /home/app
FROM base as gradle-wrapper
@kreiger
kreiger / maven-pom.gradle
Created October 5, 2020 15:17
Generate Maven pom.xml in Gradle project directory
apply plugin: 'maven-publish'
publishing {
publications {
maven(MavenPublication) {
from components.java
}
}
}
@kreiger
kreiger / pre-commit-check-syntax.sh
Created May 5, 2020 14:35
Git pre-commit hook to check syntax of json and js files.
#!/bin/sh
for cached in $(git diff --cached --name-only); do
check=$(case "$cached" in
*.json) echo "python -mjson.tool" ;;
*.js) echo "node --check -" ;;
esac)
if [ -z "$check" ]; then
continue
fi
@kreiger
kreiger / application-illegal-access-jvm-args.gradle
Created February 11, 2020 12:55
Stop "WARNING: An illegal reflective access operation has occurred"
afterProject { Project project ->
project.plugins.withType(ApplicationPlugin) {
project.application {
applicationDefaultJvmArgs.addAll('--illegal-access=deny', '--add-opens=java.base/java.lang=ALL-UNNAMED')
}
}
}
@kreiger
kreiger / git-swap-trees
Created February 10, 2020 17:39
Swap the tree of HEAD with the tree of HEAD^.
#!/bin/sh
if ! git diff-index --quiet HEAD --; then
echo "Cannot swap trees: You have unstaged changes.\nPlease commit or stash them." >&2
exit 1
fi
previous_second=$(git rev-parse HEAD)
previous_first=$(git rev-parse $previous_second^)
base=$(git rev-parse $previous_first^)