1
2
3
4
5
6
Shift + Command + 3 截取所有屏幕;
Shift + Command + 4 截取选中范围,按一次空格后切换至截取选中窗口;
Shift + Command + 5 打开傻瓜化截图 /录屏工具;

+3 和 +4 的快捷键如果再加上 Option 时,截图会放在剪贴板里。

线程池的状态参数分析

线程池的原子变量

ctl的创建如下:

1
private final AtomicInteger ctl = new AtomicInteger(ctlOf(RUNNING, 0));

上面中的RUNNING为:

1
private static final int RUNNING    = -1 << COUNT_BITS;

-1做左移COUNT_BITS运算

COUNT_BITS如下:

1
2
private static final int COUNT_BITS = Integer.SIZE - 3;

其中Integer.SIZE=32,得知COUNT_BITS为29,那么RUNNING为左移-1左移29位,-1的二进制表示为11111111111111111111111111111111,左移29位11100000000000000000000000000000

ctlOf的计算方式如下:

1
private static int ctlOf(int rs, int wc) { return rs | wc; }

线程的运行状态与线程数量做或运算,所以运行状态左移29位后,将高3位表示运行状态,低29位表示线程数量。

由于线程池的运行状态只有如下几种:

1
2
3
4
5
6
// runState is stored in the high-order bits
private static final int RUNNING = -1 << COUNT_BITS;
private static final int SHUTDOWN = 0 << COUNT_BITS;
private static final int STOP = 1 << COUNT_BITS;
private static final int TIDYING = 2 << COUNT_BITS;
private static final int TERMINATED = 3 << COUNT_BITS;

所以高3位足以表示所有的运行状态。
线程池提供了运行状态和线程数量的计算方法:

1
2
3
// Packing and unpacking ctl
private static int runStateOf(int c) { return c & ~CAPACITY; }
private static int workerCountOf(int c) { return c & CAPACITY; }

运算常量

1
2
3
4
5
6
private static final int CAPACITY   = (1 << COUNT_BITS) - 1;

CAPACITY = (1 << 29) -1
= (00000000000000000000000000000001 << 29) - 1
= 00100000000000000000000000000000 - 1
= 00011111111111111111111111111111

所以runStateOf 为舍弃掉低29位后的值,workerCountOf 为舍弃掉高3位后的值。

解决方案

  1. 添加JVM参数

    1
    Dlog4j2.formatMsgNoLookups=true
  2. 修改配置

    1
    log4j2.formatMsgNoLookups=True
  3. 添加环境变量

    1
    FORMAT_MESSAGES_PATTERN_DISABLE_LOOKUPS 设置为 true
  4. 升级Apache Log4j2 相关包至最新版

单机版使用

下载pulsar

https://pulsar.apache.org/download/
下载完成后解压

使用pulsar

启动单机pulsar

1
$ bin/pulsar standalone

订阅一个topic

1
2
$ bin/pulsar-client consume my-topic -s "first-subscription"

发布一条消息

1
2
$ bin/pulsar-client produce my-topic --messages "hello-pulsar"

结束pulsar进程

使用ctrl+c结束进程

拦截器实现

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
package com;

import com.baomidou.mybatisplus.toolkit.SqlUtils;
import com.baomidou.mybatisplus.toolkit.StringUtils;
import com.baomidou.mybatisplus.toolkit.SystemClock;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.mapping.BoundSql;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.ParameterMapping;
import org.apache.ibatis.mapping.ParameterMode;
import org.apache.ibatis.plugin.*;
import org.apache.ibatis.reflection.MetaObject;
import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.type.TypeHandlerRegistry;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Properties;

/**
* @author
* @since 2021-09-24 10:59
**/
@Intercepts({
@Signature(type = Executor.class, method = "query", args = { MappedStatement.class, Object.class, RowBounds.class,
ResultHandler.class }),
@Signature(type = Executor.class, method = "update", args = { MappedStatement.class, Object.class }) })
public class OrderPerformanceInterceptor implements Interceptor {

private static final Logger logger = LoggerFactory.getLogger(OrderPerformanceInterceptor.class);
/**
* SQL 执行最大时长,超过自动停止运行,有助于发现问题。
*/
private long maxTime = 0;

private boolean format = false;

public Object intercept(Invocation invocation) throws Throwable {
MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0];
Object parameterObject = null;
if (invocation.getArgs().length > 1) {
parameterObject = invocation.getArgs()[1];
}

String statementId = mappedStatement.getId();
BoundSql boundSql = mappedStatement.getBoundSql(parameterObject);
Configuration configuration = mappedStatement.getConfiguration();
String sql = SqlUtils.sqlFormat(boundSql.getSql(), format);

List<String> params = getParams(boundSql, parameterObject, configuration);

long start = SystemClock.now();
Object result = invocation.proceed();
long end = SystemClock.now();
long timing = end - start;
if (sql.toLowerCase(Locale.ROOT).trim().startsWith("select")) {
logger.info("Time:{} ms - ID:{} SQL Params:{} Execute SQL:{}", timing, statementId, params.toString(), sql);
}else {
logger.info("Time:{} ms - ID:{} SQL Params:{} Execute SQL:{} result:{}", timing, statementId, params.toString(), sql, result);
}
return result;
}

public Object plugin(Object target) {
if (target instanceof Executor) {
return Plugin.wrap(target, this);
}
return target;
}

public void setProperties(Properties prop) {
// TODO
}

private List<String> getParams(BoundSql boundSql, Object parameterObject, Configuration configuration) {
List<ParameterMapping> parameterMappings = boundSql.getParameterMappings();
TypeHandlerRegistry typeHandlerRegistry = configuration.getTypeHandlerRegistry();
List<String> params = new ArrayList<String>();
if (parameterMappings != null) {
for (int i = 0; i < parameterMappings.size(); i++) {
ParameterMapping parameterMapping = parameterMappings.get(i);
if (parameterMapping.getMode() != ParameterMode.OUT) {
Object value;
String propertyName = parameterMapping.getProperty();
if (boundSql.hasAdditionalParameter(propertyName)) {
value = boundSql.getAdditionalParameter(propertyName);
} else if (parameterObject == null) {
value = null;
} else if (typeHandlerRegistry.hasTypeHandler(parameterObject.getClass())) {
value = parameterObject;
} else {
MetaObject metaObject = configuration.newMetaObject(parameterObject);
value = metaObject.getValue(propertyName);
}
params.add(StringUtils.sqlParam(value));
}
}
}
return params;
}

public long getMaxTime() {
return maxTime;
}

public void setMaxTime(long maxTime) {
this.maxTime = maxTime;
}

public boolean isFormat() {
return format;
}

public void setFormat(boolean format) {
this.format = format;
}
}

配置拦截器

1
2
3
4
5
6
7
8
9
10
11
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="configLocation" value="classpath:mybatis-config.xml" />
<property name="mapperLocations" value="classpath:/sqlmap/*Mapper.xml" />
<property name="dataSource" ref="dataSource" />
<property name="plugins">
<array>
<!-- 基于拦截器的实现,配置拦截器所在工程的全路径 -->
<bean id="sqlStatementInterceptor" class="com.**.interceptor.OrderPerformanceInterceptor"/>
</array>
</property>
</bean>

设置代理(有代理)

前提情况下 是有代理

端口号是代理服务器本地端口

1
2
3
4
git config --global http.proxy http://127.0.0.1:1080

git config --global https.proxy https://127.0.0.1:1080

设置host(无代理)

  1. 打开https://github.com.ipaddress.com/ 如下图:

upload successful
把IP Address 记录下来! 把IP Address 记录下来! 把IP Address 记录下来!

  1. 打开https://fastly.net.ipaddress.com/github.global.ssl.fastly.net#ipinfo 如下图:

upload successful
把IP Address 记录下来! 把IP Address 记录下来! 把IP Address 记录下来!
3. 打开https://github.com.ipaddress.com/assets-cdn.github.com 如下图:

upload successful
把IP Address 记录下来! 把IP Address 记录下来! 把IP Address 记录下来!
4. 打开电脑的hosts文件,把下列的东东写在最后,然后保存即可

1
2
3
4
5
6
140.82.113.4(图1的IP Address) github.com 
199.232.69.194(图2的IP Address) github.global.ssl.fastly.net
185.199.108.153(图3的IP Address) assets-cdn.github.com
185.199.109.153(图3的IP Address) assets-cdn.github.com
185.199.110.153(图3的IP Address) assets-cdn.github.com
185.199.111.153(图3的IP Address) assets-cdn.github.com
  1. 在终端在输以下指令刷新DNS(需要权限)
    1
    sudo killall -HUP mDNSResponder;say DNS cache has been flushed

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
package com;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.crypto.Cipher;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
import javax.crypto.spec.IvParameterSpec;
import java.security.Key;
import java.util.HashMap;
import java.util.Map;

/**
* 加密
*
* @author
* @since 2021-08-30 14:14
**/
public class DesPlus {

private static final String strDefaultKey = "dhyPksiF";

private static final Logger logger = LoggerFactory.getLogger(DesPlus.class);

private final Map<String, Cipher> encryptMap = new HashMap<String, Cipher>();

private final Map<String, Cipher> decryptMap = new HashMap<String, Cipher>();

private static final ThreadLocal<DesPlus> localDesPlus = new ThreadLocal<DesPlus>() {

@Override
protected DesPlus initialValue() {
return new DesPlus();
}
};

private DesPlus() {
}

public static DesPlus getInstance() {

return localDesPlus.get();
}

public static final String ALGORITHM_DES = "DES/CBC/PKCS5Padding";

/**
* DES算法,加密
*
* @param data 待加密字符串
* @return 加密后的字节数组,一般结合Base64编码使用
* @throws Exception 异常
*/
public String encode(String data) throws Exception {
return encode(strDefaultKey, data.getBytes());
}

/**
* DES算法,加密
*
* @param data 待加密字符串
* @param key 加密私钥,长度不能够小于8位
* @return 加密后的字节数组,一般结合Base64编码使用
* @throws Exception 异常
*/
public String encode(String key, String data) throws Exception {
logger.info("key:{}|data:{}|start", key, data);
String encode = encode(key, data.getBytes());
logger.info("key:{}|data:{}|end。{}", key, data, encode);
return encode;
}

/**
* DES算法,加密
*
* @param data 待加密字符串
* @param key 加密私钥,长度不能够小于8位
* @return 加密后的字节数组,一般结合Base64编码使用
* @throws Exception 异常
*/
public String encode(String key, byte[] data) throws Exception {
try {
DESKeySpec dks = new DESKeySpec(key.getBytes());

SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
//key的长度不能够小于8位字节
Key secretKey = keyFactory.generateSecret(dks);
Cipher cipher = Cipher.getInstance(ALGORITHM_DES);
IvParameterSpec iv = new IvParameterSpec(key.getBytes());
cipher.init(Cipher.ENCRYPT_MODE, secretKey, iv);

byte[] bytes = cipher.doFinal(data);

return byteArrayToHexString(bytes);
} catch (Exception e) {
logger.error("key:{}|data:{}|encode error", key, new String(data), e);
}
return "";
}

public String byteArrayToHexString(byte b[]) {
StringBuffer resultSb = new StringBuffer();
for (int i = 0; i < b.length; i++)
resultSb.append(byteToHexString(b[i]));

return resultSb.toString();
}

private static String byteToHexString(byte b) {
int n = b;
if (n < 0)
n += 256;
int d1 = n / 16;
int d2 = n % 16;
return hexDigits[d1] + hexDigits[d2];
}

/**
* DES算法,解密
*
* @param data 待解密字符串
* @param key 解密私钥,长度不能够小于8位
* @return 解密后的字节数组
*/
public byte[] decode(String key, byte[] data) {
try {
DESKeySpec dks = new DESKeySpec(key.getBytes());
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
//key的长度不能够小于8位字节
Key secretKey = keyFactory.generateSecret(dks);
Cipher cipher = Cipher.getInstance(ALGORITHM_DES);
IvParameterSpec iv = new IvParameterSpec(key.getBytes());
cipher.init(Cipher.DECRYPT_MODE, secretKey, iv);
return cipher.doFinal(data);
} catch (Exception e) {
logger.error("key:{}|data:{}|decode error", key, new String(data), e);
}
return new byte[0];
}

/**
* 获取编码后的值
*
* @param data 解码数据
* @return 解码后的数据
*/
public String decodeValue(String data) {
return decodeValue(strDefaultKey, data);
}

/**
* 获取编码后的值
*
* @param key
* @param data
* @return
* @throws Exception
*/
public String decodeValue(String key, String data) {
byte[] datas;
String value = null;
try {
datas = decode(key, hexStr2ByteArr(data));
value = new String(datas);
} catch (Exception e) {
value = "";
}
return value;
}

public byte[] hexStr2ByteArr(String strIn) {

byte[] arrB = strIn.getBytes();

int iLen = arrB.length;
// 两个字符表示一个字节,所以字节数组长度是字符串长度除以2
byte[] arrOut = new byte[iLen / 2];

for (int i = 0; i < iLen; i = i + 2) {

String strTmp = new String(arrB, i, 2);

arrOut[i / 2] = (byte) Integer.parseInt(strTmp, 16);

}

return arrOut;

}

public static void main(String[] args) throws Exception {
DesPlus instance = getInstance();
String encode = instance.encode("18000000000");
System.out.println(encode);
System.out.println(instance.decodeValue(encode));
}
}

Beyond Compare 4.x

Licensed to: ASIO Allsoftinone
Quantity: 1 user
Serial number: 1822-9597
License type: Pro Edition for Linux

First delete away trial mode:

1
sudo rm -rf ~/.config/bcompare #thinks bensonkb
1
sudo sed -i "s/keexjEP3t4Mue23hrnuPtY4TdcsqNiJL-5174TsUdLmJSIXKfG2NGPwBL6vnRPddT7tH29qpkneX63DO9ECSPE9rzY1zhThHERg8lHM9IBFT+rVuiY823aQJuqzxCKIE1bcDqM4wgW01FH6oCBP1G4ub01xmb4BGSUG6ZrjxWHJyNLyIlGvOhoY2HAYzEtzYGwxFZn2JZ66o4RONkXjX0DF9EzsdUef3UAS+JQ+fCYReLawdjEe6tXCv88GKaaPKWxCeaUL9PejICQgRQOLGOZtZQkLgAelrOtehxz5ANOOqCaJgy2mJLQVLM5SJ9Dli909c5ybvEhVmIC0dc9dWH+/N9KmiLVlKMU7RJqnE+WXEEPI1SgglmfmLc1yVH7dqBb9ehOoKG9UE+HAE1YvH1XX2XVGeEqYUY-Tsk7YBTz0WpSpoYyPgx6Iki5KLtQ5G-aKP9eysnkuOAkrvHU8bLbGtZteGwJarev03PhfCioJL4OSqsmQGEvDbHFEbNl1qJtdwEriR+VNZts9vNNLk7UGfeNwIiqpxjk4Mn09nmSd8FhM4ifvcaIbNCRoMPGl6KU12iseSe+w+1kFsLhX+OhQM8WXcWV10cGqBzQE9OqOLUcg9n0krrR3KrohstS9smTwEx9olyLYppvC0p5i7dAx2deWvM1ZxKNs0BvcXGukR+/g" /usr/lib/beyondcompare/BCompare

Then restart BC, click “Enter License”:

1
2
3
4
5
6
7
8
--- BEGIN LICENSE KEY ---
ayvZeJDYPBHS4J-1K6g6bDBuPoo0G-oGAq35blZtAoRqC-qQeSz28XAzX
6nTx9laTMLRCp6nAIhHNGZ2ehkeUfbnFaxEeLvI8fJavn-XQLNbOumCLU
qgdNbNMZiFRU03+OTQnw4V-E2YKTYi-LkgPzE6R-yIJGDNWfxH2AdpIgg
8rlpsbrTs9Dt1zysUfvAEi0dKbmGIi3rqf7yWmwDh1AI5VyoWFIejvJwJ
Lmlr2CjQ1VZ3DySCfBDuKcYmOCeK7jzEWPUnAw+f9360nIiiNEB0YGkwB
kdtgaKEEik7aNiI3jXvp5r34wViVJCiX7m2y7pqBV9gZIvP9hP9KPnP++++
--- END LICENSE KEY -----

or

1
2
3
--- BEGIN LICENSE KEY ---
GXN1eh9FbDiX1ACdd7XKMV7hL7x0ClBJLUJ-zFfKofjaj2yxE53xauIfkqZ8FoLpcZ0Ux6McTyNmODDSvSIHLYhg1QkTxjCeSCk6ARz0ABJcnUmd3dZYJNWFyJun14rmGByRnVPL49QH+Rs0kjRGKCB-cb8IT4Gf0Ue9WMQ1A6t31MO9jmjoYUeoUmbeAQSofvuK8GN1rLRv7WXfUJ0uyvYlGLqzq1ZoJAJDyo0Kdr4ThF-IXcv2cxVyWVW1SaMq8GFosDEGThnY7C-SgNXW30jqAOgiRjKKRX9RuNeDMFqgP2cuf0NMvyMrMScnM1ZyiAaJJtzbxqN5hZOMClUTE+++
--- END LICENSE KEY -----

For windows:

1
2
3
4
5
6
7
8
--- BEGIN LICENSE KEY ---
H1bJTd2SauPv5Garuaq0Ig43uqq5NJOEw94wxdZTpU-pFB9GmyPk677gJ
vC1Ro6sbAvKR4pVwtxdCfuoZDb6hJ5bVQKqlfihJfSYZt-xVrVU27+0Ja
hFbqTmYskatMTgPyjvv99CF2Te8ec+Ys2SPxyZAF0YwOCNOWmsyqN5y9t
q2Kw2pjoiDs5gIH-uw5U49JzOB6otS7kThBJE-H9A76u4uUvR8DKb+VcB
rWu5qSJGEnbsXNfJdq5L2D8QgRdV-sXHp2A-7j1X2n4WIISvU1V9koIyS
NisHFBTcWJS0sC5BTFwrtfLEE9lEwz2bxHQpWJiu12ZeKpi+7oUSqebX+
--- END LICENSE KEY -----

For Mac:

  1. Open trial.key at path: /Applications/Beyond\ Compare.app/Contents/Resources/trial.key
  2. Replace content of trial.key with:
    1
    2
    3
    4
    5
    6
    7
    8
    --- BEGIN LICENSE KEY ---
    H1bJTd2SauPv5Garuaq0Ig43uqq5NJOEw94wxdZTpU-pFB9GmyPk677gJ
    vC1Ro6sbAvKR4pVwtxdCfuoZDb6hJ5bVQKqlfihJfSYZt-xVrVU27+0Ja
    hFbqTmYskatMTgPyjvv99CF2Te8ec+Ys2SPxyZAF0YwOCNOWmsyqN5y9t
    q2Kw2pjoiDs5gIH-uw5U49JzOB6otS7kThBJE-H9A76u4uUvR8DKb+VcB
    rWu5qSJGEnbsXNfJdq5L2D8QgRdV-sXHp2A-7j1X2n4WIISvU1V9koIyS
    NisHFBTcWJS0sC5BTFwrtfLEE9lEwz2bxHQpWJiu12ZeKpi+7oUSqebX+
    --- END LICENSE KEY -----
  3. Save trial.key file & restart Beyond Compare app
    Enjoy!

for 4.2.4 or higher,4.2.5,4.2.6,4.3.7,it’s works , this is the way which makes Always in evaluation mode 。

  1. open Terminal, go to the dir : cd /Applications/Beyond Compare.app/Contents/MacOS

  2. change the name BCompare to BCompare.bak: mv BCompare BCompare.bak

  3. touch a file name BCompare , and chmod a+u BCompare : touch BCompare && chmod a+u BCompare

  4. open BCompare with text editor, insert the script :

    1
    2
    3
    #!/bin/bash
    rm "/Users/$(whoami)/Library/Application Support/Beyond Compare/registry.dat"
    "`dirname "$0"`"/BCompare.bak $@
  5. restart bc .

Sublime Text

1
2
3
4
5
6
7
8
9
10
11
12
13
----- BEGIN LICENSE -----
eldon
Single User License
EA7E-1122628
C0360740 20724B8A 30420C09 6D7E046F
3F5D5FBB 17EF95DA 2BA7BB27 CCB14947
27A316BE 8BCF4BC0 252FB8FF FD97DF71
B11A1DA9 F7119CA0 31984BB9 7D71700C
2C728BF8 B952E5F5 B941FF64 6D7979DA
B8EB32F8 8D415F8E F16FE657 A35381CC
290E2905 96E81236 63D2B06D E5F01A69
84174B79 7C467714 641A9013 94CA7162
------ END LICENSE ------

jar包冲突,导致

项目中已添加

1
2
//分页插件
compile "com.github.pagehelper:pagehelper:4.1.3"

出现问题:net.sf.jsqlparser.statement.select.PlainSelect.getGroupByColumnReferences()Ljava/util/List;

去掉或者添加

1
compile group: 'com.github.jsqlparser', name: 'jsqlparser', version: '3.1'
0%