diff --git a/content/essays/android-app-to-read-write-nfc.md b/content/essays/android-app-to-read-write-nfc.md new file mode 100644 index 0000000..0c1f204 --- /dev/null +++ b/content/essays/android-app-to-read-write-nfc.md @@ -0,0 +1,11 @@ +--- +title: "NFC 读写和分析工具" +date: 2020-12-05T22:51:59+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +MIFARE Classic Tool (An NFC app for reading, writing, analyzing, etc. MIFARE Classic RFID tags.) - [https://f-droid.org/packages/de.syss.MifareClassicTool](https://f-droid.org/packages/de.syss.MifareClassicTool) \ No newline at end of file diff --git a/content/essays/article-about-HTTP2.md b/content/essays/article-about-HTTP2.md new file mode 100644 index 0000000..309fd71 --- /dev/null +++ b/content/essays/article-about-HTTP2.md @@ -0,0 +1,13 @@ +--- +title: "关于 HTTP/2 的深入浅出的文章" +date: 2021-01-14T21:41:05+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +[https://developers.google.com/web/fundamentals/performance/http2](https://developers.google.com/web/fundamentals/performance/http2) + +[https://sookocheff.com/post/networking/how-does-http-2-work/](https://sookocheff.com/post/networking/how-does-http-2-work/) \ No newline at end of file diff --git a/content/essays/async-in-python.md b/content/essays/async-in-python.md new file mode 100644 index 0000000..fd483fa --- /dev/null +++ b/content/essays/async-in-python.md @@ -0,0 +1,17 @@ +--- +title: "Python 的异步" +date: 2021-04-07T01:25:40+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +`await` 关键字表明这个位置可以被打断去执行其他任务,常用场景在网络 IO 中。 + +使用 `await` 修饰调用 `asyncio` 库中的 `sleep` 时,会切换上下文转去执行其他的任务,从而实现多个耗时 IO 并行等待的效果。 + +直接调用 `async` 修饰声明的函数,得到的是一个“协程”对象,此时函数尚未被真正执行,该对象可以被用来启动执行或取消执行该函数等操作。 + +[https://stackoverflow.com/questions/50757497/simplest-async-await-example-possible-in-python/53420574#53420574](https://stackoverflow.com/questions/50757497/simplest-async-await-example-possible-in-python/53420574#53420574) \ No newline at end of file diff --git a/content/essays/change-linux-password-by-modifying-shadow-file.md b/content/essays/change-linux-password-by-modifying-shadow-file.md new file mode 100644 index 0000000..1fbd53b --- /dev/null +++ b/content/essays/change-linux-password-by-modifying-shadow-file.md @@ -0,0 +1,15 @@ +--- +title: "关于通过修改/etc/shadow来实现修改用户密码" +date: 2020-12-05T22:49:42+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +[https://unix.stackexchange.com/questions/81240/manually-generate-password-for-etc-shadow](https://unix.stackexchange.com/questions/81240/manually-generate-password-for-etc-shadow) + +**生成的密码结构** + +[https://unix.stackexchange.com/questions/510990/why-is-the-output-of-openssl-passwd-different-each-time/511017#511017](https://unix.stackexchange.com/questions/510990/why-is-the-output-of-openssl-passwd-different-each-time/511017#511017) \ No newline at end of file diff --git a/content/essays/change-the-android-network-protal-provider.md b/content/essays/change-the-android-network-protal-provider.md new file mode 100644 index 0000000..b4d8cc7 --- /dev/null +++ b/content/essays/change-the-android-network-protal-provider.md @@ -0,0 +1,33 @@ +--- +title: "修改 Android 探测网络状态所用的服务提供者" +date: 2021-12-25T16:57:41+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +Android 会间歇探测网络状态,途径为访问一个 URL,能拿到预期的响应就认为网络正常,一般使用 204 (no content) 状态码作为标准的响应,其他响应可能也会接受(存疑) + +如果需要覆盖 Android 默认使用的探测服务提供者(一般是 Google),用到的命令类似下面这样(来源参考 2) + +``` +settings put global captive_portal_mode 1 +settings put global captive_portal_use_https 1 +settings put global captive_portal_http_url http://connect.rom.miui.com/generate_204 +settings put global captive_portal_https_url https://connect.rom.miui.com/generate_204 +settings put global captive_portal_fallback_url http://captive.v2ex.co/generate_204 +settings put global captive_portal_other_fallback_urls http://www.google.cn/generate_204 +``` + +captive_portal_mode 为 0 表示禁止探测网络状态,为 1 表示当网络需要登录时提示用户,为 2 表示当网络需要登录时断开此网络并不再连接到此网络;其他的几个变量的名字具有良好的自解释性,不再赘述(详细的解释见参考 1)。 + +一些公共的网络连通性测试服务见参考 4 + +参考: + +1. [Captive Portal parameters — answered by Andy Yan](https://android.stackexchange.com/questions/186993/captive-portal-parameters/186995#186995) +2. [chenshaoju/script running adb shell ](https://gist.github.com/chenshaoju/4f79bfe82ad63d9437744c282b8af35d) +3. [Change the server that Android uses for an internet connectivity check?](https://android.stackexchange.com/questions/134963/change-the-server-that-android-uses-for-an-internet-connectivity-check) +4. [检测网络联通性&generate_204服务汇总与评测 — 李德银's blog](https://imldy.cn/posts/99d42f85/) diff --git a/content/essays/chinese-copywriting-guidelines.md b/content/essays/chinese-copywriting-guidelines.md new file mode 100644 index 0000000..7b7ed3b --- /dev/null +++ b/content/essays/chinese-copywriting-guidelines.md @@ -0,0 +1,18 @@ +--- +title: "中文文案排版指北" +date: 2021-10-28T19:55:28+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +描述了中文排版时一些挺不错的习惯,尤其适合 Markdown 编写的博客 + +这里简述一些准则:除整段引用英文语句以外一般使用中文符号;中英文、中文和数字以及一般数字与单位之间需要加空格,但是全角标点与其他字符不加空格;正确拼写专有名词 + +~以前苦恼好久了到底使用中文符号还是英文符号的问题,英文标点写 Markdown 方便,但是缺少顿号并且小逗号就算加一个空格也没一个全角逗号美观,看样子我以后随便写什么的时候也应该向这一准则靠近~ + +- 原文:[https://github.com/sparanoid/chinese-copywriting-guidelines](https://github.com/sparanoid/chinese-copywriting-guidelines) +- 拓展(LCTT 有修订的引用):[https://lctt.github.io/wiki/tutorials/copywriting.html](https://lctt.github.io/wiki/tutorials/copywriting.html) \ No newline at end of file diff --git a/content/essays/common-format-of-config-file.md b/content/essays/common-format-of-config-file.md new file mode 100644 index 0000000..6bb737c --- /dev/null +++ b/content/essays/common-format-of-config-file.md @@ -0,0 +1,23 @@ +--- +title: "常见的配置文件格式" +date: 2021-01-16T11:36:04+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +**ini**: 未规定固定格式 + +**properties**: 典型应用在 spring 中, 每一行由键值构成, 键由一组使用点号表示层级关系的字符串构成, 可以比较明确地表述一个对象的各个属性 + +**json**: 起源于 JavaScript , 花括号表示对象, 方括号表示数组, 对象中每一个条目均为键值对, 值可以为数组\对象或其他基本类型. + +**xml**: 比较复杂的标记语言, 太长不再表述 + +**yaml**: 缩进敏感型的高可读性的一种格式, 连字符前缀的一组相同缩进的行表示数组, 高一级缩进则表示此为最近一个低一级缩进的条目的子条目, 虽然比 xml 简单, 但同样有些复杂. [详细描述](https://yaml.org/spec/1.2/spec.html) + +**toml**: 因为 yaml 过于复杂而指定的更简单的标准, 以方括号包含一个名称表示一个节, 节内有 `键=值` 来表述属性, 节的名称可以有点号分割, 进而可以表示对象的层级关系, 数组由双方括号包含一个名称表示. [详细描述](https://mojotv.cn/2018/12/26/what-is-toml) + +参考来源: [https://colobu.com/2017/08/31/configuration-file-format/](https://colobu.com/2017/08/31/configuration-file-format/) diff --git a/content/essays/comparing-MVC-MVP-MVVM.md b/content/essays/comparing-MVC-MVP-MVVM.md new file mode 100644 index 0000000..92c3593 --- /dev/null +++ b/content/essays/comparing-MVC-MVP-MVVM.md @@ -0,0 +1,13 @@ +--- +title: "MVC, MVP and MVVM" +date: 2021-03-10T10:26:03+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +MVC、MVP 和 MVVP 三种项目结构的简单比较,~并提出了一种更奇怪的项目结构?~ + +[https://gexiaoguo.github.io/MVC,-MVP-and-MVVM/](https://gexiaoguo.github.io/MVC,-MVP-and-MVVM/) \ No newline at end of file diff --git a/content/essays/const-in-cpp.md b/content/essays/const-in-cpp.md new file mode 100644 index 0000000..4b6f878 --- /dev/null +++ b/content/essays/const-in-cpp.md @@ -0,0 +1,13 @@ +--- +title: "关于 cpp 中 const 语法的说明" +date: 2021-02-12T19:15:13+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +*const 默认修饰它左边的东西,当左边没有东西时,它才会修饰右边的东西。* + +[https://www.zhihu.com/question/443195492/answer/1723886545](https://www.zhihu.com/question/443195492/answer/1723886545) \ No newline at end of file diff --git a/content/essays/debug-segmentation-faults-with-gdb.md b/content/essays/debug-segmentation-faults-with-gdb.md new file mode 100644 index 0000000..404be17 --- /dev/null +++ b/content/essays/debug-segmentation-faults-with-gdb.md @@ -0,0 +1,11 @@ +--- +title: "利用 gdb 根据 dump 文件进行调试" +date: 2021-08-13T16:06:23+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +原文: [Debugging Segmentation Faults and Pointer Problems](https://www.cprogramming.com/debugging/segfaults.html)#read \ No newline at end of file diff --git a/content/essays/deploy-a-mail-server.md b/content/essays/deploy-a-mail-server.md new file mode 100644 index 0000000..61d3543 --- /dev/null +++ b/content/essays/deploy-a-mail-server.md @@ -0,0 +1,15 @@ +--- +title: "建立一个邮箱服务器" +date: 2021-01-12T20:14:46+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +关于 SMTP , 默认端口 25 , 后有加密端口 587 , 至于 465 则是未定为但同时也有一定使用比例的端口. + +关于发送邮件的超时问题, 可能是 VPS 提供商禁用了从 25 端口目标为且目标为 25 端口的网络连接. + +[https://www.tecmint.com/install-postfix-mail-server-with-webmail-in-debian/](https://www.tecmint.com/install-postfix-mail-server-with-webmail-in-debian/) \ No newline at end of file diff --git a/content/essays/design-patterns-in-project.md b/content/essays/design-patterns-in-project.md new file mode 100644 index 0000000..c29ba04 --- /dev/null +++ b/content/essays/design-patterns-in-project.md @@ -0,0 +1,14 @@ +--- +title: "图说设计模式" +date: 2021-03-11T16:42:42+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +看起来很不错的设计模式相关的文章 + +- 直接阅读: [https://design-patterns.readthedocs.io/zh_CN/latest/index.html](https://design-patterns.readthedocs.io/zh_CN/latest/index.html) +- GitHub 项目地址: [https://github.com/me115/design_patterns](https://github.com/me115/design_patterns) \ No newline at end of file diff --git a/content/essays/dual-boot-windows-and-linux.md b/content/essays/dual-boot-windows-and-linux.md new file mode 100644 index 0000000..6321a39 --- /dev/null +++ b/content/essays/dual-boot-windows-and-linux.md @@ -0,0 +1,11 @@ +--- +title: "Win+Linux双系统实践" +date: 2020-12-06T13:18:24+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +[https://linux.cn/article-12891-1.html?utm_source=rss&utm_medium=rss](https://linux.cn/article-12891-1.html?utm_source=rss&utm_medium=rss) \ No newline at end of file diff --git a/content/essays/free-space-less-than-actual.md b/content/essays/free-space-less-than-actual.md new file mode 100644 index 0000000..1c1877b --- /dev/null +++ b/content/essays/free-space-less-than-actual.md @@ -0,0 +1,15 @@ +--- +title: "ext4 格式化以后有意料外的已用空间" +date: 2021-03-25T12:09:43+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +ext2/3 中格式化文件系统以后,会预留 5% 的空间,以便在空间耗尽以后,仍然可以保证系统的正常启动,允许系统管理员对系统进行维护。 + +对于纯粹的存储用硬盘,这种预留不是必需的。 + +[https://superuser.com/questions/575756/wrong-free-space-reported-for-an-ext4-formatted-3tb-drive](https://superuser.com/questions/575756/wrong-free-space-reported-for-an-ext4-formatted-3tb-drive) \ No newline at end of file diff --git a/content/essays/gin-gonic-middleware-declaration-style.md b/content/essays/gin-gonic-middleware-declaration-style.md new file mode 100644 index 0000000..c1d324f --- /dev/null +++ b/content/essays/gin-gonic-middleware-declaration-style.md @@ -0,0 +1,21 @@ +--- +title: "Gin middleware 的声明格式建议" +date: 2021-02-27T10:29:11+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +一般推荐使用如下这种一个使用一个函数返回真正需要的函数的格式, 因为这样子可以自定义一些在最后的函数中的一些参数. + +``` +func MyMiddleware(parm interface{}) gin.HandlerFunc { + return func(*gin.Context) { + // do anything with *gin.Context and parm + } +} +``` + +[https://stackoverflow.com/questions/50574796/gin-gonic-middleware-declaration/50575548#50575548](https://stackoverflow.com/questions/50574796/gin-gonic-middleware-declaration/50575548#50575548) \ No newline at end of file diff --git a/content/essays/how-computer-express-color.md b/content/essays/how-computer-express-color.md new file mode 100644 index 0000000..5644e6a --- /dev/null +++ b/content/essays/how-computer-express-color.md @@ -0,0 +1,13 @@ +--- +title: "计算机如何表示颜色" +date: 2021-09-30T08:40:42+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +[https://scientificrat.com/2017/10/12/%E7%90%86%E8%A7%A3%E9%A2%9C%E8%89%B2](https://scientificrat.com/2017/10/12/%E7%90%86%E8%A7%A3%E9%A2%9C%E8%89%B2) + +*(色域图中)马蹄形中(包括边缘)任意两点连线上的颜色,均可被这两端点颜色线性表示。所以,选择两个颜色就可以表示一条直线上的颜色;选择三个颜色,就可以表示它们构成的三角形内的颜色* diff --git a/content/essays/how-email-work.md b/content/essays/how-email-work.md new file mode 100644 index 0000000..9f9cc67 --- /dev/null +++ b/content/essays/how-email-work.md @@ -0,0 +1,17 @@ +--- +title: "电子邮件是怎样工作的" +date: 2021-01-09T17:27:32+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +MTA 如邮局一般, 对所有通过 SMTP 发送过来的邮件进行分发, 无论来源. + +MDA 如邮箱一般, 经由 MTA 发送至此的邮件会被保存, 直至用户收取或删除. + +MUA 即用户代理, 会使用 IMAP 或 POP 向 MDA 收取邮件, 随后用户可以以更舒服的姿势阅读邮件. + +[https://ccm.net/contents/116-how-email-works-mta-mda-mua](https://ccm.net/contents/116-how-email-works-mta-mda-mua) \ No newline at end of file diff --git a/content/essays/how-to-build-http-tunnel.md b/content/essays/how-to-build-http-tunnel.md new file mode 100644 index 0000000..02ad1ac --- /dev/null +++ b/content/essays/how-to-build-http-tunnel.md @@ -0,0 +1,17 @@ +--- +title: "建立 HTTP 隧道" +date: 2021-01-13T21:03:03+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +HTTP 隧道与 `gnu-netcat` 类似, 即将标准输入输出与目标主机的端口连接, 不同之处在于会使用一个代理来中转这一条连接. + +使用的情景: ssh 需要使用代理, 但是 ssh 本身没有任何代理的支持, 可以建立代理隧道以后, 使用 ssh 通过此隧道进行连接, 实现代理 ssh 的目的. + +题外话: GFW 现在不分青红皂白, 见到长时间连接的 ssh 就直接断流, 整的 ssh 也需要代理, 好烦呀 ~ + +[https://wiki.archlinux.org/index.php/HTTP_tunneling](https://wiki.archlinux.org/index.php/HTTP_tunneling) \ No newline at end of file diff --git a/content/essays/if-a-point-inside-a-polygon.md b/content/essays/if-a-point-inside-a-polygon.md new file mode 100644 index 0000000..eaccbb8 --- /dev/null +++ b/content/essays/if-a-point-inside-a-polygon.md @@ -0,0 +1,19 @@ +--- +title: "判断点是否在多边形内部" +date: 2021-10-23T22:23:14+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +1. 引射线法(适用于凹多边形和凸多边形), 以点 p 为起点, 引任意一条射线, 若射线与多边形的边相交的次数为奇数, 则 p 点在多边形内部. +2. 面积和判别法(适用于凸多边形), 以 p 作为三角形的一个顶点, 对于多边形的每一条边, 将边的两个点作为三角形的另外两个顶点, 计算三角形的面积, 若所有三角形的面积的和等于多边形的面积, 则点 p 在多边形内部. +3. 夹角判别法(适用于凸多边形), 对于多边形的每一条边, 以 p 为顶点, 向边的两个点作射线, 射线形成小于 180 度的角并记录其度数, 若所有的度数的和为 360 度, 则点 p 在多边形内部. + +对于引射线法, 为了便于计算一般引 y=y_0 的直线, 并判断该直线与多边形的边的交点位于 p 点右侧的个数, 若为奇数, 则 p 点在多边形内部. + +注: 后两个方法是否适用于凹多边形本人尚不知晓, 欢迎告知 + +参考: [https://www.cnblogs.com/luxiaoxun/p/3722358.html](https://www.cnblogs.com/luxiaoxun/p/3722358.html) \ No newline at end of file diff --git a/content/essays/iptables-and-NAT-strategy.md b/content/essays/iptables-and-NAT-strategy.md new file mode 100644 index 0000000..efb78b0 --- /dev/null +++ b/content/essays/iptables-and-NAT-strategy.md @@ -0,0 +1,11 @@ +--- +title: "iptables 和 NAT 策略" +date: 2020-11-29T08:50:43+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +拿衣服的安全屋 - iptables防火墙的应用和SNAT/DNAT策略(分享自知乎网)[https://zhuanlan.zhihu.com/p/26325389?utm_source=org.telegram.messenger&utm_medium=social&utm_oi=680895161005903872](https://zhuanlan.zhihu.com/p/26325389?utm_source=org.telegram.messenger&utm_medium=social&utm_oi=680895161005903872) diff --git a/content/essays/keep-processes-running-after-disconnect-ssh.md b/content/essays/keep-processes-running-after-disconnect-ssh.md new file mode 100644 index 0000000..ae39d90 --- /dev/null +++ b/content/essays/keep-processes-running-after-disconnect-ssh.md @@ -0,0 +1,11 @@ +--- +title: "在断开 SSH 连接后保持程序的运行" +date: 2020-11-22T16:55:48+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +[https://askubuntu.com/questions/8653/how-to-keep-processes-running-after-ending-ssh-session/222855#222855](https://askubuntu.com/questions/8653/how-to-keep-processes-running-after-ending-ssh-session/222855#222855) \ No newline at end of file diff --git a/content/essays/linux-file-system-permission.md b/content/essays/linux-file-system-permission.md new file mode 100644 index 0000000..a5a70d3 --- /dev/null +++ b/content/essays/linux-file-system-permission.md @@ -0,0 +1,57 @@ +--- +title: "Linux 文件系统中的权限" +date: 2021-09-29T21:04:52+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +## 普通权限 + +### READ + +对文件来说, 就是文件的读取权限, 如 `cat` . + +对目录来说, 就是查询目录下文件结构的权限, 如 `ls` . + +### WRITE + +对文件来说, 就是文件的写入权限, 如重定向输出到这个文件. + +对目录来说, 就是修改此目录下的文件结构的权限, 包括创建文件/删除文件/移动文件. + +### EXECUATE + +对文件来说, 就是文件的执行权限. + +对于目录来说, 就是进入此目录的权限, 并控制访问此目录中的其他文件或目录的权限, **若无此权限, 则目录的读写权限也会受到影响**. + +## 额外权限 + +### SUID (user+s) + +标记到文件(file)时, 此文件在运行时, 会以文件属主的身份运行. + +标记到目录(directory)时, 不会有任何作用. + +> 如命令 `sudo` 就是属主为 root 的添加 SUID 标记的可执行文件. + +### SGID (group+s) + +标记到文件时, 文件在运行时会以文件属组的身份运行. + +标记到目录(directory)时, 所有在此目录下创建的文件, 其属组均会变为该目录的属组. (移动文件至此目录下属组不会改变) + +### STICKY (other+t) + +标记到文件时, 不会产生任何效果. + +标记到目录时, 对于此目录下的所有文件, 将仅有这些文件的属主分别对其有删除权限. + +## 参考: + +1. [https://www.redhat.com/sysadmin/suid-sgid-sticky-bit](https://www.redhat.com/sysadmin/suid-sgid-sticky-bit) +2. [https://superuser.com/questions/471844/why-is-setuid-ignored-on-directories](https://superuser.com/questions/471844/why-is-setuid-ignored-on-directories) +3. [https://unix.stackexchange.com/questions/21251/execute-vs-read-bit-how-do-directory-permissions-in-linux-work](https://unix.stackexchange.com/questions/21251/execute-vs-read-bit-how-do-directory-permissions-in-linux-work) \ No newline at end of file diff --git a/content/essays/linux-network-DAD.md b/content/essays/linux-network-DAD.md new file mode 100644 index 0000000..1f28568 --- /dev/null +++ b/content/essays/linux-network-DAD.md @@ -0,0 +1,13 @@ +--- +title: "Linux Network DAD" +date: 2020-11-24T12:35:22+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +Linux network DAD (duplicate address detection) + +在 Linux 中禁用以后可以加快获取 IPv6 的速度,或能使 `network-wait-online.target` 完成时 IPv6 设备可用,但显然是不建议的 \ No newline at end of file diff --git a/content/essays/make-linux-a-router.md b/content/essays/make-linux-a-router.md new file mode 100644 index 0000000..cf95372 --- /dev/null +++ b/content/essays/make-linux-a-router.md @@ -0,0 +1,11 @@ +--- +title: "将Linux设置为一个路由器" +date: 2020-11-26T18:12:12+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +[https://www.tecmint.com/setup-linux-as-router/](https://www.tecmint.com/setup-linux-as-router/) diff --git a/content/essays/php-cgi-vs-php-fpm.md b/content/essays/php-cgi-vs-php-fpm.md new file mode 100644 index 0000000..4027ffd --- /dev/null +++ b/content/essays/php-cgi-vs-php-fpm.md @@ -0,0 +1,20 @@ +--- +title: "PHP-CGI 与 PHP-FPM 的关系" +date: 2021-01-14T21:50:05+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +CGI 约束了 HTTP 服务端分发程序与后面的服务处理程序之间消息传输的格式,是一个规范或协议。 + +PHP-CGI 是 HTTP 分发以后真正处理数据的程序,而 PHP-FPM(FastCGI Process Manager)去管理和调度多个 PHP-CGI 来提高性能。 + +如果站点流量较大,那么使用 PHP-FPM 能够更加充分利用资源;如果流量较小,PHP-CGI 会更好地运行 PHP 代码(参考 2),并且足以处理较小的流量。 + +## 参考: + +1. [https://segmentfault.com/q/1010000000256516](https://segmentfault.com/q/1010000000256516) +2. [https://www.basezap.com/difference-php-cgi-php-fpm/](https://www.basezap.com/difference-php-cgi-php-fpm/) \ No newline at end of file diff --git a/content/essays/playing-with-ipv6.md b/content/essays/playing-with-ipv6.md new file mode 100644 index 0000000..0c620c4 --- /dev/null +++ b/content/essays/playing-with-ipv6.md @@ -0,0 +1,11 @@ +--- +title: "Playing With IPv6" +date: 2020-11-28T10:47:14+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +[https://github.com/zbetcheckin/IPv6](https://github.com/zbetcheckin/IPv6) \ No newline at end of file diff --git a/content/essays/port-25-and-587.md b/content/essays/port-25-and-587.md new file mode 100644 index 0000000..e1ac8db --- /dev/null +++ b/content/essays/port-25-and-587.md @@ -0,0 +1,15 @@ +--- +title: "电子邮件端口号 25 和 587" +date: 2022-01-10T12:30:23+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +**25**:原为 MTA 接收任意来源的电子邮件,现建议为仅接收来自其他 MTA 的邮件 + +**587**:新开设的端口,建议作为 MUA 向 MTA 发送邮件的端口 + +由于曾有骚扰者在家宽下向 MTA 的 25 端口发送骚扰邮件,所以有相当一部分的 ISP 封禁了去往 25 端口的连接,这样 MUA 将无法向 MTA 提交自己要发送的邮件,所以另开设 587 端口作为 MUA 向 MTA 提交用户要发送的邮件 diff --git a/content/essays/preserve-some-env-variable-when-sudo.md b/content/essays/preserve-some-env-variable-when-sudo.md new file mode 100644 index 0000000..d30f1ab --- /dev/null +++ b/content/essays/preserve-some-env-variable-when-sudo.md @@ -0,0 +1,38 @@ +--- +title: "在 sudo 中保留部分环境变量" +date: 2022-02-14T23:23:35+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +默认情况下,通过 sudo 在运行程序时,会重置一个运行环境,以“最小化”的环境的形式运行目标程序,该环境中仅存在几个预先定义的变量,此外可以通过 `env_keep` 和 `env_check` 两个选项来从当前运行环境中继承已有的环境变量。 + +## 从当前运行环境保留环境变量 + +`sudo` 具有 `-preserve-env` 参数,可以从当前环境中保留参数 + +## 仅保留从特定文件中定义的环境变量 + +这里使用的发行版为 Debian bullseye,PAM 服务文件因发行版不同,其文件内容亦大不相同,本文仅供参考,自行修改 PAM 文件需谨慎。 + +*On systems that support PAM where the pam_env module is enabled for sudo, variables in the PAM environment may be merged in to the environment. If a variable in the PAM environment is already present in the user's environment, the value will only be overridden if the variable was not preserved by sudoers.* + +在为 sudo 启用 `pam_env` 模块的系统中,则从 PAM 中读入和变量会合并到环境变量中,若干 PAM 中所导入的某一个变量在当前用户环境中已经存在,那么该变量会保持当前用户环境中的值,除非在 sudoer 的配置中该变量未被保留。 + +在 `/etc/pam.d/sudo` 中添加如下配置,可从 `/etc/security/pam_env.conf` 文件中获取环境变量。这行配置项的来源是 `/etc/pam.d/su`,因 `su` 命令执行后会从 `pam_env.conf` 中导入环境变量而 `sudo` 不会,并且两个命令分别使用的 PAM 服务名称为 `su` 和 `sudo`,遂参考并修改。 + +``` +# This module parses environment configuration file(s) +# and also allows you to use an extended config +# file /etc/security/pam_env.conf. +# +# parsing /etc/environment needs "readenv=1" +session required pam_env.so readenv=1 +``` + +参考: + +[https://www.sudo.ws/docs/man/1.8.15/sudoers.man/#Command_environment](https://www.sudo.ws/docs/man/1.8.15/sudoers.man/#Command_environment) diff --git a/content/essays/python-exit-main-thread-from-sub-thread.md b/content/essays/python-exit-main-thread-from-sub-thread.md new file mode 100644 index 0000000..9c441ad --- /dev/null +++ b/content/essays/python-exit-main-thread-from-sub-thread.md @@ -0,0 +1,11 @@ +--- +title: "Python 多线程,从子线程退出主线程" +date: 2021-12-09T17:47:59+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +[https://stackoverflow.com/questions/1489669/how-to-exit-the-entire-application-from-a-python-thread/25419716#25419716](https://stackoverflow.com/questions/1489669/how-to-exit-the-entire-application-from-a-python-thread/25419716#25419716) diff --git a/content/essays/rethinking-pid-1.md b/content/essays/rethinking-pid-1.md new file mode 100644 index 0000000..89fd451 --- /dev/null +++ b/content/essays/rethinking-pid-1.md @@ -0,0 +1,23 @@ +--- +title: "Rethinking PID 1" +date: 2021-10-13T21:39:22+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +文章介绍了初始化进程(init)应该具有的特点, 同时介绍了几个初始化进程以及其优缺点. + +一个好的初始化进程应该: + +- 尽可能少启动程序(仅必要时再启动), 并且并行启动这些服务. +- 并行启动所有监听 socket , 即先放置 "placeholder" , 当 socket 真正得到需要处理的消息时再启动与之相对应的服务. +- 并行启动 D-Bus 服务, 与 socket 类似. +- 并行挂载文件系统, 即先放置虚假的目录, 当被读取时阻塞调用进程并真正挂载文件系统, 然后处理并返回调用结果. +- 降低初始化进程为系统带来的额外的开销. +- 跟踪进程, 借助 cgroup 来跟踪进程所 fork 的子进程, 并防止其逃离监视. +- 控制进程的运行环境, 借助 cgroup 来控制进程所获得的资源. + +原文: [http://0pointer.de/blog/projects/systemd.html](http://0pointer.de/blog/projects/systemd.html) diff --git a/content/essays/shell-parameter-expansion.md b/content/essays/shell-parameter-expansion.md new file mode 100644 index 0000000..58ccf14 --- /dev/null +++ b/content/essays/shell-parameter-expansion.md @@ -0,0 +1,11 @@ +--- +title: "bash中的参数扩展" +date: 2021-01-03T23:59:11+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +[https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html](https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html) \ No newline at end of file diff --git a/content/essays/some-article-about-cgroup.md b/content/essays/some-article-about-cgroup.md new file mode 100644 index 0000000..077cfbb --- /dev/null +++ b/content/essays/some-article-about-cgroup.md @@ -0,0 +1,11 @@ +--- +title: "关于 Cgroup 的一些讲解" +date: 2021-01-03T00:09:37+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +[https://access.redhat.com/documentation/zh-cn/red_hat_enterprise_linux/6/html/resource_management_guide/index](https://access.redhat.com/documentation/zh-cn/red_hat_enterprise_linux/6/html/resource_management_guide/index) \ No newline at end of file diff --git a/content/essays/sql-in-vs-join-exists.md b/content/essays/sql-in-vs-join-exists.md new file mode 100644 index 0000000..8bbe1ce --- /dev/null +++ b/content/essays/sql-in-vs-join-exists.md @@ -0,0 +1,39 @@ +--- +title: "在 SQL 中使用 IN 或 JOIN 或 EXISTS" +date: 2021-04-25T17:57:31+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +IN 有一种特殊的情况为 semi-join (参考 2), 即当 IN 中子查询未使用外部表达式中的变量, 即子查询独立于外部查询, IN 中的子查询会单独执行并建立一个对于特定的列具有 UNIQUE 约束的临时的表, 随后对此表使用类似 JOIN 的操作, 对于原表的每一行都判断是否存在于此表中, 由于临时表具有 UNIQUE 约束(甚至可能建立索引), 从而使得每获得一行结果的复杂度降低到 n\*log 水平. 如果原表的对应列也具有索引, 那么甚至会到达 log\*log 的水平. + +EXISTS 则是对于每一行进行子查询的运算, 某些情况下可能效率要高于简单的 JOIN, 某些情况下则会效率等同于 semi-join 的 IN 操作, 例如以下两个操作效率等同(参考 1) + +``` +select ... +from table_a +where col_1 in ( + select col_1 + from table_b +); + +select ... +from table_a +where exists ( + select 1 + from table_b + where table_a.col_1 = table_b.col_1 +) +``` + +结论: join 在无索引的表中表现较差, 原因是 semi-join 允许通过一个临时表进行聚合并复用此表进行匹配, 而 join 则有可能要通过两步(移除重复行和额外建立一个哈希表, 见参考 1, 此处涉及参考 1 中的测试语句然而由于本人懒惰尚未能在上面说明)来实现相同的操作. + +**对于 semi-join 的直观解释建议直接阅读参考 2.** + +## 参考资料: + +1. [https://explainextended.com/2009/06/16/in-vs-join-vs-exists/](https://explainextended.com/2009/06/16/in-vs-join-vs-exists/) +2. [https://mariadb.com/kb/en/semi-join-materialization-strategy/](https://mariadb.com/kb/en/semi-join-materialization-strategy/) \ No newline at end of file diff --git a/content/essays/stateful-and-stateless-of-ipv6-autoconfigure.md b/content/essays/stateful-and-stateless-of-ipv6-autoconfigure.md new file mode 100644 index 0000000..7831320 --- /dev/null +++ b/content/essays/stateful-and-stateless-of-ipv6-autoconfigure.md @@ -0,0 +1,11 @@ +--- +title: "IPv6 自动配置有状态和无状态" +date: 2020-11-26T18:12:12+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +[https://networkengineering.stackexchange.com/questions/47829/dhcpv6-stateful-vs-stateless-what-is-difference-between-it/47830#47830](https://networkengineering.stackexchange.com/questions/47829/dhcpv6-stateful-vs-stateless-what-is-difference-between-it/47830#47830) \ No newline at end of file diff --git a/content/essays/static-link-of-compiling.md b/content/essays/static-link-of-compiling.md new file mode 100644 index 0000000..dfafa78 --- /dev/null +++ b/content/essays/static-link-of-compiling.md @@ -0,0 +1,11 @@ +--- +title: "编译过程中的静态连接" +date: 2020-11-29T15:41:17+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +一文看懂静态链接(分享自知乎网)[https://zhuanlan.zhihu.com/p/317478523](https://zhuanlan.zhihu.com/p/317478523) diff --git a/content/essays/sync-way-in-game.md b/content/essays/sync-way-in-game.md new file mode 100644 index 0000000..893aeef --- /dev/null +++ b/content/essays/sync-way-in-game.md @@ -0,0 +1,11 @@ +--- +title: "细谈网络同步在游戏历史中的发展变化(下)" +date: 2020-12-18T12:39:17+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +[http://zhuanlan.zhihu.com/p/336869551?utm_campaign=rss&utm_medium=rss&utm_source=rss&utm_content=title](http://zhuanlan.zhihu.com/p/336869551?utm_campaign=rss&utm_medium=rss&utm_source=rss&utm_content=title) \ No newline at end of file diff --git a/content/essays/tcp-window-scale-timestamp-SACK.md b/content/essays/tcp-window-scale-timestamp-SACK.md new file mode 100644 index 0000000..66211d7 --- /dev/null +++ b/content/essays/tcp-window-scale-timestamp-SACK.md @@ -0,0 +1,11 @@ +--- +title: "TCP 窗口缩放、时间戳和 SACK" +date: 2020-11-23T23:29:43+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +[https://linux.cn/article-12710-1.html](https://linux.cn/article-12710-1.html) \ No newline at end of file diff --git a/content/essays/the-prove-mechanism-of-cryptocurrency.md b/content/essays/the-prove-mechanism-of-cryptocurrency.md new file mode 100644 index 0000000..fbf9c4a --- /dev/null +++ b/content/essays/the-prove-mechanism-of-cryptocurrency.md @@ -0,0 +1,22 @@ +--- +title: "区块链的四种证明" +date: 2021-07-01T10:01:07+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +工作证明:矿工们不断试图解开一个密码学的谜题,第一个成功解开谜题的将会得到币的奖励,其他矿工则会验证其作答的正确性 + +资产证明:币的奖励的决定性因素是币的持有者愿意锁定作为“长期存款”的币的数量,即锁定的币的数量越多,就越有可能会得到币的奖励,*此外有其他机制使币锁定量较少的矿工也能获得币,一定程度上避免富者越富* + +燃烧证明:币的奖励的决定性因素是币的持有者愿意将币投入一个“无底洞”的数量,即“烧掉”的币的数量越多,越有可能得到币的奖励。*这种币会不断贬值,所以需要用户们不断投资于此* + +容量证明:矿工们计算一个密码学谜题的成千上万种潜在答案并保存在自己的存储设备中,当新的币产生时,所有矿工搜索自己的磁盘寻找那一个特定的答案,最快找到该答案的矿工将会获得币的奖励 + +燃烧证明和资产证明都会导致富者越富 + +参考资料: +[Cryptocurrency Blockchains Don’t Need To Be Energy Intensive By Edd Gent](https://spectrum.ieee.org/computing/networks/cryptocurrency-blockchains-dont-need-to-be-energy-intensive) diff --git a/content/essays/tutorial-of-iptables.md b/content/essays/tutorial-of-iptables.md new file mode 100644 index 0000000..40ce935 --- /dev/null +++ b/content/essays/tutorial-of-iptables.md @@ -0,0 +1,11 @@ +--- +title: "iptables 教程" +date: 2020-11-26T18:12:12+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +[https://www.frozentux.net/iptables-tutorial/iptables-tutorial.html](https://www.frozentux.net/iptables-tutorial/iptables-tutorial.html) diff --git a/content/essays/vim-input-space-when-press-tab.md b/content/essays/vim-input-space-when-press-tab.md new file mode 100644 index 0000000..d54e45c --- /dev/null +++ b/content/essays/vim-input-space-when-press-tab.md @@ -0,0 +1,12 @@ +--- +title: "vim 中设置 tab 为 space" +date: 2021-06-18T15:36:27+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +参考资料: +[https://stackoverflow.com/a/1878983/10412935](https://stackoverflow.com/a/1878983/10412935) \ No newline at end of file diff --git a/content/essays/what-is-DKIM.md b/content/essays/what-is-DKIM.md new file mode 100644 index 0000000..be97e2f --- /dev/null +++ b/content/essays/what-is-DKIM.md @@ -0,0 +1,11 @@ +--- +title: "关于 DKIM 的介绍" +date: 2021-02-20T21:41:27+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +[https://postmarkapp.com/guides/dkim](https://postmarkapp.com/guides/dkim) diff --git a/content/essays/where-does-the-submodule-commit-info-store.md b/content/essays/where-does-the-submodule-commit-info-store.md new file mode 100644 index 0000000..345fd26 --- /dev/null +++ b/content/essays/where-does-the-submodule-commit-info-store.md @@ -0,0 +1,15 @@ +--- +title: "git submodule 的 commit 信息保存在何处" +date: 2022-04-29T14:54:02+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +Git 将子模块的整个根目录作视为一个整体处理,实际使用的是子模块的哪一个 commit 的信息以 commit object 的形式放在某一个 tree object 中 + +参考: + +[https://stackoverflow.com/questions/35211547/where-is-a-submodule-commit-number-stored-and-how-do-i-change-it/35211854#35211854](https://stackoverflow.com/questions/35211547/where-is-a-submodule-commit-number-stored-and-how-do-i-change-it/35211854#35211854) diff --git a/content/essays/why-scp-is-not-security.md b/content/essays/why-scp-is-not-security.md new file mode 100644 index 0000000..4a5c07f --- /dev/null +++ b/content/essays/why-scp-is-not-security.md @@ -0,0 +1,19 @@ +--- +title: "scp “不安全的原因”" +date: 2021-01-03T14:47:55+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +- scp 在以前的版本中不会对所请求的文件的文件名做验证 +- scp 拥有使用 shell 命令间接指明所需要的文件的特性,也因此难以对文件进行名称的验证(已经被移入到 -T 选项) +- 现阶段如果使用 -r 选项, scp 依然无法对接受的文件名进行验证 + +## 可能的攻击方式 + +你目前在目录 `dir` 下,该目录下有重要文件 `foo` ,你需要从远程的客户机 `remote-host` 上获取名为 `bar` 的文件,你使用命令 `scp remote-host:/bar ./` 将目标文件拷贝到自己主机,但是对方却向你发送了一个空的名为 `foo` 的文件,于是你原来的重要文件被覆盖。 + +[https://unix.stackexchange.com/questions/571293/is-scp-unsafe-should-it-be-replaced-with-sftp](https://unix.stackexchange.com/questions/571293/is-scp-unsafe-should-it-be-replaced-with-sftp) \ No newline at end of file diff --git a/content/essays/zsh-bash-startup-file-load-order.md b/content/essays/zsh-bash-startup-file-load-order.md new file mode 100644 index 0000000..1c8c24e --- /dev/null +++ b/content/essays/zsh-bash-startup-file-load-order.md @@ -0,0 +1,11 @@ +--- +title: "Zsh 和 Bash 配置文件的加载顺序" +date: 2020-11-22T17:06:28+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + +[https://medium.com/@rajsek/zsh-bash-startup-files-loading-order-bashrc-zshrc-etc-e30045652f2e](https://medium.com/@rajsek/zsh-bash-startup-files-loading-order-bashrc-zshrc-etc-e30045652f2e) \ No newline at end of file