日常遇到的小问题记录
python怎么安装PIT模块
1
conda install pillow
python怎么安装skimage模块
1
conda install scikit-image
eclipse中xml报错怎么办
No grammar constraints (DTD or XML Schema) referenced in the document.1
2tomcat-servlet-jsp 版本映射关系是什么
http://tomcat.apache.org/whichversion.htmlservlet-jstl 版本映射关系是什么
http://tomcat.apache.org/taglibs/standard/
git如下警告怎么办
warning: LF will be replaced by CRLF in xxx.1
git config core.autocrlf false
git常用命令有哪些
1
2
3
4
5
6
7
8#查看待提交文件
git status
#查看提交日志
git log
#查看详情,查询出来的commit id
git show 'commit id'
#退出
qwindows如何关闭占用端口进程
1
2netstat -ano|findstr 8080
taskkill /f /pid 7556es匹配符有什么区别
match 分词匹配,不支持通配符
wildcard 通配符匹配,不分词
term 精确匹配,不分词,不支持通配符
fuzzy 模糊匹配,不分词,对中文分词字段使用也不友好。(近似匹配,如”luky”匹配到”lucky”,“下个星期报”匹配到“上个星期报”)join和where有什么区别
join 交集:on和where结果一样。
left join 左表全部 右表交集:on左表无效,右表数据更少;where最后结果过滤plsql中文乱码有时有些库查询时中文乱码?
select userenv(‘language’) from dual;查到的值添加环境变量,如:
NLS_LANG
AMERICAN_AMERICA.ZHS16GBKlinux怎么后台启动进程
1
nohup java -jar sentinel-dashboard-1.8.0.jar > server.log 2>&1 &
java进程栈日志怎么打印?
jstack -l 进程id > jstack.log
如何用tar命令拆包和合包
1
2
3
4
5tar cjf - modules.tar.gz |split -b 300m - modules.tar.gz.
cat modules.tar.gz.* | tar xj
tips: yum -y install bzip2cmd怎么计算md5
1
CertUtil -hashfile C:\xxx.tar MD5
支持:MD2 MD4 MD5 SHA1 SHA256 SHA384 SHA512
pip如何指定下载源
pip3 install ddparser -i https://pypi.douban.com/simple/
centos7如何开放端口
1
2
3
4
5
6
7
8
9firewall-cmd --zone=public --add-port=9610/tcp --permanent
firewall-cmd --zone=public --remove-port=9610/tcp --permanent
firewall-cmd --reload
firewall-cmd --zone=public --list-ports
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.20.130.79" port protocol="tcp" port="23301-23306" accept"centos7没有telnet命令怎么办?
import socket
c = socket.socket()
c.connect((‘192.20.130.79’, 23306))
mongo如何如何创建用户
1
2
3
4
5db.createUser({user:"mydev",pwd:"123456",roles:[{role:"readWrite",db:"mydev"}]});
db.createUser({user:"admin",pwd:"123456",roles:[{role:"dbAdmin",db:"mydev"}]});
db.createUser({user:"root",pwd:"123456",roles:[{role:"root",db:"admin"}]});mongodb角色有哪些
数据库角色:
read
readWrite数据库管理员角色:
dbOwner (包含 dbAdmin,readWrite,userAdmin)
dbAdmin
userAdmin集群管理员角色:
clusterAdmin (包含 clusterManager,clusterMonitor,hostManager)
clusterManager
clusterMonitor
hostManager所有的数据库角色:
readAnyDatabase
readWriterAnyDatabase
userAdminAnyDatabase
dbAdminAnyDatabase超级用户角色
root(包含readWriteAnyDatabase,dbAdminAnyDatabase,userAdminAnyDatabase,clusterAdmin)maven如何打包jar和源码到本地仓库
mvn clean source:jar install
如何用jar命令解包和压包
1
2
3jar -xvf xx.jar
jar -cvfm0 xx.jar ./META-INF/MANIFEST.MF ./grep如何显示筛选行前后的内容
cat xx | grep -C10 xx
boot项目打包如何包含本地包
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<dependency>
<groupId>net.sourceforge.cpdetector</groupId>
<artifactId>cpdetector</artifactId>
<version>1.0.10</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/libs/cpdetector_1.0.10.jar</systemPath>
</dependency>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>libs/**</exclude>
</excludes>
</resource>
</resources>
</build>docker 拉取镜像失败怎么办
1
2[root@localhost image]# docker pull centos:7
Error response from daemon: Get "https://registry-1.docker.io/v2/": dial tcp: lookup registry-1.docker.io on 8.8.8.8:53: read udp 192.168.126.128:55735->8.8.8.8:53: i/o timeout先检查nameserver,不对更改尝试
1
2
3echo nameserver 8.8.8.8 > /etc/resolv.conf
service network restart
systemctl restart docker如果nameserver配置正确,可尝试多次停止、启动
1
2systemctl stop docker
systemctl start dockerFlask+Gunicorn多进程怎么玩转
https://blog.csdn.net/luanpeng825485697/article/details/92767998
1
2gunicorn -v
gunicorn -w 2 -b 0.0.0.0:45897 main:app -t 60main为py文件名称,app为Flask实例名
-b 访问地址,0.0.0.0可以监听所有ip请求
-w 进程数,默认1,若服务本身比较消耗内存等资源,不建议启动太多数量的进程
-t 允许的响应时间,秒,默认30秒,处理请求和响应请求超过该时间服务会重启,该次请求会失败
–threads 每个进程的线程数,默认1
若日志中频繁打印如下警告,便可能是资源不足导致的进程重启,应根据jmeter等工具的压测结果适量减少进程数,资源不足的情况下增加进程数可能是负优化,反而降低qps,异常率上升
1
2[WARNING] Worker with pid 5823 was terminated due to signal 2
[INFO] Shutting down: Master推荐Flask写法,既能python直接启动,也能gunicorn启动
1
2if __name__ == "__main__":
app.run(host='0.0.0.0', port=45897, debug=False)Flask返回格式怎么封装
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20class Result(object):
def __init__(self, data, code, msg):
self.data = data
self.code = code
self.msg = msg
@classmethod
def success(cls, data=None, code=200, msg='success'):
return cls(data, code, msg).to_dict()
@classmethod
def error(cls, data=None, code=500, msg='error'):
return cls(data, code, msg).to_dict()
def to_dict(self):
return {
"code": self.code,
"msg": self.msg,
"data": self.data
}使用:
1
2
3
4# success
return jsonify(Result.success(data=res))
# error
return jsonify(Result.success(msg=str(e)))Random阻塞怎么办
1
SecureRandom.getInstanceStrong() 改为 SecureRandom.getInstance("NativePRNGNonBlocking")
https://docs.oracle.com/cd/E13209_01/wlcp/wlss30/configwlss/jvmrand.html
163邮箱连接提示如下怎么办?
1
javax.mail.MessagingException: A4 NO EXAMINE Unsafe Login. Please contact [email protected] for help
Android Studio怎么设置中文
Android Studio版本
1
2Android Studio Dolphin | 2021.3.1
Build #AI-213.7172.25.2113.9014738, built on September 1, 2022其中213.7172.25便是idea版本号
在如下可查到idea完整版本
https://confluence.jetbrains.com/dashboard.action
1
IntelliJ IDEA 2021.3.3 (213.7172.25 build) Release
在插件网站
https://plugins.jetbrains.com/plugin/13710-chinese-simplified-language-pack----/versions
关键版本是两个:2021.3.3、213,所以下载213最新版即可
然后在Android Studio里通过File -Sttrings-plugins-InstallPlugin from Disk…安装即可
常用尺寸照片分辨率是什么
一寸:295*413
二寸:414*579
es如何启动
1
2./elasticsearch -d
nohup ./kibana --allow-root &curl
post
application/x-www-form-urlencoded
1
curl -X POST -d "name=zhangsan&pwd=123" http://127.0.0.1:8000/api/auth
application/json
1
curl -X POST -d '{"name":"zhangsan","pwd": "123"}' -H "Content-Type:application/json" http://127.0.0.1:8000/api/auth
win11怎么使用ie
发送程序到桌面快捷方式
1
C:\Program Files (x86)\Internet Explorer\iexplore.exe
右键-属性-快捷方式-目标,修改为如下:
1
"C:\Program Files (x86)\Internet Explorer\iexplore.exe" https://www.baidu.com/#ie={inputEncoding}&wd=%s -Embedding
feign下载文件怎么获取原始文件名
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25try (Response response = gbotFileFeignService.downFile(SOURCE, sourceId, token);
InputStream inputStream = response.body().asInputStream()) {
Map<String, Collection<String>> headers = response.headers();
// fileName
String fileName;
List<String> contentDispositions = new ArrayList<>(headers.get(HttpHeaders.CONTENT_DISPOSITION));
Iterator<String> contentDispositionIterator = contentDispositions.iterator();
if (contentDispositionIterator.hasNext()) {
String contentDisposition = contentDispositionIterator.next();
String[] contentDispositionArr = StringUtils.splitByWholeSeparator(contentDisposition, "filename=");
if (contentDispositionArr.length > 1) {
fileName = URLDecoder.decode(contentDispositionArr[1], StandardCharsets.UTF_8.name());
}
}
// contentType
String contentType = null;
Collection<String> contentTypes = headers.get(HttpHeaders.CONTENT_TYPE);
Iterator<String> contentTypesIterator = contentTypes.iterator();
if (contentTypesIterator.hasNext()) {
contentType = contentTypesIterator.next();
}
}微信朋友圈封面怎么保存
路径位于:内部存储设备-Android-data-com.tencent.mm-cache-d138a5a1a54f5700d771805301d8165c(随机字符串)-sns-2(随机数字)-9(随机数字)-好友微信号bg_
如果cache下目录太多,不好确定在哪个文件夹里,先删除cache目录,访问好友朋友圈一次,重新生成的cache目录里一下就找到了make命令报错怎么解决
错误一: make: *** /lib/modules/3.10.0-1160.90.1.el7.x86_64/build/: 没有那个文件或目录
删除/lib/modules/3.10.0-1160.90.1.el7.x86_64/build软连接,重新建立,指向/usr/src/kernels/3.10.0-1160.102.1.el7.x86_64
1
2
3make -C /lib/modules/`uname -r`/build/ M=`pwd`
ln -s /usr/src/kernels/3.10.0-1160.102.1.el7.x86_64 /lib/modules/3.10.0-1160.90.1.el7.x86_64/build
linux怎么安装博通BCM43142驱动
查看无线网卡型号
1
2[root@localhost src]# /sbin/lspci | grep Broadcom
08:00.0 Network controller: Broadcom Inc. and subsidiaries BCM43142 802.11b/g/n (rev 01)安装驱动编译程序
1
yum install kernel-headers kernel-devel gcc
创建驱动编译目录,放到/usr/local/src目录便于留存
1
2mkdir /usr/local/src/hybrid-wl
cd /usr/local/src/hybrid-wl下载驱动至/usr/local/src/hybrid-wl,并解压
1
tar -xzvf hybrid-v35_64-nodebug-pcoem-6_30_223_271.tar.gz
下载并安装补丁
1
2
3
4
5
6patch -p1 < ./patch/wl-kmod-01_kernel_4.7_IEEE80211_BAND_to_NL80211_BAND.patch
patch -p1 < ./patch/wl-kmod-02_kernel_4.8_add_cfg80211_scan_info_struct.patch
patch -p1 < ./patch/wl-kmod-03_fix_kernel_warnings.patch
patch -p1 < ./patch/wl-kmod-04_kernel_4.11_remove_last_rx_in_net_device_struct.patch
patch -p1 < ./patch/wl-kmod-05_kernel_4.12_add_cfg80211_roam_info_struct.patch
patch -p1 < ./patch/wl-kmod-fix-ioctl-handling.patch替换代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19sed -i 's/[ >][>=] KERNEL_VERSION(2, 6, 3.)/>= KERNEL_VERSION(2, 6, 32)/' src/wl/sys/wl_cfg80211_hybrid.c
sed -i 's/[ >][>=] KERNEL_VERSION(3, ., .)/>= KERNEL_VERSION(2, 6, 32)/' src/wl/sys/wl_cfg80211_hybrid.c
sed -i 's/[ >][>=] KERNEL_VERSION(3, 11, .)/>= KERNEL_VERSION(2, 6, 32)/' src/wl/sys/wl_cfg80211_hybrid.c
sed -i 's/< KERNEL_VERSION(3, 18, .)/< KERNEL_VERSION(2, 6, 30)/' src/wl/sys/wl_cfg80211_hybrid.c
sed -i 's/[ >][>=] KERNEL_VERSION(3, 15, .)/>= KERNEL_VERSION(2, 6, 32)/' src/wl/sys/wl_cfg80211_hybrid.c
sed -i 's/[ >][>=] KERNEL_VERSION(4, 0, 0)/>= KERNEL_VERSION(2, 6, 32)/' src/wl/sys/wl_cfg80211_hybrid.c
sed -i 's/< KERNEL_VERSION(4,2,0)/< KERNEL_VERSION(2, 6, 30)/' src/wl/sys/wl_cfg80211_hybrid.c
sed -i 's/ >= KERNEL_VERSION(3, 11, 0)/ >= KERNEL_VERSION(3, 10, 0)/' src/wl/sys/wl_cfg80211_hybrid.c
sed -i 's/ >= KERNEL_VERSION(3, 15, 0)/ >= KERNEL_VERSION(3, 10, 0)/' src/wl/sys/wl_cfg80211_hybrid.c
sed -i 's/ < KERNEL_VERSION(3, 18, 0)/ < KERNEL_VERSION(3, 9, 0)/' src/wl/sys/wl_cfg80211_hybrid.c
sed -i 's/ >= KERNEL_VERSION(4, 0, 0)/ >= KERNEL_VERSION(3, 10, 0)/' src/wl/sys/wl_cfg80211_hybrid.c
sed -i 's/ < KERNEL_VERSION(4,2,0)/ < KERNEL_VERSION(3, 9, 0)/' src/wl/sys/wl_cfg80211_hybrid.c
sed -i 's/ >= KERNEL_VERSION(4, 7, 0)/ >= KERNEL_VERSION(3, 10, 0)/' src/wl/sys/wl_cfg80211_hybrid.c
sed -i 's/ >= KERNEL_VERSION(4, 8, 0)/ >= KERNEL_VERSION(3, 10, 0)/' src/wl/sys/wl_cfg80211_hybrid.c
sed -i 's/ >= KERNEL_VERSION(4, 11, 0)/ >= KERNEL_VERSION(3, 10, 0)/' src/wl/sys/wl_cfg80211_hybrid.c
sed -i 's/ < KERNEL_VERSION(4, 12, 0)/ < KERNEL_VERSION(3, 9, 0)/' src/wl/sys/wl_cfg80211_hybrid.c
sed -i 's/ >= KERNEL_VERSION(4, 12, 0)/ >= KERNEL_VERSION(3, 10, 0)/' src/wl/sys/wl_cfg80211_hybrid.c
sed -i 's/ <= KERNEL_VERSION(4, 10, 0)/ < KERNEL_VERSION(3, 9, 0)/' src/wl/sys/wl_linux.c编译驱动
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20[root@localhost hybrid-wl]# make
KBUILD_NOPEDANTIC=1 make -C /lib/modules/`uname -r`/build M=`pwd`
make[1]: 进入目录“/usr/src/kernels/3.10.0-1160.102.1.el7.x86_64”
CFG80211 API is prefered for this kernel version
Using CFG80211 API
CC [M] /usr/local/src/hybrid-wl/src/wl/sys/wl_linux.o
CC [M] /usr/local/src/hybrid-wl/src/wl/sys/wl_iw.o
CC [M] /usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.o
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:1845:2: 警告:从不兼容的指针类型初始化 [默认启用]
.get_station = wl_cfg80211_get_station,
^
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:1845:2: 警告:(在‘wl_cfg80211_ops.get_station’的初始化附近) [默认启用]
LD [M] /usr/local/src/hybrid-wl/wl.o
Building modules, stage 2.
CFG80211 API is prefered for this kernel version
Using CFG80211 API
MODPOST 1 modules
CC /usr/local/src/hybrid-wl/wl.mod.o
LD [M] /usr/local/src/hybrid-wl/wl.ko
make[1]: 离开目录“/usr/src/kernels/3.10.0-1160.102.1.el7.x86_64”安装
1
2[root@localhost hybrid-wireless]# make install
install -D -m 755 wl.ko /lib/modules/`uname -r`/kernel/drivers/net/wireless从内核中移除现在可能存在的无线模块
1
2
3
4
5
6
7modprobe -r bcm43xx
modprobe -r b43
modprobe -r b43legacy
modprobe -r ssb
modprobe -r bcma
modprobe -r brcmsmac
modprobe -r ndiswrapper创建模块依赖
1
depmod `uname -r`
载入驱动模块
1
modprobe wl
可能遇到的错误
1
2[root@localhost wireless]# modprobe wl
modprobe: ERROR: could not insert 'wl': Required key not available原因是系统启用了UEFI安全启动,无线网卡驱动wl模块没有正确签名,被内核拒绝加载
解决方式是BOIS中找到Secure Boot选项,将Enable改为Disable
检查驱动
1
2
3[root@localhost hybrid-wl]# lsmod | grep wl
wl 6449773 0
cfg80211 719008 1 wl连接wifi
查看无线网络接口名称,为wlp8s0
1
2
3
4
5
6
7[root@localhost ~]# iwconfig
wlp8s0 IEEE 802.11 ESSID:off/any
Mode:Managed Frequency:2.447 GHz Access Point: Not-Associated
Tx-Power=200 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Encryption key:off
Power Management:off启动 NetworkManager 服务
1
2systemctl start NetworkManager
systemctl enable NetworkManager扫描无线网
1
nmcli device wifi list
连接
1
nmcli device wifi connect SSID password PASSWORD
分配IP地址
1
2dhclient -r wlp8s0
dhclient wlp8s0查看连接信息
1
nmcli connection show
查看连接状态
1
nmcli device show
断开连接
1
nmcli device disconnect wlp8s0
yum怎么更换阿里源
备份本地yum源
1
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo_bak
替换阿里yum源
1
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
替换阿里epel源
1
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
清除并重建缓存
1
yum clean all && yum makecache
ssh连接慢怎么处理
可能原因一:DNS解析导致
1
2vim /etc/ssh/sshd_config
UseDNS no1
systemctl restart sshd
如何将一个可执行程序注册为windows服务
1
sc create gitea start= auto binPath= "\"D:\ProgramFiles\Sync\Gitea\gitea.exe\" web --config \"D:\ProgramFiles\Sync\Gitea\custom\conf\app.ini\""
计算机管理-服务和应用程序-服务,找到gitea并启动
(扩展)从windows服务删除
1
sc delete gitea
vue3如何引入全局变量
vuex
main.ts
1
2
3import store from './stores';
app.use(store)stores/index.ts
1
2
3
4
5
6
7
8
9import { createStore } from 'vuex'
export default createStore({
state: {
user: { username: '' },
yDoc: {} as Doc,
websocketProvider: {} as WebsocketProvider,
}
})用的地方
1
2
3
4
5
6import { useStore } from 'vuex'
const global = useStore().state
console.log(global.user.username)
console.log(global.yDoc)
console.log(global.websocketProvider)
pinia(推荐)
main.ts
1
2
3import { createPinia } from 'pinia'
app.use(createPinia())stores/index.ts
1
2
3
4
5
6
7
8
9import { defineStore } from 'pinia'
export const useGlobalStore = defineStore('global', {
state: () => ({
user: { username: '' },
yDoc: {} as Doc,
websocketProvider: {} as WebsocketProvider,
})
})用的地方
1
2
3
4
5
6import { useGlobalStore } from '@/stores'
const global = useGlobalStore()
console.log(global.user.username)
console.log(global.yDoc)
console.log(global.websocketProvider)
单例模式共享(有些复杂对象无法序列化)
YjsManager.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22import { Doc } from 'yjs'
import { WebsocketProvider } from 'y-websocket'
class YjsManager {
static instance: YjsManager
yDoc: Doc
wsProvider: WebsocketProvider
constructor() {
this.yDoc = new Doc()
this.wsProvider = new WebsocketProvider('ws://localhost:1234', 'my-room', this.yDoc)
}
static getInstance() {
if (!YjsManager.instance) {
YjsManager.instance = new YjsManager()
}
return YjsManager.instance
}
}
export default YjsManager用的地方
方式一:
1
2
3
4
5
6
7import YjsManager from './YjsManager';
const yjsManager = YjsManager.getInstance();
const yDoc = yjsManager.yDoc;
const wsProvider = yjsManager.wsProvider;
console.log(yDoc, wsProvider);方式二:
main.ts
1
2
3
4
5
6
7import { provide } from 'vue';
import YjsManager from './YjsManager';
const yjsManager = YjsManager.getInstance();
provide('yDoc', yjsManager.yDoc);
provide('wsProvider', yjsManager.wsProvider);用的地方
1
2
3
4
5
6import { inject } from 'vue';
const yDoc = inject('yDoc');
const wsProvider = inject('wsProvider');
console.log(yDoc, wsProvider);