Skip to content

Instantly share code, notes, and snippets.

View stanio's full-sized avatar

Stanimir Stamenkov stanio

View GitHub Profile
@JonasGroeger
JonasGroeger / build.gradle
Last active January 23, 2024 07:55
Gradle: Read git commit hash.
def getCheckedOutGitCommitHash() {
def gitFolder = "$projectDir/.git/"
def takeFromHash = 12
/*
* '.git/HEAD' contains either
* in case of detached head: the currently checked out commit hash
* otherwise: a reference to a file containing the current commit hash
*/
def head = new File(gitFolder + "HEAD").text.split(":") // .git/HEAD
def isCommit = head.length == 1 // e5a7c79edabbf7dd39888442df081b1c9d8e88fd
@JamesXNelson
JamesXNelson / Template.java
Last active March 10, 2024 03:00
A one-file, zero-dependency, high-performance java string templating algorithm. You send a template string and list of tokens to perform replacement upon, it compiles into a stack of nodes that can .toString() an array of replacement values with maximum efficiency (1.5-3x faster than regex replacement).
package xapi.dev.source;
/**
* A fast, lightweight string templating system with zero dependencies.
*
* You supply a template String and an array of tokens to replace when calling
* {@link #apply(String...)}. The order of tokens supplied in the constructor
* corresponds to the order of strings supplied in apply().
*
* The Template will compile your string into an executable stack, which