pandas 合并数据常用的两个函数:

刚好有一个对比 RNN 和 LSTM 神经网络运行结果的场景分别用到了这两个函数:

  • 采用 concat 合并两个csv表; csv表为两次运行结果的,列名基本一致。
  • 采用 merge 合并模型运行条件类似的表, 用于对比数据
阅读全文 »

一、WSL 安装 Ubuntu22.04

  1. 启用 WSL

  2. 打开 Microsoft Store,安装 Ubuntu22.04

  3. 设置源,更新
    ref: https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/

更新:sudo apt update

升级:sudo apt upgrade

  1. 安装 ZSH、oh-my-zsh

参考 zsh & oh-my-zsh 安装配置

二、安装 openmc

ref: https://docs.openmc.org/en/stable/quickinstall.html

  1. 参照 Installing from Source on Ubuntu,安装 openmc。

    安装完成后,运行 openmc 试一下, 提示错误: 找不到材料数据卡 cross_sections.xml

  2. 下载材料数据集

1
2
3
4
git clone https://github.com/openmc-dev/data openmc-dev_data

cd openmc-dev_data
python3 convert_nndc71.py
阅读全文 »

ref: https://github.com/ScoopInstaller/Scoop/issues/4390

0. 问题: scoop 本身不支持安装包有解压密码的自动解压。

scoop 本身不支持安装包有解压密码的自动解压。因此在安装 MAS 时会卡在解压处,无法继续安装。

1. 7z 命令手册

7z 命令是支持的: 7z x FILENAME.7z -pPWD -oOUTDIR

2. 查 Scoop 源码的解压函数

找到 Scoop 源码里的 “~\scoop\apps\scoop\current\lib\decompress.ps1” 文件。
文件封装了 Expand-7zipArchive 函数命令, 但参数没有能将密码传入的方法。

3. 试 Scoop 的 pre_install

Scoop Wiki 里提到了 pre_install 等说法。

在 MAS.json 中加入:

1
"pre_install": "7z x $dir\\$fname -p1234 $('-o' + $dir)"

尝试了很多次还是不起作用,Scoop的策略是遇到压缩包先执行解压、再做后续的事情。所以这一句不会被执行,安装程序依旧卡在解压处,无法继续安装。

阅读全文 »

1. 客户端 VSCode 安装 Remote 插件

安装插件, 略

添加远程连接 aaa@192.168.1.xxx, 连接、等待, 输入密码

2. 连接时可能连不上,并出现警告

警告: The remote host may not meet VS Code Server's prerequisitesfor glibc and libstdc++

阅读全文 »

从在线日历获取事件

Outlook 查看日历链接: 设置-日历-共享日历-发布日历,可以看到如下链接:

https://outlook.live.com/owa/calendar/d82e6afe-XXXX-XXXX/cid-YYYY/calendar.ics

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
from ics import Calendar
import requests

# Parse the URL
url = "https://outlook.live.com/owa/calendar/d82e6afe--XXXX-XXXX/cid-YYYY/calendar.ics"
cal = Calendar(requests.get(url).text)


#%%
# Print all the events
events = sorted(cal.events)
for event in events:
print(event.begin , event.name )

#%%
timeline = cal.timeline
for tl in timeline:
print(tl.begin , tl.name )

# %%
# 获取今天及之后的事件
from ics import Calendar
import requests
import arrow

cal = Calendar(requests.get(url).text)

today = arrow.now()
print(today)
today = arrow.now().replace(hour=0, minute=0, second=0, microsecond=0)
print(today)
today = arrow.now().span('day')[0]
print(today)

evts = cal.timeline.start_after(today)

for evt in evts:
print(evt.begin.strftime("%Y-%m-%d %a %H:%M"), evt.name )

ref: (https://github.com/ScoopInstaller/Scoop/wiki/App-Manifests)

尝试自己制作一个安装配置文件, 软件是 N_m3u8DL-RE

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
{
"version": "v0.2.0-beta",
"description": "Cross-Platform, modern and powerful stream downloader for MPD/M3U8/ISM",
"homepage": "https://github.com/nilaoda/N_m3u8DL-RE",
"license": "MIT",
"suggest": {
"ffmpeg": [
"ffmpeg",
"ffmpeg-nightly"
]
},
"url": "https://github.com/nilaoda/N_m3u8DL-RE/releases/download/v0.2.0-beta/N_m3u8DL-RE_Beta_win-x64_20230628.zip",
"hash": "9e3133f03e112cc57f34bf04234b7857ae7c997c214f0eb510a120739c388652",
"bin": [
"N_m3u8DL-RE_Beta_win-x64/N_m3u8DL-RE.exe",
[
"N_m3u8DL-RE.exe",
"N_m3u8DL_RE"
]
],
"checkver": {
"url": "https://api.github.com/repos/nilaoda/N_m3u8DL-RE/releases",
"regex": "releases/download/(?<tag>[vV]?[\\w-.]+)/N_m3u8DL-RE_Beta_win-x64_(?<date>[\\d.-]+).zip",
"replace": "${tag}"
},
"autoupdate": {
"url": "https://github.com/nilaoda/N_m3u8DL-RE/releases/download/$matchTag/N_m3u8DL-RE_Beta_win-x64_$matchDate.zip"
}
}

阅读全文 »

1 安装 zsh

1
2
3
4
5
sudo apt install zsh

# echo $SHELL # 显示当前 shell 类型
# cat /etc/shells # 显示可使用的 shell
# chsh -s /bin/zsh # 将 zsh 设为默认终端

2 安装 ohmyzsh

ref: https://ohmyz.sh/

  • 用 wget 安装。
1
sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"

有时候会出现 443 网路错误,可手动下载、安装 install.sh

1
nano zsh-install.sh

打开 https://github.com/ohmyzsh/ohmyzsh/blob/master/tools/install.sh
将安装代码全部复制进去

1
2
sudo chmod +x zsh-install.sh
./zsh-install.sh

3 安装 ohmyzsh (gitee 源)

ref: https://gitee.com/mirrors/oh-my-zsh.git

1
sh -c "$(wget https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh -O -)"

4 配置 ohmyzsh (gitee 源)

  • 打开配置文件
1
nano ~/.zshrc
  • 修改如下:
1
2
3
4
5
# 主题
ZSH_THEME="ys"

# 插件
plugins=(git zsh-autosuggestions zsh-syntax-highlighting )
  • 也可以用命令修改:
1
2
sed -i 's/^ZSH_THEME=.*/ZSH_THEME="ys"/g' .zshrc
sed -i 's/^plugins=.*/plugins=(git zsh-autosuggestions zsh-syntax-highlighting)/g' .zshrc
  • 下载插件
1
2
3
git clone https://gitee.com/mirrors/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

git clone https://gitee.com/mirrors/zsh-syntax-highlighting ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

ref: https://github.com/zsh-users/zsh-autosuggestions

ref: https://github.com/zsh-users/zsh-syntax-highlighting

  • 加载配置文件, 使生效
1
source ~/.zshrc

===

1
2
3
4
5
6
7
8
9
10
11
12
sudo apt install zsh -y
sudo apt install git -y

sh -c "$(wget https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh -O -)"

sed -i 's/^ZSH_THEME=.*/ZSH_THEME="ys"/g' .zshrc
sed -i 's/^plugins=.*/plugins=(git zsh-autosuggestions zsh-syntax-highlighting)/g' .zshrc

git clone https://gitee.com/mirrors/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://gitee.com/mirrors/zsh-syntax-highlighting ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

source ~/.zshrc

用 raspberry pico w 和墨水屏做一个 mnist-clock

1. 墨水屏

2. pico w 基本配置

2.1 刷固件

  • https://micropython.org/download/rp2-pico-w/

  • 下载类似rp2-pico-w-20221107-unstable-v1.19.1-616-g5987130af.uf2

  • 首次将 pico w 连接电脑之后,会以U盘形式弹出来,把固件拖进去。

  • 已经刷过固件的,按着板子上的 BOOTTSEL 按钮连接电脑。

重新上电,固件就自动刷好了。

2.2 开发环境 thonny

  • 安装 thonny, scoop install thonny
  • Thonny IED: 打开 ‘运行’ - ‘配置解释器’, 配置一下
  • 运行一下板载的 LED 测试程序:
1
2
3
4
5
6
7
8
9
from machine import Pin 
import time

led = Pin('LED', Pin.OUT)
while(True):
led.on()
time.sleep(1)
led.off()
time.sleep(1)

可以看到板载的 LED 在闪烁。

阅读全文 »

  • 申请 leancloud 应用。

ref: https://console.leancloud.cn/apps

  • 安装 pip install leancloud
1
2
3
4
5
6
7
8
9
10
11
12

import leancloud

leancloud.init("xxx", "yyy")

TestObject = leancloud.Object.extend('my_log')
test_object = TestObject()
test_object.set('col1', 'a')
test_object.set('col2', 'b')
test_object.set('col3', 'c')
test_object.save()

群晖型: DS218+,
CPU: Intel Celeron J3355
DSM版本: 7.0

1. 安装 bootstrap

1
2
3
4
5
wget http://ipkg.nslu2-linux.org/feeds/optware/syno-i686/cross/unstable/syno-i686-bootstrap_1.2-7_i686.xsh
chmod +x syno-i686-bootstrap_1.2-7_i686.xsh
sudo sh syno-i686-bootstrap_1.2-7_i686.xsh

reboot

2. 安装 aria2

1
2
3
ipkg update
ipkg install aria2

阅读全文 »

日历文件:将csv文件转换为ics

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
# pip install icalendar

# %%
import pandas as pd

df = pd.read_csv('1.csv',
encoding='gbk',
header=0,
parse_dates=[0,1],
date_parser=lambda x: pd.to_datetime(x, format='%Y/%m/%d %H:%M'))

print(df)


# %%
from icalendar import Calendar, Event

cal = Calendar()
cal.add('version', '2.0')


for row in df.itertuples(index=False):
stime, etime, thing = row[0], row[1], row[2]

# print(row[0], row[1], row[2])

event = Event()
event.add('summary', thing)
event.add('dtstart', stime)
event.add('dtend', etime)
# print(event)

cal.add_component(event)

txt = cal.to_ical()
print(str(txt, encoding='utf8'))


# %%
with open('1.ics', 'wb') as f:
f.write(txt)

文件替换:保留原始路径

问题描述:将特定类型文件的文件挑出来,放入一个文件夹,批量处理之后再替换原文件。

1. 文件迁移

  • 将文件路径经过md5加密后,作为文件名前缀。
  • 复制文件到一个新文件夹
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
# xyz_a.py
# %%
import os
import shutil

from hashlib import md5


# 创建 md5 对象
def encrypt_md5(s):
new_md5 = md5()
new_md5.update(s.encode(encoding='utf-8'))
return new_md5.hexdigest()


# old_root = os.getcwd() # 待处理文件的根目录
old_root = "E:\\"
new_root = "D:\\0\\"
exts = ['.xyz']


for parent, dirnames, filenames in os.walk(old_root):
for filename in filenames:
extension = os.path.splitext(filename)[1]

if extension.lower() in ext:

old_dir = os.path.join(parent, filename)
new_name = encrypt_md5(old_dir) + '_' + filename # 修改文件名
new_dir = os.path.join(new_root, new_name)

print(f'{old_dir};; {new_name};; {new_dir}')

# shutil.copyfile(old_dir, new_dir) # 复制到新文件夹


  • 用命令行运行:
1
python xyz_a.py > zzz.csv
阅读全文 »

0 Winget官网

Winget官网: https://github.com/microsoft/winget-cli

1. 安装 winget (Win10 LTSC)

目前官方只支持 windows store 安装,但 LTSC 并没有应用商店。

1
2
3
4
版本	Windows 10 企业版 LTSC
版本号 21H2
操作系统内部版本 19044.1766
体验 Windows Feature Experience Pack 120.2212.4170.0

Win10 手动安装 winget 方法如下:

参考安装方法: https://github.com/muradbuyukasik/winget-script

1.1 安装 VC++ v14 依赖

1
2
3
cd ~
aria2c -c -s 5 -x 5 https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx # 注意版本号
Add-AppxPackage Microsoft.VCLibs.x64.14.00.Desktop.appx

1.2 安装 Microsoft.UI.Xaml 依赖

1
2
3
4
5
6
cd ~
aria2c -c -s 5 -x 5 https://www.nuget.org/api/v2/package/Microsoft.UI.Xaml/2.7.1 # 注意版本号
# 下载的文件: microsoft.ui.xaml.2.7.1.nupkg,解压
7z x microsoft.ui.xaml.2.7.1.nupkg -o*
cd microsoft.ui.xaml.2.7.1\tools\AppX\x64\Release
Add-AppxPackage microsoft.ui.xaml.2.7.appx

1.3 安装 winget

1
2
3
4
5
6
7
8
cd ~
aria2c -c -s 5 -x 5 https://github.com/microsoft/winget-cli/releases/download/v1.2.10271/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle # 注意版本号
# aria2c -c -s 5 -x 5 https://ghproxy.net/https://github.com/microsoft/winget-cli/releases/download/v1.2.10271/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle

Add-AppPackage .\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle

.\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle

阅读全文 »

1.安装

以scoop安装oh-my-posh。

1
2
3
4
5
6
#
scoop install psreadline
scoop install posh-git

#
scoop install oh-my-posh

2. 配置文件

新建、修改配置文件,运行:

1
2
if (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force }
code $PROFILE

加入以下内容:

1
2
3
4
5

chcp 65001
Set-PSReadLineOption -PredictionSource History

oh-my-posh init pwsh --config ~\scoop\persist\oh-my-posh\themes\yo.omp.yaml | Invoke-Expression

ref: https://ohmyposh.dev/docs/

阅读全文 »

ref: (https://dominikrys.com/posts/zsh-in-git-bash-on-windows/)

1. 安装 zsh

https://packages.msys2.org/package/zsh?repo=msys&variant=x86_64

  • 1.1 从 MSYS2 下载 zsh package
1
aria2c -c -s 8 -x 8 https://mirror.msys2.org/msys/x86_64/zsh-5.8-5-x86_64.pkg.tar.zst
  • 1.2 解压
    压缩文件的格式是ZST, 需要安装一个支持的解压软件
1
2
3
scoop install zstd

zstd -d zsh-5.8-5-x86_64.pkg.tar.zst

\etc\usr 文件夹解压到本机 git 的安装目录:

  • 1.3 运行
1
2
3
4
5
zsh

autoload -U zsh-newuser-install
zsh-newuser-install -f

  • 设置 zsh 自启动, 在~/.bashrc加入:
1
2
3
if [ -t 1 ]; then
exec zsh
fi
阅读全文 »

书包没拿好掉地上, XPS13 9370 屏幕左上角磕到了,开机花屏。

想罢工是不可能的。

换新屏,连壳一起换了。

阅读全文 »

右键菜单

1
2
3
4
5
6
# 管理员运行运行后重启:
reg.exe add "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" /f /ve

# 恢复默认:
# reg.exe delete "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}" /f