尝试使用PayPal-node-SDK向Paypal的API发出请求
exports.requestPayment = functions.https.onRequest((req, res) => {
return new Promise(function (fullfilled, rejected) {
paypal.payment.create(create_payment_json, {}, function (error, payment) {
if (error) {
rejected(error);
} else {
console.log("Create Payment Response");
console.log(payment);
res.status(200).send(JSON.stringify({
paymentID: payment.id
})).end();
fullfilled(payment);
}
});
});
});
Run Code Online (Sandbox Code Playgroud)
但我经常收到一个错误:
Error: getaddrinfo ENOTFOUND api.sandbox.paypal.com api.sandbox.paypal.com:443
at errnoException (dns.js:28:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)
Run Code Online (Sandbox Code Playgroud)
我试过的事情:
ENOTFOUNDcors(req,res, ()=>{...})https://主持人问题是什么?
我真的很难理解Dagger 2 Dependency注射系统.
我理解使用@Inject注释告诉Dagger我们需要在这里提供某种类型的实例.
但是,我不明白其他成分如各种角色:@Module,@Component,@Provides以及他们如何一起工作,以提供相应的实例到适当的依赖.
有人可以简单而简洁地解释一下吗?
我是android的新手,非常习惯于web开发.在javascript中,当您要执行异步任务时,您将函数作为参数传递(回调):
http.get('www.example.com' , function(response){
//some code to handle response
});
Run Code Online (Sandbox Code Playgroud)
我想知道我们是否可以对android做同样的事情AsyncTask,传递方法的函数引用onPostExecute(),它将运行它.
有什么建议 ?
我正在使用Angular2和Semantic UI作为css库.我有这段代码:
<div class="ui three stakable cards">
<a class="ui card"> ... </a>
<a class="ui card"> ... </a>
<a class="ui card"> ... </a>
</div>
Run Code Online (Sandbox Code Playgroud)
卡片很好地呈现在它们之间的空间.像这样:请参阅链接中的卡片部分
因为卡片代表某种视图我想到用它制作一个组件,所以现在代码是:
<div class="ui three stakable cards">
<my-card-component></my-card-component>
<my-card-component></my-card-component>
<my-card-component></my-card-component>
</div>
Run Code Online (Sandbox Code Playgroud)
但现在风格破碎了,它们之间再也没有空间了.
有没有什么好办法解决这个问题?
我想做的第一件事是:
my-card-component OLD template:
<a class="ui card">
[some junk]
</a>
|||
VVV
my-card-component NEW template:
[some junk]
and instantiating like:
<my-card-component class="ui card"></my-card-component>
or like:
<a href="?" my-card-component></a>
Run Code Online (Sandbox Code Playgroud)
但这并不令人满意,因为我希望能够传入一个对象并且组件会自动设置[href]=obj.link.
在AngularJS 1.0中,有一个replace: true属性可以满足我的需求,在Angular2中有类似的东西吗?
css semantic-ui angular2-directives angular2-template angular
我是Webpack的新手,并将它用于Angular2项目(https://angularclass.github.io/angular2-webpack-starter/).
我很难让jQuery和Semantic-ui工作(包括.css和.js)npm install.我认为这有点问题,因为这两个库都没有任何模块格式,也不能简单地require(...)编辑或import编辑
我是否需要将它们简单地包含在index.html正常情况下,或者是否有"Webpack方式"来执行此操作?
我希望能够使用定点数据类型和递归方案来制定hindley-milner类型推理算法.忽略除实际递归部分之外的所有细节:
w env term = case term of
Lam n e -> lam (w (modify1 env) e)
App a b -> app (w (modify2 env) a) (w (modify3 env) b)
...
Run Code Online (Sandbox Code Playgroud)
该算法在env递归遍历树直到它到达叶子时构建环境数据结构.然后它再次使用此信息建立结果.
没有这env部分,这可以很容易地实现cata.这个(with env)一般可以使用递归方案吗?
recursion haskell type-inference hindley-milner recursion-schemes
我想使用 GADT 在 Haskell 中对 Tensor 演算进行类型安全的实现,因此规则是:
- 是一个没有 indecies 的张量(标量),
是一个带有“楼上”索引的张量,
是一个带有一堆“楼上”和“楼下”indecies的张量您可以添加相同类型的张量,这意味着它们具有相同的 indecies 签名。第一个张量的第 0 个索引与第二个张量的第 0 个索引属于相同类型(楼上或楼下),依此类推...
所以我希望 Haskell 的类型检查器不允许我编写不遵循这些规则的代码,否则它不会编译。
这是我使用 GADT 的尝试:
{-# LANGUAGE GADTs #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE TypeOperators #-}
data Direction = T | X | Y | Z
data Index = Zero | Up Index | Down Index deriving (Eq, Show)
plus :: Index -> …Run Code Online (Sandbox Code Playgroud) 我想要一个带注释的 AST,所以我使用Fix以下定义了这些递归数据结构:
data Term a
= Abstraction Name a
| Application a a
| Variable Name
deriving (Read,Show,Eq,Functor,Foldable,Traversable)
data Label a b
= Label a (Term b)
deriving (Read,Show,Eq,Functor,Foldable,Traversable)
newtype Labeled a
= Labeled (Fix (Label a))
deriving (Show)
Run Code Online (Sandbox Code Playgroud)
我希望能够showa Labeled a,但编译器不高兴:
Run Code Online (Sandbox Code Playgroud)No instance for (Show1 (Label a)) arising from the first field of `Labeled' (type `Fix (Label a)')
什么是类Show1以及如何定义适当的实例以显示Labeled a?
haskell abstract-syntax-tree recursive-datastructures deriving
我正在尝试调用knit,它告诉我它需要一个rmarkdown需要包的更新版本stringi.
安装时stringi我收到以下错误:
> install.packages("stringi")
Installing package into ‘C:/Users/matan/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
There is a binary version available but the source version is later:
binary source needs_compilation
stringi 1.1.5 1.1.6 TRUE
Binaries will be installed
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/stringi_1.1.5.zip'
Warning in install.packages :
cannot open URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/stringi_1.1.5.zip': HTTP status was '404 Not Found'
Error in download.file(url, destfile, method, mode = "wb", ...) :
cannot open URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/stringi_1.1.5.zip'
Warning in install.packages :
download of …Run Code Online (Sandbox Code Playgroud) 我知道如何使用do块内每个monad的函数.但是一旦我完成了如何运行计算并获得结果?
run :: (MonadError Error m, MonadState State m) => m Int -> Int
run = ???
Run Code Online (Sandbox Code Playgroud) haskell ×4
android ×2
angular ×2
java ×2
semantic-ui ×2
css ×1
dagger-2 ×1
data-kinds ×1
deriving ×1
dns ×1
firebase ×1
gadt ×1
jquery ×1
monads ×1
node.js ×1
paypal ×1
r ×1
r-markdown ×1
recursion ×1
rstudio ×1
state-monad ×1
stringi ×1
type-safety ×1
typeclass ×1
webpack ×1