Pickups 拾遗
每天进步一点点.
2020
18 Dec
R
语言stepAIC
函数报错error in eval (predvars data env)
,原因是因变量未指定。使用.
省略因变量,可采用如下写法:
1 | lm1 = lm(mpg ~ ., mtcars) |
另见passing-lm-result-to-stepaic-works-in-script-fails-inside-function.
2021
23 Mar Ctrl + Alt + M 快捷键占用
原因是与GeForce Experience快捷键冲突, 见What is preventing ctrl-alt-m from reaching IntelliJ on Windows 10?.
06 June 修改.gitignore后刷新
1 | git rm -r --cached . |
另见
- gist:4371622
- Resync git repo with new .gitignore file
26 Aug 同步新电脑
Zotero
Edit-Preferences-Sync-Settings
设置File Syncing
到坚果云指定目录Edit-Preferences-Advanced-Files and Folders
设置Base directory
到OneDrive指定目录- 安装ZotFile,
Tools-ZotFile Preferences-General Settings
, 设置Custom Location
到OneDrive指定目录, 设置subfolder
参数为/%c
镜像加速
- conda换源
Typora
语言为英文时无法选择PicGo, 需切换为中文.
Git
Quickly set up GitHub SSH example. 运行
ssh-keygen -o -t rsa -C "email@example.com"
, 然后把id_rsa.pub
内所有内容复制进SSH keys / Add new.Best way to use multiple SSH private keys on one client [closed]. 例子如下:
1
2
3
4
5
6
7
8
9
10
11# github
Host CarlossShi github.com
HostName github.com
User git
IdentityFile ~/.ssh/github_CarlossShi
# gitee
Host CarlossShi gitee.com
HostName gitee.com
User git
IdentityFile ~/.ssh/gitee_CarlossShiGit: “please tell me who you are” error. 例子如下:
1
2git config --global user.name "Carlos"
git config --global user.email "ycshi2018@gmail.com"
30 Aug 在Python环境下安装Gurobi
How do I install Gurobi for Python?
31 Aug DP切换HDMI
三块屏幕, 主机Project
选择Duplicate
.
主屏幕用DP连接了主机, 两个HDMI分别连接Switch和PS4, 想要在三者间互相切换.
实验后发现
- DP连接主机后, 想要切换HDMI都会黑一下跳回DP
- 拔了DP, HDMI相互切换正常
参考一个显示器同时接HDMI和DP输出,可以选择切换输出吗?
- 地狱男爵的回答,
正确方式是Win+P
把Project
选为Second screen only
,
然后盲切主屏幕.
17 Sep 微软拼音中文模式下使用英文标点
win+I
→ 设备 (Devices) → 输入(Typing) → 多语言文本建议 (Multilingual text suggestions) → 关闭 (Off), 见微软拼音设置中文使用英文标点, 为什么还是出现中文标点???- 若上述方法无效, 进入微软拼音设置, General → Use previous version of Microsoft Pinyin → On
https://docs.microsoft.com/en-us/windows/wsl/tutorials/gui-apps)
10 Oct WMT14 English-German预处理数据集
由于阅读Ghazvininejad2019MaskPredictPD代码facebookresearch/Mask-Predict需要, 要下载该数据集, 步骤如下:
新建fairseq/examples/translation/prepare-wmt14en2de.sh~由于网络原因, 手动新建/orig/
文件夹, 在其中下载上述代码中URLS
内的5个文件运行, 按照报错手动调整orig
内的文件目录, 发现一堆报错``` bash bash get_data.sh
1
2
3
4
5
6
2. Windows环境下手动运行`get_data`中的`preprocess.py`部分, 并把`--workers`参数改为1, 这是因为Windows不支持多线程, 具体如下:
```bash
python preprocess.py --source-lang en --target-lang ro --trainpref data/wmt16.en-ro/train --validpref data/wmt16.en-ro/valid --testpref data/wmt16.en-ro/test --destdir data-bin/wmt16.en-ro --joined-dictionary --workers 1 --nwordssrc 40000 --nwordstgt 40000
python preprocess.py --source-lang ro --target-lang en --trainpref data/wmt16.en-ro/train --validpref data/wmt16.en-ro/valid --testpref data/wmt16.en-ro/test --destdir data-bin/wmt16.ro-en --joined-dictionary --workers 1 --nwordssrc 40000 --nwordstgt 40000
26 Oct 删除多版本Office软件
Fix Office installation errors
30 Oct .md转化为知乎适应格式
使用drmingdrmer/md2zhihu,
在博客目录创建.github/workflows/md2zhihu.yml
如下,
其中pattern
格式见Patterns
to match file paths (避免一些不支持的Markdown格式在转换时报错).
1 | name: md2zhihu |
14 Nov 治疗食指关节炎
How to use your keyboard to control the mouse pointer in Windows 10
How to Use a Keyboard to Click Instead of a Mouse
28 Nov Word中给空格加下划线
- 用
Tab
和Ctrl+U
加; - Home → Paragraph → Paragraph Settings → Tabs → Default tab stops,
设置一个
Tab
的长度.
30 Nov Word中解决空格换行问题
不知道为什么pandoc到处的docx文件中部分空格会换行,
导致导出的文档非常难看,
这些空格在show paragraph marks
模式下显示为一个小黑点,
类似\(\ \cdot\ \),
解决办法是把它们全部替换为Non-Breaking Space
,
快捷键为Ctrl+Shift+Space
, 在上述模式下显示为一个空心源泉,
类似\(\ \circ \ \), 见Inserting
a Non-Breaking Space.
三种方法见Microsoft Word Tricks: 3 Simple Ways to Keep Text Together.
3 Dec Jupyter Notebook父目录import
Importing modules from parent folder
24 Dec microsoft/recommenders
sequential_recsys_amazondataset
Tensorflow版本问题
报错cannot import name 'dynamic_rnn' from 'tensorflow.nn'
,
是版本不兼容问题.
解决方法为将sli_rec.py
中from tensorflow.nn import dynamic_rnn
中的tensorflow.nn
改为tensorflow.compat.v1.nn
.
重新看一眼原Notebook中输出的版本信息
1 | print("System version: {}".format(sys.version)) |
然而不用%tensorflow_version 1.x
会疯狂报错.
sli_rec.yaml
prepare_hparams
中要输入的超参文件,
在Colab中的目录为/usr/local/lib/python3.7/dist-packages/recommenders/models/deeprec/config/sli_rec.yaml
,
当前版本(dce8f71)没有,
可以到这里抄一个reco_utils/recommender/deeprec/config/sli_rec.yaml,
内容如下
1 | #data |
29 Dec Script
file pip-script.py
is not present.
见Why Anaconda-script.py is not present ? #762,
easy_install.py
可以在anaconda3\pkgs\setuptools-$\Lib\site-packages\setuptools\command
中找到.1
easy_install pip
见Why Anaconda-script.py is not present ? #762, 慢且有冲突.
1
conda install --force-reinstall pip
见[Solved] Pycharm Use pip Error: Script file ‘D:-script.py‘ is not present.
1
python -m ensurepip --default-pip
注: 解决好后可能会收到提示要求你更新pip
,
一通操作pip install --upgrade pip
后发现pip
又坏了.
2022
06 Feb pip install -e
Install a project in editable mode (i.e. setuptools “develop mode”) from a local project path or a VCS url.
What is the
use case for pip install -e
?
pip documentation v22.0.3 - #install-editable
09 Feb Inspect Variable
1 | # [Printing Lists as Tabular Data](https://stackoverflow.com/a/26937531/12224183) |
17 Feb Visual Studio Code with LaTeX
04 Mar 组合恒等式
今天好朋友给了个组合恒等式要证明, 发现了一些有意思的式子.
Show ∑n=0∞(2nn)xn=(1−4x)−1/2
Identity for convolution of central binomial coefficients: ∑k=0n(2kk)(2(n−k)n−k)=22n∑k=0n(2kk)(2(n−k)n−k)=22n
08 Mar Jamesellis51015/Multi-Agent-Path-Finding-with-Reinforcement-Learning Quick Start
今天帮一位老哥debug, 问题是运行训练时lanpa/tensorboardX的tensorboardX.SummaryWriter
一直报错,
阅读文档tensorboardX后也没发现有啥问题,
弄了一个小时发现原来是events.out
明明过长,
把xx_experiments.py
中的name
改短点就好了.
14 Mar 邮件问论文问题
今天看论文发现作者文章没写数据生成方式, 想起上次看Wiki看不懂也给作者发了封邮件, 每次都写的狗屁不通, 干脆整理一下.
To: %Corresponding author% Subject: %Paper title%
Dear Prof. %NAME%,
With a great interest I read your paper on %TOPIC%. Since I work in a similar area, I would like to %short presentation of what you want% [e.g., to compare my approach [1, 2, 3] to yours].
Do you have %your actual inquiry, detailed%?
Thank you very much in advance.
[1] Paper [2] Paper [3] Paper
Best regards, %Your name% -- %Your signature, including your institution, email, phone, and further ways to contact you%
– How to appropriately email a researcher to ask for details about their paper?
Dear Dr. [/Mr./Ms./Prof., try to know the appropriate title from the author list] [surname], I am interested in your paper [title] but I don't have access to it [you may briefly provide a reason why you need it/don't have access, if it may be interesting to them, e.g. what you are working on and where, collaborations/connections have been made that way], so can you please send it to me? Many thanks, [signature]
– How can I send requesting email to researcher for their research articles?
17h Mar 风扇管理
连着三天夜里跑模型自动关机了, 我觉得是GPU过热触发保护机制了, 因此找了个控制风扇速度的软件Argus Monitor, 见SpeedFan not detecting fans.
19 Mar JupyterLab
大三那时候看万门的课知道了Jupyter Notebook, 那时候不会用快捷键感觉真的好难用, 从一月打MathorCup大数据开始逐渐习惯用Jupyter Notebook做一些交互式的调试 (主要也就用abdm这几个快捷键), 今天发现没目录啊喂, 就发现了JupyterLab, 真好用!
可以在Setting
→ Advanced Setting Editor
→
JSON Setting Editor
→
User Preferences
里设置自己喜欢的快捷键.
移动代码块的快捷键.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 {
"shortcuts": [
{
<<other items you may have>>
},
{
"command": "notebook:move-cell-up",
"keys": [
"Ctrl Shift ArrowUp"
],
"selector": ".jp-Notebook:focus"
},
{
"command": "notebook:move-cell-down",
"keys": [
"Ctrl Shift ArrowDown"
],
"selector": ".jp-Notebook:focus"
},
]
}– David, How to move Jupyter notebook cells up/down using keyboard shortcut?
22 Mar jainor/ocst-problem
就问你能不能认真写Readme啊!
代码两个
make
都漏了s
, 要不是不知道make
按tan
看一下都发现不了, 应该改为 (其中ocstpin2
可以改为src/test/TestInstances
里的任意实例), 第一个cmake
运行第一遍会出现CMake Warning: Manually-specified variables were not used by the project:InstanceOCSTP
, 运行第二遍没问题.1
2
3cmake . -D InstanceOCSTP=ocstpin2
make generate-instances
make run-instancesscripts/python/runOCST.py
中print
语法不一致, 都改成Python3的就好了.scripts/python/runOCST.py
中把Queue
改为queue
.键入
export LD_LIBRARY_PATH=src/lib/:lib/gurobi902
, 否则会报错./src/bin/main: error while loading shared libraries: libproject_LIB.so: cannot open shared object file: No such file or directory
和./src/bin/main: error while loading shared libraries: libgurobi90.so: cannot open shared object file: No such file or directory
.运行
make run-instances
报错, 怀疑是多线程有问题, 已提issue.1
2
3
4
5
6
7
8
9
10Exception in thread Thread-5:
Traceback (most recent call last):
File "/home/carlos/anaconda3/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/home/carlos/anaconda3/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/home/carlos/Github/ocst-problem/scripts/python/runOCST.py", line 19, in parallelRun
f=open(inputPath, "r")
FileNotFoundError: [Errno 2] No such file or directory: 'Instances/sparseRsmallW/n20p0.2/in1'
Thread 5 new task: Instances/sparseRsmallW/n20p0.2/in3 Instances/sparseRsmallW/n20p0.2/pathbased/out3.csv pathbased
02 Apr conda
Time Out
开始用组里的服务器了, 怎么装Pytorch这么慢😠?
先看看源有没有问题, 见ubuntu更换anaconda的镜像_泡泡里的月亮的博客,
Anaconda
镜像使用帮助 - 清华大学开源软件镜像站.
find /home/ -n .condarc
查找后vim
,
发现都加了💢.
使用conda config --show
,
查看remote_read_timeout_secs
(默认为66),
使用conda config --set remote_read_timeout_secs 1000
修改.
怎么还是没速度👿, 究极解决办法 pytorch / packages/pytorch,
直接下载了安装.tar.bz2
使用conda install --use-local ***.tar.bz2
安装,
见Conda
install 本地压缩包文件tar.bz2.
03 Apr 与两定圆相切的圆心轨迹
看了半天发现建模错了用不到, 不过这仍是个有趣的问题.
- Given two tangent circles, find the two centers of a third that is tangent to both with given radius: 给定两圆是相切的
- Find the center of a Circle tangent to two circles with a known radius, 给定两圆有重合
- Given two circles in a plane, is there a simple equation that gives the locus of the centers of all circles that are tangent to both?: 很好的例子展示了2/4条轨迹
- Locus of the centers of all circles tangent to two circles: 直观的轨迹动图
- Find the position of a circle tangent to two other circles: 题设和图完全和我需求一致, 且要求是数学计算
30 Apr 卸载Office
帮室友装了两次Office, 总是安装报错Error Code 30094-1015, 猜想要把Office卸载干净, 用官方卸载工具最为省心, 见Uninstall Office from a PC, 下载地址为SaRA-officeUninstallFromPC. 然而还是继续报错, 由于这台电脑之前按照此方法装过Office猜想是激活后删除后存留了一些自动更新的模块无法停止, 最后还是选择装了学校的Office.
16 Jun Steam操作愿望单
[忤旭]《Steam》利用App ID添加游戏到Steam愿望单攻略
1
javascript:AddToWishlist(<APP_ID>, 'add_to_wishlist_area', 'add_to_wishlist_area_success', 'add_to_wishlist_area_fail', '1_5_9__407' );
Steam 愿望单无法移除锁区游戏的解决方法
Clash换区后使用桌面应用购买
21 Jun Github表情的使用
A First Look at Emoji Usage on GitHub: An Empirical Study: 用户如何在与开发相关的通信中使用表情符号的大规模实证研究
Beyond Textual Issues: Understanding the Usage and Impact of GitHub Reactions: 分析了开发人员对超过 250 万个问题和 970 万个问题评论提供的反应,以回答关于反应使用和采用的九个研究问题的广泛列表
The State of the Octoverse: communicating with emoji on GitHub: 社区如何使用表情符号表达自己的统计
17 Jul 遣散Teamviewer设备
由于新电脑坏了, 用了一阵子新电脑, 又要用到学校的台式机,
Teamview登录上限到了, 要想办法替换电脑登录, 见Install
Limit Reached - TeamViewer Community and Support,
实际上步骤应是Edit profile → Free devices
,
一切一回我的Remainning switches
已经是0了,
不知道之后怎么搞.
17 Jul 安装Windows Terminal
这东西大学捣鼓电脑时候装过, 很麻烦, 现在好像比以前方便多了, 在Microsoft Store里安装好后能直接检测到所有的可用Terminal, 比如Git, Powershell, Ubuntu等, 不用像以前一样一个一个手动配置. 之后考虑美化一下, 安装Oh My Posh.
Windows中在Powershell使用官方的三个方法,
发现最后一个即运行Set-ExecutionPolicy Bypass -Scope Process -Force; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://ohmyposh.dev/install.ps1'))
可以安装,
见Installation-Windows
按照Installation-Fonts的cli方法直接安装发现连接不上,
又看到配置的字体是MesloLGM NF, 谷歌搜一下, 结果第一个是nerd-fonts/Meslo
LG M Regular Nerd Font Complete Mono.ttf,
安装一下然后在settings → Defauts → Appearance → Font face
里设置为MesloLGM
Nerd Font Mono就可以了
按照Change
your prompt在Powershell设置启动脚本, 发现权限不够,
则以管理员身份打开后运行set-executionpolicy remotesigned
,
参见How to enable execution of
PowerShell scripts?, 至此, Powershell的Oh My Posh已经配置完成.
而在WSL上首先按Installation-Linux的步骤安装,
随后参考Change
your prompt在bash的设置方法即可,
具体为vim ~/.bashrc
的末尾添加一行eval "$(oh-my-posh init bash)"
,
随后exec bash
重载.
When using oh-my-posh in Windows and the WSL, know that you can share your theme with the WSL by pointing to a theme in your Windows user's home folder.
Inside the WSL, you can find your Windows user's home folder here:
/mnt/c/Users/<WINDOWSUSERNAME>
.– Installation-Customize
设置主题时, Anacodna的Python环境不显示了, 看到了许多讨论
-
Help:
Conda Environment Doesn't display · Discussion #1103:
指出使用
conda config --set changeps1 false
, 仍未解决 -
How
to display current virtual environtment in python in oh-my-posh?:
指出
sudo vim~/.bashrc
中加入export VIRTUAL_ENV_DISABLE_PROMPT=1
, 仍未解决 - python segment is not showing current enviroment with miniconda on WSL2 #2323: 对theme的json文件中的python段进行了修改, 成功解决
下面来详细地整理一下. 由于尝试了一下午仍未解决,
最后意识到可能是和theme的配置有关,
我把配置放在了/mnt/c/Users/Carlos/.wt_theme.json
,
下面给出两个版本的theme, 来回切换发现Windows
Terminal是即时更新theme的
Configuration-Overview中给出的极简版, 就一个路径
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"final_space": true,
"blocks": [
{
"type": "prompt",
"alignment": "left",
"segments": [
{
"type": "path",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#ffffff",
"background": "#61AFEF",
"properties": {
"style": "folder"
}}]}]}jandedobbeleer.omp.json: 这就是一个让人恼火的版本, 需要修改三处地方
下面详细说一下三处改动,
即display_mode, fetch_virtual_env
和template
.
首先在json文件中查找python, 原始版本是这样的
1 | { |
解释一下这三个要改动地方的含义
- display_mode:
string
determines when the segment is displayedalways
: the segment is always displayedfiles
: the segment is only displayed when*.py
,*.ipynb
,pyproject.toml
,venv.bak
,venv
, or.venv
files are presentenvironment
: the segment is only displayed when a virtual env is present (default)context
: the segment is only displayed when eitherenvironment
orfiles
is active
- fetch_virtual_env1:
boolean
- fetch the name of the virtualenv or not - defaults totrue
- template: Every segment has a
template
property to tweak the text that is displayed. Under the hood, this uses go's text/template feature extended with sprig and offers a few standard properties to work with. (see Configuration-Templates)
前两个改成default就行, template参照python
segment is not showing current enviroment with miniconda on WSL2
#2323改为"template": " \ue235 {{ .Full }}{{ if .Venv }} {{ .Venv }}{{ end }} "
,
改动后效果如下
Appendix
Enable transparent backgrounds in Windows Terminal: 详细的步骤, 及troubleshooting
22 Aug 运行UCAS学位论文
尝试在VS Code中运行论文模板, 遇到如下问题:
Package ctable Error: You must load ctable after tikz.
: 在table
前加入tikz
即可, 即\usepackage[*<super>,list,tikz,table,math*]{*Style/artratex*}
Tex/Chap_Guide.tex:214: LaTeX Error: Command \bfseries invalid in math mode.
: 诸如$^{\citep{lamport1986document}}$
应修改为$^\text{\citep{lamport1986document}}$
, 见[Weird “
23 Aug Output Speaker to Microphone
Microphone input from speaker output回答得特别详细, 列举了一系列方法, 最后使用的是Voicemeeter. 具体方法为, 把virtual在输入输出都设为默认, 然后打开要播放的音频即可, 但此时该virtual设备是不会输出任何声音的. 若在腾讯会议中, 实际获取声音输出的是另一个设备, 可以将virtual输入的耳返输出到该设备.
02 Sep 清理C盘内存
- SpaceSniffer, find lost disk space the easy way.
- 移除pagefile.sys和hiberfil.sys获取C盘空间:
swapfile.sys
,hiberfil.sys
- What is AppData Folder in Windows and How to Clean It Up?
29 Oct 制作动态Shields
到目标网站上的Network搜索想要的数据,
中文query
使用$['净打点效率']
格式填写,
否则报错unparseable jsonpath query
, 见Unparseable
jsonpath query error on dynamic json badge #5580.
进一步考虑在Typora中设置变量进行运算, 目前还没有此功能, 见Feature Request: Make use of YAML front matter variables #4191.