Skip to content

Instantly share code, notes, and snippets.

View caoxudong's full-sized avatar
💭
coding,talking

caoxudong caoxudong

💭
coding,talking
View GitHub Profile
@caoxudong
caoxudong / JavaTest.java
Created June 22, 2017 13:24
根据前序遍历和中序遍历计算后序遍历,根据中序遍历和后序遍历计算前序遍历,递归方法
package test;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
public class JavaTest {
private static class Node {
public int value;
@caoxudong
caoxudong / InstallCert.java
Created April 13, 2017 02:49
生成某个HTTPS网站的证书
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.security.KeyStore;
import java.security.MessageDigest;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
@caoxudong
caoxudong / JWTTest.java
Created March 9, 2017 10:26
json web token
package codec;
import java.security.Key;
import org.jose4j.jwe.ContentEncryptionAlgorithmIdentifiers;
import org.jose4j.jwe.JsonWebEncryption;
import org.jose4j.jwe.KeyManagementAlgorithmIdentifiers;
import org.jose4j.keys.AesKey;
import org.jose4j.lang.ByteUtil;
import org.jose4j.lang.JoseException;
@caoxudong
caoxudong / BaiduSNGenerator.java
Created February 26, 2017 11:37
百度地图, java版计算signature签名
package location.api.baidu;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.security.NoSuchAlgorithmException;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
// java版计算signature签名
@caoxudong
caoxudong / IDCertNoTool.java
Created January 20, 2017 14:08
校验身份证格式
package demo.tool;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@caoxudong
caoxudong / OfferTrace.java
Created November 2, 2016 05:17
统计某个方法中调用另一个方法的次数
import com.sun.btrace.annotations.*;
import static com.sun.btrace.BTraceUtils.*;
@BTrace
public class OfferTrace {
@TLS
private static long startTime = 0;
@TLS
@caoxudong
caoxudong / build_binary_tree_with_array.js
Created August 11, 2016 08:15
数组构建二叉树
function Node(value) {
this.value = value;
this.left = null;
this.right = null;
}
function build_btree(number_array) {
length = number_array.length;
middle = Math.floor((0 + length - 1) / 2);
root = new Node(number_array[middle]);
@caoxudong
caoxudong / DumpClassURL.java
Created May 26, 2016 11:20 — forked from rednaxelafx/DumpClassURL.java
Using the ProtectionDomain of an InstanceKlass to see where it was loaded from
import java.io.*;
import java.util.*;
import sun.jvm.hotspot.memory.*;
import sun.jvm.hotspot.oops.*;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.tools.*;
public class DumpClassURL extends Tool {
public void run() {

Object Query Language (OQL)

$ java -version
java version "1.8.0_20"
Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)

OQL is SQL-like query language to query Java heap. OQL allows to filter/select information wanted from Java heap. While pre-defined queries such as "show all instances of class X" are already supported by HAT, OQL adds more flexibility. OQL is based on JavaScript expression language.

@caoxudong
caoxudong / JDK5u22_client.log
Created May 9, 2016 10:57 — forked from rednaxelafx/JDK5u22_client.log
PrintCompilation samples running Groovy shell 1.7.7 on different versions of HotSpot VM
1 b java.lang.String::charAt (33 bytes)
2 b java.lang.Math::max (11 bytes)
3 b java.util.jar.Manifest$FastInputStream::readLine (167 bytes)
4 b sun.nio.cs.UTF_8$Decoder::decodeArrayLoop (553 bytes)
5 b java.util.Properties$LineReader::readLine (383 bytes)
6 b java.lang.String::hashCode (60 bytes)
7 b java.lang.String::indexOf (151 bytes)
8 b sun.nio.cs.ext.DoubleByteDecoder::decodeSingle (10 bytes)
9 b java.lang.String::lastIndexOf (156 bytes)
10 b java.lang.String::replace (142 bytes)