Skip to content

Instantly share code, notes, and snippets.

View asd1245dss's full-sized avatar

Summer asd1245dss

View GitHub Profile
################################################################################
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
mvn -B -X archetype:generate -DarchetypeCatalog=local -DarchetypeGroupId=org.apache.karaf.archetypes -DarchetypeArtifactId=karaf-command-archetype -DarchetypeVersion=4.0.5 -DgroupId=com.wpg.demo -DartifactId=demo-karaf -Dversion=1.0-SNAPSHOT -Dpackage=com.wpg.demo.karaf -Dcommand=testKaraf -Ddescription="Test Karaf Archetype Command" -Dscope=test
@asd1245dss
asd1245dss / WsChatServlet.java
Created August 3, 2016 05:38 — forked from chitan/WsChatServlet.java
How to use WebSocket of Tomcat
//This sample is how to use websocket of Tomcat.
package wsapp;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.util.ArrayList;
import org.apache.catalina.websocket.MessageInbound;
import org.apache.catalina.websocket.StreamInbound;
import org.apache.catalina.websocket.WebSocketServlet;
@asd1245dss
asd1245dss / date_time.js
Created August 9, 2016 01:24 — forked from jhjguxin/date_time.js
js上周(月、季)、上上周(月、季)、去年同期上周(月、季)
/***
* 获得当前时间
*/
function getCurrentDate(){
return new Date();
};
//今年以来的起止时间段
function getThisYear(){
//起止日期数组
@asd1245dss
asd1245dss / pom.xml
Created January 16, 2017 03:49
mvn dependency:tree to locate which conflict dependencies for the library
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.4.9</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
@asd1245dss
asd1245dss / gist:a9540a304e69bfe64a9cd8dde61bdafe
Created January 26, 2017 10:11
npm package.json版本号快速升级
#小版本号升级一个版本
npm version patch
#中版号升级一个版本
npm version minor
#大版本号升级一个版本
npm version major
@asd1245dss
asd1245dss / UnsafeSequenceTest.java
Created February 7, 2017 08:14
Java array clone is not deep clone,so all the elements in the array are same class
@Test
public void testArrayClone() {
UnsafeSequence[] unsafeSequences = new UnsafeSequence[10];
for (int i = 0; i < unsafeSequences.length; i++) {
unsafeSequences[i] = new UnsafeSequence();
}
UnsafeSequence[] unsafeSequencesClone = unsafeSequences.clone();
System.out.println(Arrays.toString(unsafeSequences));
System.out.println(Arrays.toString(unsafeSequencesClone));
@asd1245dss
asd1245dss / NoMoreLoop.java
Last active February 15, 2017 02:25
Constructor Block will always be executed first before constructor method
package com.wpg.demo.jdk8.stream;
import java.util.Arrays;
/**
* @author ChangWei Li
* @version 2017-02-15 10:14
*/
class NoMoreLoop {
@asd1245dss
asd1245dss / ResourceBundleMessageSource.java
Created February 22, 2017 02:19
Because the default encoding for ResiurceBunldeMessageSource is ISO-8859-1,so you should define the defaultEncoding to UTF-8
(stream != null) {
String encoding = getDefaultEncoding();
if (encoding == null) {
encoding = "ISO-8859-1";
}
try {
return loadBundle(new InputStreamReader(stream, encoding));
}
finally {
stream.close();
@asd1245dss
asd1245dss / gist:2c249df72dd14b8ef3c4093ee505e883
Created February 23, 2017 00:30
three date mapping type is used for different time type in database but all the type is subclass for java.util.Date
01:20:00
2016-09-11
2016-09-11 01:20:00.0