自定义 Sh Bash Zsh Shell 配置
Jun 11, 2022
Sh Shell 系统范围配置: /etc/profile 用户范围配置: $HOME/.profile 有些系统(例如 Debian)会读取 /etc/profile.d 目录里的 *.sh 作为自定义的系统级配置: if [ -d /etc/profile.d ]; then for i in /etc/profile.d/*.sh; do [ -r $i ] && . $i done unset i fi 以上代码写在 /etc/profile 里,如果没有说明当前的系统不支持读取 profile.d 里的自定义配置,可以自己加上。 …
Swift 中的值类型和引用类型
May 30, 2022
Swift 中的 struct, enum, tuple 是值类型,class 是引用类型。 值类型在传递的时候是直接拷贝一份数据副本,而引用类型不拷贝数据,只是增加引用计数。 为了避免内存浪费,Swift 对值类型增加了一个写时复制(Copy-On-Write)的特性,只有在赋值后做了修改才会发生拷贝数据副本的行为,否则就和引用类型一样共享一份数据。 …
C++ 实现一个 AutoLayout 的 DSL
May 18, 2022
DSL 全称是 Domain-Specific Language,叫作领域专用语言。用于解决特定问题而提出的编程语言。比如 CSS 就是解决网页中布局问题而产生的 DSL。 自动布局(AutoLayout)是开发中必不可少的,但是其 API 沉长难记而且写出来的代码不直观。为了解决这些而出现了 Masonry 和 SnapKit。这两个库也属于自动布局的 DSL。 …
在 FreeBSD 中安装 Bash Shell
May 17, 2022
FreeBSD 安装后默认可选的 Shell 只有 sh 和 tcsh,如果需要 bash 和 zsh 是需要自己安装配置的。 安装 bash: sudo pkg install bash 以上命令使用到了 sudo,在 FreeBSD 里 sudo 也是需要自己安装。 配置 bash: …
FreeBSD 中的 pkg 使用代理
May 17, 2022
FreeBSD 13.1 发布了,终于修复了在 Apple Silicon 上不能使用网络的问题。 下载地址: https://download.freebsd.org/releases/arm64/aarch64/ISO-IMAGES/13.1/ pkg 是 FreeBSD 的包管理工具,类似于 Debian 上的 apt。 pkg 的配置文件路径是 /usr/local/etc/pkg.conf,代理信息需要写在配置文件中,环境变量 http_proxy 没有作用。 …
[推荐] 免费的编程字体
May 16, 2022
Source Code Pro Adobe 出品的开源字体,不支持连字符和 Powerline。 https://github.com/adobe-fonts/source-code-pro/releases 下载:Source-Code-Pro.tar.xz Cascadia Code 微软内置于 Windows Terminal 和 Visual Studio 2019 里的字体,免费开源,而且支持提供连字符、Powerline 字体支持。 …
Visual Studio 2022 中使用 Clang
May 15, 2022
本文适用 Visual Studio 2017 以及更高版本 下载 LLVM for Windows 当前最新的 LLVM 版本是 14.0.3,在以下链接可以下载官方编译好的版本: https://github.com/llvm/llvm-project/releases x86: LLVM-14.0.3-win32.exe x86_64: LLVM-14.0.3-win64.exe arm64: LLVM-14.0.3-woa64.zip 我下载的是 LLVM-14.0.3-win64.exe,安装在目录 C:\Program Files\LLVM-14.0.3 …
Visual Studio 2022 以 UTF-8 编译 CMake 项目
May 14, 2022
本文适用 Visual Studio 2017 以及更高版本 默认情况下,MSVC 使用当前系统的代码页(Code Page)编译源文件,这样在编译字符串字面量的时候就和当前系统的代码页一致。 …
制作 Visual Studio 2022 离线安装包
May 09, 2022
Create an offline installation of Visual Studio Workload Component ID Visual Studio 2022 version: 17.4 %~dp0\vs2022_Professional.exe ^ --lang zh-CN ^ --add Microsoft.VisualStudio.Workload.CoreEditor ^ --add Microsoft.VisualStudio.Workload.NativeDesktop ^ --add Microsoft.VisualStudio.Component.Git ^ --add Microsoft.VisualStudio.Component.VC.ATL.ARM ^ --add Microsoft.VisualStudio.Component.VC.ATL.ARM64 ^ --add Microsoft.VisualStudio.Component.VC.ATL.ARM.Spectre ^ --add Microsoft.VisualStudio.Component.VC.ATL.ARM64.Spectre ^ --add Microsoft.VisualStudio.Component.VC.ATL.Spectre ^ --add Microsoft.VisualStudio.Component.VC.ATLMFC.Spectre ^ --add Microsoft.VisualStudio.Component.VC.MFC.ARM ^ --add Microsoft.VisualStudio.Component.VC.MFC.ARM64 ^ --add Microsoft.VisualStudio.Component.VC.MFC.ARM.Spectre ^ --add Microsoft.VisualStudio.Component.VC.MFC.ARM64.Spectre ^ --add Microsoft.VisualStudio.Component.VC.Redist.MSM ^ --add Microsoft.VisualStudio.Component.VC.Runtimes.ARM.Spectre ^ --add Microsoft.VisualStudio.Component.VC.Runtimes.ARM64.Spectre ^ --add Microsoft.VisualStudio.Component.VC.Runtimes.x86.x64.Spectre ^ --includeRecommended ^ --includeOptional ^ --layout %~dp0\vs2022_professional Visual Studio 2019 …
Swift 使用泛型实现命名空间形式的扩展
May 03, 2022
什么是命名空间形式的扩展 什么是扩展? extension UIView { var v: ... } v 就是扩展出来的一个 UIView 属性。 什么是命名空间? 相较于 ObjC 没有命名空间的特性,Swift 使用模块名作为命名空间进行隔离,防止不同模块中有同名扩展而造成冲突。 …