Pandas replace value in multiindex row

Question: So, I have a MultiIndex DataFrame and I cannot figure out row to modify a row index value.
In this example, I would like to set c = 1 where the "a" index is 4:
import pandas as pd
import numpy as np

df = pd.DataFrame({('colA', 'x1'): {(1, np.nan, 0): np.nan, (4, np.nan, 0): np.nan},
('colA', 'x2'): {(1, np.nan, 0): np.nan, (4, np.nan, 0): np.nan},
('colA', 'x3'): {(1, np.nan, 0): np.nan, (4, np.nan, 0): np.nan},
('colA', 'x4'): {(1, np.nan, 0): np.nan, (4, np.nan, 0): np.nan}})

df.index.set_names(['a', 'b', 'c'], inplace=True)

print(df)

            colA
              x1    x2  x3  x4
a   b   c
1   NaN 0   NaN NaN NaN NaN
4   NaN 0   NaN NaN NaN NaN

Desired output:
            colA
              x1    x2  x3  x4
a   b   c
1   NaN 0   NaN NaN NaN NaN
4   NaN 1   NaN NaN NaN NaN

Any help is appreciated.
Comment: This will give `IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices`
Comment: hmmm sorry its a bit harder than i expected... I dont have time to solve it right now ... but here is how you can get the mask to use `mask = df.index.get_level_values('a') == 4`
Comment: `pandas[df.index['a'] == 4] = 1` ? maybe/
Comment: Not sure what you meant by "pandas"
Comment: oops pandas should be `df[df.index['a'] == 4] = 1`\
Comment: ahh your right. ... give me a minute
Comment: it's ok, thank you for the direction
Answer: Assuming we start with df.
x = df.reset_index()
x.loc[x[x.a == 4].index, 'c'] = 1
x = x.set_index(['a', 'b', 'c'])
print(x)

        colA
          x1  x2  x3  x4
a b   c
1 NaN 0  NaN NaN NaN NaN
4 NaN 1  NaN NaN NaN NaN

Comment: I'm guessing there's no way to do it directly, without reseting the index, right? BC I'm working with a big dataframe in reality
Comment: resetting the index doesn't change the order of the data and the size of the data doesn't really matter.
Comment: big is pretty fluid.. how do you define big?
Answer: Solution
Separate the index, process it and put it back together with the data.
Logic

Separate index and process it as a dataframe
Prepare a MultiIndex
Either of the following two options:

combine data and MultiIndex together Method-1
update the index of the original dataframe Method-2

Code
# separate the index and process it
names = ['a', 'b', 'c'] # same as df.index.names
#dfd = pd.DataFrame(df.to_records())
dfd = df.index.to_frame().reset_index(drop=True)
dfd.loc[dfd['a']==4, ['c']] = 1

# prepare index for original dataframe: df
index = pd.MultiIndex.from_tuples([tuple(x) for x in dfd.loc[:, names].values], names=names)

## Method-1
# create new datframe with updated index
dfn = pd.DataFrame(df.values, index=index, columns=df.columns)
# dfn --> new dataframe

## Method-2
# reset the index of original dataframe df
df.set_index(index)

Output:
            colA
              x1  x2  x3  x4
a   b   c
1.0 NaN 0.0  NaN NaN NaN NaN
4.0 NaN 1.0  NaN NaN NaN NaN

Dummy Data
import pandas as pd
import numpy as np

df = pd.DataFrame({('colA', 'x1'): {(1, np.nan, 0): np.nan, (4, np.nan, 0): np.nan},
('colA', 'x2'): {(1, np.nan, 0): np.nan, (4, np.nan, 0): np.nan},
('colA', 'x3'): {(1, np.nan, 0): np.nan, (4, np.nan, 0): np.nan},
('colA', 'x4'): {(1, np.nan, 0): np.nan, (4, np.nan, 0): np.nan}})

df.index.set_names(['a', 'b', 'c'], inplace=True)

Comment: @peter_b Here's another option.
Comment: I can see this certainly works but it really feels like an overkill!

Pandas replace value in multiindex row


Effect of zeroth and first derivative on smoothing splines

Question: Let $\hat{f}=\arg min_f \left( \sum_{i=1}^n (Y_i -f(X_i))^2 + \lambda \int [f^{(m)}(x)]^2 dx\right)$
Suppose $\lambda = \infty$ and consider the cases when m = 0, m = 1. I am trying to understand what the subsequent function will look in both cases.
When m = 1, the penalizing term forces $\int [f'(x)]^2 dx$ to be small, so the slope of f(x) tends to 0, and thus f(x) will look like a step function. Is this line of reasoning correct?
When m = 0, the penalizing term forces $\int [f(x)]^2 dx$ to be small, thus the resulting function will simply be f(x) = 0?
Answer: As $\lambda \rightarrow \infty$, our smoothing penalty dominates the cost function in evaluating $f$'s associated costs. As a consequence $\hat{f}$ approximates the least squares solution we would get for $y \approx \beta_0 + \beta_1 x$, i.e. we get a straight line which has no "actual" second derivatives. Do note though that $f$ is defined to be a cubic spline based on the form presented here; so by definition, it is (at least) twice differentiable.
Given the above:

for $m=1$ we won't have a step function because step functions are not valid smoothing functions. If any sharp inflexion points existed they would have infinite first derivatives as $\lambda$ got larger. In this scenario, as $\lambda$ gets larger, we have to predict the mean value $\bar{y}$ for all the values of $x$ because this prediction will allow us to get the smallest first derivatives possible (i.e. no slopes at any point) while minimising our RSS from the first term.
for $m=0$ you are correct, we will indeed have $\hat{f}(x)\rightarrow0$, as even the "slightest fit" to the data would move us away from the minimum. In effect, we ignore the data. :D


How to use gsem when the independent variables are binary?

Question: According to this website, "Binary—probit, logit, complementary log-log". But does the "binary" here mean independent variable or the latent variable (that is determined by the independent variable)?
I am esp. unsure since probit and logit are used to model binary dependent variables. So I find it strange that when input variables are binary, Bernoulli logit is used, as done here in the first figure. Also I wonder how can we know that "MathApt" has a Bernoulli distribution? (If I understand the documentation correctly.)
Answer: Bernoulli/binomial indicates that the outcome is binary, but you could use different link functions, like probit or logit. The latent/unobserbed variables (math aptitude and school quality) are continuous.
The probit or logit choice rarely matters in practice in that the marginal effects will be similar. The coefficients, of course, will be quite different.
Comment: If you wrote family(binomial), then yes. The general syntax is family(binomial k) or family(binomial num_trials_var). To get Bernoulli, you can set k to 1 or have a variable that is all ones. For code readability reasons, however, family(bernoulli) seems best to me.
Comment: Just to make sure: by "outcome", do you mean the measured variables? (i.e. whether q1 was answered correctly in the example I mentioned in the question?)

Also when should I use Bernoulli and when should I use binomial? I do not think it is possible to have binomial distribution for binary, which only has 0 and 1.
Comment: Outcome is pass/fail as measured on the test. Binomial without specifying the number of trials defaults to Bernoulli, which is binomial with one trial.
Comment: OK so if I specified the family as binomial for binary outcomes, the program would just interpret it as bernoulli?


Solving a system of nonlinear (quadratic) equations

Question: Consider the following system of equations:
$$\begin{align}
(x + 1)^2 [(p - l)^2 + (q - m)^2] &= (a - l)^2 + (b - m)^2 \\
(x + 1)^2 [(p - a)^2 + (q - b)^2] &= x^2[(a - l)^2 + (b - m)^2]\end{align}$$
Find the value of $p$ and $q$ in terms of $a, b, x, l$ and $m$, provided that $x > 0$.
Comment: Try to divide second equation to the first one. I checked in Mathematica, this system has single solution and it's short and nice.
Comment: Kaster gave you the very good hint ! Show your efforts, please. If you have problem, tell us where you are stuck and a lot of people will be helping you.
Comment: I sware that, if you do what Kaster gave you, it is pretty simple (even simpler that what is given in the good answers you received). Come on ! Cheers :)
Comment: what is the answer, then? please tell me, I don't have mathematica yet.
Comment: Actually, I'm not showing my efforts because they are very lengthy
Comment: @ClaudeLeibovici, I can't solve this using by paper and pen, even by Kaster's method, How do you sware that it's pretty simple. Please tell me post your answer I assure you I'll upvote your question and will choose your answer correct if it's simple. Please tell me your attempt. I tried for half an hour, and doesn't get success, please answer.
Comment: I did by hand what Kaster suggested and I am almost blind ! It took me ten minutes or even less.
Comment: can you please post your attempt? because I'm unable to solve honestly.
Comment: Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/16100/discussion-between-user91374-and-claude-leibovici).
Comment: I have to go now. But, in any manner, I would prefer that Kaster be involved. All the merit is his !
Comment: but please tell me your method.
Comment: @ClaudeLeibovici, Please post your answer, I'm feeling very uncomfortable. I've divided 2nd equation from 1st equation. Then, the RHS became $x^2$ then I've simplified LHS, but how to proceed then??
Comment: @user91374 sorry for delay. I haven't solved this problem. I just suggest that dividing one to another might make it a bit easier. Based on Claude's answer, it is somewhat solvable. I was too lazy to solve by hands and so just fed it to the Mathematica, which provided the following answer:
$$
p = \frac {a + lx}{1 + x} \\
q = \frac {b + mx}{1+x}
$$
Comment: @Kaster thank you, really. Actually, I don't have mathematica. But for the sake of information, I am asking. Does Mathematica provide step by step solution?
Answer: Hint:
Divide both equations by $(x+1)^2$ and set
$$\alpha^2 =  \frac{(a - l)^2 + (b - m)^2}{(x+1)^2} \quad \beta^2 = \frac{x^2[(a - l)^2 + (b - m)^2]}{(x+1)^2},$$
then the system of equations to solve becomes
$$\left\{\begin{array}{rcl}
(p - l)^2 + (q - m)^2 &=& \alpha^2 \\
(p - a)^2 + (q - b)^2 &=& \beta^2
\end{array}\right.$$
I.e. you have to find the intersection of two circles in the plane. One of these circle has center $c_1 = (l,m)$ and radius $r_1 = \alpha$ while the other has center $c_2 = (a,b)$ and radius $r_2=\beta$.
Answer: Here's my semi-geometrical solution. Let's scale $p$ and $q$ to $1+x$. So
$$
P = p(1+x) \\
Q = q(1+x)
$$
so equation become
\begin{align}
\left [P-(x+1)l \right ]^2 + \left [Q-(x+1)m \right ]^2 &= (a-l)^2 + (b-m)^2 \\
\left [P-(x+1)a \right ]^2 + \left [Q-(x+1)b \right ]^2 &= x^2 \left [ (a-l)^2 + (b-m)^2 \right ]
\end{align}
So, geometrical part now. The problem above is to find intersection points of two circles. Obviously circles might intersect at zero points (don't intersect), one point (tangent to each other), two points (real intersection) and infinite number of points (coinciding circles). Circle number one has a center at $[(x+1)l, (x+1)m]$ and a radius of $r = \sqrt{(a-l)^2 + (b-m)^2}$. Circle number two has a center of $[(x+1)a, (x+1)b]$ and a radius of $R = \sqrt{x^2 \left [ (a-l)^2 + (b-m)^2 \right ]} = rx$. Now, observe that distance between centers is $d = \sqrt{(x+1)^2 \left [ (a-l)^2 + (b-m)^2 \right ]} = (x+1)r = r + R$. So, the only possibility to those two circles is to be tangent to each other. Diagram is below

It is obvious now, that tangent point divides the line that connects the centers in $1:x$ proportion. So
$$
P = (x+1)l + 1 \cdot (a-l) = a + xl \\
Q = (x+1)m + 1 \cdot (b -m) = b + xm
$$
Going back to $p$ and $q$, you can easily find that
$$
\left \{ \begin{array}{ccc}
p & = & \frac {a + xl}{1 + x} \\
q & = & \frac {b + xm}{1 + x}
\end{array} \right .
$$
Comment: Thanx, really, I want to know that how you get this idea?
Comment: @user91374 well, main part is to scale $p$ and $q$. I decide to do so after doing some ``cheating'' :). I already knew the solution by using mathematica and I just observed that both $p$ and $q$ had a common denominator of $1+x$. So I multiplied to it to see if equations get simplified. They did and also revealed simple geometry with obvious centers location and relation between radii. I'm not sure if I would do that without knowing the solution beforehand.
Comment: Oh, yes! I forgotten you used Mathematica... Despite you made  a very good observation. I also made an observation just now!, It is that, p and q are same as Section formula, isn't it?
Comment: @user91374 exactly. I actually used the same, just a bit shorter version of it.
Comment: Okay, I'm satisfied from your answer and your method thank you very much for that, really. But for the sake of curiosity, what was Claude talking about? He said he solved this equations using your hint : Divide second equation by the first one, and he got the answer within ten minutes, I tried and simplified for half an hour, I got nothing than lengthy expressions, how did he? Have you any idea? Please, Check in mathematica if possible.
Comment: @user91374 have no idea. Not that I spent a lot of time on it, but moving terms around didn't lead me anywhere. If you solve those equations in Mathematica and don't do full simplification, solution for the $q$ looks so ugly involving squares. But I don't completely reject the idea that there is some algebraically clever solution which is quite simple too. BTW, I think mvw is moving in that direction. He just didn't finish it up. I'm sure after all algebra's done, he should get the same answer. So give him some credit too.
Comment: Kaster did spend the time to look at the one point solution closer and his graphics is very nice for this. I did not isolate that situation which should somehow show up in the lengthy solutions, giving a reason why not two but one solutions, e.g. by cancelling root sub terms. I tried instead to work in vector representation, location vector plus r times unit sphere vector but that results in statements of sine and cosine functions with different amplitudes and angles where one needs to decide if they have common points which I can only do by plotting them and not by looking at values alone.
Comment: The fact that we share answers and comments allows improvement not unlike traditional publishing.
Comment: @Kaster. Very elegant geometric analysis ! Thanks for providing it. Cheers :-)
Comment: @ClaudeLeibovici, But how did you solve by hands within ten minutes! please tell us, I'm very curious to know about your method.I'm begging you for many days, please tell me.
Comment: Hey @user91374, why would you uncheck this as a solution?
Comment: Sorry mate, but I've found an short algebraic solution - (with no use of geometry) by hand, which I found to be more elegant, I 'll post it tomorrow.
Answer: The right hand sides just differ by a factor $x^2 > 0$:
$$
\begin{align}
(x + 1)^2 [(p - l)^2 + (q - m)^2] &= (a - l)^2 + (b - m)^2 \\
(x + 1)^2 [(p - a)^2 + (q - b)^2] &= x^2[(a - l)^2 + (b - m)^2]
\end{align}
$$
so we can get an equation for the left hand sides:
$$
\begin{align}
(x + 1)^2 [(p - l)^2 + (q - m)^2] &=
\frac{(x + 1)^2}{x^2} [(p - a)^2 + (q - b)^2] \iff \\
[(p - l)^2 + (q - m)^2] &=
\frac{1}{x^2} [(p - a)^2 + (q - b)^2] \quad (*)
\end{align}
$$
and indeed if we call the left side of $(*)$ $r_1^2$ and $x^2$ times the right side $r_2^2$
we got two circle equations in coordinates $p$ and $q$
$$
\begin{align}
(p - l)^2 + (q - m)^2 &= r_1^2 \\
(p - a)^2 + (q - b)^2 & = r_2^2
\end{align}
$$
where $r_1 = \sqrt{(a-l)^2+(b-m)^2}\, / \, (1 + x)$, $r_2 = x \, r_1$ and the first circle has radius radius $r_1$, origin $(l, m)$ and the second circle has radius $r_2$, origin $(a, b)$.
So the system can have the following solutions:

no solution: the two circles do not intersect, e.g. both origin $(0,0)$ and $r_1 \ne r_2$
one solution: the two circles intersect at just one point
two solutions: the two circles intersect in two points
infinite solutions: the two circles are congruent (same origin, same radius)

This gives
$$
p = l \pm \sqrt{r_1^2 - (q -m)^2} = a \pm \sqrt{r_2^2 - (q - b)^2} \quad (**)
$$
For $l = a$ this reduces to
$$
r_1^2 - (q -m)^2 = r_2^2 - (q - b)^2
$$
which gives
$$
q = \frac{b^2-m^2+r_1^2-r_2^2}{2(b-m)}
$$
for $b \ne m$ otherwise this reduces to
$$
r_1 = r_2 \iff x = 1
$$
for $b = m$.
For $l \ne a$ the calculation gets lengthy, throwing it into a computer algebra system (here WolframAlpha) gives
this result.
Once one knows $q$ one can use one of the equations $(**)$ to calculate $p$.


Importing new process definition with "witadmin importprocessconfig" in TFS has no effect, and no error message

Question: After I customized the WIT definitions of an Agile process template, I got an TF400917 error trying to access the Backlogs in TFS. According to https://msdn.microsoft.com/library/hh500413.aspx I have to update the process config (which makes sense), but this is where I got issues.
I updated and imported the process config file with witadmin importprocessconfig. The operation completed and I got no error messages after a few tries. Though the process definition is still not updated on the server. I can see that it's still the old file by exporting it with witadmin exportprocessconfig.
Can anyone give me a tip on what could be wrong, or what I can do next to try to update the file?

See Categories XML below.
Creating new WIT's, changing their states and working with queries work fine.
I have updated the categories definition to see if that would help. It worked fine to import the file but did not solve the problem.
I'm running VS 2015 with power tools, and I think the TFS server is 2013.

Best regards
Qanik
New process config XML (which did not work)
<code><?xml version="1.0" encoding="ibm850"?>
<ProjectProcessConfiguration>
  <BugWorkItems category="Microsoft.BugCategory" pluralName="Bugs" singularName="Bug">
    <States>
      <State type="Proposed" value="New" />
      <State type="InProgress" value="Programming" />
      <State type="InProgress" value="Testing" />
      <State type="Complete" value="Done" />
      <State type="Resolved" value="Released" />
    </States>
  </BugWorkItems>
  <FeedbackRequestWorkItems category="Microsoft.FeedbackRequestCategory" pluralName="Feedback Requests" singularName="Feedback Request">
    <States>
      <State type="InProgress" value="Active" />
      <State type="Complete" value="Closed" />
    </States>
  </FeedbackRequestWorkItems>
  <FeedbackResponseWorkItems category="Microsoft.FeedbackResponseCategory" pluralName="Feedback Responses" singularName="Feedback Response">
    <States>
      <State type="InProgress" value="Active" />
      <State type="Complete" value="Closed" />
    </States>
  </FeedbackResponseWorkItems>
  <PortfolioBacklogs>
    <PortfolioBacklog category="Microsoft.FeatureCategory" pluralName="Features" singularName="Feature" workItemCountLimit="500">
      <AddPanel>
        <Fields>
          <Field refname="System.Title" />
        </Fields>
      </AddPanel>
      <Columns>
        <Column width="100" refname="System.WorkItemType" />
        <Column width="400" refname="System.Title" />
        <Column width="100" refname="System.State" />
        <Column width="50" refname="Microsoft.VSTS.Common.BusinessValue" />
        <Column width="200" refname="System.Tags" />
      </Columns>
      <States>
        <State type="Proposed" value="New" />
        <State type="InProgress" value="In Progress" />
        <State type="InProgress" value="Done" />
        <State type="Complete" value="Relesed" />
      </States>
    </PortfolioBacklog>
  </PortfolioBacklogs>
  <RequirementBacklog category="Microsoft.RequirementCategory" parent="Microsoft.FeatureCategory" pluralName="Stories" singularName="User Story" workItemCountLimit="500">
    <AddPanel>
      <Fields>
        <Field refname="System.Title" />
      </Fields>
    </AddPanel>
    <Columns>
      <Column width="100" refname="System.WorkItemType" />
      <Column width="400" refname="System.Title" />
      <Column width="100" refname="System.State" />
      <Column width="50" refname="Microsoft.VSTS.Scheduling.StoryPoints" />
      <Column width="200" refname="System.IterationPath" />
      <Column width="200" refname="System.Tags" />
    </Columns>
    <States>
      <State type="Proposed" value="New" />
      <State type="Proposed" value="Redy for development" />
      <State type="InProgress" value="Programming" />
      <State type="InProgress" value="Testing" />
      <State type="InProgress" value="Done" />
      <State type="Complete" value="Released" />
    </States>
  </RequirementBacklog>
  <TaskBacklog category="Microsoft.TaskCategory" parent="Microsoft.RequirementCategory" pluralName="Tasks" singularName="Task" workItemCountLimit="500">
    <AddPanel>
      <Fields>
        <Field refname="System.Title" />
      </Fields>
    </AddPanel>
    <Columns>
      <Column width="400" refname="System.Title" />
      <Column width="100" refname="System.State" />
      <Column width="100" refname="System.AssignedTo" />
      <Column width="50" refname="Microsoft.VSTS.Scheduling.RemainingWork" />
    </Columns>
    <States>
      <State type="Proposed" value="To do" />
      <State type="InProgress" value="In Progress" />
      <State type="Complete" value="Done" />
    </States>
  </TaskBacklog>
  <TypeFields>
    <TypeField refname="Microsoft.VSTS.Common.Activity" type="Activity" />
    <TypeField refname="Microsoft.VSTS.Common.StackRank" type="Order" />
    <TypeField refname="Microsoft.VSTS.Feedback.ApplicationLaunchInstructions" type="ApplicationLaunchInstructions" />
    <TypeField refname="Microsoft.VSTS.Feedback.ApplicationStartInformation" type="ApplicationStartInformation" />
    <TypeField refname="Microsoft.VSTS.Feedback.ApplicationType" type="ApplicationType">
      <TypeFieldValues>
        <TypeFieldValue type="ClientApp" value="Client application" />
        <TypeFieldValue type="RemoteMachine" value="Remote machine" />
        <TypeFieldValue type="WebApp" value="Web application" />
      </TypeFieldValues>
    </TypeField>
    <TypeField format="{0} h" refname="Microsoft.VSTS.Scheduling.RemainingWork" type="RemainingWork" />
    <TypeField refname="Microsoft.VSTS.Scheduling.StoryPoints" type="Effort" />
    <TypeField refname="System.AreaPath" type="Team" />
  </TypeFields>
  <Weekends>
    <DayOfWeek>Sunday</DayOfWeek>
    <DayOfWeek>Saturday</DayOfWeek>
  </Weekends>
  <WorkItemColors>
    <WorkItemColor primary="FFCC293D" secondary="FFFAEAE5" name="Bug" />
    <WorkItemColor primary="FFFF9D00" secondary="FFFCEECF" name="Code Review Request" />
    <WorkItemColor primary="FFFF9D00" secondary="FFFCEECF" name="Code Review Response" />
    <WorkItemColor primary="FF773B93" secondary="FFEEE2F2" name="Feature" />
    <WorkItemColor primary="FFFF9D00" secondary="FFFCEECF" name="Feedback Request" />
    <WorkItemColor primary="FFFF9D00" secondary="FFFCEECF" name="Feedback Response" />
    <WorkItemColor primary="FFFF9D00" secondary="FFFCEECF" name="Issue" />
    <WorkItemColor primary="FF773B93" secondary="FFEEE2F2" name="Requirement" />
    <WorkItemColor primary="FFFF9D00" secondary="FFFCEECF" name="Shared Parameter" />
    <WorkItemColor primary="FFFF9D00" secondary="FFFCEECF" name="Shared Steps" />
    <WorkItemColor primary="FFF2CB1D" secondary="FFF6F5D2" name="Task" />
    <WorkItemColor primary="FFFF9D00" secondary="FFFCEECF" name="Test Case" />
    <WorkItemColor primary="FFFF9D00" secondary="FFFCEECF" name="Test Plan" />
    <WorkItemColor primary="FFFF9D00" secondary="FFFCEECF" name="Test Suite" />
    <WorkItemColor primary="FF009CCC" secondary="FFD6ECF2" name="User Story" />
  </WorkItemColors>
</ProjectProcessConfiguration>
</code>
Updates in the category XML (which did take effect).
<code>  <CATEGORY refname="Microsoft.FeatureCategory" name="Feature Category">
    **<DEFAULTWORKITEMTYPE name="Requirement" />
    <WORKITEMTYPE name="Feature" />
    <WORKITEMTYPE name="Theme" />**
  </CATEGORY>

  <CATEGORY refname="Microsoft.HiddenCategory" name="Hidden Types Category">
    <DEFAULTWORKITEMTYPE name="Code Review Request" />
    <WORKITEMTYPE name="Code Review Response" />
    **<WORKITEMTYPE name="Feature" />**
    <WORKITEMTYPE name="Feedback Request" />
    <WORKITEMTYPE name="Feedback Response" />
    <WORKITEMTYPE name="Shared Steps" />
    <WORKITEMTYPE name="Shared Parameter" />
    <WORKITEMTYPE name="Test Plan" />
    <WORKITEMTYPE name="Test Suite" />
  </CATEGORY>
  <CATEGORY refname="Microsoft.RequirementCategory" name="Requirement Category">
</code>
Comment: What's the change you made on the customized WIT definitions? Can you share it?
Comment: Hi Eddie - MSFT
Thanks for your answer.
I have added the XML code for the process configuration to the question. As you can see I have updated the states for the bug, feature and requirement categories and added a colour for my new requirement WIT. To add the WIT definitions will be a lot of code since I have added quite a few states and transitions customized the UI on different WITs and added a new one. I have also added a release date field on 2 WIT's.

Best regards

Qanik
Comment: I didn't see any issue for the XML you provided. Can you try export the process config file and make a minor change on it (For example: Change color) and then import it to see if the xml file can be imported successfully?
Comment: If I only update a colour I get error messages saying that certain WITs doesn't have definitions for it's states (which is true :) ). See below.
If I fix these errors, I get Operation complete in the command prompt. But nothing happens in the system.
Comment: Errorr messages:
_The following element contains an error: TaskBacklog/States. TF400587: This element defines the states for work items that appear on your backlog. Each state must exist in at least one of the work item types belong to category defined in: 'TaskBacklog/States'. The following state does not exist in any of the work item types: New, Active, Closed._
Comment: Error message: _The following element contains an error: TaskBacklog/States. TF400536: This element defines the states for work items that appear on your backlog. The initial state value for each work item type must match one of the states defined in this element. The following work item types have an initial state that is not included in the defined states: 'Task'._
Answer: When the error occurs, you can go to your TFS server "Computer Management\System Tools\Applications and Services Logs\Microsoft-Team Foundation Server\Debug". The logs should be generated for the error and you can check it for the root cause.


can i use column alias in many positions in the query?

Question: if i managed to make the folowing view in mysql
select id,name,score,total,CALCIT(total - score) as x,(CALCIT(total - score) / total) as per from tblx;

the process CALCIT(total - score) is being caculated two times
how to do some thing like this:
select id,name,score,total,CALCIT(total - score) as `x`,`x`/total as per from tblx;

where CALCIT is a function
Answer: MySQL will permit you to use a column alias inside the ORDER BY, GROUP BY clauses, but you won't be able to reuse the alias in the SELECT list.  If you really needed to do this, having many instances of the calculated value, you can do a self JOIN which produces the calculation.
SELECT
  id,
  name,
  score,
  total,
  x,
  x / total AS per
FROM tblx JOIN (
    /* Subquery JOIN which performs the calculation */
    SELECT CALCIT(total - score) AS x FROM tblx xcalc
  ) ON tblx.id = xcalc.id

This method may be more performant than redoing the calculation in one SELECT, but as with anything, benchmark to find out.
Answer: better you can use inner query --
select id,
       name,
       score,
       total,
       X,
       X/total as per
 from (
        select id,
               name,
               score,
               total,
               CALCIT(total - score) as X from tblx
      )

Answer: Try something like this:
select *, x/total from (
    select id,name,score,total,CALCIT(total - score) as x from tblx;
) as tblx


Creating child objects on basis created parent object in java

Question: I'm learning java design patterns and I wonder if I can apply some with following problem. I have class Solider and some child classes, for example: General and Sergeant. I'm creating Solider object and in runtime I want to change this object to General or Sergeant object, or create new Sergeant or General object using created earlier Solider object:
 Solider s = new Solider(...);
 .....
 if (generalCondition) {
     General g = createGeneralFromSolider(s);
     //or better:
     //General g = promoteSoliderToGeneral(s);
 } else if (sergeantCondition) {
      Sergeant sr = createSergeantFromSolider(s);
      //or better:
      //Sergeant sr = promoteSoliderToSergeant(s);
 }

Firstly I decided to create additional constructor in General/Sergeant Class:
Class General extends Solider {
    General(Solider s, Map<String, String> generalSpecificParams) {
        //first we are going to copy all solider params to general params (bad idea if we have a lot of params)
        this.setParamX(s.getParamX());
        ....
        //then we can assign the rest of general-specific params
        this.setGeneralSpecificParams(generalSpecificParams);
    }
}

and use it in methods createGeneralFromSolider but I'm not sure if it is elegant way. Main disadvantage is that I create new object, so after calling createGeneralFromSolider I have 2 object in memory. I would rather have one object in memory: General/Sergeant promoted from Solider (object General/Sergeant which earlier was the Solider object). I wonder if I can use some design patter to resolve it. I remember that in C++ there has been something like copying constructors which copying all params from one object to another by assigning all params, one after another. In Java I didn't hear about anything similar.
Comment: Are you sure you want to use inheritance here?
Answer: You would probably need to use a Factory pattern for this kind of situation.
For example:
public class SoldierFactory {

   //use getSoldier method to get object of type Soldier
   public Soldier getSoldier(String soldierType){
      if(soldierType == null){
         return null;
      }
      if(soldierType.equals("case1")){
         return new General();

      } else if(soldierType.equals("case2")){
         return new Sergeant();

      } else if(.....

      }

      return null;
   }
}

public class FactoryPatternDemo {

   public static void main(String[] args) {
      SoldierFactory soldierFactory = new SoldierFactory();

      Soldier s1 = soldierFactory.getsoldier("case1");

   }
}

I think its better to not create the Soldier ahead of calling Soldier factory. You're going to change it regardless during run-time right?
Comment: I have Solider object on the begining. Then, I want to change it (or create new using it) in runtime. I'm not sure how this factory would help in my situation.
Comment: You are creating the final object from scratch - not from existing Solider as I want. If you factory would create Sergeant or General using given Solider object (factory.getSolider("caseX", solidetObj) - then solution would be acceptable.
Answer: First of all, when constructing child classes, use super as the first statement of the constructor like so:
class Soldier {
    private String rank; // e.g. Pvt, PFC, etc.
    private int yearsOfService;

    // ... (Standard constructor)
    public Soldier(Soldier s) {
        this.rank = s.rank; this.yearsOfService = s.yearsOfService;
    }
    // ... (Getters and Setters)
}

class Sergeant extends Soldier {
    private int subordinates;

    public Sergeant(Soldier s) {
        super(s)
        this.rank = "Sergeant"; // overwrites this Sergeant's rank
        this.subordinates = 0;
    }
}

You could easily encapsulate this in a promoteSoldierToSergeant method. However, this can lead to telescoping constructors if classes with many attributes are designed naively, or necessitate your map-based workaround. To resolve this, I'm personally a big fan of the Builder pattern, but you can also consider the Factory pattern.
Your question regarding "copying constructors" is perhaps best addressed by reading up on the Clonable interface, but be aware of the differences between shallow and deep copies, and the implications for your classes and data structures.
Answer: I think your approach is totally acceptable. If you have an object X, that you want to turn into Y, you can do it in Y constructor, copying all necessary fields.
You could as well use a builder, or static factory methods, but either way you'll have to copy fields, as there's no automatic copy constructor in java (except if you use some dedicated library such as lombok, which can provide full-args constructors from annotations)
You worry about having 2 objects in memory. But if you remove every reference of the original Soldier, the garbage collector will destroy it.
Last thing, as mentionned by @tsolakp , is it a good design to have General inheriting from Soldier? Couldn't it be just a "grade" variable, or something like that, to reflect this state? It's a common mistake to overuse inheritance where composition would be sufficient, and would cause less troubles.
Comment: Using composition can be a good approach here, but can cause other troubles when I need to map those objects to DB object. Besides, inheritance better reflects the reality: we can say that General is also a Solider (in opposite to: "General has a Solider" in composition approach).
Answer: What you want could be achieved using Reflections.
That way you can automatically copy fields from the instance of parent to child class.
Your code would look something like this:
public static void copyObject(Object src, Object dest)
            throws IllegalArgumentException, IllegalAccessException,
            NoSuchFieldException, SecurityException {
        for (Field field : src.getClass().getFields()) {
            dest.getClass().getField(field.getName()).set(dest, field.get(src));
        }
    }

    public static General createGeneral (Solider solider, String devision) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException {
        General general = new General();
        copyObject(solider, general);
        general.setDevision(devision);

        return general;
    }

The Field import is java.lang.reflect.Field;
========================================================================
Another way would be to use the Apache Bean Utils.
Than, you can use it's cloneBean(Object Bean) method like this:
General general = cloneBean(solider);

to copy the fields from solider to general and after that all the fields that are specific to child class (General).
========================================================================
EDIT: It would also be wise to introduce another child class that would be used for "ordinary" soliders if you intended to use the parent class Solider for "ordinary" soliders (which I suppose you do according to your commented method name promoteSoliderToGeneral(Solider s).
So, for example you would have a parent class called MilitaryMan and 3 child classes that extend it: Solider, General and Sergeant.
This way, you can uniformly handle all of the MilitaryMan. And, you can check if the MilitaryMan is a Solider, General or Sergeant with:
if (militaryMan instanceOf Solider) {
   // do solider specific processing
   ...
} else if (militaryMan instanceof General) {
   ...
} else if (militaryMan instanceof Sergeant) {
   ...
}

I think it would be cleaner this way.


Parenthesis change the function signature

Question: When I set parenthesis in a function definition, the function types change.
I have two functions: addition1(without parenthesis) and addition2 (with parenthesis). The types are the same, but the function signature is different. Why is the type different?
let addition1 a b =
  a + b
//val addition1 : a:int -> b:int -> int

let addition2(a, b) =
  a + b
//val addition2 : a:int * b:int -> int

Comment: You also added a comma which is the big change
Comment: It's not the same, first function is taking two parameters (actually taking first parameter  then creating a function taking the second parameter). And can be curried. Second function is taking one parameter, that is a tuple. First form is common for F# code, second one is more for interop with BCL.
Comment: Possible duplicate of [F# function calling syntax confusion](http://stackoverflow.com/questions/2725202/f-function-calling-syntax-confusion)
Comment: @s952163 I understand. Is there some significant difference?
Comment: Please see this: [A Common Mistake: Tuple vs Multiple Parameters](https://fsharpforfunandprofit.com/posts/defining-functions/)
Answer:
The types are the same, but the function signature is different. Why the type different?

The types aren't actually the same.
When you write:
let addition1 a b = a + b

You create a function which is distinctly different than
let addition2 (a, b) = a + b

In the second case, the parenthesis and comma are creating a tuple, meaning that your function accepts a single parameter, which is a tuple (typed as int * int), and returns an int.
The first case creates a function which can be curried.  The type signature of int -> int -> int means that it creates a function which accepts an int, and then returns a function which accepts and int and returns an int.  This allows you to use partial application:
let partially_applied_addition1 = addition1 3

For details, see functions in the official docs, and Currying from fsharpforfunandprofit.
Allowing for currying is much more common in F# code.  In general, using tuples as a parameter is mostly done for interop scenarios with the base class libraries or when planning an API to be used from C# or other languages.  Being able to partially apply allows things like piping to work properly:
let answer =
    getSomeIntegerValue ()
    |> addition1 12 // Add 12 to result

The tupled form will not compile with the above, as it cannot work with partial application.


Consulta por índice em coluna do tipo JSON

Question: Como realizo uma consulta, por índice, onde os dados da coluna são do tipo JSON?
Por exemplo:
Desejo obter todos os dados onde a tensão for igual à 220:
tabela material
id | descricao   | extra
 2 | Altus       | {"tensao": "220", "comunicacao": "2"}
 5 | Sonesse 406 | {"tensao": "110", "comunicacao": "2"}
 7 | Sonesse 409 | {"tensao": "220", "comunicacao": "2"}

Comment: Sendo o 5.7 creio que tenha muita coisa https://dev.mysql.com/doc/refman/5.7/en/json.html, creio que possa usar `JSON_CONTAINS` / `JSON_EXTRACT`, desde que o tipo da coluna seja `JSON`. Agora eu sinceramente diria que o melhor seria criar colunas ou até uma estrutura relacional ao invés de salvar como JSON "puro".
Answer: Creio que você possa usar JSON_EXTRACT, mas se for do tipo JSON já pode fazer assim:
... WHERE `extra`->'$.tensao' = 200

Pode também usar o JSON_CONTAINS, algo como:
... WHERE JSON_CONTAINS(`extra`, 200, '$.tensao')

Não cheguei a testar JSON_CONTAINS com colunas que não sejam do tipo JSON.

Extra:
Se tratando de um banco simples, não vejo problema algum em usar JSON, agora se supondo que o banco precise fazer consultas complexas, talvez deva optar por não usar JSON, mas sim uma estrutura relacional divido (conforme a necessidade) para poder fazer comparações e extrações de dados.
Por exemplo um estoque tem X produtos, todos produtos compartilham daquele valor, logo seria interessante haver uma tabela para valores e outra para produtos, seria uma estrutura N:N (many-to-many).
Aproveite e leia sobre o JOIN: Qual é a diferença entre INNER JOIN e OUTER JOIN?


WHERE statement with CASE clause to return one value or all others

Question: I want to ask you for help about the CASE statement in WHERE clause.
I want to achieve to get rows where SEMI_GV column with value 'SEMI' if description of division (IC.Description) is containing also the '%semi%'. This is actually working, but when if column SEMI_GV has different value than 'SEMI' (e.g. GV or NULL), I am not sure how to return all values excluding the 'SEMI'.
Below is code I tried, but actually it's not working as I am not sure what should be used after second THEN statement to filter everything else.
...
WHERE
    procur.SEMI_GV LIKE
        CASE
            WHEN IC.[Description] LIKE '%semi%' THEN 'SEMI'
            WHEN IC.[Description] NOT LIKE '%semi%' THEN ???
        END

Thank you in advance for support!
EDIT:
the result table I want to filter out is this
KUNNR   NAME1   LAND1   BRAN1   VKORG   VTWEG   SPART   ZTERM   Resp_FAM    Description MAIL    SEMI_GV POSITION
0050000001  Dummy account   GB  11002   1101    10  00  ECCP    GCN UK Inside Sales firstname.lastname@example.com   NULL    BC
0050000001  Dummy account   GB  11002   1101    10  00  ECCP    GCN UK Inside Sales firstname.lastname@example.com   SEMI    BC

In where clause I want to return only one row based on condition:

if Description contains "SEMI" and SEMI_GV contains SEMI, return this row (2nd row)
if Description contains anything else, return this row (1st row)

The WHERE clause is working for the case when description contains the 'semi' in it, however I tried to put the another conditions like:
WHERE
    procur.POSITION = 'BC'
AND
    procur.SEMI_GV LIKE
        CASE
            WHEN IC.[Description] LIKE '%semi%' THEN 'SEMI'
            WHEN IC.[Description] NOT LIKE '%semi%' THEN
                CASE
                    WHEN SEMI_GV IS NOT NULL THEN 'GV'
                ELSE NULL

However I cannot get through the NULL value because "LIKE" statement on the beginning.
Comment: So, you want a results set where it matches and a results set where it doesn't?
Comment: yeah, this is exactly what I need
Comment: It's generally better to use AND/OR constructions instead of case _expressions_ in the WHERE clause.
Comment: @jarlh, thank you, added further info
Answer: From what I can gather, it sounds like you want a results set for when the IC.[Description] column contains "semi" and a different results set for when it doesn't (but lumped into one datatable).
If I've interpreted it correctly, you may be better of looking at a UNION, i.e.
SELECT *
FROM MyTable
WHERE procur.SEMI_GV = 'SEMI'
      AND IC.[Description] LIKE '%semi%'
UNION ALL
SELECT *
FROM MyTable
WHERE procur.SEMI_GV != 'SEMI'
      OR IC.[Description] NOT LIKE '%semi%';

Without more information on the data involved and what the end result should be, I'm not sure how much more I can help.


Conditional rendering of the data template in XAML

Question: I have a list of text blocks, that may include urls inside, smth like:

Build failed, see more here: http://...
Build succeeded
App http://myapp/ cannot be started, see more here: http://...

I need to display this (endless) list in a UWP app. Considering this list can be used in multiple views inside the app, I made it a common template:
<ResourceDictionary>
  <ControlTemplate x:Key="ListItemTemplate" TargetType="ItemsControl">
    <Grid>
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="50"/>
        <ColumnDefinition Width="*"/>
      </Grid.ColumnDefinitions>
      <Image Grid.Column="0" Source="{Binding image_url}"/>
      <TextBlock Grid.Column="1" Text="{Binding status}"/>
    </Grid>
  </ControlTemplate>
</ResourceDictionary>

In this template links are treated like regular text (which is expected). As I understand, to make links work I need to wrap them into <HyperLink> tag, but I cannot do this in template, because I don't know where exactly links will be and how many of them will appear.
Is there any way to implement some renderer method, that could generate item's body (<TextBlock>) in code, processing passed value?
Probably converter could help me, but if I understand correctly, it only accept value from binding, and I need to reference whole instance.
UPD: Expanding solution from the accepted answer:
Resource dictionary:
<ResourceDictionary xmlns:resources="using:NamespaceWithTextBlockExt">
  <ControlTemplate x:Key="ListItemTemplate" TargetType="ItemsControl">
    <Grid>
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="50"/>
        <ColumnDefinition Width="*"/>
      </Grid.ColumnDefinitions>
      <Image Grid.Column="0" Source="{Binding image_url}"/>
      <TextBlock Grid.Column="1" resources:TextBlockExt.XAMLText="{Binding Text}"/>
    </Grid>
  </ControlTemplate>
</ResourceDictionary>

Processor somewhere in your project:
public static class TextBlockExt
{
    public static String GetXAMLText(TextBlock obj)
    {
        return (String)obj.GetValue(XAMLTextProperty);
    }

    public static void SetXAMLText(TextBlock obj, String value)
    {
        obj.SetValue(XAMLTextProperty, value);
    }

    ///
    /// Convert raw string from ViewModel into formatted text in a TextBlock:
    ///
    /// @"This <Bold>is a test <Italic>of the</Italic></Bold> text."
    ///
    /// Text will be parsed as XAML TextBlock content.
    ///
    /// See WPF TextBlock documentation for full formatting. It supports spans and all kinds of things.
    ///
    ///
    public static readonly DependencyProperty XAMLTextProperty =
        DependencyProperty.RegisterAttached("XAMLText", typeof(String), typeof(TextBlockExt),
                                             new PropertyMetadata("", XAMLText_PropertyChanged));

    private static void XAMLText_PropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        if (d is TextBlock)
        {
            var ctl = d as TextBlock;

            try
            {
                //  XAML needs a containing tag with a default namespace. We're parsing
                //  TextBlock content, so make the parent a TextBlock to keep the schema happy.
                //  TODO: If you want any content not in the default schema, you're out of luck.
                var value = e.NewValue;

                var strText = String.Format(@"<TextBlock xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"">{0}</TextBlock>", e.NewValue);

                TextBlock parsedContent = Windows.UI.Xaml.Markup.XamlReader.Load(strText) as TextBlock;

                //  The Inlines collection contains the structured XAML content of a TextBlock
                ctl.Inlines.Clear();

                var inlines = parsedContent.Inlines.ToList();
                parsedContent.Inlines.Clear();

                //  UI elements are removed from the source collection when the new parent
                //  acquires them, so pass in a copy of the collection to iterate over.
                ctl.Inlines.Concat(inlines);
                inlines.ForEach(x => ctl.Inlines.Add(x));
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(String.Format("Error in Ability.CAPS.WPF.UIExtensions.TextBlock.XAMLText_PropertyChanged: {0}", ex.Message));
                throw;
            }
        }
    }
}

I'm not sure this is the best way, but it works. I just need to preprocess bound value and wrap all URLs into hyperlink tags:
"App <Hyperlink NavigateUri=\"http://app/\">myapp</Hyperlink>"
I assume this should work with any other content, like <InlineUIContainer>
Comment: It should work with any content that can be a child of `TextBlock`.
Answer: You can write an attached behavior that parses a string as XAML using XamlReader.Load(Stream), and adds the resulting control to the target control. Here's one I wrote which does it with TextBlock content, which can include Hyperlink. That's for WPF not UWP; there may be some differences.
Yours would have to do a little additional work: It would take a non-XAML string, and before parsing as XAML it would have to find URLs and replace them with XAML Hyperlink elements in the string. Then you'd parse that.
It would be cleaner to put that second part in a value converter. Call it HyperLinksToXAMLConverter:
<TextBlock
    local:XAMLText="{Binding status, Converter={StaticResource HyperLinksToXAML}}"
    />

Comment: Thank you very much! I tested this solution and it allows me to modify content and show hyperlinks. As mentioned - code should be adjusted slightly.
Comment: @ragzovskii Awesome. Can you add the UWP version of the code to your Q, or edit it into my A? I'll approve the edit.


When to use list(text) or taxonomy?

Question: This may be a silly question, but I'm curious what the benefit is of using a list (text) multiple select field over a taxonomy term reference field. They both seem to fill roughly the same function of giving predetermined multiple choice options, but taxonomy has the added benefit of allowing you to add terms after content has been written to the database.
So is there any good guideline for one to use one or the other? (And particularly when list(text) makes more sense than taxonomy term reference?).
Comment: I try to think of a taxonomy as 'way to categorize data in a structured manner' (including tree structures) and lists as 'Offering several defined options' when organization isn't important. When in doubt, I pick taxonomy, since the integration into browsing via Views is quick to implement.
Comment: The one thing select/text can't do is structure data hierarchy; Taxonomy alone offers trees.
Comment: There's an article about this at http://eosrei.net/articles/2013/12/definitive-drupal-field-api-option-list-vs-taxonomy-pro-con-list.
Answer: Structure and dynamic are IMO the keywords for choosing taxonomy.
I recently had this question come to me when tagging companies with geographical regions. My first choice was to prepare taxonomy with list of regions. Soon it turned out to be over-complication. The regions almost never change their names and almost never change their structure/parents. So I tossed out the taxonomy and decided to use a flat List (Text). It's now also much easier to maneuver the regions in a View. So - if your list is static and flat - go for a list.
Comment: Well there's one obvious thing which slipped my mind - I'd say use taxonomy when you want the tags to have their own pages, filled with custom fields, images, displayed in various modes (full, teaser, etc.)
Comment: accepting this because it gave some pros and cons. Patrick Kenny's point about performance is important too though.
Answer: Taxonomy has performance issues as it scales because the SQL queries get longer; if you are using views filters, select lists will be faster than taxonomy.
Comment: That is generally true, but with experience you get to know that you should use SOLR search for scaling views with filters so it doesnt matter much then.
Answer: The key differentiations I learned were:

do you want users to be adding to the list of values, not just site admins or, will adding to the list be a semi-regular need for even site admins?
do you want to use the value as an organizing piece of content itself (as suggested above by @Artur, creating pages of all content that shares this term, with different layouts, like a product page: show all XL clothes; or news, show all Sports)
is the data at all hierarchical? (eg: subcategories where you'll want to capture the parent category sometimes or the children separately at others)

If no to all of the above, use select/text. If yes, use taxonomy terms. You'll usually use select/text, in my experience. It always feels wrong, but it's usually right.
Answer: Clear winner in my opinion would be taxonomy term, more power, little downsides.

When to use list(text) or taxonomy?


Why don't I get a module dependencies?

Question: I've got very little knowledge but I've managed to install Drupal Commerce 2 on a Debian 9 with the command
composer create-project drupalcommerce/project-base mysite --stability dev
I started off with a minimal debian installation so I really had to look around to resolve any dependencies just to get this composer command to work! It's not as straight-forward as the manual seems to suggest. Anyways, I've got a site installed now and besides a few suggestions from composer, I don't think I have received any errors.
I can browse to the installed site with my web browser but I'm stuck on page 2 (Verify requirements) where it says

REQUIRED MODULES: Not found Commerce_log, Commerce_tax

Where do I get the modules from and how? Isn't composer supposed to resolve all dependencies and have these modules installed automatically?
Besides the error that stops me from continuing the creation of the site, I get a warning on CLEAN URLS (disabled).
Here is the log of my composer installation:
composer create-project drupalcommerce/project-base mystore --stability dev --verbose
Installing drupalcommerce/project-base (8.x-dev 44c1fe21fbd9155a294c4b8fe0eaac0195a0f585)
  - Installing drupalcommerce/project-base (8.x-dev 44c1fe2): Cloning 44c1fe21fbd9155a294c4b8fe0eaac0195a0f585 from cache
Created project in mystore
> pre-update-cmd: DrupalProject\composer\ScriptHandler::checkComposerVersion
Loading composer repositories with packagUpdating dependencies (including require-dev)         Dependency resolution completed in 9.290 seconds
Analyzed 11720 packages to resolve dependencies
Analyzed 485242 rules to resolve dependencies
Dependency resolution completed in 0.000 seconds
Package operations: 122 installs, 0 updates, 0 removals
Installs: cweagans/composer-patches:1.6.1, drupal-composer/drupal-scaffold:2.3.0, composer/installers:v1.4.0, symfony/yaml:v2.8.26, symfony/finder:v3.3.6, drupal/console-extend-plugin:0.9.2, drupalcommerce/commerce_base:dev-8.x-1.x 241bcf3, zendframework/zend-stdlib:3.1.0, zendframework/zend-escaper:2.5.2, zendframework/zend-feed:2.8.0, psr/http-message:1.0.1, zendframework/zend-diactoros:1.4.0, twig/twig:v1.34.4, symfony/polyfill-mbstring:v1.4.0, symfony/translation:v2.8.26, ircmaxell/password-compat:v1.0.4, symfony/polyfill-php55:v1.4.0, symfony/polyfill-php54:v1.4.0, symfony/http-foundation:v2.8.26, symfony/psr-http-message-bridge:v1.0.0, symfony/polyfill-iconv:v1.4.0, symfony/event-dispatcher:v2.8.26, psr/log:1.0.2, symfony/debug:v2.8.26, symfony/http-kernel:v2.8.26, symfony/routing:v2.8.26, symfony-cmf/routing:1.4.1, stack/builder:v1.0.4, paragonie/random_compat:v2.0.10, masterminds/html5:2.2.2, guzzlehttp/psr7:1.4.2, guzzlehttp/promises:v1.3.1, guzzlehttp/guzzle:6.3.0, doctrine/lexer:v1.0.1, egulias/email-validator:1.2.14, easyrdf/easyrdf:0.9.1, doctrine/inflector:v1.2.0, doctrine/collections:v1.4.0, doctrine/cache:v1.6.2, doctrine/annotations:v1.2.7, doctrine/common:v2.7.3, composer/semver:1.4.2, asm89/stack-cors:1.1.0, symfony/validator:v2.8.26, symfony/serializer:v2.8.26, symfony/process:v2.8.26, symfony/dependency-injection:v2.8.26, symfony/console:v2.8.26, symfony/polyfill-apcu:v1.4.0, symfony/class-loader:v2.8.26, drupal/core:8.3.6, drupal/admin_toolbar:1.19.0, psr/simple-cache:1.0.0, psr/cache:1.0.1, symfony/cache:v3.3.6, symfony/expression-language:v3.3.6, symfony/dom-crawler:v3.3.6, symfony/css-selector:v2.8.26, jakub-onderka/php-console-color:0.1, jakub-onderka/php-console-highlighter:v0.3.2, dnoegel/php-xdg-base-dir:0.1, nikic/php-parser:v3.1.0, symfony/var-dumper:v3.3.6, psy/psysh:v0.8.11, gabordemooij/redbean:v4.3.4, vlucas/phpdotenv:v2.4.0, drupal/console-dotenv:0.3.0, webmozart/assert:1.2.0, webmozart/path-util:2.3.0, webflo/drupal-finder:0.3.0, symfony/filesystem:v3.3.6, symfony/config:v3.2.13, stecman/symfony-console-completion:0.7.0, drupal/console-en:1.0.0, dflydev/placeholder-resolver:v1.0.2, dflydev/dot-access-data:v1.1.0, dflydev/dot-access-configuration:v1.0.2, drupal/console-core:1.0.0, alchemy/zippy:0.4.3, drupal/console:1.0.0, commerceguys/intl:v0.7.4, drupal/state_machine:1.0.0-beta3, drupal/entity:dev-1.x 6bf9d50, drupal/profile:dev-1.x 75637f8, drupal/entity_reference_revisions:1.3.0, drupal/inline_entity_form:1.0.0-beta1, commerceguys/enum:v1.0, commerceguys/addressing:v1.0.0-beta3, drupal/address:1.1.0, drupal/commerce:2.0.0-beta3, drupal/search_api:1.3.0, html2text/html2text:4.0.1, swiftmailer/swiftmailer:v5.4.8, drupal/mailsystem:4.1.0, drupal/swiftmailer:1.0.0-beta1, symfony/browser-kit:v3.3.6, fabpot/goutte:v3.2.1, behat/mink:v1.7.1, behat/mink-browserkit-driver:v1.3.2, behat/mink-goutte-driver:v1.2.1, jcalderonzumba/gastonjs:v1.0.3, jcalderonzumba/mink-phantomjs-driver:v0.3.3, mikey179/vfsStream:v1.6.5, sebastian/version:1.0.6, sebastian/global-state:1.1.1, sebastian/recursion-context:1.0.5, sebastian/exporter:1.2.2, sebastian/environment:1.3.8, sebastian/diff:1.4.3, sebastian/comparator:1.2.4, doctrine/instantiator:1.0.5, phpunit/php-text-template:1.2.1, phpunit/phpunit-mock-objects:2.3.8, phpunit/php-timer:1.0.9, phpunit/php-file-iterator:1.4.2, phpunit/php-token-stream:1.4.11, phpunit/php-code-coverage:2.2.4, phpdocumentor/reflection-common:1.0, phpdocumentor/type-resolver:0.3.0, phpdocumentor/reflection-docblock:3.2.2, phpspec/prophecy:v1.7.0, phpunit/phpunit:4.8.36
  - Installing cweagans/composer-patches (1.6.1): Downloading (100%)
 Extracting archiveNo patches found for cweagans/composer-patches.
Patching is disabled. Skipping.
  - Installing drupal-composer/drupal-scaffold (2.3.0): Downloading (100%)
 Extracting archiveNo patches found for drupal-composer/drupal-scaffold.
Patching is disabled. Skipping.
  - Installing composer/installers (v1.4.0): Downloading (100%)
 Extracting archiveNo patches found for composer/installers.
Patching is disabled. Skipping.
  - Installing symfony/yaml (v2.8.26): Downloading (100%)
 Extracting archiveNo patches found for symfony/yaml.
Patching is disabled. Skipping.
  - Installing symfony/finder (v3.3.6): Downloading (100%)
 Extracting archiveNo patches found for symfony/finder.
Patching is disabled. Skipping.
  - Installing drupal/console-extend-plugin (0.9.2): Downloading (100%)
 Extracting archiveNo patches found for drupal/console-extend-plugin.
Patching is disabled. Skipping.
  - Installing drupalcommerce/commerce_base (dev-8.x-1.x 241bcf3): Cloning 241bcf336c92abaac8275807ce552bea846bbee0 from cache
No patches found for drupalcommerce/commerce_base.
Patching is disabled. Skipping.
  - Installing zendframework/zend-stdlib (3.1.0): Downloading (100%)
 Extracting archiveNo patches found for zendframework/zend-stdlib.
Patching is disabled. Skipping.
  - Installing zendframework/zend-escaper (2.5.2): Downloading (100%)
 Extracting archiveNo patches found for zendframework/zend-escaper.
Patching is disabled. Skipping.
  - Installing zendframework/zend-feed (2.8.0): Downloading (100%)
 Extracting archiveNo patches found for zendframework/zend-feed.
Patching is disabled. Skipping.
  - Installing psr/http-message (1.0.1): Downloading (100%)
 Extracting archiveNo patches found for psr/http-message.
Patching is disabled. Skipping.
  - Installing zendframework/zend-diactoros (1.4.0): Downloading (100%)
 Extracting archiveNo patches found for zendframework/zend-diactoros.
Patching is disabled. Skipping.
  - Installing twig/twig (v1.34.4): Downloading (100%)
 Extracting archiveNo patches found for twig/twig.
Patching is disabled. Skipping.
  - Installing symfony/polyfill-mbstring (v1.4.0): Downloading (100%)
 Extracting archiveNo patches found for symfony/polyfill-mbstring.
Patching is disabled. Skipping.
  - Installing symfony/translation (v2.8.26): Downloading (100%)
 Extracting archiveNo patches found for symfony/translation.
Patching is disabled. Skipping.
  - Installing ircmaxell/password-compat (v1.0.4): Downloading (100%)
 Extracting archiveNo patches found for ircmaxell/password-compat.
Patching is disabled. Skipping.
  - Installing symfony/polyfill-php55 (v1.4.0): Downloading (100%)
 Extracting archiveNo patches found for symfony/polyfill-php55.
Patching is disabled. Skipping.
  - Installing symfony/polyfill-php54 (v1.4.0): Downloading (100%)
 Extracting archiveNo patches found for symfony/polyfill-php54.
Patching is disabled. Skipping.
  - Installing symfony/http-foundation (v2.8.26): Downloading (100%)
 Extracting archiveNo patches found for symfony/http-foundation.
Patching is disabled. Skipping.
  - Installing symfony/psr-http-message-bridge (v1.0.0): Downloading (100%)
 Extracting archiveNo patches found for symfony/psr-http-message-bridge.
Patching is disabled. Skipping.
  - Installing symfony/polyfill-iconv (v1.4.0): Downloading (100%)
 Extracting archiveNo patches found for symfony/polyfill-iconv.
Patching is disabled. Skipping.
  - Installing symfony/event-dispatcher (v2.8.26): Downloading (100%)
 Extracting archiveNo patches found for symfony/event-dispatcher.
Patching is disabled. Skipping.
  - Installing psr/log (1.0.2): Downloading (100%)
 Extracting archiveNo patches found for psr/log.
Patching is disabled. Skipping.
  - Installing symfony/debug (v2.8.26): Downloading (100%)
 Extracting archiveNo patches found for symfony/debug.
Patching is disabled. Skipping.
  - Installing symfony/http-kernel (v2.8.26): Downloading (100%)
 Extracting archiveNo patches found for symfony/http-kernel.
Patching is disabled. Skipping.
  - Installing symfony/routing (v2.8.26): Downloading (100%)
 Extracting archiveNo patches found for symfony/routing.
Patching is disabled. Skipping.
  - Installing symfony-cmf/routing (1.4.1): Downloading (100%)
 Extracting archiveNo patches found for symfony-cmf/routing.
Patching is disabled. Skipping.
  - Installing stack/builder (v1.0.4): Downloading (100%)
 Extracting archiveNo patches found for stack/builder.
Patching is disabled. Skipping.
  - Installing paragonie/random_compat (v2.0.10): Downloading (100%)
 Extracting archiveNo patches found for paragonie/random_compat.
Patching is disabled. Skipping.
  - Installing masterminds/html5 (2.2.2): Downloading (100%)
 Extracting archiveNo patches found for masterminds/html5.
Patching is disabled. Skipping.
  - Installing guzzlehttp/psr7 (1.4.2): Downloading (100%)
 Extracting archiveNo patches found for guzzlehttp/psr7.
Patching is disabled. Skipping.
  - Installing guzzlehttp/promises (v1.3.1): Downloading (100%)
 Extracting archiveNo patches found for guzzlehttp/promises.
Patching is disabled. Skipping.
  - Installing guzzlehttp/guzzle (6.3.0): Downloading (100%)
 Extracting archiveNo patches found for guzzlehttp/guzzle.
Patching is disabled. Skipping.
  - Installing doctrine/lexer (v1.0.1): Downloading (100%)
 Extracting archiveNo patches found for doctrine/lexer.
Patching is disabled. Skipping.
  - Installing egulias/email-validator (1.2.14): Downloading (100%)
 Extracting archiveNo patches found for egulias/email-validator.
Patching is disabled. Skipping.
  - Installing easyrdf/easyrdf (0.9.1): Downloading (100%)
 Extracting archiveNo patches found for easyrdf/easyrdf.
Patching is disabled. Skipping.
  - Installing doctrine/inflector (v1.2.0): Downloading (100%)
 Extracting archiveNo patches found for doctrine/inflector.
Patching is disabled. Skipping.
  - Installing doctrine/collections (v1.4.0): Downloading (100%)
 Extracting archiveNo patches found for doctrine/collections.
Patching is disabled. Skipping.
  - Installing doctrine/cache (v1.6.2): Downloading (100%)
 Extracting archiveNo patches found for doctrine/cache.
Patching is disabled. Skipping.
  - Installing doctrine/annotations (v1.2.7): Downloading (100%)
 Extracting archiveNo patches found for doctrine/annotations.
Patching is disabled. Skipping.
  - Installing doctrine/common (v2.7.3): Downloading (100%)
 Extracting archiveNo patches found for doctrine/common.
Patching is disabled. Skipping.
  - Installing composer/semver (1.4.2): Downloading (100%)
 Extracting archiveNo patches found for composer/semver.
Patching is disabled. Skipping.
  - Installing asm89/stack-cors (1.1.0): Downloading (100%)
 Extracting archiveNo patches found for asm89/stack-cors.
Patching is disabled. Skipping.
  - Installing symfony/validator (v2.8.26): Downloading (100%)
 Extracting archiveNo patches found for symfony/validator.
Patching is disabled. Skipping.
  - Installing symfony/serializer (v2.8.26): Downloading (100%)
 Extracting archiveNo patches found for symfony/serializer.
Patching is disabled. Skipping.
  - Installing symfony/process (v2.8.26): Downloading (100%)
 Extracting archiveNo patches found for symfony/process.
Patching is disabled. Skipping.
  - Installing symfony/dependency-injection (v2.8.26): Downloading (100%)
 Extracting archiveNo patches found for symfony/dependency-injection.
Patching is disabled. Skipping.
  - Installing symfony/console (v2.8.26): Downloading (100%)
 Extracting archiveNo patches found for symfony/console.
Patching is disabled. Skipping.
  - Installing symfony/polyfill-apcu (v1.4.0): Downloading (100%)
 Extracting archiveNo patches found for symfony/polyfill-apcu.
Patching is disabled. Skipping.
  - Installing symfony/class-loader (v2.8.26): Downloading (100%)
 Extracting archiveNo patches found for symfony/class-loader.
Patching is disabled. Skipping.
  - Installing drupal/core (8.3.6): Downloading (100%)
 Extracting archiveNo patches found for drupal/core.
Patching is disabled. Skipping.
  - Installing drupal/admin_toolbar (1.19.0): Downloading (100%)
 Extracting archiveNo patches found for drupal/admin_toolbar.
Patching is disabled. Skipping.
  - Installing psr/simple-cache (1.0.0): Downloading (100%)
 Extracting archiveNo patches found for psr/simple-cache.
Patching is disabled. Skipping.
  - Installing psr/cache (1.0.1): Downloading (100%)
 Extracting archiveNo patches found for psr/cache.
Patching is disabled. Skipping.
  - Installing symfony/cache (v3.3.6): Downloading (100%)
 Extracting archiveNo patches found for symfony/cache.
Patching is disabled. Skipping.
  - Installing symfony/expression-language (v3.3.6): Downloading (100%)
 Extracting archiveNo patches found for symfony/expression-language.
Patching is disabled. Skipping.
  - Installing symfony/dom-crawler (v3.3.6): Downloading (100%)
 Extracting archiveNo patches found for symfony/dom-crawler.
Patching is disabled. Skipping.
  - Installing symfony/css-selector (v2.8.26): Downloading (100%)
 Extracting archiveNo patches found for symfony/css-selector.
Patching is disabled. Skipping.
  - Installing jakub-onderka/php-console-color (0.1): Downloading (100%)
 Extracting archiveNo patches found for jakub-onderka/php-console-color.
Patching is disabled. Skipping.
  - Installing jakub-onderka/php-console-highlighter (v0.3.2): Downloading (100%)
 Extracting archiveNo patches found for jakub-onderka/php-console-highlighter.
Patching is disabled. Skipping.
  - Installing dnoegel/php-xdg-base-dir (0.1): Downloading (100%)
 Extracting archiveNo patches found for dnoegel/php-xdg-base-dir.
Patching is disabled. Skipping.
  - Installing nikic/php-parser (v3.1.0): Downloading (100%)
 Extracting archiveNo patches found for nikic/php-parser.
Patching is disabled. Skipping.
  - Installing symfony/var-dumper (v3.3.6): Downloading (100%)
 Extracting archiveNo patches found for symfony/var-dumper.
Patching is disabled. Skipping.
  - Installing psy/psysh (v0.8.11): Downloading (100%)
 Extracting archiveNo patches found for psy/psysh.
Patching is disabled. Skipping.
  - Installing gabordemooij/redbean (v4.3.4): Downloading (100%)
 Extracting archiveNo patches found for gabordemooij/redbean.
Patching is disabled. Skipping.
  - Installing vlucas/phpdotenv (v2.4.0): Downloading (100%)
 Extracting archiveNo patches found for vlucas/phpdotenv.
Patching is disabled. Skipping.
  - Installing drupal/console-dotenv (0.3.0): Downloading (100%)
 Extracting archiveNo patches found for drupal/console-dotenv.
Patching is disabled. Skipping.
  - Installing webmozart/assert (1.2.0): Downloading (100%)
 Extracting archiveNo patches found for webmozart/assert.
Patching is disabled. Skipping.
  - Installing webmozart/path-util (2.3.0): Downloading (100%)
 Extracting archiveNo patches found for webmozart/path-util.
Patching is disabled. Skipping.
  - Installing webflo/drupal-finder (0.3.0): Downloading (100%)
 Extracting archiveNo patches found for webflo/drupal-finder.
Patching is disabled. Skipping.
  - Installing symfony/filesystem (v3.3.6): Downloading (100%)
 Extracting archiveNo patches found for symfony/filesystem.
Patching is disabled. Skipping.
  - Installing symfony/config (v3.2.13): Downloading (100%)
 Extracting archiveNo patches found for symfony/config.
Patching is disabled. Skipping.
  - Installing stecman/symfony-console-completion (0.7.0): Downloading (100%)
 Extracting archiveNo patches found for stecman/symfony-console-completion.
Patching is disabled. Skipping.
  - Installing drupal/console-en (1.0.0): Downloading (100%)
 Extracting archiveNo patches found for drupal/console-en.
Patching is disabled. Skipping.
  - Installing dflydev/placeholder-resolver (v1.0.2): Downloading (100%)
 Extracting archiveNo patches found for dflydev/placeholder-resolver.
Patching is disabled. Skipping.
  - Installing dflydev/dot-access-data (v1.1.0): Downloading (100%)
 Extracting archiveNo patches found for dflydev/dot-access-data.
Patching is disabled. Skipping.
  - Installing dflydev/dot-access-configuration (v1.0.2): Downloading (100%)
 Extracting archiveNo patches found for dflydev/dot-access-configuration.
Patching is disabled. Skipping.
  - Installing drupal/console-core (1.0.0): Downloading (100%)
 Extracting archiveNo patches found for drupal/console-core.
Patching is disabled. Skipping.
  - Installing alchemy/zippy (0.4.3): Downloading (100%)
 Extracting archiveNo patches found for alchemy/zippy.
Patching is disabled. Skipping.
  - Installing drupal/console (1.0.0): Downloading (100%)
 Extracting archiveNo patches found for drupal/console.
Patching is disabled. Skipping.
  - Installing commerceguys/intl (v0.7.4): Downloading (100%)
 Extracting archiveNo patches found for commerceguys/intl.
Patching is disabled. Skipping.
  - Installing drupal/state_machine (1.0.0-beta3): Downloading (100%)
 Extracting archiveNo patches found for drupal/state_machine.
Patching is disabled. Skipping.
  - Installing drupal/entity (dev-1.x 6bf9d50): Cloning 6bf9d5039a2fa4a9cd596d0a3d6b41b5d70f04cb from cache
No patches found for drupal/entity.
Patching is disabled. Skipping.
  - Installing drupal/profile (dev-1.x 75637f8): Cloning 75637f87825aed9bb0cad0d912ee3bbe88383610 from cache
No patches found for drupal/profile.
Patching is disabled. Skipping.
  - Installing drupal/entity_reference_revisions (1.3.0): Downloading (100%)
 Extracting archiveNo patches found for drupal/entity_reference_revisions.
Patching is disabled. Skipping.
  - Installing drupal/inline_entity_form (1.0.0-beta1): Downloading (100%)
 Extracting archiveNo patches found for drupal/inline_entity_form.
Patching is disabled. Skipping.
  - Installing commerceguys/enum (v1.0): Downloading (100%)
 Extracting archiveNo patches found for commerceguys/enum.
Patching is disabled. Skipping.
  - Installing commerceguys/addressing (v1.0.0-beta3): Downloading (100%)
 Extracting archiveNo patches found for commerceguys/addressing.
Patching is disabled. Skipping.
  - Installing drupal/address (1.1.0): Downloading (100%)
 Extracting archiveNo patches found for drupal/address.
Patching is disabled. Skipping.
  - Installing drupal/commerce (2.0.0-beta3): Downloading (100%)
 Extracting archiveNo patches found for drupal/commerce.
Patching is disabled. Skipping.
  - Installing drupal/search_api (1.3.0): Downloading (100%)
 Extracting archiveNo patches found for drupal/search_api.
Patching is disabled. Skipping.
  - Installing html2text/html2text (4.0.1): Downloading (100%)
 Extracting archiveNo patches found for html2text/html2text.
Patching is disabled. Skipping.
  - Installing swiftmailer/swiftmailer (v5.4.8): Downloading (100%)
 Extracting archiveNo patches found for swiftmailer/swiftmailer.
Patching is disabled. Skipping.
  - Installing drupal/mailsystem (4.1.0): Downloading (100%)
 Extracting archiveNo patches found for drupal/mailsystem.
Patching is disabled. Skipping.
  - Installing drupal/swiftmailer (1.0.0-beta1): Downloading (100%)
 Extracting archiveNo patches found for drupal/swiftmailer.
Patching is disabled. Skipping.
  - Installing symfony/browser-kit (v3.3.6): Downloading (100%)
 Extracting archiveNo patches found for symfony/browser-kit.
Patching is disabled. Skipping.
  - Installing fabpot/goutte (v3.2.1): Downloading (100%)
 Extracting archiveNo patches found for fabpot/goutte.
Patching is disabled. Skipping.
  - Installing behat/mink (v1.7.1): Downloading (100%)
 Extracting archiveNo patches found for behat/mink.
Patching is disabled. Skipping.
  - Installing behat/mink-browserkit-driver (v1.3.2): Downloading (100%)
 Extracting archiveNo patches found for behat/mink-browserkit-driver.
Patching is disabled. Skipping.
  - Installing behat/mink-goutte-driver (v1.2.1): Downloading (100%)
 Extracting archiveNo patches found for behat/mink-goutte-driver.
Patching is disabled. Skipping.
  - Installing jcalderonzumba/gastonjs (v1.0.3): Downloading (100%)
 Extracting archiveNo patches found for jcalderonzumba/gastonjs.
Patching is disabled. Skipping.
  - Installing jcalderonzumba/mink-phantomjs-driver (v0.3.3): Downloading (100%)
 Extracting archiveNo patches found for jcalderonzumba/mink-phantomjs-driver.
Patching is disabled. Skipping.
  - Installing mikey179/vfsstream (v1.6.5): Downloading (100%)
 Extracting archiveNo patches found for mikey179/vfsstream.
Patching is disabled. Skipping.
  - Installing sebastian/version (1.0.6): Downloading (100%)
 Extracting archiveNo patches found for sebastian/version.
Patching is disabled. Skipping.
  - Installing sebastian/global-state (1.1.1): Downloading (100%)
 Extracting archiveNo patches found for sebastian/global-state.
Patching is disabled. Skipping.
  - Installing sebastian/recursion-context (1.0.5): Downloading (100%)
 Extracting archiveNo patches found for sebastian/recursion-context.
Patching is disabled. Skipping.
  - Installing sebastian/exporter (1.2.2): Downloading (100%)
 Extracting archiveNo patches found for sebastian/exporter.
Patching is disabled. Skipping.
  - Installing sebastian/environment (1.3.8): Downloading (100%)
 Extracting archiveNo patches found for sebastian/environment.
Patching is disabled. Skipping.
  - Installing sebastian/diff (1.4.3): Downloading (100%)
 Extracting archiveNo patches found for sebastian/diff.
Patching is disabled. Skipping.
  - Installing sebastian/comparator (1.2.4): Downloading (100%)
 Extracting archiveNo patches found for sebastian/comparator.
Patching is disabled. Skipping.
  - Installing doctrine/instantiator (1.0.5): Downloading (100%)
 Extracting archiveNo patches found for doctrine/instantiator.
Patching is disabled. Skipping.
  - Installing phpunit/php-text-template (1.2.1): Downloading (100%)
 Extracting archiveNo patches found for phpunit/php-text-template.
Patching is disabled. Skipping.
  - Installing phpunit/phpunit-mock-objects (2.3.8): Downloading (100%)
 Extracting archiveNo patches found for phpunit/phpunit-mock-objects.
Patching is disabled. Skipping.
  - Installing phpunit/php-timer (1.0.9): Downloading (100%)
 Extracting archiveNo patches found for phpunit/php-timer.
Patching is disabled. Skipping.
  - Installing phpunit/php-file-iterator (1.4.2): Downloading (100%)
 Extracting archiveNo patches found for phpunit/php-file-iterator.
Patching is disabled. Skipping.
  - Installing phpunit/php-token-stream (1.4.11): Downloading (100%)
 Extracting archiveNo patches found for phpunit/php-token-stream.
Patching is disabled. Skipping.
  - Installing phpunit/php-code-coverage (2.2.4): Downloading (100%)
 Extracting archiveNo patches found for phpunit/php-code-coverage.
Patching is disabled. Skipping.
  - Installing phpdocumentor/reflection-common (1.0): Downloading (100%)
 Extracting archiveNo patches found for phpdocumentor/reflection-common.
Patching is disabled. Skipping.
  - Installing phpdocumentor/type-resolver (0.3.0): Downloading (100%)
 Extracting archiveNo patches found for phpdocumentor/type-resolver.
Patching is disabled. Skipping.
  - Installing phpdocumentor/reflection-docblock (3.2.2): Downloading (100%)
 Extracting archiveNo patches found for phpdocumentor/reflection-docblock.
Patching is disabled. Skipping.
  - Installing phpspec/prophecy (v1.7.0): Downloading (100%)
 Extracting archiveNo patches found for phpspec/prophecy.
Patching is disabled. Skipping.
  - Installing phpunit/phpunit (4.8.36): Downloading (100%)
 Extracting archiveNo patches found for phpunit/phpunit.
zendframework/zend-feed suggests installing zendframework/zend-cache (Zend\Cache component, for optionally caching feeds between requests)
zendframework/zend-feed suggests installing zendframework/zend-db (Zend\Db component, for use with PubSubHubbub)
zendframework/zend-feed suggests installing zendframework/zend-http (Zend\Http for PubSubHubbub, and optionally for use with Zend\Feed\Reader)
zendframework/zend-feed suggests installing zendframework/zend-servicemanager (Zend\ServiceManager component, for easily extending ExtensionManager implementations)
zendframework/zend-feed suggests installing zendframework/zend-validator (Zend\Validator component, for validating email addresses used in Atom feeds and entries ehen using the Writer subcomponent)
paragonie/random_compat suggests installing ext-libsodium (Provides a modern crypto API that can be used to generate random bytes.)
easyrdf/easyrdf suggests installing ml/json-ld (~1.0)
symfony/validator suggests installing symfony/intl ()
symfony/validator suggests installing symfony/property-access (For using the 2.4 Validator API)
symfony/serializer suggests installing symfony/property-access (For using the ObjectNormalizer.)
symfony/dependency-injection suggests installing symfony/proxy-manager-bridge (Generate service proxies to lazy load them)
symfony/var-dumper suggests installing ext-symfony_debug ()
psy/psysh suggests installing ext-pdo-sqlite (The doc command requires SQLite to work.)
psy/psysh suggests installing hoa/console (A pure PHP readline implementation. You'll want this if your PHP install doesn't already support readline or libedit.)
alchemy/zippy suggests installing guzzle/guzzle (To use the GuzzleTeleporter with Guzzle 3)
commerceguys/addressing suggests installing symfony/intl (to use it as the source of country data)
behat/mink suggests installing behat/mink-selenium2-driver (slow, but JS-enabled driver for any app (requires Selenium2))
behat/mink suggests installing behat/mink-zombie-driver (fast and JS-enabled headless driver for any app (requires node.js))
sebastian/global-state suggests installing ext-uopz (*)
phpunit/php-code-coverage suggests installing ext-xdebug (>=2.2.1)
phpunit/phpunit suggests installing phpunit/php-invoker (~1.1)
Writing lock file
Generating autoload files
Downloading (100%)Downloading (100%)Downloading (100%)Downloading (100%)Downloading (100%)Downloading (100%)Downloading (100%)Downloading (100%)Downloading (100%)Downloading (100%)Downloading (100%)Downloading (100%)Downloading (100%)Downloading (100%)Downloading (100%)Creating packages services cache file:
/var/www/drupal/mystore/vendor/drupal/console/extend.console.uninstall.services.yml
> post-update-cmd: DrupalProject\composer\ScriptHandler::createRequiredFiles
Create a sites/default/settings.php file with chmod 0666
Create a sites/default/services.yml file with chmod 0666
Create a sites/default/files directory with chmod 0777
Do you want to remove the existing VCS (.git, .svn..) history? [Y,n]? y

Answer: This is something I haven't seen before.
Look at the output you shared:
"Installing drupal/commerce (2.0.0-beta3)"
The current version is RC1, beta3 is from last November. That's why you're getting the message about missing modules.
What makes this problem even weirder is that you got the most recent version of project-base, as well as Address. You only received an ancient version of Commerce.
Try deleting the folder and rerunning the command. If that still gives you the same result, try "composer clear-cache" first, then the command.
Comment: Additionally a `composer why drupal/commerce` might give some insight as to why its downloading an older version of commerce.
Comment: I've tried it again with the clear-cache command, I even removed the apt-version of composer and downloaded the latest composer from https://getcomposer.org/install, but I keep getting the same version (Installing drupal/commerce (2.0.0-beta3): Downloading (100%)).
Comment: Do you think this has something to do with me being on debian stable and having some older packages from apt, or is this some other bug in the whole composer process?
Comment: System packages don't affect Composer. It sounds like a hiccup on the Composer side (a stale cache somewhere, perhaps).
Comment: I just tried the command locally and it completed fine, giving me RC1. Can you try appending "--verbose" to the command, so that we can get more output? Might help spot the issue.
Comment: Also, please tell us which version of composer you are using, it may be a composer bug in handling the order of packages in the metadata and choosing the wrong one.
Comment: Thanks for the updates. I was reading a bit more on getcomposer.org and I just figured the whole issue is probably the composer.json file that I missed out on. The 'composer why drupal/commerce' kindly pointed it out as confirmation.
I'll try and figure out where I can get that file and I'll get back to confirm or deny that that's the issue. Cheers.
Comment: OK, I'm about to give up on this :( The documentation is so confusing and spread out so I'm just going to ask... where can I get a composer.json so I can get this site up and running? `composer why drupal/commerce` gives me an error _Could not find package "drupal/commerce" in your project_.
Comment: composer create-project clones the project from github.com/drupalcommerce/project-base, which has the composer.json. Then it runs composer install. Anyway, we're still missing the "--verbose" output.
Comment: Sorry Bojan, I updated the original post with the verbose output. It says patch available but patching is disabled. I am sure I didn't disable anything like that out of my free will, I like things to be up to date.
Answer: I just ran into this issue, using the same installation method.
I tried manually requiring the newer version with:
composer require "drupal/commerce 2.x-dev"

Which gave me an error:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for drupal/commerce 2.x-dev -> satisfiable by drupal/commerce[2.x-dev].
- drupal/commerce 2.x-dev requires ext-bcmath * -> the requested PHP extension bcmath is missing from your system.

To enable extensions, verify that they are enabled in your .ini files:
- /etc/php/cli-php7.0/php.ini
- /etc/php/cli-php7.0/ext-active/opcache.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

Installation failed, reverting ./composer.json to its original content.

Solution:
Updating PHP to use bcmath and restarting the web server solved the problem for me.  Installation is now progressing normally.
Comment: Dude, you da man! :D
Comment: Wow, that's crazy. Jakke didn't have bcmath, so Composer selected the last release without the bcmath requirement, which is beta3. It produced no message to indicate what happened. Looks like we'll need to remove that requirement from composer.json and rely on Drupal itself enforcing it.

Why don't I get a module dependencies?


Angular JS filter ng-repeat with field AND dropdown

Question: I have seen a lot of conflicting answers on the web about this, but I am looking for the most succinct way to accomplish this.
I have data that is a list of countries of the world, including, name, ISO alpha code, region of the world, etc.
I have an ng-repeat in a table to display this:

I have a text field and a dropdown that needs to filter the list.
The text field is supposed to filter by country name:  either by matching the ISO alpha code or the country name.
<input type="text" id="countrySearch" placeholder="Country" ng-model="countryQuery">

This works with this in the Controller:
    $scope.countryFilter = function (value) {
      if (angular.isUndefined($scope.countryQuery) || $scope.countryQuery === '') {
        return true;
      }
       return value.name.indexOf($scope.countryQuery) >= 0 || value.alpha_2.indexOf($scope.countryQuery) >= 0;
    };

The bane of my existence is how to bring the dropdown into the mix.  The dropdown is using an array of objects with values for regions of the world, as in
$scope.regionMenu = [
    {
      label: 'Show All',
      value: ''
    },
    {
      label: 'EU',
      value: 'Europe'
    },...

and
<select ng-model="region" ng-options="s.value as s.label for s in regionMenu"></select>

The goal is to have the input field work together, so the filteredItems would show a row if the value typed in matches:
(ISO alpha-2 OR Name) AND (region chosen in menu)
Any help on how to edit the countryFilter function or to totally rewrite it to accomplish this much appreciated.
Answer: I can think of two options:
Solution 1: Chain another filter
This solution is easier, but is less efficient, since you can end up scanning all the elements in the array twice (instead of once in solution 2).
Controller:
$scope.regionFilter = function (value) {
  if (angular.isUndefined($scope.region) || $scope.region === '') {
    return true;
  }
  return value.region === $scope.region;
};

Template:

Solution 2: Join the filters
$scope.countryFilter = function (value) {
  var passCountry;
  if (angular.isUndefined($scope.countryQuery) || $scope.countryQuery === '') {
    passCountry = true;
  }
  else {
    passCountry = value.name.indexOf($scope.countryQuery) >= 0 || value.alpha_2.indexOf($scope.countryQuery) >= 0;
  }

  var passRegion;
  if (angular.isUndefined($scope.region) || $scope.region === '') {
    passRegion = true;
  }
  else {
    passRegion = value.region === $scope.region;
  }

  return passCountry && passRegion;
};


Como calcular tamanho de uma div header para fazer o espacamento correto?

Question: Olá,
Tenho um site com um menu fixed no topo o qual coloquei a classe header, e ele acompanha a barra de rolagem, sei que minha outra div com a classe content precisa de um margin de acordo com a altura do header para nao ficar tampado. Minha duvida é como eu faço isso de forma flexivel. Que independente da altura do header o margin da div contain seja alterado sem eu precisar mudar o margin toda hora.

html {
  background-color: #bcbcbc;
}

.header {
  background-color: white;
  height: 100px;
  top: 0;
  left: 0;
  width: 100%;
  position: fixed;
}

.header h2{
     text-align: center;
}

.content{
  height: 100%;

}
.footer {
  background-color: black;
  height: 100px;
  width: 100%;

}

FIXED

Conteudo

Conteudo

Conteudo

Conteudo

Conteudo

Conteudo

Answer: Vc pode substituir o position:fixed por position:sticky vc pode ler mais sobre aqui: https://css-tricks.com/position-sticky-2/
Conforme o Jorge falou no comentário segundo o site Can I Use essa propriedade não funciona no IE  https://caniuse.com/#feat=css-sticky Mas tenha em mente que o Windows 10 que é o atual o browser padrão é o Edge não o IE, e que daqui para frente o IE só tende a sumir, e pode ser que nem venha mais nas próximas versões do Windows...
Veja como fica o resultado, coloquei uma transparência no topo só para vc ver que não tem nada por baixo...

html {
    background-color: #bcbcbc;
}

body {
    margin: 0;
}

.header {
    background-color: rgba(255, 255, 255, 0.5);
    height: 100px;
    top: 0;
    left: 0;
    width: 100%;
    position: sticky;
}

.header h2 {
    text-align: center;
    margin: 0;
}

.content {
    height: 100%;

}

.footer {
    background-color: black;
    height: 100px;
    width: 100%;

}

FIXED

Conteudo

Conteudo

Conteudo

Conteudo

Conteudo

Conteudo

Comment: Vale lembrar que  `position:sticky` só tem suporte em navagadores mais modernos, IE por exemplo não suporta. Seria legal colocar a referência para consultas futuras: https://caniuse.com/#feat=css-sticky
Comment: @Jorge.M sem problemas fiz a observação na resposta.


SQL Search query error in Laravel 5.3

Question: I am trying to build a search query. I got following error, It seems syntax error of sql.

SQLSTATE[HY093]: Invalid parameter number (SQL: select * from products
  where styles = Abstract , Abstract and subject = ? )

Why this error occurred ?
How to figure it out ?
My code as follows
if (isset($request->search)) {

    //GET ALL INPUT FROM THE REQUEST
    $query_strings = $request->all();

    //PULL OUT ANY EMPTY FIELD FROM THE REQUEST
    $filtered_array = array_filter($request->all());

    //remove the last item
    array_pop($filtered_array);

    //BUILD A QUERY
    $sql = array();
    $values = array();
    $x = 1;
    foreach ( $filtered_array as $key =>$value ) {
        if($x < count($filtered_array)){
            $sql[]=" $key = ? and ";
            $values[] =" $value , ";
          } else {
            $sql[]=" $key = ? ";
            $values[] ="  $value  ";
          }
            $x++;
     }

     $fields = join(' ',  $sql);
     $v = join(' ',$values);

     dd( \DB::select("select * from products where {$fields} ", [$v]));

}

Comment: It's Laravel you're talking about and you're using none of it :( Also can you explain a bit more where you're getting an error and what error are you getting.
Answer: When you're passing some values, you should add ? placeholder:
\DB::select("select * from products where ?", [$value]));

Answer: This is a bit of a stretch and I doubt it will work as is on the first try. But I really suggest you try and make use of the Laravel's query builder.
This code assumes you're passing 'products' table column names as names of GET or POST parameters and values you want to query by as values. For example:
url.com?price=200&size=2

Where 'price' and 'size' are column names of 'products' table.
Code:
// Check if request has 'search' parameter
if($request->has('search')) {
  // $filtered_array now has all parameters that were passed to the controller
  $filtered_array = $request->all();

  // Start a query on table 'products'. Laravel style (more: https://laravel.com/docs/5.3/queries)
  $query = \DB::table('products');

  // For each parameter passed to the controller, we make "and where products.$key = $value" statement in the query
  foreach($filtered_array as $key => $value) {
    $query->where($key, '=', $value);
  }

  // Tell the query builder to get the results and save it to $results variable
  $results = $query->get();
}

This will undoubtedly cause a lot of errors as anyone can send anything as GET/POST parameters and query by that (which will throw SQL error that the column doesn't exist).
You should change the $filtered_array = $request->all() to:
$filtered_array = $request->only(['id', 'price', 'size']);

This way you will store only the parameters you specify in the ->only(array) in the $filtered_array and ignore all the others. So you should replace 'id', 'price' and 'size' with all the columns of the 'products' table you wish to query by.

SQL Search query error in Laravel 5.3


How to automate PDF form-filling in Java

Question: I am doing some "pro bono" development for a food pantry near where I live. They are inundated with forms and paperwork, and I would like to develop a system that simply reads data from their MySQL server (which I set up for them on a previous project) and feeds data into PDF versions of all the forms they are required to fill out. This will help them out enormously and save them a lot of time, as well as get rid of a lot of human errors that are made when filling out these forms.
Not knowing anything about the internals of PDF files, I can foresee two avenues here:

Harder Way: It is possible to scan a paper document, turn it into a PDF, and then have software that "fills out" the PDF simply by saying "add text except blah to the following (x,y) coordinates..."; or
Easier Way: PDF specification already allows for the construct of "fields" that can be filled out; this way I just write code that says "add text excerpt blah to the field called *address_value*...", etc.

So my first question is: which of the two avenues am I facing? Does PDF have a concept of "fields" or do I need to "fill out" these documents by telling the PDF library the pixel coordinates of where to place data?
Second, I obviously need an open source (and Java) library to do this. iText seems to be a good start but I've heard it can be difficult to work with. Can anyone lend some ideas or general recommendations here? Thanks in advance!
Answer: You can easily merge data into PDF's fields using the FDF(Form Data Format) technology.
Adobe provides a library to do that :  Acrobat Forms Data Format (FDF) Toolkit
Also Apache PDFBox can be used to do that.
Comment: No, FDF specify an XML format of the the data to be merged into a PDF document and then a new PDF is created with the data merged, see these PDFBox examples :  http://kickjava.com/src/org/pdfbox/ImportFDF.java.htm  and  http://grepcode.com/file_/repo1.maven.org/maven2/org.apache.pdfbox/pdfbox/1.6.0/org/apache/pdfbox/examples/fdf/SetField.java/?v=source
Comment: Thanks for the suggestion @RealHowTo, but the FDF seems to only *process* data that is submitted from forms. I'm looking to simply place data into a form so that it can then be printed and sent out via postal mail!
Answer: Please take a look at the chapter about interactive forms in the free ebook The Best iText Questions on StackOverflow. It bundles the answers to questions such as:

How to fill out a pdf file programatically?
How can I flatten a XFA PDF Form using iTextSharp?
Checking off pdf checkbox with itextsharp
How to continue field output on a second page?
finding out required fields to fill in pdf file
and so on...

Or you can watch this video where I explain how to use forms for reporting step by step.
See for instance:
public void manipulatePdf(String src, String dest) throws DocumentException, IOException {
    PdfReader reader = new PdfReader(src);
    PdfStamper stamper = new PdfStamper(reader,
            new FileOutputStream(dest));
    AcroFields fields = stamper.getAcroFields();
    fields.setField("name", "CALIFORNIA");
    fields.setField("abbr", "CA");
    fields.setField("capital", "Sacramento");
    fields.setField("city", "Los Angeles");
    fields.setField("population", "36,961,664");
    fields.setField("surface", "163,707");
    fields.setField("timezone1", "PT (UTC-8)");
    fields.setField("timezone2", "-");
    fields.setField("dst", "YES");
    stamper.setFormFlattening(true);
    stamper.close();
    reader.close();
}

Comment: FYI, a commercial license is required for iText unless the application you're using it in is open source
Comment: The OP is doing pro bono development for a food pantry (food bank). I think commercial software development is *really* not the issue here.
Comment: @TimKuehn Your comment isn't accurate. You claim "The link**s** on this answer don't work anymore." I tested them all and they all worked but the last one. In the case of the last one, I got a Page Not Found page with a search box. When I entered "reporting" in the search box, the first hit pointed at the desired page.
Answer: public void fillPDF()
{

     try {
            PDDocument pDDocument = PDDocument.load(new File("D:/pdf/pdfform.pdf")); // pdfform.pdf is input file
            PDAcroForm pDAcroForm = pDDocument.getDocumentCatalog().getAcroForm();

         PDField field = pDAcroForm.getField("Given Name Text Box");

          field.setValue("firstname");
          field = pDAcroForm.getField("Family Name Text Box");
          field.setValue("lastname");
          field = pDAcroForm.getField("Country Combo Box");
          field.setValue("Country");
          System.out.println("country combo" );
          field = pDAcroForm.getField(" Driving License Check Box");

          field = pDAcroForm.getField("Favourite Colour List Box");
        System.out.println("country combo"+ field.isRequired());
          pDDocument.save("D:/pdf/pdf-java-output.pdf");
             pDDocument.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
}

Comment: This is from PDF Box. https://github.com/TomRoush/PdfBox-Android


How should I refer to this random variable?

Question: Let $(\Omega,\mathscr{F},\mathbb{P})$ be a probability space and let $(\Gamma,\mathscr{G})$ be a measurable space. Then a random probability measure on $(\Gamma,\mathscr{G})$ can be defined as a function $M\colon \Omega \times \mathscr{G} \to [0,1]$ such that

For all $\omega \in \Omega$, the function $M_\omega\colon A \mapsto M(\omega,A)$ is a probability measure on $(\Gamma,\mathscr{G})$,
For all $A \in \mathscr{G}$, the function $M_A\colon \omega \mapsto M(\omega,A)$ is a random variable on $(\Omega,\mathscr{F},\mathbb{P})$.

This definition is based on chapter VI of Çınlar's Probability and Stochastics.
Let $X$ be a measurable function on $(\Gamma,\mathscr{G})$. Then $X$ is a random variable on each probability space $(\Gamma,\mathscr{G},M_\omega)$, and Fubini's theorem implies that the function
$$
\omega \mapsto \int_\Gamma  X \,\mathrm{d}M_\omega
$$
is a random variable on $(\Omega,\mathscr{F},\mathbb{P})$. Is there any particular name for such a random variable? From what I understand here, I would be tempted to call this random variable the "random expectation" of $X$ with respect to the random probability measure $M$. However, I've never seen the phrase "random expectation" anywhere, so I'm not sure if it is indeed a correct interpretation, or if another name is usually used.
Answer: A variation is to realize everything on the same space (the sensible thing to do in probability: enrich your measured space as needed):
$$\begin{align}
Y & = \Omega \times \Gamma, \\
\mathcal{Y} & = \mathcal{F} \otimes \mathcal{G}, \\
\mu (B \times A) & = \int_B M_\omega (A) \ d\mathbb{P} (\omega).
\end{align}$$
Then $(Y, \mathcal{Y}, \mu)$ is a probabilized space. We can define $X = X(\gamma)$ on $Y$, but depending only on the second coordinate. Then
$$\int_\Gamma X(\gamma) \ d M_\omega (\gamma) = \mathbb{E} (X|\omega),$$
so you are looking at the conditional expectation of $X$ knowing $\omega$.
Comment: Thanks! I did not see it this way, but indeed it also makes sense to combine the spaces.