Instantly share code, notes, and snippets.

View Color.java
public enum Color {
RED, GREEN, BLUE,;
static {
Mirror.of(RGB.class);
}
}
View String.format.vm
public java.lang.String toString() {
#if ( $members.size() > 0 )
#set ( $i = 0 )
return String.format("$classname{#foreach( $member in $members )$member.name=%s#if ( $i < $members.size() - 1 ), #end#set ( $i = $i + 1 )#end}"#foreach( $member in $members ),#if ( $member.objectArray )$member.accessor == null ? null : java.util.Arrays.asList($member.accessor)#else$member.accessor#end#end);
#else
return "$classname{}";
#end
}
View TryPerf.java
public class TryPerf {
private static int foo(int a) {
return a * 2;
}
private static int tryFinally(int a) {
try {
return a * 2;
} finally {
View FormatterExercise.java
import java.util.Formatter;
public class FormatterExercise {
private static int n = 1_000_000;
public static void main(String[] args) throws InterruptedException {
long before = System.nanoTime();
str();
long after = System.nanoTime();
System.out.println((after - before)/1_000_000);
View selftar.sh
#!/bin/sh
if [ $# -eq 0 ]; then
echo "This script creates self extractable executable"
echo Usage: $0 TAR.GZ [COMMAND]
exit;
fi
if [ $# -gt 0 ]; then
TAR_FILE=$1
View CQLTest
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.ResultSetFuture;
import com.datastax.driver.core.Session;
import com.google.common.util.concurrent.Futures;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Collection;
public class CQLTest {