Skip to content

Instantly share code, notes, and snippets.

@codyaray
codyaray / AbstractXmlReader.java
Created January 3, 2013 07:13
Simple AbstractXmlReader for building RESTful web services with Jersey using Guava to find the generic parameter types. See http://codyaray.com/2013/01/finding-generic-type-parameters-with-guava for details.
package com.mydomain.myapp.resources.xml;
import java.io.IOException;
import java.io.InputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.ext.MessageBodyReader;
@codyaray
codyaray / AbstractInjectableProvider.java
Created January 3, 2013 06:57
Simplified AbstractInjectableProvider for building RESTful web services with Jersey using Guava to find the generic parameter types. See http://codyaray.com/2013/01/finding-generic-type-parameters-with-guava for details.
package com.mydomain.myapp.resources;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import javax.ws.rs.core.Context;
import com.google.common.reflect.TypeToken;
import com.sun.jersey.core.spi.component.ComponentContext;
@codyaray
codyaray / AbstractInjectableProvider.java
Created January 3, 2013 06:54
Basic AbstractInjectableProvider for building RESTful web services with Jersey using reflection to find the Super Type Tokens. See http://codyaray.com/2013/01/finding-generic-type-parameters-with-guava for details.
package com.mydomain.myapp.resources;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import javax.ws.rs.core.Context;
import com.sun.jersey.core.spi.component.ComponentContext;
import com.sun.jersey.core.spi.component.ComponentScope;
import com.sun.jersey.server.impl.inject.AbstractHttpContextInjectable;
@codyaray
codyaray / ValidatingJacksonJsonProvider.java
Created January 2, 2013 00:34
Automatic model validation using Jersey, Jackson, and Hibernate Validator
package com.mydomain.myapp.resources;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.List;
import java.util.Set;
@codyaray
codyaray / private.py
Created May 31, 2011 14:45
The authentication section of Mailman's private.py
# Authorization confirmed... output the desired file
try:
ctype = content_type(path)
if mboxfile:
f = open(os.path.join(mlist.archive_dir() + '.mbox',
mlist.internal_name() + '.mbox'))
ctype = 'text/plain'
elif true_filename[-3:] == '.gz':
import gzip
f = gzip.open(true_filename, 'r')