外文分享

Cannot set initial form values into FormArray

半城伤御伤魂 提交于 2021-02-19 23:50:31
问题 I have a reactive form that on cancel has to set again the initial form values into the formGroup. import { Map } from "immutable"; @Input() data: any; public ngOnInit() { if (this.data && this.data.controls) { this.group = this.fb.group({ isActive: [this.data.isActive], items: this.fb.array(this.buildFormArray(this.data.controlPerformers)), }); // Deep copy of the formGroup with ImmutableJs this.originalFormData = Map(this.group).toJS(); } } public buildFormArray(controllers:

Wordpress Posts odd/even Li layout

瘦欲@ 提交于 2021-02-19 23:49:51
问题 I am working on a custom theme and on one of the pages i need to style the posts pages as follows: http://gyazo.com/e1f7cfc03c7ba3981188077afcdf0314 The grey box is an image and the red box is content. I need to use perhaps an odd/even Li/Ul pseudo class/selector but i have no idea how to do it. Could anyone offer me a way to start it up? I was thinking of using the Odd/Even pseudo class on UL to change the divs names however i can't think how to do it or where to start. Thanks! Edit: I am

PHP Upload - Spaces in File Name

给你一囗甜甜゛ 提交于 2021-02-19 23:49:06
问题 When I use my upload script to upload a PHP file, I can't upload a file with spaces in it (I get a 500 error). Is there a way so my code automatically puts an underscore in the file name instead of the space? All help is greatly appreciated. :) 回答1: Simply use str_replace to replace all white spaces with another string: $fileName = str_replace(" ", "_", $fileName); Doc: php.net 回答2: Use this regular expression.suppose your filename look like my pic.jpg (one spaces) or my pic.jpg (three spaces

Excel pivot table: move value fields from row to column

旧街凉风 提交于 2021-02-19 23:48:38
问题 I'm developing an excel addin in c# and have to create a pivot table, which I don't know how to organize the data, how it should be. First of all the datasource: This is, how the final Pivot Table should looks like: But I only get something like this and I have no Idea where I have to how to change my code: Finally my code to arrange the data source columns: /* PIVOT RowFields */ Excel.PivotField nameField = pTable.PivotFields("Name"); nameField.Orientation = Excel.XlPivotFieldOrientation

Excel pivot table: move value fields from row to column

别等时光非礼了梦想. 提交于 2021-02-19 23:47:52
问题 I'm developing an excel addin in c# and have to create a pivot table, which I don't know how to organize the data, how it should be. First of all the datasource: This is, how the final Pivot Table should looks like: But I only get something like this and I have no Idea where I have to how to change my code: Finally my code to arrange the data source columns: /* PIVOT RowFields */ Excel.PivotField nameField = pTable.PivotFields("Name"); nameField.Orientation = Excel.XlPivotFieldOrientation

Guilds Highest Role Command?

南笙酒味 提交于 2021-02-19 23:47:22
问题 I want to get the highest role in the guild with discord.js message.guild.roles.highestRole This doesn't work. Any help would be appreciated. Thanks from now :) 回答1: For discord.js v12 / master use message.guild.roles.highest.name For discord.js v11.4.x / stable use message.guild.roles.sort((b, a) => a.position - b.position || a.id - b.id).first().name, this will sort the roles Collection by their position and then get the highest one, and return the name of it. 来源: https://stackoverflow.com

Newbie questions on Answer Set Programming

放肆的年华 提交于 2021-02-19 23:45:44
问题 I'm totally new to Clingo (and logic programming) and I'm looking for the best way to implement the following basic constraints: Q1. I have a predicate selected(T) where T ranges from 1 to N=5; how can I specify that exist at least one T such that selected(T) ? Q2. I have a binary predicate wrap(E,T) where E, T range from 1 to M, N; how can I specify that for each E exist at least one T such that wrap(E,T) ? Q3. How can I specify that if selected(a) OR selected(b) then selected(c) must be

Excel pivot table: move value fields from row to column

百般思念 提交于 2021-02-19 23:45:19
问题 I'm developing an excel addin in c# and have to create a pivot table, which I don't know how to organize the data, how it should be. First of all the datasource: This is, how the final Pivot Table should looks like: But I only get something like this and I have no Idea where I have to how to change my code: Finally my code to arrange the data source columns: /* PIVOT RowFields */ Excel.PivotField nameField = pTable.PivotFields("Name"); nameField.Orientation = Excel.XlPivotFieldOrientation

How to pythonically select a random index from a 2D list such that the corresponding element matches a value?

旧城冷巷雨未停 提交于 2021-02-19 23:44:40
问题 I have a 2D list of booleans. I want to select a random index from the the list where the value is False . For example, given the following list: [[True, False, False], [True, True, True], [False, True, True]] The valid choices would be: [0, 1] , [0, 2] , and [2, 0] . I could keep a list of valid indices and then use random.choice to select from it, but it seems unpythonic to keep a variable and update it every time the underlying list changes for only this one purpose. Bonus points if your

Restrict fitted regression line (abline) to range of data used in model

﹥>﹥吖頭↗ 提交于 2021-02-19 23:44:20
问题 Is it possible to draw an abline of a fit only in a certain range of x-values? I have a dataset with a linear fit of a subset of that dataset: # The dataset: daten <- data.frame(x = c(0:6), y = c(0.3, 0.1, 0.9, 3.1, 5, 4.9, 6.2)) # make a linear fit for the datapoints 3, 4, 5 daten_fit <- lm(formula = y~x, data = daten, subset = 3:5) When I plot the data and draw a regression line: plot (y ~ x, data = daten) abline(reg = daten_fit) The line is drawn for the full range of x-values in the