把Docker当沙盒用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
sudo docker run -itd \
  --name srv1 \
  -v /mnt/hgfs/share:/home/work/share \
  -p 9083:9083 \
  fedora:latest \
  /bin/bash
 
sudo docker exec -it srv1 /bin/bash
 
sudo docker stop srv1
#sudo docker start srv1
sudo docker rm srv1
sudo docker rmi fedora:latest
sudo docker system df -v

Docker-in-Docker (DinD)

1
2
3
4
5
6
7
8
udo docker run -itd \
  --name jumpserver \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v $(which docker):/usr/bin/docker \
  -v /mnt/hgfs/share:/home/work/share \
  -p 80:80 -p 2222:2222 \
  fedora:latest \
  /bin/bash

在Keycloak里添加飞书IdP

先在Keycloak的管理员控制台的Identity Providers中添加OAuth v2 idp,Alias比如设为feishu。具体参数参考:
https://open.feishu.cn/document/sso/web-application-sso/login-overview

添加后,登陆中使用feishu第三方登陆,Keycloak后台报异常:No identifier provider for identity.
原因是标准的OAuth2流程在第三步取user_info,返回的json是在根结点有sub字段表示登陆者id,但飞书的user_info返回字段不标准,比如需要我们改代码取data子节点的email作为登陆者id。

具体在keycloak-26.3.0\services\src\main\java\org\keycloak\broker\oauth\OAuth2IdentityProvider.java
doGetFederatedIdentity函数返回identity之前,加入代码:

1
2
3
4
5
            if (userInfo.has("data")) {
                JsonNode dataNode = userInfo.get("data");
                id = dataNode.get("email") != null ? dataNode.get("email").asText() : null;
                identity.setId(id);
            }

Docker Memo

不写dockerfile,快速运行镜像:
docker run -it --name redhat85 redhat/ubi8:8.5

Docker容器中ADD的文件是旧的:
docker-compose stop some-docker-id
docker-compose rm -v some-docker-id
docker-compose build --no-cache some-docker-id

Jni FindClass Returns Null

One reason is the version of jvm.dll which contains JNI_CreateJavaVM is different from the version of the class file which is assigned to FindClass.

When FindClass returns null, we can check the reason like this:

1
2
3
if (env->ExceptionCheck()) {
    env->ExceptionDescribe();
}

refer to: https://blog.csdn.net/liu_12345_liu/article/details/131154935

Print signature of a Java function:

javap -s -private Sample2

refer to: https://blog.csdn.net/fuhanghang/article/details/122257507

Vue3 自定义组件传参

父组件

1
2
3
4
5
6
7
8
9
<template>
  <HelloWor v-model:aaa="foo" />
  {{foo}}
</template>
<script setup>
import HelloWor from './Hello.vue'
import{ref}from 'vue'
const foo=ref()
</script>

子组件

1
2
3
4
5
6
7
8
9
10
11
<template>
  <input v-model="yyy" />
</template>
<script setup>
import{useAttrs,computed}from 'vue'
const attrs = useAttrs()
const emit = defineEmits(['update:aaa'])//v-model父传子必须要用emit声明,否则父的v-model修饰符会不起作用。
const yyy=computed({
get() {return attrs.aaa},
set(newV) {emit('update:aaa',newV)}})
</script>

refer to:
https://segmentfault.com/a/1190000044885561

Visit Guest Service From Host With VirtualBox

VBoxManage modifyvm "xubuntu" --natpf1 "guest-redis,tcp,,6379,,6379"
VBoxManage modifyvm "xubuntu" --natpf1 "guest-mysql,tcp,,3306,,3306"

Another method is to create two adapters, NAT + Host Only.

ps. Delete the forwarding rules like:
VBoxManage modifyvm "xubuntu" --natpf1 delete "guest-redis"

refer to:
https://blog.csdn.net/chinainvent/article/details/6234368
https://superuser.com/questions/1282666/host-cant-connect-to-guest-with-nat-networking-at-virtualbox-but-others
https://forums.virtualbox.org/viewtopic.php?t=32014

Arthas Memo

dashboard
thread -b	# check dead lock
thread
thread 123
jad TestClass
redefine /root/TestClass.class
jmap -histo 1234 | head -20

refer to:
https://visualvm.github.io/index.html

SpringBoot Request And Response

1, 简单参数
	定义方法形参,请求参数名与形参变量名一致。
	如果不一致,通过@RequestParam手动映射。
2,实体参数
	请求参数名,与实体对象的属性名一致,会自动接收封装。
3,数组集合参数
	数组:请求参数名与数组名一致,直接封装。
	集合:请求参数名与集合名一致,@RequestParam绑定关系。
4,日期参数
	@DateTimeFormat
5,JSON参数
	@RequestBody
6,路径参数
	@PathVariable
	@Autowired
	private HttpServletRequest request;

refer to:
https://www.bilibili.com/video/BV1kg4y1x7o6?p=70