text:
Q: how arrange my data in txt file for plot mesh in latex? i have a data file and want plot mesh/surface for it but the output isn't suitable.
\documentclass{article}
\usepackage{tikz, pgfplots}
\usepackage{pgfplots}
\begin{document}
% Preamble: \pgfplotsset{width=7cm,compat=1.11}
\begin{tikzpicture}
\begin{axis}
\addplot3[surf,mesh/ordering=y varies,mesh/cols=16]
table {data3.txt};
\end{axis}
\end{tikzpicture}
\end{document}

and my data is:

x y z
0   0   0
0   0   0
0   2   0
0   4   0
0   6   0
0   8   0
0   10  0
0   12  0
0   14  0
0   16  0
0   18  0
0   20  0
0   22  0
0   24  0
0   26  0
0   28  0
0   30  0
0   32  0
0   34  0
0   36  0
0   38  0
0   40  0
0   42  0
0   44  0
0   46  0
0   48  0
0   50  0
0   52  0
0   54  0
0   56  0
0   58  0
0   60  0
0   62  0
1   62  0.0200000000000000
1   0   0.0131000000000000
1   2   0.0128000000000000
1   4   0.0132000000000000
1   6   0.0142000000000000
1   8   0.0153000000000000
1   10  0.0220000000000000
1   12  0.0300000000000000
1   14  0.0405000000000000
1   16  0.0478000000000000
1   18  0.0472000000000000
1   20  0.0648000000000000
1   22  0.0597000000000000
1   24  0.0663000000000000
1   26  0.0767000000000000
1   28  0.0842000000000000
1   30  0.0876000000000000
1   32  0.0876000000000000
1   34  0.0842000000000000
1   36  0.0767000000000000
1   38  0.0663000000000000
1   40  0.0597000000000000
1   42  0.0648000000000000
1   44  0.0472000000000000
1   46  0.0478000000000000
1   48  0.0405000000000000
1   50  0.0300000000000000
1   52  0.0220000000000000
1   54  0.0153000000000000
1   56  0.0142000000000000
1   58  0.0132000000000000
1   60  0.0128000000000000
1   62  0.0131000000000000
2   62  0.0331000000000000
2   0   0.0268000000000000
2   2   0.0262000000000000
2   4   0.0271000000000000
2   6   0.0290000000000000
2   8   0.0323000000000000
2   10  0.0455000000000000
2   12  0.0644000000000000
2   14  0.0849000000000000
2   16  0.104500000000000
2   18  0.113800000000000
2   20  0.141400000000000
2   22  0.146000000000000
2   24  0.165500000000000
2   26  0.181500000000000
2   28  0.199200000000000
2   30  0.208200000000000
2   32  0.208200000000000
2   34  0.199200000000000
2   36  0.181500000000000
2   38  0.165500000000000
2   40  0.146000000000000
2   42  0.141400000000000
2   44  0.113800000000000
2   46  0.104500000000000
2   48  0.0849000000000000
2   50  0.0644000000000000
2   52  0.0455000000000000
2   54  0.0323000000000000
2   56  0.0290000000000000
2   58  0.0271000000000000
2   60  0.0262000000000000
2   62  0.0268000000000000
3   62  0.0468000000000000
3   0   0.0410000000000000
3   2   0.0410000000000000
3   4   0.0435000000000000
3   6   0.0453000000000000
3   8   0.0527000000000000
3   10  0.0731000000000000
3   12  0.102500000000000
3   14  0.137500000000000
3   16  0.168600000000000
3   18  0.191000000000000
3   20  0.232900000000000
3   22  0.247000000000000
3   24  0.276400000000000
3   26  0.306000000000000
3   28  0.332000000000000
3   30  0.344000000000000
3   32  0.344000000000000
3   34  0.332000000000000
3   36  0.306000000000000
3   38  0.276400000000000
3   40  0.247000000000000
3   42  0.232900000000000
3   44  0.191000000000000
3   46  0.168600000000000
3   48  0.137500000000000
3   50  0.102500000000000
3   52  0.0731000000000000
3   54  0.0527000000000000
3   56  0.0453000000000000
3   58  0.0435000000000000
3   60  0.0410000000000000
3   62  0.0410000000000000
4   62  0.0610000000000000
4   0   0.0546000000000000
4   2   0.0552000000000000
4   4   0.0572000000000000
4   6   0.0609000000000000
4   8   0.0703000000000000
4   10  0.0976000000000000
4   12  0.137000000000000
4   14  0.182600000000000
4   16  0.225500000000000
4   18  0.260100000000000
4   20  0.310300000000000
4   22  0.337200000000000
4   24  0.374800000000000
4   26  0.411100000000000
4   28  0.438800000000000
4   30  0.455900000000000
4   32  0.455900000000000
4   34  0.438800000000000
4   36  0.411100000000000
4   38  0.374800000000000
4   40  0.337200000000000
4   42  0.310300000000000
4   44  0.260100000000000
4   46  0.225500000000000
4   48  0.182600000000000
4   50  0.137000000000000
4   52  0.0976000000000000
4   54  0.0703000000000000
4   56  0.0609000000000000
4   58  0.0572000000000000
4   60  0.0552000000000000
4   62  0.0546000000000000
5   62  0.0746000000000000
5   0   0.0694000000000000
5   2   0.0697000000000000
5   4   0.0731000000000000
5   6   0.0776000000000000
5   8   0.0889000000000000
5   10  0.124600000000000
5   12  0.174300000000000
5   14  0.231600000000000
5   16  0.285300000000000
5   18  0.332300000000000
5   20  0.392700000000000
5   22  0.428900000000000
5   24  0.473500000000000
5   26  0.514100000000000
5   28  0.549600000000000
5   30  0.567500000000000
5   32  0.567500000000000
5   34  0.549600000000000
5   36  0.514100000000000
5   38  0.473500000000000
5   40  0.428900000000000
5   42  0.392700000000000
5   44  0.332300000000000
5   46  0.285300000000000
5   48  0.231600000000000
5   50  0.174300000000000
5   52  0.124600000000000
5   54  0.0889000000000000
5   56  0.0776000000000000
5   58  0.0731000000000000
5   60  0.0697000000000000
5   62  0.0694000000000000
6   62  0.0894000000000000
6   0   0.0836000000000000
6   2   0.0834000000000000
6   4   0.0874000000000000
6   6   0.0936000000000000
6   8   0.107600000000000
6   10  0.148400000000000
6   12  0.205200000000000
6   14  0.272300000000000
6   16  0.333400000000000
6   18  0.390100000000000
6   20  0.456900000000000
6   22  0.501600000000000
6   24  0.550200000000000
6   26  0.595600000000000
6   28  0.627200000000000
6   30  0.642200000000000
6   32  0.642200000000000
6   34  0.627200000000000
6   36  0.595600000000000
6   38  0.550200000000000
6   40  0.501600000000000
6   42  0.456900000000000
6   44  0.390100000000000
6   46  0.333400000000000
6   48  0.272300000000000
6   50  0.205200000000000
6   52  0.148400000000000
6   54  0.107600000000000
6   56  0.0936000000000000
6   58  0.0874000000000000
6   60  0.0834000000000000
6   62  0.0836000000000000
7   62  0.103600000000000
7   0   0.0987000000000000
7   2   0.0989000000000000
7   4   0.103600000000000
7   6   0.110400000000000
7   8   0.127000000000000
7   10  0.174200000000000
7   12  0.237300000000000
7   14  0.310200000000000
7   16  0.378500000000000
7   18  0.441700000000000
7   20  0.513900000000000
7   22  0.564500000000000
7   24  0.615600000000000
7   26  0.658700000000000
7   28  0.685200000000000
7   30  0.696000000000000
7   32  0.696000000000000
7   34  0.685200000000000
7   36  0.658700000000000
7   38  0.615600000000000
7   40  0.564500000000000
7   42  0.513900000000000
7   44  0.441700000000000
7   46  0.378500000000000
7   48  0.310200000000000
7   50  0.237300000000000
7   52  0.174200000000000
7   54  0.127000000000000
7   56  0.110400000000000
7   58  0.103600000000000
7   60  0.0989000000000000
7   62  0.0987000000000000
8   62  0.118700000000000
8   0   0.112900000000000
8   2   0.112700000000000
8   4   0.118000000000000
8   6   0.126300000000000
8   8   0.146000000000000
8   10  0.196700000000000
8   12  0.263300000000000
8   14  0.340600000000000
8   16  0.413700000000000
8   18  0.481900000000000
8   20  0.555000000000000
8   22  0.611300000000000
8   24  0.661600000000000
8   26  0.698600000000000
8   28  0.719500000000000
8   30  0.728900000000000
8   32  0.728900000000000
8   34  0.719500000000000
8   36  0.698600000000000
8   38  0.661600000000000
8   40  0.611300000000000
8   42  0.555000000000000
8   44  0.481900000000000
8   46  0.413700000000000
8   48  0.340600000000000
8   50  0.263300000000000
8   52  0.196700000000000
8   54  0.146000000000000
8   56  0.126300000000000
8   58  0.118000000000000
8   60  0.112700000000000
8   62  0.112900000000000
9   62  0.132900000000000
9   0   0.128400000000000
9   2   0.128600000000000
9   4   0.134500000000000
9   6   0.144100000000000
9   8   0.166600000000000
9   10  0.220400000000000
9   12  0.289500000000000
9   14  0.368300000000000
9   16  0.444400000000000
9   18  0.517100000000000
9   20  0.592900000000000
9   22  0.650800000000000
9   24  0.697400000000000
9   26  0.730000000000000
9   28  0.747900000000000
9   30  0.757000000000000
9   32  0.757000000000000
9   34  0.747900000000000
9   36  0.730000000000000
9   38  0.697400000000000
9   40  0.650800000000000
9   42  0.592900000000000
9   44  0.517100000000000
9   46  0.444400000000000
9   48  0.368300000000000
9   50  0.289500000000000
9   52  0.220400000000000
9   54  0.166600000000000
9   56  0.144100000000000
9   58  0.134500000000000
9   60  0.128600000000000
9   62  0.128400000000000
10  62  0.148400000000000
10  0   0.142200000000000
10  2   0.143300000000000
10  4   0.149200000000000
10  6   0.159900000000000
10  8   0.185000000000000
10  10  0.242100000000000
10  12  0.311500000000000
10  14  0.391100000000000
10  16  0.469100000000000
10  18  0.543800000000000
10  20  0.619700000000000
10  22  0.679800000000000
10  24  0.723200000000000
10  26  0.753600000000000
10  28  0.770500000000000
10  30  0.778600000000000
10  32  0.778600000000000
10  34  0.770500000000000
10  36  0.753600000000000
10  38  0.723200000000000
10  40  0.679800000000000
10  42  0.619700000000000
10  44  0.543800000000000
10  46  0.469100000000000
10  48  0.391100000000000
10  50  0.311500000000000
10  52  0.242100000000000
10  54  0.185000000000000
10  56  0.159900000000000
10  58  0.149200000000000
10  60  0.143300000000000
10  62  0.142200000000000
11  62  0.162200000000000
11  0   0.157500000000000
11  2   0.158500000000000
11  4   0.165400000000000
11  6   0.177100000000000
11  8   0.204800000000000
11  10  0.264300000000000
11  12  0.334400000000000
11  14  0.414500000000000
11  16  0.492600000000000
11  18  0.568500000000000
11  20  0.645200000000000
11  22  0.703700000000000
11  24  0.747000000000000
11  26  0.775600000000000
11  28  0.791400000000000
11  30  0.798400000000000
11  32  0.798400000000000
11  34  0.791400000000000
11  36  0.775600000000000
11  38  0.747000000000000
11  40  0.703700000000000
11  42  0.645200000000000
11  44  0.568500000000000
11  46  0.492600000000000
11  48  0.414500000000000
11  50  0.334400000000000
11  52  0.264300000000000
11  54  0.204800000000000
11  56  0.177100000000000
11  58  0.165400000000000
11  60  0.158500000000000
11  62  0.157500000000000
12  62  0.177500000000000
12  0   0.172100000000000
12  2   0.173400000000000
12  4   0.180700000000000
12  6   0.193300000000000
12  8   0.223900000000000
12  10  0.285200000000000
12  12  0.356200000000000
12  14  0.436300000000000
12  16  0.514200000000000
12  18  0.589700000000000
12  20  0.665900000000000
12  22  0.723600000000000
12  24  0.765800000000000
12  26  0.794200000000000
12  28  0.809600000000000
12  30  0.816500000000000
12  32  0.816500000000000
12  34  0.809600000000000
12  36  0.794200000000000
12  38  0.765800000000000
12  40  0.723600000000000
12  42  0.665900000000000
12  44  0.589700000000000
12  46  0.514200000000000
12  48  0.436300000000000
12  50  0.356200000000000
12  52  0.285200000000000
12  54  0.223900000000000
12  56  0.193300000000000
12  58  0.180700000000000
12  60  0.173400000000000
12  62  0.172100000000000
13  62  0.192100000000000
13  0   0.188800000000000
13  2   0.190000000000000
13  4   0.197600000000000
13  6   0.211800000000000
13  8   0.244800000000000
13  10  0.308100000000000
13  12  0.380700000000000
13  14  0.460900000000000
13  16  0.537000000000000
13  18  0.611600000000000
13  20  0.686300000000000
13  22  0.742400000000000
13  24  0.785300000000000
13  26  0.813100000000000
13  28  0.827700000000000
13  30  0.834200000000000
13  32  0.834200000000000
13  34  0.827700000000000
13  36  0.813100000000000
13  38  0.785300000000000
13  40  0.742400000000000
13  42  0.686300000000000
13  44  0.611600000000000
13  46  0.537000000000000
13  48  0.460900000000000
13  50  0.380700000000000
13  52  0.308100000000000
13  54  0.244800000000000
13  56  0.211800000000000
13  58  0.197600000000000
13  60  0.190000000000000
13  62  0.188800000000000
14  62  0.208800000000000
14  0   0.203800000000000
14  2   0.205300000000000
14  4   0.213700000000000
14  6   0.229000000000000
14  8   0.264100000000000
14  10  0.329300000000000
14  12  0.403200000000000
14  14  0.483400000000000
14  16  0.557500000000000
14  18  0.631300000000000
14  20  0.703900000000000
14  22  0.758200000000000
14  24  0.800300000000000
14  26  0.829100000000000
14  28  0.843200000000000
14  30  0.849100000000000
14  32  0.849100000000000
14  34  0.843200000000000
14  36  0.829100000000000
14  38  0.800300000000000
14  40  0.758200000000000
14  42  0.703900000000000
14  44  0.631300000000000
14  46  0.557500000000000
14  48  0.483400000000000
14  50  0.403200000000000
14  52  0.329300000000000
14  54  0.264100000000000
14  56  0.229000000000000
14  58  0.213700000000000
14  60  0.205300000000000
14  62  0.203800000000000
15  62  0.223800000000000
15  0   0.220600000000000
15  2   0.222200000000000
15  4   0.231000000000000
15  6   0.247800000000000
15  8   0.285600000000000
15  10  0.351900000000000
15  12  0.427000000000000
15  14  0.506800000000000
15  16  0.579400000000000
15  18  0.651800000000000
15  20  0.721700000000000
15  22  0.774000000000000
15  24  0.815800000000000
15  26  0.845100000000000
15  28  0.858800000000000
15  30  0.863900000000000
15  32  0.863900000000000
15  34  0.858800000000000
15  36  0.845100000000000
15  38  0.815800000000000
15  40  0.774000000000000
15  42  0.721700000000000
15  44  0.651800000000000
15  46  0.579400000000000
15  48  0.506800000000000
15  50  0.427000000000000
15  52  0.351900000000000
15  54  0.285600000000000
15  56  0.247800000000000
15  58  0.231000000000000
15  60  0.222200000000000
15  62  0.220600000000000
16  62  0.240600000000000
16  0   0.235700000000000
16  2   0.237700000000000
16  4   0.247400000000000
16  6   0.264900000000000
16  8   0.304900000000000
16  10  0.372900000000000
16  12  0.447500000000000
16  14  0.528100000000000
16  16  0.599400000000000
16  18  0.669100000000000
16  20  0.736900000000000
16  22  0.787800000000000
16  24  0.829100000000000
16  26  0.858100000000000
16  28  0.871800000000000
16  30  0.877400000000000
16  32  0.877400000000000
16  34  0.871800000000000
16  36  0.858100000000000
16  38  0.829100000000000
16  40  0.787800000000000
16  42  0.736900000000000
16  44  0.669100000000000
16  46  0.599400000000000
16  48  0.528100000000000
16  50  0.447500000000000
16  52  0.372900000000000
16  54  0.304900000000000
16  56  0.264900000000000
16  58  0.247400000000000
16  60  0.237700000000000
16  62  0.235700000000000
17  62  0.255700000000000
17  0   0.253700000000000
17  2   0.255900000000000
17  4   0.266500000000000
17  6   0.285300000000000
17  8   0.328100000000000
17  10  0.397200000000000
17  12  0.472300000000000
17  14  0.553200000000000
17  16  0.623300000000000
17  18  0.690000000000000
17  20  0.754500000000000
17  22  0.803100000000000
17  24  0.843200000000000
17  26  0.872700000000000
17  28  0.886400000000000
17  30  0.891600000000000
17  32  0.891600000000000
17  34  0.886400000000000
17  36  0.872700000000000
17  38  0.843200000000000
17  40  0.803100000000000
17  42  0.754500000000000
17  44  0.690000000000000
17  46  0.623300000000000
17  48  0.553200000000000
17  50  0.472300000000000
17  52  0.397200000000000
17  54  0.328100000000000
17  56  0.285300000000000
17  58  0.266500000000000
17  60  0.255900000000000
17  62  0.253700000000000
18  62  0.273700000000000
18  0   0.272700000000000
18  2   0.275100000000000
18  4   0.285900000000000
18  6   0.307000000000000
18  8   0.351300000000000
18  10  0.422700000000000
18  12  0.497400000000000
18  14  0.578400000000000
18  16  0.648400000000000
18  18  0.709000000000000
18  20  0.771700000000000
18  22  0.818000000000000
18  24  0.857200000000000
18  26  0.886100000000000
18  28  0.899500000000000
18  30  0.905200000000000
18  32  0.905200000000000
18  34  0.899500000000000
18  36  0.886100000000000
18  38  0.857200000000000
18  40  0.818000000000000
18  42  0.771700000000000
18  44  0.709000000000000
18  46  0.648400000000000
18  48  0.578400000000000
18  50  0.497400000000000
18  52  0.422700000000000
18  54  0.351300000000000
18  56  0.307000000000000


text:
Q: Centering Checkbox in Table I'm using an MDBootstrap Custom checkbox and want to display it in a table cell for every foreach loop in Razor. The foreach doesn't really matter though, but I can't get the checkbox to center horizontally. A normal Checkbox input works fine, but when I use the custom Checkbox from bootstrap, it's not aligned to center anymore. This is my HTML with custom checkbox.

             <input type="checkbox" class="custom-control-input" id="defaultUnchecked">

This is the normal checkbox that works
<input type="checkbox" >

On the following picture you can see both the custom and standard checkbox. The one without the warning background is the one I would want centered.

A: Just add custom css for MDBootstrap Custom checkbox like this:

.custom-control-label::before, .custom-control-label::after {
  left: -1.25rem !important;
}

<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.0/css/all.css">

<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.2.1/css/bootstrap.min.css" rel="stylesheet">

<link href="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.7.3/css/mdb.min.css" rel="stylesheet">

                <input type="checkbox" class="custom-control-input" id="defaultUnchecked">

            <input type="checkbox" >

redpajama_set_name: RedPajamaStackExchange


text:
Q: How do you get Black Dye besides buying it? With a selling price pushing 3G, Black Dye is clearly in demand. Other than buying it, how can someone get it? Random drops only? Can it be forged with Mystic Coins?

A: *

*All monsters can drop Unidentified Dye.

*You can very rarely get Unidentified Dye from gathering wild plants (with the sickle).

*There are sparse reports that a rare Unidentified Gray Dye, made by chefs, may produce Black dye when opened.

*You can combine 4 dyes in the Mystic Forge for a chance of another random dye.


text:
Q: scipy kde contour to probability I have created a bivariate gaussian using the scipy.state kde library:
k = kde.gaussian_kde(data.T)
However I don't understand how the contours or z values relate to the probability of a new data point falling within those contours,
ngenerated distribution with contours
I would like to be able to define a contour with the equivalent of p=0.001, or put another way a contour defining 99.9% of expected observations.


text:
Q: Can we import posts directly into Wordpress database? We published a daily blog starting in 1998, almost before the word "blog" was invented. We had static pages set up in a folder structure, but /year/month/date/index.shtml + content here
We switched to Wordpress in November of 2008 and are now scraping the archives 1998-2008 and converting to JSON... with Title, Description, Category, Date and then we are using a PHP widget to read the JSON, convert to xml and upload using the WP RSS uploader. The problem is the RSS loader is very buggy and is failing. It keeps telling us posts are already in the database, even though the new posts have a unique date string and content string. the upload file is very small, only 3 MB, PHP has plenty of memory 120MB and upload file limit is set to 32MB
We note that if one manually adds a record to the wp_posts table from the back end, using something like PHPMyAdmin, it works fine. Since the RSS import is broken, we want to try to bulk upload old posts directly into the wp_post table, but we need to add the category also. I think this is done in the wp_term_relationships table where the object_id = the post_id in the post table.
Can anyone add more light on this? Are their more dependencies that need to be inserted into other tables? We are only interested in the post, no comments or anything else. I would also need to know what the standard if for the GUID field.
If this is a really bad idea, then given the RSS uploader in 3.6 is broken, what can we do?  Is did see the CVS importer plug in and we may try that... but I wanted to know if we can do it directly in PHPMyAdmin or some other standard tool for importing directly into the database. We just need to make sure the category gets inserted.

A: Sure you can do it in PhpMyAdmin. PhpMyAdmin > SQL
INSERT INTO `wp_posts` (`ID`, `post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_content_filtered`, `post_parent`, `guid`, `menu_order`, `post_type`, `post_mime_type`, `comment_count`)
Your values start here.
VALUES(1, 1, '2013-11-05 03:06:30', '2013-11-05 03:06:30', 'Old blog post content', 'Post Title', '', 'publish', 'open', 'open', '', 'Post Name', '', '', '2013-11-05 03:06:30', '2013-11-05 03:06:30', '', 0, 'http://localhost:8080/wordpress/?p=1', 0, 'post', '', 1)

I would use the Mail Merge feature in MS Office to create the queries. Put all the old posts in to an excel spreadsheet. The header row of the spreadsheet should correspond to...
ID`, `post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_content_filtered`, `post_parent`, `guid`, `menu_order`, `post_type`, `post_mime_type`, `comment_count
Then when your xls file is ready create a new document in MS Word. When you select new recipients reference the xls list that you created. Insert the merge fields into the correct place in the query... It will looks something like this:
VALUES('<ID>','<post_author>','<post_date>'.....

A: If you're nervous about importing the old data directly into the WordPress database, you can use CSV as an intermediary format.  There are many plugins built for this.  Here's one that looks like it's in active development:
http://wordpress.org/plugins/wp-ultimate-csv-importer/

A: Good Question.
Let us think about writing a post.
All the information written there is all about wp_post.
At the time of writing a WordPress post, you can input what GUId is and other meta informations are. Also, any other information is not possible to be entered.
Now,
insert into 'wp_post' ('ID', 'post_author','post_date','post_date_gmt','post_content','post_content_filtered','post_title','post_excerpt','post_status','post_type','comment_status','ping_status','post_password','post_name','to_ping','pinged','post_modified','post_modified_gmt','post_parent','menu_order','post_mime_type','guid','post_category','tags_input','tax_input',meta_input');

in phpmyadmin is the best way.
And You should see the reference
And a database diagram.
[
wp_post centered in diagram is well liked to other tables.


text:
Q: Great Expectations - Result validation for row_count and column_freshness I would like to validate results for row count and column freshness on some data on AWS. I am using a check_config.json file to configure the checks. I use terraform to make a Glue job to run the check and throw the result to DynamoDB. The result in DynamoDB is not elaborate and I would like the result to be more specific on the exact results obtained before marking a check as fail or pass. I would like to see, for example, when was the table last modified(column freshness) and number of rows obtained after a count (expect_row_count).
Below is the current result in DynamoDB:

Below is the json code:
   {
        "table": "table1",

        "checks": [
            {
               "check": "custom_expect_column_to_be_fresh",
         "parameters": {
              "columns": [
                "column1"
             ],
            "strftime_format": "%Y-%m-%d",
            "threshold_days": 0,
             "threshold_hours": 10
          }
        },
        {
          "check": "expect_table_row_count_to_be_between",
          "result_format" : "COMPLETE",
          "include_config": "True",
          "parameters": {
            "min_value": 1,
            "max_value": 100000

          },
              "alarm" : {
                "threshold": 100,
                "period": 3600
              }
            }
        ]
      }

I was expecting a more elaborate result on how many rows were obtained before the row_count is marked as a failure and I also want to see the last table modification timestamp before column freshness marks as a failure.


text:
Q: PHP check input type for validation I'm wondering if there is a way to check what type of input was used for $_POST information. I want to then use that type for validation. For instance, if an input type="text" then I would want to be able to create certain validations for that type of input.
So this is my code to generate the form:
$fields = array(
    array(
        'label' => 'Name:',
        'id' => $meta.'_nhm_lead_name',
        'class' => 'field-name input', // optional
        'wrapper_class' => 'four columns', // optional
        'type' => 'text',
        'required' => true,
    ),
)

and this is how I generate the html:
    public function make_fields(){
    foreach($this->fields as $field => $value){
        switch ($value['type']) {
            case 'text':
                $inputs .= '
';
                $inputs .= '<input type="text" name="'.$value['id'].'" class="'.$value['class'].'" />';
                $inputs .= '';
                $inputs .= '
';
            break;
         }
     }
     }

A: When receiving the data from $_POST only the values are passed. However, you can use an structure like this:
$Fields = array(
  array('type' => 'text',   'name' => 'name'),
  array('type' => 'text',   'name' => 'password'),
  array('type' => 'number', 'name' => 'age'));

Then generate the html form from that. So then, you can use that same variable to generate the validation. However, this is normally too much work for few forms (engine to generate form inputs from an array), and it's preferred to make it 'hardcoded' unless you are using already a framework with this functionality.
To give you an idea, the form would be like:
<form method = "POST" action = "/post.php">
  <?php foreach ($Fields as $Input) {
    switch($Input['type']) {
      case "text":
        echo "<input type = 'text' name = '" . $Input['name'] . "'>";
        break;
      case "number":
        echo "<input type = 'number' name = '" . $Input['name'] . "'>";
        break;
      }
    }
   ?>
 </form>

And then in post.php:
foreach ($Fields as $Input) {
  $Name = $Input['name'];
  if (array_key_exists($Name, $_POST) &&
      // You need to define this:
      checktype($_POST[$Name], $Input['type'])) {
    $Posted = $_POST[$Name];
    }
  }

A: You would want to do that based on the name of the key in the $_POST array.  A user can submit data without using any type (Javascript for example) making what you are asking to do impractical.  They would be sending data that had no type.
Data being posted to your page can come from anywhere.
For re-usability, create a data object for the submission of your form that contains the validations for each of the inputs or write a validation function.  Keep that on the server so that a malicious user isn't able to manipulate the data and change how you validate what is being submitted.

A: You could write a jQuery script that checks the prop of the input, and then adds it to the $_POST.  Something like:
HTML:
<form method="POST" action = "here.php" id="myform">
   <input type="text" value="hello" id= "input1" />
</form>

jQuery:
var input1type="&input1type=" + $('#input1').prop('type');
$.post('here.php', $('#myform').serialize()+input1type );

This would be best used if you can't affect the originating HTML.
Please note, that this is dangerous, and you can't trust the data from the www, but it might work in a secured (such as intranet) system.


text:
Q: javascript: classes and get methods before class syntax i am creating a class in a old way without the new class syntax like this:
function User(name, lastname){
  this.name = name;
  this.lastname = lastname;
  this.fullname = function(){
    return this.name+' '+this.lastname;
  }
}

i would like to use fullname as a get method. but i don't get how to do  it.
for example i would like to call it this way:
var u = new User('dario', 'developer');
console.log(u.fullname);

basically without parentheses. I know with the new class syntax you can use the get keyword. but how can i do it with this way of creating classes?

A: You should use Object.defineProperty (BEWARE: it's supported from ES5 onward, otherwise you have to make it thorugh an object literal declaration, but that would need to change your current code a bit more) if you want to keep your current scenario.

function User(name, lastname){
  this.name = name;
  this.lastname = lastname;
  Object.defineProperty(this, "fullname", {
    get: function() {
      return this.name+' '+this.lastname;
    }
  });
}

var u = new User('dario', 'developer');
console.log(u.fullname);


text:
Q: How to pass double[][] into a method call? Hi I am trying to init an object with a double value in the format double filter[3][3];
but i keep getting the following error.
cannot convert 'double[3][3]' to 'double' in assignment.
in my header i have this
@interface filter : NSObject
{
    double **matrix;
}
@property(nonatomic)double **matrix;
-(id)initWithMatrix:(double**)filterMatrix;

inside my class i have this method.
-(id)initWithMatrix:(double**)filterMatrix
{
    matrix = filterMatrix;
    return self;
}

and i am trying to call it like this.
double filter[3][3] = {0,0,0,0,1,0,0,0,0};
MyMatrix *myMatrix = [[MyMatrix alloc] initWithMatrix:filter];

I now get the error.
Error: Cannot convert double[*][3] to double** in argument passing

Any help on this issue would be amazing.
Thanks
A

A: That's because double** isn't the equivalent of double[*][*]. In fact, double[*][*] is an invalid type, because it leaves the stride undefined. double** is a pointer to a pointer to a double, or to put it another way, it's a pointer to an array of doubles. You should just use double* as your type.
Edit: To clarify, double[*][3] is still just an array of doubles, even though it has 2 dimensions. This is still the equivalent of double*.

A: you are passing as a parameter a double 2d array(double[][]) when your method signature asks for a double (a primitive like 34.2).
set the method declaration to
- (id)initWithMatrix:(double*) matrix;
this passes a pointer to your array (2d) to the method.
edit: missed a semicolon.

A: A two-dimensional array is not the same thing as a pointer-to-a-pointer.  You have two choices - change the filter class to contain a 2D array, or change your initialization to use pointer-to-pointers.
In choice #1, you're could keep a copy of the array in your filter instance, instead of just holding a pointer.  You need to change the class interface:
@interface filter : NSObject
{
    double matrix[3][3];
}

-(id)initWithMatrix:(double[3][3])filterMatrix;

Then your implementation of initWithMatrix: can just do a memcpy() or the equivalent to copy the data into your instance.
Choice #2 is a bit different.  Keep your other code the way it is, but change your initialization of filter:
double row0[3] = {0,0,0};
double row1[3] = {0,1,0};
double row2[3] = {0,0,0};
double **filter[3] = { row0, row1, row2 };

It's probably safer to malloc() all of those arrays, since otherwise you're going to end up with references to stack variables in your filter class, but I think you get the idea.


text:
Q: sed is not replacing all occurences when using cat when I apply the following to the tail of a file:
tail test9 | sed -e '/},/N;s/,\n*\]/]/g' >wtf

I get the correct result:
{"_id":{"},oid":"58dc04a9fbca629d612f1905"},"memberID":"114526","gender":"M","a    ge":"33","ethnicOriginCountryName":"Egypt","sect":"SU"},
{"_id":{"},oid":"58dc04a9fbca629d612f190d"},"memberID":"114534","gender":"M","age":"24","ethnicOriginCountryName":"United Kingdom","sect":"SU"}]

however when using cat
cat test9 | sed -e '/},/N;s/,\n*\]/]/g' >wtf

I do not get the correct result:
{"_id":{"},oid":"58dc04a9fbca629d612f1905"},"memberID":"114526","gender":"M","age":"33","ethnicOriginCountryName":"Egypt","sect":"SU"},
{"_id":{"},oid":"58dc04a9fbca629d612f190d"},"memberID":"114534","gender":"M","age":"24","ethnicOriginCountryName":"United Kingdom","sect":"SU"},
]

A: Using N command in sed has its limitations. It works if the input is pair of lines. In your case the input is not just pair of lines, but rather a paragraph ended by ].
The solution is to keep reading the whole paragraph, then replacing \n,] with ,], then finally printing the paragraph.
sed -e '1h;1!H;/]/!d' -e 'x;s/,\n]/]/;s/]\n//' test9

Here's what each of those sed commands do:
1h - if it is line 1, replace hold space with the contents of pattern space.
1!H - except line 1, append a newline followed by the contents of pattern space to the hold space.
/]/!d - delete pattern space except when it contains pattern /]/.
x - swap the contents of the pattern and hold spaces.
s/,\n]/]/ - replace ,\n] with ,].
s/]\n// - remove the pattern ]\n which were inadvertenly pre-pended.
One word of advise, sed is not the right tool when working on json objects. Use jq. Your input seems to be a broken (mangled) json therefore jq will no longer work on it.
Thanks to @Yunnosch for some help.


text:
Q: How to export custom characters or character by character via XML I have provided an image below. I have managed to export a patch of test code on the right side of the image, but I want the layout to be similar to that of the left. I want to export characters such as {, :, [, ],,
Is there a way to export to XML in a structure similar to the left side? I want to avoid the automatic insertions (e.g. <, >, /).
Is there an equivalent way to do this in Haxe?
If not, what are my options?
Picture, comparison of what I want vs. what I have managed to export currently:
https://i.imgur.com/LZZAGd9.png


text:
Q: Disable button on click but still process form I want to disable my register button on click to prevent spam, but I don't want to prevent the form the button submits from submitting.
I'm able to disable the button on click, but can't figure out why the form still won't submit...
button:
<?= form_open("course/registerCourse", "method='post'") ?>
   <input type="hidden" name="session" value="<?= $session["id"] ?>">
   <button type="submit" class="btn-sm btn btn-success register">REGISTER</button>
<?= form_close() ?>

jQuery:
$('.register').on('click',function() {
    $(this).prop("disabled",true);
    $("form").submit();
});

register function:
public function registerCourse()
{

    $user = $this->users_model->userAccountTP();
    $appParticipant = $user[0]["id"];

    $author_id = $this->session->userdata("ci_user_id");
    $appSession = $this->input->post('session');

    $this->ci_channel_entry_model->save_multiple(array(
        "channel_id" => 11,
        "title" => date("Y-m-d h:i:s"),
        "author_id" => $author_id,
        "status_id" => 7,
        "date" => date("Y-m-d h:i:s"),
        "data" => array(
            array(
                // application-session
                "field_id" => 28,
                "content" => $appSession
            ),
            array(
                // application-participant
                "field_id" => 29,
                "content" => $appParticipant
            )
        ),
        "hook" => FALSE
    ));

    redirect($this->agent->referrer());
}

A: I think you might have a typo, because I dont see where you are declaring $form, so maybe this helps:
$('.register').on('click',function() {
    $(this).prop("disabled",true);
    $("form").submit();
});

A: Ended up reworking my form to align with this answer and everything worked:
https://stackoverflow.com/a/5691065/4141833


text:
Q: android: customized text selector I wanted to design a customized text selector that changed the text color when user clicks the TextView. But got the following error:
java.lang.RuntimeException: Unable to start activity ComponentInfo{}: android.view.InflateException: Binary XML file line #55: Error inflating class
here is what I have:
 drawable/text_selector.xml
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:state_enabled="false"
        android:state_focused="true"
        android:drawable="@color/black" />
  <item android:state_pressed="true"
        android:drawable="@color/blue" />
  <item android:state_focused="true"
        android:drawable="@color/black" />
</selector>

layout/textview.xml
<TextView android:id = "@+id/last_page_button"
    android:text="@string/last_page_button_string"
    android:gravity="center_horizontal"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="#ffffff"
    android:textColor = "@drawable/text_selector"
    android:layout_weight="1" />

values/color.xml
<resources>
    <color name="white">#ffffffff</color>
    <color name="black">#ff000000</color>
    <color name="blue">#ffccddff</color>

A: You can't assign drawable to textColor. It has to be a Color.
<selector
    xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:state_selected="true"

        android:color="@color/color1" />
    <item
        android:color="@color/color2" />
</selector>

create a folder color in your res , save this file as mycolor.xml and assign it to textColor as @color/mycolor

A: use selector as follows:
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item
    android:state_selected="true"

    android:color="@color/c1" />
<item
    android:color="@color/c2" />


text:
Q: how to convert string date time to int using python I am doing data preprocessing, so I am trying to convert the date string format into an int, but I got an error, please help me how to convert it.
I have data like this :
0        Apr-12
1        Apr-12
2        Mar-12
3        Apr-12
4        Apr-12

I tried this :
d=df['d_date'].apply(lambda x: datetime.strptime(x, '%m%Y'))

I got an error.
ValueError                                Traceback (most recent call last)
<ipython-input-134-173081812744> in <module>()
----> 1 d=test['first_payment_date'].apply(lambda x: datetime.strptime(x, '%m%Y'))

~\Anaconda3\lib\site-packages\pandas\core\series.py in apply(self, func, convert_dtype, args, **kwds)
   4036             else:
   4037                 values = self.astype(object).values
-> 4038                 mapped = lib.map_infer(values, f, convert=convert_dtype)
   4039
   4040         if len(mapped) and isinstance(mapped[0], Series):

pandas\_libs\lib.pyx in pandas._libs.lib.map_infer()

<ipython-input-134-173081812744> in <lambda>(x)
----> 1 d=test['first_payment_date'].apply(lambda x: datetime.strptime(x, '%m%Y'))

~\Anaconda3\lib\_strptime.py in _strptime_datetime(cls, data_string, format)
    563     """Return a class cls instance based on the input string and the
    564     format string."""
--> 565     tt, fraction = _strptime(data_string, format)
    566     tzname, gmtoff = tt[-2:]
    567     args = tt[:6] + (fraction,)

~\Anaconda3\lib\_strptime.py in _strptime(data_string, format)
    360     if not found:
    361         raise ValueError("time data %r does not match format %r" %
--> 362                          (data_string, format))
    363     if len(data_string) != found.end():
    364         raise ValueError("unconverted data remains: %s" %

ValueError: time data 'Apr12' does not match format '%m%Y'

A: IIUC, You need to se %b-%y as Apr is %b and 12 is %y. Refer to Python's strftime directives for more information. Once you convert to datetime objects, you can then convert them to UNIX.
df:
col
0   Apr-12
1   Apr-12

For int datetime,
pd.Series(pd.to_datetime(df['col'], format='%b-%y').values.astype(float)).div(10**9)

Output:
0    1.333238e+09
1    1.333238e+09
dtype: float64

Explanation:
pd.to_datetime(df['col'], format='%b-%y')

Outputs:
0   2012-04-01
1   2012-04-01
Name: col, dtype: datetime64[ns]


text:
Q: Use esttab to generate summary statistics by group with columns for mean difference and significance I would like to use esttab (ssc install estout) to generate summary statistics by group with columns for the mean difference and significance. It is easy enough to generate these as two separate tables with estpost, summarize, and ttest, and combine manually, but I would like to automate the whole process.
The following code generates the two components of the desired table.
sysuse auto, clear

* summary statistics by group
eststo clear
by foreign: eststo: quietly estpost summarize ///
    price mpg weight headroom trunk
esttab, cells("mean sd") label nodepvar

* difference in means
eststo: estpost ttest price mpg weight headroom trunk, ///
    by(foreign) unequal
esttab ., wide label

And I can print the two tables and cut-an-paste into one table.
* can generate similar tables and append horizontally
esttab, cells("mean sd") label
esttab, wide label

* manual, cut-and-paste solution
-------------------------------------------------------------------------------------------------------
                              (1)                       (2)                         (3)

                             mean           sd         mean           sd
-------------------------------------------------------------------------------------------------------
Price                    6072.423     3097.104     6384.682     2621.915         -312.3         (-0.44)
Mileage (mpg)            19.82692     4.743297     24.77273     6.611187         -4.946**       (-3.18)
Weight (lbs.)            3317.115     695.3637     2315.909     433.0035         1001.2***       (7.50)
Headroom (in.)           3.153846     .9157578     2.613636     .4862837          0.540**        (3.30)
Trunk space (.. ft.)        14.75     4.306288     11.40909     3.216906          3.341***       (3.67)
-------------------------------------------------------------------------------------------------------
Observations                   52                        22                          74
-------------------------------------------------------------------------------------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

It seems that I should be able to get the desired table with one esttab call and without cutting-and-pasting, but I can't figure it out. Is there a way to generate the desired table without manually cutting-and-pasting?
I would prefer to output a LaTeX table, but anything that eliminates the cutting-and-pasting is a big step, even passing through a delimited text file.

A: I don't think there's a way to do this with esttab (estout package from ssc), but I have a solution with listtab (also ssc) and postfile. The table here is a little different than the one I propose above, but the approach is general enough that you can modify it to fit your needs.
This solution also use LaTeX's booktabs package.
/* data and variables */
sysuse auto, clear
local vars price mpg weight headroom trunk

/* means */
tempname postMeans
tempfile means
postfile `postMeans' ///
    str100 varname domesticMeans foreignMeans pMeans using "`means'", replace
foreach v of local vars {
    local name: variable label `v'
    ttest `v', by(foreign)
    post `postMeans' ("`name'") (r(mu_1)) (r(mu_2)) (r(p))
}
postclose `postMeans'

/* medians */
tempname postMedians
tempfile medians
postfile `postMedians' ///
    domesticMedians foreignMedians pMedians using `medians', replace
foreach v of local vars {
    summarize `v' if !foreign, detail
    local med1 = r(p50)
    summarize `v' if foreign, detail
    local med2 = r(p50)
    ranksum `v', by(foreign)
    local pval = 2 * (1 - normal(abs(r(z))))
    post `postMedians' (`med1') (`med2') (`pval')
}
postclose `postMedians'

/* combine */
use `means'
merge 1:1 _n using `medians', nogenerate
format *Means *Medians %9.3gc
list

/* make latex table */
/* requires LaTeX package `booktabs` */
listtab * using "Table.tex", ///
    rstyle(tabular) replace ///
    head("\begin{tabular}{lcccccc}" ///
    "\toprule" ///
    "& \multicolumn{3}{c}{Means} & \multicolumn{3}{c}{Medians} \\" ///
    "\cmidrule(lr){2-4} \cmidrule(lr){5-7}" ///
    "& Domestic & Foreign & \emph{p} & Domestic & Foreign & \emph{p}\\" ///
    "\midrule") ///
    foot("\bottomrule" "\end{tabular}")

This yields the following.

A: The answer chosen is nice but a bit redudant. You can achieve the same result with only estpost ttest.
sysuse auto, clear
estpost ttest price mpg weight headroom trunk, by(foreign)
esttab, cells("mu_1 mu_2 b(star)"

The output looks like this:
             mu_1          mu_2         b

c_score     43.33858    42.034       1.30458***
nc_a4_17    4.007524    3.924623    .0829008*

A: If you still want to use esttab, you can play around using cells and pattern. The table in the original post can be replicated with the following code:
sysuse auto, clear

eststo domestic: quietly estpost summarize ///
    price mpg weight headroom trunk if foreign == 0
eststo foreign: quietly estpost summarize ///
    price mpg weight headroom trunk if foreign == 1
eststo diff: quietly estpost ttest ///
    price mpg weight headroom trunk, by(foreign) unequal

esttab domestic foreign diff, ///
cells("mean(pattern(1 1 0) fmt(2)) sd(pattern(1 1 0)) b(star pattern(0 0 1) fmt(2)) t(pattern(0 0 1) par fmt(2))") ///
label

which yields
-----------------------------------------------------------------------------------------------------
                              (1)                       (2)                       (3)

                             mean           sd         mean           sd            b               t
-----------------------------------------------------------------------------------------------------
Price                     6072.42      3097.10      6384.68      2621.92      -312.26         (-0.44)
Mileage (mpg)               19.83         4.74        24.77         6.61        -4.95**       (-3.18)
Weight (lbs.)             3317.12       695.36      2315.91       433.00      1001.21***       (7.50)
Headroom (in.)               3.15         0.92         2.61         0.49         0.54**        (3.30)
Trunk space (.. ft.)        14.75         4.31        11.41         3.22         3.34***       (3.67)
-----------------------------------------------------------------------------------------------------
Observations                   52                        22                        74
-----------------------------------------------------------------------------------------------------


text:
Q: htaccess redirect with GET parameters - 2 parameters but dont need the second param I have a URL with 2 parameters but need to redirect it to a new page with a cleaner URL.
The old URL is https://example.com/homes-for-sale-results/?city=Delta&propertyType=SFR%2CCND The first parameter (city=Delta) is the only one that needs to match – any other parameters afterwards shouldn't have an effect on the redirect.
I am wanting it to redirect to https://example.com/listings/pageid-89/city-Ladner/ regardless of what comes after https://example.com/homes-for-sale-results/?city=Delta
I have tried the following:
RewriteEngine On
RewriteCond %{QUERY_STRING} city=Delta
RewriteRule ^/homes-for-sale-results(.*)?$ http://example.com/listings/pageid-89/city-Ladner/ [R=301]

However this does not work but instead redirects to https://example.com/residential-properties/our-sold-listings/?city=Delta&propertyType=SFR,CND
Does anyone know a way I could fix this?


text:
Q: Root Partition using too much space I'm having problems with my disk usage. My system monitor says that I have 44,6gb used. But when I run disk usage analyzer, it shows that I have 5.4gb used. My partitions are in LVM. Here some images:

Here the df -a result too:
Filesystem                  1K-blocks     Used Available Use% Mounted on
/dev/mapper/ubuntu--vg-root 110437200 43584168  61220020  42% /
proc                                0        0         0    - /proc
sysfs                               0        0         0    - /sys
none                                4        0         4   0% /sys/fs/cgroup
none                                0        0         0    - /sys/fs/fuse/connections
none                                0        0         0    - /sys/kernel/debug
none                                0        0         0    - /sys/kernel/security
none                                0        0         0    - /sys/firmware/efi/efivars
udev                          4016416        4   4016412   1% /dev
devpts                              0        0         0    - /dev/pts
tmpfs                          806336     1084    805252   1% /run
none                             5120        0      5120   0% /run/lock
none                          4031680      164   4031516   1% /run/shm
none                           102400       48    102352   1% /run/user
none                                0        0         0    - /sys/fs/pstore
/dev/sda2                      241965    54091    175382  24% /boot
/dev/mapper/ubuntu--vg-home 361112164 38376484 304369216  12% /home
/dev/sda1                      523248     3428    519820   1% /boot/efi
binfmt_misc                         0        0         0    - /proc/sys/fs/binfmt_misc
systemd                             0        0         0    - /sys/fs/cgroup/systemd
/home/marcus/.Private       361112164 38376484 304369216  12% /home/marcus
gvfsd-fuse                          0        0         0    - /run/user/1000/gvfs

With additional info I resize the root partition to get the Home partition.
In advance, thanks for all the help. I wanna to know what is causing this difference and how i solve this issue.

A: When i had resized my ROOT volume and copied my Home files to my HOME volume, the 'rm' not erased my encrypted files. I just boot my system with a live CD, mounted my /root volume and use 'rm -f' to erase all files inside the home folder in /root.Thus, the hidden folder .encrptfs was deleted.


text:
Q: How to go about a column with different values in a same row in sql? my table has the following strucuture

empno    empname    loan ref   amount
1        abc        123        100
1        abc        456        200.

i.e an employee can avail two loans(say car and scooter).
The output expected:

empno   empname      loan ref1   amt    loanref2    amt
1       abc           120        100    456         200

to avoid duplicate empno repeating. How to go about it in sql???

A: Concerning the previous comments on table design - there is, in fact, a redundancy in the table; you could store the empname in another table, which you would join with your table here to avoid that; every redundancy is a potential contradiction.
However, if we have a table design optimised for querying and minimising necessary joins, it might be populated in a batch job from somewhere else, and then the design would be appropriate.
What you want to do here is often referred to as 'horizontal pivoting'.
We lack some info here, so I'm assuming a maximum number of loans of 2. We need a mechanism that allows us to put data in col1 or col2, depending on whether it's the first or second row for the same empno. That's why we generate a sequence number. Finally, we use a SUM(CASE seq WHEN ...) expression in conjunction with a GROUP BY to reduce the number of rows and flatten the table.
Here goes:
-- first global table expression - the input table
-- The table could exist already, and then this would not be needed.
WITH foo(empno,empname,loanref,amount) AS (
          SELECT  1,'abc',123,100
UNION ALL SELECT  1,'abc',456,200
)
-- second global table expression - add sequence number
-- this needs to be in the query
,    foo_numbered AS (
SELECT
  -- need a number: 1 for the first, 2 for the second loan
  ROW_NUMBER() OVER(PARTITION BY empname ORDER BY loanref) AS seq
, *
FROM foo
)
SELECT
  empno
, empname
, MAX(CASE seq WHEN 1 THEN loanref END) AS loanref_1
, SUM(CASE seq WHEN 1 THEN amount END) AS amount_1
, MAX(CASE seq WHEN 2 THEN loanref END) AS loanref_2
, SUM(CASE seq WHEN 2 THEN amount END) AS amount_2
FROM foo_numbered
GROUP BY
  empno
, empname
;

Happy playing
Marco


text:
Q: Synchronous Universal Analytics The new Universal Analytics re-introduces synchronous event tracking: https://developers.google.com/analytics/devguides/collection/analyticsjs/method-reference#sync.
The documentation however is incomplete, it says:

"This calling syntax will not work when loading the analytics.js
  library using the default snippet. The default snippet is designed to
  work with the asynchronous calling syntax."

So now I've only got a default (asynchronous) snippet:
<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-XXXXX-YY', 'mydomain.com');
  ga('send', 'pageview');

</script>

I can't find any mention of the correct snippet for synchronous calls. Anyone?

A: Use this one:
<script src="//www.google-analytics.com/analytics.js"></script>
  <script>
    var tracker = ga.create('UA-12345678-1', 'auto');
    tracker.send('pageview');
  </script>

Tested.


text:
Q: How to create calculated field column for sorting the numbers I have three columns
value1 value2 value3
 (100   100     80)
 (100   100     100)
 (70    40     50)

I want to sort this by concatenating all these and padding left 0 and then sort it.
Can any one help me out, how can I write the formula.

A: Try this out
Step 1 : Sort the numbers (Formula below). To keep the formula concise I had to user "123","321"etc. They represent the order of values. So, "123" means order in ascending i.e. value1 value2 and then value3
    IF( Value1<Value2
        , IF( Value1<Value3
              , IF( Value2<Value3
                    ,"123"
                    ,"132"
                  )
              ,"312"
            )
        , IF( Value2<Value3
              , IF( Value1<Value3
                    ,"213"
                    ,"231"
                  )
              ,"321"
            )
       )

Step 2 : Since you now have the base ready, you can replace "123" etc with whatever you want (padding with zeros) in your case
Here are some tests that i ran. Check out the screen shot below.

Hope it helps

A: *

*You can use the MAX function to get the highest from 3 values

*Append leading 000 to the result (padding left you mean, I presume)

*Then use the RIGHT function to get the last 3 digits

Available Functions and Syntax List is at https://www.365csi.nl/vm365com/365coach/#/Calculated_Column_Functions_List
Off the top of my head (so likely wrong, as it is 08:00 here in Amsterdam and I haven't finished my first coffee yet)
= RIGHT( "000" & MAX( value1,value2,value3 ) , 3 )


text:
Q: "Invalid Date" for an invalid date? Why does JavaScript return 'Invalid Date' when setting an (invalid) date? Seems like it should error out/throw an exception and makes it hard to handle any errors.
Question: What is the best way to handle this to run a check on the date value after you 'new it up' to see if the value is actually a date or a string value of 'Invalid Date'?

const validDate = new Date();
console.log('validDate instanceof Date:', validDate instanceof Date);

const invalidDate = new Date('asdfasdfasdf');
console.log('invalidDate instanceof Date:', invalidDate instanceof Date);

if (invalidDate) {
  // This hits because invalidDate is now a string and is therefore truthy
  console.log('Date is Valid');
}

if (invalidDate instanceof Date) {
  // This hits because it's still an instance of date (although the value is a string)
  console.log('Date is Valid');
}

if (typeof invalidDate === 'string') {
  // Doesnt hit because invalidDate is not a string
}

A: try with this code:
const invalidDate = new Date('aksjdhaksjdh');
console.log('invalidDate instanceof Date:', invalidDate.setUTCHours(0) instanceof Date);

The setUTCHours() method sets the hour of a date object, according to the UTC time. In this case, as our var is invalid, it can not be converted and returns false.


text:
Q: java.lang.IllegalArgumentException: Parameter with that position [1] did not exist This is my repository:
@Repository
public interface MyRepository extends JpaRepository<Entity, Long> {

  public static final String DISTANCE = "((acos(sin(?1 * pi() / 180) * sin(a.latitude * pi() / 180) + cos(?1 * pi() / 180) * cos(a.latitude * pi() / 180) * cos((?2 - a.longitude) * pi() / 180)) * 180 / pi()) * 60 * 1.609344) as distance";

  @Query("select new package.SearchResult(" + DISTANCE + ", a.addressOwner) from Address a group by a.addressOwner, col_0_0_ having col_0_0_ < ?3 order by col_0_0_")
  public Page<SearchResult> findClosestByCoordinates(double lat, double lng, double maxDistance, Pageable pageable);

}

When I try to execute this method an exception occurs:
Parameter with that position [1] did not exist; nested exception is java.lang.IllegalArgumentException: Parameter with that position [1] did not exist']
But when I replace Page<SearchResult> with List<SearchResult> everything works just fine. Is it Spring's bug or something?
UPDATE: I guess I found what is wrong: when ALL the parameters take part in where clause, everything is ok. But if at least one of them is not used there, it fails. But I don't understand why it happens with Page and doesn't happen when using List. And what is the best way to deal with it?

A: I'd got same problem with you, and finally found solution for these case.
I'm trying to solve similar problem like you as calculate lat, long things.
At first, problem is "Count Query" caused by using Pageable parameter.
I debugged things and found some codes like "when using Pageable, generate count query with WHERE clauses WITHOUT EVERY CONDITIONS".
So try like this.
@Query(value = "FROM MemberEntity mem " +
        "WHERE mem.seq != :selfSeq AND " +
        "get_distance_in_kilos_between_geo_locations(" +
        ":lat, " +
        ":lon, " +
        "mem.recentLocationLog.latitude, " +
        "mem.recentLocationLog.longitude" +
        ") > :pageId " +
        "ORDER BY get_distance_in_kilos_between_geo_locations(" +
        ":lat, " +
        ":lon, " +
        "mem.recentLocationLog.latitude, " +
        "mem.recentLocationLog.longitude" +
        ") ASC "// +
        ,
        countQuery = "SELECT COUNT(1) FROM MemberEntity mem " +
                "WHERE mem.seq != :selfSeq AND " +
                "get_distance_in_kilos_between_geo_locations(" +
                ":lat, " +
                ":lon, " +
                "mem.recentLocationLog.latitude, " +
                "mem.recentLocationLog.longitude" +
                ") > :pageId "
)
Page<MemberEntity> findByDistanceAndExcludeSelf(
        @Param("lat") double latitude,
        @Param("lon") double longitude,
        @Param("selfSeq") long selfSeq,
        @Param("pageId") double pageId,
        Pageable pageable
);

A: You can make the query by the use of @Param("query_param_name") annotation that make query  more clear and understandable.
 @Repository
 public interface MyRepository extends JpaRepository<Entity, Long> {

 public static final String DISTANCE = "((acos(sin(:lat * pi() / 180) *   sin(a.latitude * pi() / 180) + cos(:lat * pi() / 180) * cos(a.latitude * pi() /     180) * cos((:lng - a.longitude) * pi() / 180)) * 180 / pi()) * 60 * 1.609344) as   distance";

  @Query("select new package.SearchResult(" + DISTANCE + ", a.addressOwner)   from Address a group by a.addressOwner, col_0_0_ having col_0_0_ < :maxDistance order by col_0_0_")
 public Page<SearchResult> findClosestByCoordinates(@Param("lat")double lat, Param("lng")double lng, @Param("maxDistance") double maxDistance, Pageable pageable);

 }

This error come when the spring not find the where to enter the method param in query.
So, use of @Param() annotation binds the query param and method param together and increase the simplycity of the query

A: Cause Page need to call extra count Query, but List not. This error must be caused by count Query.
See here, most like same problem

A: I faced same issue. After some try got to know that Pagination works in to phases.

*

*First query for Count based on your parameter : includes every parameter in Count query's WHERE clause, if you miss any parameter you will get below exception with missed parameter index number

Parameter with that position [1] did not exist; nested exception is

*Second query to retrieve data : Here there is a way you can use parameter of your choice.

Solution : use value and countQuery inside @Query parameter to use different parameter values.
For Example
@Query(value = "SELECT * FROM Shop s WHERE pincode = :pin",
        countQuery = "SELECT COUNT(1) FROM Shop s WHERE pincode = :pin AND shoptitle = :title")
Page<Shop> findShopForPincode(@Param("pin") String pin, @Param("title") String title);


text:
Q: Display a grid radio form with Django Forms or Django Floppyforms I would like to make a form with this kind of grid :

Do you know how I can do this ? Is there a Django Form widget for that ?
Actually it is questions with the same choices list displayed as radio in a grid.
Thanks,
Natim

A: I'd do this with a django form with one field per line on your grid, with a ChoiceField and RadioSelect as widget:
line1 = forms.ChoiceField(widget=forms.RadioSelect, choices=TRUC)
line2 = …

Then you need to find the template layout to render this correctly. RadioSelect generates a
 with eahc choice being a
. The choice label is included in the
, which is not what you want here.
With floppyforms you could subclass RadioSelect and give it a cutom template_name (look at the floppyforms/radio.html template) to omit the labels. You can also alter it to render, say, table cells (s) instead of
, and make your form markup generate a table with the labels in the table's header.
import floppyforms as forms

class RadioSelect(forms.RadioSelect):
    template_name = 'myforms/radio.html'

Put your desired row markup in the above template.
Then, in the template that renders your form:
<form method="post" action="youraction">

      {% for field in form %}

          {{ field.label_tag }}
          {{ field }}

      {% endfor %}

</form>

Then it's only a matter of applying a couple of CSS styles to get the layout you need :)

A: You can try this field django-radiogrid


text:
Q: Crome: Run content script in dynamically created iframe I'm writing an extension for Chrome (currently testing in Chrome 51). I need the content script to run in dynamically created iframes.
For example, if I understand correctly, this site creates a new iframe each time the user clicks "Run".
This is my manifest (well, parts of it, which I thought were relevant):
"content_scripts": [
    {
        "matches": [ "<all_urls>", "http://*/*", "https://*/*"],
        "match_about_blank": true,
        "all_frames": true,
        "run_at": "document_start",
        ...
    }],
"permissions": [
    "<all_urls>",
    "http://*/",
    "https://*/",
    ...
]

But the newly created frame still doesn't get my content script. I put a breakpoint in my content script's entry point and it isn't hit (it only hits for the main frame of the page, but not the frame which was dynamically created).
I know there are other similar questions but the Internet seems to be in agreement that match_about_blank is the way to go, but it doesn't work in my case.
UPDATE: So it turns out this wasn't the problem at all. I would have deleted the question (cause truly it's kind of embarrassing), but still there's a lesson to be learned here, since I spend A LOT of time investigating why my script isn't loaded.
In fact it WAS loaded. The breakpoint didn't hit probably because of some glitch in the map and/or source files (when I recompiled my TypeScript project and copied the files again, the breakpoint started hitting). I should have trusted the debugger window to see that my content script was loaded, instead of insisting on hitting the breakpoint...


text:
Q: Pivot Data with Uneven Groups Python Pandas I have a table and I want to convert it using Python 3x Pandas into the following:

Group
Assessment
Review

GroupA
No team spirit
Negative

GroupA
Good players
Positive

GroupA
They scored well
Positive

GroupB
Goal failed
Negative

GroupB
Bad weather
Negative

GroupB
Resilience
Positive

GroupB
Growth potential
Positive

GroupB
Bad  technique
Negative

Resulting table should be:

Group
Positive
Negative

GroupA
Good players
No team spirit

GroupA
They scored well
NaN

GroupB
Resilience
Goal Failed

GroupB
Growth Potential
Bad weather

GroupB
NaN
Bad Technique

Is there any neat, Pythonic way of doing it using Pandas or other method?

A: You can't pivot as is, but you could add a group number using groupby + cumcount and pivot using the newly created numbering as index:
out = (df.assign(num=df.groupby(['Group','Review']).cumcount())
       .pivot(['num','Group'],'Review','Assessment')
       .droplevel(0).sort_index()
       [['Positive','Negative']]
       .reset_index()
       .rename_axis(columns=[None]))

Output:
    Group          Positive        Negative
0  GroupA      Good players  No team spirit
1  GroupA  They scored well             NaN
2  GroupB        Resilience     Goal failed
3  GroupB  Growth potential     Bad weather
4  GroupB               NaN   Bad technique

A: it is not what you exactly want, but it seems this table structure has more sence:
res = (df.groupby(['Group','Review']).
       apply(lambda x:x['Assessment'].tolist()).
       unstack())
print(res)
'''
Review                                   Negative                          Positive
Group
GroupA                           [No team spirit]  [Good players, They scored well]
GroupB  [Goal failed, Bad weather, Bad technique]    [Resilience, Growth potential]


text:
Q: What should I use? Hex codes, RGB codes, or color names in code? I just wanted to know, would there be a difference, or would it be better, if I use hex codes in HTML like #000000, RGB codes like rgb(0,0,0), or color names like black?

A: There is no difference. You can use all.

A: It is truly up to your own preferences for most, but I usually avoid color names because you are depending on something else to translate the color. I avoid RGBA for now since it's gaining support but still not supported broadly enough. RGB though is a bit easier to manipulate in javascript.

A: i suggest you to use the hexa code like #000000 because name like black, white are label assigned by the browser for that kind of code so, maybe, some browser will not recognize them. hexa and RGB are the same (you can use both together without problems). The only advantage of using RGB is that you can declare the alpha direcly in the rule like RGBA (RED, GREEN, BLUE, ALPHA LEVEL) instEad of declare another css rule


text:
Q: Javascript: Displaying output dependent on which checkedboxes pressed? I am creating a web app that will take 2 sets of user input, i.e. Age and Weight and display an outcome dependent on what box is ticked on each.
What is the best way to do this?
I.e. if one age and weight is selected I wish to display one value, but if a different combo is selected I wish to display another?
I ask this as I know it can be done using multiple if statements, but I assume there is a better way.
Current Code:
<!DOCTYPE html>

Health Calculator

Select age

<form action="age.asp" method="get">
  <input type="checkbox" name="Age" value="under25"> Under 25

  <input type="checkbox" name="Age" value="over25"> Over 25

 </form>

Select Weight

<form action="weight.asp" method="get">
  <input type="checkbox" name="Probability" value="under80"> Under 80kg

  <input type="checkbox" name="Probability" value="over80"> Over 80kg

</form>

<button onclick= "analyseHealth"> Analyse health </button>

A: This is not finished but I think you can guess the rest.
http://codepen.io/anon/pen/RPpjBm
function analyseHealth()
{
   var ages = document.getElementsByName('Age');
   var probs = document.getElementsByName('Probability');

  var age = undefined;
  for(var i = 0; i < ages.length; i++)
  {
    if(ages[i].checked)
    {
      age = ages[i].value;
    }
  }

   var probability = undefined;
   for(var i = 0; i < probs.length; i++)
   {
      if(probs[i].checked)
      {
        probability = probs[i].value;
      }
    }
   switch(age){
       case 'under80': break;
   }
}

Better than if might be switch. First you get the checked radio buttons which might be the better choice here.


text:
Q: Update an item and trigger change (whether disabled or not) In multiple parts of my code I need to update the value of an item, and in some cases it may have been disabled for user input; but in all cases I want the "change" event to fire, regardless.
I need a function that will take a jQuery expression, and a new value to set any corresponding item(s) to the new value; and then fire the "change" event on them. If the item was disabled, it should remain disabled.
jQuery 1.7.1

A: I'd suggest you to make the <input> readonly instead of disabled.
Demo

$("#form").on("change", ".all", function() {
  $("#feedback").append($(this).attr("id") + " changed
");
});

$(".all")
  .val("new value")
  .trigger("change");
input[readonly] {
  background: #ccc;
}

  Item1 =
  <input id="item1" class="all">

Item2 =
  <input id="item2" class="all" readonly />

A: This is what I have at the moment; it seems inelegant to me, hoping to see if there's a better way to do it:
function updVal (qry, nwVal) {

  $(qry+":not([disabled])")
    .val(nwVal)
    .trigger("change");

  // we need to temporarily enable then disable the disabled items
  // in order for the change event to fire
  $(qry+":disabled")
    .val(nwVal)
    .prop("disabled",false)
    .trigger("change")
    .prop("disabled",true);

}

e.g.
updVal("#myreport input[data-x='bla']", "new value");


text:
Q: JSP components libraries like primefaces I there a famously used library of components such as Primefaces or Richfaces that is mainly designed to be used with JSP? And if not, then what are the possibility of using any of the aforementioned with JSP and drawbacks?

A: JSP is deprecated since JSF 2.0 and succeeded by Facelets. You shouldn't expect JSF 2.0 component library vendors to support JSP as well, that's almost double of development and maintenance work.
So if you're looking for component libraries supporting JSP, then you should be looking at JSF 1.x targeted component libraries. RichFaces for example has the 3.3.x as the latest JSF 1.2 compatible version.
Or, just upgrade yourself first and step over to Facelets.

A: It seems that ZK JSP Tags is something you look for . It is a collection of JSP Tags built upon highly interactive ZK Ajax components. It follows standard JSP specifications and integrate seamlessly with other JSP tags and solutions.


text:
Q: Holding on ImageView to change InputType of TextView - Android I have EditText with InputType of password and one ImageView like a button. So I want when user hold his finger on that image, InputType of EditText to become normal text, and when user remove finger, InputType again to be password. So how can I do this?

A: You can do a setOnTouchListener on the Image and inside you can call the setInputType of the EditText. Just report to this link to see wich setInputType parameter suits you the most.

A: ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
imageView.setOnTouchListener(new View.OnTouchListener {
   public onTouch(View v, MotionEvent event){
    if (event.getAction() == MotionEvent.ACTION_DOWN)
    {
       //set edittext to normal
    }
    else if (event.getAction() == MotionEvent.ACTION_UP
    {
     // set edittext to password
    }
    return true;
   }
});

The above code should work, it might need a little tweaking - I can't test it at the moment. Should give you a good idea on how to handle it.


text:
Q: HTTP request to the remote WebDriver server for URL timeout when running tests across browsers in parallel I've been battling the commonly seen "HTTP request to the remote WebDriver server for URL ... timed out after x seconds" for several months in an attempt to run tests against two browsers simultaneously (Chrome and IE), spending hours at a time trawling through stackoverflow and search engine results to attempt to find a solution.
My behavior, like others before me, varies between timing out at a click function or when attempting to get a url, and I have increased pageload and implicit wait timeouts to over 600 seconds in various cases, inserting the waits before an element, after a url is called, before a url is called, after the driver constructor is called and as a parameter in the driver object call.
I have attempted to include javascript exectutor scripts (provided from answers in previous SO posts on this issue) that check for the page load ready state to be complete before continuing with an action, to no success.
I have attempted to update my chrome and IE, selenium web and support drivers all to the latest compatible versions, manually calling the binary for the latest compatible browser executable - as well as attempting to roll back to previous versions where people have reported success (chrome v48, chromedriver 2.22.0.0, webdriver 2.53.1). I've tried adding  "no-sandbox" as a chrome option, ensured that my IE security zones all shared the same level of protection.
I've investigated whether my page is using AJAX scripts and attempted to use the solutions provided in various threads to accommodate for any dynamic content.
When running either IE or Chrome individually, outside of the parallel query, no timeout issues are observed. The issue specifically occurs when chrome initializes its remote WebDriver instance. I've also tried using 32bit and 64bit versions of the chrome/ie drivers.
I've pulled information out of many topics, and pages, but these are some of the most relevant ones.
Selenium Error - The HTTP request to the remote WebDriver timed out after 60 seconds
https://sqa.stackexchange.com/questions/13326/the-http-request-to-the-remote-webdriver-server-timed-out-after-60-seconds
https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/5441
https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/5071
Selenium Error - The HTTP request to the remote WebDriver timed out after 60 seconds
Selenium WebDriver throws Timeout exceptions sporadically
Here's an example of the output:
System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.
  ----> System.AggregateException : One or more errors occurred.
  ----> OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL http://localhost:52240/session/a969dbe2-3b0c-461f-a979-21bafec0dd8e/element/7005aeab-ff31-454a-8f78-0a39ad861695/click timed out after 120 seconds.
  ----> System.Net.WebException : The request was aborted: The operation has timed out.

I call the drivers from a case list where there are later added in to the parallel query:
 private static IWebDriver DefineDriver(Browser supportedbrowsers)
        {
            var baseDriverPath = ConfigurationManager.AppSettings["BaseDriverPath"].ToString();
            var ieDriverFolder = ConfigurationManager.AppSettings["IeDriverFolder"].ToString();
            var chromeDriverFolder = ConfigurationManager.AppSettings["ChromeDriverFolder"].ToString();
            ChromeOptions chromeoptions = new ChromeOptions();
            chromeoptions.BinaryLocation = @"C:\WebDrivers\Binary\chrome32_49.0.2623.75\chrome.exe";
            chromeoptions.AddArgument("no-sandbox");
            InternetExplorerOptions ieoptions = new InternetExplorerOptions();
            ieoptions.IntroduceInstabilityByIgnoringProtectedModeSettings = false;

            IWebDriver driver = null;
            switch (supportedbrowsers)
            {
                case Browser.Chrome:
                    driver = new ChromeDriver(Path.Combine(baseDriverPath, chromeDriverFolder), chromeoptions, TimeSpan.FromMinutes(5));
                    break;
                case Browser.InternetExplorer:
                    driver = new InternetExplorerDriver(Path.Combine(baseDriverPath, ieDriverFolder), ieoptions, TimeSpan.FromMinutes(5));
                    break;
                default:
                    driver = new ChromeDriver(Path.Combine(baseDriverPath, chromeDriverFolder), chromeoptions, TimeSpan.FromMinutes(5));
                    break;
            }

            driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(120));
            driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromMinutes(10));
            driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromMinutes(10));

            driver.Manage().Window.Maximize();

            return driver;
        }

In my test code, I am simply launching a page, navigating to another local page and then attempting to click a button that is immediately visible on the page.
I've tried wrapping the click command for the button in a try catch, added explicit waits with expected conditions (displayed, enabled, isclickable), used thread sleep which have all worked as expected when running a single browser.
For example, I call the button via:
 public void SelectAddWorkWorkPageButton()
    {
        WebDriverWait wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(10));
        wait.Until(ExpectedConditions.ElementToBeClickable(addNewWorkItemWorkPageBtn));
        addNewWorkItemWorkPageBtn.Click();
    }

Which locates the following element:
//Create New Button
        [FindsBy(How = How.Id, Using = "btnWorkDefinitionCreateNewWorkDefinition")]
        public IWebElement addNewWorkItemWorkPageBtn { get; set; }

And it's HTML:
<i id="btnWorkDefinitionCreateNewWorkDefinition" title="Add work" class="fa fa-plus-circle cursorPointer crudIcon" style="font-size: 20px;margin:0;padding-left:15px" ng-click="AddNewWorkDefinition()" role="button" tabindex="0"></i>

As a separate note regarding the timeouts, when updating to the latest versions of the WebDriver, I have also updated the timeouts to their new format:
    //driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(120);
    //driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(120);
    //driver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromSeconds(120);

This issue seems to have existed in the community since as far back as 2012 and has, to my finding, never been isolated and clearly identified, with people still reporting it in May this year.
Selenium Error - The HTTP request to the remote WebDriver timed out after 60 seconds

A: After attempting several more workarounds, including the use of Protractor to account for AngularJS code, I've finally isolated the cause of the "The HTTP request to the remote WebDriver server for URL" exception message down to a specific issue when running the IEDriver individually or in parallel against the application in test.
It appears that the application was using a SignalR connection to handle certain processes and this causing the IEDriver actions (such as a click event) to timeout because the SignalR connection would never complete and therefore result in the IEDriver not being able to determine that the page had finished loading before it could perform another action.
When the SignalR connection type was updated to use "Long Polling" this resolved the IEDriver timeout issue entirely.
Better explanations are available in these posts, and much credit is owed to those who contributed within, I'd never have guessed that SignalR was the cause otherwise:
https://github.com/SignalR/SignalR/issues/293
SignalR w/ Web Sockets
C# Protractor AngularJS IEDriverServer Click() Exception "Timed out waiting for page to load"
Thanks.


text:
Q: React.js Falha Manipulando Eventos Estou a começar a aprender React.js vendo alguns vídeos, tutoriais e documentação. No entanto, estou a ter um problema com o meu código no Google Chrome aparece assim desta forma:

E no Firefox nem me aparece informação de mensagem de erro nenhuma e supostamente deveria aparecer, pelo menos no tutorial aparece a informação.
HTML
<!DOCTYPE html>

<link href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.min.css" rel="stylesheet" type="text/css" />

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet" type="text/css" />

<link href="css/style.css" rel="stylesheet" type="text/css" />
<title>React Bulletin Board</title>

JavaScript
var Note = React.createClass({

    edit: function() {

        alert('editing note');

    },

    remove: function() {

        alert('removing note');

    },

    render: function() {

        return (

                    <button className="btn btn-primary glyphicon glyphicon-pencil"/>
                    <button className="btn btn-danger glyphicon glyphicon-trash"/>

        );

    }

});

React.render(<Note>Hello World</Note>,
    document.getElementById('react-container'));

CSS
@import url(http://fonts.googleapis.com/css?family=Shadows+Into+Light);

body,
html,
div.board,
div#react-container {
    height: 100%;
    overflow: hidden;
}

body {
    margin: 0;
    padding: 0;
}

div.board {
    background-color: brown;
    width: 100%;
    background: #eab92d;
    background: -moz-radial-gradient(center, ellipse cover, #eab92d 57%, #c79810 99%);
    background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(57%, #eab92d), color-stop(99%, #c79810));
    background: -webkit-radial-gradient(center, ellipse cover, #eab92d 57%, #c79810 99%);
    background: -o-radial-gradient(center, ellipse cover, #eab92d 57%, #c79810 99%);
    background: -ms-radial-gradient(center, ellipse cover, #eab92d 57%, #c79810 99%);
    background: radial-gradient(ellipse at center, #eab92d 57%, #c79810 99%);
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eab92d', endColorstr='#c79810', GradientType=1);

}

div.note {
    height: 150px;
    width: 150px;
    background-color: yellow;
    margin: 2px 0;
    position: relative;
    cursor: -webkit-grab;
    -webkit-box-shadow: 5px 5px 15px 0 rgba(0, 0, 0, .2);
    box-shadow: 5px 5px 15px 0 rgba(0, 0, 0, .2);
}

div.note:active {
    cursor: -webkit-grabbing;
}

div.note p {
    font-size: 22px;
    padding: 5px;
    font-family: "Shadows Into Light", Arial;
}

div.note:hover > span {
    opacity: 1;
}

div.note > span {
    position: absolute;
    bottom: 2px;
    right: 2px;
    opacity: 0;
    transition: opacity .25s linear;
}

div.note button {
    margin: 2px;
}

div.note > textarea {
    height: 75%;
    background: rgba(255, 255, 255, .5);
}

.glyphicon-plus {
    position: fixed;
    top: 10px;
    right: 10px;
}

Não consigo compreender porque razão existe falta de informação no browser. Sendo que a informação deveria aparecer.

A: Estás a tentar a tentar fazer load do Note.js a partir do disco, e como o chrome te avisa e bem, vais bater num erro com o teu Cross Origin request!
A minha recomendação é montares um servidor de web no teu computador(http://localhost:porto-whatever,  nada de assustador), vê aqui uns exemplos de como fazer algo simples em express.js https://expressjs.com/en/starter/hello-world.html


text:
Q: How to keep version number in a single place in a python project with setup.py and debian/control For a python project I'm working on, I'd like to:

*

*Keep a version string in a single place.

*Be able get the version string at runtime for logging purposes

*

*Get a default value when launching the code from the source branch.

*Get a value that depends on the bzr revision number of the branch that was used to build the source package.

*Make the project packages available in a launchpad PPA using a recipe.

In the way the code works right now:

*

*the version number is in debian/changelog

*a recipe in launchpad adds the revision number of the development branch when the source package is built.

*a function in setup.py parses the first line of debian/changelog to retrieve the version number and pass it to setup so that setup --version works fine (without the revision number, but that could be fixed).

However, the version number isn't available at run time. What would be a good way to do that and meet the requirements above?
Some solutions I've used/seen in the past are based on generating a version.py module at build time from a template:

*

*Using a external tool
A tool/command is used to generate a version.py module with the version number. However, this doesn't work well with launchpad recipes because the ability to run arbitrary commands in a recipe is disabled in launchpad.

*In setup.py
I've seen a project that subclasses distutils.command.install_data.install_data to perform some string substitutions on the fly. However the code isn't very readable, so I'd prefer to use some other strategy.
Besides this, I've also used python-apt to just query the apt cache for the installed package version to get the version string back. However, this doesn't work to display a default value when the code is launched from the source branch unless the package isn't installed or some path checks code are added which isn't very clean from my point of view.
I've already read other questions in SO like:

*

*How can I get the version defined in setup.py (setuptools) in my package?

*Automatic version number both in setup.py (setuptools) AND source code?
but they don't really address the problem of dealing with with packaging and version control at the same time.
Please let me know what could be a reasonable approach to do this and provide a link to an example project that uses that approach if possible.

A:
A tool/command is used to generate a version.py module with the version number. However, this doesn't work well with launchpad recipes because the ability to run arbitrary commands in a recipe is disabled in launchpad.

You can, of course, do that at build time, rather that at source-package-creation time.
version.py:
# Overwritten during Debian packaging build
package_version="unknown"

debian/rules:
override_dh_auto_build:
        dpkg-parsechangelog | sed -rne 's,^Version: (.*),package_version="\1", p' > version.py
        dh_auto_build

debian/clean:
version.py


text:
Q: d3js/svg - Polygon without fixed coordinates? Is it possible to create an SVG polygon shape in d3js without hard coding the coordinates?
From what I understand a most common way to create an SVG polygon shape is to hard code the coordinates like done in the below linked examples.
Process multiple polygons d3

http://www.w3.org/TR/SVG/shapes.html#PolygonElement
But I do not want to hard code the coordinates since I want to use a force directed layout algorithm (in d3js) to define the coordinates like done in the below linked example.
http://bl.ocks.org/mbostock/2706022
Thanks,
Erno Lindfors

A: See this answer: https://stackoverflow.com/a/13204818/1651713
It works fine with a force layout, e.g.
var polygon = svg.selectAll('polygon')
  .data([nodes])
  .enter()
  .append('polygon')
  .style('fill', 'green');

force.on('tick', function() {
  polygon.attr('points',function(d){
    return d.map(function(d) {
      return [d.x,d.y].join(',');
    }).join(' ');
  });
});


text:
Q: Way to go direct to defined screen in ReactNative and OneSignal I have integrated with OneSignal in my app for push notification, right now I need to handle when user click on the notification.
When user click on the notification, App have to go to screen that have defined in OneSignal but instead of immediately go to defined screen, it land on main screen until receiving event from OneSignal (onOpened event) complete.
constructor(props) {
    super(props);
    OneSignal.addEventListener('received', this.onReceived);
    OneSignal.addEventListener('opened', this.onOpened);
    OneSignal.addEventListener('ids', this.onIds);
    }

  onOpened(openResult) {
    const data = openResult.notification.payload.additionalData;
    if(data.screen) {
      navigationService.navigate(data.screen);
    }
  }

Do we have any way to let it go direct to defined screen? Thanks

A: You can use componentWillmount
componentWillmount(openResult) {
   this.onOpened(openResult);
}


text:
Q: Best Practice to Write Dataframe to Azure SQL Server Table? I'm trying to figure out the best way to push data from a dataframe (DF) into a SQL Server table.  I did some research on this yesterday and came up with this.
import com.microsoft.azure.sqldb.spark.config.Config
import com.microsoft.azure.sqldb.spark.connect._

// Aquire a DataFrame collection (val collection)

val config = Config(Map(
  "url"            -> "my_sql_server.database.windows.net",
  "databaseName"   -> "my_db_name",
  "dbTable"        -> "dbo.my_table",
  "user"           -> "xxxxx",
  "password"       -> "xxxxx",
  "connectTimeout" -> "5", //seconds
  "queryTimeout"   -> "5"  //seconds
))

import org.apache.spark.sql.SaveMode
DF.write.mode(SaveMode.Append).sqlDB(config)

The idea is from this link.
https://docs.databricks.com/data/data-sources/sql-databases-azure.html#connect-to-spark-using-this-library
Everything works fine if I use the original DF headers, as ordinal positions for field names (_c0, _c1, _c2, etc.).  I have to have these field names in my table to make this work.  Obviously, that's not sustainable.  Is there a way to get the DF loaded into a table without matching header names (the order of the fields will always be the same in the DF and the table).  Or, is it better way to do this, like renaming the field names of the Spark DF?  Thanks.

A: I found a solution!
val newNames = Seq("ID", "FName", "LName", "Address", "ZipCode", "file_name")
val dfRenamed = df.toDF(newNames: _*)

dfRenamed.printSchema


text:
Q: Let $A$ be an integer. Consider two integers $A$ and $A+1.$ Print the sum of the numbers that cannot be formed using any combination of $A$ and $A+1.$
Not getting any sort of lead for this question

for A=2, answer is 1

for A=4, all numbers with combination of A and A+1 except 1,2,3,6,7,11. So, answer is 30 (1+2+3+6+7+11)

A: Here is a pattern that I was able to derive. This is not a complete answer and you will have to refine it further.
This is for any given positive integer $A$, where all possible numbers $n$ need to be built using
$n = iA + j(A+1)$ where $i, j \in Z$ and $i, j \ge 0$
say $k = A - 1$
Numbers that you cannot make using $A, A + 1$ -
(1) $ \, 1$ to $A - 1$
(2) $ \,A+2$ to $2A-1$
(3) $ \,2A+3$ to $3A-1$
...
...
(A-2) $ \,(A-3)A + (A-2)$ to $A(A-2) -1$ ($2$ numbers)
(A-1) $ \,(A-2)A + (A-1)$ to $A(A-1) -1$ (just $1$ number and the largest number).
In other words, we can write it as
$S = \sum \limits_{i=1}^k \sum \limits_{j = 1}^{A - i} (i-1)A + (i -1) + j$
EDIT:
I tried to simplify and see if it came to the same answer as in Arthur's link -
$S = \sum \limits_{i=1}^k (i-1) (A + 1) (A - i) + \frac {(A - i) (A + 1 - i)} {2}$
$S = \frac {1}{2} \sum \limits_{i=1}^k (2A^2 + 2A + 1) i - (2A + 1) i^2 - A (A + 1)$
$S = \frac {1}{2} [\frac {A(A-1)(2A^2 + 2A + 1)}{2} - \frac {A(A-1)(2A-1)(2A+1)}{6} - A (A-1) (A + 1)]$
Simplifying I get $ \, S = \frac {(A-1)(A^3-A)}{6}$ which is same as in the link as there, the numbers are $n + 1, n + 2$ instead of $A, A + 1$.

A: I solved your problem (with no more than secondary-school mathematics). Here is the problem-solving strategy I used:

*

*For $A\leq 5$, write out all the numbers that cannot be written as a nonnegative integral linear combination of $A$ and $A+1$.

*Develop a conjecture on patterns of consecutive integers in those numbers.

*Prove the conjecture.

*Use formulae for sums of consecutive integers and sums of squares to arrive at a formula for the sum of those numbers.

A: Following the terminology of the theory of numerical semigroups, let $S$ be the additive semigroup generated by $A$ and $A+1$. The set ${\Bbb N} − S$ is called the set of gaps in $S$ and is denoted by $G(S)$.
Since $A$ and $A+1$ are relatively prime, the largest number that is not in $S$ (called the Frobenius number of $S$), is
$$
F(S) = A(A+1) - (A + (A+ 1)) = A^2 - A - 1.
$$
and the size of $G(S)$ is $A(A-1)/2$.
The elements of $S$ lesser than or equal to $F(S)$ are of the form $kA + i$ with
$0 \leqslant i \leqslant k$ and $1 \leqslant k <A$. The sum of these elements is
\begin{align}
\sum_{1 \leqslant k < A} \Bigl(\sum_{0 \leqslant i \leqslant k} (kA + i)\Bigr) &= \sum_{1 \leqslant k < A}k(k+1)(A + 1/2) \\
&= (A + 1/2)\sum_{1 \leqslant k < A}k(k+1) \\
&= (A + 1/2)2\binom{A}{3}= (2A + 1) \binom{A}{3}
\end{align}
It follows that the sum of the elements of $G(S)$ is
\begin{align}
F(S)(F(S) + 1)/2 - (2A + 1) \binom{A}{3} &= 3(A^2 - A - 1)A(A - 1)/6 - (2A + 1) A(A-1)(A-2)/6 \\
&= A(A-1)^2(A+1)/6 = (A-1)\binom{A+1}{3}
\end{align}
\begin{array}{c|cccccc}
A&2&3&4&5&6&7\\
\hline
\text{SUM}&1&8&30&80&175&336
\end{array}


text:
Q: freesurfer command running from shell but not from script I want to convert a transformation matrix with freesurfer's lta-convert.
If I run the following command in my bash-shell (echo $0 shows -bash)
lta_convert -inlta input.lta --outfsl output.mat

it runs without problem:
$Id: lta_convert.cpp,v 1.9.2.1 2016/08/09 02:33:22 zkaufman Exp $

--inlta: input.lta input LTA transform.
--outfsl: output.mat output FSL matrix.
 LTA read, type : 1
 0.93123   0.02020   0.00726  -12.56508;
-0.00133   0.92407   0.00102  -2.41168;
 0.00007   0.02780   1.00388   21.38016;
 0.00000   0.00000   0.00000   1.00000;
FSLOUTPUTTYPE NIFTI_GZ
tkreg2FSL: mov det = 8, ref det = 1
INFO: FSL2FreeSurfer: Mov volume is NIFTI with positive det,
  applying LR flip to registration matrix.
INFO: FSL2FreeSurfer: Ref volume is NIFTI with positive det,
  applying LR flip to registration matrix.
lta_convert successful.`

But if I try to run the same command in a shell script containing the following two lines:
#!/bin/bash

lta_convert -inlta input.lta --outfsl output.mat

it throws me an error.
$Id: lta_convert.cpp,v 1.9.2.1 2016/08/09 02:33:22 zkaufman Exp $

dyld: lazy symbol binding failed: Symbol not found: ___emutls_get_address
  Referenced from: /Applications/freesurfer/bin/../lib/gcc/lib/libgomp.1.dylib
  Expected in: /usr/lib/libSystem.B.dylib

dyld: Symbol not found: ___emutls_get_address
  Referenced from: /Applications/freesurfer/bin/../lib/gcc/lib/libgomp.1.dylib
  Expected in: /usr/lib/libSystem.B.dylib

./test.sh: line 3: 91440 Abort trap: 6           lta_convert -inlta input.lta --outfsl output.mat

Why does this happen and how can I resolve this?
Other freesurfer commands like mri_robust_register run from the shell without problems. I am running the script on Mac OS 10.12.4.

A: The issue you're having probably has to do with the environment variable DYLD_LIBRARY_PATH not being propagated because of System Integrity protection. The work around in your case is checking what is the value of DYLD_LIBRARY_PATH and LD_LIBRARY_PATH when freesurfer works and setting those variables in your bash script before running it.
There is more info in the following question: Why Isn't DYLD_LIBRARY_PATH being propagated here?

A: Found the solution. Add a line to the script so that it shows:
#!/bin/bash

source $FREESURFER_HOME/SetUpFreeSurfer.sh
lta_convert -inlta input.lta --outfsl output.mat


text:
Q: SQL Server 2008 Express - sample database download? is there a sample database for SQL Server 2008 that I can download to practice learning how to develop/use SQL Server...I have downloaded the SQL Server 2008 Express Edition, Visual Studio 2008, MS Web Dev 2008, ASP.NET 3.5.....
...don't think I can download anything else before I start learning how to use this stuff.
Thanks guys...
p.s. rookie coming from ms access/vba

A: Adventure Works is the new sample databases for the SQL 2008 database. If you're using the express version you might want to look into downloading the Adventure Works LT version, it has many fewer tables than the full blown Adventure Works database.
You can also always use the northwind and pubs databases that were used with the old SQL 2000 databases. Those are still used for many examples and demos.
Hope this helps some.

A: Check out http://www.codeplex.com/MSFTDBProdSamples
It has a lot of community and Microsoft driven sample databases.  Determine what you want to learn, and then download the appropriate database sample.


text:
Q: What OS and file system for an raspberrypi NAS in apple eco-system I'm trying to create a NAS, running on a raspberry pi, which will be used entirely in an apple eco-system, and doesn't need windows support.
The NAS will be run purely from the OS SD card with no external harddrive (I don't need a lot of storage).
In this case, for the highest performance apple NAS setup on a raspberry pi setup should I be using raspbian with a NFS+ file system?
Then would I need something like SMB or AFP on top to connect it to my MAC or AppleTV?

A: The openmediavault distribution is pretty good for that and easy to install and use. They have install images for Raspberry Pi.
Then share your files using SMB/CIFS.
Using a Raspberry Pi as a NAS can have downsides. They sometimes have problems running for a long time. It also isn't especially fast. In fact you might have problems streaming HD videos over the network.