Skip to content

Instantly share code, notes, and snippets.

@jdigger
jdigger / gw
Last active March 21, 2017 19:05
Gradle Wrapper search script
#!/bin/bash
# PURPOSE
#
# The Gradle wrapper[1] is a simple and convenient way of making Gradle
# builds self-contained and reproducible. However, in multi-project
# builds, it can be cumbersome to type in relative paths e.g.:
# ./gradlew # when in root
# ../gradlew # when in subdir
#
### Keybase proof
I hereby claim:
* I am jdigger on github.
* I am jmoore (https://keybase.io/jmoore) on keybase.
* I have a public key whose fingerprint is ADD7 5AF0 7E21 312D AE37 4639 F9A8 FBC6 EE25 BFBD
To claim this, I am signing this object:
@jdigger
jdigger / Failure.java
Last active August 29, 2015 14:14
Union Class In Java
import javax.annotation.Nonnull;
/**
* Indicates there was an error.
*/
public interface Failure {
/**
* Returns the error.
*/
@Nonnull
@jdigger
jdigger / Reflection.java
Created January 2, 2015 23:52
Functions for working with MethodHandles in Proxy
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
/**
* Functions for doing reflection.
@jdigger
jdigger / ComplexValueClass.java
Last active August 29, 2015 14:12
Class builder example
import javax.annotation.Nonnull;
/**
* @see #withValue1(String)
*/
public class ComplexValueClass {
private final String value1;
private final String value2;
private final String value3;
@jdigger
jdigger / show-remote-branch-info.sh
Created June 11, 2013 15:22
Too many crusty old git branches? Run this to find likely candidates for deletion. It lists all the remote branches and sorts them by age.
#!/bin/sh
#
# Too many crusty old git branches? Run this to find likely candidates for deletion
# It lists all the remote branches and sorts them by age.
#
#for k in `git branch -r|awk '{print $1}'`;do echo `git show --pretty=format:"%ci %cr %cn " $k|head -n 1`\\t$k;done|sort -r
for k in `git branch -r|awk '{print $1}'`;do echo `git show --pretty=format:"%Cgreen%ci %Cblue%cr %Cred%cn %Creset" $k|head -n 1`\\t$k;done|sort -r
@jdigger
jdigger / init.gradle
Last active December 12, 2015 08:18
Initialization script (in ~/.gradle) to add my credentials for repos.
import org.gradle.api.artifacts.repositories.AuthenticationSupported
import org.gradle.api.tasks.Upload
import org.gradle.api.publication.maven.internal.ant.RepositoryBuilder
apply from: 'config.gradle'
logger.info "Applying init.gradle to add Artifactory credentials for ${security.host}"
gradle.projectsEvaluated {
security.each {secRepoConfig ->
@jdigger
jdigger / build.gradle
Last active December 11, 2015 17:38
Working with generated files (such as wsdl2java) in Gradle
buildscript {
dependencies {
classpath "commons-io:commons-io:2.4"
}
}
configurations {
java2wsdl
}