我一直在跟随John Papa和Ward Bell对PluralSight进行角度测试.
当我运行我的规格时,我目前收到以下错误.
AssertionError: expected { Object ($$state) } to have a property 'length'
at Assertion.assertLength (bower_components/chai/chai.js:1331:37)
at Assertion.assert (bower_components/chai/chai.js:4121:49)
at Context.<anonymous> (scripts/home/homeController.Specs.js:48:49)
Run Code Online (Sandbox Code Playgroud)
请注意,我只包含了我认为相关的代码,因此我没有用无关的信息重载这个问题.如果您需要查看更多代码,这不是问题.
我的代码如下:
homeController.js:
window.app.controller('homeController', ['$scope', 'sidebarService',
function ($scope, sidebarService) {
$scope.title = 'Slapdash';
$scope.sidebar = {
"items": sidebarService.getSidebarItems()
};
}])
Run Code Online (Sandbox Code Playgroud)
sidebarService.js:
(function () {
window.app
.service('sidebarService',['$http', function ($http) {
this.getSidebarItems = function () {
$http.get("http://wwww.something.com/getSidebarItems")
.then(function (response) {
return response.data;
});
};
}]);
}());
Run Code Online (Sandbox Code Playgroud)
homeController.Specs.js:
beforeEach:
beforeEach(function () {
bard.appModule('slapdash');
bard.inject(this, '$controller', '$q', '$rootScope')
var mockSidebarService …Run Code Online (Sandbox Code Playgroud) 我一直在使用SpecFlow,没有使用"但是"逻辑.
考虑以下情况:
Scenario: Kiran logs into the system but doesn't click remember me
Given I have a username of 'Kiran'
And a password of 'password'
When I chose login
But I don't chose remember me
Then I should be logged in
And Taken to the home screen
But My username should not be remembered
Run Code Online (Sandbox Code Playgroud)
难道"but"步骤不能与"和"互换吗?
使用"但是"有什么好处吗?
我是否正确地认为这纯粹是为了可读性目的?
我期待听到你对此的看法.
非常感谢,Kiran
安装Theano anaconda时会自动尝试安装pygpu,尽管这是一个可选的依赖项.我已从Windows用户目录中删除了.theanorc文件.
此外,在运行我的应用程序时,Theano尝试从GPU加载.它就像是以某种方式记得的?
conda install theano
Fetching package metadata .............
Solving package specifications: .
Package plan for installation in environment
C:\Users\zebco\Miniconda3\envs\py35:
The following NEW packages will be INSTALLED:
libgpuarray: 0.6.9-vc14_0
pygpu: 0.6.9-py36_0
theano: 0.9.0-py36_0
Proceed ([y]/n)?
Run Code Online (Sandbox Code Playgroud)
如你所见,我只指定安装theano但conda想要安装所有内容,包括可选的依赖项.
我能够获取包含 Python 查询的电子邮件列表,但是当我从线程内运行代码时,出现错误:
ssl.SSLError: [SSL: WRONG_VERSION_NUMBER]
Run Code Online (Sandbox Code Playgroud)
这是我调用线程的方式:
Thread(target=get_messages_for_label, args=({'recruitment'})).start()
Run Code Online (Sandbox Code Playgroud)
错误发生在这一行:
response = service.users().labels().list(userId=user_id).execute()
Run Code Online (Sandbox Code Playgroud)
但是,当我在没有线程的情况下运行它(作为简单的方法调用)时,它工作得很好。
很难共享中间的代码,因为在线程启动和错误发生之间有相当多的方法调用。
任何帮助,将不胜感激。
我正在尝试设置构建管道以在特定代理池上运行。目前它坚持致力于“Azure Pipelines”池:
但是我无法更改构建管道的代理池(至少我不确定如何更改)。
我的 YAML 如下所示:
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
variables:
buildConfiguration: 'Release'
steps:
- task: NuGetCommand@2
inputs:
command: 'restore'
restoreSolution: '**/*.sln'
feedsToUse: 'select'
- script: dotnet build --configuration $(buildConfiguration)
displayName: 'dotnet build $(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: 'Pack the package'
inputs:
command: 'pack'
configuration: 'Release'
packagesToPack: 'NugetComponents/**/*.csproj'
nobuild: true
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
Run Code Online (Sandbox Code Playgroud)
我不确定这里是否需要更改任何内容。我在界面中找不到任何用于配置管道应使用哪个代理布尔值的内容?
我希望使用 .NET 核心捕获屏幕截图。我知道使用 .NET 框架这是微不足道的,但这是否可以使用 .NET 核心?我已经搜索过,但在任何地方都找不到任何答案。
我正在尝试使用 Angular 材质拖放一个自由节点。它不是列表的一部分,但我想知道该项目何时被删除。我不确定如何绑定到此事件。
我只是想知道节点何时被删除。
到目前为止,这是我的代码:
<svg id="svgCanvas" >
<g *ngFor="let link of linkPaths">
<path [attr.d]="link"></path>
</g>
<g *ngFor="let node of nodes" id="nodesGroup">
<circle class="node" [attr.cx]="node.x" [attr.cy]="node.y + 45" [attr.r]="settings.nodes.radius"
(click)="nodeClick($event)" (dragEnd)="drop($event, node)" [attr.data-selected]="node.data.selected" cdkDrag cdkDragBoundary="#svgCanvas" ></circle>
</g>
</svg>
Run Code Online (Sandbox Code Playgroud)
我希望触发 DragEnd 事件并在组件代码中调用我的放置函数。
private drop(event) {
console.log('drag end')
}
Run Code Online (Sandbox Code Playgroud)
点击事件似乎有效,但放置不会触发。
我可以看到列表支持拖放功能,但我没有对列表使用拖放功能。这些是自由移动的节点。
javascript drag-and-drop angular-material angular angular-cdk
我似乎无法测试绑定到 Angluar2 模型的输入框。我对此有点陌生,所以请耐心等待。
我有一个非常基本的 Angular2 组件,它包含一个绑定到模型的输入框。
<form>
<input type="text" [(ngModel)]="searchTerm" name="termsearchTerm" (keyup)="search()" value=""/>
</form>
Run Code Online (Sandbox Code Playgroud)
这是后面的代码:
import { Component, Input, Output, EventEmitter } from '@angular/core';
@Component({
moduleId: module.id,
selector: 'sc-search',
templateUrl: 'search.component.html'
})
export class SearchComponent {
@Input() data: any;
@Output() onSearchTermChanged = new EventEmitter<string>();
private searchTerm: string;
search() {
this.onSearchTermChanged.emit(this.searchTerm);
}
}
Run Code Online (Sandbox Code Playgroud)
运行以下测试时,不断得到 Expected undefined 等于 'John'。我期待测试通过。
searchableHierarchyComponentFixture.detectChanges();
let termInputDbg = searchableHierarchyComponentFixture.debugElement.query(By.css('input[name="termsearchTerm"]'));
let input = searchableHierarchyComponentFixture.nativeElement.querySelector('input');
input.value = 'John';
let evt = document.createEvent('Event');
evt.initEvent('keyup', true, false);
termInputDbg.triggerEventHandler('keyup', null);
input.dispatchEvent(evt);
tick(50); …Run Code Online (Sandbox Code Playgroud) 我正在使用 Gmail API 从我的收件箱中检索电子邮件:
query = 'to:me after:{}'.format(weekStartDate)
unreadEmailsQuery = service.users().messages().list(userId='me', q=query).execute()
# For Each Email
for message in unreadEmailsQuery['messages']:
result = service.users().messages().get(id=message['id'],userId='me').execute()
email_content = ''
if 'data' in result['payload']['body'].keys():
email_content+= result['payload']['body']['data']
else:
for part in result['payload']['parts']:
email_content = part['body']['data'] + email_content
test = bytes(str(email_content),encoding='utf-8')
print(base64.decodebytes(test))
Run Code Online (Sandbox Code Playgroud)
正确打印出简单的纯文本消息:
b'Got another one with me
但是会像这样打印出 html 消息:
b'<body\x03B\x83B\x83B\x83B\x88\x08\x0f\x1bY]\x18H\x1a\x1d\x1d\x1c\x0bY\\]Z]\x8fH\x90\xdb\
Run Code Online (Sandbox Code Playgroud)
我可以看到,直到第一个 > 从那时起字符串被错误打印出来之前都可以,我不知道为什么。
我试图从我的电子邮件中提取单词,以便我可以训练分类器,但我被卡住了。
任何帮助将不胜感激。
我一直在看C#的通用函数委托(Func)功能.
例:
// Instantiate delegate to reference UppercaseString method
Func<string, string> convertMethod = UppercaseString;
string name = "Dakota";
// Use delegate instance to call UppercaseString method
Console.WriteLine(convertMethod(name));
Run Code Online (Sandbox Code Playgroud)
我正在努力想到一个真实的生活场景,它们可能在我自己的应用程序中很有用.所以我想我会把问题提到那里.\
我非常感谢你的想法.
我对以下代码行感到困惑:
input_img = Input(shape=(53,))
Run Code Online (Sandbox Code Playgroud)
我有一批 52 张图像,但是一个元组怎么在逗号之后没有任何内容?这是什么意思?
我有这个用于webkitRequestFullScreen的JSFiddle示例.
我在Mac OSX上使用Chrome 2,该示例似乎对我不起作用.最初我写了我自己的例子,但下面链接中的那个不是我写的.它仍然似乎没有用.
var test = document.querySelector('.test');
test.addEventListener('click', function () {
if(test.requestFullScreen) {
test.requestFullScreen();
} else if(test.mozRequestFullScreen) {
test.mozRequestFullScreen();
} else if(test.webkitRequestFullScreen) {
test.webkitRequestFullScreen();
}
}, false);
Run Code Online (Sandbox Code Playgroud)
但以下示例确实有效!只有当我尝试在Plunker或JSFiddle中重现它时,它似乎不起作用:
http://www.jwplayer.com/blog/using-the-browsers-new-html5-fullscreen-capabilities/
继承人我的掠夺者例子:
<!-- just to keep things in one place I put the JS here. -->
<script type="text/javascript">
function goFullscreen(id) {
// Get the element that we want to take into fullscreen mode
var element = document.getElementById(id);
// These function will not exist in the browsers that don't support fullscreen …Run Code Online (Sandbox Code Playgroud) 我一整天都在为 JQuery 验证问题而苦苦挣扎。它仅验证第一个字段。
我已经成功地在这里重现它:
$(document).ready(function() {
$('#go').click(function() {
console.log('go clicked');
if ($('#detailsForm').valid()) {
alert('if you see this then the form is valid.');
}
});
});Run Code Online (Sandbox Code Playgroud)
<!DOCTYPE html>
<html>
<head>
<script data-require="jquery@1.10.0" data-semver="1.10.0" src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
<script data-require="jquery-validate@1.10.0" data-semver="1.10.0" src="//cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.15.0/jquery.validate.js"></script>
<script data-require="jquery-validate@1.10.0" data-semver="1.10.0" src="//cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.15.0/additional-methods.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>
<body>
<h1>This doesn't work :(</h1>
<form id="detailsForm">
<div class="row guttered-bottom">
<div class="col-md-6 col-xs-12">
<div class="row">
<div class="col-md-12 col-xs-12">
<br />
First Name<div style="color:#E320C9">*</div>
<div class="input-container">
<input id="ReserveFirstName" type="text" class="input-large input-wide" placeholder="Enter your …Run Code Online (Sandbox Code Playgroud)javascript ×4
python-3.x ×3
angular ×2
c# ×2
gmail-api ×2
python ×2
.net-core ×1
anaconda ×1
angular-cdk ×1
angularjs ×1
azure-devops ×1
bardjs ×1
base64 ×1
cucumber ×1
func ×1
generics ×1
gherkin ×1
jquery ×1
keras ×1
keras-layer ×1
specflow ×1
ssl ×1
syntax ×1
tensorflow ×1
theano ×1
theano-cuda ×1