小编Per*_*ids的帖子

将受信任的CA添加到Debian / Ubuntu映像

我正尝试按照https://askubuntu.com/a/94861/88763http://blog.bigon.be/2014/03中的说明,在Debian / nodejs容器中将CA证书部署为受信任的根证书。/ 22 /将新的CA证书添加到证书存储在Debian /中,但是失败没有任何明显的原因。我的Dockerfile:

FROM debian:jessie # or buildpack-deps:jessie or node:5
RUN apt-get update -y && \
    apt-get install ca-certificates netcat strace wget -y
ADD rootCa.pem /usr/local/share/ca-certificates/rootCa.crt
RUN update-ca-certificates --verbose

CMD ["netcat", "-l", "12345"] # just to keep the container running
Run Code Online (Sandbox Code Playgroud)

构建容器时,它实际上告诉我添加了一个证书(1 added, 0 removed; done.)尽管如此,当我尝试将根CA与wget一起使用时,找不到该证书:

$ sudo docker exec -it cleanslatehg_catests_1 wget https://foo.v3.testing
converted 'https://foo.v3.testing' (ANSI_X3.4-1968) -> 'https://foo.v3.testing' (UTF-8)
--2016-02-02 15:11:33--  https://foo.v3.testing/
Resolving foo.v3.testing (foo.v3.testing)... 172.19.0.7
Connecting to foo.v3.testing …
Run Code Online (Sandbox Code Playgroud)

ssl debian docker

6
推荐指数
0
解决办法
1663
查看次数

无法使用Control.Exception.try捕获"Prelude.read:no parse"异常

我试图从文件中读取一些值并捕获可能发生的每个异常(在"更容易请求宽恕而非许可"的思维模式中).我在捕捉Prelude.read: no parse异常时遇到了麻烦.要告诉try它应该捕获我tryAny使用显式类型定义的每个异常SomeException,据我所知,这是每个异常的"超类型":

import Control.Exception (try,SomeException)
tryAny :: IO a -> IO (Either SomeException a)
tryAny = try
Run Code Online (Sandbox Code Playgroud)

随着tryAny我似乎能够赶上IO错误:

> tryAny (fromFile "nonExistingFileName")
Left nonExistingFileName: openFile: does not exist (No such file or directory)
Run Code Online (Sandbox Code Playgroud)

但是不会捕获读取错误:

> tryAny (return ((read "a")::Int))
Right *** Exception: Prelude.read: no parse
Run Code Online (Sandbox Code Playgroud)

我能做些什么来捕捉每一个例外?

haskell

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

将Accept标头添加到JQuery AJAX GET(通过JSONP)请求

我正在尝试将一个接受标头添加到使用"jsonp"的jQuery AJAX GET请求中dataType,但由于某种原因它无效.到目前为止,这是我的代码.

var e4json =  JSON.stringify( { 
                  "thomas_smith106"           : "Daniel244", 
                  "transaction_type"          : "34",
                  "transaction_tag"           : "902006933",
                  "authorization_num"         : "ET4653",
                  "amount"                    : "15.75"
              } ); 

$.ajax ({
    url: "https://api.demo.globalgatewaye4.firstdata.com",
    type: "GET",
    headers : {
        'accepts' : 'application/json'
    },
    data: e4json,
    dataType: "jsonp",
    success: function  (response) {
        alert('Successfuly called the e4 gateway api');
    }
});
Run Code Online (Sandbox Code Playgroud)

我尝试了很多东西,但似乎没有任何工作.我查看了jQuery网站上的文档,但我找不到任何好的例子.

这是我的请求标题.我需要接受标头为'application/json'.

Accept:*/*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Cookie:_fd_session=d69310c5cd4a02a4700b5ba63f0d0c9b
Host:api.demo.globalgatewaye4.firstdata.com
Referer:http://localhost:8080/smart-two-site/customerinfo.html
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36 …
Run Code Online (Sandbox Code Playgroud)

ajax jquery jsonp get http-accept-header

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

用于循环模板参数/类型

我想为几个可能类的几种组合编写基准代码.如果我自己编写每个组合,它就变成了一个难以维护的混乱.因此,我正在寻找一种通过模板自动组合每种类型的方法,类似于以下伪代码:

for (typename HashFuction : Sha256, Sha512, Sa512_256, Sha3_256, Sha3_512) {
   for (typename KeyingWrapper : TwoPassKeyedHash, OnePassKeyedHash, PlainHash) {
      for (typename InstantiatedGetLeaf: GetLeaf<8>, GetLeaf<1024>) {
         for (typename algorithm : algA, algB, algC) {
            runAndTime<HashFunction,KeyingWrapper,
                       InstantiatedGetLeaf,algorithm>(someArgs);
         }
       }
    }
 }
Run Code Online (Sandbox Code Playgroud)

哪里Sha256,......,TwoPassKeyedHash......是类型.

我正在寻找的代码应该在功能上等同于以下内容:

runAndTime<Sha256,TwoPassKeyedHash,GetLeaf<8>,algA>(someArgs);
runAndTime<Sha256,TwoPassKeyedHash,GetLeaf<8>,algB>(someArgs);
runAndTime<Sha256,TwoPassKeyedHash,GetLeaf<8>,algC>(someArgs);

runAndTime<Sha256,TwoPassKeyedHash,GetLeaf<1024>,algA>(someArgs);
runAndTime<Sha256,TwoPassKeyedHash,GetLeaf<1024>,algB>(someArgs);
runAndTime<Sha256,TwoPassKeyedHash,GetLeaf<1024>,algC>(someArgs);

runAndTime<Sha256,OnePassKeyedHash,GetLeaf<8>,algA>(someArgs);
runAndTime<Sha256,OnePassKeyedHash,GetLeaf<8>,algB>(someArgs);
runAndTime<Sha256,OnePassKeyedHash,GetLeaf<8>,algC>(someArgs);

// And 99 further lines…
Run Code Online (Sandbox Code Playgroud)

在Peregring-lk的帮助下,我已经走到了尽头

#include <iostream>

template<typename Aux_type>
void test_helper()
{}

template<typename Aux_type, typename Head, typename... Tail>
void test_helper() {
   std::cout << Head::i;
   test_helper<Aux_type, …
Run Code Online (Sandbox Code Playgroud)

c++ templates metaprogramming

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

使用 `gpg --recv-key` 下载密钥并同时在脚本中检查指纹

如何通过导入密钥gpg --recv-key并自动检查其指纹?理想情况下,我会gpg --recv-key $fingerprint直接使用,但gpg 最近才添加了一个检查,即接收到的密钥实际上具有正确的指纹,而不是盲目地信任密钥服务器,并且修复程序并未出现在我关心的所有发行版中(例如Docker Ubuntu Image 仍然有一个旧的 gpg 版本)。

我想将它与apt-key向 docker 容器添加 PPA结合使用。

apt gnupg pgp docker

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

为什么n + 1选择模式慢?

我对数据库缺乏经验,只读过"n + 1选择问题".我的后续问题:假设数据库与我的程序驻留在同一台机器上,缓存在RAM中并正确编制索引,为什么n + 1查询模式会变慢?

举个例子,让我们从接受的答案中获取代码:

SELECT * FROM Cars;

/* for each car */
SELECT * FROM Wheel WHERE CarId = ?
Run Code Online (Sandbox Code Playgroud)

使用我的数据库缓存的心理模型,每个SELECT * FROM Wheel WHERE CarId = ?查询都需要:

  • 1次查找到达"Wheel"表(一个hashmap get())
  • 1查找到达指定CarId(另一个hashmap get())的k轮列表
  • k查找以获取每个匹配轮的轮行(k指针解除引用)

即使我们将它乘以一个小的常数因子,因为内部存储器结构会产生额外的开销,但它仍然应该是不明显的快速.进程间通信是瓶颈吗?


编辑:我刚刚通过黑客新闻发现了这篇相关文章:通过Postgres内部发表选择声明.- HN讨论主题.

编辑2:为了澄清,我认为N是大的.一个非平凡的开销会加起来明显延迟,是的.我问的是,对于上述设置,为什么开销在一开始就是非平凡的.

sql orm select-n-plus-1

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

如何获取自动付款的原始费用和退款 ID

Stripe 连接帐户可配置为按照定期付款计划合并付款,例如在我们的案例中为每月付款。对于这些每月付款,我们需要向账户所有者解释我们平台上的哪些交易(在我们的例子中是预订和退款)产生了他们收到的总金额。我们将条带费用 ID(或退款 ID)存储在数据库的预订(或退款)对象中。因此,问题归结为:

给定一个 Stripe 帐户 ID,如何获取促成上次付款的 Stripe 费用和退款 ID 列表?

ruby stripe-payments stripe-connect

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

如何迭代所有字节值(`0..256`中的overflowing_literals)

我正在尝试迭代所有可能的byte(u8)值.不幸的是在我的范围内的文字0..256被强制转换为u8256溢出:

fn foo(byte: u8) {
    println!("{}", byte);
}

fn main() {
    for byte in 0..256 {
        foo(byte);
        println!("Never executed.");
    }
    for byte in 0..1 {
        foo(byte);
        println!("Executed once.");
    }
}
Run Code Online (Sandbox Code Playgroud)

以上编译:

warning: literal out of range for u8
 --> src/main.rs:6:20
  |
6 |     for byte in 0..256 {
  |                    ^^^
  |
  = note: #[warn(overflowing_literals)] on by default
Run Code Online (Sandbox Code Playgroud)

第一个循环体永远不会被执行.

由于演员阵容,我的解决方法非常难看并且感觉很脆弱:

for short in 0..256 {
    let _explicit_type: u16 = short;
    foo(short as u8); …
Run Code Online (Sandbox Code Playgroud)

rust

4
推荐指数
2
解决办法
729
查看次数

如何获取 RSAPrivateKey 的实例

我如何创建java.security.interfaces.RSAPrivateKey给定 RSA 的实例de并且n(假设为 BigIntegers)。(这里d表示私有指数、e公共指数和n=pqRSA 模数。)

我认为这真的很简单,但我在文档或互联网中找不到任何内容。

如果有任何帮助,我已经安装了 BouncyCastle。

编辑澄清:我在寻找一个实现该接口,并采取一类de和/或n作为参数传递给构造函数(或参数为出厂功能等),而不是创造一个新的,随机密钥或阅读的关键来自某种 PKCS* 格式的文件。

java cryptography

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

Windows演示基础项目wpf不支持int16

为什么我收到以下错误:"Windows演示基础项目wpf不支持Int16."

我正在阅读以下MSDN文本: MSDN TEXT重新分级基元映射

下面是我的简单代码:

<Window x:Class="Test.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">

    <Window.Resources>
        <x:Int16 x:Key="cnst">12</x:Int16>        
    </Window.Resources>

    <Grid>

    </Grid>

</Window>
Run Code Online (Sandbox Code Playgroud)

为什么这段代码不起作用?需要做些什么才能让它发挥作用.我的猜测:2006需要替换2009为未来版本.

c# wpf xaml

-2
推荐指数
1
解决办法
642
查看次数