From 33c4ec124b76dc318db5d7be65818790e27bada2 Mon Sep 17 00:00:00 2001 From: zyimm Date: Fri, 24 Nov 2023 13:15:59 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=89PHP=208.3=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E4=B8=8E=E6=96=B0=E7=89=B9=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- _posts/code-first.md | 6 +++++- _posts/git/batch_delete_branch.md | 1 + _posts/git/questions.md | 3 ++- _posts/编程/C++/env-setup.md | 5 +++-- _posts/编程/C语言/implements-php-array.md | 8 ++++++-- _posts/编程/C语言/pointer.md | 4 +++- _posts/编程/PHP/standard.md | 4 ++-- _posts/编程/设计模式/行为模式/Strategy.md | 9 ++++++--- _posts/编程/设计模式/行为模式/factory-method.md | 12 +++++++----- 10 files changed, 36 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 3f711d7..cb82f63 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ date: 2021-09-30 --- ## 关于本站 -由 [Hexo](https://hexo.io/zh-cn/) & [NexT.Mist(主题)](https://theme-next.org/) 驱动支持。因评论系统基于Gittalk,中国大陆地区读者访问本站时,可能存在网络不稳定性! +由 [Hexo](https://hexo.io/zh-cn/) & [NexT.Mist(主题)](https://theme-next.org/) 驱动支持。因评论系统基于Gitalk,中国大陆地区读者访问本站时,可能存在网络不稳定性! 网站名称为何取名为 **Wake Me Up When September Ends** ? diff --git a/_posts/code-first.md b/_posts/code-first.md index 2d24bca..3b0e0fb 100644 --- a/_posts/code-first.md +++ b/_posts/code-first.md @@ -1,5 +1,9 @@ --- title: 这是一段来源于 `carbon.now.sh` 的代码 +title: Git 免密登录 +date: 2022-09-30 +tags: + - javascript --- carbon.now.sh 可以让你的文本代码转换成图片,并可以随时分享出去! @@ -15,4 +19,4 @@ const unfold = (f, seed) => { return res ? go(f, res[1], acc.concat([res[0]])) : acc } -``` \ No newline at end of file +``` diff --git a/_posts/git/batch_delete_branch.md b/_posts/git/batch_delete_branch.md index 3b97143..e84a798 100644 --- a/_posts/git/batch_delete_branch.md +++ b/_posts/git/batch_delete_branch.md @@ -51,4 +51,5 @@ git branch -r | grep -v "main" | sed 's/origin\//:/' | xargs git push ```shell git remote prune origin ``` + 该命令会检查本地仓库中的远程分支引用,并将那些在远程仓库中已经不存在的分支引用删除掉,以保持本地仓库的分支列表与远程仓库保持同步。 diff --git a/_posts/git/questions.md b/_posts/git/questions.md index 4a6d624..afb8c80 100644 --- a/_posts/git/questions.md +++ b/_posts/git/questions.md @@ -36,6 +36,7 @@ server { client_max_body_size 500m; } ``` + ### 3.fatal: 拒绝合并无关的历史 这个错误通常发生在尝试合并两个没有共同历史的分支时。解决这个问题的一种方法是使用--allow-unrelated-histories选项来强制合并。命令如下: @@ -43,5 +44,5 @@ server { ```sh git merge --allow-unrelated-histories ``` -这个命令将允许你合并两个没有共同历史的分支。如果有冲突发生,需要解决冲突并手动提交合并结果。 +这个命令将允许你合并两个没有共同历史的分支。如果有冲突发生,需要解决冲突并手动提交合并结果。 diff --git a/_posts/编程/C++/env-setup.md b/_posts/编程/C++/env-setup.md index 2e5f9f2..efad246 100644 --- a/_posts/编程/C++/env-setup.md +++ b/_posts/编程/C++/env-setup.md @@ -1,11 +1,12 @@ --- title: Ubuntu下CLion的C/C++环境搭建 date: 2022-10-16 -tags: C++ +tags: + - C++ --- 使用Clion作为C++开发,需要安装C++ g++ make 等编译工具链,ubuntu提供了一个`build-essential`工具直接帮我们把c/c++对应的编译工具链依赖安装好 ```sh sudo apt-get install build-essential -``` \ No newline at end of file +``` diff --git a/_posts/编程/C语言/implements-php-array.md b/_posts/编程/C语言/implements-php-array.md index 7d99fcc..4f9c331 100644 --- a/_posts/编程/C语言/implements-php-array.md +++ b/_posts/编程/C语言/implements-php-array.md @@ -1,9 +1,12 @@ --- title: C 语言实现类似php的array数据类型 date: 2023-03-30 -tags: C +tags: + - C语言 --- +语言实现类似php的array数据类型! + ```c #include #include @@ -79,6 +82,7 @@ int main() { } ``` + 上面code中使用了动态数组来表示类似于PHP的array数据类型。动态数组包含一个void指针数组和数组的大小和容量。使用realloc函数来实现动态扩容。在添加元素时,先判断数组是否已满,如果已满则动态扩容。在删除元素时,将数组中的元素向前移动一个位置,覆盖掉要删除的元素。在获取元素时,根据索引返回相应的元素。需要注意的是,由于数组中的元素是void指针类型,因此需要进行类型转换后才能使用。 -这种实现方式可以用于存储任意类型的数据,包括基本类型、结构体、指针等。但需要注意的是,由于C语言中没有自带的动态类型或泛型机制,因此在使用动态数组时需要手动进行类型转换和类型检查,否则可能会导致程序出错或崩溃。 \ No newline at end of file +这种实现方式可以用于存储任意类型的数据,包括基本类型、结构体、指针等。但需要注意的是,由于C语言中没有自带的动态类型或泛型机制,因此在使用动态数组时需要手动进行类型转换和类型检查,否则可能会导致程序出错或崩溃。 diff --git a/_posts/编程/C语言/pointer.md b/_posts/编程/C语言/pointer.md index 1264e50..3c9a60a 100644 --- a/_posts/编程/C语言/pointer.md +++ b/_posts/编程/C语言/pointer.md @@ -1,7 +1,9 @@ --- title: C语言函数指针理解 date: 2022-10-13 -tags: C语言 嵌入式 +tags: + - C语言 + - 嵌入式 --- 之前写了很长时间的PHP,现在对PHP一些扩展以及swoole感兴趣,但是自己的c语言的基础太差几乎忘记一干二净。首先学一下c语言,c语言核心之一就是指针,所以这里应该记录一下这边学到函数指针,整理一下自己理解。 diff --git a/_posts/编程/PHP/standard.md b/_posts/编程/PHP/standard.md index bccbe10..afedb80 100644 --- a/_posts/编程/PHP/standard.md +++ b/_posts/编程/PHP/standard.md @@ -1,9 +1,9 @@ --- title: PHP代码统一规范规则细节 date: 2023-06-09 -tags: PHP +tags: + - PHP --- -# 规则Rule ## PHPDoc diff --git a/_posts/编程/设计模式/行为模式/Strategy.md b/_posts/编程/设计模式/行为模式/Strategy.md index c2f6c46..3a3bb9c 100644 --- a/_posts/编程/设计模式/行为模式/Strategy.md +++ b/_posts/编程/设计模式/行为模式/Strategy.md @@ -1,12 +1,14 @@ --- title: 设计模式-策略模式🍋 date: 2023-07-30 -tags: 设计模式 +tags: + - 设计模式 --- 策略模式是一种行为设计模式, 它能让你定义一组算法和策略, 并将每种算法分别放入独立的类中, 根据不同场景使用不同算法和策略。 # 需求的场景 + 假设以需要一个服务或模块来实现消息通知功能,一开始只需要邮件通知,你实现发送邮件通知功能😀。。。。 然后几天后需求方提出能不能增加短信通知,你加班加点实现短信通知功能 😵。。。 @@ -28,6 +30,7 @@ tags: 设计模式 3. 约定好策略算法接口 # 实现 + 这边使用PHP语言实现,其他具有oop编程语言逻辑类似 1. 👆定义策略算法接口 @@ -38,6 +41,7 @@ interface StrategyInterface public function handle(ContextInterface $content): mixed; } ``` + 接口StrategyInterface handle 依赖Context上下文对象。Context在这个需求中可以封装为需要发送消息对象实现依赖。如短信,邮件: ```php @@ -73,7 +77,6 @@ class DispatchStrategy } ``` - 3. 🫰运行调用 ```php @@ -81,4 +84,4 @@ class DispatchStrategy (new DispatchStrategy(new Email(), new Context()))->dispatch(); //邮件 (new DispatchStrategy(new Sms(), new Context()))->dispatch(); //短信 -``` \ No newline at end of file +``` diff --git a/_posts/编程/设计模式/行为模式/factory-method.md b/_posts/编程/设计模式/行为模式/factory-method.md index 83bdbe5..044be2f 100644 --- a/_posts/编程/设计模式/行为模式/factory-method.md +++ b/_posts/编程/设计模式/行为模式/factory-method.md @@ -1,26 +1,28 @@ --- title: 💫设计模式-工厂模式 date: 2023-09-02 -tags: 设计模式 +tags: + - 设计模式 --- **工厂模式**是一种创建型设计模式, 其在父类中提供一个创建对象的方法, 允许子类决定实例化对象的类型。 -# 需求的场景 +## 需求的场景 + 这种模式在面试中经常会被问到,很多面试题的答案会表示该模式经常用于框架的db或cache组件设计。 假设你所在项目组在开发某个项目中,使用了多种缓存数据源,比如有内存,redis,本地文件。目前每次根据不同场景使用不同类型缓存,需要实例化不同缓存实例进行操作,比较繁琐。项目组开发人员希望统一调用缓存入口,简化缓存调用心智负担。 +### 如何解决 -# 如何解决 1. 定义cache工厂类(父类)和依赖类 2. 编写各个类型cache子类 3. cache工厂类创建调用 -# 实现 +### 实现 +> > 这边实现使用PHP代码作为演示,其他oop语言逻辑类似。 - **😼1.定义cache工厂类(父类)和依赖类** ```php