Skip to content

Instantly share code, notes, and snippets.

View kimble's full-sized avatar

Kim A. Betti kimble

View GitHub Profile
@kimble
kimble / ApplicationGuiceModule.java
Created May 6, 2012 19:01
Dropwizard instrumentation of Guice beans annotated with @timed
package com.developerb.dropbot;
import com.developerb.dropbot.instrumentation.MethodInvocationTimingInterceptor;
import com.google.inject.AbstractModule;
import com.yammer.metrics.annotation.Timed;
import static com.google.inject.matcher.Matchers.annotatedWith;
import static com.google.inject.matcher.Matchers.any;
/**
@kimble
kimble / DropwizardTestServer.java
Created May 25, 2012 19:15
JUnit @rule for running Dropwizard integration test. Ps! This is just a proof of concept. There are probably some landminds lying around waiting to go off, especially around lifecycle management and static state
package com.developerb.dropwizard;
import com.yammer.dropwizard.AbstractService;
import com.yammer.dropwizard.Service;
import com.yammer.dropwizard.cli.Command;
import com.yammer.dropwizard.config.Configuration;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
@kimble
kimble / ScreenshotTest.java
Created August 24, 2012 10:50
Java screenshot robot
import org.junit.Test;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import static java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment;
@kimble
kimble / HumanReadableToString.java
Created June 12, 2013 19:00
Groovy AST transformation adding toString implementation based on simple pattern supplied in annotation.
package developerb.groovy.compiler;
import org.codehaus.groovy.transform.GroovyASTTransformationClass;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
author "Your Name"
description "upstart script for sample-dw-service"
# respawn the job up to 5 times within a 10 second period.
# If the job exceeds these values, it will be stopped and
# marked as failed.
respawn
respawn limit 5 10
# move to this service's working directory
@kimble
kimble / TemporaryDirectory.java
Created July 31, 2014 08:22
Junit Rule for working with temporary files and directories (draft)
import com.google.common.base.Charsets;
import com.google.common.io.Files;
import org.apache.commons.io.FileUtils;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
import java.io.File;
import java.io.IOException;
@kimble
kimble / NoXML.java
Created September 19, 2014 21:22
NoXML
package com.developerb.noxml;
import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.common.io.ByteSource;
import org.joda.time.LocalDate;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
### Keybase proof
I hereby claim:
* I am kimble on github.
* I am kimble (https://keybase.io/kimble) on keybase.
* I have a public key whose fingerprint is 2C3B 8702 F1E3 D303 5DE5 DAC2 EC5D 44DD 9F63 BDD3
To claim this, I am signing this object:
import org.junit.Test;
import java.lang.ref.WeakReference;
import static org.junit.Assert.*;
public class PubSubTest {
@Test
@kimble
kimble / H2Rule.java
Last active August 29, 2015 14:27
H2Rule.java
package junit.rules;
import org.h2.jdbcx.JdbcConnectionPool;
import org.junit.rules.ExternalResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.function.Consumer;