Skip to content

Instantly share code, notes, and snippets.

View andytill's full-sized avatar

Andy Till andytill

View GitHub Profile
@Target({ TYPE, METHOD }) @Retention(RUNTIME) @ScopeAnnotation
public @interface FXMLLoadingScoped {
}
@andytill
andytill / CompatibleImageBenchMark.java
Created November 2, 2012 10:08
A mini benchmark to test if Java compatible images are rendered faster than images loaded in the default manner, results printed on the command line.
import java.awt.Color;
import java.awt.Graphics;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Image;
import java.awt.Transparency;
import java.awt.image.BufferedImage;
import java.io.File;
@andytill
andytill / MethodHandleTest.java
Created November 2, 2012 10:11
A benchmark for testing method handle performance.
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class MethodHandleTest
{
private static final String METHOD_NAME = "increment";
public class Math {
public static boolean isPrime(final long number) {
if (number == 2)
return true;
if (number < 2)
return false;
if(number % 2 == 0)
return false;
long maxCheck = (long) Math.sqrt(number);
@BookScoped
public class Hobbit implements Hero
{
public Hobbit()
{
System.out.println("created " + toString());
}
}
public class MiddleEarthModule extends AbstractModule
{
private final EnterableScope scope;
public MiddleEarthModule()
{
scope = new EnterableScope();
}
@Override
public interface Hero
{
}
@Target({ TYPE, METHOD }) @Retention(RUNTIME) @ScopeAnnotation
public @interface BookScoped
{
}
public class Main
{
public static void main(String[] args)
{
MiddleEarthModule module;
module = new MiddleEarthModule();
Injector injector;
@andytill
andytill / SPL
Created March 30, 2013 21:41
South Park inspired software license v1
All specifications and documentation for
this software--even those required for
customer sign off--are entirely fictional.
All code is tested... poorly.
The following program contains leaky
abstractions and should not be reused by anyone.