一招搞定Typora本地图片导成html查看不了
Typora是一款用户体验极强的Markdown编辑器,编辑内容体验非常流畅,且具备导出成各种格式的强大功能。比如pdf、word、html等,都不在话下。不过,在导出带有本地图片的md文件成html的时候,却遇到了在别人那边查看不了图片的问题。
Typora是一款用户体验极强的Markdown编辑器,编辑内容体验非常流畅,且具备导出成各种格式的强大功能。比如pdf、word、html等,都不在话下。不过,在导出带有本地图片的md文件成html的时候,却遇到了在别人那边查看不了图片的问题。
mac升级到10.15.4后,系统自带装了php7.3,但是有个问题,竟然不能装swoole插件,于是想删掉系统的php。
$ which php
/usr/bin/php
$ cd /usr/bin/
$ sudo rm -rf php php-config phpdoc phpize
rm: php: Read-only file system
rm: php-config: Read-only file system
rm: phpize: Read-only file system出现了Read-only file system的提示,用sudo都删不掉。
老婆在mac最新的MacOS Mojave系统里边安装了photoshop cc 2016以后,发现在使用触控板的时候,没有触感了,尝试了各种重装,重装ps,重装wacom驱动,都没有凑效。
在百度搜了一下,发现有一篇通过修改系统隐私的方案比较靠谱,于是照着操作了一番,果然ok了。不过,老婆在我操作成功之后说,实际上她也找到了那篇文章,但是在设置隐私的时候,发现都是置灰的状态,不能操作,就没有继续下去了。因此,这篇文章将通过图文并茂的形式,帮助大家快速解决这个问题。
一直以为,抓取网站整站,要么需要一个非常牛的工具,要么自己用curl之类写一个。这次想把caddy的英文文档的站点做个镜像的时候,竟然发现可以直接利用wget来实现,还真是小瞧了这个常见的工具了。
wget的参数的详解,网上已经很多了,就不再copy了,有兴趣详细了解的朋友可以参考下面的链接:
首先,我想做caddy的doc的镜像的原因是因为经常访问不了,也就是说,不想通过代理才能访问,所以,我需要使用代理的相关命令。因为caddy是https协议,所以我export一个变量https_proxy来作为代理。
网站讲究高可用,讲究不间断服务。而对于刚接触caddy的我们而言,修改配置文件是加家常便饭,比如:增加日志监控,增加一个301重定向什么的。那么修改了配置文件,配置文件是否配置正确呢?配置后又该怎么重启呢?如何确保重启过程的不间断服务呢?如果出现服务挂掉该怎么确保服务的自动启动呢?这一系列的疑问,我们今天来一一释怀吧。但是,需要相信的是,caddy作为一个新生代的web服务器软件,这些方面肯定会考虑到的。本文将参考官方的命令行模式文档,为这些问题一一解答。
ps.关于Caddy的命令行参数,也可以参考我翻译的中文文档:Caddy命令行参数
caddy指定配置文件的参数是-conf,那么怎么验证配置文件是否正确呢?就像nginx的-t参数一样,caddy有-validate参数可供使用。看一下官方文档:
-validate
Parse the Caddyfile and exit. If syntactically valid, a message will be printed to stdout and the process log (if any) and will exit with status 0. If not, an error will be returned with a non-zero exit status.
解析Caddyfile并退出,如果句法结构正确,将会通过标准输出打印一条信息,记录日志(如果配置了),最后会退出,退出码为0。否则,会报出相应的错误信息,状态码为非0。
网站改版后,很难确保新的网址和旧的网址保持一致,因此总需要写一些重定向规则,确保原来被搜索引擎抓取的页面能重定向到新的URL。对于一个基于typeocho的php类型的网站,重写也总是必要的。在使用nginx服务器的时候,重写和重定向是在一起的,并没有什么歧义产生,但是,到caddy里边,这两个概念是区分开的。更为不好的地方在于,两者并存的时候,会出现意想不到的结果。
比如,最早本站发现有一些老页面的流量过来,但是会进到404页面。
5 203.208.60.50 - - [26/Aug/2018:20:53:44 +0800] "GET /article/223672015323021312 HTTP/1.1" 404 2057 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"按照官方说明,在Caddyfile中使用__redir__命令予以重定向。
redir 301 { /article/223672015323021312 /article/2017/06/php-git-http-server.html
/article/2017/06/5.html /article/2017/06/php-git-http-server.html
}
rewrite {
to {path} {path}/ /
}</code></pre><p>重启caddy,但是发现并没有生效,还是和之前效果一样。</p><!--more--><p>检查配置文件,发现应该是因为里边存在__<a href="https://dengxiaolong.com/caddy/cn-doc/http.rewrite.html" title="rewrite">rewrite</a>__指令,而caddy并没有处理两者之间的优先级导致的。<a href="https://www.bing.com/" title="bing">bing</a>搜索一下,发现果然有这方面的讨论。</p><p><a href="https://github.com/mholt/caddy/issues/1107">https://github.com/mholt/caddy/issues/1107</a></p><p>其中,hlidotbe提到:</p><blockquote>Looking a bit further, I see why it happens. in caddyhttp/httpserver/plugin.go "redir" is after "header", way after "rewrite".</blockquote><p>主要说的是<code>redir</code>是在在<code>rewrite</code>后面执行的,也就是说,先执行了rewrite逻辑,然后再执行redir逻辑。</p><p>查看<a href="https://github.com/mholt/caddy/blob/master/caddyhttp/httpserver/plugin.go">源代码</a>,果然如此:</p><pre><code class="lang-go">// directives is the list of all directives known to exist for the
// http server type, including non-standard (3rd-party) directives.
// The ordering of this list is important.
var directives = []string{
// primitive actions that set up the fundamental vitals of each config
"root",
"index",
"bind",
"limits",
"timeouts",
"tls",
// services/utilities, or other directives that don't necessarily inject handlers
"startup", // TODO: Deprecate this directive
"shutdown", // TODO: Deprecate this directive
"on",
"supervisor", // github.com/lucaslorentz/caddy-supervisor
"request_id",
"realip", // github.com/captncraig/caddy-realip
"git", // github.com/abiosoft/caddy-git
// directives that add listener middleware to the stack
"proxyprotocol", // github.com/mastercactapus/caddy-proxyprotocol
// directives that add middleware to the stack
"locale", // github.com/simia-tech/caddy-locale
"log",
"cache", // github.com/nicolasazrak/caddy-cache
"rewrite",
"ext",
"minify", // github.com/hacdias/caddy-minify
"gzip",
"header",
"geoip", // github.com/kodnaplakal/caddy-geoip
"errors",
"authz", // github.com/casbin/caddy-authz
"filter", // github.com/echocat/caddy-filter
"ipfilter", // github.com/pyed/ipfilter
"ratelimit", // github.com/xuqingfeng/caddy-rate-limit
"expires", // github.com/epicagency/caddy-expires
"forwardproxy", // github.com/caddyserver/forwardproxy
"basicauth",
"redir",
"status",</code></pre><p><a href="https://github.com/hlidotbe">hlidotbe</a> 还提到</p><blockquote><p>I think there's really only two (and a half) options:</p><p>1 merge redir and rewrite as most/all web servers do which makes the problem disappear and remove all ambiguity about it;<br>2 order rewrite after redir which may break some use cases but should limit surprises for most;<br>2.5 allow rewrite to redirect too but that would render redir redundant and often unused when rewrites are involved;</p></blockquote><p>简单翻译一下:<br>我认为最后解决方式只有2.5个选项:<br>1 像大多数web服务器软件一样(如nginx),合并<code>redir</code>和<code>rewrite</code>两个指令,让分歧彻底消失;<br>2 使<code>rewrite</code>指令在<code>redir</code>指定后面执行,这虽然会影响部分使用场景(有时候可能想重写后还能重定向),但会解决绝大部分疑惑;<br>2.5 允许<code>rewrite</code>指令支持重定向,不过这样就会让<code>redir</code>显得多余了。</p><p>既然,问题出现了,而且也没有解决方案,我们只能自己绕路而行了。<br>思路就是:</p><ul><li>rewrite命令想办法让需要redir的路径不重写;</li><li>其他一切不变</li></ul><p>最后,来看一下改进的Caddyfile文件:</p><pre><code class="lang-caddy"> # 先让rewrite过滤掉需要redir的路径
rewrite {
if {path} not /article/223672015323021312
if {path} not /article/2017/06/5.html
to {path} {path}/ /
}
# 先执行rewrite,再执行redir
redir 301 {
/article/223672015323021312 /article/2017/06/php-git-http-server.html
/article/2017/06/5.html /article/2017/06/php-git-http-server.html
}</code></pre><p>经过这样调整,caddy终于能正常相应redir的请求了。虽然这样来看,比nginx的<code>rewrite</code>配置要复杂不少,但其他地方的配置,尤其是https的配置,实在是要高明得多。对于普通的blog来说,caddy还是显得要便捷得多。</p>
用惯了linux,在windows里边操作,总感觉到处受阻,因此,需要有一款类似于linux的东东,让你在windows里边也能手指如飞,快速实现你的想法。cygwin就是这样的一款软件,稍微加以打磨,你就可以在windows里边手指如飞,能量满满。
安装完virtualbox的虚拟机,一开始全部按默认设置的,往往还没有开始爽起来,就发现磁盘不够用了。怎么办?重装又得重新来过,而且太没有技术含量了。按照本文的流程,将帮助你化解这一个尴尬的境地,让virtualbox虚拟机的硬盘扩容一点都不麻烦。
经常用git,在实际操作中有一些较难但非常使用的命令,将在本文予以累积。分为比较、整理、易用性等章节。
比较两次版本的不同,如果需要忽略空格和tab,可以加上-w参数
git diff -w -- ./foo/bar.php kvm生成一台新机器后,并不能自动分配新的ip。本文介绍了基于php语言,结合libvirt一系列的工具,实现通过命令行对虚拟机进行克隆和自动ip分配的方案。
克隆来源的domain里边的文件已经被删除:/etc/udev/rules.d/70-persistent-net.rules。