在nodejs cli中运行以下代码:
var my_function = function() {
var next_value = 1
, value = undefined
, difference = undefined
, prev_difference = undefined
while ((typeof prev_difference === 'undefined') || (prev_difference > 0)) {
value = next_value
next_value = 2
difference = next_value - value
if (difference > prev_difference) {
throw new Error('Diminishing')
}
prev_difference = 0
}
return next_value
}
for (var i = 0; i< 300; i++) { console.log(i); console.log(my_function()) }
Run Code Online (Sandbox Code Playgroud)
在循环的迭代282,我开始得到值'1'而不是'2'.不能为我的生活理解为什么.这段代码是我一直在努力的其他东西的减少,因此在循环中看似不必要的if语句.有几种方法可以改变这些代码,使得执行路径不会搞砸,但我想了解为什么它会破坏当前的设置.
另外,如果你有任何工具提示可以帮助我将来调试这样的东西,我将非常感激.在大多数情况下,我使用console.log来缩小范围.
node.js版本v0.8.6.在Mac OSX版本10.7.5上运行.谢谢
在ag
命令行上使用时,如下所示:
$> ag . --ignore="*node_modules/*/node_modules" -l --nocolor -f -U -g ""
我能够避免在我的节点服务中搜索多个深度级别的任何node_modules目录,这是所需的行为.
但是,当我在我的vimrc中使用以下内容时,不会忽略多个深度级别的node_modules目录:
" Use The Silver Searcher https://github.com/ggreer/the_silver_searcher
if executable('ag')
" Use Ag over Grep
set grepprg=ag\ --nogroup\ --nocolor
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
let g:ctrlp_user_command = 'ag %s --ignore="*node_modules/*/node_modules" -l --nocolor -f -U -g ""'
endif
Run Code Online (Sandbox Code Playgroud)
如何设置ag
并ctrlp
正确忽略这些目录?在移植到vimrc时,不确定是否需要使用不同的语法(如regex)或其他一些问题.
我没有把它放在野外的原因是我的.gitignore中忽略了node_modules,所以我使用该-U
选项忽略任何vcs文件(从而允许ag
搜索node_modules) - 但是这个选项似乎也绕过了wildignore.
嘿嘿,
我在 GKE v1.16.x 中使用 kubernetes 部署了 prometheus、grafana、kube-state-metrics、alertmanager 等设置。我使用https://github.com/do-community/doks-monitoring作为 yaml 文件的起点。
我已经尝试调试一种情况几天了,非常感谢您的帮助。我的普罗米修斯节点没有从 cadvisor 获取指标。
kubectl get --raw "/api/v1/nodes/<your_node>/proxy/metrics/cadvisor"
,但是当我在 prometheus 中查找container_cpu_usage
或时container_memory_usage
,没有数据。 - job_name: kubernetes-cadvisor
honor_timestamps: true
scrape_interval: 15s
scrape_timeout: 10s
metrics_path: /metrics/cadvisor
scheme: https
bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
tls_config:
ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
insecure_skip_verify: true
kubernetes_sd_configs:
- role: node
relabel_configs:
- action: labelmap
regex: __meta_kubernetes_node_label_(.+)
Run Code Online (Sandbox Code Playgroud)
摘自 …
我需要将以下 SAN 添加到证书中:
oid:1.2.3.4.5.5
Run Code Online (Sandbox Code Playgroud)
我正常的证书创建过程是生成一个openssl.cnf文件,然后用这个文件生成一个csr(证书签名请求),然后用我自己的CA从csr生成一个证书。
.cnf 文件是一个纯文本文件,其中包含一个部分,描述了我希望包含在 csr 和最终 crt 中的所有 SAN。该部分如下所示:
...
[san]
DNS.1 = foo.bar
DNS.2 = baz.foobar
IP.1 = 1.1.1.1
IP.2 = 2.2.2.2
...
Run Code Online (Sandbox Code Playgroud)
我尝试以 3 种不同的方式插入 OID 条目:
attempt 1) OID.1 = 1.2.3.4.5.5
attempt 2) DNS.3 = 1.2.3.4.5.5
attempt 3) IP.3 = 1.2.3.4.5.5
Run Code Online (Sandbox Code Playgroud)
1) 尝试生成证书时出现错误,表明OID
无法识别前缀。使用 2) 和 3) 我能够生成 crt,但是当我将它放置到位时,不支持 SAN oid:1.2.3.4.5.5。
所以,我想知道将此类和条目添加到 openssl.cnf 文件的主题备用名称部分的正确语法是什么。
干杯!
cadvisor ×1
certificate ×1
ctrlp ×1
javascript ×1
kubernetes ×1
node.js ×1
openssl ×1
prometheus ×1
ssl ×1
vim ×1