Skip to content

Instantly share code, notes, and snippets.

View linxiaobai's full-sized avatar
🏠
Working from home

Kevin Lim linxiaobai

🏠
Working from home
View GitHub Profile
@linxiaobai
linxiaobai / MultiMapPattern.java
Created July 15, 2019 09:24
multiMap string to Map
private static final String MULTIMAP_PATTERN_REGEX = "(, |\\s*)(.*?)=\\[(.*?)]";
private static final Pattern MULTIMAP_PATTERN = Pattern.compile(MULTIMAP_PATTERN_REGEX);
public static Map<String, String> convertHeaderMultimapStringToHashMap(String text) {
Map<String, String> map = new HashMap<>();
text = text.substring(1, text.length() - 1);
Matcher matcher = MULTIMAP_PATTERN.matcher(text);
while (matcher.find()) {
map.put(matcher.group(2).toUpperCase(), matcher.group(3)); //header name ignore upper or lower case
static class Condition implements ConfigurationCondition {
@Override
public ConfigurationPhase getConfigurationPhase() {
return ConfigurationPhase.PARSE_CONFIGURATION;
}
//condition获取properties,直接用context.getEnvironment().getProperty()不行,因为配置还未加载进去,所以需要用以下写法
@Override
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
@linxiaobai
linxiaobai / tcpkillcmd
Last active June 4, 2019 11:27
tcpkill
sudo tcpkill -i en0 "host ${ip} and port ${port}"
ip:连接对端地址
port:连接对端端口
执行完会反复kill掉tcp连接,模拟连接异常情况
@linxiaobai
linxiaobai / shade logback.txt
Last active March 27, 2019 05:39
shade logback
shade logback注意logback.xml里的appender的class值也要填shade之后的全路径类名。