Skip to content

Instantly share code, notes, and snippets.

View chanjarster's full-sized avatar
🎯
Focusing

Daniel Qian chanjarster

🎯
Focusing
  • Shanghai, China
View GitHub Profile
@chanjarster
chanjarster / fk_query.sql
Created November 6, 2014 02:08
oracle外键反查套件
/*
Examples:
查询我引用谁
SELECT * FROM TABLE(FK_UTIL.get_refering_stats('TABLE_A'));
查询谁引用我
SELECT * FROM TABLE(FK_UTIL.get_refered_stats('TABLE_A'));
查询ID为的某条记录的被引用计数
@chanjarster
chanjarster / import-dpdump.sh
Created November 6, 2014 01:49
impdp数据库dump的脚本
#!/bin/bash
if [[ -z $1 || -z $2 || -z $3 || -z $4 || -z $5 || -z $6 ]]; then
echo 'usage: import-dpdump.sh <dba> <dba password> <user> <user password> <directory> <dump>'
echo 'example: import-dpdump.sh admin 123456 user 123456 dir_object user20141010.dpdmp'
exit
fi
dba=$1
dbapsswd=$2
user=$3
@chanjarster
chanjarster / AccessSessionInAnotherThread.java
Created January 26, 2015 03:08
多线程访问到过期Session的测试代码
import org.apache.catalina.Context;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.session.StandardManager;
import org.apache.catalina.startup.Tomcat;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
@chanjarster
chanjarster / IdcardParser.java
Created July 24, 2015 06:41
中国大陆身份证号Parser
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* 中国居民身份证parser,支持15位,18位身份证
* http://www.360doc.com/content/11/0322/21/4240950_103674335.shtml
* http://baike.baidu.com/view/3457576.htm
* Created by qianjia on 15/7/22.
*/
@chanjarster
chanjarster / es-demo.md
Created January 25, 2018 02:11
Elasticsearch中将Doc根据A字段排序获得第一个Doc的B字段值的方法

注:本文基于Elasticsearch 6.1.2编写

最近遇到这样一个需求,要通过Elasticsearch将Doc根据A字段降序,然后获得B字段的值,最终根据B字段的值再去做[Pipeline Aggregation][1]。

先尝试了[Max Aggregation][2],但是Max Aggregation只能获得A字段的最大值。

然后尝试了[Top Hits Aggregation][3],但是Top Hits Aggregation的结果无法被Pipeline Aggregation使用。

最终尝试[Scripted Metric Aggregation][4]成功。下面举例说明

@chanjarster
chanjarster / echo-server-istio.yaml
Last active August 16, 2018 02:58
A istio tracing test app
apiVersion: v1
kind: Namespace
metadata:
name: istio-test
labels:
istio-injection: enabled
---
apiVersion: v1
kind: Service
metadata:
@chanjarster
chanjarster / echo-server.yaml
Last active August 17, 2018 05:53
Istio 1.0: HTTPRoute `appendHeaders` got wrong result if that header already exists in request headers.
apiVersion: v1
kind: Namespace
metadata:
name: istio-test
labels:
istio-injection: enabled
---
apiVersion: v1
kind: Service
metadata:
@chanjarster
chanjarster / haproxy.cfg
Last active August 20, 2018 14:41
Haproxy配置样例
# Haproxy的常见配置
# 参考文档:
# http://cbonte.github.io/haproxy-dconv/1.9/configuration.html
# http://blog.sina.com.cn/s/blog_704836f40102w243.html
# http://thread.gmane.org/gmane.comp.web.haproxy/12557
# https://serverfault.com/questions/678882/is-there-a-way-to-rate-limit-connections-with-haproxy-using-
# https://blog.codecentric.de/en/2014/12/haproxy-http-header-rate-limiting/
# http://cbonte.github.io/haproxy-dconv/1.9/management.html
# https://www.haproxy.com/blog/websockets-load-balancing-with-haproxy/
@chanjarster
chanjarster / docker-image-clear.sh
Created September 19, 2018 01:29
清理没有tag的docker image
#!/bin/bash
docker image ls | grep '<none>' | awk '{print $3}' | xargs -n1 -I{} docker image rm {}
@chanjarster
chanjarster / tomcat-jmx-non-ssl.yaml
Last active October 15, 2018 03:15
k8s-tomcat-jmx-samples
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: tomcat-jmx-non-ssl
namespace: default
spec:
selector:
matchLabels:
app: tomcat-jmx-non-ssl