我第一次尝试使用Angular + express + mongodb构建一些东西,所以我可能完全以错误的方式解决这个问题.Express被用来提供json.然后Angular负责所有的观点等.
我正在使用Mongoose与Mongo进行交互.
我有以下数据库架构:
var categorySchema = new mongoose.Schema({
title: String, // this is the Category title
retailers : [
{
title: String, // this is the retailer title
data: { // this is the retailers Data
strapLine: String,
img: String , // this is the retailer's image
intro: String,
website: String,
address: String,
tel: String,
email: String
}
}
]
});
var Category = mongoose.model('Category', categorySchema);
Run Code Online (Sandbox Code Playgroud)
在Express中我有几条路径来获取数据:
app.get('/data/categories', function(req, res) {
// Find all Categories.
Category.find(function(err, …Run Code Online (Sandbox Code Playgroud) 我正在为我的商店开发一个新的Shopify模板.我正在尝试将标题中的字符数和我描述中的字符数加起来.从200减去此总数,并在截断中使用结果.
(这是因为我想在每个方框中获得相同数量的字符)
我认为下面的代码可以工作....捕获位工作(nb:如果我的总字符数= 204,结果是4)但似乎截断不能解决变量?
{% capture truncateBy %}
{{ product.title.size | plus: product.description.size | minus: 200 }}
{% endcapture %}
<p>{{ product.description | strip_html | replace: ' ', ' ' | truncate: truncateBy }}</p>
Run Code Online (Sandbox Code Playgroud) 我正在尝试拍摄网络摄像头 - (横向格式),剪切中间位(纵向格式)并将其渲染到画布,使其填充屏幕纵向1080px到1920px(为此我缩放我剪切的位出3.8).然后我需要翻转这个画布,以便镜像图像.我已经成功地删除了中间位,并将其呈现给画布......我只是想弄清楚如何翻转它.
编辑
感谢所有在context.scale(-1,1)指出我的人 - 我的问题是,我已经在使用scale ...我认为我的问题与保存上下文有关,但我尝试的一切没能奏效?
<script>
// Put event listeners into place
window.addEventListener("DOMContentLoaded", function() {
// Grab elements, create settings, etc.
var canvas = document.getElementById("canvas"),
context = canvas.getContext("2d"),
video = document.getElementById("video"),
videoObj = {
video: {
mandatory: {
minWidth: 1280,
minHeight: 720,
/*Added by Chad*/
maxWidth: 1280,
maxHeight: 720
}
}
},
errBack = function(error) {
console.log("Video capture error: ", error.code);
};
// Put video listeners into place
if(navigator.getUserMedia) { // Standard
navigator.getUserMedia(videoObj, function(stream) {
video.src = …Run Code Online (Sandbox Code Playgroud) 使用此标记不会触发 Vue JS 计算属性
\n\n<!-- language: lang-html -->\n<p>\xc2\xa3{{plant_price}}</p>\n\n <div v-if="selected.plant.variations.length > 0 ">\n <select v-model="selected.plant.selected_variation" class="form-control">\n <!-- inline object literal -->\n <option v-for="(variation, i) in selected.plant.variations" :selected="variation.id == selected.plant.selected_variation ? \'selected\' : \'\'":value="variation.id">\n {{variation.name}}\n </option>\n </select>\n </div>\nRun Code Online (Sandbox Code Playgroud)\n\n<!-- language: lang-js -->\nvar app = new Vue({\n el: \'#vueApp\',\n data: {\n selected: {\n type: {a: \'\' , b: \'\'},\n vehicle: \'\',\n plant: {\n }\n },\n computed: {\nplant_price: function() {\n if (this.selected.plant.variations.length > 0 ) {\n var variant = _.find(this.selected.plant.variations, …Run Code Online (Sandbox Code Playgroud) 所以我只是将我的应用程序推送到Dokku(数字海洋) - 并从ajax帖子返回以下错误:
POST http://example.com/foo 413(请求实体太大)
快速谷歌显示此问题是由于client_max_body_size太低.所以我已经通过SSH连接到服务器,打开了应用程序nginx.conf并按照说明增加了它:
client_max_body_size 100M;
Run Code Online (Sandbox Code Playgroud)
https://github.com/progrium/dokku/issues/802
但是,我仍然遇到同样的问题......我是否需要重启某个进程?我尝试重新启动dokku应用程序 - 但所有这一切都是为了覆盖我的nginx.conf文件.
我正在尝试在我的 hapi.js 应用程序中验证由 stripe 发送的 webhook。我已按照此处详细说明的说明进行操作:
https://stripe.com/docs/webhooks/signatures
(我显然没有在这里发布我的端点秘密:)
<!-- language: lang-js -->
const enpointSecret = ######;
const sig = _.fromPairs(request.headers["stripe-signature"].split(',')
.map(s => s.split('=')));
// produces object eg { t: '1111', v1: '111111..', v0: '...'} etc
const signed_payload = `${sig.t}.${JSON.stringify(request.payload)}`;
const hmac = crypto.createHmac('sha256', endpointSecret)
.update(signed_payload)
.digest('hex');
Run Code Online (Sandbox Code Playgroud)
生成的 hmac 与标头 (sig.v1) 中的签名不匹配。我无法弄清楚我做错了什么......
我正在本地开发 - 并使用 ngrok,以便我可以测试我的 webhooks。这可能是一个问题吗?谢谢
在一个循环中,我有:
<div class="barcode" class="thumbnail">
<canvas class="ean" barcode-generator barcode-value="9002236311036"> </canvas>
</div>
Run Code Online (Sandbox Code Playgroud)
这会阻止一大堆条形码.我已经静态添加了条形码值,但目的是通过{{barcodeNumber}}添加
我发现了一个非常好的插件https://github.com/joushx/jQuery.EAN13,它将数字转换为条形码.
在各种教程之后,我写了以下指令(虽然我还没有得到如何或者为什么).我还在Angular上面包含了jquery,在Angular之后包含了插件.
app.directive('barcodeGenerator', function () {
return {
restrict: 'A',
scope: {
barcodeValue: '='
},
link: function (scope, elem, attrs) {
console.log("Recognized the barcode directive usage");
$('.ean').EAN13(scope.barcodeValue);
}
}
});
Run Code Online (Sandbox Code Playgroud)
console.log有效 - 但是我调用插件的位不会... Chrome调试显示以下错误:
TypeError:对象9002236311036没有方法'拆分'
我不确定我做错了什么 - 阅读过很多论坛帖子,但不能完全理解它.
谢谢,罗布
编辑 - 继下面的Francisco的帖子 - 添加toString()已经奏效.唯一的问题是,我不知道为什么/如何运作.
app.directive('barcodeGenerator', function () {
return {
restrict: 'A',
scope: {
barcodeValue: '='
},
link: function (scope, elem, attrs) {
console.log("Recognized the barcode directive …Run Code Online (Sandbox Code Playgroud) 我试图在路线中返回随机函数函数的输出...我一直在'未定义' - 但不知道我做错了什么...
var randomizer = function() {
// A load of stuff happens here.. and functions that are needed by the pullOut function (I've removed for brevity)
var pullOut = function(pick) {
if (playerList.length !== pick) {
var random_item = getRandomItem(list, weight);
if (playerList.indexOf(random_item) == -1) { // doesn't exist. So add to array.
playerList.push(random_item);
}
pullOut(pick);
} else {
console.log(playerList)
return playerList;
}
}
return pullOut(pick);
}
router.route('/ordercreated')
.post(function(req, res) {
var orderedItems = req.body.line_items;
// I foreach …Run Code Online (Sandbox Code Playgroud) 目前,我有一个重复订阅设置,每周五开始.
我正在尝试创建一个不赞成的重复订阅.客户每周支付33英镑进行访问(他们在帖子中发送了一个项目),每周五更新.
我想立即开始客户订阅,然后每周五更新.例如
如果他们在星期四报名 - 他们支付33英镑......然后他们在周五再支付33英镑,之后每周五支付.
我已经浏览了复杂的文档,并看到立即开始的所有基于订阅的订阅都是按比例分配的.有没有人对我如何处理这种情况有任何建议?
谢谢,罗布
我提前道歉 - 这个问题需要一些背景知识,这可能是冗长的:
我正在尝试构建一个可与 PouchDb 脱机工作的应用程序。PouchDb 将与 Cloudant 同步。
使用的技术:Hapi、SQL、Vue、Cloudant、PouchDb
我已经构建了一个小的 hapi.js 服务来注册/验证用户。当“帐户所有者”注册时 - 他们将作为新用户添加到 SQL 数据库中。
使用 Cloudants API,我提供了一个新数据库(使用随机名称),并在数据库上设置了安全性,以便新用户可以访问。
我将安全性(数据库名称、用户名和密码)作为元数据保存回 SQL 数据库中的用户。
与此处非常相似的方法:https : //www.bennadel.com/blog/3208-provisioning-cloudant-couchdb-databases-from-auth0-for-a-database-per-user-architecture-in-angular-2 -4-1.htm(确实,我基于以上内容)。
当“帐户所有者”登录时,查询 SQL 数据库 - 检索元数据并将其发送到客户端 vue 应用程序。然后使用 Cloudant 数据库名称、用户名和密码填充 PouchDB 远程字符串。
例如:
const remoteDB = new PouchDB(`https://${name}:${pass}@0000-0000-bluemix.cloudant.com/${DBname}`);
Run Code Online (Sandbox Code Playgroud)
这一切都有效:PouchDB 可以与 Cloudant 对话 - 并且数据可以毫无问题地进出。
“帐户所有者”能够授予其他人(“员工”)对其 cloudantDB 的读/写访问权限。当他们添加新的职员时,职员会被添加到 SQL 数据库中。使用 cloudants API,我为该用户创建了新的安全凭证,以便他们可以访问 DB-(我不创建新的 DB)并将它们保存到 SQL 数据库中的 Staff Member 作为元数据...
新员工会收到一封电子邮件 - 他们在 SQL db 上设置了他们的用户名和密码,然后可以登录。Cloudant 元数据被拾取......等等...... PouchDB / Couchdb 相互交谈 - 这也作品。
最初我有点担心将这个元/凭据发送给客户端 …