Skip to content

Instantly share code, notes, and snippets.

package com.zhuhai;
import com.auth0.jwt.JWT;
import com.auth0.jwt.JWTVerifier;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.exceptions.JWTCreationException;
import com.auth0.jwt.exceptions.JWTVerificationException;
import com.auth0.jwt.interfaces.DecodedJWT;
import com.auth0.jwt.interfaces.Verification;
@zhuhai
zhuhai / RSAUtil.java
Created January 30, 2019 06:39
RSA加解密工具类
public class RsaUtil {
/**
* 密钥位数
*/
private static final int RAS_KEY_SIZE = 1024;
/**
* 加密算法RSA
*/
@zhuhai
zhuhai / ProtostuffUtil.java
Created June 3, 2016 10:04
使用protostuff进行序列化和反序列化
/**
* Created by zhuhai on 2016/6/3.
*/
public class ProtostuffUtil {
private static Map<Class<?>, Schema<?>> schemaMap = new ConcurrentHashMap<Class<?>, Schema<?>>();
public static <T> Schema<T> getSchema(Class<T> clazz) {
Schema<T> schema = (Schema<T>) schemaMap.get(clazz);
@zhuhai
zhuhai / 日期维度表.sql
Last active August 14, 2017 14:55
日期维度表
DROP TABLE IF EXISTS dim_date;
CREATE TABLE dim_date (
the_date datetime NOT NULL ,
date varchar(20) NOT NULL ,
the_year char(6) ,
the_halfyear char(6),
the_quarter char(6),
the_month char(6),
the_day char(4),
@zhuhai
zhuhai / RangeDate.java
Last active August 29, 2015 14:26
获取两个指定日期间的所有日期
public List<String> getDateList(String startDate,String endDate) throws ParseException{
List<String> list = new ArrayList<String>();
list.add(startDate);
Calendar calendar = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
calendar.setTime(sdf.parse(startDate));
boolean flag = true;
while(flag){
calendar.add(Calendar.DAY_OF_MONTH, 1);
if(sdf.parse(endDate).compareTo(calendar.getTime())>=0){
@zhuhai
zhuhai / DownloadServlet.java
Created August 18, 2013 08:26
文件下载
package com.kaishengit.web;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashMap;
@zhuhai
zhuhai / FileUploadServlet.java
Created August 17, 2013 15:12
文件的上传
package com.kaishengit.web;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.UUID;
@zhuhai
zhuhai / upload.jsp
Created August 17, 2013 09:31
Ajax拖动文件上传
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>拖动上传</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
<style type="text/css">
#droparea{
width:700px;
@zhuhai
zhuhai / Account.java
Last active December 21, 2015 02:59
EhCache + JDBC + CommonsDBUtil + Commons DBCP
package com.kaishengit.entity;
import java.io.Serializable;
public class Account implements Serializable{
private static final long serialVersionUID = 1L;
private int id;
private String username;
private int age;
@zhuhai
zhuhai / L5.java
Created April 3, 2013 03:44
冒泡排序法
public class L5{
public static void main(String[] args){
int[] nums=new int[5];
for(int a=0;a<nums.length;a++){
System.out.println("请输入"+(a+1)+"个整数的值:");
nums[a]=input.nextInt();
}
System.out.println("你输入的数为:");
for(int a=0;a<nums.length;a++){