Skip to content

Instantly share code, notes, and snippets.

View syhily's full-sized avatar
🎯
Focusing

Yufan Sheng syhily

🎯
Focusing
View GitHub Profile
@syhily
syhily / Timer.java
Last active February 27, 2017 10:54
package com.oneapm.research.alert.utils;
import lombok.Getter;
import java.util.concurrent.TimeUnit;
public class Timer {
private static final long INITIAL_TIME = 0L;
import com.google.common.collect.Maps;
import org.I0Itec.zkclient.IZkDataListener;
import org.I0Itec.zkclient.ZkClient;
import java.util.Map;
import java.util.ResourceBundle;
/**
* 类名称: ZkClientUtils <br>
* 类描述: A sync tool based on zkCli, inspired by sharp-config. (LOL)<br>
import java.util.*;
public class CalendarUtils {
private static final String[] weekTitle = {"一", "二", "三", "四", "五", "六", "日"};
private static final String[] monthTitle = {"一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"};
private static final int[] monthSize = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
private CalendarUtils() {
// No Construct function
@syhily
syhily / StringMatchUtil.java
Last active February 12, 2016 12:02
在Java语言中,怎么样查找一个特定的字符串,获取它的下一个索引位置,并返回它的索引位置? 例如说:我要在一组字符串中查找一个子字符串"activity",要求返回它的索引位置,同时,这个字符在字符串中出现的次数至少多于2次,也就是说,我需要一个方法能够直接获取它在字符串中出现的各个索引!
import com.google.common.collect.Lists;
import java.util.List;
/**
* Title: StringMatchUtil
* Description:
*
* @author Yufan
* @version 1.0.0
@syhily
syhily / nginx
Created March 17, 2016 06:09
Nginx init.d Script
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /usr/local/nginx/conf/nginx.conf
# pidfile: /var/run/nginx.pid
@syhily
syhily / AbstractDAOTest.java
Created March 18, 2016 02:47
Simple MyBatis Test Case
package com.blueocn.user.server;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.sql.Connection;
import java.util.Properties;
import javax.sql.DataSource;
;(function(window, document, $) {
var isInputSupported = 'placeholder' in document.createElement('input'),
isTextareaSupported = 'placeholder' in document.createElement('textarea'),
prototype = $.fn,
valHooks = $.valHooks,
hooks,
placeholder;
if (isInputSupported && isTextareaSupported) {
package com.blueocn.api.support.csrf;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.UUID;
/**
* CSRF Token控制器, 获取Session和请求中的Token
* 如果Session中Token不存在, 表明是第一次请求, 附加上Token参数
*
package com.blueocn.api.support.csrf;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* A Spring MVC <code>HandlerInterceptor</code> which is responsible to enforce CSRF token validity on incoming posts
package com.blueocn.user.server.v2.common;
import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
import org.springframework.util.Assert;
import java.io.Serializable;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;