我也将它发布到了Squeak Beginners列表中 - 我一定会确保从那里得到任何答案:)
我正在使用Squeak 4.2并处理命名管道连接的smalltalk端,该连接使用以下命令向命名管道服务器发送消息:
msg := 'Here''s Johnny!!!!'.
pipe nextPutAll: msg; flush.
Run Code Online (Sandbox Code Playgroud)
然后它应该收到一个确认,它将是收到的消息的32字节md5哈希值(smalltalk应用程序随后可以验证).命名管道服务器可能已经消失或者无法处理请求,因此我想在读取确认时设置超时.我试过用这个:
ack := [ pipe next: 32 ] valueWithin: (Duration seconds: 3) onTimeout: [ 'timeout'. ].
Run Code Online (Sandbox Code Playgroud)
然后使管道服务器人为地暂停以测试代码.但是smalltalk线程在读取时阻塞并且不进行(即使在超时之后),但是如果我然后让管道服务器发送正确的响应(例如在5秒延迟之后),则为'ack'的值'是'超时'.显然超时完成了它应该做的事情,但无法"解锁"管道上的阻塞读取.
有没有办法实现这一点,即使阻止FileStream读取?如果可能的话,我宁愿避免忙碌等待有32个字符可用.
我正在使用一个节点库,它允许发出简单的 http 请求并返回一个承诺 - 这很好用,因为它允许并行创建多个请求,然后我稍后使用Promise.all(). 但是,http 请求只返回一个字符串,我需要知道有关每个请求的一些额外标识信息。所以我认为这样做的一种方法是从请求承诺中链接一些东西并将该信息添加进去。 这是我到目前为止的代码,显示了一个这样的请求被添加到我稍后将收集的承诺数组中:
var promises = [];
promises.push(new Promise(function(resolve, reject){
ReqPromise('http://some.domain.com/getresult.php')
.then(function(reqResult) {
resolve({
source: 'identifier',
value: reqResult
});
});
}));
Run Code Online (Sandbox Code Playgroud)
这就是我在解决这个承诺时得到的回报:
{
source: 'identifier'
value: 1.2.3.4
}
Run Code Online (Sandbox Code Playgroud)
这是“标记”承诺结果的理想方式吗?或者我对承诺有什么误解,这意味着我不需要像上面那样创建额外的承诺?请注意,这ReqPromise是在一个外部库中,因此很难让它接受额外的参数并返回它们。
我有一个脚本处理共享邮箱并转发不同的电子邮件(基于诸如原始的'To:'标题之类的东西给各个人.它已经好几个月工作,因为它更灵活(以及迄今为止,可靠)更换用于gmail过滤器.
逻辑是基本的
我们最近收到了一封电子邮件,似乎在邮件转发时触发了一个奇怪的错误.错误是'无效的mime类型.(第123行,文件"代码").脚本的第123行写道:
// subject: removes the 'Fwd:' prefix which we don't need, and adds the original target email in square brackets, and sets the replyTo for easy processing
really && msg.forward(rcvr, {subject: msg.getSubject() + " [" + thisTo + "]", replyTo: msg.getFrom()});
Run Code Online (Sandbox Code Playgroud)
以下是有趣位的摘要:
really 只是一个布尔值,所以我们可以做'干运行'进行测试msg 设置为当前正在处理的邮件,其类型为GmailMessagercvr 是带有收件人电子邮件地址的字符串thisTo 是一个包含原始"To:"标题的字符串有问题的消息是一个多部分的mime电子邮件,其中包含纯文本和html.它在gmail中显示得很好,我可以毫无问题地从那里转发它.那么,有没有人能够了解脚本引擎的抱怨?原始电子邮件看起来像这样(有一些位用于隐私),以防有助于将其固定:
Delivered-To: XXXX@YYYY.com
Received: by 10.182.155.73 with SMTP id vj5sqase239pbc;
Wed, 26 Jun 2013 08:50:48 -0700 (PDT)
X-Received: by 10.68.166.5 with SMTP id …Run Code Online (Sandbox Code Playgroud) 我正在使用客户端应用程序中的可调用函数从 Firestore 中检索一些数据。数据是使用以下方法创建的:
projectData = {
created: firebase.firestore.FieldValue.serverTimestamp(),
...otherData
}
firebase.firestore().collection(projectsCollection).add(projectData)
Run Code Online (Sandbox Code Playgroud)
我可以看到时间戳正确保存在 Firestore 控制台中。callable 函数做了一些其他的事情并且有错误处理,但是数据检索是这样完成的(使用 lodash 将每个文档展开成一个对象返回给客户端):
const projectRef = firestore.collection(gProjectsCollection).orderBy('created')
return projectRef.get().then(snapshot => {
return {
projects: _.chain(snapshot.docs)
.keyBy('id')
.mapValues(s => s.data())
.value()
}
})
Run Code Online (Sandbox Code Playgroud)
这主要是有效的,但返回的对象有一个被破坏的created属性(在函数 shell 输出中显示):
RESPONSE RECEIVED FROM FUNCTION: 200, {
"result": {
"projects": {
"XcRyQyaxLguRdbNmxQdn": {
"name": "c",
"description": "c",
"created": {
"_seconds": 1543405587,
"_nanoseconds": 169000000
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我假设这是因为可调用函数在JSON.stringify()内部使用,并且服务器时间戳未正确转换。我尝试将时间戳显式转换为这样的日期:
return projectRef.get().then(snapshot => {
return {
exVersion,
exId,
projects: …Run Code Online (Sandbox Code Playgroud) javascript firebase google-cloud-functions google-cloud-firestore
我在云函数中有以下代码,该消息返回错误消息
错误:3个INVALID_ARGUMENT:每个请求最多允许500次写入
console.log(`${projectId} doClassifySources: Got ${_.size(output)} items`)
const lastClassification = new Date().toJSON()
const batch = firestore.batch()
batch.update(projectRef, {lastClassification})
_.forEach(output, item => {
batch.set(projectRef.collection('output').doc(encodeURIComponent(item.url)), {
classifiedAt: admin.firestore.FieldValue.serverTimestamp(),
...item
}, {
merge: true
})
})
return batch.commit().then(() => lastClassification)
Run Code Online (Sandbox Code Playgroud)
但是,firebase日志在抛出错误之前就显示了这一点:
12:28:19.963 PM classifySources ZklZYB5hq96J43CroKgP doClassifySources: Got 310 items
Run Code Online (Sandbox Code Playgroud)
在我看来,该批次应包含310个项目,远低于500个限制。我在计算500个项目的限额时是否缺少某些东西?是否merge: true影响以任何方式?这与item正在写入的对象的传播有关(即,这是否会增加所需的写入次数)?
我理解.sync在Vue 2.3中返回的修饰符,并将其用于实现"多选"问题和答案的简单子组件.父组件像这样调用子组件:
<question
:stem="What is your favourite colour?"
:options="['Blue', 'No, wait, aaaaargh!']
:answer.sync="userChoice"
>
Run Code Online (Sandbox Code Playgroud)
父项具有一个字符串数据元素,userChoice用于存储子组件的结果.孩子为选项提供问题和单选按钮.孩子的基本部分看起来像这样(我使用的是Quasar q-radio):
<template>
<div>
<h5>{{stem}}</h5>
<div class="option" v-for="opt in options">
<label >
<q-radio v-model="option" :val="opt.val" @input="handleInput"></q-radio>
{{opt.text}}
</label>
</div>
</div>
</template>
export default {
props: {
stem: String,
options: Array,
answer: String
},
data: () => ({
option: null
}),
methods: {
handleInput () {
this.$emit('update:answer', this.option)
}
}
}
Run Code Online (Sandbox Code Playgroud)
这一切都很好,除了如果父母然后更改userChoice由于应用程序中发生的其他事情的值,孩子不会更新单选按钮.我不得不把这个包含watch在孩子身上:
watch: {
answer () …Run Code Online (Sandbox Code Playgroud) 我知道Firebase的云功能仍然很新,但我正在尝试将一些客户端代码移到云端,而"注册"过程似乎是一个明显的目标.
目前,注册页面要求提供电子邮件地址,生成随机密码和呼叫createUserWithEmailAndPassword().这很好用,然后我想将"重置密码"电子邮件发送到刚才使用的电子邮件地址,以确认电子邮件地址,并让用户有机会设置他们选择的特定密码.我能够在客户端代码中执行此操作,但我想尝试创建由...触发的函数onCreate().
这一点工作正常,但我无法弄清楚如何sendPasswordResetEmail()从firebase函数环境中调用.
这是到目前为止的代码:
var functions = require('firebase-functions')
const admin = require('firebase-admin')
admin.initializeApp(functions.config().firebase)
exports.createUserRec = functions.auth.user().onCreate(event => {
admin.auth().sendPasswordResetEmail(event.data.email)
})
Run Code Online (Sandbox Code Playgroud)
功能日志说:
TypeError: admin.auth(...).sendPasswordResetEmail is not a function
Run Code Online (Sandbox Code Playgroud)
我假设该auth()对象auth()与客户端SDK中找到的对象不同,这可以使用:
import * as firebase from 'firebase/app'
import 'firebase/database'
import 'firebase/auth'
var fbConfig = {
// All the required bits
}
firebase.initializeApp(fbConfig)
.
.
.
firebase.auth().sendPasswordResetEmail(emailAddress)
Run Code Online (Sandbox Code Playgroud)
我简要地搜索了firebase函数源代码,我看不到任何明显的sendPasswordResetEmail()函数引用,所以也许它不是直接可用的(还是?).有没有其他方法来触发这个 - 除了把它放回客户端代码?
我有一个应用程序,我正在为其创建一个自定义组件,该组件将输出表格的单行。它包含一个用户可调整的数字字段,因此在该自定义组件中,我使用了 quasar 框架中的另一个自定义组件 ( q-numeric)。我正在努力了解如何通过 2 个组件在顶层绑定变量 - 也许它不能直接完成,但我希望避免在中间组件中添加大量额外代码。到目前为止,从上到下看起来是这样的:
在 App.vue 模板中,我有这样的行:
<config-item v-model="numParticipants">Number of Participants</config-item>
Run Code Online (Sandbox Code Playgroud)
ConfigItem.vue,看起来像这样:
<template>
<tr>
<td class="text-right"><slot></slot></td>
<td class="text-right">
<q-numeric
v-model="value"
:min="min"
:max="max"
:step="step"
@input="$emit('input', value)"
></q-numeric>
</td>
</tr>
</template>
<script>
export default {
props: {
label: String,
value: Number,
min: {
type: Number,
default: 1
},
max: {
type: Number,
default: 1000
},
step: {
type: Number,
default: 1
}
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
但这当然行不通,因为我现在将属性 绑定value到q-numeric,这会改变它。真的,我不想将顶级变量绑定numParticipants到 …
javascript ×3
firebase ×2
vue.js ×2
blocking ×1
named-pipes ×1
promise ×1
smalltalk ×1
squeak ×1
timeout ×1
vuejs2 ×1