<svg version="1.1" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">
<g stroke="lightgray" stroke-dasharray="1,1" stroke-width="1" transform="scale(4, 4)">
<line x1="0" y1="0" x2="256" y2="256"></line>
<line x1="256" y1="0" x2="0" y2="256"></line>
<line x1="128" y1="0" x2="128" y2="256"></line>
<line x1="0" y1="128" x2="256" y2="128"></line>
</g>
<g transform="scale(1, -1) translate(0, -900)">
<style>
.stroke1 {fill: #BF0909;}
.stroke2 {fill: #BFBF09;}
.stroke3 {fill: #09BF09;}
.stroke4 {fill: #09BFBF;}
.stroke5 {fill: #0909BF;}
.stroke6 {fill: #BF09BF;}
.stroke7 {fill: #BFBFBF;}
.stroke8 {fill: #090909;}
</style>
<path class="stroke1" d="M 272 567 Q 306 613 342 669 Q 370 718 395 …Run Code Online (Sandbox Code Playgroud) 有没有办法允许用户使用他的密码,电子邮件和姓名注册本地策略?
我在网上找到的每个例子都只使用名称/密码或电子邮件/密码.
我还搜索了整个护照文档,但该文档根本没用.这只是一个充满例子的臃肿网站.
我只需要一份护照使用的函数,类和变量列表,并解释它们和它们的每个参数的作用.每个好的图书馆都有这样的东西,为什么我找不到护照?
以下是我的代码的关键部分:
passport.use('local-signup', new LocalStrategy({
usernameField: 'email',
passwordField: 'password',
//are there other options?
//emailField did not seem to do anything
passReqToCallback: true // allows us to pass in the req from our route (lets us check if a user is logged in or not)
},
function(req, email, password, done) {
//check if email not already in database
//create new user using "email" and "password"
//I want an additional parameter here "name"
}));
Run Code Online (Sandbox Code Playgroud)
护照真的那么有限吗?必须有办法做到这一点,对吧?
我之前在两个node.js服务器之间进行了语音聊天(参见:tvoip),这非常有效,但现在我想在node.js服务器和浏览器之间进行.怎么可以这样做?
从node.js到node.js我只是通过TCP连接使用原始PCM流.
对于浏览器来说,这可能不会那么容易,对吧?我的意思是浏览器并不真正提供TCP API.它确实提供了WebSocket API,但它是否处理流?我是否必须将流转换成什么格式以及如何转换?我应该使用什么协议?是否有任何有用的库来实现这一目标?是socket.io流的可行库派这类流?
据我所知,音频流在浏览器上采用PCM格式.所以它应该与我在Node.js中获得的流相匹配.这个假设是否正确?
我设法将浏览器麦克风输入管道传输到浏览器扬声器输出,如下所示:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
</head>
<body>
<!-- alternative method that also works
<audio></audio>
<script>
navigator.mediaDevices.getUserMedia({ audio: true }).then(function(stream) {
const audio = document.querySelector('audio')
audio.srcObject = stream
audio.onloadedmetadata = function(e) {
audio.play()
}
}).catch(console.error)
</script>
-->
<script>
navigator.mediaDevices.getUserMedia({audio: true}).then(stream => {
const aCtx = new AudioContext()
const analyser = aCtx.createAnalyser()
const microphone = aCtx.createMediaStreamSource(stream)
microphone.connect(analyser)
analyser.connect(aCtx.destination)
}).catch(err => {
console.error("Error getting audio stream from getUserMedia")
})
</script>
</body> …Run Code Online (Sandbox Code Playgroud) 如何制作iframe点击,但是iframe的正文仍然可以点击?
我试过了:
iframe.style.width = '100%'
iframe.style.height = '100%'
iframe.style.display = 'block'
iframe.style.position = 'fixed'
iframe.style.backgroundColor = 'transparent'
iframe.style.pointerEvents = 'none'
iframe.style.border = '0'
iframe.frameborder = '0'
iframe.scrolling = 'no'
iframe.allowTransparency = 'true'
Run Code Online (Sandbox Code Playgroud)
在我的框架内我使用以下css:
html, body {
/* background:none transparent; */
pointer-events:auto;
}
Run Code Online (Sandbox Code Playgroud)
这会导致身体可见(这就是我想要的),但它像iframe的其余部分一样是点击式的.我希望iframe的主体可以点击,但实际的iframe元素的其余部分应该是点击式的.
iframe总是比它里面的身体大.
不幸的是我无法从主站点访问iframe内容(因此无法访问scrollHeight等),我只能更改其实际的源代码.
如何在 Alpine Linux 上列出给定软件包的所有可用软件包版本?
我在 apk 帮助中找不到任何有用的东西。
apk info bash 只显示最新的可用 bash 版本。
# apk info bash
bash-5.0.0-r0 description:
The GNU Bourne Again shell
bash-5.0.0-r0 webpage:
https://www.gnu.org/software/bash/bash.html
bash-5.0.0-r0 installed size:
1200128
Run Code Online (Sandbox Code Playgroud)
使用该--all标志,我只能获得该版本的一些附加信息:
# apk info --all bash
bash-5.0.0-r0 description:
The GNU Bourne Again shell
bash-5.0.0-r0 webpage:
https://www.gnu.org/software/bash/bash.html
bash-5.0.0-r0 installed size:
1200128
bash-5.0.0-r0 depends on:
/bin/sh
so:libc.musl-x86_64.so.1
so:libreadline.so.8
bash-5.0.0-r0 provides:
cmd:bash
bash-5.0.0-r0 has auto-install rule:
bash-5.0.0-r0 license:
GPL-3.0-or-later
Run Code Online (Sandbox Code Playgroud)
apk list并且apk list --available只列出最新版本的所有可用包。
所以如果我运行apk list -a …
假设我使用以下代码来运行一系列的promises:
let paramerterArr = ['a','b','c','d','e','f']
parameterArr.reduce(function(promise, item) {
return promise.then(function(result) {
return mySpecialFunction(item);
})
}, Promise.resolve())
Run Code Online (Sandbox Code Playgroud)
代码只是调用mySpecialFunction(它返回一个promise),等待解析的promise,然后再次调用mySpecialFunction等等.因此,对于数组中的每个元素,按正确的顺序调用该函数一次.
我怎样才能确保每次通话之间至少有50毫秒的延迟mySpecialFunction(item)?
重要的是承诺以正确的顺序执行,执行时间mySpecialFunction每次都不同.
我想同步睡眠会起作用,但我不打算在一个单独的线程中运行这个代码,因此它会在浏览器中引起恼人的ui冻结.
我不确定是否可以以某种方式使用setTimer.我的意思是我不能拖延承诺的回归.
我在过去几周一直在编写一些浏览器扩展,直到今天我还认为Firefox的WebExtension应该在Chrome中自动运行.所以我试着根据Mozilla的例子编写我的代码.
但是今天我意识到Chrome扩展程序的API文档中没有提到Promises.
我在所有扩展程序的代码中都严格使用了Promise.
所以现在我的问题是,我的代码会在Chrome中运行吗?或者,如果我var browser = chrome在最顶层添加声明,它会起作用吗?
或者Chrome根本不支持API上的Promise?
如果Chrome尚未支持API函数的Promises,它将来是否会支持它们?
注意,我知道这个项目:https://github.com/mozilla/webextension-polyfill
但是我不愿意经历在任何地方包含该库的麻烦.此外,它有令人讨厌的错误.
除此之外,我没有Chrome或Chromium,出于隐私和安全原因,我无法安装它们.
javascript google-chrome-extension firefox-addon-webextensions
我想让页面慢慢平滑地向下滚动.那么,速度实际上应该是可调的.用户还应该能够在脚本向下滚动时手动向上滚动.首先我尝试了这个:
var autoScrollDelay = 1
var autoScrollSpeed = 1
var autoScrollTimer
function setAutoScroll(newValue) {
autoScrollSpeed = newValue ? newValue : autoScrollSpeed
if (autoScrollTimer) {
clearInterval(autoScrollTimer)
}
if (autoScrollDelay) {
autoScrollTimer = setInterval(function(){
window.scrollBy(0,autoScrollSpeed)
},autoScrollDelay)
}
}
setAutoScroll(1) // higher number = faster scrolling
Run Code Online (Sandbox Code Playgroud)
但它导致了非常繁重的CPU负载,而最慢的速度太快了.除此之外,在代码运行时手动向上滚动也无法正常工作.
然后我尝试了:
var autoScrollDelay = 1
var autoScrollSpeed = 1
var autoScrollTimer
function setAutoScroll(newValue) {
autoScrollDelay = newValue ? newValue : autoScrollDelay //using autoScrollDelay instead of autoScrollSpeed
if (autoScrollTimer) {
clearInterval(autoScrollTimer)
}
if (autoScrollDelay) {
autoScrollTimer = …Run Code Online (Sandbox Code Playgroud) javascript ×7
node.js ×3
css ×2
html ×2
admin ×1
alpine-linux ×1
audio ×1
bash ×1
browser ×1
c++ ×1
cover ×1
delay ×1
ecmascript-6 ×1
es6-promise ×1
firefox-addon-webextensions ×1
icons ×1
iframe ×1
jquery ×1
linux ×1
mkv ×1
package ×1
passport.js ×1
privileges ×1
promise ×1
scroll ×1
svg ×1
tagging ×1
voip ×1
windows ×1