Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
LynxStirp
committed
Jun 12, 2021
1 parent
f3d67f4
commit 7e4096a
Showing
74 changed files
with
378 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
--- | ||
title: "友情链接" | ||
date: 2021-04-04T20:54:47Z | ||
lastModified: 2021-04-04T20:54:47Z | ||
lastmod: 2021-03-04T20:54:47Z | ||
draft: false | ||
falsemenu: "main" | ||
hiddenfromhomepage: true | ||
weight: 50 | ||
--- | ||
友情链接: | ||
----- | ||
|
||
[木杉的博客](http://mushanshitiancai.github.io/atom.xml) 一个持续上进的程序员 | ||
[木杉的博客](http://mushanshitiancai.github.io/atom.xml) 一个持续上进的程序员 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--- | ||
title: "从Simple迁移到Hugo" | ||
date: 2021-04-05T17:54:47Z | ||
lastmod: 2021-06-10T17:54:47Z | ||
draft: false | ||
toc: true | ||
tags: ["hugo","Simple", "迁移"] | ||
--- | ||
|
||
## 初试Hugo | ||
|
||
Simple由于GitHub登录API变化而无法登录使用,已经过去1年多,我原本计划修复Simple的登陆方案的,后来实在是懒癌发作外加似乎需要服务器支持才能完成GitHub的新版登录API,索性弃坑重新寻找写博客的方法。恰好前两天看到了[Keep Coding](https://liujiacai.net/)的博客,稍微了解了一下,觉得Hugo应该是比Hexo,或者说基于NodeJS的任意方案都要好一些,毕竟依赖会少不少,而且实在不行就用docker跑编译,总之是省了不少本地依赖的事情。 | ||
|
||
通常来说,迁移博客最基础的,就是将文章迁移过来。Simple作为基于GitHub API的静态博客,它自己是没有数据库来存储文章的,而是将markdown作为注释放在正文里的。我们恰好可以借助这一特性,将相应的md文件提取出来: | ||
|
||
```bash | ||
cat fileName.html | awk '/<!-- markdown -->/,/<!-- markdown end -->/' > exports/fileName.md | ||
``` | ||
|
||
怎么遍历文件名就不赘述了,bash脚本跑循环就好。 | ||
|
||
不过这样导出的文件里还有markdown的注解,可以使用如下命令来清除: | ||
|
||
```bash | ||
sed -i "s/<!-- markdown -->//g" *.md | ||
sed -i "s/<!-- markdown end -->//g" *.md | ||
``` | ||
|
||
那么当我之前的博客都备份好了,怎么导入到Hugo里呢? | ||
|
||
先不说Hugo的站点结构如何,这个问题各位观众那都可以慢慢调整;最重要的是Hugo的md文件是有格式的,你得遵照一定的格式导入,也就是每篇文章开头的元数据,至少包含title,date。此外我希望导入以后,网页的URL还能按照原先的URL存在,避免死链.那怎么办呢? | ||
|
||
原来Simple有一个main.json是专门存储元数据的,我们可以从它解析到相应的参数,填入目标文档。经过一番探究,我写了如下的脚本生成相应的目标文档: | ||
|
||
```bash | ||
echo "---" >hugo/content/imported/$filename.md && \ | ||
echo "title: \"$(jq -r '.posts|map(select(.path == "'$filename'.html").title)[0]' main.json)\"" >> hugo/content/imported/$filename.md && \ | ||
echo "date: \"$(jq -r '.posts|map(select(.path == "'$filename'.html").date)[0]' main.json)T00:00:00Z\"" >> hugo/content/imported/$filename.md && \ | ||
echo "draft: false" >> hugo/content/imported/$filename.md && \ | ||
echo "tags: [\"$(jq -r '.posts|map(select(.path == "'$filename'.html").tags)[0]|split(" ")|join("\",\"")' main.json)\"]" >> hugo/content/imported/$filename.md && \ | ||
echo "url: $filename.html" >> hugo/content/imported/$filename.md && \ | ||
echo "---" >> hugo/content/imported/$filename.md && cat exports/$filename.md >> hugo/content/imported/$filename.md | ||
``` | ||
|
||
通过上述脚本指定的url, 我们导入的文章url仍然在根目录下,不会受到影响,这样的url就跟原来的simple的url一致,保证迁移后搜索引擎的链接仍然有效。 | ||
|
||
## 使用Even | ||
据我观察, Hugo 使用 Even 主题的博客很多,简单了解了一下,这个主题已经比较完善了.但是我刚刚开始使用它,咦,目录空了,囧. 谷歌一下,发现它必须使用post目录,而不是默认的posts目录,更不支持imported目录了.最简单的办法就是把imported目录放到post目录下,以后新建的文章就放到post目录下就好啦. | ||
|
||
但是随后就发现生成的rss文章包括了关于我这样的页面,这个问题还是比较严重的.不过默认hugo生成的rss是包含区域rss的,因此直接使用post/rss.xml就可以只生成post目录下的rss文件了. | ||
|
||
## 解决tags和archive空白问题 | ||
|
||
不知道为什么,当我点击tags和archive目录的时候,前者是404,后者是空白页.既然 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
content/post/imported/A-Method-To-Find-Midlle-in-Binary-Search-in-C.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
--- | ||
title: "二分查找法查找中点的方法(C语言)" | ||
date: "2011-12-07T00:00:00Z" | ||
|
||
draft: false | ||
tag: ["C","二分查找"] | ||
tags: ["C","二分查找"] | ||
url: A-Method-To-Find-Midlle-in-Binary-Search-in-C.html | ||
--- | ||
|
||
今天跟同事说起二分查找法中常见的一个问题,就是计算中点时会溢出的问题。 | ||
|
||
常见的方法(a+b)/2就是铁定会溢出的方法。如果a和b很大,之和超出了它们定义的范围,那么运算结果可能会是负数,这绝对不是我们想要的。 | ||
|
||
之后同事说他看到一个算法是(a+b)>1。其实这个问题只能说缓解了溢出的问题,实际问题还是存在的。为啥?比如int,当发生上溢的时候,溢出的进位其实进入了符号位;而右移的时候把符号位移到了第一位,此时计算结果是正确的;但是如果是无符号整型,溢出的时候已经丢弃了进位,右移后结果要少差一半。 | ||
|
||
所以最好还是用a+(b-a)/2这样。除二或者右移一位都是可以的。当然,前提是因为我们知道a和b作为数组下标,都是正数,因此b-a不会下溢。如果你的数组奇怪到居然用负数左下标,呃,好吧,a和b做右移或除2处理再相加吧。不过记得要判断两个都是奇数的情况哦! | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
content/post/imported/Changing_DNS_After_VPN_CAUSE_INTRANET_DOMAIN_Resorve_Fail.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
--- | ||
title: "拨公司 VPN 后,指定了外网 dns,却无法访问内网域名的解决办法" | ||
date: "2020-02-02T00:00:00Z" | ||
|
||
draft: false | ||
tag: ["VPN","域名","DNS","网络"] | ||
tags: ["VPN","域名","DNS","网络"] | ||
url: Changing_DNS_After_VPN_CAUSE_INTRANET_DOMAIN_Resorve_Fail.html | ||
--- | ||
|
||
今天我遇到一个情况,就是使用公司 VPN 后再指定家里的 DNS 后,公司的内网域名反而无法访问的问题。 | ||
|
||
这是因为我家路由器上的 DNSMASQ 配置了rebind_protection,这个选项是指当上级 DNS 返回了内网地址时,会将结果吞掉,并返回 NOERROR。这个选项是为了防止有些无良 ISP 的 DNS 劫持用的,有些路由可能就叫做“防止 DNS 劫持”的功能。 | ||
|
||
但是公司内网的地址解析肯定不是公网的,但是这个解析又配置在外网环境,导致内网域名也被外网 DNS 解析并返回,导致 DNSMASQ 当成了劫持,返回了 NOERROR。而 NOERROR 对于操作系统来说,就算是这个 DNS 解析到了,不会再询问第二第三 DNS 了,导致第二第三 DNS 就是配置公司的 DNS 也无济于事。 | ||
|
||
解决方法就是在路由器上关闭此功能,或者在 VPN 的 DNS 里调整一下顺序,将公司的 DNS 放在优先位置。公司的 DNS 会将外网域名解析为 NXDOMAIN,这样就会顺序使用第二第三 DNS 来访问外网了。 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
--- | ||
title: "Charles 出4啦" | ||
date: "2016-08-02T00:00:00Z" | ||
|
||
draft: false | ||
tag: ["Charles"] | ||
tags: ["Charles"] | ||
url: Charles-Update-to-4.html | ||
--- | ||
|
||
很多人用Windows抓Http包的时候都用fiddler,在Mac上用Charles则是最好的选择。 | ||
|
||
刚好Charles这两天出第四版了,试了下比原先的UI更线代了,功能也更强大了,而且好像价格也更优惠了。 | ||
|
||
于是赶紧买买买,正版计划又前进了一小步,哈哈~ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.