Qooxdoo Layout issues

Question: I have been using qooxdoo now for 3 days so, it s just the begining but obviously I do already have some troubles.
It is about VBox HBox... I don t really understaind how it is working. I saw the online documentation and forums but whatever I tried I wasn t able to obtain the same result with my code (except copy-past). Hence, do you have some tips ?
Also may you help me with my code ?
I would like to have 2 tabviews (that is good) in which I want 2 groupboxs. The thing is I can display the groupbox but the "auto scaling" cut the text and I can t figure out why.
Thank you in advance.
Edit : (solution)
The answer is not working with a embed.Html as wanted initaly but with a Label (result is easier). My goal was to use some html codes for the shape of my text. Hence some 'translations' were madatory. As the basic.Label allows this kind of thing, it had been used.
Here my code :
Application.js
qx.Class.define("Q.Application",
{
  extend : qx.application.Standalone,
  members :
  {
    main : function()
    {
      this.base(arguments);
      if (qx.core.Environment.get("qx.debug"))
      {
        qx.log.appender.Native;
        qx.log.appender.Console;
      }
      var  main = new Q.Windows();
      main.open();
    }
  }
});

Windows.js :
qx.Class.define("Q.Windows",
{
  extend : qx.ui.window.Window,

    construct : function()
    {

      this.base(arguments, "windows");
      this.setWidth(600);
      this.setHeight(700);
      this.setResizable(true);
      var layout = new qx.ui.layout.Grow();
    this.setLayout(layout);

// ############################ CREATION SHAPE PAGE ########################

      var tabView = new qx.ui.tabview.TabView();
      this.add(tabView);

// ############################ Page UN ########################
// ############################ Page UN ########################

      var page1 = new qx.ui.tabview.Page("History", "");
      page1.setLayout(new qx.ui.layout.Grow());
      tabView.add(page1);
// ############################ Backgroung page ########################
      var group1 = new qx.ui.groupbox.GroupBox(this.tr(""));
      group1.setLayout(new qx.ui.layout.Grow());

// ############################ Introduction #########################

      var htmlp1 = "
 For more than 50 years hadron electromagnetic form factors are considered fundamental quantities for non point-like particles. They parametrize the internal structure of hadrons.

Nucleons

This database collects all data and their references in the scattering (space-like) and in the annihilation (time-like) region, as they were published in the original articles. Experiments and theoretical developments are ongoing. Space-like measurements are based on unpolarized (Rosenbluth separation) and polarized (Akhiezer-Rekalo method) electron elastic scattering off protons and, for neutron, on electron scattering off light nuclei. In the time-like region the reactions e⁺e⁻→ pp̄ (accompanied or not by initial state radiation) and pp̄ → e⁺e⁻ allow to extract form factors relying on a precise angular distribution.
 ";
      var embedp1 = new qx.ui.embed.Html(htmlp1);
      group1.add(embedp1);

// ############################ Nucleon #########################
      page1.add(group1);

// ############################ Page DEUX ########################
// ############################ Page DEUX ########################

      var page2 = new qx.ui.tabview.Page("Computation", "");
      page2.setLayout(new qx.ui.layout.Grow());
      tabView.add(page2);

// ############################ Backgroung page ########################

      var group2 = new qx.ui.groupbox.GroupBox(this.tr(""));
      group2.setLayout(new qx.ui.layout.VBox(10));

// ############################ Objectif #########################

      var fs1 = new qx.ui.groupbox.GroupBox(this.tr(""));
      fs1.setLayout(new qx.ui.layout.Grow());
      var htmlp2 ="This is a qooxdoo application skeleton which is used as a template. The 'create-application.py' script (usually under tool/bin/create-application.py)will use this and expand it into a self-contained qooxdoo application which can then be further extended. Please refer to the script and other documentationfor further information."
      var embedp2 = new qx.ui.embed.Html(htmlp2);

      fs1.add(embedp2);
      group2.add(fs1);

// ############################ Simul #########################

     var fs = new qx.ui.groupbox.GroupBox(this.tr("Choice"));
     fs.setLayout(new qx.ui.layout.Grow());

//Setup of the checkboxes

         var mainLayout = new qx.ui.layout.Grid(0,0);
         mainLayout.setSpacing(10);

         var container = new qx.ui.container.Composite(mainLayout);
         container.setPadding(20);

         var slp = new qx.ui.form.CheckBox("Space Like Protons");
         var tlp = new qx.ui.form.CheckBox("Time Like Protons");
         var sln = new qx.ui.form.CheckBox("Space Like Neutrons");
         var tln =  new qx.ui.form.CheckBox("Time Like Neutrons");
         container.add(slp,{row:2,column:1});
         container.add(tlp,{row:2,column:2});
         container.add(sln,{row:1,column:1});
         container.add(tln,{row:1,column:2});

         var btOk = new qx.ui.form.Button("OK");
         var  checkBoxes = [ slp, tlp, sln, tln ];
         container.add(btOk,{row:3,column:2});

     fs.add(container);

     group2.add(fs);

// Creation of the function linked to the button OK

     btOk.addListener("execute", function(e) {
     var cbs = checkBoxes;
     var count = 0;
     var str = "";

     for (var i=0; i<cbs.length; i++)
     {
       if (cbs[i].getValue())
       {
         count++;
         str += (cbs[i].getLabel()  + ", ");
       }
     }

     if (count > 0)
     {
       str = str.substring(0, str.length-2);
       alert("You want" + str);
     }
     else
     {
       alert("No choice");
     }
     });

     page2.add(group2);

    }

});

Comment: Your question was answered already by @johnspackman but let me introduce you some posts that might help you to better understand qooxdoo layouts:  * [intro](http://blog.muhuk.com/2009/01/30/using-layouts-in-qooxdoo-part-1.html)  * [vbox](http://blog.muhuk.com/2009/02/04/using-layouts-in-qooxdoo-part-2-vbox-layout.html)  * [hbox](http://blog.muhuk.com/2009/02/15/using-layouts-in-qooxdoo-part-3-hbox-layout.html)  * [grid](http://blog.muhuk.com/2009/02/21/using-layouts-in-qooxdoo-part-4-grid-layout.html)
Answer: HBox and VBox just lay out the widgets from left to right/top to bottom in the order you add them; that's working just fine in your example code.
You can add layout options to each widget that you add to a container that are interpreted by the layout for that container, so for example where you have this code:

    group2.add(fs1);
    group2.add(fs);

you're just adding the fs1 and then fs widgets one after the other; each widget will take up as much space as it needs as a minimum (which is obviously not the same as taking up as much as it could)
The second argument to .add allows you to specify some settings to change how this is done, for example:

     group2.add(fs1, { flex: 1 });
     group2.add(fs);

This tells the group2's VBox layout that fs1 is to take up as much room as possible.
The documentation lists the available options
PS - "flex" doesn't just mean "take up all the space: if one widget had a flex of 2 and the other had a flex of 1, the first widget would have 2/3 the space, and the second widget would have 1/3
Comment: Hi thank you for this link and also for this answer.

However, is there a way to to do it by "automatic" ? I mean, here, all the page is filled, but there are some blank spaces under my text. Can I get ride of them ?

I ve seen several links but I haven t yet found "my answer". Perhaps it is something simple but I don t know. I would like the "perfect box" for my text.
Comment: I don't understand what you mean - please can you put together a quick playground example [here](http://demo.qooxdoo.org/current/playground/#Hello%20World-ria)
Comment: Ok sorry for the delay. My point was : I want something nice to see. Hence a big black space, as I can have with flex is not what I looking for. However, this option will be very keenful later for my project. As said somewhere on the page, I do have the answer. Using a Label is perfectly suitable. The thing is with embed.html the size of the shape is blocked (exept with flex) that was my main issue.
Answer: First of all please put your comments for the answer below the answer. This way the author of the answer will get notified for your comment and will be able to provide more help.
Regarding your question of more automatic and spaces you don't want below your text. I am not sure if I understand it right but I guess you want something like this screenshot

In this case you need to add in your layout the box with your text, a qx.ui.core.Spacer and the box with the buttons. In this order.
Here is your code modified to produce that screenshoot
    qx.Class.define("q.Windows",
    {
        extend: qx.ui.window.Window,

        construct: function (){

            this.base(arguments, "windows");
            this.setWidth(600);
            this.setHeight(700);
            this.setResizable(true);
            var layout = new qx.ui.layout.Grow();
            this.setLayout(layout);

// ############################ CREATION SHAPE PAGE ########################

            var tabView = new qx.ui.tabview.TabView();
            this.add(tabView);

// ############################ Page UN ########################
// ############################ Page UN ########################

            var page1 = new qx.ui.tabview.Page("History", "");
            page1.setLayout(new qx.ui.layout.Grow());
            tabView.add(page1);
// ############################ Backgroung page ########################
            var group1 = new qx.ui.groupbox.GroupBox(this.tr(""));
            group1.setLayout(new qx.ui.layout.Grow());

// ############################ Introduction #########################

            var htmlp1 = '
 For more than 50 years hadron electromagnetic form factors are considered fundamental quantities for non point-like particles. They parametrize the internal structure of hadrons.

' +
                ' Nucleons ' +
                '

This database collects all data and their references in the scattering (space-like) and in the annihilation (time-like) region, as they were published in the original articles. Experiments and theoretical developments are ongoing. Space-like measurements are based on unpolarized (Rosenbluth separation) and polarized (Akhiezer-Rekalo method) electron elastic scattering off protons and, for neutron, on electron scattering off light nuclei. In the time-like region the reactions e⁺e⁻→ pp̄ (accompanied or not by initial state radiation) and pp̄ → e⁺e⁻ allow to extract form factors relying on a precise angular distribution.
';
            var embedp1 = new qx.ui.embed.Html(htmlp1);
            group1.add(embedp1);

// ############################ Nucleon #########################
            page1.add(group1);

// ############################ Page DEUX ########################
// ############################ Page DEUX ########################

            var page2 = new qx.ui.tabview.Page("Computation", "");
            page2.setLayout(new qx.ui.layout.Grow());
            tabView.add(page2);

// ############################ Backgroung page ########################

            var group2 = new qx.ui.groupbox.GroupBox(this.tr(""));
            group2.setLayout(new qx.ui.layout.VBox(10));

// ############################ Objectif #########################

            var fs1 = new qx.ui.groupbox.GroupBox(this.tr(""));
            fs1.setLayout(new qx.ui.layout.Grow());
            var label = new qx.ui.basic.Label();
            label.setValue("This is a qooxdoo application skeleton which is used as a template. The 'create-application.py' script (usually under tool/bin/create-application.py)will use this and expand it into a self-contained qooxdoo application which can then be further extended. Please refer to the script and other documentationfor further information.");
            label.setRich(true);
            // var embedp2 = new qx.ui.embed.Html(htmlp2);

            fs1.add(label);
            group2.add(fs1);
            var spacer = new qx.ui.core.Spacer();
            group2.add(spacer, {flex: 1});

// ############################ Simul #########################

            var fs = new qx.ui.groupbox.GroupBox(this.tr("Choice"));
            fs.setLayout(new qx.ui.layout.Grow());

//Setup of the checkboxes

            var mainLayout = new qx.ui.layout.Grid(0, 0);
            mainLayout.setSpacing(10);

            var container = new qx.ui.container.Composite(mainLayout);
            container.setPadding(20);

            var slp = new qx.ui.form.CheckBox("Space Like Protons");
            var tlp = new qx.ui.form.CheckBox("Time Like Protons");
            var sln = new qx.ui.form.CheckBox("Space Like Neutrons");
            var tln = new qx.ui.form.CheckBox("Time Like Neutrons");
            container.add(slp, {row: 2, column: 1});
            container.add(tlp, {row: 2, column: 2});
            container.add(sln, {row: 1, column: 1});
            container.add(tln, {row: 1, column: 2});

            var btOk = new qx.ui.form.Button("OK");
            var checkBoxes = [slp, tlp, sln, tln];
            container.add(btOk, {row: 3, column: 2});

            fs.add(container);

            group2.add(fs);

// Creation of the function linked to the button OK

            btOk.addListener("execute", function (e){
                var cbs = checkBoxes;
                var count = 0;
                var str = "";

                for (var i = 0; i < cbs.length; i++) {
                    if (cbs[i].getValue()) {
                        count++;
                        str += (cbs[i].getLabel() + ", ");
                    }
                }

                if (count > 0) {
                    str = str.substring(0, str.length - 2);
                    alert("You want" + str);
                }
                else {
                    alert("No choice");
                }
            });

            page2.add(group2);

        }

    });

I took the liberty to convert your embedp2 variable to qx.ui.basic.Label since this gave easier results. If you set it to rich (as I have in this code) then the text is wraped and you can also apply HTML markup if you wish.
Comment: HI,

Your answer is great and filled what I was looking for. Label is fine for me as long as I can use html code. Hence all is perfect.

Thanks you all for your helps.

Qooxdoo Layout issues


Any tool to assist in building REST controller specs?

Question: I'm sick of writing out the same controller specs each time I make a new controller. I know I can use the scaffold generator, but there are enough little things I have to change that it usually doesn't save me much time.
Are there any projects/tools out there that provide some sort of base set of specs and/or a DSL to make this easier?
Answer: I've never found that any two REST controllers I wanted to write had similar enough interfaces that the tests were at all similar (and generally, I recommend Cucumber, not controller specs).
Something like inherited_resources or Rails 3's respond_with is very useful for writing the controllers, but I'm not sure about the tests.
Comment: Interesting… coming at the problem from the other side. I think I would still want to write a full test suite though, unless I was using the absolute vanilla inherited_resources config.
Comment: What do you mean by coming at the problem from the other side? Do you mean that I'm putting the DRY stuff in the implementation instead of the tests? If so, that's the way it should be...
Answer: I use the decent_exposure gem.
Comment: a valid point. I think my tired brain substituted something else for "spec" and I thought you were asking for an easier way to setup the controller itself, not the spec to test it. Apologies.


Counting nulls for each column in table

Question: We want to count how many nulls each column in a table has. There are too many columns to do this one by one, so the following PLSQL procedure was created.
In the first part of the procedure, all column names are obtained. This works, as the dbms_output correctly lists them all.
Secondly, a query inserts the count of null values in the variable 'nullscount'. This part does not work, as the output printed for this variable is always 0, even for columns where we know there are nulls.
Does anyone know how to handle the second part correctly?
Many thanks.
CREATE OR REPLACE PROCEDURE COUNTNULLS AS
nullscount int;

BEGIN

for c in (select column_name from all_tab_columns where table_name = upper('gp'))
loop

select count(*) into nullscount from gp where c.column_name is null;

dbms_output.put_line(c.column_name||' '||nullscount);
end loop;

END COUNTNULLS;

Comment: `c.column_name` is just a ***string*** and it's not null.  You need dynamic SQL.
Comment: What's your oracle version?
Answer: You can get it with just one query like this: this query scans table just once:
DBFiddle: https://dbfiddle.uk/asgrCezT
select *
from xmltable(
        '/ROWSET/ROW/*'
        passing
        dbms_xmlgen.getxmltype(
            (
            select
                'select '
              ||listagg('count(*)-count("'||column_name||'") as "'||column_name||'"',',')
              ||' from '||upper('gp')
            from user_tab_columns
            where table_name = upper('gp')
            )
        )
        columns
            column_name varchar2(30) path './name()',
            cnt_nulls   int path '.'
        );

Results:
COLUMN_NAME                     CNT_NULLS
------------------------------ ----------
A                                       5
B                                       4
C                                       3

Dynamic sql in this query uses (24 chars + column name length) so it should work fine for example for 117 columns with average column name length = 10. If you need more, you can rewrite it a bit, for example:
select *
from xmltable(
        'let $cnt := /ROWSET/ROW/CNT
         for $r in /ROWSET/ROW/*[name() != "CNT"]
           return <R name="{$r/name()}"> {$cnt - $r} </R>'
        passing
        dbms_xmlgen.getxmltype(
            (
            select
                'select count(*) CNT,'
              ||listagg('count("'||column_name||'") as "'||column_name||'"',',')
              ||' from '||upper('gp')
            from user_tab_columns
            where table_name = upper('gp')
            )
        )
        columns
            column_name varchar2(30) path '@name',
            cnt_nulls   int path '.'
        );

Comment: I confirm that this works, as Sayan said, in a single query without the need for PLSQL.
Comment: This may also be the accepted answer but since this post has upvotes already, the other is selected for equal distribution to equally useful responses - apologies for this and many thanks for your help.
Comment: @ClementineSin note that this solution doesn't require to read the table as many times as your number of columns. This solution scan your table just once.
Comment: But will fail if your table contains some BLOB, CLOB, NCLOB, ... columns.
Comment: @p3consulting don't forget that lob objects have different structure: `lob_col is null` just means that there is no locator to lob object, so it counts also "empty" clobs/blobs, see example: https://dbfiddle.uk/SCxrsKUj that's why count(lob) was not implemented
Comment: @SayanMalakshinov: it's not the point I am addressing: if count() is not implemented on some data types, it just means you can't "select from user_tab_columns" without filtering out these types and then expect the "listagg( 'count("' ... be running without failure on tables having these column types. So the query could be improved to avoid this.
Answer: c.column_name is never null because it's the content of the column "column_name" of the table "all_tab_columns"
not the column of which name is the value of c.column_name, in table gp.
You have to use dynamic query and EXECUTE IMMEDIATE to achieve what you want.
Comment: This was indeed the problem, replacing by a dynamic query solved the issue.
Answer: create table gp (
    id                             number generated by default on null as identity
                                   constraint gp_pk primary key,
    c1                             number,
    c2                             number,
    c3                             number,
    c4                             number,
    c5                             number
)
;

-- add some data with NULLS and numbers
DECLARE
BEGIN
  FOR r IN 1 .. 20 LOOP
    INSERT INTO gp (c1,c2,c3,c4,c5) VALUES
    (CASE WHEN mod(r,2) = 0 THEN NULL ELSE mod(r,2) END
    ,CASE WHEN mod(r,3) = 0 THEN NULL ELSE mod(r,3) END
    ,CASE WHEN mod(r,4) = 0 THEN NULL ELSE mod(r,4) END
    ,CASE WHEN mod(r,5) = 0 THEN NULL ELSE mod(r,5) END
    ,5);
  END LOOP;
END;
/

-- check what is in the table
SELECT * FROM gp;

-- do count of each column
DECLARE
  l_colcount NUMBER;
  l_statement VARCHAR2(100) := 'SELECT COUNT(*) FROM $TABLE_NAME$ WHERE $COLUMN_NAME$ IS NULL';
BEGIN
  FOR r IN (SELECT column_name,table_name FROM user_tab_columns WHERE table_name = 'GP') LOOP

    EXECUTE IMMEDIATE REPLACE(REPLACE(l_statement,'$TABLE_NAME$',r.table_name),'$COLUMN_NAME$',r.column_name) INTO l_colcount;

    dbms_output.put_line('Table: '||r.table_name||', column'||r.column_name||', COUNT: '||l_colcount);
  END LOOP;
END;
/

Table created.

Statement processed.

Result Set 4
ID  C1  C2  C3  C4  C5
1   1   1   1   1   5
2    -  2   2   2   5
3   1    -  3   3   5
4    -  1    -  4   5
5   1   2   1    -  5
6    -   -  2   1   5
7   1   1   3   2   5
8    -  2    -  3   5
9   1    -  1   4   5
10   -  1   2    -  5
11  1   2   3   1   5
12   -   -   -  2   5
13  1   1   1   3   5
14   -  2   2   4   5
15  1    -  3    -  5
16   -  1    -  1   5
17  1   2   1   2   5
18   -   -  2   3   5
19  1   1   3   4   5
20   -  2    -   -  5

20 rows selected.

Statement processed.

Table: GP, columnID, COUNT: 0
Table: GP, columnC1, COUNT: 10
Table: GP, columnC2, COUNT: 6
Table: GP, columnC3, COUNT: 5
Table: GP, columnC4, COUNT: 4
Table: GP, columnC5, COUNT: 0

Comment: I tested this and it worked for this issue, the difference with the query in the question was indeed as mentioned below that a dynamic query had to be used.

Counting nulls for each column in table


Shouldn't the variance of the vector of regression coefficients decrease when we have larger sample sizes?

Question: In the first answer to this post, it is shown that the variance of the estimated regression coefficient $\hat \beta_1$ in simple linear regression is
$$
\text{Var}(\hat \beta_1) = \frac{\sigma^2}{\sum_i (x_i - \bar x)^2}. \quad \quad \quad (1)
$$
On Wikipedia we have the following expression for the variance-covariance matrix of the vector of coefficients:
$$
\text{Var}(\hat \beta|X) = \sigma^2 (X^T X)^{-1}. \quad \quad \quad (2)
$$
The expressions (1) and (2) are quite similar. In expression (1), it is clear that for larger samples sizes, the variance will decrease as we will have more terms in the summation in the denominator. But for expression 2, it seems that there is no guarantee that the variance (the diagonals of the covariance matrix) will decrease if we take larger samples sizes?
Also, can expression (1) be obtained from expression (2)?
Edit: The result for $\text{Var}(\hat \beta_1$) in (1) should also be contained in the a corresponding entry on the diagonal of $\text{Var}(\hat \beta | X)$? How do we show that (1) corresponds to an entry on the diagonal of (2)? I'm not seeing where the subtraction of the mean in the denominator of (1) arises in (2)?
Answer: In regression analysis, if you want to get asymptotic consistency results you need to impose some limiting conditions on the explanatory variables.  The regression model itself makes no assumptions about the form of the sequence of explanatory variables, so these limiting conditions are conditions that go beyond the model assumptions for regression analysis.  There are various (sufficient) limiting conditions that can be imposed on the sequence of explanatory variables in order to get consistency of the OLS estimators, but the usual conditions are the so-called "Grenander conditions" (see e.g., Grenander 1954), which we will discuss below.

OLS consistency does not follow from the ordinary regression model assumptions: Without imposing any conditions here, there is no guarantee that the variance of the OLS estimators will reduce to zero asymptotically, even under the first of your two equations.  (As an example of this, consider the case where the sequence of $x_i$ values converges rapidly to its mean so that it stops adding anything more to the sum-of-squares after a finite number of observations.)  In the general case, the OLS estimator can be written in the form:
$$\hat{\boldsymbol{\beta}} = \boldsymbol{\beta} + \Bigg( \frac{1}{n} \ \mathbf{x}^\text{T} \mathbf{x} \Bigg)^{-1} \Bigg( \frac{1}{n} \ \mathbf{x}^\text{T} \boldsymbol{\varepsilon} \Bigg),$$
so we have the probability limit:
$$\text{plim} \ \hat{\boldsymbol{\beta}} = \boldsymbol{\beta} + \Bigg( \text{plim} \ \frac{1}{n} \ \mathbf{x}^\text{T} \mathbf{x} \Bigg)^{-1} \Bigg( \text{plim} \ \frac{1}{n} \ \mathbf{x}^\text{T} \boldsymbol{\varepsilon} \Bigg).$$
The standard regression assumptions give IID error terms with $\mathbb{E}(\boldsymbol{\varepsilon}|\mathbf{x}) = \mathbf{0}$.  Using the laws of iterated expectation and variance, the moments of the second quantity are:
$$\mathbb{E} \Big( \frac{1}{n} \ \mathbf{x}^\text{T} \boldsymbol{\varepsilon} \Big) = \mathbf{0}
\quad \quad \quad
\mathbb{V} \Big( \frac{1}{n} \ \mathbf{x}^\text{T} \boldsymbol{\varepsilon} \Big) =
\frac{\sigma^2}{n} \cdot \frac{\mathbf{x}^\text{T} \mathbf{x}}{n}.$$
The OLS estimator is consistent if and only if $\text{plim} \ \hat{\boldsymbol{\beta}} = \boldsymbol{\beta}$, which occurs when the second term in the above expression vanishes (i.e., is equal to the zero vector).  The first thing to observe is that there is no guarantee that this occurs under the standard regression model assumptions.  If the asymptotic behavious of the explanatory variables is nasty, then the $\text{plim}$ in the first brackets might be zero, or the $\text{plim}$ in the second brackets might not be zero.  In the example I mentioned above, where the explanatory variables rapidly converge to their mean, the $\text{plim}$ in the first brackets will be zero, and the inverted term explodes.

OLS consistency comes from the limiting behaviour of the explanatory variables To obtain asymptotic consistency of the OLS estimator, it is sufficient to show that $\mathbb{V}(\tfrac{1}{n} \ \mathbf{x}^\text{T} \boldsymbol{\varepsilon}) \rightarrow 0$ (so that the second $\text{plim}$ converges to the zero vector) and that the first bracketed term converges to a fixed matrix.  This is where we use the "Grenander conditions", or some other sufficient conditions.  In particular, it is sufficient here to assume (or establish from other assumptions) that there exists some probability limit $\text{plim} \ \tfrac{1}{n} \ \mathbf{x}^\text{T} \mathbf{x} = \mathbf{Q}$ where $\mathbf{Q}$ is a positive definite matrix with non-zero diagonal elements.  This is a sufficient condition for asymptotic consistency, since it ensure that the first $\text{plim}$ in the above expression is non-zero and the second is zero.  This ensures that the entire term vanishes, leaving the consistency property $\text{plim} \ \hat{\boldsymbol{\beta}} = \boldsymbol{\beta}$.
Comment: Again, that quantity depends on $\mathbf{x}$.  So you tell me --- is it?
Comment: Your (counter) example is interesting as it shows that I have made a mistake in my other recent post - https://stats.stackexchange.com/questions/491005/does-the-variance-in-the-estimates-of-the-coefficients-for-standard-linear-regre
Comment: The rate of convergence would depend on the properties of the sequence of explanatory variables, so if you wanted results pertaining to this you would need to stipulate further conditions on these variables.
Comment: Yes, but remember that that is an assumption about the explanatory variables, not something that follows from the initial assumptions of the regression model.
Comment: If you want to get an "order" of convergence then you need to make some assumption about the corresponding "order" of the explanatory variables.
Comment: Assume we have the 'Grenander Conditions for Well-Behaved Data' on $x$ which are listed here - http://people.stern.nyu.edu/wgreene/MathStat/GreeneChapter4.pdf.- the author states these conditions are weak enough to be satisfied by almost any dataset encountered in practice. So with these conditions, can we say something about the rate?
Comment: It looks like $\text{plim} \ (x^T\varepsilon)/n$ converges at $O(1/n)$ with those conditions?
Comment: Do you know the rate of convergence with respect to $n$ at which $\text{plim} \ \hat \beta \to \beta$?
Comment: Disregarding my other post (linked in the first comment above), it still seems like the variance goes down at $O(1/n)$. See the first two pages of these notes http://www.econ.nyu.edu/user/flinnc/notes1.pdf. They have $\text{Var}(\hat \beta|X) = \sigma^2/n \bigg(\frac{X^T X}{n}\bigg)^{-1}$. The first term decays as $O(1/n)$ and the second term approaches a finite matrix, so it appears we can indeed say the variance decays as  $O(1/n)$ as $n \to \infty$ as long as we assume that $\lim_{n\to \infty} \frac{X^TX}{n}$ is a finite matrix?
Comment: In terms of your post above, is it possible to say anything about the rate of convergence of $\text{plim} \frac{1}{n}x^T \varepsilon$ to $0$?


Redefining environment trouble

Question: I'm trying to renew the "enumerate" environment so that there is a bracket instead of a dot after the number. Actually here is the code:
\documentclass[a4paper, 14pt]{extarticle}
\usepackage{amsfonts, amsmath, amssymb, amsthm}
\usepackage{enumitem}
\usepackage[top = 1.5cm, right = 1.5cm, bottom = 1.5cm, left = 1.5cm]{geometry}
\usepackage{mathtools} % DeclarePairedDelimiter
\usepackage{nomencl}
\let\originalenumerate\enumerate
\renewenvironment{enumerate}{\begin{originalenumerate}[label={$\left.\arabic*\right)$}]}{\end{originalenumerate}\\}
\newtheorem{theorem}{Theorem}
\newtheorem*{corollary*}{Corollary}
\begin{document}
\section*{Theorems}
\begin{theorem}
Let
\begin{enumerate}
\item Condition 1,
\item Condition 2,
\item Condition 3,
\end{enumerate}
then assertion.
\end{theorem}
\begin{proof}
Proof.
\end{proof}
\end{document}

This raises a trouble whose solution I can't google: the last item always moves to the left.

There is one more nuisance - if I don't write \\ after \end{originalenumerate} there will be no line break.
How can I solve these troubles?
Answer: The problem is caused by the fact that you just store the code for the original start of enumerate, but not \endenumerate, which means that \end{originalenumerate} does not really do anything. Also writing \\ anywhere outside a tabular environment is nearly always wrong and in your case it causes an error if one would properly store the end of enumerate with \let\endoriginalenumerate\endenumerate.
Anyway, much simpler than redefining the enumerate environment, you can use \setlist{label={$\left.\arabic*\right)$}
\documentclass[a4paper, 14pt]{extarticle}
\usepackage{amsfonts, amsmath, amssymb, amsthm}
\usepackage{enumitem}
\usepackage[top = 1.5cm, right = 1.5cm, bottom = 1.5cm, left = 1.5cm]{geometry}
\usepackage{mathtools} % DeclarePairedDelimiter
\usepackage{nomencl}

\setlist{label={$\left.\arabic*\right)$}

\newtheorem{theorem}{Theorem}
\newtheorem*{corollary*}{Corollary}
\begin{document}
\section*{Theorems}
\begin{theorem}
Let
\begin{enumerate}
\item Condition 1,
\item Condition 2,
\item Condition 3,
\end{enumerate}
then assertion.
\end{theorem}
\begin{proof}
Proof.
\end{proof}
\end{document}

Redefining environment trouble


Method to return derived generic class without specifying the types of the return

Question: I have a base class like this:
public class BaseClass<T, R> : DbContext where T : class, IAPIObject<R>
{
    public void MethodA()
    {
        Something using T
        Something using R
    }
}

I have some derived classes like this:
public class DerivedClass1 : BaseClass<TypeA, TypeB>
public class DerivedClass2 : BaseClass<TypeC, TypeD>

I would like to write a function like the following, without specifying the types for the returned object, since they are defined within the derived classes:
private BaseClass GetObject<T>(T apiObject)
{
    return apiObject switch
        {
            TypeA _ => DerivedClass1(),
            TypeC _ => DerivedClass2(),
        }
}

Is this possible? Is this a good idea? I feel like there is a chance this is totally the wrong way to go about designing this thing, but I'm not too experienced.
The end goal is to be able to get an instance of BaseClass with the types defined based on some argument and then do things like BaseClass.MethodA() and not worry about specifying the types anymore:
var thing = GetObject<TypeA>(someObject);
thing.MethodA();

If I define the types on the methods themselves, then I have to define them every time I call MethodA(), which feels redundant if I know DerivedClass1 will always use TypeA and TypeB. Is there a better way to do this with a virtual method and override?
Comment: You can have `GetObject` return a non-generic `IBaseClass` **interface**, which has a `MethodA` method declared. `BaseClass` would then implement this interface.
Comment: Abstract method?
Answer: Since the signature of the method that you are trying to call (MethodA) does not involve the type parameters (only its implementation uses the type parameters), you can make a non-generic interface:
interface IBaseClass {
    void MethodA();
}

// change the return type to the non-generic interface
private IBaseClass GetObject<T>(T apiObject) =>
    apiObject switch
    {
        TypeA _ => DerivedClass1(),
        TypeC _ => DerivedClass2(),
        // you seem to be missing a default case?
    };

On this non generic interface IBaseClass, you can then call MethodA!
Since you don't know anything about T and R of the returned object, you can't use any of the members of BaseClass that involve those types. IBaseClass is you promising to the compiler that "I won't use any of those members that involve T and R".
Comment: And thanks for the comment about the default case - I just didn't include it in the question pseudo code
Comment: Since BaseClass actually inherits from Microsoft.EntityFrameworkCore.DbContext, I made it a class instead of an interface, but this should be workable regardless.


Four towns are connected by five roads

Question: Question:
Four towns are connected by five roads. Imagine a rhombus where the left, up, right, and down corners are $A, B, D$, and $C$ respectively; and connect the corners B and C. Each road is blocked by snow independently with probability $p$. What is the probability that you can drive between the towns $A$ and $D$?
I will explain how I understand the first part of the solution.
More importantly, I am asking for someone to explain the solution which is below.
This question is taken from "Probability and Random Variables, a Beginner's guide" by David Stirzaker, pages $63-64$, which shows the following solution:
Let $R$ be the event that the road BC is open and Q the event that you can drive from $A$ to $D$.
$R'$ means the complement of event $R$.
$$P(Q)=P(Q|R) \cdot (1−p)+P(Q|R′)\cdot p$$
$$P(Q)=(1−p^2)^2\cdot (1−p)+(1−(1−(1−p)^2)^2)\cdot p$$
I now will explain my understanding of the first part of the above solution:
(1) $p^2$ is the probability of having two consecutive roads (such as $AB$ and $BD$; or $AC$ and $CD$; or $AB$ and $BC$; or $AC$ and $CB$) blocked. Note that in the case of $AB$ and $BC$, or $AC$ and $CB$, the town $D$ was not reached.
(2) $1-p^2$ is the probability that two consecutive roads are not blocked, and $(1-p^2)^2$ is the probability that two pairs of consecutive roads are not blocked, such as $AB$ and $BD$; or $AC$ and $CD$.
(3) $(1-p^2)^2 \cdot (1-p)$ is the probability that two consecutive roads are not blocked plus road $BC$ not being blocked. So that means the routes $AB$ and $BC$ and $CD$; or $AC$ and $CB$ and $BD$. The problem with this solution is that, apparently, it ignores the routes $AB$ and $BD$; or $AC$ and $CD$.
That was my attempt at understanding the first term of the solution. I invite an explanation of the book's solution (both, the first and second terms of the solution) and, ideally, show step by step how such solution was found, hopefully showing equations with unions and intersections of events.
Answer: For simplicity, I will write $O_\text{road}$ to indicate the event that a particular road is open, for example $O_{AB}$ denotes $AB$ is opened.
The first line is the law of total probability.
$$P(Q)=P(Q|R)P(R)+P(Q|R')P(R')$$
and we have $P(R)=1-p$.
Hence we want to prove that $P(Q|R)=(1-p^2)^2$ and $P(Q|R')=1-(1-(1-p)^2)^2$.
If the event $R$ happens, that is if $BC$ is open, in order to reach $D$ from $A$. We need ($AB$ or $AC$ to be opened) and ($BD$ or $CD$ to be opened).
\begin{align}
P(Q|R)&=P((O_{AB} \cup O_{AC}) \cap (O_{BD} \cup O_{CD})) \\
&=P(O_{AB} \cup O_{AC}) \cdot P(O_{BD} \cup O_{CD}) \\
&= \left( 1-P(O_{AB}')P(O_{AC}')\right)\left( 1-P(O_{BD}')P(O_{CD}')\right) \\
&= (1-p^2)^2
\end{align}
If the event $R'$ happens, that is if $BC$ is not open, in order to reach $D$ from $A$, we need ($AB$ and $BD$ to be opened) or ($AC$ and $CD$ to be opened).
\begin{align}
P(Q|R') &= P((O_{AB} \cap O_{BD}) \cup (O_{AC} \cup O_{CD})) \\
&=1-P((O_{AB} \cap O_{BD})' )\cdot P( (O_{AC} \cup O_{CD})') \\
&= 1-(1-P(O_{AB})P(O_{BD}))\cdot (1-P(O_{AC})P(O_{CD}))\\
&= 1-(1-(1-p)^2)^2\\
\end{align}
Comment: Thank you. For people who may need more detail for the second part of the solution, I would add the following:
Comment: Following from the comment above I would add the following between the 1st and the 2nd lines of the second part of the solution:
                                                                                = 1 - P ( ( ( AB and BD ) or ( AC and CD ) ) ' )    and then                                                                   = 1 - P ( ( AB and BD ) ' and ( AC and CD ) ' )

Four towns are connected by five roads


how to get forecast like zig zag type

Question:
My model is ARIMA(0,1,1).And diagnostics are ok.but cant get clear values for the forecasting in r.
Comment: You might want to add more information, otherwise the chance for a good answer will remain close to 0. A specific example with code, data and concept would be ideal.
Answer: Your model says that differences in the observations are MA(1):
$$ y_t-y_{t-1}=\theta\epsilon_{t-1}+\epsilon_t \quad\text{or}\quad y_t=y_{t-1}+\theta\epsilon_{t-1}+\epsilon_t.$$
In (point) forecasting, you plug in the mean value for the innovations $\epsilon$, which is zero. So your forecast is just the last observation. (The very first forecast data point could be somewhat off, because that uses the last "observed" innovation, but you may not see it if the MA coefficient is small.)
A "zigzag" pattern can arise in many ways. The simplest would be an AR(1) model with a negative coefficient:
<code>library(forecast)
set.seed(1)
xx <- arima.sim(model=list(ar=c(-0.9)),n=100)
model <- arima(xx,order=c(1,0,0))
plot(forecast(model,h=10))
</code>

However: why do you want a zigzag forecast? If your data generating process truly is ARIMA(0,1,1), then the flat line will be the best forecast (under squared error loss). Anything else will perform worse. See Is it unusual for the MEAN to outperform ARIMA? Don't be afraid of a flat line forecast!
Comment: Thank you sir.But problem is this is the coconut export prices.then the how can forecast next year.its straight line
Comment: If your data is just noise, then the *data* will be noisy, but the best forecast (i.e., the one that minimizes the expected squared error) will be the *expectation*, i.e., a flat line. Here is an experiment: suppose your past and future data is simply $N(0,1)$ random variables. What is the best forecast for each future time period? You can simulate this and try various approaches.

how to get forecast like zig zag type


Gitlab on Virtualbox VM with repositories on host os

Question: I've set up a Virtualbox VM (debian 7.6) on my MacMini (10.9). I've successfully installed Gitlab (7.1) in the VM and I'm able to access it from all machines in my network. I'm able to log in and create a user.
However, I'd like the git repositories to be a directory on a shared folder rather than somewhere within the VM. I've added user 'git' to the vboxsf group and as this user I can create directories in the shared folder just fine.
I've tried symlinking /var/opt/gitlab/git-data/repositories to a directory within my shared folder.
but I'm getting permission denied when trying to add a user or a group.
Any ideas?
Answer: If you look in the file ~git/gitlab/config/gitlab.yml it says:
  ## GitLab Shell settings
  gitlab_shell:
    path: /home/git/gitlab-shell/

    # REPOS_PATH MUST NOT BE A SYMLINK!!!
    repos_path: /home/git/repositories/
    hooks_path: /home/git/gitlab-shell/hooks/

So no symlink :-)
But you can modify the file and the repos_path setting to point to a folder under your shared folder. You will also need to modify this file: ~git/gitlab-shell/config.yml as it contains a duplicated setting (with the same name) which is generated from the above file during the "installation" process.
Once done, restart your Gitlab services (at least gitlab-sidekiq gitlab-unicorn).
Comment: Thanks for the answer. I've followed your instructions. For posterity: when gitlab is installed using one of the packages as described on the Gitlab page, the gitlab.yml file is under `/var/opt/gitlab/gitlab-rails/etc`, the other is under `/var/opt/gitlab/gitlab-shell/config.yml`. I've changed the repos_path to `/media/sf_develop/repositories` (a subfolder of my shared folder) and restarted the VM to make sure everything is restarted as necessary. After that, I can access the users I've created, but I can't create a new project, i.e. no folder on disk is created :-(.
Comment: And I guess you can do `sudo -u git touch /media/sf_develop/repositories/testfile` assuming the GitLab user for the packages is also "git". If you can't then you have a permission problem, or there is something else...
Comment: Maybe there is one more step to do after modifying the file. In the manual installation, we need to do `cd ~git/gitlab; sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production` to regenerate configurations. Looking at the path of the package installation I would guess you need to `cd /var/opt/gitlab` instead. Once done, you need to just restart the services (on Ubuntu it seems that `sudo /etc/init.d/gitlab restart` is enough).
Comment: Ho and finally, try `sudo -u git -H /home/git/gitlab-shell/bin/check` (check the path on your installation) this should tell you if anything regarding repositories directory is misconfigured.
Comment: For posterity, the rake command can be executed as `sudo -u git -H /opt/gitlab/bin/gitlab-rake assets:precompile`. This results in: `chpst: fatal: unable to setgroups: permission denied`. `sudo -u git -H /opt/gitlab/embedded/service/gitlab-shell/bin/check` results in 'OK'.
Comment: I will modify my config of GitLab to test my answer and report to you soon.
Comment: Did someone find a solution for this problem?


Como fazer o Auto Clomplete abrir a baixa da linha onde esta sendo digitado?

Question: Tenho um sistema de auto complete e queria que as opções aparececem abaixa da linha onde o usuario esta digitando, como por exemplo editores de codigos como o dreamweaver.
Auto Complete - Jquery:
$(function() {
var availableTags = [
  "",
  ""
];
function split( val ) {
  return val.split( /\s*/ );
}
function extractLast( term ) {
  return split( term ).pop();
}

$( "#tags" )
  // don't navigate away from the field on tab when selecting an item
  .bind( "keydown", function( event ) {
    if ( event.keyCode === $.ui.keyCode.TAB &&
        $( this ).autocomplete( "instance" ).menu.active ) {
      event.preventDefault();
    }
  })
  .autocomplete({
    minLength: 0,
    source: function( request, response ) {
      // delegate back to autocomplete, but extract the last term
      response( $.ui.autocomplete.filter(
        availableTags, extractLast( request.term ) ) );
    },
    focus: function() {
      // prevent value inserted on focus
      return false;
    },
    select: function( event, ui ) {
      var terms = split( this.value );
      // remove the current input
      terms.pop();
      // add the selected item
      terms.push( ui.item.value );
      // add placeholder to get the comma-and-space at the end
      terms.push( "" );
      this.value = terms.join( "" );
      return false;
    }
  });

});
HTML:
<textarea id="tags" ></textarea>

Answer: Você pode usar o atributo autoFocus para tal. Quando achar a palavra basta clicar no enter. Veja o exemplo:

<!doctype html>

  <meta charset="utf-8">
  <title>jQuery UI Autocomplete - Default functionality</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">

  <link rel="stylesheet" href="/resources/demos/style.css">

  Tags:
  <textarea id="tags"></textarea>

EDIT 1:
Da uma olhada nesse plugin: http://yuku-t.com/jquery-textcomplete/
Comment: não é isso que eu queria, eu queria q estas tags aparececem na linha abaixo na qual digitada, caso ele esteja digitando na linha 1, na linha 2 apareceria as tags para ele celecionar.
Comment: Não entendi, consegue colocar uma imagem anexa a tua pergunta?
Comment: ok, http://i.stack.imgur.com/RANnh.jpg, tipo assim q eu queria
Comment: O efeito que vc quer é o mesmo que postei. Pesquise por exemplo por 'java' e pressione o Enter o efeito será o mesmo
Comment: Observe que ele não é autocomplete simples, ele possui o recurso de foco no primeiro item da lista
Comment: desculpe a demora pois acabei me esquecendo desta pergunta :-/. Não oque eu queria era apenas a posição como de exemplo, tenho uma textarea com o height de 1500px e queria que o auto complete aparece abaixo da linha na qual esta digitando como na foto. Espero ter esclarecido, desculpem a demora
Comment: Veja o EDIT 1 pf


Bundler doesn't seem to be working

Question: Excuse my Rails noobitude.
After running bundle install, all my gems install correctly.
When I run bundle update, it outputs a list of my installed gems and tells me "Your bundle is complete! Use bundle show [gemname] to see where a bundled gem is installed."
I try 'bundle show rake' and the output is exactly the same. When I'm trying to rake db:migrate with bundle exec, the output is exactly the same the the db migration doesn't even happen.
Do I have something wrong with my bundler or something?
I am so confused.
$ bundle update rake
"BundlingUsing rake (0.8.7)
Using abstract (1.0.0)
Using activesupport (3.0.5)
Using builder (2.1.2)
Using i18n (0.6.0)
Using activemodel (3.0.5)
Using erubis (2.6.6)
Using rack (1.2.3)
Using rack-mount (0.6.14)
Using rack-test (0.5.7)
Using tzinfo (0.3.29)
Using actionpack (3.0.5)
Using mime-types (1.16)
Using polyglot (0.3.2)
Using treetop (1.4.10)
Using mail (2.2.19)
Using actionmailer (3.0.5)
Using arel (2.0.10)
Using activerecord (3.0.5)
Using activeresource (3.0.5)
Using bundler (1.0.15)
Using thor (0.14.6)
Using railties (3.0.5)
Using rails (3.0.5)
Using sqlite3 (1.3.4)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

Comment: This question doesn't make any sense :( Why are you running `bundle update`? What is the first output of `rake db:migrate` and what are you expecting it to do?
Comment: To note: `bundle update rake` will update the bundle's version of rake to the highest that can be supported by the restrictions enforced by the other gems that you're using. You're using Rails 3.0.5 and so the rake version is going to be 0.8.7 based on the dep in `railties 3.0.5`. To use 0.9.2, upgrade to Rails 3.0.9.
Comment: Okay, but what I mean is every input outputs the same thing and nothing changes. Bundle exec db:migrate should perform the database migration, yes? But it doesn't do anything, it just outputs the same thing I pasted up there and doesn't perform the db migration. Why?
Comment: I know that bundle update performs updating gems, sorry that was poorly written.
Answer: I've had a similar issue and found my solution here: Bundler ignores groups in rails apps
Summary:
Do the following:
rm .bundle/config
bundle install

Bundler doesn't seem to be working


How do I install the Spark distribution using only Drush?

Question: How do I fire up the Spark Distribution via a drush command?
Comment: `drush make build-spark.make ~/Sites/spark`...http://drupal.org/node/1741590
Comment: That seems an answer. `:)`
Comment: @kiam Feel free to put it in, I'm on mobile at the mo and it's fiddly :)
Answer: From comments:
Clive: drush make build-spark.make ~/Sites/spark - Building Spark from Drush Make yourself


How to make a custom LinkedIn share button using POST

Question: I would like to use my own image for the LinkedIn share button. I've been following the information on this previous post:
How to make a custom LinkedIn share button
It's noted here that: To create a custom Share button for LinkedIn, you need to make POST calls now.
I've read the Linkedin documentation however I don't understand how to incorporate the POST call with my HTML page. Could someone help explain it to me please?
I've initially tried to use this URL which i understand is now not supported by LinkedIn:
https://www.linkedin.com/shareArticle?mini=true&url=articleUrl&title=YourarticleTitle&summary=YourarticleSummary&source=YourarticleSource
It partially works! The image, title and summary are all incomplete or not what I have specified in the URL, however if I click on the LinkedIn post it does actually link to the right page.
Is there anyway of getting this working?
Many thanks
Comment: Without using a `` (which may or may not be amenable to you in your situation), you cannot use the POST method in HTML without also using JavaScript. If you're already familiar with JavaScript, I would recommend taking a look at MDN's [Using Fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch) page. If you're new to JS, on the other hand, I would start by taking a primer course on the language, e.g., MDN's [JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript) learning area.
Comment: Thanks for coming back to me with this information. I'm new to JavaScript so will have a look at the learning area link you provided.  You mentioned that I would need to use a  (i'm amending the html page through a CMS so probably won't be possible but i'd like to explore the idea). I don't quite understand how this can be incorporated into the custom button though? Would the user be required to fill in a form field in order to get this to work? Thanks
Comment: Ah, I see. Every CMS is different, so assuming you're using a standardized third-party system instead of a custom-built tool, your best bet is to look up the documentation for your CMS. If you *are* using a custom-built tool, you might ask the developers of the tool, assuming you have a support contract with them (I've worked with this kind of situation before, but I'm not sure how typical it is). As for filling in a form field, no-- there is no requirement to fill in a field. You might just create a `` with an input `type=submit`, and possibly store a token in an input `type=hidden`.
Comment: ok thanks - really appreciate your thoughts. It is a custom based tool so i'll see if I can ask the developers. Much appreciated.
Comment: Hi, jd12, let me know if my answer has been helpful at all, or if there's anything I can improve, thanks!
Answer: Let's take a quick glance at the Official LinkedIn "Making Your Website Shareable on LinkedIn" Documentation.  The URL format should be...
https://www.linkedin.com/sharing/share-offsite/?url={url}

And to have it use the other parameters, such as image, etc., set your og: tags in the HTML of the link you are sharing, like so...

<meta property='og:title' content='Title of the article"/>
<meta property='og:image' content='//media.example.com/ 1234567.jpg"/>
<meta property='og:description' content='Description that will show in the preview"/>
<meta property='og:url' content='//www.example.com/URL of the article" />


GetDirectoryContents method doesn't show files over 28MB

Question: I'm currently trying to display files we've got in a directory. For this I'm using the IFileProvider / ContentRootFileProvider with it's method GetDirectoryContents(string path). It works like a charm on my local maschine with IIS in Visual Studio, but not on Azure. If I execute it locally, it shows every file with its details. But as soon as I try to run it on Azure, I only get files which are < 28MB. After googling a bit I tried editing the web.config on Azure and including the web.config into my project. Sadly both cases didn't work and I still just got files which were smaller than 28MB.
My edit to the web.config:
<security>
    <requestFiltering>

        <requestLimits maxAllowedContentLength="419430400" />
    </requestFiltering>
</security>

Any help would be much appreciated.
Answer: UPDATE
The code provided by Krishg's is valid and recommended.
The solution I provided (file classification) sometimes ignores large files. This phenomenon is very strange.
new PhysicalFileProvider(Directory.GetCurrentDirectory(), ExclusionFilters.None);

PRIVIOUS
I read your description carefully and tested it myself. This question is very interesting.
I tried to create a webapp and choose the linux platform, everything is normal. (If you can, please choose this plan to deploy your program).
Created under the windows platform, under the folder to be traversed, if it contains picture files (formats: jpg, gif, png), .csproj files, then files over 28M cannot be recognized.
I use kudu to upload large files. When it is less than a certain value, it can be seen. After uploading, it disappears, which is very strange.
Solutions and suggestions:
1. Use linux platform to redeploy webapp
2. Classify files in the project. Assign to the corresponding folder when traversing.
var contents = _fileProvider.GetDirectoryContents("/zip");

Test Result.

3. You can raise a support ticket on portal and get the official answer. If it is really a bug, after you submit the question, the official will handle it and help the webapp to improve it.
Comment: If you declare PhysicalFileProvider by passing ExclusionFilters.None param in constructor `new PhysicalFileProvider(Directory.GetCurrentDirectory(), ExclusionFilters.None);`, it works fine :)
Comment: Sadly using linux is no option, since our subscription doesn't include it. Did I unterstand correctly, that you propose to create different folders for different types of files (2.)? Since I just have one folder which I need to go through (it has a lot of big .json files in it and I can't change anything), (2.) doesn't seem to be an option. That it, of course, if I understood you correctly.

I'll test everything tomorrow and will raise a support ticket if it doesn't play out. Thanks for the help! As for now, I'll mark your answer as accepted. :)
Comment: @krishg  Krishg is right, but there are many ways to read and traverse files. At present, the problem of op is a general and conventional writing method, and this problem will be encountered. In theory, the local test should be consistent with azure.
Comment: @0x41 You can choose any way to solve your problem. Whichever modifies the least, you take which approach.


What's the difference between "Contexts" in CTools/Panels and in Context module?

Question: I've been wondering this for a while and always assumed they were different things, but the fact that the Context module uses CTools for its Plugin API kinda confuses me even more...
Can someone please break it down for me please? Thanks!
Answer: This is essentially a duplicate of Panels or Context module?. However, Lullabot has a pretty good breakdown on the differences, and at the end of the day, it comes down to a matter of preference (I personally tend to go with Context).
Answer: Main difference is panels context (ctool context under the hood) its for interacting in a panel's environment while Context module interact with whole Drupal site.


How to add query parameters in twig using path()?

Question: I am following the code snippet provided here
{# Link to frontpage view. #} {{ 'View all content'|t }}

{# Link to user entity/profile page. #} {{ 'View user profile'|t }}

{# Link to node page. #} {{ 'View node page'|t }}

https://www.drupal.org/docs/8/theming/twig/functions-in-twig-templates#path
As the function says path($name, $parameters, $options), I want to add a link which has query parameters as shown in below
blue?destination=blue-search&cookie[blue_referrer]=3622&cookie[blue_type]=node

I tried implementing it as follows
Find a Distributor

but it gives an error

The website encountered an unexpected error. Please try again
  later.Twig_Error_Syntax: An
  array element must be followed by a comma. Unexpected token
  "punctuation" of value ":"
  ("punctuation" expected with value ","). in Twig_TokenStream->expect() (line 124 of /templates/node/node--product.html.twig).
  Twig_ExpressionParser->parseArrayExpression()
  (Line: 205)
Comment: Twig doesn't have associative arrays like PHP, you need to pass a hash (replace square brackets with curly ones)
Comment: You don't want to do that - 100% guaranteed-valid urls don't contain square brackets (RFC3986), they need to be escaped. The browser and server both know what to do with it so I wouldn't worry
Comment: HI @Clive thanks, Find
I need to pass '[' but its passing %5 how can I make sure the query params has [ and not '[' ?
Comment: Thanks buddy @Clive
Answer: Twig uses hashes where PHP uses associative arrays. So to fix your code just convert the array syntax to a hash literal:
{{
  path('blue_general.blue',
    {'node': node.id},
    {'query': {
      'destination': path('view.blue_search.page_1'),
      'cookie[blue_referrer]': node.id,
      'cookie[blue_type]':'node'
    }}
  )
}}

Answer: Here is an example of passing views contextual filter value into path() twig function:
{% set ical_path = path('view.events.ical', {arg_0: 12}) %}


What are the best browser based administration tools for Linux?

Question: Looking for recommendations the best comprehensive browser based administration tool for administering a Linux machine.  Ideally this would be distribution agnostic.  This could also be an "appliance" type product that would administer multiple machines on network.
This is marked community wiki.  Give your answer preferably one product per answer and vote up packages that you recommend also.
Answer: I've used webmin which offers a comprehensive set of administration tools for everything from process management, apache, BIND DNS, bandwidth monitoring, command shell, DHCP server, various mail servers, RAID, IP tunnelling, MYSQL (etc etc!) to a java based file manager - plus a shed load of 3rd party modules. It's available in RPM, deb, TAR, and solaris formats and can administer multiple machines as a "cluster". Many languages are supported too.
Comment: Just watch out for security ! Webmin should not be accessible by anyone on the Internet as in really not at all.
Comment: Webmin really is your best option, IMHO. We use it on all of our servers.
Answer: I use ebox on a server that need such an interface. It's a bit young when compared to webmin. It's worth a peek:
http://trac.ebox-platform.com/wiki/Document/FAQ/HowEboxDiffersFromWebmin
The main reason for choosing ebox being that box runs debian.
Comment: +1 for suggesting an alternative.
Answer: There are others which you can explore..

ISPConfig
Ajenti
ZPanel


use-either-port multiple interfaces between three nodes

Question: I have a network of three computers, each of which has two ports.  I do not have a network switch (the three ports are 10GbE and the switches are prohibitively expensive for now).
I would like to connect the three such that any one of them can talk to the other (*), but without depending on a strict mapping between which port of the pair should be connected to which peer.  Put another way, I'd like a configuration that's stable enough that I could swap the pair of cables connected to a single computer and at least after rebooting all three nodes, expect that the communications would work as normal.
A simple diagram:
   +---------+
   |  Node A |
   |    |eth0}-----+
   |         |?    | +---------+
   |    |eth1}-+   | |  Node C |
   +---------+ |   +-{eth0|    |
               |    ?|         |
               |   +-{eth1|    |
               |   | +---------+
   +---------+ |   |
   |  Node B | |   |
   |    |eth0}-+   |
   |         |?    |
   |    |eth1}-----+
   +---------+

Additionally, I would expect that any such configuration must be a single-hop configuration, enabling bridging (e.g.) would not be an adequate solution.
Note that there is a fixed master among the nodes, though I shouldn't think that would be a necessary component of the solution.
Is there such a configuration?  If so, how could I configure it?  From what I understand, using multiple identical routes with different interfaces may not be robust enough.  I prefer not to use solutions like iptables or tc unless those are the only appropriate tools for this particular task.
(*) "talk to the other" constitutes initiating TCP connections in any direction, UDP+ICMP traffic, etc.
Answer: The configuration that satisfies most of your requirements would be to enable bridging and spanning tree on all three servers.
If you can live without the requirement of being able to arbitrarily swap network ports, the simplest thing to do is just configure static IP's for every interface with three different subnets.
There are no configurations that satisfy all of your requirements.
Comment: Thanks for the input.  I suspect you're right, but I'll hold out for a little while to see if someone else thinks you're mistaken. :)
Answer: As far as I understand, you need in increasing bandwidth. So why don't use bonding/teaming, such as LACP: http://en.wikipedia.org/wiki/Link_Aggregation_Control_Protocol, which is supported on pretty many switches?


Understanding average treatment effect estimator notation

Question: I want to check that I understand the notation for the average treatment effect (ATE) estimator correctly, and hopefully some of you can double check this. I often try to understand formulas through specific examples. Consider a randomized controlled trial with $n=10$, where 6 have been given treatment, so that $n_1=6$, and 4 have not so $n_0=4$.
Filling in the ATE-estimator:
$\hat\tau= \frac{1}{n_1} \sum_{n=1}^{n_1} y_i(1) - \frac{1}{n_0} \sum_{n=1}^{n_0} y_i(0)$
We get,
$\hat\tau= \frac{1}{6} \sum_{n=1}^{6} y_i(1) - \frac{1}{4} \sum_{n=1}^{4} y_i(0)$
Which for the following toy data set
<code>i  t  y
1  0  1
2  0  2
3  0  2
4  0  1
5  1  3
6  1  4
7  1  5
8  1  5
9  1  6
10 1  3
</code>
corresponds to:
$\hat\tau= 0.33 \frac{3+4+5+5+6+3}{6} - 0.25 \frac{1+2+2+1}{4}=1.43-0.38=1.05$
Which says that the treatment had a positive effect of, on average, 1.05 for the population who received the treatment.
Answer: There are a few problems with what you've written, some of which are minor. First, the true ATE is $$E[y(1)] - E[y(0)]$$where $y_i(a)$ is the potential outcome under treatment level $a$. Without assumptions, this quantity cannot be estimated because $y_i(1)$ and $y_i(0)$ are not observed for any units.
Randomization gives us the assumption of exchangeability, meaning that $y(a) \perp A
\ \forall a$, which implies that $E[y(a)|A=a]=E[y(a)]$. Assuming consistency (i.e., that there are no unmeasured versions of treatment), we also have $y_i = \sum_a{I(A=a)y_i(a)}$, which implies that we can replace $y_i(a)$ with $y_i$ when we condition on $A=a$.
Under these assumptions, the difference in sample means is unbiased for the ATE. $\frac{1}{n_1}\sum_{i\in A=1}{y_i}$ is an unbiased estimator of $E[y|A=1]$, which under consistency is equal to $E[y(1)|A=1]$, which under exchangeability is equal to $E[y(1)]$. The same argument can be made for $A=0$, so we have that $\frac{1}{n_1}\sum_{i\in A=1}{y_i} - \frac{1}{n_0}\sum_{i\in A=0}{y_i}$ is unbiased for $E[y(1)] - E[y(0)]$, the ATE.
I don't know where you got the $.33$ and $.25$ in your formula. The correct math is $$\frac{3+4+5+5+6+3}{6}-\frac{1+2+2+1}{4}=\frac{26}{6}-\frac{6}{4}=2.833$$
Comment: The 6 and 4 in the denominators are those values. Summation by itself doesn't involve a denominator; the 6 and 4 are the $1/n$ for each group. You don't need to additionally include them.
Comment: Thanks for your helpful reply! My only follow-up question is an easy question on notation. I got .33 by substituting $1/n_{1}$ with 1/6 (typo 2/6), and .25 by $1/n_{0}$ with 1/4. By your reply, it seems like this notation is not included in the calculation. Thus, I wonder what the $1/n$ notation adds to the summation operator? Is it just a way to describe that the sum of all observations is to be divided by the number of observations?


Chave primária composta usando uma chave estrangeira

Question: É possível criar uma chave primária composta utilizando uma chave estrangeira?
Tenho a tabela mov_estoque, onde pensei em colocar como chave composta o id_mov e id_prod, porém, id_prod é uma chave estrangeira da tabela produtos.
tentei:
ALTER TABLE mov_estoque
DROP PRIMARY KEY, ADD PRIMARY KEY (id,id_pro);

mas recebo:

1832 - Cannot change column 'id_pro': used in a foreign key constraint 'mov_estoque_ibfk_2'
Comment: Por que ela tem que ser composta? Talvez uma tabela de movimentação e uma auxiliar relacionando n para n movimentação-produtos ficaria mais coeso no modelo, assim vc teria a movimentação em separado e os produtos desta movimentação
Answer: ALTER TABLE NomeDaTabela
ADD CONSTRAINT PK_NomeDaPK PRIMARY KEY CLUSTERED (Coluna1, Coluna2)

Caso queira adicionar a PK durante a criação da tabela, use esta sintaxe:
CREATE TABLE NomeDaTabela (
   Coluna1 INT,
   Coluna2 INT,
   CONSTRAINT PK_NomeDaPK PRIMARY KEY (Coluna1, Coluna2)
)


Prove that $\lim\limits_{n \to \infty} \int_{-\infty}^{+\infty}f(x-n)\arctan (x/n)dx=\frac{\pi}{4}\int_{-\infty}^{+\infty}f(x)dx$

Question: Let $f(x) \in L^1(-\infty,+\infty)$.
Prove that $\lim\limits_{n \to \infty} \int_{-\infty}^{+\infty}f(x-n)\arctan (x/n)dx=\frac{\pi}{4}\int_{-\infty}^{+\infty}f(x)dx$.
I took $t=x-n$, and want to evaluate the these two terms' difference
Answer: The integral is $\int_{-\infty}^\infty f(x)\arctan(\frac{x+n}{n})dx$. Note for each fixed $x$, $\lim_{n \to \infty} \frac{x+n}{n} \to 1$, so the integrand converges pointwise to $\frac{\pi}{4}f(x)$. Note for each $x,n$, $|f(x)\arctan(\frac{x+n}{n})| \le \frac{\pi}{2}|f(x)| \in L^1((-\infty,\infty))$. So you can use dominated convergence theorem to get the result.


How to use setCache for online data OkHttpClient in Android

Question: I want to show 3 fragments in my Activity and load data from json in any fragments! I need to show website data into Recyclerview with OkHTTP v3 library.
I want to show this data for offline, I mean, if user turn off data/wifi show this datas for offline. but i do not want use SQLite Database!
For this idea i use okHttpClient cache , but not found setCache for client and show me this Error : Image link
MainActivity codes:
public class MainActivity extends AppCompatActivity {

    private RecyclerView recyclerView;
    private ArrayList<AndroidVersion> data;
    private DataAdapter adapter;
    private static Context context;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        context = this;

        initViews();
    }

    private void initViews() {
        recyclerView = (RecyclerView) findViewById(R.id.card_recycler_view);
        recyclerView.setHasFixedSize(true);
        RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getApplicationContext());
        recyclerView.setLayoutManager(layoutManager);
        loadJSON();
    }

    private void loadJSON() {

        OkHttpClient client = new OkHttpClient();
        client.networkInterceptors().add(REWRITE_CACHE_CONTROL_INTERCEPTOR);

        //setup cache
        File httpCacheDirectory = new File(context.getCacheDir(), "responses");
        int cacheSize = 10 * 1024 * 1024; // 10 MiB
        Cache cache = new Cache(httpCacheDirectory, cacheSize);

        //add cache to the client
        client.setCache(cache);

        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl("http://api.learn2crack.com")
                .client(client)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        RequestInterface request = retrofit.create(RequestInterface.class);
        Call<JSONResponse> call = request.getJSON();
        call.enqueue(new Callback<JSONResponse>() {
            @Override
            public void onResponse(Call<JSONResponse> call, Response<JSONResponse> response) {

                JSONResponse jsonResponse = response.body();
                data = new ArrayList<>(Arrays.asList(jsonResponse.getAndroid()));
                adapter = new DataAdapter(data);
                recyclerView.setAdapter(adapter);
            }

            @Override
            public void onFailure(Call<JSONResponse> call, Throwable t) {
                Log.d("Error", t.getMessage());
            }
        });
    }

    private static final Interceptor REWRITE_CACHE_CONTROL_INTERCEPTOR = new Interceptor() {
        @Override
        public okhttp3.Response intercept(Chain chain) throws IOException {
            okhttp3.Response originalResponse = chain.proceed(chain.request());
            if (isNetworkAvailable(context)) {
                int maxAge = 60; // read from cache for 1 minute
                return originalResponse.newBuilder()
                        .header("Cache-Control", "public, max-age=" + maxAge)
                        .build();
            } else {
                int maxStale = 60 * 60 * 24 * 28; // tolerate 4-weeks stale
                return originalResponse.newBuilder()
                        .header("Cache-Control", "public, only-if-cached, max-stale=" + maxStale)
                        .build();
            }
        }
    };

    public static boolean isNetworkAvailable(Context context) {
        ConnectivityManager cm =
                (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
        return activeNetwork != null &&
                activeNetwork.isConnectedOrConnecting();
    }

}

How can i fix this and use okHttpClient cache?
Answer: From the screenshot, it is apparent you are using an outdated version of OkHttp. Retrofit 2 requires OkHttp 3. (The latest right now is 3.4.1.)
Also, to set the cache on the client in OkHttp 3, new OkHttpClient.Builder().cache(cache).build().


Change font colour and type in PgAdmin 8.2 / 9.1

Question: I use dark theme on windows, and my pgAdmin changes dark theme too.
It's great for me, except the black column tittle when i open the table:

I try to change the font colour to gray via File -> Options -> Browser -> UI Miscellaneous. I click 'OK', but nothing happens.
i open the UI Miscellanious again, and the font doesn't change (still black Tahoma).. :(

Somebody, please help me..
Answer: So it appears that pgadmin uses incompatible default color attributes from gtk. Namely "Windows Text" Color for the foreground and "Input Box" Color for the background.
To change the colors in ubuntu,
1. right click on the desktop -> change desktop background
2. from the Appearance Preferences Menu click the Theme Tab
3. Highlight your current theme then click Customize
4. Click the Colors tab, and change the "Windows: Text" , and "Input boxes: Background" to the colors you want for pgadmin.
5. Restart pgadmin to see the color changes.
Unfortunately this has the effect of changing your desktop color settings, and it is somewhat difficult to adjust such that you don't mess something else up. Pgadmin -- I advise you to maybe submit a bug report to pgadmin with some tag to the effect of "Incompatible Default GTK Color Classes Used on UI Rendering"


Fit a Normalizer with an array, then transform another in python with sklearn

Question: I'm not sure if i'm doing something wrong, or if this is not the correct way to do this..
I'm encoding variables in a dataset for a model, now, i'm using a Normalizer() from sklearn.preprocessing to normalize one of my variables which is numerical.
My dataset is split in two, one for the training and one for the inference. Now, my goal is to normalize this numerical variable (let's call it column x) in the training subset, and then use the normalization parameters to normalize the same variable in the inference dataset. Now, both subsets don't have the same amount of entries, so, what i'm doing is:
nr = Normalizer()
nr.fit([df1.x])
new_col = nr.transform(df1.x)

Now, the problme is.. when i try to use the same normalizer parameters on the column x in the inference subset, since it has a different number of rows:
new_col1 = nr.transform(df2.x)

I get:
X has 10 features, but Normalizer is expecting 697 features as input.
I'm not sure if it's some reshape problem or if the Normalizer() shouldn't be used in that way, so, any advice would be more than welcome.
Answer: Normalizer is used to normalize rows whereas StandardScaler is used to normalize column. Concerning your questions, it seems that you want to scale columns. Therefore you should use StandardScaler.
scikit-learn transformers excepts 2D array as input of shape (n_sample, n_feature) but pandas.Series are one-dimensional ndarray with axis labels.
You can fix that by passing a pandas.DataFrame to the transformer.
As follows:
import numpy as np
import pandas as pd
from sklearn.preprocessing import StandardScaler

df1 = pd.DataFrame({'x' : np.random.uniform(low=0, high=10, size=1000)})
df2 = pd.DataFrame({'x' : np.random.uniform(low=0, high=10, size=850)})

scaler = StandardScaler()
new_col = scaler.fit_transform(df1[['x']])
new_col1 = scaler.transform(df2[['x']])

Comment: I'm gonna give it a try that way.
Comment: Well, the code worked, but the problem now is that it outputs an array of 1's. Like, it's normalizing by row instead of by the column.
Comment: I think that's why it worked, because it's normalizing per row (which doesn't actually make any sense since every value will always be 1), and then is normalizing the second column also by row.
Comment: I modified my answer to use `StandardScaler` as you want to normalize columns.


Add dynamically multiple columns to data table

Question: Given a data table with 3 columns (the first two form the key), I'm trying to add a bunch of columns x_k with k running from 1 to N
df
>    a    b    c
1:   1    1    1
2:   1    2    1
3:   1    3    2

For each new column x_k, its value is calculated by the equation cos(2 * pi * c / k) grouped by a and b.
My approach doesn't seem to work: generating a list of column names then parsing it
df[, eval(parse(text = paste0(paste0("x_", 1:N), " := cos(2 * pi * c / ", 1:N, ")"))), by = .(a,b)]

R said c not found. How should i correct my approach other than looping through list of column names ?
Answer: Maybe try something like:
df[, paste0("x_", 1L:N) := lapply(1L:N, function(k) cos(2 * pi * c / k)), .(a, b)]

Comment: That's exactly what i came to after posting the question :D
Comment: I think i'll leave it here for later reference.
Comment: I would use `seq_len(N)`
Comment: Pls feel free to answer your own question or delete.


appropriateness of factor analysis using correlation matrix of mixed variable types

Question: I am aware that questions about factor analysis with mixed variable types have already been addressed. My situation is unique:
I have datasets from two samples that were administered the exact same 122 personality items. I wish to compare the EFA results for each sample, but the problem is that in one dataset all the items are 5-scale Likert types (strongly agree to strong disagree), and in the other dataset, 5 out of the 122 items happen to be dichotomous (yes/no).
The question at hand is whether I can do an EFA per dataset without excluding the 5 items that happen to be binary in one dataset. Whichever approach I take, it needs to be well-justified as the results will be published. Thus far, I have considered and attempted three approaches, which involve different correlation matrices:
Option 1: polychoric/tetrachoric correlation matrix
Under the strictest of interpretations, the items are all ordinal and categorical (polytomous/dichotomous), and in that sense I can obtain a matrix of polychoric and tetrachoric correlations for the odd dataset (for the other dataset, the matrix would be all polychoric).
I used Polymat-C (SPSS program) to obtain the matrix and run the EFA in SPSS, but was notified that the matrix was not positive definite. To make sure that the program was not at fault, I also obtained the matrix using R 'psych' function mixedCor, and ran the EFA in R, and again--not positive definite. I then attempted to exclude different sets of items to see if some were creating the problem but could not identify any as problematic.
Option 2: Pearson correlation matrix
Under a less strict interpretation, I could consider my items interval and continuous, as is done routinely in personality research, and use standard EFA procedures that rely on Pearson correlations. In this case, procedures can be run with no errors.
Option 3: Pearson, biserial and tetrachoric correlation matrix
Using the mixedCor function in 'psych' (R), I can obtain a matrix with:
(1) Pearson correlations between the non-dichotomous items
(2) biserial correlations between dichotomous and non-dichotomous
(3) tetrachoric between dichotomous items.
This would be used for the odd dataset, whereas an all-Pearson matrix would be used in the other.
As in option 2, the EFA procedures can be run with no errors. Looking at the results, the loadings of those 5 dichotomous items also appear to be more accurate* than when using strictly Pearson correlations (option 2).
*This requires further explanation: the 5 affected items are all part of a 30-item scale, so I am able to run a separate EFA or CFA on those 30 items to compare the results (i.e. item loadings) with the ones reported in existing publications. I can also compare the item loadings between the two datasets. I can tell that the loadings are unusually low when Option #2 is attempted compared to Option #3, but I admit that this is just "eyeballing" the results.
FINAL THOUGHTS
I am leaning towards Option 3, but I don't know if my circumstances warrant using a correlation matrix with different types of correlations, even if it only involves 5 odd items in one sample.
Looking for an informed opinion on which option is best, if any. Other options welcome but I am likely to stick to EFA (not PCA and other data reduction techniques, and confirmatory techniques are not appropriate as this is an exploratory analysis). I can also see excluding those 5 items altogether, but that is only a final resort.
Update: I have received feedback from other academics reassuring me that using a mixed correlation matrix for EFA (as noted in option 3) is not a problem. I realize this inquiry may not be helpful to others as it is too lengthy and case-specific. Should the moderators wish to close it, that would be fine.
Comment: Clarification: The 122 items are the same as in the stems are the same, but 5 have different response options, ¿correct?
Comment: Yes, that is correct.
Answer: For option #1, the problem is most likely that the estimation method for the polychoric correlations is doing an item-by-item paired estimation. The more accurate approach would be to estimate all of the correlations simultaneously, thus resulting in a correlation matrix that was not semi-negative definite (assuming the protocol can converge on an acceptable solution).
Option #2 is indeed one approach that may give an approximation to a solution spanning fewer dimensions, though if I were reviewing, I would discourage publication. Other reviewers may be less strict.
Option #3, this is a reasonable method to obtain an approximate solution, though it still has concerns. The main issue is how you are determining that some items "appear to be more accurate" when you are conducting and exploratory data analysis. (If you have an idea of the structure, you should be conducting a confirmatory factor analysis.
The option that I would recommend would be categorical confirmatory factor analysis.  This method can account for the different response options for different items (in that the tau-cuts for estimation would be fewer for those items).
Happy to provide more information if this seems like the option you'd like to pursue.
Comment: Since I am exploring the structure of a number of traits, confirmatory methods are not appropriate. Re your comments on #1: I believe the correlations were obtained simultaneously using default global=TRUE in 'mixedCor' function ('psych' R package), so not sure this is the issue. Re #3; sounds like you're saying it might be acceptable to use tetrachoric/biserial correlations for those 5 items rather than Pearson, but you're not convinced of my reasoning, so I added further context. See if it changes your opinion, as I'm very interested in finding proper justification for going with Option 3.
Comment: I haven't used mixedCor package...so just confirm that global means there is a single multivariable probability distribution being estimated vs. global meaning the same tau-cuts are applied to all items; re #3, I'd encourage you to review Finney & DiStefano's chapter (Non-Normal and Categorical data in structural equation modeling) in Hancock & Mueller's SEM, A 2nd Course...this may provide a rationale to use that approach. However, I still have concern about the the EFA vs. CFA issue...with your clarification, it still sounds as though you are working with an established measure (CFA).
Comment: Global means that the global values of tau parameters are used as opposed to the pairwise values (as documentation states). I'm doing an exploratory factor analysis of several similar personality scales (not CFA). The structure of each scale is already known; their joint structure is not known. Looking back I should have compressed my inquiry to a single question: can I justify using a "mixed" correlation matrix for the dataset with 5 binary items (and has it been done before)? Looked at the Finney & DiStefano chapter, but SEM is not relevant to what I'm doing. Appreciate your thoughts
Comment: 1. In this case, global is not producing multivariate distributions, but pairwise estimations...if you want to revisit option #1, it actually would be to your benefit to not use the global option, let the tau's be estimated freely from pair to pair, and then rerun the analysis.
Comment: 2. If the structure of each scale is known, and you want to show a different structure exists between two existing scales, then an EFA may be locating nothing more than random noise between potentially highly correlated items. I'm not saying you shouldn't do this, but at a minimum, you should still confirm (via CFA) that the original scales' measurement models are adequate (if not better than the final solution you decide upon).
Comment: 3. Not to be pedantic, but all CFA are SEMs.
Comment: Appreciate your concern for what I'm trying to do, but this discussion is straying from its intended purpose and I realize I should have provided more context for the goals of the EFA (it involves items from 12 subscales). Let's end it here, since I have now received feedback from two other academics and they reassured me that using a mixed correlation matrix under the circumstances noted will not be a problem in the review process. Thanks


Comparison the area

Question:
Any tricks to solve quickly that which one is bigger: area of DPC or area of DQR?
Comment: Hint: check the bases and height.  Can you now tell the ratio of their areas?
Answer: Hint: They obviously have equal heights. What about bases?

Comparison the area


Contador javascript/html

Question: Preciso fazer uma aplicação em javascript/jquery/html que conte os cliques do usuário no botão e quando o contador chegar em 10 trave o botão e exibe um alert, não sei porque não está exibindo. Alguém sabe?

    <title>Página</title>

    <link href src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" media="screen"></script>

    <link href="design.css" rel="stylesheet" medi="screen">

                linha azul

        <form name="input" method="get">

                      <button type="button" onclick="add_field(); contador();">ADD</button>

        </form>

Comment: `var count = 0;` fora da função `contador()` e já deve funcionar. O problema é que estás a colocar o `count = 0` cada vez que a chamavas
Answer: O seu count desta forma sempre será 0:
function contador()
    {
        var count = 0;
        count++;

        if(count == 10){
            alert("QWERTY");

        }

    };

então o correto seria você  declará o cont fora da função contador()
   var count = 0;
 function contador()
        {

            count++;

            if(count == 10){
                alert("QWERTY");
             document.getElementById('btn').disabled=true;

            }

        };

Veja o seu codigo com a alteração feita. coloque um id para o botão:

function add_field()
    {
        var form = document.getElementsByTagName('form')[0],
        input = document.createElement('textarea');
        input.setAttribute('type', 'textarea');
        input.setAttribute('name', 'item');
        form.appendChild(input);

    };

var count = 0;

function contador()
    {

        count++;

        if(count == 10){
            alert("QWERTY");
   document.getElementById('btn').disabled=true;

        }

    };

    <link href src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" media="screen">

    <link href="design.css" rel="stylesheet" medi="screen">

                linha azul

        <form name="input" method="get">

                      <button type="button" onclick="add_field(); contador();" id="btn">ADD</button>

        </form>

Contador javascript/html


Intuitive meaning of attitude error function $\Psi$ defined over $SO(3)$. Is $\Psi$ a metric?

Question: We define the attitude error function $\Psi(R, R_d)$ over $SO(3)$ as :
$$ \Psi(R, R_d) = \frac{1}{2}tr(I - R_d^{\top}R)$$
This acts as a metric to define distance between two rotation matrices which otherwise can't be calculated using euclidean vector space subtraction.
But we also know that $\Psi = \mathbb{cos(\phi)}$, where $\mathbb{\phi}$ is the rotation angle about the rotation axis as obtained through the axis-angle representation of rotation matrices.
I wanted to ask if $\Psi$ is actually a metric (in a formal sense) or not? Meaning does it satisfy the triangle inequality :
$$ \Psi(I, R) \le \Psi(I,R_d) + \Psi(R_d,R)$$
I tried working it out, also did brute force expansion, but couldn't really come to a conclusion. Since $\Psi$ corresponds to the rotation angle, I feel like this should be true as we can see by keeping an axis fixed, say $e_1$ and perform 2 successive rotations about the same axis corresponding to $R_d$ and $R$ respectively.
I have very elementary knowledge regarding the above. Any help is appreciated.
Comment: Are you sure you want $\Psi$ and not $\sqrt{\Psi}$? The latter is the distance with respect to the Frobenius norm.
Comment: Yes, it is  $\Psi $. This function is used in all the papers I have been referring to.
Comment: Too bad because $\Psi$ is not a metric while $\sqrt{\Psi}$ is a metric and a very natural one, essentially the restriction of the Euclidean metric. Your function does have a name though, it is a conditionally negative semidefinite kernel .
Comment: I kind of expected it. That makes it conclusive then. Thanks.
Comment: @MoisheCohen One last thing, so can you please tell me if I can comment about $\Psi \le M$ for some bound $M$, if I specify that $\Psi(I, R_d) \le M_1$ and $\Psi(R_d, R) \le M_2$ for some $M_1, M_2$. That was my main objective because RHS is what I have and LHS is what I want, somehow.
Answer: As I noted in my comment, your $\Psi$ is not a metric. Specific examples violating the triangle inequality are given by the triples $I, R_\phi, R_{2\phi}$, for any given $\phi\in (0, \frac{\pi}{2})$, where $I$ is the identity and $R_\psi$ is the rotation by the angle $\psi$ around the $z$-axis.
However, $\sqrt{\Psi}(A,B)$ is a metric since it equals $||A-B||_F$ where the norm is the restriction of the Frobenius norm on the space of all 3-by-3 matrices (the same works in all dimensions). Recall that the Frobenius norm $||\cdot||_F$ on the vector space of $n\times n$ matrices is the norm associated with the bilinear form
$$
\langle A, B\rangle= tr(A^TB),
$$
$$
||A||_F= \sqrt{tr(A^TA)}.
$$
From the fact that the metric defined by the Frobenius norm satisfies the triangle inequality, you get the inequality
$$
\Psi(A,C)\le [\Psi^{1/2}(A,B)+\Psi^{1/2}(B,C)]^2,
$$
for all orthogonal matrices $A, B, C$.
Nevertheless, your function $\Psi$ does satisfy an interesting "metric" property, it is what's called a conditionally negative semidefinite kernel:
Definition. Given an infinite set $X$ (such as the set of all orthogonal 3-by-3 matrices), a function $\Psi: X\times X\to {\mathbb R}$ is conditionally negative semidefinite if it determines a bilinear form of the signature $(1,\infty)$ on the space $Map_F(X, {\mathbb R})$ consisting of all maps $X\to {\mathbb R}$ with finite support. This space has the basis $\{\chi_x; x\in X\}$, where $\chi_x(x)=1, \chi_x(y)=0$ for all $y\ne x$. Then the bilinear form on $Map_F(X, {\mathbb R})$ is determined  by its value on the basis of this space which is given by the formula
$$
\langle \chi_x, \chi_y\rangle= \Psi(x,y).
$$
The fact that your function $\Psi$ has this property has nothing to do with orthogonal matrices: Given any subset $X$ of a Euclidean space $E$ (of any dimension, even a Hilbert space), the function
$$
\Psi(x,y)= \left ( dist_E(x,y) \right)^2
$$
is a conditionally negative semidefinite kernel on $X$. One can prove, furthermore, that if $X$ is a smooth submanifold of $E$ of dimension $>0$, then $\Psi$ is never a metric on $X$.
Comment: Thanks again for the comprehensive edit.


Android support design library CoordinatorLayout with webview problem

Question: I am using CoordinatorLayout with webview in my app.
but I have a problem like the image:

(source: duitang.com)
on 4.4+. I don't know what's the problem with my layout.
this is my xml layout.
<code><?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/swipelayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true">

        <android.support.design.widget.AppBarLayout
            android:id="@+id/appbar"
            android:layout_width="match_parent"
            android:layout_height="256dp"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

            <android.support.design.widget.CollapsingToolbarLayout
                android:id="@+id/collapsing_toolbar"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true"
                app:contentScrim="?attr/colorPrimary"
                app:expandedTitleMarginEnd="64dp"
                app:expandedTitleMarginStart="48dp"
                app:layout_scrollFlags="scroll|exitUntilCollapsed">

                <ImageView
                    android:id="@+id/backdrop"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:fitsSystemWindows="true"
                    android:scaleType="centerCrop"
                    app:layout_collapseMode="parallax" />

                <android.support.v7.widget.Toolbar
                    android:id="@+id/toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    app:layout_collapseMode="pin"
                    app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

            </android.support.design.widget.CollapsingToolbarLayout>

        </android.support.design.widget.AppBarLayout>

        <android.support.v4.widget.NestedScrollView
            android:id="@+id/nsv_scroll"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">

            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_margin="16dp">

                <WebView
                    android:id="@+id/webview"
                    style="@style/Widget.CardContent"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:minHeight="100dp">

                </WebView>

            </android.support.v7.widget.CardView>

        </android.support.v4.widget.NestedScrollView>

        <com.getbase.floatingactionbutton.FloatingActionButton xmlns:fab="http://schemas.android.com/apk/res-auto"
            android:id="@+id/floatingaction"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="16dp"
            android:clickable="true"
            app:layout_anchor="@id/appbar"
            app:layout_anchorGravity="bottom|right|end"
            fab:fab_colorNormal="?attr/colorAccent"
            fab:fab_colorPressed="?attr/colorAccentDark" />

    </android.support.design.widget.CoordinatorLayout>
</android.support.v4.widget.SwipeRefreshLayout>
</code>
Expected layout:

(source: duitang.com)
Comment: What are you expecting it to look like?
Comment: @Khalos  like this [image](http://img4q.duitang.com/uploads/item/201507/05/20150705010829_3cP85.png)  the webview is under the appbarlayout .   not the bottom of the screen.
Comment: https://github.com/chrisbanes/cheesesquare/blob/master/app/src/main/res/layout/activity_detail.xml
Answer: I faced the same issue yesterday and it turns out that it's a bug and fix is released in Android Support Library 22.2.1.
Please update Android Support Library. This resolved my problems.


Triple integral, volume of sphere inside cylinder; $x²+y²+z²=a²$, $x²+y²=ay$

Question: The equation of the cylinder is
$$x²+y²=ay \implies x²+\left(y-\frac{a}{2}\right)^2 = \frac{a²}{4} \tag{1}$$
and the sphere is
$$x²+y²+z²=a²$$
In order to find this integral, I first realized that the region is a sphere inside a cylinder delocated from the center. I first computed the integral with respect to $z$ of the length of the sphere, which is:
$$\int_{-\sqrt{a-x²-y²}}^{\sqrt{a-x²-y²}}dz = 2\sqrt{a-x²-y²}$$
Now, I need to take this integral over the circumference that the cylinder forms when projected to the $xy$ plane, which is $(1)$. Therefore, I need to integrate $2\sqrt{a-x²-y²}$ inside the circumference $(1)$. I'll do it in polar coordinates, so I need to make my substitutions. The idea is to substitute $x=p\cos(t), y=p\sin(t)$ and not $x=p\cos(t), y-\frac{a}{2}=p\sin(t)$ because I want to make the integrand easier, not the region. So the region will not be simply $p$ from 0 to $\frac{a}{2}$ and $\theta$ from $0$ to $2\pi$. If I make the substition $x=p\cos(t), y=p\sin(t)$ in $(1)$ I end up with the equation $p=\sin(\theta)$ for the circumference $(1)$in polar coordinates. I also know that $\theta$ must go from  $-\frac{\pi}{2}$ to  $\frac{\pi}{2}$ for this one. Therefore, my double integral becomes:
$$\int_{-\frac{\pi}{2}}^{\frac{\pi}{2}} \int_{0}^{\sin(t)} 2\sqrt{a-(p\cos(\theta))²-(p\sin(\theta))²}p\  dp \ d\theta$$
Since this integral is quite hard, I would like to know if I'm doing all fine before trying to integrate this. Wolfram Alpha does not integrate it, don't know why, but my book says the answer is $$\frac{2\cdot a³\pi}{3}$$
UPDATE:
$$\int_o^{\pi} (-1)\int_0^{a\sin(t)}\sqrt(a²-p²)-2p \ dp\  dt$$
$$u = a²-p² \implies du = -2p dp $$
$$\int_o^{\pi} (-1)\int_{a²}^{a²\cos²(t)}\sqrt(u)du\  dt=$$
$$\int_o^{\pi} (-1)\frac{2}{3}((a²\cos²(t))^{3/2}-(a²)^{3/2})dt = $$
$$(-1)\frac{2}{3}a^3\int_0^{\pi} (\cos^3(t)-1)  dt = \frac{2\cdot a³\pi}{3}$$
:)
Answer: First, the boundary of the sphere is $z = \pm\sqrt{a^\color{red}{2}-x^2-y^2}$ (note the exponent on $a$).
Also, the region bounded by $x^2+y^2 = ay$ is a circle of radius $\tfrac{a}{2}$ centered at $(0,\tfrac{a}{2})$. If you sketch this, you'll see that the bounds for $\theta$ are $0 \le \theta \le \pi$ instead of $-\tfrac{\pi}{2} \le \theta \le \tfrac{\pi}{2}$.
So, your double integral (in polar coordinates) is $$\displaystyle\int_{0}^{\pi}\int_{0}^{a\sin \theta}2\sqrt{a^2-(p \cos \theta)^2-(p \sin \theta)^2}p\,dp\,d\theta$$
Using the identity $(\cos\theta)^2+(\sin\theta)^2 = 1$, you can simplify the integral as $$\displaystyle\int_{0}^{\pi}\int_{0}^{a\sin \theta}2\sqrt{a^2-p^2}p\,dp\,d\theta$$
For the inner integral, substitute $u = a^2-p^2$, $du = -2p\,dp$. This will give you something which is easy to integrate.
Comment: why from $0$ to $\pi$? For me, $-\pi/2$ to $\pi/2$ works: http://www.wolframalpha.com/input/?i=polar+plot+p+%3D+sin%28t%29%2C+t+from+-pi%2F2+to+pi%2F2-0.1
Comment: The circle $x^2+y^2=ay$ lies in the first and second quadrants. So if you substitute $x = p\cos\theta$ and $y = p\sin\theta$, then your range of $\theta$ will be $0$ to $\pi$ instead of $-\pi/2$ to $\pi/2$ (which goes over the fourth and first quadrants). For this problem, you might get the same answer using either set of bounds due to symmetry.
Comment: thanks, I updated my question with the solution
Answer: I think, conversely, that the double integrals are easy to handle. Note that we are facing a symmetric region so we can solve just: $$2\int_0^{\theta=\pi/2}\int_0^{a\sin(\theta)}\sqrt{a^2-r^2}~rdrd\theta$$