Skip to content

Instantly share code, notes, and snippets.

@josefbetancourt
josefbetancourt / INIX-example.inix
Last active December 29, 2015 17:09
Inix file reader source code to accompany blog post "Groovy implementation of INIX file format"
# Example very simple data file
#
[>root]
one
two
three
[<root]
[>demo1/compile]
x,y,z
[<demo1/compile]
@josefbetancourt
josefbetancourt / HexDump.groovy
Last active September 13, 2016 15:25
Groovy Hex Dump
package com.octodecillion.util
import static java.lang.Character.*
/**
* Simple ASCII hex dump of file.
* <p>
* Example output:<br>
* <pre>
* OFFSET 0 1 2 3 4 5 6 7 8 9 a b c d e f | ASCII
@josefbetancourt
josefbetancourt / ClasspathTestScanner
Last active August 29, 2015 14:24
Simple method to search Java classpath to find @test annotated JUnit tests
/**
* Get all test classes starting from a base package path.
* <p>
* Example use:
* <pre>
* UnitTestScanner scanner = new UnitTestScanner();
* List<Class<?>> list = scanner.getTestClasses("com.octodecillion.test");
* </pre>
* @param basePackage package where search will start
* @param debug if true output more info
@josefbetancourt
josefbetancourt / RequiresTestAnnotationScanner.java
Last active August 29, 2015 14:25
Scan classpath for classes with @RequiresTest annotated methods
package com.octodecillion.test;
import java.lang.reflect.Method;
import java.util.List;
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
import org.springframework.core.type.ClassMetadata;
import org.springframework.core.type.classreading.MetadataReader;
import org.springframework.core.type.classreading.MetadataReaderFactory;
import org.springframework.core.type.filter.TypeFilter;
@josefbetancourt
josefbetancourt / HelloRxTest.java
Last active January 3, 2016 01:50
Hello world using RxJava.
package com.octodecillion.learn.rxjava;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
import org.junit.Assert;
import org.junit.Before;
package com.octodecillion.util;
import java.util.Map;
import java.util.Map.Entry;
/**
* A {@link Map} decorator that allows
* <a href="https://en.wikipedia.org/wiki/Fluent_interface#Java">Fluent</a>
* add of entries.<p>
*
package com.octodecillion.util;
import java.io.IOException;
import java.io.Reader;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
package com.octodecillion.util;
import java.io.IOException;
import java.io.Reader;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
package com.octodecillion.util;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
package com.octodecillion.util;
import java.io.IOException;
import java.io.Reader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;