Run through dates in Python

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import datetime
 
def date_range(start_date, end_date):
	for n in range(int((end_date - start_date).days)):
		yield start_date + datetime.timedelta(n)
 
 
#start = datetime.datetime(2014, 11, 26, 0, 0, 0)
start = datetime.datetime.strptime("20230101", "%Y%m%d")
end = datetime.datetime.now()
 
for i in date_range(start, end):
	weekday = i.weekday() + 1
	if weekday == 6 or weekday == 7:
		continue
	print(i.strftime('%Y%m%d'))

refer to:
https://www.cnblogs.com/ChenKeng/articles/4141791.html
https://www.zkxjob.com/48467

Install Redis in WSL

1
2
3
4
5
6
7
8
9
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
sudo apt-get update
sudo apt-get install redis
 
# start server
redis-server
 
redis-cli
	config set requirepass 123123

Redis in python,

1
2
3
4
5
6
import redis
 
redis_pool = redis.ConnectionPool(host='127.0.0.1', port=6379, password='123123')
redis_conn = redis.Redis(connection_pool=redis_pool)
redis_conn.set('name_2', 'Zarten_2')
redis_conn.get('name_2')

refer to:
https://www.jianshu.com/p/ec8b749cd842
https://blog.csdn.net/weixin_30456039/article/details/97497620
https://blog.csdn.net/csdnhxs/article/details/122450575

Move Ubuntu subsystem in Windows

After installing an Ubuntu app from Micosoft Store, open an Administrator's prompt,

1
2
3
4
5
6
7
8
9
10
wsl -l -v
wsl --export Ubuntu-22.04 d:\cext\Ubuntu\ubuntu22.04.tar
 
# or unistall it through System Settings
wsl --unregister Ubuntu-22.04
 
wsl --import Ubuntu d:\cext\Ubuntu\ubuntu22 d:\cext\Ubuntu\ubuntu22.04.tar
 
# start Ubuntu as eu
wsl -d Ubuntu -u eu

refer to:
https://blog.csdn.net/popboy29/article/details/126854886
https://blog.csdn.net/csdn_life18/article/details/128246494

Environmental variables for Calligra

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
PWD_DIR=/home/work/kde/calligra/build
INST_DIR=$PWD_DIR/installed
 
export XDG_DATA_DIRS=$INST_DIR/share:$XDG_DATA_DIRS
export XDG_CONFIG_DIRS=$INST_DIR/etc/xdg:$XDG_CONFIG_DIRS
export PATH=$INST_DIR/bin:$PATH
export QT_PLUGIN_PATH=$INST_DIR/lib64/plugins:$INST_DIR/lib/plugins:$INST_DIR/lib/x86_64-linux-gnu/plugins:$QT_PLUGIN_PATH
export QML_IMPORT_PATH=$INST_DIR/lib64/qml:$INST_DIR/lib/qml:$INST_DIR/lib/x86_64-linux-gnu/qml
export QML2_IMPORT_PATH=$INST_DIR/lib64/qml:$INST_DIR/lib/qml:$INST_DIR/lib/x86_64-linux-gnu/qml
 
export XDG_CONFIG_HOME=$HOME/kde/Settings
export KDETMP=/tmp/kdedev-$USER
export KDEVARTMP=/var/tmp/kdedev-$USER
export KDESYCOCA=$KDEVARTMP/ksycoca
 
mkdir -p $KDETMP
mkdir -p $KDEVARTMP

refer to:
https://community.kde.org/Calligra/Building/3

ERROR 2003 (HY000): Can't connect to MySQL server on ... 113

1
2
3
4
5
6
7
8
9
telnet 192.168.1.165 3306
 
# firewall in ubuntu
sudo ufw disable
 
# or found ip changed
vi /etc/mysql/mysql.conf.d/mysqld.cnf
systemctl restart mysql
systemctl status mysql

refer to:
https://blog.csdn.net/zhangasas/article/details/89432832

Recording video or audio in Windows

1
2
3
4
5
6
7
ffmpeg -f dshow -list_devices true -i dummy
 
#can only play one instance simultaneously
ffplay -f dshow -i video="Integrated Webcam"
 
#can play multiple instances at once
ffmpeg -f dshow -i audio="Microphone (Realtek(R) Audio)" out2.wav

refer to:
https://blog.csdn.net/qq_43627907/article/details/124416450
compiled ok in Qt5.15.2.

https://blog.csdn.net/how0723/article/details/77418421
https://zhuanlan.zhihu.com/p/31348306
search 'QAudioOutput' in Qt Creator Examples.

https://blog.csdn.net/jlf521521/article/details/106689503
QT5使用QCustomplot绘制频谱瀑布图并封快速傅里叶变换fft类
https://blog.csdn.net/u013915524/article/details/122288358