所以我在之前的提交中错误地提交了我的secrets.yml(yikes !!)并且我想清理我的git提交历史.似乎禁食最简单的方法是使用BFG.我已经下载了jar文件并安装了Java是必需的,并且我创建了一个我的repo的镜像 - 但是当我按照文档运行命令时:
java -jar bfg.jar --delete-files secrets.yml my-repo.git
我收到了错误 Unable to access jarfile bfg.jar
文档非常漂亮,但没有说明我应该做些什么来安装它或让它运行,或链接到我的镜像仓库,我很困惑.我看了一个youtube教程,说我应该使用像这样的命令创建一个符号链接;
ln -s ~/bfg-1.11.6.jar /usr/local/bin/bfg
运行bfg,除了我不确定该命令的第二部分是指(/usr/local/bin/bfg)或它应该指向我的情况,因为这对我来说不起作用.我将jar文件保存在用户根目录中.我需要搬家吗?如何在镜像仓库上运行BFG,运行时我是否应该在镜像应用程序目录中?或者从应用程序外部运行它?
我正在尝试从用户注册中捕获http响应状态。
我的代码如下所示:
it.only('returns a 400 response if email is taken', async () => {
await page.goto(`${process.env.DOMAIN}/sign-up`)
await page.waitFor('input[id="Full Name"]')
await page.type('input[id="Full Name"]', 'Luke Skywalker')
await page.type('input[id="Email"]', 'LukeSkywalker@voyage.com')
await page.type('input[id="Password"]', 'LukeSkywalker123', {delay: 100})
await page.click('input[type="submit"]', {delay: 1000})
const response = await page.on('response', response => response)
console.log('request status', response.status)
// expect(response).toEqual(400)
})
Run Code Online (Sandbox Code Playgroud)
该文档提供了拦截请求并对其进行处理的示例:
await page.setRequestInterception(true);
page.on('request', request => {
request.respond({
status: 404,
contentType: 'text/plain',
body: 'Not Found!'
});
});
Run Code Online (Sandbox Code Playgroud)
而且我尝试了类似的模式,但无济于事,还有许多其他模式。我所做的一切都会返回page,这是一个我看不到状态的巨大物体。任何帮助深表感谢。
工作原理:
感谢@tomahaug指导我正确的方向。我的第一个问题是放置,在提出请求之前就需要设置侦听器,而在请求之后就已经有了它。说得通。我最大的问题是将侦听器分配给变量,以便可以将期望作为最后一行。将其分配给变量会导致page返回。我需要做的就是在监听器中运行测试。在done()为我使用throws and error时,我关闭了我的测试,如下所示,这是我的代码的工作版本:
it.only('returns a …Run Code Online (Sandbox Code Playgroud) 我正在尝试以编程方式设置阶段作为我的 AWS API Gateway 部署的一部分。我正在使用 SAM CLI。cloudformation 文档给出了定义:
DeploymentId 阶段指向的部署的 ID。
要求:是
类型:字符串
更新要求:无中断
和代码示例:
Resources:
Prod:
Type: AWS::ApiGateway::Stage
Properties:
StageName: Prod
Description: Prod Stage
RestApiId: !Ref MyRestApi
DeploymentId: !Ref TestDeployment ## <===== this
DocumentationVersion: !Ref MyDocumentationVersion
ClientCertificateId: !Ref ClientCertificate
Variables:
Stack: Prod
MethodSettings:
- ResourcePath: /
HttpMethod: GET
MetricsEnabled: 'true'
DataTraceEnabled: 'true'
- ResourcePath: /stack
HttpMethod: POST
MetricsEnabled: 'true'
DataTraceEnabled: 'true'
ThrottlingBurstLimit: '999'
- ResourcePath: /stack
HttpMethod: GET
MetricsEnabled: 'true'
DataTraceEnabled: 'true'
ThrottlingBurstLimit: '555'
Run Code Online (Sandbox Code Playgroud)
..但没有关于价值TestDeployment指向什么的背景。 …
我将路由 53 添加到我的 DBCluster 并不断遇到错误: Attribute: ReadEndpoint.Address was not found for resource: <DBCluster-name>
整个堆栈是通过 cloudformation 创建的。
另外,应该注意的是,这适用于 Serverless Aurora,以防万一?
这是我的代码:
AWSTemplateFormatVersion: 2010-09-09
Description: RDS Aurora serverless template
Parameters:
CustomFunctionArn:
Default: arn:aws:lambda:us-west-2:123456789:function:vault-secrets-read-lambda-prod
Description: The ARN of the lambda function to retrieve password from Vault
Type: String
DBName:
AllowedPattern: '[a-zA-Z][a-zA-Z0-9]*'
Description: Name of the database
Type: String
DBMasterUsername:
AllowedPattern: '[a-zA-Z][a-zA-Z0-9]*'
Description: The master user name for the DB instance
Type: String
DBScalingAutoPauseEnabled:
AllowedValues:
- 'true'
- 'false'
Default: 'true'
Description: Pause all …Run Code Online (Sandbox Code Playgroud) amazon-web-services amazon-rds aws-cloudformation amazon-route53
当我浏览一些Ruby Doc时,我遇到了百分比字符串,其中两个我有些困惑。具体来说就是%()
string = %(I am a string)
#=> "I am a string"
Run Code Online (Sandbox Code Playgroud)
和%q()
string = %q(I am a string)
#=> "I am a string"
Run Code Online (Sandbox Code Playgroud)
当我和他们一起演奏时,它们似乎都输出了与我刚刚写的相同的字符串
string = "I am a string"
#=> "I am a string"
Run Code Online (Sandbox Code Playgroud)
为什么以及在哪种情况下,宁愿使用它们而不是仅仅创建字符串文字,因为它们似乎并没有通过键入或简化而节省很多?
我想用"#"替换除了最后4个字符之外的所有字符...就像你在信用卡对帐单上看到的那样.我已经完成了这个使用Array#each方法迭代索引[0 ..- 4]然后另一个for [-4 ..- 1]并将两者的结果铲入一个新字符串.我想也许这可以用正则表达式做得更好?但我是regex的新手,谷歌没有提出任何我可以用来替换整个范围而不会丢失字符串的长度.我试过了
str.gsub(str[0..-5],'#')
Run Code Online (Sandbox Code Playgroud)
(以及其他一些东西)但它用一个字符替换整个范围.如何使用正则表达式完成目标?
我正在使用React和Next.js并尝试在该页面的数据不可用时从页面重定向用户Router.push('/another-page').
为此,我正在检查状态代码getInitalProps并应用条件.它看起来像这样:
const statusCode = action.currentArticle ? 200 : 404
if (isServer) res.statusCode = statusCode
if (statusCode === 404) {
Router.push('/')
}
Run Code Online (Sandbox Code Playgroud)
状态代码正在设置正确,它使它在条件内,此时我遇到这个错误: No router instance found. You should only use "next/router" inside the client side of your app.
实际上,无论我尝试重定向组件的生命周期事件中的哪个位置,我都会收到相同的错误,并且我在网上获得的关于此错误的信息很少.
重定向的模式getInitalProps可以在next.js wiki中看到:HERE
关于为什么会出现此错误或如何修复错误的任何想法都非常感谢;)
我昨天清理了我的提交历史,因为有一些私人信息被意外推送.清理完提交后,我强行推送到我的主分支.在我的电脑和我的回购中,一切都是一样的.但是,当我尝试推送到Heroku时,我收到此错误:
Updates were rejected because the tip of your current branch is behind its remote counterpart. Integrate the remote changes (e.g.'git pull ...') before pushing again.
Run Code Online (Sandbox Code Playgroud)
所以我一直在寻找类似的线程,并尝试过:
$ git pull origin master 和 git pull --rebase origin master
返回:
* branch master -> FETCH_HEAD
Already up-to-date.
Run Code Online (Sandbox Code Playgroud)
我也尝试过git fetch返回相同的响应.它说一切都是最新的,为什么我不能推送到heroku?这与git filter-branch我昨天跑的有什么关系,我该如何解决?
在控制台中,我可以看到它releaseLink具有正在抓取的正确值(链接).但是当我尝试为它创建一个click事件时,在下一行,我在控制台中收到此错误:
Uncaught TypeError: Cannot read property 'on' of undefined
这是jQuery:
var releaseLink = $( "#release-link")[0];
var previousLink = $( "#prev-link" )[0];
releaseLink.on('click', function(){
console.log('hello. you clicked the release notes link');
});
Run Code Online (Sandbox Code Playgroud)
这是与之关联的html.
<div id="release-notes">
<h3><a id="release-link" href="#">Release Notes</a></h3>
<div id="release-notes"></div>
</div>
<div id="previous-versions">
<h3><a id="prev-link" href="#">Previous Versions</a></h3>
<div id="version-notes"></div>
</div>
Run Code Online (Sandbox Code Playgroud) git ×2
ruby ×2
amazon-rds ×1
aws-sam ×1
aws-sam-cli ×1
github ×1
heroku ×1
jar ×1
javascript ×1
jquery ×1
nextjs ×1
puppeteer ×1
reactjs ×1
regex ×1
string ×1