小编gra*_*hay的帖子

如何使用jade/pug在标题中添加样式标记?

我想要这样的东西:

html
  head
    style(type="text/css")
      table {
        width: 100%
      }
  body
    table
Run Code Online (Sandbox Code Playgroud)

但找不到合适的咒语.这会导致"意外文本"错误.我尝试用|来逃避css,但无济于事; 到目前为止我所取得的最好成绩是在标题中呈现一个表格标签:(

用玉/哈巴狗可以做到这一点吗?

pug

16
推荐指数
1
解决办法
1万
查看次数

当使用-File参数调用时,如何让PowerShell返回正确的退出代码?

如果使用-File参数调用,Powershell将在发生错误时返回0退出代码.这意味着我的构建是绿色的,它不应该是:(

例如:

(在wtf.ps1中)

$ErrorActionPreference = "Stop";   
$null.split()
Run Code Online (Sandbox Code Playgroud)

(CMD)

powershell -file c:\wtf.ps1  
You cannot call a method on a null-valued expression.
At C:\wtf.ps1:3 char:12
+ $null.split <<<< ()
    + CategoryInfo          : InvalidOperation: (split:String) [], ParentConta
   insErrorRecordException
    + FullyQualifiedErrorId : InvokeMethodOnNull


echo %errorlevel%  
0

powershell c:\wtf.ps1  
You cannot call a method on a null-valued expression.
At C:\wtf.ps1:3 char:12
+ $null.split <<<< ()
    + CategoryInfo          : InvalidOperation: (split:String) [], ParentConta
   insErrorRecordException
    + FullyQualifiedErrorId : InvokeMethodOnNull


echo %errorlevel%  
1
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

(我已经尝试了前两页的每个想法:https://www.google.co.uk/search?q …

powershell exit-code

15
推荐指数
2
解决办法
2万
查看次数

git push对于分支来说非常慢

我们有一个相当大的git仓库(ios app资源).我很欣赏git在使用它时会很慢,但如果我创建一个新分支并编辑几个文件(不是二进制文件)并推送,则需要永远.

感觉整个回购都被推了.我的印象是git只会发送差异,是不是错了?(我知道git存储整个文件的压缩版本,我的意思是我的分支和我从哪里分支的差异).

如果我运行,git diff --stat --cached origin/foo那么我会看到一个简短的文件列表,看起来像我期望的那样,例如34 files changed, 1117 insertions(+), 72 deletions(-).但当我推动它进入Writing objects: 21% (2317/10804)并停止时,好像它正在推动所有2.4GB的二进制数据.

我错过了什么(我用Google搜索了很多)?这是预期的行为吗?我在OS X(Mavericks)和ssh(git@github.com)上使用git 2.2.2.

我在这里发现了一个类似的问题:Git - 推动一个大项目的远程分支是非常缓慢但没有真正的答案.

git

15
推荐指数
1
解决办法
2万
查看次数

是否真的没有办法从失败的js获取请求中获取响应主体?

如果请求失败,新的js fetch API将失败(400):

fetch(uri).catch(function(err) {
   console.log(err);
});
Run Code Online (Sandbox Code Playgroud)

发生这种情况时,真的没有办法获得响应机构吗?例如,检查错误代码.

编辑:我创建了一个js小提琴:https://jsfiddle.net/4x4xLwqo/,它调用这个mockbin端点:http://mockbin.org/bin/d87acbb0-526e-4d66-aea4-b827d9c35031/view

编辑2:更新jsfiddle以使用更好的端点:https://jsfiddle.net/4x4xLwqo/2/

javascript fetch-api

10
推荐指数
1
解决办法
4282
查看次数

nodejs ssl"无法获取本地颁发者证书"

我已获得SSL证书用于签署客户端请求以及相关的CA证书.我可以使用openssl验证它:

$ openssl s_client -CAfile /etc/ssl/foo/ca-combined.pem -servername foo.co.in -connect foo.co.in:443
CONNECTED(00000003)
... snip ...
Verify return code: 0 (ok)
---
closed
Run Code Online (Sandbox Code Playgroud)

(我将2个CA证书混合到一个文件中).但是当我尝试使用节点复制它时:

    var tls = require('tls');
    var fs = require('fs');

    var options = { 
        host: 'foo.co.in',
        servername: 'foo.co.in',
        port: 443,
        key: fs.readFileSync('/etc/ssl/private/foo.key'),
        cert: fs.readFileSync('/etc/ssl/foo/cert.pem'),
        ca: [fs.readFileSync('/etc/ssl/foo/combined-ca.pem')]
    };  

    tls.connect(options, function(err) {
        done(err);
    });
Run Code Online (Sandbox Code Playgroud)

我收到一个错误:

Uncaught Error: unable to get local issuer certificate
  at Error (native)
  at TLSSocket.<anonymous> (_tls_wrap.js:1092:38)
  at TLSSocket._finishInit (_tls_wrap.js:610:8)
  at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:440:38)
Run Code Online (Sandbox Code Playgroud)

我在这里找到了答案,建议我需要将每个CA证书放在一个单独的文件中:

ca: [fs.readFileSync('/etc/ssl/foo/ca.pem'), fs.readFileSync('/etc/ssl/foo/root-ca.pem')]
Run Code Online (Sandbox Code Playgroud)

但那仍然给出了同样的错误.(我也尝试颠倒顺序).然后我尝试将中间证书放在客户端1中,并且只提供根CA证书ca(这似乎是文档建议的),同样的错误.在这一点上,我已经没有想法了.openssl很高兴的事实表明我做错了什么,有什么建议吗? …

ssl https node.js

7
推荐指数
1
解决办法
1万
查看次数

是否可以捕获无法处理的异常(在C#中)?

我有一个捕获T的异常的泛型类:

    public abstract class ErrorHandlingOperationInterceptor<T> : OperationInterceptor where T : ApiException
    {
        private readonly Func<OperationResult> _resultFactory;

        protected ErrorHandlingOperationInterceptor(Func<OperationResult> resultFactory)
        {
            _resultFactory = resultFactory;
        }

        public override Func<IEnumerable<OutputMember>> RewriteOperation(Func<IEnumerable<OutputMember>> operationBuilder)
        {
            return () =>
            {
                try
                {
                    return operationBuilder();
                }
                catch (T ex)
                {
                    var operationResult = _resultFactory();
                    operationResult.ResponseResource = new ApiErrorResource { Exception = ex };
                    return operationResult.AsOutput();
                }
            };
        }
    }

使用特定异常的子类,例如

    public class BadRequestOperationInterceptor : ErrorHandlingOperationInterceptor<BadRequestException>
    {
        public BadRequestOperationInterceptor() : base(() => new OperationResult.BadRequest()) { }
    }

这一切似乎都很完美.但是,不知何故,在日志中(曾经,而不是每次)都是InvalidCastException: …

c# generics error-handling

6
推荐指数
1
解决办法
229
查看次数

npm install git+ssh 在 docker (node16) 中失败

谁能解释为什么从 切换node:14-alpinenode:16-alpine会导致 npm install 失败?

 > [ 8/10] RUN --mount=type=ssh npm i:
#14 14.27 npm ERR! code 128
#14 14.28 npm ERR! An unknown git error occurred
#14 14.28 npm ERR! command git --no-replace-objects ls-remote ssh://git@github.com/(somerepo).git
#14 14.28 npm ERR! Warning: Permanently added 'github.com' (RSA) to the list of known hosts.
#14 14.28 npm ERR! git@github.com: Permission denied (publickey).
#14 14.28 npm ERR! fatal: Could not read from remote repository.
#14 14.28 npm ERR! 
#14 14.28 …
Run Code Online (Sandbox Code Playgroud)

git node.js npm docker

6
推荐指数
1
解决办法
2855
查看次数

有没有办法让NHibernate发出死锁提示?

有没有办法让NHibernate发出死锁提示?例如,对于SQL服务器"SET DEADLOCK_PRIORITY LOW".目前我只是执行原始SQL查询.

sql-server nhibernate deadlock

5
推荐指数
1
解决办法
470
查看次数

从生成的命令输出管道输出时如何返回错误?

我正在使用快速从生成的命令(ffmpeg,而不是它重要)管道stdout,但是如果子进程失败,我仍然得到200.

如果退出代码非零,我有什么办法可以返回500吗?(我认为标题已经被发送了):

const express = require('express');
const { spawn } = require('child_process');

var app = express();

app.get('/video', function(req, res) {
    var cmd = "ffmpeg";
    var args = ["--wat"];
    var proc = spawn(cmd, args);
    res.contentType('video/mp4');
    proc.stdout.pipe(res);
    proc.stderr.pipe(process.stdout);
    proc.on("exit", code => {
        console.log("child proc exited:", code);
        //res.status(code > 0 ? 500 : 200).end();
    }); 
    res.on("close", () => {
        proc.kill("SIGKILL");
    }); 
});

app.listen(4000);
Run Code Online (Sandbox Code Playgroud)

node.js express

5
推荐指数
1
解决办法
133
查看次数

nodejs带表达式的箭头函数

根据文档,您可以从箭头函数返回表达式:

(param1, param2, …, paramN) => expression
     // equivalent to:  => { return expression; }
Run Code Online (Sandbox Code Playgroud)

但这似乎没有像我期望的那样工作(nodejs 4.2.3)

> [1,2,3].map(i => i);
[ 1, 2, 3 ]
> [1,2,3].map(i => {});
[ undefined, undefined, undefined ]
Run Code Online (Sandbox Code Playgroud)

第二个例子不应该返回3个空对象吗?或者我错过了什么?

javascript node.js ecmascript-6 arrow-functions

3
推荐指数
1
解决办法
550
查看次数