我的基于Jekyll的网站突然停止包括Google Analytics脚本块.昨天,它正在工作(脚本块在所有页面上),但今天,在我上传新帖子后,脚本块统一消失在所有页面上.
我在GitHub页面上托管我的网站,所以为了排除故障,我想在我的本地机器上重现这个问题.事实证明我在我的本地机器上运行旧版本的Ruby和Jekyll,所以我更新了Ruby并安装了GitHub Pages Gem以确保我的本地环境与GitHub页面匹配:
gem install github-pages
这使我能够重现这个问题.现在,即使我跑了
jekyll服务 - 安全
Analytics脚本块未包含在任何页面中.
经过多次故障排除后,我终于想通了如果我在我的JB /分析文件中放置任何类型的非空格字符,在谷歌案例和include指令之间,它都有效.
因此,这部作品,在这个意义上,当--safe
开关接通时,在脚本块JB/analytics-providers/google
中包括:
{% case site.JB.analytics.provider %}
{% when "google" %}.
{% include JB/analytics-providers/google %}
Run Code Online (Sandbox Code Playgroud)
(注意期间字符之后{% when "google" %}
).
但是,这不起作用 - 即使使用--safe
开关,include JB/analytics-providers/google
也不会包含以下内容:
{% case site.JB.analytics.provider %}
{% when "google" %}
{% include JB/analytics-providers/google %}
Run Code Online (Sandbox Code Playgroud)
虽然我有一个解决方法,但我非常感谢这种行为的解释.
我使用SSH在for
循环中的多个远程机器上运行一些命令.它为IP地址列表执行相同的命令.某些IP地址可能无法访问,因此我使用了该ConnectTimeout
选项.
但是,我的脚本没有按照我想要的方式工作.实际上它停留在第一个无法访问的IP而不是放弃并尝试列表中的下一个IP地址.
这是我的脚本的相关部分:
for ip in ${IP} ; do
ssh -o BatchMode=yes \
-o StrictHostKeyChecking=no \
-o ConnectTimeout=10 \
-l ${USERNAME} \
${SCRIPT_HOST} \
"${COMMAND} -i $ip || echo timeout" \
>> ./myscript.out
done
Run Code Online (Sandbox Code Playgroud)
它对于可访问的IP工作正常,但是如果特定的IP已关闭,它会等待一段时间(远超过10秒,可能是35-40秒)并向我的终端显示错误消息:
ERROR connecting : Connection timed out
所以我想知道我没有正确使用哪个选项.
我设置Ubuntu Linux来运行OpenSSH服务器.我的DSL路由器是端口转发SSH连接.我用的时候
ssh -X myhost
Run Code Online (Sandbox Code Playgroud)
然后打开一些GUI程序,然后关闭GUI应用程序并退出,然后SSH注销挂起.<Ctrl>-c
似乎工作,但每次都要按它是烦人的.如果我不打开GUI,注销将不会挂起.
任何人都有想法如何解决这个问题?
以下脚本使用该-e
选项运行,因此如果其中的任何命令失败,它将退出:
#!/bin/sh -e
command1 #script should fail if command1 fails
command2 #script should NOT fail if command2 fails
command3 #script should fail if command3 fails
Run Code Online (Sandbox Code Playgroud)
如何让脚本不失败command2
?
tee newOutputFile < existingInputFile > newOutputFile2
究竟如何tee
参与争论?会这样吗?
newOutputFile < existingInputFile
因此,existingInputFile的内容将被写入newOutputFilenewOutputFile > newOutputFile2
因此newOutputFile的内容将写入newOutputFile 2我正在尝试编写一个处理此特定命令的shell.但是,我对于在参数中传递的顺序感到困惑tee
.我编写程序的方式就可以了
tee newOutputFile2 < existingInputFIle
我正在研究underscore.js,我陷入了第一个功能.
// Create a safe reference to the Underscore object for use below.
var _ = function(obj) {
if (obj instanceof _) return obj;
if (!(this instanceof _)) return new _(obj);
this._wrapped = obj;
};
// Test Examples
var obj = {
name : 'Francis',
gender: 'male'
}
var test = _(obj);
console.log(test); // _ {_wrapped: Object}
// Why statement this._wrapped = obj; still got executed?
var Man = function() {
this.age = 30;
this.people = "John";
return this;
this.man …
Run Code Online (Sandbox Code Playgroud)