doc.open()
用于获取对文档的引用)onload
iframe文档的处理程序附加(通过写入<body onload="...">
iframe.现在让我难过的是onload处理程序中的全局(窗口)和文档对象(在它运行时)与通过脚本节点添加的JavaScript运行的相同对象不同.
<!doctype html>
<html>
<head>
<script>
(function(){
var dom,doc,where,iframe;
iframe = document.createElement('iframe');
iframe.src="javascript:false";
where = document.getElementsByTagName('script')[0];
where.parentNode.insertBefore(iframe, where);
doc = iframe.contentWindow.document;
var _doc = document;
doc.open()._l=function() {
// the window object should be the one that doc is inside
window.vanishing_global=new Date().getTime();
var js = this.createElement("script");
js.src = 'test-vanishing-global.js?' + window.vanishing_global;
window.name="foobar";
this.foobar="foobar:" + Math.random();
document.foobar="barfoo:" + Math.random();
// `this` should be the document object, but it's not
console.log("this …
Run Code Online (Sandbox Code Playgroud) 我正在尝试Julia DataFrames模块.我对它很感兴趣所以我可以用它在Gadfly中绘制简单的模拟.我希望能够迭代地向数据帧添加行,我想将其初始化为空.
有关如何执行此操作的教程/文档很少(大多数文档描述了如何分析导入的数据).
附加到非空数据帧很简单:
df = DataFrame(A = [1, 2], B = [4, 5])
push!(df, [3 6])
Run Code Online (Sandbox Code Playgroud)
这回来了.
3x2 DataFrame
| Row | A | B |
|-----|---|---|
| 1 | 1 | 4 |
| 2 | 2 | 5 |
| 3 | 3 | 6 |
Run Code Online (Sandbox Code Playgroud)
但是对于一个空的init我会得到错误.
df = DataFrame(A = [], B = [])
push!(df, [3, 6])
Run Code Online (Sandbox Code Playgroud)
错误信息:
ArgumentError("Error adding 3 to column :A. Possible type mis-match.")
while loading In[220], in expression starting on line 2 …
Run Code Online (Sandbox Code Playgroud) 我正在编写Makefile,makefile运行的一些命令需要密码.我想让用户能够使用make PASSWORD=password
或者如果用户没有传入它来传递它,然后提示用户并将其响应存储在所述Makefile变量中.
目前,我能够检查Makefile变量,然后作为目标特定规则的一部分,编写shell命令,提示用户输入密码并将其存储在shell变量中.但是,此变量仅适用于该特定shell,而不适用于任何其他shell.
如何从用户那里读取内容并将其存储在变量中?
我尝试过以下方法:
PASSWORD ?= $(shell read -s -p "Password: " pwd; echo $pwd)
Run Code Online (Sandbox Code Playgroud)
但是从不打印提示.我也试过echo "Password: "
内壳,但也没打印.
有任何想法吗?
编辑:
为了澄清,需要为特定目标设置密码,所以我有这样的事情:
PASSWORD :=
my-target: PASSWORD ?= $(shell read -s -p "Password: " pwd; echo $$pwd)
my-target:
# rules for mytarget that use $(PASSWORD)
Run Code Online (Sandbox Code Playgroud)
编辑2:
我发现了这个问题.当我设置PASSWORD :=
在脚本的顶部时,它设置PASSWORD
为一个空字符串,这反过来导致?=
跳过(因为PASSWORD
)已经设置.
考虑以下代码:
<script>
function testFunc(){
alert('test')
}
$(function(){
var g = document.getElementById , w = window.testFunc ;
//g
alert(typeof(g));
alert(String(g));
alert(g instanceof Object);
alert(g instanceof Function);
//w
alert(typeof(w));
alert(String(w));
alert(w instanceof Object);
alert(w instanceof Function);
//run it
alert(g('t'));
w();
});
</script>
Run Code Online (Sandbox Code Playgroud)
typeof =>"function"
String =>"function #funcName#{[native code]}"
instanceof Object => true
instanceof Function => true
它有点奇怪,我们可以w
通过使用轻松调用()
,但是g
,我们必须调用它是这样的:
g.call(document,elementId);
Run Code Online (Sandbox Code Playgroud)
说到IE 6,结果完全不同:
// g
typeof =>"object"
String =>"function getElementById {[native code]}"
instanceof Object => false
instanceof …
我正在使用curl_easy
libcurl 接口编写代码,但很难让它重用连接。详细信息如下。
curl --version
curl 7.58.0 (x86_64-pc-linux-gnu) libcurl/7.58.0 OpenSSL/1.1.1 zlib/1.2.11
libidn2/2.0.4 libpsl/0.19.1 (+libidn2/2.0.4) nghttp2/1.30.0 librtmp/2.3
Release-Date: 2018-01-24
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3
pop3s rtmp rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB
SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL
Run Code Online (Sandbox Code Playgroud)
我的代码运行了一系列单元测试,所有这些单元测试都必须通过 H2 连接到同一主机,因此我设置了持久连接。我调用一次curl_easy_init,然后调用所有全局curl_easy_setopt
值,然后在一个循环中,我通过调用curl_easy_setopt
设置post字段、url、内容长度,然后调用curl_easy_perform
. 我只curl_easy_cleanup
在所有请求提出后才打电话。我设置了以下选项:
CURLOPT_FOLLOWLOCATION => 1
CURLOPT_SSL_VERIFYPEER => 1
CURLOPT_SSL_VERIFYHOST => 2
CURLOPT_SSLVERSION …
Run Code Online (Sandbox Code Playgroud) 我有时在尝试 ssh 到主机时会看到此问题。最常见的是通过 git 时(因为我使用 git 进行 ssh 的频率比直接进行 ssh 的频率更高)。
ssh 的输出如下所示:
Received disconnect from <server ip> port 22:2: Too many authentication failures
Disconnected from <server ip> port 22
Run Code Online (Sandbox Code Playgroud)
我还使用了 SSH 代理,在这种情况下,输出如下所示:
Received disconnect from UNKNOWN port 65535:2: Too many authentication failures
Disconnected from UNKNOWN port 65535
Killed by signal 1.
Run Code Online (Sandbox Code Playgroud)
从错误消息的表面来看,我的帐户似乎已被锁定 - 也就是说,如果您多次错误地输入密码,通常会发生什么情况。但我只使用 ssh 密钥进行身份验证,并且这在几天前就有效了。
查看详细输出(使用 ssh -v),我没有看到更多有帮助的信息,但它确实告诉我,它已尝试使用IdentityFile
我的文件中为此主机模式配置的所有 s.ssh/config
以及中可用的所有身份我的 ssh 代理。
由于我们每季度进行密钥轮换,我最近向代理添加了新密钥。