如何改变${USER}JetBrains WebStorm的价值?
我在寻找Settings-> File and Code Templates但在那里我只能改变寺庙的结构而不是变量的价值USER.
/**
* Created by ${PRODUCT_NAME}.
* User: ${USER}
* Date: ${DATE}
* Time: ${TIME}
* To change this template use File | Settings | File Templates.
*/
Run Code Online (Sandbox Code Playgroud) 我有两个用于 puppeteer 自动化的 Node.js 脚本。
1) 启动器.js
此 Puppeteer 脚本启动 Chrome 浏览器并断开与 chrome 的连接,以便可以使用 WSEndpoint 进行连接。
const puppeteer = require('puppeteer');
module.exports = async () => {
try {
const options = {
headless: false,
devtools: false,
ignoreHTTPSErrors: true,
args: [
`--no-sandbox`,
`--disable-setuid-sandbox`,
`--ignore-certificate-errors`
]
};
const browser = await puppeteer.launch(options);
let pagesCount = await browser.pages();
const browserWSEndpoint = await browser.wsEndpoint();
// console WSEndPoint say : "ws://127.0.0.1:42207/devtools/browser/dbb2525b-ce44-43c2-a335-ff15d0306f36"
console.log("browserWSEndpoint----- :> ", browserWSEndpoint);
await browser.disconnect();
return browserWSEndpoint;
} catch (err) {
console.error(err);
process.exit(1); …Run Code Online (Sandbox Code Playgroud) 我的eslint配置就像这样简单
{
"extends": "airbnb-base",
"env": {
"browser": true,
"es6": true,
"jquery": true
},
"plugins": [
"ejs"
]
}
Run Code Online (Sandbox Code Playgroud)
我跑的时候
eslint app.js
Run Code Online (Sandbox Code Playgroud)
输出是:
162:110 error A space is required after ',' comma-spacing
167:1 error Expected indentation of 2 spaces but found 4 indent
168:1 error Expected indentation of 4 spaces but found 8 indent
169:1 error Expected indentation of 4 spaces but found 8 indent
170:1 error Expected indentation of 2 spaces but found 4 indent
171:1 error Expected indentation of …Run Code Online (Sandbox Code Playgroud) 我在我的 Node.js 项目中收到来自 Amazon S3 SDK 的错误,如下所示。
{ Error: getaddrinfo EAI_AGAIN ***.s3-accelerate.amazonaws.com:443
at Object._errnoException (util.js:992:11)
at errnoException (dns.js:55:15)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:92:26)
message: 'getaddrinfo EAI_AGAIN ***.s3-accelerate.amazonaws.com:443',
code: 'NetworkingError',
errno: 'EAI_AGAIN',
syscall: 'getaddrinfo',
hostname: '***.s3-accelerate.amazonaws.com',
host: '***.s3-accelerate.amazonaws.com',
port: 443,
region: 'us-east-1',
retryable: true,
time: 2018-12-14T05:46:18.649Z }
error: There was an error viewing your album: getaddrinfo EAI_AGAIN ***.s3-accelerate.amazonaws.com:443
Run Code Online (Sandbox Code Playgroud)
我知道这是 DNS 问题错误。但偶尔会发生错误。如果我一次又一次地尝试运行代码,则可能不会显示此错误。
S3 位于美国东部地区,我从亚洲访问。但据我所知,Amazon S3 区域并没有参与其中。
我的部分代码如下:
仅供参考:我承诺了 S3 SDK
const s3 = new AWS.S3({useAccelerateEndpoint: true});
const bucket_name = s3Storage.bucketName;
s3getImageV2: async …Run Code Online (Sandbox Code Playgroud) 我有一个带有事务的 api,它使用 DynamoDB 作为数据库。我会遇到两种例外情况。一种是由于不满足条件时出现ConditionalCheckFailed异常。错误对象如下所示:
{
"message": "Transaction cancelled, please refer cancellation reasons for specific reasons [None, ConditionalCheckFailed]",
"code": "TransactionCanceledException",
"time": "2020-01-22T05:46:32.756Z",
"requestId": "UG14A08TDB6Q5CADF0NH9JQAB3VV4KQNSO5AEMVJF66Q9ASUAAJG",
"statusCode": 400,
"retryable": false,
"retryDelay": 32.837614849025734
}
Run Code Online (Sandbox Code Playgroud)
另一种情况是,当我对同一个 api 进行负载测试时,我将收到TransactionConflict异常。
{
"message": "Transaction cancelled, please refer cancellation reasons for specific reasons [None, TransactionConflict]",
"code": "TransactionCanceledException",
"time": "2020-01-22T05:54:40.940Z",
"requestId": "87MHRV37F3G3EUUF629AKICARBVV4KQNSO5AEMVJF66Q9ASUAAJG",
"statusCode": 400,
"retryable": false,
"retryDelay": 31.786748424710908
}
Run Code Online (Sandbox Code Playgroud)
由于 TransactionConflict异常,我想在错误时重试事务。但我不确定如何使用此错误信息有条件地重试事务。由于消息部分是唯一告诉我错误确切原因的关键,而不是错误代码本身。
我不认为比较消息是有条件处理错误的好方法。
我编写了这个函数来将文本复制到剪贴板。它复制内容,但它向复制的字符串添加换行符。
function copyToClipboard(text) {
// console.log("text",text);
const textarea = document.createElement('textarea');
textarea.textContent = text;
document.body.appendChild(textarea);
var selection = document.getSelection();
var range = document.createRange();
range.selectNode(textarea);
selection.removeAllRanges();
selection.addRange(range);
const success = document.execCommand('copy');
selection.removeAllRanges();
document.body.removeChild(textarea);
return success;
console.log("now paste in the text area");
}
$('button').click(function () {
copyToClipboard($('#ip').val());
})Run Code Online (Sandbox Code Playgroud)
textarea{
width:100%;
height: 200px;
border: 1px solid grey;
}
input{
min-width: 200px;
}Run Code Online (Sandbox Code Playgroud)
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input id='ip' placeholder="insert some text and press copy"><button>Copy</button>
<textarea placeholder='perform paste in this textarea and you will see line feeds'> …Run Code Online (Sandbox Code Playgroud)我的 Node.js 缓存静态文件的代码如下:
app.use(express.static(path.join(__dirname, "public"),
{ maxAge: (process.env.NODE_ENV === "local") ? 0 : 31557600000 }));
Run Code Online (Sandbox Code Playgroud)
公共文件夹包含我的服务器的所有静态文件。
调用静态文件的html代码(我使用EJS)是:
<script src="/assets/js/slick.min.js"></script>
<script src="/assets/js/main.js"></script>
<!--for form validation -->
<script src="/assets/js/parsley.min.js"></script>
<script src="/assets/js/moment.min.js"></script>
<script src="/assets/js/wheelzoom.js"></script>
<script src="/assets/js/alertify.js"></script>
<script src="/assets/js/alertify.min.js"></script>
<script type="text/javascript" src="/assets/js/validator.min.js"></script>
<script src="/assets/js/owl.carousel.min.js"></script>
<script src="/assets/js/jquery.bootstrap.wizard.min.js"></script>
Run Code Online (Sandbox Code Playgroud)
但是当我访问该页面并检查 Chrome 上的网络选项卡时,我发现由于添加到静态文件 get 调用中的查询参数,浏览器不会从缓存加载文件,而是请求服务器。
为什么 a__SbCache被添加到这些静态文件中?由于此问题,静态文件缓存无法正常工作。