我在ascii中有一个很长的文本文件.它经常会有Page: #####
一条线.我希望从"Page:25141"开始,然后在文档末尾的每一行匹配.
我尝试过的一些组合是:
grep -E ^["Page: 25141".*] document.txt
grep "Page: 25141.*" document.txt
grep "Page: 25141\.\*" document.txt
grep -E "Page: 25141"[.*] document.txt
grep -E "Page: 25141"{.*} document.txt
grep -E {"Page: 25141".*} document.txt
Run Code Online (Sandbox Code Playgroud)
无法让这个工作.
我正在为mocha/jasmine的服务编写单元测试.我的原始服务取决于NodeSrv
服务.但是,当我在单元测试中注入它时,它看起来并不像是真正注入了依赖NodeSrv
服务.我明白了TypeError: Cannot read property 'spyOn' of null
describe("Label Exists Check Service", function() {
var LabelExistsCheck;
var NodeSvc;
var VipSvc;
beforeEach(function() {
return module("main");
});
beforeEach(inject(function(_LabelExistsCheck_, _NodeSvc_, _VipSvc_) {
LabelExistsCheck = _LabelExistsCheck_;
NodeSvc = _NodeSvc_;
VipSvc = _VipSvc_;
}));
describe("It should check if node label exists", function() {
spyOn(NodeSvc, "getNodes").and.returnValue(["testing1", "foo"]);
newLabelName = "testing1";
oldLabelName = "nada";
devices = NodeSvc.getNodes();
deviceExist = devices.some(function(element) {
if (newLabelName == element) {
return true
}});
//spyOn(form, "$setValidity");
it("node label …
Run Code Online (Sandbox Code Playgroud) 对于ES6生成器,为什么这篇博文的作者说:
来自:http://davidwalsh.name/es6-generators
"第一个下一个(..)调用,我们不发送任何内容.为什么?因为没有收益表达式来接收我们传入的内容."
不是第一次it.next()
打电话(yield (x + 1))
?
function *foo(x) {
var y = 2 * (yield (x + 1));
var z = yield (y / 3);
return (x + y + z);
}
var it = foo( 5 );
// note: not sending anything into `next()` here
console.log( it.next() ); // { value:6, done:false }
console.log( it.next( 12 ) ); // { value:8, done:false }
console.log( it.next( 13 ) ); // …
Run Code Online (Sandbox Code Playgroud) 我试图在Angular中将Controller作为语法.在这一点上,我在我的routerProvider中有它...不确定它对我遇到的问题是否重要,但在这里它仍然是:
angular.module('ucp.kick', [
'ngRoute'
])
.config ($routeProvider, APP_BASE_URL) ->
$routeProvider
.when APP_BASE_URL + 'kicks',
name: 'Kicks'
templateUrl: 'kick/partials/kick.html'
controller: 'kick as KickController'
Run Code Online (Sandbox Code Playgroud)
这是我的控制器的浓缩版本:
this.$watchCollection('filtered.devices', function(devices) {
return this.filteredDevices = devices;
});
Run Code Online (Sandbox Code Playgroud)
但我得到:
TypeError: Object [object Object] has no method '$watchCollection'
Run Code Online (Sandbox Code Playgroud)
我意识到当使用控制器作为语法时,您不希望注入范围.那么,我该如何访问$watchCollection
功能呢?
我有这个CSS动画,当选择页面时,页面从底部滚动到顶部。
我遇到的问题是页面首先短暂显示在其顶部位置,然后消失以从底部滚动到顶部。如何防止页面在显示动画之前显示?
注意:我想保持短暂的动画延迟500ms
mainPanelContent.classList.add('slide-up-now');
Run Code Online (Sandbox Code Playgroud)
.slide-up-now {
-webkit-animation: slide-up .6s cubic-bezier(0.4, 0, 0.2, 1) 500ms;
-moz-animation: slide-up .6s cubic-bezier(0.4, 0, 0.2, 1) 500ms;
animation: slide-up .6s cubic-bezier(0.4, 0, 0.2, 1) 500ms;
}
@-webkit-keyframes slide-up {
0% { -webkit-transform: translateY(100%); }
100% { -webkit-transform: translateY(0); }
}
Run Code Online (Sandbox Code Playgroud) 我有一DetailView
节课,其中我没有通过pk或slug.因此,我试图覆盖get_object(self)
并手动放置查询过滤器项(在我的情况下是当前登录的用户).但是,我没有成功:
class ViewSpecialUser(LoginRequiredMixin, DetailView):
model = SpecialUser
print(self)
def get_object(self):
object = super(ViewSpecialUser, self).get_object(queryset)
object.queryset = queryset.filter(pk=self.request.user.pk)
return object
def get_context_data(self, **kwargs):
context = super(ViewSpecialUser, self).get_context_data(**kwargs)
return context
Run Code Online (Sandbox Code Playgroud) 我有一个使用 DJango 1.6 的网络应用程序。这是一个简单的 Web 应用程序,它从论坛进行 api 调用并跟踪未答复的线程。我想将这些未应答的线程集合存储在redis临时哈希表中。
我感到困惑的是我是否应该使用 django-redis(它也使用 redis-py)或只是 redis-py。我已经阅读了 django-redis 文档,据我所知,它的目的是使用 redis 来存储 Django 会话和其他后端 Django 缓存。对于我想做的就是保持一定的温度。由 api 调用填充的论坛线程表,正确的工具是 Django-Redis 还是 Redis-py?
dom-change
事件对象E在Polymer.dom(e).localTarget
给我<template is="dom-if"
理所应当。但是我该如何接孩子<div id="uploadedImage1"
呢? firstChild
并且firstElementChild
为空。
<template is="dom-if" if="[[uploadedImage1]]">
<div id="uploadedImage1" class="row-image horizontal layout">
foo
</div>
</template>
Run Code Online (Sandbox Code Playgroud)
我以为也许我需要对localTarget对象执行另一个查询,但没有成功:
this.$['images-container'].addEventListener('dom-change', (e)=> {
var bob = Polymer.dom(e).localTarget;
var sue = Polymer.dom(bob).querySelector('div')
console.log(sue);
});
Run Code Online (Sandbox Code Playgroud)
我也尝试了这些但没有成功:
this.$['images-container'].addEventListener('dom-change', (e)=> {
var bob = Polymer.dom(e).localTarget;
var sue = this.queryEffectiveChildren(bob);
console.log(sue);
});
Run Code Online (Sandbox Code Playgroud)
this.$['images-container'].addEventListener('dom-change', (e)=> {
var bob = Polymer.dom(e).localTarget;
var sue = bob.getEffectiveChildNodes();
console.log(sue);
});
}
Run Code Online (Sandbox Code Playgroud)
从儿童身长文档示例中,甚至Polymer.dom(this).children.length
返回0:
<dom-module id="image-uploader">
<template>
<style include="iron-flex iron-flex-factors iron-flex-alignment">
<div …
Run Code Online (Sandbox Code Playgroud) 在 Angular 9动画中,如何从组件本身触发动画?我假设我会在组件本身中手动执行此操作,因为它会跟踪创建图形时的状态。与使用模板表达式相反,在模板表达式中,父级将通过数据绑定和主机属性来跟踪状态。
<div class="chart-body">
<div *ngFor="let chart of charts | async | daysFilter:7" class="last-seven-days-body">
<line-chart
[curve-data]="chart"
graph-size="med"></line-chart>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
@Component({
selector: 'line-chart',
templateUrl: './line-chart.component.html',
styleUrls: ['./line-chart.component.css'],
animations: [
trigger('fadeIn', [
transition('void => *', [
style({ opacity: 0 }),
animate(2000, style({opacity: 1}))
])
])
],
})
export class LineChartComponent {
@Input('curve-data') curveData: Array<object>;
@Input('graph-size') graphSize: String;
constructor(
private lineChartService: LineChartService,
private elRef: ElementRef,
private fadeInStart: Boolean,
) { }
ngAfterViewInit() {
this.lineChartService.makeGraph(
this.curveData,
this.elRef.nativeElement,
this.graphSize,
);
this.fadeInStart = …
Run Code Online (Sandbox Code Playgroud) 我从以下位置收到此错误Expected at least 1 arguments, but got 0 or more
:
if (initialValues.length > 0) {
return Object.assign(...initialValues);
}
Run Code Online (Sandbox Code Playgroud)
我猜它是在抱怨initialValues
可能是空的。但是,if 条件保证它不会为空。我该怎么做才能让打字稿意识到这一点?
angularjs ×2
django ×2
python ×2
angular ×1
bash ×1
css ×1
css3 ×1
ecmascript-6 ×1
grep ×1
jasmine ×1
javascript ×1
polymer ×1
polymer-1.0 ×1
redis ×1
regex ×1
typescript ×1
unit-testing ×1