Hugo 发布一篇文章的过程

安装 windows:确保有 hugo.exe 在工程目录下, 并且 .gitignore 里面写上 hugo.exe,即可 Mac:确保 hugo 已安装就可以 新建 一般,都在 post 文件夹下放 markdown 文件,使用不同文件夹来归类 hugo new post/tool/useHugo/publishArticle.md 书写 设定文章的 title, categories, tags 写入内容。标题大小从 ## 开始 本地预览 hugo server 编译成 html,输出到 /docs (路径与 GitHub Action 对应) hugo 到这里,就完成了写作 Git Push 先 fetch,再 commit,再 push。 Github Page 需要重新填写域名 因为 Github Action 在执行的时候会把 master 分支中的 /docs 内所有内容拷贝到 main 分支,这里面不包括 CNAME 文件。所以在 repository 的 setting 的 pages 重新填写域名。(问题已经解决,在 workflow action.yml 中添加 cname: 1-1.link,所以如果域名有改动,需要在这修改) ...

March 11, 2023

Notion文件导出

Notion 批量文件导出,以 PFD格式 Notion 是一款 markdown 笔记软件,可以快速书写,多端同步,支持文件导出,十分方便。 我在 notion 中写了很多页面,有时要转移到别的地方保存,那么应该怎么做呢? notion 支持导出的文件格式:PDF,HTML,MD 可是,这几种方法都有缺点。 PDF:只能当前页面,导出所有子页面,需要升级 Pro HTML:多出了一些附带的文件,文件散乱,转移和浏览都不方便 MD:导出之后,图片和文本都分开,转移不方便,文件散乱 那么,有没有更简单的办法获取我自己写的许多页面,且保存为 PDF ? 有的,步骤如下: 在notion中包含子页面导出 markdown 使用 vs code 打开,使用插件 Markdown PDF 逐页导出。 具体操作步骤 下图可以看到我的一个页面包含了多个子页面。 右上角三个点的按钮,选择 export 导出 markdown 会得到页面和子页面的目录结构 使用 vscode 打开。 安装插件 ”Markdown PDF“ 搜索 Markdown PDF, 点击安装 install。 设置 ”auto convert when save “ 在插件库里可以看到已安装 Markdown PDF 这样一来,打开一个 md 文件,ctrl + s,它就自动转换为 pdf 并输出到源路径了。 ...

March 11, 2023

Java

多线程 Java 多线程编程笔记 🔗

July 12, 2022

各种设计模式

Creational Object Created Pattern Factory Method Provide the method for creating an instance in the superclass, and allow the subclass to choose the type of the instance. 在父类中提供创建对象的方法,允许子类决定实例化对象的类型。 具备的部分:生产者协议、产品协议,往后就可以根据需要来扩展每一种产品。 具体的生产者比如 MongoCakeCreator 的存在是为了实现与产品相关的核心业务逻辑,而不仅仅是创建 MongoCake 实例。工厂方法将核心业务逻辑从具体产品类中分离出来。 // Creator protocol CakeCreator { func createCake() -> Cake func doSomethingForCake(cake: Cake) -> Cake } // Product protocol Cake { func doWork() } // ConcreteCreator class MongoCakeCreator: CakeCreator { var cake: MongoCake? func createCake() -> Cake { var cake = MongoCake() doSomethingForCake(cake: cake) return cake } func doSomethingForCake(cake: Cake) -> Cake{ cake.doWork() cake.doWork() return cake } } // ConcreteCreator class ChocolateCakeCreator: CakeCreator { func createCake() -> Cake { var cake = ChocolateCake() doSomethingForCake(cake: cake) return cake } func doSomethingForCake(cake: Cake) -> Cake{ cake.doWork() return cake } } class MongoCake: Cake { func doWork() { print("Add some mongo") } } class ChocolateCake: Cake { func doWork() { print("Add some chocolate") } } // If we want to add a type of cake call "PinapleCake", just need to // make it conform to Cake and add a creator that conform to the CakeCreator for the "PinapleCake" let cakeOne = MongoCakeCreator().createCake() Abstract Factory Base on the factory method, add an abstract factory. We can call the same abstract factory method to create different mode’s product. If we want to create another mode’s product, we need to change the concrete factory. ...

July 11, 2022

Advanced Operators

Unlike arithmetic operators in C, arithmetic operators in Swift don’t overflow by default. If want to overflow by default, use the overflow operation begin with ampersand (&). For example, the overflow addition operator (&+). It’s so free to define custom infix, prefix, postfix and assignment operators, precedence and associativity values. Bitwise Operators Here we use a function to pad 0 for the number’s print result. func pad(num: UInt8, count: Int) -> String { var str = String(num, radix: 2) var res: String = str for _ in 0..<(count - str.count) { res = "0" + res } return res } ~ NOT ...

June 19, 2022

Access Control

Access control restrict access to part of the code form code in other source files and modules. It enable us to hide the implement detail of the code, and to specify a preferred interface which that code can be accessed and used. Set access levels to individual types (classes, structures, enumerations), as well as to properties, methods, initializers, and subscripts belonging to those types. Protocols can be restricted to a certain context, as can global constants, variable, and functions. ...

June 18, 2022

Memory Safty

Most of the time we don’t have to think about accessing memory, but it’s important to understand where potential conflicts can occur, so we can avoid writing code that has conflicting access to memory. Here we are talking about the situation that happen on a single thread. Memory Access var one = 1 // write access to the memory one is stored. print("\(one)") // read access from the memory one is stored. The conflicting access to memory can occur when different part of the code are trying to access the same location in memory at the same time. ...

June 12, 2022

Automatic Reference Counting

Swift use ARC to track and manage the app’s memory usage. ARC frees up the memory used by class instances when those instances are no longer needed. Reference counting applies only to instance of classes. Reference: strong: retain the obj. (default) weak: don’t retain the object referred to, track the object referred to. unowned: don’t retain the object referred to, don’t tract the object referred to. How ARC Work Allocate a chunk of memory to store information about that instance ...

June 12, 2022

Opaque Type

A function with an opaque type hides its return value’s type information. Hiding type information at some boundaries between a module and code that calls into the module. Unlike returning a value whose type is a protocol type, opaque type preserve type identity —the compile has access to the type information, but clients of the module don’t. The Situation Here we have a Shape protocol. protocol Shape { func draw() -> String } The struct Triangle conform to the Shape. Describe how to draw(). ...

June 5, 2022

Generics

Define a class with template type , then should illustract the type when use the class.

June 5, 2022