This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.concurrent.Callable; | |
import javax.annotation.concurrent.ThreadSafe; | |
@ThreadSafe | |
public final class ThreadContext { | |
private static final ThreadLocal<Context> CONTEXT = new ThreadLocal<>(); | |
private ThreadContext() { | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static com.google.common.base.Preconditions.*; | |
import java.util.Random; | |
public class RandomDistribution { | |
public static RandomDistribution using(Random random) { | |
return new RandomDistribution(checkNotNull(random)); | |
} | |
private final Random random; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class IsPerfectSquare { | |
// Taken from http://stackoverflow.com/a/18686659/180719 | |
private static long goodMask = computeGoodMask(); // 0xC840C04048404040 computed below | |
private static long computeGoodMask() { | |
long goodMask = 0L; | |
for (int i = 0; i < 64; i++) { | |
goodMask |= Long.MIN_VALUE >>> (i * i); | |
} | |
return goodMask; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Confidence { | |
private static double erf(double x) { | |
double a1 = 0.254829592; | |
double a2 = -0.284496736; | |
double a3 = 1.421413741; | |
double a4 = -1.453152027; | |
double a5 = 1.061405429; | |
double p = 0.3275911; | |
x = Math.abs(x); | |
double t = 1 / (1 + p * x); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-optimizationpasses 5 | |
-dontusemixedcaseclassnames | |
-dontskipnonpubliclibraryclasses | |
-dontpreverify | |
-verbose | |
-keep, allowobfuscation class be.ogregoire.* | |
-keepclassmembers, allowobfuscation class * { | |
*; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.regex.Pattern; | |
import java.util.regex.PatternSyntaxException; | |
public class Glob { | |
public static Glob compile(String pattern) { | |
return new Glob(Pattern.compile(globToRegex(pattern))); | |
} | |
private final Pattern pattern; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<Configuration status="warn" name="MyApp" packages=""> | |
<Properties> | |
<Property name="baseDir">logs</Property> | |
</Properties> | |
<Appenders> | |
<RollingFile name="RollingFile" fileName="${baseDir}/app.log" | |
filePattern="${baseDir}/$${date:yyyy-MM}/app-%d{yyyy-MM-dd}.log.gz"> | |
<PatternLayout pattern="%d %p %c{1.} [%t] %m%n" /> | |
<CronTriggeringPolicy schedule="0 0 0 * * ?"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
sudo apt-get install software-properties-common python-software-properties | |
sudo add-apt-repository ppa:webupd8team/java | |
sudo apt-get update | |
sudo apt-get install oracle-java8-installer | |
sudo apt-get install oracle-java8-set-default | |
wget http://download.jboss.org/wildfly/10.0.0.Final/wildfly-10.0.0.Final.tar.gz | |
sudo tar -zxf wildfly-10.0.0.Final.tar.gz -C /opt/ | |
sudo ln -s /opt/wildfly-10.0.0.Final /opt/wildfly | |
sudo cp /opt/wildfly/bin/init.d/wildfly.conf /etc/default/wildfly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.math.BigDecimal; | |
import java.math.RoundingMode; | |
public class Pi { | |
private static final BigDecimal TWO = new BigDecimal("2"); | |
private static final BigDecimal FOUR = new BigDecimal("4"); | |
private static final BigDecimal FIVE = new BigDecimal("5"); | |
private static final BigDecimal TWO_THIRTY_NINE = new BigDecimal("239"); |
OlderNewer