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
package test; | |
import java.security.MessageDigest; | |
import javax.crypto.Cipher; | |
import javax.crypto.spec.SecretKeySpec; | |
import org.apache.commons.codec.binary.Base64; | |
public class AesEncDec { |
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 ComputeUtil { | |
/** | |
* 根据已有平均值、总量、新增值递推新平均值的公共函数, 计算公式: newAvg = (oldAvg * oldCount)/(oldCount+1) + newVal/(oldCount+1); | |
* 另外由于目前的需求是保留2位小数,所以当oldCount大到一定程度时,oldCount/(oldCount+1) 趋近于 1 且 1/(oldCount+1) 趋近于 0,就不必执行某些实际计算以减少不必要操作 | |
* | |
* @param oldAvg 老平均值 | |
* @param oldCount 老的总量 | |
* @param newVal 新值 | |
* @return 新平均值 |
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
package test; | |
import java.net.InetAddress; | |
import java.net.NetworkInterface; | |
import java.net.SocketException; | |
import java.util.Enumeration; | |
import java.util.HashSet; | |
import java.util.Iterator; | |
import java.util.Set; |
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 Test { | |
public static void main(String... args) { | |
TreeLog log = new TreeLog("test"); | |
log.log("第一层"); | |
TreeLog log1 = log.addChild("test1"); | |
log1.log("第二层"); | |
TreeLog log2 = log1.addChild("test2"); | |
log2.log("第三层"); | |
TreeLog log3 = log.addChild("test3"); | |
log3.log("又一个第二层"); |
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
package test; | |
import java.util.Map; | |
import org.eclipse.jdt.core.JavaCore; | |
import org.eclipse.jdt.core.ToolFactory; | |
import org.eclipse.jdt.core.formatter.CodeFormatter; | |
import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; | |
import org.eclipse.jface.text.Document; | |
import org.eclipse.jface.text.IDocument; |
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
package kilim.tools; | |
import java.io.File; | |
import java.io.FileOutputStream; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.net.MalformedURLException; | |
import java.net.URL; | |
import java.net.URLClassLoader; | |
import java.util.Enumeration; |
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
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns | |
Compress 1K bytes with Zippy 3,000 ns // 3微秒 | |
Send 2K bytes over 1 Gbps network 20,000 ns // 20微秒 | |
Read 1 MB sequentially from memory 250,000 ns // 0.25毫秒 | |
Round trip within same datacenter 500,000 ns // 0.5毫秒 | |
Disk seek 10,000,000 ns // 10毫秒 |
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
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.github.pfmiles</groupId> | |
<artifactId>jar.groovy</artifactId> | |
<version>1.0-SNAPSHOT</version> | |
<packaging>jar</packaging> | |
<name>jar.groovy</name> |
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
package test; | |
import java.io.IOException; | |
import java.io.UnsupportedEncodingException; | |
import java.net.UnknownHostException; | |
import java.nio.charset.Charset; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.List; | |
import java.util.Map; |
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 static void makeSettable(Field f) { | |
try { | |
Field modifiersField = Field.class.getDeclaredField("modifiers"); | |
modifiersField.setAccessible(true); | |
modifiersField.setInt(f, f.getModifiers() & ~Modifier.FINAL); | |
f.setAccessible(true); | |
} catch (Exception e) { | |
throw new RuntimeException(e); | |
} | |
} |
NewerOlder