Relative Content

K4NZDROID

category

「GNU Emacs」- 编辑 Markdown 文档

问题描述
我们需要在 GNU Emacs 中编辑 Markdown 文档,并且希望能够进行预览 Markdown 文档。
该笔记将整理我们使用过的 Markdown 插件。
解决方法
方法一、gh-md(已废弃,不推荐)
https://github.com/emacsorphanage/gh-md
该插件已经废弃,因此不建议使用,并且渲染出来的页面样式比较一般(在未经配置是)
方法二、Markdown Mode for Emacs(推荐)
https://jblevins.org/projects/markdown-mode/
参考 Markdown Mode for Emacs 笔记。
参考文献
EmacsWiki: Markdown Mode[……]

READ MORE

「Emacs」- Python

使用 Elpy 扩展
仓库地址:GitHub – jorgenschaefer/elpy: Emacs Python Development Environment 官方文档:Introduction — Elpy 1.35.0 documentation
注释功能
Comment/Uncomment Region 如果打开了‘transient-mark-mode’功能,可以使用‘comment-dwim’:选择区域,然后按下`M-;’即可
或者使用python-mode中内置的py-comment-region等等功能。
自动导包
Tidying imports
「py-isort」用于自动排序各个导入包,它使用的Python的「isort」模块,所以要先使用pip安装。
「Elpy」环境使用了Python的「importmagic」模块。
在Emacs中,你可以安装「importmagic.el」模块,它也使用了Python的「importmagic」模块。因此这需要在Emacs中安装「importmagic.el」,还要安装它依赖的「importmagic」和「epc」这两个Python模块。有关「importmagic.el」的安装、配置参考「README.md」文件。
参考文献
Emcas Wiki/Python Programming In Emacs[……]

READ MORE

「Emacs」- 符号重命名

重命名函数中的变量
Rename symbol in Emacs (refactor like a baws)
M-x package-install [RET] multiple-cursors [RET] M-x mc/mark-all-like-this-dwim[……]

READ MORE

「Emacs」- 常见错误汇总

device is not a termcap terminal device
问题原因
在 ~/.emacs 中,存在如下配置:

(send-string-to-terminal “\033]12;#5C5CFF\007”)

但是 send-string-to-terminal 只有在终端模式下运行时才会有效,否则会产生如上错误。
原因分析
整个问题的成因有很多,我遇到的只是其中之一。
解决方法
加入检查,判断当前环境是否启动图形界面:

(if (not (display-graphic-p))
(send-string-to-terminal “\033]12;#5C5CFF\007”)
)[……]

READ MORE

「Emacs」- 配置使用 Fcitx 输入法、Fcitx 输入法无效

问题描述
在 Emacs 中,无法使用 Fcitx 中文输入法。
原因分析
根据 Fcitx – ArchWiki/#Emacs 描述,这是 Emacs 早期 BUG 导致的。
解决方案
如果要解决这个问题,有如下几种方法:
LC_CTYPE=zh_CN.UTF-8
1)需要在启动 Emacs 时,将 LC_CTYPE 设置为 zh_CN.UTF-8 语言:

# 在 Shell 中
LC_CTYPE=zh_CN.UTF-8 /usr/bin/emacs

# 在 emacs.desktop 中

Exec=env LC_CTYPE=zh_CN.UTF-8 /usr/bin/emacs

without Window System
2)或者,使用终端模式运行,这依托于输入法在终端中能正常工作:

# 在 GNOME Terminal 中
/usr/bin/emacs -nw

Warning: locale not supported by C library, locale unchanged
How to install/change locale on Debian? `Gtk-WARNING **: Locale not supported by C library. ` when starting apps from the commandline
问题描述
当使用 env LC_ALL=zh_CN.UTF-8 /usr/bin/emacs 启动 Emacs 时,虽然能够切换输入法,但是依旧无法输入中文。
并且,此时控制台输出类似如下错误:

Warning: locale not supported by C library, locale unchanged

问题原因
没有安装 zh_CN.UTF-8(中文语言)环境。使用命令 locale -a 查看当前语言环境。
解决办法
安装语言包:

apt-get install locales-all
apt-get install language-pack-en-base language-pack-en

注意事项
1)解决方法只使用于我们的环境。发行版不同,配置方法可能不同。 2)由于我们未研究过语言环境问题,因此部分内容可能有失准确。
参考文献
Fcitx – ArchWiki/#Emacs Locale – ArchWiki[……]

READ MORE

「Emacs」- (wrong-type-argument stringp (require . info))

问题描述
在执行 package-refresh-contents 命令时(或者其他命令),经常会出现如下几种错误:


Failed to download ‘melpa’ archive.

(wrong-type-argument stringp (require . china-util))

(wrong-type-argument stringp (require . info))

问题原因
# 09/12/2020
在使用 edebug 调试后,我们没有找到具体的原因。但是,有时候又能够正常更新,所以,我们猜测是网络原因导致响应内容被破坏而导致失败。
# 01/31/2021
在使用 mitmproxy 抓包后,我们发现响应内容没有问题。
# 03/03/2021
只要把 ~/.emcas 相关的配置移出(备份到其他目录,一切就恢复正常了)。我们又怀疑这个问题与 LC_CTYPE=zh_CN.UTF 环境变量有关。
# 03/04/2021
该错误会导致我们无法通过 Package 安装工具,这是最大的问题。但是,我们找到一个替代方案,来解决无法通过 Package 安装扩展的问题:
1)首先,不加载原有配置,而仅使用自己的配置,来启动:emacs –no-init-file –load init-lite.el
2)而配置文件 init-lite.el 仅包含用于安装扩展的配置:

(setq url-proxy-services
‘((“http” . “127.0.0.1:8123”)
(“https” . “127.0.0.1:8123”)))

(custom-set-variables
‘(package-archives
‘((“gnu” . “https://elpa.gnu.org/packages/”)
(“melpa” . “https://melpa.org/packages/”))))

3)在安装完成之后,我们再重新启动 emacs 应用即可(应用的安装实际就是下载应用到 ~/.emacs.d/elpa/<package-name>/)。或者,在其他 Emacs 实例中执行:(package-initialize)
# 03/15/2021
在我们开启 debug on error(M-x toggle-debug-on-error [RET])后,再次执行引发错误的命令,我们得到如下信息:

Debugger entered–Lisp error: (wrong-type-argument[……]

READ MORE

「IntelliJ IDEA」

Activation Code: http://idea.medeming.com/jihuoma/
常见问题处理
Inotify Watches Limit
https://confluence.jetbrains.com/display/IDEADEV/Inotify+Watches+Limit
如果开发插件
https://www.jetbrains.org/intellij/sdk/docs/basics/getting_started.html
获取「社区版」的源码
IntelliJ IDEA Community Edition: http://www.jetbrains.com/idea
Certificate for x.x.x.x doesn’t match any of the subject alernative names
Getting “Server’s certificate is not trusted” message – IDEs Support (IntelliJ Platform) | JetBrains Server Certificates | IntelliJ IDEA
1)进入证书检查设置: —- for Windows and Linux:File | Settings | Tools | Server Certificates —- for macOS:IntelliJ IDEA | Preferences | Tools | Server Certificates 2)勾选:Accept non-trusted certificates automatically
Groovy
Cannot resolve symbol ‘String’
Cannot resolve symbol ‘String’ – IDEs Support (IntelliJ Platform) | JetBrains
第一步、添加 SDK 平台: 1)File / Project Structure / Platform Settings 2)然后,在 SDK 中,添加需要使用的 SDK 版本;
第二步、选择 SDK 平台: 1)File / Project Structure / Project Settings / Project 2)在 SDK: 中,选择要使用的 SDK 版本;[……]

READ MORE

「NetBeans IDE」- 常用配置

Homepage: https://netbeans.org/
安装 PHP 插件
How to add HTML, PHP and C++ plus other Plugins to Apache NetBeans 9.0 on Windows, MacOS and Linux GitHub/JQL/NetBeans9Plugins
在NetBeans IDE 9.0中,没有默认的PHP插件支持。插件仓库中也没有PHP相关的插件。
解决办法是向NetBeans IDE 9.0中添加NetBeans IDE 8.2的插件仓库,然后在安装相关的插件。
添加NetBeans IDE 8.2的插件仓库
Tools ⇒ Plugins ⇒ Settings ⇒ Add::

Name: NetBeans 8.2 Plugin Center
URL: http://updates.netbeans.org/netbeans/updates/8.2/uc/final/distribution/catalog.xml.gz

OK ⇒ Updates ⇒ Update
安装PHP插件
Tools ⇒ Plugins ⇒ Available Plugins ⇒ 选中你要安装的插件 ⇒ Next ⇒ Install
在文件浏览器中自动定位当前文件
https://stackoverflow.com/questions/5051459/netbeans-automatically-select-current-file-in-projects
<View> -> <Synchronize Editor with Views>
但是,这只能在<File>选项卡中同步,<Projects>选项卡无法同步。如图:
修改文件的扩展名
如果修改文件的扩展名,首先文件必须使没有打开的。

关闭要修改的文件。
在文件上单击右键,选择<Properties>,然后,修改<Extension>属性值。

关闭拼写检查

标题栏显示当前文件的完整路径
安装插件“Show path in titlebar”。
参考文献 https://www.douban.com/group/topic/21780189/
类的「完全限定名(FQN)」的问题
默认情况下,自动提示生成的Class带有完全限定名(FQN :: Fully Qualified Name)的:

通过Ctrl + Shift +[……]

READ MORE

「PHPStrom」

内容: phpstorm 设置笔记, 记录 phpstrom 中某些设置的位置.
默认文件的换行符设置
File > Settings > Editor > Code Style > Line separator
编辑区的主题文件位置
Windows:username@PC C:\Users\username\.WebIde100\config\colors
主题下载:http://www.phpstorm-themes.com/
无法使用中文输入法
Fcitx已经正常启动,其他应用中也没有问题,到了PHPStrom这里就不行了。
修改/path/to/phpstorm/bin/phpstorm.sh,然后在文件的最开始加入以下几行:

export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS=”@im=fcitx”

参考自「Ubuntu 16.04 Phpstorm中文输入法」一文
高级搜索
「Search for a target by name」 通过名称来搜索目标,可以搜索类、文件、符号、动作。
使用「Alt + N」快捷键,勾选「Include non-project items」。
Setup FTP (or FTPS or SFTP )
Setup FTP (or FTPS or SFTP ) in PHPStorm Phpstorm中使用SFTP
添加: 1)Tools ⇒ Deployment ⇒ Configuration 2)然后,点击 + 创建即可。
在「Mappings」中「Deployment Path On Server xxxx」是添加「Connection」前缀的「Root Path」
查看: 1)Tools ⇒ Deployment ⇒ Browse Remote Host[……]

READ MORE

「PHPStorm」- External file changes sync may be slow

系统环境:Kali GNU/Linux Rolling
问题描述
运行PHPStorm时,产生如下提示:
External file changes sync may be slow
the current inotify(7) watch limit is too low. More Details.

在Linux平台中,PHPStorm使用Inotify来获取文件的变化状态。产生该问题的原因是目录的“监视句柄”值太低了,一般在项目文件比较多的时候才会遇到这个问题,而我的情况正是项目文件比较多。
如何解决这个问题?
在/etc/sysctl.conf中加入如下配置:

fs.inotify.max_user_watches = 524288

然后,执行如下命令应用更改:

# sysctl -p –system

最后,重启你的IDE即可。
后记
07/24/2018 昨天按照上述操作修改完配置,启动PHPStorm后,PHPStorm内存使用居然下降了,原本是1.4G左右,现在降到30M多一点(情景是相同的)。exm???,会差这么多?决定观察一下再说。 07/25/2018 今天的实际内存使用量依旧保持的30M多一点。难道是因为我没有写代码? 07/27/2018 今天的内存实际使用量是在600M以下。结论是内存使用量有了明显的下降?我应该写个Shell脚本,定时收集内存使用,按照时间做个图表。突然觉得自己闲的… 07/30/2018 没事了,我想多了,它现在又是1.4G的实际内存使用量了。 08/09/2018 唉,1.4G,我要尝试用Emcas进行PHP开发了。 08/22/2018 嗯,1.0G,决定慢慢转到Emcas的阵营了。不是说这个东西不好,而是说不适合与我的工作环境。
参考文献
Inotify Watches Limit[……]

READ MORE

「PHPStrom 2016.2」- Crack With Activation Code

安装PHPStorm 2016.2 Mac破解版
系统版本:OS X 10.5 或更高 下载地址:https://pan.baidu.com/s/1kVhhv63 密码:iueh
破解方法:
1.打开将dmg镜像,将“PhpStorm.app”拖入“应用程序”中;
2.双击打开“Crack”文件夹,将“JetbrainsCrack.jar”复制到“应用程序” -> 右键PhpStorm.app -> 选择显示包内容 -> Contents -> bin;
3.编辑2.中的bin目录下的phpstorm.vmoptions,添加-javaagent:JetbrainsCrack.jar到最后一行;
4.运行软件,在激活页面选择“Activation code”,在输入框中输入“Crack”文件夹中的“SN.txt”中的激活码激活;
参考文献
PhpStorm 2016.2 Mac破解版[……]

READ MORE

「PyCharm」- The Python IDE

PyCharm: the Python IDE for Professional Developers by JetBrains

章节列表
「PyCharm」- 进行 Python 代码调试 「PyCharm」- 配置使用虚拟环境(virtualenv) 「PyCharm」- 安装与升级 「PyCharm」- 插件与常用设置 「PyCharm」- 作为编辑器使用[……]

READ MORE

「PyCharm」- 安装与升级

下载地址
Other Versions – PyCharm
如果要下载其他版本(官方未提供)怎么办? 官方提供 2019.1.4 版本,但是我们需要下载 2019.1.3 版本。此时,使用运气法,即可以修改下载链接:

https://download.jetbrains.com/python/pycharm-professional-2019.1.4.tar.gz
=>
https://download.jetbrains.com/python/pycharm-professional-2019.1.3.tar.gz[……]

READ MORE

「PyCharm」- 插件与常用设置

设置多行显示的编辑器选项卡
File / Settings / Editor / Editor Tabs / Show tabs in one row
将目录设置为模块目录
intellij idea – How to mark a directory as library root? – Stack Overflow
Right Click on Project / Mark Directory as / Sources Root
特定格式文件,进行自动换行
General—PyCharm
比如我们希望只对 Markdown 进行自动换行,进入如下设置: 1)File / Settings… / Editor / General / 右侧 2)Soft Wraps / Soft-wrap files: 3)其义自明,无需过多解释;[……]

READ MORE

「PyCharm」- 配置使用虚拟环境(virtualenv)

问题描述
我们项目众多,我们需要在 PyCharm 中针对不同项目使用 virtualenv 特性,来隔离各个项目的运行环境。
该笔记将记录:在 PyCharm 中,如何配置 virtualenv 功能。
解决方案
1)进入项目设置页面:File / Settings… / Project: <project-name> / Project Interpreter 2)添加新的解释程序:

<右侧界面> / Project Interpreter: / <齿轮> / Add… / Virtualenv Environment

对于 New environment 选项:

Location:,指定虚拟环境的安装位置(目录必须为空);
Base interpreter:,指定用于创建虚拟环境的 Python 版本,将基于该版本创建虚拟环境;
Inherit global site-packages,用于继承已经安装在系统中的模块;
Make available to all projects,对于所有项目都可以见该虚拟环境;

对于 Existing environment 选项:

Interpreter:,用于选择已经存在的虚拟环境;
Make available to all projects,对于所有项目都可以见该虚拟环境;
3)选择解释程序:<右侧界面> / Project Interpreter: / <选择刚才添加的解释程序> / OK

相关内容
基于项目的 requirements.txt / setup.py 创建特定的虚拟环境: Create a virtual environment using the project requirements
参考文献
Configure a virtual environment—PyCharm[……]

READ MORE

「PyCharm」- 进行 Python 代码调试

问题描述
代码调试功能相当方便,它可以帮助我们快速理解应用程序的执行逻辑。在复杂的场景中,远优于“观测调试”、“输出调试”等等方法。
该笔记将记录:在 PyCharm 中,如何进行代码调试。
解决方案
很多操作是类似的,大家多习以为常(比如,对于现代 IDE 工具,添加断点通常是在行号数字后面单击),所以我们这里只进行步骤概述。如果需要阅读详细说明,参考官方 Part 1. Debugging Python Code—PyCharm 文档。
以下为调试步骤: 1)添加断点,在行号数字后面单击,将显示红色圆点; 2)单击 “Debug”(图标为“绿虫”的按钮)进行调试;
常用功能按钮说明
Step through the program—PyCharm
1)Step over,向下执行,但是不要进入函数方法; 2)Step into,进入函数,用于了解函数内发生的事情; 3)Step into my code,从核心类库中出来; 4)Step out,完成当前函数执行,返回函数调用处; 5)Run to cursor,运行到鼠标所在的地方;
附加到正在 Running 的进程
Attach to process—PyCharm
MenuBar / Run / Attach to Process…,然后就可以像在 Debug 中那样进行调试。
相关链接
Debug—PyCharm Part 1. Debugging Python Code—PyCharm[……]

READ MORE

「VISUAL STUDIO CODE」- 免费的源码编辑器

参考文献
访问VSCode主页 SqlToolsService Known Issues Running VS Code on Linux/Installation Visual Studio Code on Linux

章节列表
「VSCode」- LaTeX Workshop(学习笔记) 「VSCode」- Graphviz 「VISUAL STUDIO CODE」- 编辑 Markdown 文件 「VSCode」- 插件、配置、自定义、常用设置 「VSCode」 – 常见错汇总 「VISUAL STUDIO CODE」- Python,插件,常用配置 「Visual Studio Code」- 安装 「VSCode」- 概念、术语[……]

READ MORE

「Visual Studio Code」- 安装

VSCode on Debian 10.5
# 03/30/2019

cd /tmp
curl -s https://packages.microsoft.com/keys/microsoft.asc | gpg –dearmor > microsoft.gpg
mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
echo “deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main” \
> /etc/apt/sources.list.d/vscode.list

apt-get update
apt-get install -y code # or code-insiders

其他发行版
https://code.visualstudio.com/docs/setup/linux
参考文献
Running Visual Studio Code on Linux[……]

READ MORE

「VSCode」- 常用设置

高亮功能
莫名奇妙的中文高亮
问题描述:
解决方案: Settings / Unicode Highlight / Non Basic ASCII == false
目录配置
当单个子目录时,显示为一行 VS Code not showing subfolders when there is only one – Stack Overflow explorer.compactFolders[……]

READ MORE

「VSCode」- 插件、配置、自定义、常用设置

配置文件
Visual Studio Code User and Workspace Settings
User Settings – Settings that apply globally to any instance of VS Code you open. Workspace Settings – Settings stored inside your workspace and only apply when the workspace is opened.
On Windows/Linux – File > Preferences > Settings On macOS – Code > Preferences > Settings
进入 Settings 页面,右上角,Open Settings,能够在 配置界面 与 配置文件 间相互切换;
代码编辑
代码对齐:Visual Studio Code > Formatters > Better Align
界面调整
调整 Minimap 配色
visual studio code – Change VSCode minimap colors
问题描述:在暗色主题下,滑块的颜色不明显,我们希望能够调整;
解决方案:

{

“workbench.colorCustomizations”: { # 调整滑块颜色
“minimapSlider.background”: “#0062fa1b”,
“minimapSlider.hoverBackground”: “#00fa2a1b”,
“minimapSlider.activeBackground”: “#00c97554”,
},
“editor.minimap.showSlider”: “always” # 显示“滑块”,而非 mouseover 才显示;

}

调整 行号区域 颜色
themes – vscode change linenumber color – Super User

// 背景颜色

“workbench.colorCustomizations”: {
“editorLineNumber.foreground”: “#999999”
}

// 当前行号颜色

“workbench.colorCustomizati[……]

READ MORE

「VSCode」- LaTeX Workshop(学习笔记)

LaTeX Workshop,在 VSCode 中,用于编写 LaTeX 的工具。
James-Yu/LaTeX-Workshop: Boost LaTeX typesetting efficiency with preview, compile, autocomplete, colorize, and more.
预览当前内容
1)Ctrl + Alt + v 对内容进行预览 2)或者,当前编辑窗口右上角的 View LaTeX PDF file 按钮;
参考文献
View · James-Yu/LaTeX-Workshop Wiki[……]

READ MORE

「VISUAL STUDIO CODE」- 编辑 Markdown 文件

Office Viewer
cweijan/vscode-office: 让VSCode支持预览PDF,Excel等格式, 并增加markdown所见即所得编辑器
该插件使用 Vditor 编辑器,所以提供 Markdown 的图形化预览。
绘图支持
Mermaid: Markdown Preview Mermaid Support – Visual Studio Marketplace[……]

READ MORE

「VISUAL STUDIO CODE」- Python,插件,常用配置

常见问题处理
Sort Imports
Editing Python Code in Visual Studio Code
默认 isort 模块,来实现 import 排序;
1)Right-click in editor and select Sort Imports (no selection is required) 2)Command Palette (Ctrl+Shift+P), then Python Refactor: Sort Imports[……]

READ MORE

「VSCode」 – 常见错汇总

Unable to watch for file changes in this large workspace folder
Visual Studio Code User and Workspace Settings Running Visual Studio Code on Linux
问题描述
Unable to watch for file changes in this large workspace folder. Please follow the instructions link to resolve this issue.
原因分析
工作目录的文件过多,导致 VS Code File Watcher 的句柄用完了,而无法检测全部文件的变更。
解决方案
忽略不必要的文件:

# .vscode/settings.json
{
“files.watcherExclude”: {
“**/.git/objects/**”: true,
“**/.git/subtree-cache/**”: true,
“**/node_modules/*/**”: true,
“**”: false
}
}

增加文件句柄数:

# /etc/sysctl.conf
fs.inotify.max_user_watches=524288[……]

READ MORE

「Vim」- Vi IMproved

基本操作

_KEY_
_DESCRIPTION_

D、d$
从当前光标位置开始,删除到行尾

v
进入Visual模式,可以选择

y
复制

p
粘贴

V、d、p
剪切

i、a
进入编辑模式;我们经常使用 a 键,因为我们希望光标移动到后一个字符。

全选:ggVG 从文件中读取内容,然后插入当前位置::-1.read<filename> 行号::set number
移动光标

功能
命令

第一行开始
gg

最后一行结束
G

执行命令

功能
命令

使用XMLINT格式化
ggVG:、 !xmllint –format –

重复输入
Ctrl+O 、 80 、 i 、 – 、 ESC

替换操作

功能
命令

替换命令
:%s/search/replace/g

将字符替换为换行
:%s/char/r/g

!!!替换操作是正则替换,因此特殊字符需要转义。
文本删除

功能
命令

从光标位置开始,删除到行尾
d $

常见问题处理
编辑 YAML 文件
Wrong indentation when editing Yaml in Vim – Stack Overflow

# 修复错误的自动缩进
echo ‘autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab’ >> ~/.vimrc

参考文献
Wikipedia/Vim (text editor) Delete from cursor to end of line on VI what is the command for “Select A[……]

READ MORE