背景
我正在尝试将条带付款整合到我的网站中.我需要使用私有条带密钥创建条带用户.我将此密钥存储在我的服务器上,并调用服务器方法来创建用户.也许有另一种方法可以实现这一目标?这是条纹api(为方便起见,下面复制):https: //stripe.com/docs/api/node#create_customer
//stripe api call
var Stripe = StripeAPI('my_secret_key');
Stripe.customers.create({
description: 'Customer for test@example.com',
card: "foobar" // obtained with Stripe.js
}, function(err, customer) {
// asynchronously called
});
Run Code Online (Sandbox Code Playgroud)
我的尝试和结果
我一直在使用不同服务器代码的相同客户端代码.所有尝试都会在客户端的console.log(...)上立即给出undefined,但在服务器console.log(...)上给出正确的响应:
//client
Meteor.call('stripeCreateUser', options, function(err, result) {
console.log(err, result);
});
//server attempt 1
var Stripe = StripeAPI('my_secret_key');
Meteor.methods({
stripeCreateUser: function(options) {
return Meteor.wrapAsync(Stripe.customers.create({
description: 'Woot! A new customer!',
card: options.ccToken,
plan: options.pricingPlan
}, function (err, res) {
console.log(res, err);
return (res || err);
}));
}
});
//server attempt …Run Code Online (Sandbox Code Playgroud) 编辑
所以我发现它与路由器处于历史模式有关,如果我'mode': 'history',从router.js中删除一切都有效!如果其他人有同样的问题,或者有人可以提供解释,请离开这里......
原版的
我无法将vue v2与vue-router和cordova一起使用(即建立cordova/www并使用index.html文件中的cordova工作).我曾经能够使用vue和vue-router v1.我也能用vue v2但不使用vue-router.
要清楚,应用程序npm run dev在打开构建时使用时不起作用index.html.
我有一种感觉这与路由器寻找路径/但看到的有关index.html吗?
以下是一些相关代码:
main.js
import Vue from 'vue'
import App from './App.vue'
import router from './router/router.js'
/* eslint-disable no-new */
new Vue({
el: '#app',
router,
// replace the content of <div id="app"></div> with App
render: h => h(App)
})
Run Code Online (Sandbox Code Playgroud)
app.vue
<template>
<div id="app">
<img src="./assets/logo.png">
<router-view></router-view>
</div>
</template>
<script>
import Hello from './components/Hello'
export default {
name: …Run Code Online (Sandbox Code Playgroud) 我正在通过修改我为处理切片而创建的库来尝试泛型。我有一个Difference函数,它接受切片并返回仅在其中一个切片中找到的唯一元素的列表。
我修改了该函数以使用泛型,并且我正在尝试使用不同类型(例如字符串和整数)编写单元测试,但在联合类型方面遇到了麻烦。这就是我现在所拥有的:
\ntype testDifferenceInput[T comparable] [][]T\ntype testDifferenceOutput[T comparable] []T\ntype testDifference[T comparable] struct {\n input testDifferenceInput[T]\n output testDifferenceOutput[T]\n}\n\nfunc TestDifference(t *testing.T) {\n for i, tt := range []testDifference[int] {\n testDifference[int]{\n input: testDifferenceInput[int]{\n []int{1, 2, 3, 3, 4},\n []int{1, 2, 5},\n []int{1, 3, 6},\n },\n output: []int{4, 5, 6},\n },\n } {\n t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {\n actual := Difference(tt.input...)\n\n if !isEqual(actual, tt.output) {\n t.Errorf("expected: %v %T, received: %v %T", tt.output, tt.output, actual, actual)\n }\n …Run Code Online (Sandbox Code Playgroud) 我正在通过服务器方法执行数据库计数.用户可以选择他们想要执行计数的方式,然后调用该方法.
我的问题是计数可能需要一些时间,并且用户可能会在方法运行时改变主意并请求不同的计数.我有什么方法可以取消调用的方法并运行新的计数吗?
我以为this.unblock()可能会起作用; 它将允许运行一个新方法,但它不会取消旧方法.我也考虑过预先计数,然后只使用查找,但选择器组合太多了.
这是我的代码,它很简单:
//Server
Meteor.methods({
getFilterCount: function(oFilterSelector) {
return clMaBldgs.find(oFilterSelector, {}).count();
}
});
//Client
Meteor.call('getFilterCount', oFilterSelector, function (error, result) {
//do some stuff
});
Run Code Online (Sandbox Code Playgroud) 我有一个相当大的项目,许多集成测试分散在不同的包中。我使用构建标签来分隔单元、集成和 e2e 测试。
在运行集成和 e2e 测试之前,我需要进行一些设置,因此我将一个TestMain函数放在main_test.go根目录的文件中。这很简单:
//go:build integration || e2e
// +build integration e2e
package test
import (
...
)
func TestMain(m *testing.M) {
if err := setup(); err != nil {
os.Exit(1)
}
exitCode := m.Run()
if err := tearDown(); err != nil {
os.Exit(1)
}
os.Exit(exitCode)
}
func setup() error {
// setup stuff here...
return nil
}
func tearDown() error {
// tear down stuff here...
return nil
}
Run Code Online (Sandbox Code Playgroud)
但是,当我运行测试时:
$ go test …Run Code Online (Sandbox Code Playgroud) 我是蟒蛇和蟒蛇的新手,所以请原谅任何无知.
我正在尝试使用conda安装keras.我在Windows 10(胜利-64).我看到有一个win-64包keras @ 1.0.8,但是当我去安装它时conda install -c jaikumarm keras=1.0.8,我收到以下错误:
conda install -c jaikumarm keras=1.0.8
Fetching package metadata ...........
Solving package specifications: .
PackageNotFoundError: Package not found: '' Package missing in current win-64 channels:
- keras 1.0.8*
You can search for packages on anaconda.org with
anaconda search -t conda keras
Run Code Online (Sandbox Code Playgroud)
当我使用cli搜索时:
anaconda search -t conda keras
Using Anaconda API: https://api.anaconda.org
Run 'anaconda show <USER/PACKAGE>' to get more details:
Packages:
Name | Version | Package Types | Platforms …Run Code Online (Sandbox Code Playgroud) 我需要将此提交拉入我的 go 项目中。
我尝试了多个版本go.mod:
...
require (
github.com/libp2p/go-libp2p-core@v0.0.7-0.20190626134135-aca080dccfc2
// and...
github.com/libp2p/go-libp2p-core v0.0.0-20190626-aca080dccfc2c9933df66baafe6cf9cc4f429825
)
...
Run Code Online (Sandbox Code Playgroud)
两者在运行时都会导致错误$ go build:
...
require (
github.com/libp2p/go-libp2p-core@v0.0.7-0.20190626134135-aca080dccfc2
// and...
github.com/libp2p/go-libp2p-core v0.0.0-20190626-aca080dccfc2c9933df66baafe6cf9cc4f429825
)
...
Run Code Online (Sandbox Code Playgroud)
去获取也不起作用:
$ go build
go: finding github.com/libp2p/go-libp2p-core v0.0.0-20190626-aca080dccfc2c9933df66baafe6cf9cc4f429825
go: finding github.com/libp2p/go-libp2p-core v0.0.7-0.20190626134135-aca080dccfc2
go: github.com/libp2p/go-libp2p-core@v0.0.0-20190626-aca080dccfc2c9933df66baafe6cf9cc4f429825: unknown revision v0.0.0-20190626-aca080dccfc2c9933df66baafe6cf9cc4f429825
go: github.com/libp2p/go-libp2p-core@v0.0.7-0.20190626134135-aca080dccfc2: unknown revision aca080dccfc2
go: error loading module requirements
Run Code Online (Sandbox Code Playgroud)
正如@JimB 指出的那样,该散列未合并并重新定位。所以我试图用一个新的替换它,但它仍然试图获取旧的?
$ go get github.com/libp2p/go-libp2p-core@aca080dccfc2c9933df66baafe6cf9cc4f429825
go: finding github.com/libp2p/go-libp2p-core v0.0.7-0.20190626134135-aca080dccfc2 go: github.com/libp2p/go-libp2p-core@v0.0.7-0.20190626134135-aca080dccfc2: unknown revision aca080dccfc2
go: error loading module requirements
Run Code Online (Sandbox Code Playgroud) 我有 cordova 应用程序,它使用 WebRTC 和 RTCPeerConnection 连接两个客户端以允许他们聊天。它在浏览器和 iOS 上(使用 webRTC shim)成功运行。但是,Android 上仅捕获和发送音频,没有视频!这是代码。该视频甚至没有附加到#localVideo elem(这本身可能是另一个问题)!
navigator.getUserMedia = navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia
navigator.getUserMedia({video: true, audio: true}, function (stream) {
var video = document.getElementById('localVideo')
video.src = window.URL.createObjectURL(stream)
video.play()
window.myRTC.pc1.addStream(stream)
console.log(stream)
console.log('adding stream to pc1')
window.myRTC.setupDC1()
window.myRTC.pc1.createOffer(function (desc) {
window.myRTC.pc1.setLocalDescription(desc, function () {}, function () {})
console.log('created local offer', desc)
},
function () { console.warn("Couldn't create offer") },
window.myRTC.sdpConstraints)
}, function (error) {
console.log('Error adding stream to pc1: ' + …Run Code Online (Sandbox Code Playgroud) 我有一个类似下面的mongo集合(Foo(X)== keys; Bars == values):编辑 - 我来自关系数据库背景.显然我的收藏品看起来不像下面那样,但你明白了......
+--------+--------+--------+
| Foo1 | Foo2 | Foo3 |
+--------+--------+--------+
| Barbar | Barbar | Bar |
| bar | Bar | BarBar |
| Bar | barbar | barBar |
| ... | ... | ... |
Run Code Online (Sandbox Code Playgroud)
允许我的客户端过滤数据对我来说很重要.有时候,所有列都会有一个过滤器,有时候没有列会有过滤器,而且介于两者之间.目前,我正在处理以下问题:
客户
Var aFoo1Filter = ["bar"]
Var aFoo2Filter = ["Barbar", "BarBar"]
Var aFoo3Filter = ["barbar", "bar"]
//Where the user can affect the array through some other code
Run Code Online (Sandbox Code Playgroud)
服务器
Meteor.publish("foos", function (aFoo1Filter, aFoo2Filter, aFoo3Filter ) {
return …Run Code Online (Sandbox Code Playgroud) 假设我在 postgres 中有一个简单的表,如下所示:
+--------+--------+----------+
| Car | Pet | Name |
+--------+--------+----------+
| BMW | Dog | Sam |
| Honda | Cat | Mary |
| Toyota | Dog | Sam |
| ... | ... | ... |
Run Code Online (Sandbox Code Playgroud)
我想运行一个 sql 查询,该查询可以返回第一列中的列名和第二列中的唯一值。例如:
+--------+--------+
| Col | Vals |
+--------+--------+
| Car | BMW |
| Car | Toyota |
| Car | Honda |
| Pet | Dog |
| Pet | Cat |
| Name | Sam | …Run Code Online (Sandbox Code Playgroud) go ×3
javascript ×3
meteor ×3
cordova ×2
anaconda ×1
conda ×1
distinct ×1
generics ×1
mongodb ×1
postgresql ×1
python ×1
sql ×1
vue-router ×1
vue.js ×1
webrtc ×1