music - cue

分轨 CUE 文件

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
REM DATE 2005
REM DISCID 8E0F5C0B
REM COMMENT "ExactAudioCopy v1.3"
CATALOG 0602498845233
PERFORMER "Sigur Ros"
TITLE "Takk..."
REM COMPOSER "Sigur Ros"
FILE "01 - Takk....wav" WAVE
TRACK 01 AUDIO
TITLE "Takk..."
PERFORMER "Sigur Ros"
REM COMPOSER "Sigur Ros"
ISRC GBKEE0500001
INDEX 01 00:00:00
FILE "02 - Glosoli.wav" WAVE
TRACK 02 AUDIO
TITLE "Glosoli"
PERFORMER "Sigur Ros"
REM COMPOSER "Sigur Ros"
ISRC GBKEE0500002
INDEX 01 00:00:00
FILE "03 - Hoppipolla.wav" WAVE
TRACK 03 AUDIO
TITLE "Hoppipolla"
PERFORMER "Sigur Ros"
REM COMPOSER "Sigur Ros"
ISRC GBKEE0500003
INDEX 01 00:00:00
FILE "04 - Meo Bloonasir.wav" WAVE
TRACK 04 AUDIO
TITLE "Meo Bloonasir"
PERFORMER "Sigur Ros"
REM COMPOSER "Sigur Ros"
ISRC GBKEE0500004
INDEX 01 00:00:00
FILE "05 - Se Lest.wav" WAVE
TRACK 05 AUDIO
TITLE "Se Lest"
PERFORMER "Sigur Ros"
REM COMPOSER "Sigur Ros"
ISRC GBKEE0500005
INDEX 01 00:00:00
FILE "06 - Saeglopur.wav" WAVE
TRACK 06 AUDIO
TITLE "Saeglopur"
PERFORMER "Sigur Ros"
REM COMPOSER "Sigur Ros"
ISRC GBKEE0500006
INDEX 01 00:00:00
FILE "07 - Milano.wav" WAVE
TRACK 07 AUDIO
TITLE "Milano"
PERFORMER "Sigur Ros"
REM COMPOSER "Sigur Ros"
ISRC GBKEE0500007
INDEX 01 00:00:00
FILE "08 - Gong.wav" WAVE
TRACK 08 AUDIO
TITLE "Gong"
PERFORMER "Sigur Ros"
REM COMPOSER "Sigur Ros"
ISRC GBKEE0500008
INDEX 01 00:00:00
FILE "09 - Andvari.wav" WAVE
TRACK 09 AUDIO
TITLE "Andvari"
PERFORMER "Sigur Ros"
REM COMPOSER "Sigur Ros"
ISRC GBKEE0500009
INDEX 01 00:00:00
FILE "10 - Svo Hljott.wav" WAVE
TRACK 10 AUDIO
TITLE "Svo Hljott"
PERFORMER "Sigur Ros"
REM COMPOSER "Sigur Ros"
ISRC GBKEE0500010
INDEX 01 00:00:00
FILE "11 - Heysatan.wav" WAVE
TRACK 11 AUDIO
TITLE "Heysatan"
PERFORMER "Sigur Ros"
REM COMPOSER "Sigur Ros"
ISRC GBKEE0500011
INDEX 01 00:00:00

整轨 CUE 文件

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
PERFORMER "李娜"
TITLE "信天游"
FILE "CDImage.wav" WAVE
TRACK 01 AUDIO
TITLE "信天游"
PERFORMER "李娜"
INDEX 00 00:00:00
INDEX 01 00:00:02
TRACK 02 AUDIO
TITLE "风中的承诺"
PERFORMER "李娜"
INDEX 01 04:41:63
TRACK 03 AUDIO
TITLE "我热恋的故乡"
PERFORMER "李娜"
INDEX 01 09:26:12
TRACK 04 AUDIO
TITLE "小小少年"
PERFORMER "李娜"
INDEX 01 13:36:02
TRACK 05 AUDIO
TITLE "小路"
PERFORMER "李娜"
INDEX 01 17:35:40
TRACK 06 AUDIO
TITLE "夏日最后的玫瑰"
PERFORMER "李娜"
INDEX 01 21:50:21
TRACK 07 AUDIO
TITLE "小放牛"
PERFORMER "李娜"
INDEX 01 24:27:51
TRACK 08 AUDIO
TITLE "黄土高坡"
PERFORMER "李娜"
INDEX 01 28:11:43
TRACK 09 AUDIO
TITLE "喀秋莎"
PERFORMER "李娜"
INDEX 01 32:05:74
TRACK 10 AUDIO
TITLE "阿里郎"
PERFORMER "李娜"
INDEX 01 34:46:50
TRACK 11 AUDIO
TITLE "秋风歌"
PERFORMER "李娜"
INDEX 01 38:13:49
TRACK 12 AUDIO
TITLE "康定情歌"
PERFORMER "李娜"
INDEX 01 42:40:32
TRACK 13 AUDIO
TITLE "阿里山的姑娘"
PERFORMER "李娜"
INDEX 01 45:10:09
TRACK 14 AUDIO
TITLE "写不完的爱"
PERFORMER "李娜"
INDEX 01 48:31:17

os x

分区

1
2
3
4
5
6
$ diskutil partitionDisk disk4 GPT fat32 Linux 10% ExFat d2 10% ExFat d3 80%
# 对 disk4 进行分区,GPT格式
# 三个分区:
# Linux (fat32格式,10%空间)
# d2 (ExFat格式,10%空间)
# d3 (ExFat格式,80%空间)

Write Bootable ISO

目标磁盘尽量格式化为 Mac OS Extended (Journaled),通过 ls /Volumns 查看目标磁盘。

Mac OS

Big Sur

1
2
3
4
5
6
7
8
$ sudo /Applications/Install\ macOS\ Big\ Sur.app/Contents/Resources/createinstallmedia --volume /Volumes/Big\ Sur --nointeraction # "/Volumes/Big\ Sur" 需要定制
# output
Erasing disk: 0%... 10%... 20%... 30%... 100%
Copying to disk: 0%... 10%... 20%... 30%... 100%
Making disk bootable...
Install media now available at "/Volumes/Install macOS Big Sur"

# 如果不显示进度,尝试重启终端 / 在 Disk Utility 中重新挂在卷

Catalina

1
$ sudo /Applications/Install\ macOS\ Catalina.app/Contents/Resources/createinstallmedia --volume /Volumes/Catalina --nointeraction

参考

Windows

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 注: 暂时废弃

#### 1. Convert ISO to DMG
$ hdiutil convert -format UDRW -o cn_windows_10_business_editions_version_2004_updated_sep_2020_x64_dvd_7134ba4b.img cn_windows_10_business_editions_version_2004_updated_sep_2020_x64_dvd_7134ba4b.iso
# output 64_dvd_7134ba4b.iso
Reading CPBA_X64FRE_ZH-CN_DV9 (Apple_UDF : 0)…
..............................................................................................................................................................................................
Elapsed Time: 12.059s
Speed: 420.2Mbytes/sec
Savings: 0.0%
created: /Users/wii/Downloads/cn_windows_10_business_editions_version_2004_updated_sep_2020_x64_dvd_7134ba4b.img.dmg

#### 2. Rename
$ mv cn_windows_10_business_editions_version_2004_updated_sep_2020_x64_dvd_7134ba4b.img.dmg cn_windows_10_business_editions_version_2004_updated_sep_2020_x64_dvd_7134ba4b.img

#### 3. 写入
$ sudo dd if=cn_windows_10_business_editions_version_2004_updated_sep_2020_x64_dvd_7134ba4b.img of=/dev/rdisk2s5 bs=1m

unraid 插件

插件

1
2
3
4
5
6
$ vi /etc/hosts
199.232.68.133 raw.githubusercontent.com

# Plugin
https://github.com/dlandon/unassigned.devices/raw/master/unassigned.devices.plg
https://raw.githubusercontent.com/Squidly271/community.applications/master/plugins/community.applications.plg

VFIO

1
vfio-pci.ids=054c:0899

备份 USB 内容

Main -> Flash -> Flash Backup

image-20231207101821105

Problems

Requested operation is not valid: cannot undefine domain with nvram

1
$ virsh undefine --nvram "Macinabox BigSur"

设置 DNS

1
2
3
$ vim /boot/config/go
echo "nameserver 8.8.8.8" >> /etc/resolv.conf
echo "nameserver 4.4.4.4" >> /etc/resolv.conf

下载 App 网络错误

查找 IP

1
2
3
# vim /etc/hosts
# 添加如下内容
<ip> raw.githubusercontent.com

保存数据

Unraid 系统中,/boot/mnt 之外的路径均在内存中,在下次重启后,会丢失。可以用如下方式来保存数据。

  • 第一步,数据保存在 /boot 路径下
  • 第二步,在 Unraid 系统启动时把文件拷贝到目标位置,有两种方式
    • 其一,更改 /boot/config/go 文件(shell 脚本),在 Unraid 系统启动时把文件拷贝到目标位置
    • 其二,使用 User Scripts 插件,在 Apps 中搜索安装,在 Plugins 中使用
      • 可以选择脚本运行时间,如果只需运行一次,选 At First Array Start Only 即可
      • 脚本路径在界面有显示,比如 /boot/config/plugins/user.scripts/scripts/dockerInit,这是一个目录,下面有个 script 文件用于编写命令

Docker

重启 Docker

1
$ /etc/rc.d/rc.docker restart

问题

环境变量无法清除

比如设置了 http_proxy,后面在界面移除环境变量,但是进入容器后,环境变量依然存在,需要手动修改容器配置。

1
/var/lib/docker/containers/{container-id}/config.json

django startup

安装

1
2
3
4
5
# 安装最新
$ pip3 install django

# 指定版本
$ pip3 install django==3.0.7

创建应用

1
2
3
4
5
# 创建Project
$ django-admin startproject mysite

# 创建应用
$ python3 manage.py startapp polls

配置

数据库

MySQL

使用 pymysql 库替代 mysqldb

1
2
3
4
5
6
7
8
# 安装
$ pip install pymysql

# 替换
## settings.py 中添加
import pymysql
pymysql.version_info = (1, 4, 13, 'final', 0)
pymysql.install_as_MySQLdb()

配置

1
2
3
4
5
6
7
8
9
10
11
12
# settings.py

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'test-db',
'HOST': '127.0.0.1',
'PORT': 3306,
'USER': 'root',
'PASSWORD': 'root'
}
}

python virtualenv

安装

1
2
3
4
5
6
7
8
# ubuntu
$ sudo apt install python3-pip # 安装pip3
## OR
$ sudo apt-get install python-pip python-dev python-virtualenv # for Python 2.7
$ sudo apt-get install python3-pip python3-dev python-virtualenv # for Python 3.n

# pip
$ pip3 install virtualenv

新建虚拟环境

1
2
3
4
5
6
$ virtualenv venv	# sample

$ virtualenv --no-site-packages venv # 不使用外部库; 默认不使用,在virtualenv>=20版本中移除,添加上可能会报错
$ virtualenv --system-site-packages venv # 使用系统库
$ virtualenv -p python3 venv # 指定Python版本
$ virtualenv --copies venv # 复制Python程序等,而不是链接

激活新环境

1
2
3
4
5
6
7
# 进入环境
$ cd venv
# 激活
$ source bin/activate

$ source bin/activate # bash, sh, ksh, or zsh
$ source bin/activate.csh # csh or tcsh

退出环境

1
deactivate

配合supervisor

supervisor配置文件

1
2
3
4
5
6
7
8
9
10
11
[program:myproj-uwsgi]
process_name=myproj-uwsgi
command=/home/myuser/.virtualenvs/myproj/bin/uwsgi
--chdir /home/myuser/projects/myproj
-w myproj:app
environment=PATH="/home/myuser/.virtualenvs/myproj/bin:%(ENV_PATH)s"
user=myuser
group=myuser
killasgroup=true
startsecs=5
stopwaitsecs=10

导出环境

1
2
3
4
# 导出
$ pip freeze > requirements
# 安装
$ pip install -r requirements

python requests

安装

1
$ pip3 install requests

引入

1
import requests

请求

1
2
headers = {'user-agent': '...'}
requests.get(url, headers=headers)

参数

1
2
3
4
5
6
7
8
# Get
payload = {'key1': 'value1', 'key2': ['value2', 'value3']}
r = requests.get(url, params=payload)

# Post Json
data = {'key': 'value'}
r = requests.post(url, data=json.dumps(data), headers=headers) # OR
r = requests.post(url, json=data)

读取

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 返回码
r.status_code

# Json 数据
r.json()

# 读取二进制数据
r.content

# 读取图片
from PIL import Image
from io import BytesIO

i = Image.open(BytesIO(r.content))

# 保存到文件
with open(filename, 'wb') as fd:
for chunk in r.iter_content(chunk_size=128):
fd.write(chunk)

树莓派配置

Wifi认证及静态IP

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#### Raspbian
$ cat /etc/network/interfaces
# ...
source-directory /etc/network/interfaces.d

auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.8.160
netmask 255.255.255.0
network 192.168.8.1
gateway 192.168.8.1
broadcast 192.168.8.255
wpa-essid "..."
wpa-psk "..."

# wpa-essid: wifi名称
# wpa-psk: wifi 密码,psk认证

树莓派连接游戏手柄

驱动

xpadneo

依赖

1
2
# Raspbian
$ sudo apt install dkms raspberrypi-kernel-headers

安装

1
2
3
4
5
6
7
8
9
$ git clone https://github.com/atar-axis/xpadneo.git
$ cd xpadneo
$ sudo ./install.sh

# 如遇如下报错
# Your kernel headers for kernel 4.19.97-v7l+ cannot be found at
# /lib/modules/4.19.97-v7l+/build or /lib/modules/4.19.97-v7l+/source.
# 将 /lib/modules 下拷贝一份至缺失版本,如:
# sudo cp -r /lib/modules/5.4.79-v7l+ /lib/modules/4.19.97-v7l+

连接

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$ bluetoothctl
$ [bluetooth]# scan on
...
# 长按xbox前侧配对键,至指示灯快速闪烁,出下如下新设备,记录其mac地址
[NEW] Device <MAC> Xbox Wireless Controller
...
[bluetooth]# pairable on
[bluetooth]# power on
[bluetooth]# pair <MAC>
[bluetooth]# trust <MAC>
[bluetooth]# connect <MAC>

# 如若报 Failed to connect: org.bluez.Error.Failed 错误,执行如下命令并重启系统
$ echo 'options bluetooth disable_ertm=Y' | sudo tee -a /etc/modprobe.d/bluetooth.conf

其他

1
2
# 查看设备
$ bluetoothctl devices

使用

Python

安装依赖

1
$ sudo pip3 install evdev asyncio

测试

1
2
3
4
5
6
$ cd xpadneo/misc/examples # 克隆下来的Git仓库
$ python3 python_asyncio_evdev/gamepad.py
press x to stop, Y to rumble light, B to rumble once, trigger and joystick right to see analog value
trigger_right = 32.98 joystick_right_x = 0

# 如果一切顺利,按手柄Y会感受到长震动;按B会感受到短震动;按X退出程序

按键

按键 code type 值类型
LT 10 03 区间,0~1023
RT 09 03 区间,0~1023
LB 310 01 单值,00,01
RB 311 01 单值,00,01
左摇杆 Y轴 01 03 区间,0~65535
左摇杆 X轴 00 03 区间,0~65535
右摇杆 Y轴 05 03 区间,0~65535
右摇杆 X轴 02 03 区间,0~65535
视图 158 01 单值,00,01
菜单 315 01 单值,00,01
十字键 上 17 03 单值,00,-1
十字键 下 17 03 单值,00,01
十字键 左 16 03 单值,00,-1
十字键 右 16 03 单值,00,01
Y 308 01 单值,00,01
X 307 01 单值,00,01
A 304 01 单值,00,01
B 305 01 单值,00,01

  • 摇杆X轴左侧为0,Y轴上侧为0