Skip to content

Instantly share code, notes, and snippets.

@two8g
two8g / WebServerOne_.idea_.name
Created February 6, 2015 14:46
The first webserver project on IntelliJ IDEA
WebServerOne
webserverdemo
若需要对 Jackson 的序列化行为进行定制,比如,排除值为空属性、进行缩进输出、将驼峰转为下划线、进行日期格式化等,这又如何实现呢?
首先,我们需要扩展 Jackson 提供的 ObjectMapper 类,代码如下:
public class CustomObjectMapper extends ObjectMapper {
private boolean camelCaseToLowerCaseWithUnderscores = false;
private String dateFormatPattern;
public void setCamelCaseToLowerCaseWithUnderscores(boolean camelCaseToLowerCaseWithUnderscores) {
托瓦兹称,如果他具有所谓的远见卓识,那么Linux操作系统和Git可能都不会出现。在最近接受采访时,他解释说:
“我当初开发Linux的时候并没有预见到它会取得成功,也许正是因为不知道它将来会怎样才促成了我的成功。如果我从一开始就知道它会取得今时今日的重要地位,那么我可能都不敢随便动手编写它了。
“正因为我不知道它将来会怎样,所以我对别人的建议和影响才表现得格外开放。如果我已预见到它未来的样子,已经胸有成竹,那么我可能就不会那样开放 了。我想,正是这样的开放性让事情变得容易了许多,有趣了许多,也让我更愿意接纳别人参与到这个项目中。人们不必仰仗别人的远见卓识来获得成功,他们完全 可以跟着自己的感觉走。”
setxkbmap -layout us -option ctrl:nocaps
setxkbmap -layout us -option nocaps:ctrl
@two8g
two8g / userAgent.js
Created June 22, 2016 03:50
js客户端浏览器版本
var AGENT = navigator.userAgent;
var BROWSERS = {
isMac: (navigator.platform.substr(0,3) === "Mac"),
isPC: (navigator.platform.substr(0,3) === "Win"),
isMSIE: ("ActiveXObject" in window && "clipboardData" in window),
isEdge: ("MSGestureEvent" in window && "chrome" in window &&
window.chrome.loadTimes == null),
isFirefox: (!!AGENT.match(/Gecko\//) && !AGENT.match(/like Gecko/)),
isSafari: (!!AGENT.match(/ (Apple)?WebKit\//) && !AGENT.match(/ like iPhone /) &&
(!window.chrome || window.chrome.app == null)),
@Test
public void multithreadTest() throws InterruptedException {
int threadNum = 10;
int loopCount = 1000;
ExecutorService executor = Executors.newFixedThreadPool(threadNum);
final CountDownLatch latch = new CountDownLatch(loopCount);
for (int i = 0; i < loopCount; i++) {
executor.submit(new Runnable() {
@Override
public void run() {
@two8g
two8g / xvfb
Created October 8, 2016 03:47 — forked from rsanheim/xvfb
/etc/init.d/xvfb
root@ci:/etc/init.d# cat Xvfb
#! /bin/sh
### BEGIN INIT INFO
# Provides: Xvfb
# Required-Start: $local_fs $remote_fs
# Required-Stop:
# X-Start-Before:
# Default-Start: 2 3 4 5
# Default-Stop:
@two8g
two8g / gist:b016ada5ebfaf81d7561f7654077679e
Last active March 16, 2017 03:59
maven filter .properties 编码错误

Wrong encoding after activating resource filtering

http://stackoverflow.com/questions/14327003/wrong-encoding-after-activating-resource-filtering

http://docs.oracle.com/javase/6/docs/api/java/util/Properties.html#load(java.io.Reader)

Because Properties inherits from Hashtable, the put and putAll methods can be applied to a Properties object. Their use is strongly discouraged as they allow the caller to insert entries whose keys or values are not Strings. The setProperty method should be used instead. If the store or save method is called on a "compromised" Properties object that contains a non-String key or value, the call will fail. Similarly, the call to the propertyNames or list method will fail if it is called on a "compromised" Properties object that contains a non-String key.

The load(Reader) / store(Writer, String) methods load and store properties from and to a character based stream in a simple line-oriented format specified below. The load(InputStream) / store(OutputStream, String) met

@two8g
two8g / BaseDao.java
Created May 10, 2017 15:17 — forked from pengju/BaseDao.java
SSH中BaseDao的写法
package com.kaishengit.dao.core;
import java.io.Serializable;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.List;
import java.util.Map;
import org.hibernate.Criteria;
import org.hibernate.Query;