Skip to content

Instantly share code, notes, and snippets.

Avatar

Dain Sundstrom dain

View GitHub Profile
View gist:8818242
checkNotNull(outputs, "outputs is null");
this.outputs = ImmutableMap.copyOf(Maps.transformValues(outputs, new Function<Set<?>, Set<?>>() {
@Override
public Set<?> apply(@Nullable Set<?> input)
{
return ImmutableSet.copyOf(input);
}
}));
View Closeables.java
package io.airlift.testing;
import java.io.Closeable;
import java.io.IOException;
import static com.google.common.base.Preconditions.checkNotNull;
public final class Closeables
{
private Closeables()
View gist:254400
"Name","Retained Size","Shallow Size"
"byte[3703132]","3703144","3703144"
"_bytes of org.mortbay.io.ByteArrayBuffer","3703200","56"
"_buf of org.mortbay.jetty.HttpConnection$Output","3703256","56"
"_out of org.mortbay.jetty.HttpConnection","3705144","104"
"_connection of org.mortbay.jetty.nio.SelectChannelConnector$ConnectorEndPoint","3709968","64"
"[2985] of java.lang.Runnable[3000]","1886724728","12016"
"_jobs of org.mortbay.thread.QueuedThreadPool","1886728176","128"
"this$0 of org.mortbay.thread.QueuedThreadPool$PoolThread [Stack Local, Thread, Monitor Used] "4353837@qtp-27187756-191"","2240","112"
View gist:392561
public class Example {
public static interface Foo<T extends Bar> {
T[] getEnumValues();
}
public static interface Bar {
}
View gist:933354
import java.util.Arrays;
import java.util.Collection;
public class Glommer<T>
{
public static <T> Glommer<T> glommer()
{
return new Glommer<T>();
}
@dain
dain / LZFCodec
Created Jun 21, 2011
Hadoop CompressionCodec for com.ning.compress-lzf
View LZFCodec
import com.ning.compress.lzf.LZFInputStream;
import com.ning.compress.lzf.LZFOutputStream;
import org.apache.hadoop.io.compress.CompressionCodec;
import org.apache.hadoop.io.compress.CompressionInputStream;
import org.apache.hadoop.io.compress.CompressionOutputStream;
import org.apache.hadoop.io.compress.Compressor;
import org.apache.hadoop.io.compress.Decompressor;
import java.io.IOException;
import java.io.InputStream;
View gist:1109992
cd src/hadoop-lzo
tar xzvf ~/Downloads/lzo-2.05.tar.gz
cd lzo-2.05
CFLAGS="-arch x86_64" ./configure --build=x86_64-darwin --enable-shared --disable-asm --prefix=$HOME/hadoop-0.20.2/lzo
make -j4
make install
cd ..
env \
JAVA_HOME=/Library/Java/Home \
C_INCLUDE_PATH=$HOME/hadoop-0.20.2/lzo/include \
@dain
dain / JsonPretty.java
Created Jul 11, 2012
Json pretty-print an object
View JsonPretty.java
import org.codehaus.jackson.map.ObjectMapper;
import java.io.IOException;
import static org.codehaus.jackson.map.SerializationConfig.Feature.INDENT_OUTPUT;
public class JsonPretty {
private static final ObjectMapper mapper = new ObjectMapper().configure(INDENT_OUTPUT, true);
public static String toPrettyJson(Object instance)
{
@dain
dain / Directions
Created Aug 12, 2012
Code that demonstrates problems with MLVM
View Directions
Build the code with ASM 4 and Guava 12 as follows:
$ javac -cp $HOME/.m2/repository/org/ow2/asm/asm-all/4.0/asm-all-4.0.jar:$HOME/.m2/repository/com/google/guava/guava/12.0/guava-12.0.jar:. FibGeneratedAsm.java
Code can be run with:
$ ~/jdk-back/1.8.0-mlvm-2012_08_01_10_07/Contents/Home/bin/java -cp $HOME/.m2/repository/org/o/asm/asm-all/4.0/asm-all-4.0.jar:$HOME/.m2/repository/com/google/guava/guava/12.0/guava-12.0.jar:. FibGeneratedAsm
View gist:3518112
<dependency>
<groupId>io.airlift</groupId>
<artifactId>http-server</artifactId>
<exclusions>
<exclusion>
<groupId>org.eclipse.jetty.orbit</groupId>
<artifactId>javax.servlet</artifactId>
</exclusion>
</exclusions>
</dependency>