Skip to content

Instantly share code, notes, and snippets.

@ryankennedy
ryankennedy / GithubClientTest.java
Created March 25, 2015 23:04
Using DropwizardClientRule to test the GitHub API.
package com.hypnoticocelot.github;
import io.dropwizard.jackson.Jackson;
import io.dropwizard.jersey.jackson.JacksonMessageBodyProvider;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
@ryankennedy
ryankennedy / Audited.java
Created September 24, 2013 17:48
Example of adding audited REST endpoints to a Dropwizard service.
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Audited {
}
@ryankennedy
ryankennedy / asmifier.c
Last active January 4, 2017 13:27
Quickly creating a command line utility to run ASMifier (http://asm.ow2.org/asm40/javadoc/user/org/objectweb/asm/util/ASMifier.html).
#include <stdio.h>
#include <errno.h>
int main(int argc, char* argv[]) {
int i;
char* argv2[argc+3];
argv2[0] = "java";
argv2[1] = "-cp";
argv2[2] = argv[0];
argv2[3] = "org.objectweb.asm.util.ASMifier";
@ryankennedy
ryankennedy / VendorJsonProvider.java
Created April 16, 2013 06:25
Brief exploration into what it takes to do vendor extensions in JAX-RS.
package com.yammer.testvendor;
import com.yammer.dropwizard.jersey.JacksonMessageBodyProvider;
import com.yammer.dropwizard.json.Json;
import javax.ws.rs.Consumes;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
@ryankennedy
ryankennedy / MultiRunner.java
Created May 18, 2012 08:06
JVM Multi Runner
package com.yammer.runner;
import java.io.File;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Arrays;
import java.util.jar.Attributes;
import java.util.jar.JarFile;
@ryankennedy
ryankennedy / VendorJsonProvider.java
Created May 16, 2012 05:05
Vendor JSON Provider for Jersey
package com.yammer.testvendor;
import com.yammer.dropwizard.jersey.JacksonMessageBodyProvider;
import com.yammer.dropwizard.json.Json;
import javax.ws.rs.Consumes;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
@ryankennedy
ryankennedy / NewIndexTest.java
Created February 10, 2012 23:32
testing creating secondary indices in bdb after the primary has already been used
import com.sleepycat.je.*;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
public class NewIndexTest {
public static void main(String[] args) throws IOException {
File envHome = new File("bdb-temp-dir");
try {
@ryankennedy
ryankennedy / velocity_2012_bdbje_scaling.txt
Created January 10, 2012 06:46
Scalable Application Specific Databases with Berkeley DB Java Edition
Title: Scalable Application Specific Databases with Berkeley DB Java Edition
Short Description (400 chars): In 2011 Yammer replaced a creaking 10B row messaging
database with BDB JE. This improved our availability, simplified scaling and lowered
delivery latency. I will discuss evaluating whether BDB JE is right for your situation,
problems you may run into with along the way and useful patterns for leveraging BDB
JE as an embedded solution to building reliable application specific databases at scale.
Full Description (a few paragraphs):
@ryankennedy
ryankennedy / SolrWtf.java
Created September 6, 2011 21:41
solr wtf?
/**
* Set the duration for which commit point is to be reserved by the deletion policy.
*
* @param indexVersion version of the commit point to be reserved
* @param reserveTime time in milliseconds for which the commit point is to be reserved
*/
public void setReserveDuration(Long indexVersion, long reserveTime) {
long timeToSet = System.currentTimeMillis() + reserveTime;
for(;;) {
Long previousTime = reserves.put(indexVersion, timeToSet);
@ryankennedy
ryankennedy / bite_me.txt
Created August 2, 2011 20:40
bite me, java.net.URI
#
# WTF is java.net.URI thinking?
#
scala> new URI("http", null, "hostname", 80, "/foo", "bar%20is=baz", null)
res5: java.net.URI = http://hostname:80/foo?bar%2520is=baz
#
# Oh, I see...I have to do this the inconvenient way.
#
scala> URI.create("http://hostname:80/foo?bar%20is=baz")