Skip to content

Instantly share code, notes, and snippets.

@lanhuai
lanhuai / Dockerfile
Last active March 15, 2017 10:26
Tomcat 8 and alpine docker Dockerfile
FROM anapsix/alpine-java:8_jdk_unlimited
MAINTAINER lanhuai<[email protected]>
# alpine 的时区配置不起作用,主要依靠JDK的参数设置
# -Duser.language=zh -Duser.country=CN -Duser.timezone=Asia/Shanghai
# Expose web port
EXPOSE 8080
@lanhuai
lanhuai / nginx.conf
Created March 26, 2016 05:29 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@lanhuai
lanhuai / VolatileDemo.java
Created January 27, 2016 13:26
volatile with trouble
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.CountDownLatch;
public class VolatileDemo {
@lanhuai
lanhuai / ThreadAbc.java
Last active January 21, 2016 11:22
用三个线程按顺序循环打印abc三个字母,比如abcabcabc
package com.lanhuai.common.util;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;
/**
* @author lanhuai
*/
public class ThreadAbc {
package com.sagedevices.platform.jersey.core;
import com.sagedevices.platform.api.util.StringUtil;
public class RequestId {
public static final String HEADER_NAME_ORIGIN = "X-Origin-Request-Id";
public static final String HEADER_NAME_LOCAL = "X-Local-Request-Id";
public static final String MDC_NAME_LOCAL = "LocalRequestId";
#!/bin/sh
logger_general()
{
logger -s -p local0.notice -t geek_script $1
}
logger_general "###########Geek script Started###########"
if [ $1 = "web-gui" ] ;then
logger_general "###########Geek script started from web-gui###########"
logger_general "Sleeping for 30 secs to give time for router boot"
@lanhuai
lanhuai / java_nio_diagram.puml
Last active August 29, 2015 14:03
Java NIO 类关系图
@startuml
interface ReadableByteChannel
interface WritableByteChannel
interface InterruptibleChannel
interface GatheringByteChannel
interface ScatteringByteChannel
interface Channel
interface ByteChannel
abstract AbstractInterruptibleChannel
@lanhuai
lanhuai / carbon
Last active August 29, 2015 14:01
在 CentOS 6.4 上 使用 virtualenv 安装 Graphite 0.9.12
#!/bin/bash
#
# Carbon (part of Graphite)
#
# chkconfig: 3 50 50
# description: Carbon init.d
. /etc/rc.d/init.d/functions
prog=carbon
RETVAL=0
@lanhuai
lanhuai / DistributedLockTest.java
Last active January 3, 2016 05:49
我写的测试同事开发的Zookeeper分布式锁性能的代码
import com.lanhuai.zookeeper.distributelock.DistributeLock;
import com.lanhuai.zookeeper.distributelock.DistributeLockFactory;
import junit.framework.TestCase;
import org.apache.zookeeper.KeeperException;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.CyclicBarrier;