text:
Q: Why does the function signature differ between array_map and array_filter/array_reduce? array_map asks for the $array input as the last parameter(s).  array_filter and array_reduce take $array input as the first parameter. As a contrasting example, when you call map, filter or reduce on an array in JavaScript, the callback function signatures look like
(current, index, array) => {…}

Array.prototype.reduce takes the carryover value as the first parameter, but it is still impossible to mix up the parameters' order in the JavaScript methods.
I know that PHP isn't functionally-oriented, but I'm wondering what the design decisions were leading to the signatures for array_map etc.
Does array_map take an array as the last parameter simply because you can feed as many arrays as you want (variadic)?  Does the ability to feed an arbitrary number of arrays through the callback function of array_map outweigh having more uniform function signatures?
EDIT/ Comment:
from Wikipedia, this puts in perspective just how long PHP has been evolving:

'Early PHP was not intended to be a new programming language, and grew
  organically, with Lerdorf noting in retrospect: "I don't know how to
  stop it, there was never any intent to write a programming language
  […] I have absolutely no idea how to write a programming language, I
  just kept adding the next logical step on the way." A development team
  began to form and, after months of work and beta testing, officially
  released PHP/FI 2 in November 1997. The fact that PHP was not
  originally designed but instead was developed organically has led to
  inconsistent naming of functions and inconsistent ordering of their
  parameters. In some cases, the function names were chosen to match the
  lower-level libraries which PHP was "wrapping", while in some very
  early versions of PHP the length of the function names was used
  internally as a hash function, so names were chosen to improve the
  distribution of hash values.'

A:
Does array_map take an array as the last parameter simply because you can feed as many arrays as you want (variadic)?

Yes; only the last parameter in a method signature can be variadic.

Does the ability to feed an arbitrary number of arrays through the callback function of array_map outweigh having more uniform function signatures?

Essentially, this is asking if array_map should accept multiple arrays. There are good use cases for allowing for calling array_map with multiple arrays; below is an example from the PHP array_map guide that I've slightly modified:
<?php
function showLanguages($n, $s, $g)
{
    return("The number $n is called $s in Spanish and $g in German.");
}

$a = array(1, 2, 3, 4, 5);
$b = array("uno", "dos", "tres", "cuatro", "cinco");
$c = array("eins", "zwei", "drei", "vier", "funf");

$d = array_map("showLanguages", $a, $b, $c);
print_r($d);

What if array_map were changed to have a multidimensional array as the first argument? While it would technically make the function signatures more uniform, it would actually add some additional problems.
The underlying code would not only have to validate that the first argument is an array, it would have to validate that it's an array of arrays. That would make it essentially be a different kind of parameter than just an array, so it would still be a different method signature than the other array_* methods.
If you really wanted to have the callback as the last argument, you could use a modified function that removes the last element, move it to the first argument, then call array_map on that. You would lose all type-hinting, though, so it'd be harder to use.
/*
 * Accepts a variable number of arrays as the first N arguments, takes a callback as the last argument
 */
function map()
{
    $args = func_get_args();

    $callback = array_pop($args);

    array_unshift($args, $callback);

    return call_user_func_array("array_map", $args);
}


text:
Q: Are sentences limited to one coordinating conjunction? I have a sentence, and I'm not sure if it should be written as in example one or two:
Example one:

Someone keeps on popping my car's tires. So I installed a camera onto my car, and I caught the guy.

Example two:

Someone keeps on popping my car's tires[,] so I installed a camera onto my car, and I caught the guy.

As shown in my two examples, one of them has a comma before "so." So, which would be the better sentence?

A: Both your examples are equally correct. This is an emphasis issue. Do you want the reader to experience a full stop? Then use a period.
You may be confused with serial conjunctions, which don't take commas:
I like red and white and blue and purple.
However, the writer may still use a comma to help with comprehension:
I like red and white, or blue and purple. Although some would use an em-dash there.

A: As the question was put, stick to the second option.
Several other points in those examples need attention but in the context of the question as put neither is strictly wrong but Example Two is at least 99% preferable.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Finding Sets of 3 pairs in list that form a Circular reference Hopefully a really simple question but I have been pulling my hair out over this.
I have a list of reference points that have been identified through an index. These index values are the start and end points of lines. EG Line 1 [1,3] Line2 [4,5] etc
I attempting to do the following in Pure Python and have run through so many code iterations I cant think straight anymore. I am sure it is a list management solution of some sort...
**List 1:**

[1,3]
[4,5]
[2,1]
[5,1]
[3,2]
[4,1]

From List 1 I wish to get the following output.
**List2**
[1,3]
[2,1]
[3,2]

**List3**
[4,5]
[5,1]
[4,1]

So the result is groups of data that effectively provide a circular/triangular association between them.
Please help, I am totally stumped!
EDIT:
I have attached a sketch of the data structure I am working with. You can see each line has a start and end point reference. And identifying the corresponding "groups" within the list to be able to extract 3 unique references would allow me to generate a triangle.
Link to Data Structure Example and Desired Output
I have abandoned most of my code to date but have tried using combinations (I dont want to use this method because there will be lots of data to iterate through)
def combinations(iterable, r):
    pool = tuple(iterable)
    n = len(pool)
    for indices in permutations(range(n), r):
        if sorted(indices) == list(indices):
            yield tuple(pool[i] for i in indices)

input = IN[0]
result = []

for i in input:
    matrix = []
    matrix.append(combinations(i,3))
    result.append(matrix)

OUT = result

A: How about something like this? We basically just check each pair of adjacent vertices to see if they have any common neighbors, if so then that forms a triangle. We arbitrarily enforce some ordering on the points (x < y < z) so that we don't find the same triangle more than once.
# given some input:
pairs = ([
[1,3],
[4,5],
[2,1],
[5,1],
[3,2],
[4,1]
])

# compute the set of neighbors of each vertex
from collections import defaultdict
neighbors = defaultdict(set)
for x, y in pairs:
  # enforce some arbitrary ordering x < y < z so that
  # we don't find the same triangle more than once
  if x < y:
    neighbors[x].add(y)
  else:
    neighbors[y].add(x)

# for each pair of adjacent neighbors
for (x, y) in pairs:
  # Optional sorting
  if x > y:
    (y, x) = (x, y)

  # (x, y, z) form a triangle if z is a common neighbor of x and y
  common_neighbors = neighbors[x] & neighbors[y]
  for z in common_neighbors:
    print((x,y,z))

Producing the set of triangles (not quite in the same format that you mentioned, but should be the same information content, feel free to adjust accordingly depending on your requirements):
(1, 2, 3)
(1, 4, 5)


text:
Q: $\int_{-\infty}^{\infty}\frac{1}{3 t^2+1} {\rm exp}\left(\frac{at^2+ibt}{3 t^2+1}+itx\right){\rm d}t$ How to solve the integral?
$$
f(x)=\int_{-\infty}^{\infty}\frac{1}{3 t^2+1} {\rm exp}\left(\frac{a t^2+i b t}{3 t^2+1}+itx\right){\rm d}t\tag{1}
\\{\rm with}\,\, x,b\in \mathbb{R},a\in\mathbb{R}_{<0},i^2=-1$$
This question was previously posted in Mathematica SE, however algorithms of Mathematica couldn't solve it. A deeper mathematical analysis is needed. In the solution a potpourri of Error function, Bessel function, hypergeometric function or infinite series of them can be expected (see these solved similar integrals: integral1, integral2, integral3).
A plot of $f(x)$ for $a=-200,b=-100$:

A: In a hurry, I pulled out of my head the equality of equations (1) & (2)  but had no time to write down all the steps or reduce to simpler functions that seems to be possible with low effort. I leave that for other users.
$$\begin{align}
f(x)&=\int_{-\infty}^{\infty}\frac{1}{3 t^2+1} {\rm exp}\left(\frac{a t^2+i b t}{3 t^2+1}+itx\right){\rm d}t\tag{1}\\
g(x)&=\frac{\pi e^{a/3}}{{\sqrt{3}}} \left(
\begin{array}{l}
 \begin{array}{l}
 \sum _{k,v=0}^\infty  \frac{c_-^k c_+^v}{k! (v!)^2}\left(\frac{-2x}{\sqrt{3}}\right)^{(k+v)/2}W_{(v-k)/2,-(k+v+1)/2}\left(\frac{-2x}{\sqrt{3}}\right) & x<0 \\
 \sum _{k,v=0}^\infty  \frac{c_-^k c_+^v}{(k!)^2 v!}\left(\frac{2x}{\sqrt{3}}\right)^{(k+v)/2}W_{(k-v)/2,-(k+v+1)/2}\left(\frac{2x}{\sqrt{3}}\right) & x>0 \\
 \sum _{k,v=0}^\infty  \frac{c_-^k c_+^v}{k! (v!)^2}(k+1)^{\overline{v}} & x=0 \\
\end{array}
\end{array}
\right)\tag{2}
\end{align}$$
with
$c_{\pm}=-\frac{a}{12}\pm\frac{b}{4 \sqrt{3}}$, rising factorial $(\cdot)^{\overline{v}}$, and Whittaker's $W$ function
$$W_{(k-v)/2,-(k+v+1)/2}(x)=\sqrt{\dfrac{x^{k-v}}{e^x}}\sum _{s=0}^k \binom{k}{s} \frac{(v+1)^{\overline{s}}}{x^s}\tag{3}$$
A comparison of $f(x),g(x),|f(x)-g(x)|$ for $a=-20,b=-10$ reveals numerical insufficiencies. They are higher for the example given in the question $(a=-200,b=-100)$.

A: $\color{brown}{\textbf{Useful integral.}}$
Denote
$$f(k,m,x)=\int\limits_{-\infty}^\infty\dfrac {t^k}{(3t^2+1)^{m+k+1}}\,e^{itx} \,\text dt\tag1$$
Are known the integrals via the modified Bessel function
$$f(0,m,x)=\sqrt{\dfrac\pi3}\,\dfrac{2}{m!}\,\left|\dfrac x{2\sqrt3}\right|^{m+\frac12}\operatorname K_{\large-\frac12-m}\left(\dfrac{|x|}{\sqrt3}\right),\tag2$$
$$f(1,m,x)=i\,\sqrt{\dfrac\pi3}\,\dfrac{x}{3(m+1)!} \,\left|\dfrac x{2\sqrt3}\right|^{m+\frac12}\operatorname K_{\large-\frac12-m}\left(\dfrac{|x|}{\sqrt3}\right)=\dfrac{ix}{6m+6}\,f(0,m,x).\tag3$$
Besides,
$$f(k+2, m,x)=\int\limits_{-\infty}^\infty\dfrac {t^{k+2}}{(3t^2+1)^{m+k+3}}\,e^{itx} \,\text dt
=\dfrac13\int\limits_{-\infty}^\infty\dfrac {(3t^2+1-1)\,t^k}{(3t^2+1)^{m+k+3}}\,e^{itx} \,\text dt,$$
$$f(k+2,m,x)=\dfrac13\big(f(k,m+1,x)-f(k,m+2,x)\big),$$
$$f(k+4,m,x)=\dfrac19\big(f(k,m+2,x)-2f(k,m+3,x)+f(k,m+4,x)\big),$$
$$f(2k,m,x)=\dfrac1{3^k}\sum\limits_{j=0}^k (-1)^j\dbinom k{j}f(0,m+k+j,x).\tag4$$
$$f(2k+1,m,x)=\dfrac{ix}{3^k}\sum\limits_{j=0}^k \dfrac{(-1)^j}
{6(m+k+j+1)} \dbinom k{j}f(0,m+k+j,x).\tag5$$
In the Matematika language,
$$\begin{align}
&f(k,n+k+1,x)=\dfrac1{2\Gamma[1+k+n]}3^{-1-k} \bigg(3^{\large\frac12+\frac k2} \big(1+(-1)^k\big) \Gamma\left[\frac12+\frac k2\right]\\[4pt]
&\times \Gamma\left[\frac12+\frac k2+n\right]
\,\operatorname{HypergeometricPFQ}\left[\left\{\frac12+\frac k2\right\},\left\{\frac12,\frac12-\frac k2-n\right\},\frac{x^2}{12}\right]\\[4pt]
&-I\, 3^{\large \frac k2} \big(-1+(-1)^k\big)\, x\, \Gamma\left[1+\frac k2\right]\, \Gamma\left[\frac k2+n\right]\\[4pt] &\times\operatorname{HypergeometricPFQ}\left[\left\{1+\frac k2\right\},\left\{\frac32,1-\frac k2-n\right\},\frac{x^2}{12}\right]\\[4pt]
&+2\, I\, 3^{-n} |x|^{1+k+2 n} \Gamma[-1-k-2 n] \Gamma[1+k+n]\\[4pt] &\times\operatorname{HypergeometricPFQ}\left[\{1+k+n\},\left\{1+\frac k2+n,\frac32+\frac k2+n\right\},\frac{x^2}{12}\right]\\[4pt]
&\times \left(\big(-1+(-1)^k\big) \cos\left[\frac {k\pi}2+n\pi\right] \operatorname{Sign}[x]+I \big(1+(-1)^k\big) \sin\left[\frac {k\pi}2+n\pi\right]\right)\bigg)\\
& \,\text{if}\; x\in\mathbb R\;\&\&\;\Re[k]>-1\;\&\&\;\Re[k+2 n]>-2
\end{align}\tag{$\Diamond$}$$
$\color{brown}{\textbf{Integration.}}$
$$I=\int\limits_{-\infty}^\infty\dfrac{1}{3t^2+1}\,\exp\,\dfrac{at^2+ibt}{3t^2+1}\,\,e^{itx} \,\text dt$$
$$=\exp\,\dfrac a3\int\limits_{-\infty}^\infty\dfrac{1}{3t^2+1}\,\exp\left(-\dfrac{a}{3(3t^2+1)}\right)\exp\,\dfrac{ibt}{3t^2+1}\,\,e^{itx} \,\text dt$$
$$=\exp\,\dfrac a3 \sum\limits_{n=0}^\infty\dfrac1{n!}\left(-\dfrac a3\right)^n \sum\limits_{k=0}^\infty\dfrac{(ib)^k}{k!}
\int\limits_{-\infty}^\infty\,\dfrac {t^k}{(3t^2+1)^{n+k+1}}\,e^{itx} \,\text dt,$$
$$I=\dfrac1{\sqrt3}\exp\,\dfrac a3 \sum\limits_{n=0}^\infty\dfrac1{n!}\left(-\dfrac a3\right)^n \sum\limits_{k=0}^\infty\left(-\dfrac13\right) ^{\large\genfrac\lfloor\rfloor{}{}{k+1}2}x^{^{\Large2\genfrac\{\}{}{}k2}} \,\dfrac{b^k}{k!}$$
$$\times \operatorname B\left(\genfrac\lfloor\rfloor{}{}{k+1}2+\dfrac12,n-\genfrac\lfloor\rfloor{}{}{1-k}2+\dfrac12\right)$$
$$\times\operatorname{_1F_2}\left(\genfrac\lfloor\rfloor{}{}{k+1}2+\dfrac12;\,\dfrac12+2\genfrac\{\}{}{}k2,\,\genfrac\lfloor\rfloor{}{}{1-k}2+\dfrac12-n;\dfrac{x^2}{12}\right),$$
and these approximations do not provide sufficient accuracy.
$\color{brown}{\mathbf{Alternative\ approach,\ case\; x=0.}}$
Since
$$g(k)=\int\limits_{-\infty}^\infty\dfrac{(-a+3ibt)^k}{(3t^2+1)^{k+1}}\,\text dt
=\sqrt{\dfrac\pi3}\,\dfrac{\Gamma\left(k+\frac12\right)}{k!}(-a)^k
\operatorname{_2F_1}\left(\frac{1-k}2,-\frac k2;\frac12-k;\frac{3b^2}{a^2}\right),$$
then
$$I\bigg|_{x=0}=\sqrt{\dfrac\pi3}\,\exp\dfrac a3\,\sum\limits_{k=0}^\infty \dfrac{\Gamma\left(k+\frac12\right)}{k!^2}\left(-\frac a3\right)^k \operatorname{_2F_1} \left(\frac{1-k}2,-\frac k2;\frac12-k;\frac{3b^2}{a^2}\right).$$
$\color{brown}{\textbf{Alternative approach, common case.}}$
$$I=\int\limits_{-\infty}^\infty\dfrac{1}{3t^2+1}\,\exp\,\dfrac{at^2+ibt}{3t^2+1}\,\,e^{itx} \,\text dt$$
$$=\exp\,\dfrac a3\int\limits_{-\infty}^\infty\dfrac{1}{3t^2+1}\,\exp\left(-\dfrac{a}{3(3t^2+1)}\right)\exp\,\dfrac{ibt}{3t^2+1}\,\,e^{itx} \,\text dt$$
$$=\exp\,\dfrac a3 \sum\limits_{n=0}^\infty\dfrac{a^n}{n!} \left(-\dfrac13\right)^n\sum\limits_{k=0}^\infty\dfrac{(ib)^{2k}}{(2k)!}
\left(f(2k,n,x)+\dfrac{ib}{2k+1}\,f(2k+1,n.x)\right)$$
$$=2\sqrt{\dfrac\pi3}\exp\,\dfrac a3 \sum\limits_{n=0}^\infty\dfrac{a^n}{n!} \sum\limits_{k=0}^\infty\dfrac{b^{2k}}{(2k)!}\,\left(-
\dfrac13\right)^{n+k}
\sum\limits_{j=0}^k \dfrac{(-1)^j}{(n+k+j)!}\dbinom k{j}$$
$$\times\left(1-\dfrac{bx}{6(2k+1)(n+k+j+1)}\right)
\left|\dfrac x{2\sqrt3}\right|^{n+k+j+\frac12}
\operatorname K_{\large-\frac12-n-k-j}\left(\dfrac{|x|}{\sqrt3}\right).$$


text:
Q: Can anybody tell me why my code is returning my Z array to be 0? (CUDA C) I've written a CUDA C program to parallelize matrix multiplication by having each thread calculate a row of the result matrix. I've stored my matrices as 1D arrays in row-major form. I can't seem to find anywhere why my program shouldn't be working, be it issues with pointers or the kernel code. Help will be appreciated, thanks!
Code:
#include <cuda.h>
#include <time.h>
#include <stdlib.h>

__global__ void multiplyMatricesKernel(float* d_x, float* d_y, float* d_z, int m, int n, int p)
{
    int i = blockDim.x * blockIdx.x + threadIdx.x;
    if(i < m)
    {
        for(int j = 0; j < p; ++j)
        {
            d_z[i * p + j] = 0;
            for(int k = 0; k < m; ++k)
            {
                d_z[i * p + j] += d_x[i * n + k] * d_y[k * p + j];
            }
        }
    }
}

void multiplyMatrices(float* x, float* y, float* z, int m, int n, int p)
{

    int elements_x = m * n * sizeof(float);
    int elements_y = n * p * sizeof(float);
    int elements_z = m * p * sizeof(float);

    float* d_x;
    float* d_y;
    float* d_z;

    cudaMalloc((void**) &d_x, elements_x);
    cudaMalloc((void**) &d_y, elements_y);
    cudaMalloc((void**) &d_z, elements_z);

    cudaMemcpy(d_x, x, elements_x, cudaMemcpyHostToDevice);
    cudaMemcpy(d_y, y, elements_y, cudaMemcpyHostToDevice);

    multiplyMatricesKernel<<<ceil(m / 64.0), 64>>>(d_x, d_y, d_z, m, n, p);

    cudaMemcpy(z, d_z, elements_z, cudaMemcpyDeviceToHost);

    cudaFree(d_x);
    cudaFree(d_y);
    cudaFree(d_z);
}

int main()
{
    srand(time(NULL));
    int m = rand() % 8 + 1;
    int n = rand() % 8 + 1;
    int p = rand() % 8 + 1;

    float x[m * n] = {0};
    float y[n * p] = {0};
    float z[m * p] = {0};

    printf("X =\n[");
    for(int i = 0; i < sizeof(x) / sizeof(float); ++i)
    {
        x[i] = rand() % 129 - 64;
        printf("%.1f ", x[i]);
        if((i + 1) % n == 0 && i != (sizeof(x) / sizeof(float) - 1))
        {
            printf("]\n[");
        }
        if(i == (sizeof(x) / sizeof(float) - 1))
        {
            printf("]\n\n");
        }
    }

    printf("Y = \n[");
    for(int i = 0; i < sizeof(y) / sizeof(float); ++i)
    {
        y[i] = rand() % 129 - 64;
        printf("%.1f ", y[i]);
        if((i + 1) % p == 0 && i != (sizeof(y) / sizeof(float) - 1))
        {
            printf("]\n[");
        }
        if(i == (sizeof(y) / sizeof(float) - 1))
        {
            printf("]\n\n");
        }
    }

    multiplyMatrices(x, y, z, m, n, p);

    printf("Z = \n[");
    for(int i = 0; i < sizeof(z) / sizeof(float); ++i)
    {
        printf("%.1f ", z[i]);
        if((i + 1) % p == 0 && i != (sizeof(z) / sizeof(float) - 1))
        {
            printf("]\n[");
        }
        if(i == (sizeof(z) / sizeof(float) - 1))
        {
            printf("]\n\n");
        }
    }
    return 0;
}

A: Regarding your kernel, there is a mistake in dimentioning y and z
    int elements_x = m * n * sizeof(float);
    int elements_y = n * p * sizeof(float);
    int elements_z = m * p * sizeof(float);

*

*x is m x n

*y is m x p, not n x p

*z is n x p, not m x p
This kind of error is very difficult to find...

A: The problem is in this line inside your kernel.
for(int k = 0; k < m; ++k)

It should be n not m, as each element is the sum of n multiplications, like this:
for(int k = 0; k < n; ++k)

I want to add also that you can make the block of size 1024 not only 64.
multiplyMatricesKernel<<<ceil(m / 1024.0), 1024>>>(d_x, d_y, d_z, m, n, p);

Finally, you can make it even faster by calculating all elements in parallel, not only the rows.

A: I managed to solve my issue. Turned out that because I hadn't rebooted my Arch Linux system after a kernel package update, the necessary nvidia module needed to do GPU memory allocation and GPU to CPU memory transfers  wasn't loaded (nvidia_uvm was the module name). A restart of my system did the trick. Thanks for all your help, especially Robert Crovella and AbdelAziz AbdelLatef for pointing out my iterative error in my kernel. Thanks!


text:
Q: Question about a group-theoretic Chinese remainder theorem and intersections of normal finite-index subgroups I have recently been wondering about the group-theoretic Chinese remainder theorem. In particular, I was wondering whether this analogue can be generated to the case of more than two subgroups:
Showing that $G/(H\cap K)\cong (G/H)\times (G/K)$
An answer to following question demonstrates that it cannot, by giving an example where $G=(\mathbb Z/2\mathbb Z)^2$:
Validation for a conjecture about Chinese Remainder Theorem for groups
However, I was wondering whether anyone had a counterexample to this in an infinite group where we restrict the normal subgroups to having finite index. In particular, what I would like is an example of an infinite group $G$ and normal subgroups $L,M,N\triangleleft G$ all having finite index and satisfying $LM=LN=MN=G$ but $L(M\cap N)\neq G$ (or a proof that no such thing is possible). Can something be said of groups in which this cannot occur (e.g. $\mathbb Z$)?
Compare also the following question, in which it is shown that the Chinese remainder theorem still works if we take the indices to be coprime:
An Analogue of Chinese Remainder Theorem for Groups


text:
Q: Replacing a new line with its html equivalent in PHP I am facing a bit of a quandary, I need to replace a new line with
. Now, clearly, replacing all instances of \n did not work, as the page did not have proper linebreaks. Here is an example of some possible text:
Some text

More text

Now, this is an issue because there is no \n and I have no way to auto-insert
. How can I ensure that this contains proper linebreaks?
This is in PHP. I cannot serve it as plain text.

A: Maybe you want http://php.net/nl2br? Or maybe I have misunderstood...

A: You will want to use nl2br.
Your text has to have a newline (\n) or carriage return (\r) if the text is on 2 different lines.
nl2br will handle either case.

A: php has a built in function for that.
nl2br() i believe.

A: To replace new line breaks with  just use nl2br


text:
Q: Create a hole in react-native webview for touch events We are trying to repeat the same thing that was done is this plugin: https://github.com/mapsplugin/cordova-plugin-googlemaps/blob/master/README.md (How does this plugin work) but using react-native + mapbox gl(native).
The idea is simple: webview and mapview are "siblings", webview is above mapview and part of webview is transparent and mapview is shown under it. We would like any touch events that occur in this transparent area not to be captured by webview and bubble/whatever to mapview so you can touch/drag/zoom map.
Simply said: we want part(not all of it) of webview not to capture events, but to allow underlying view to capture them.
It looks like there are some methods in react native that allow to do that(conditionally control event capture) (https://facebook.github.io/react-native/docs/view.html#onstartshouldsetrespondercapture ) but we can't find any working example to test it and we can't completely understand documentation that is provided (we can't even understand should this callback be specified for parent view or child views).
So basically we just need some instrument in react-native to conditionally capture touch events.
Can anyone help us with it? Example with map/webview may be too complicated, any conditional capture of events in two views should help a lot.

A: I am not sure if this is the perfect solution but what you can do is to create an EvenEmitter and just make the Webview catch all of the clicks. The ones that should be handled by the Map, can me sent to the map itself.
I use them on screens, where multiple components might be created but they can be emitted to the parent screen. It is mostly used to handle modal screens.
import EventEmitter from 'react-native/Libraries/vendor/emitter/EventEmitter';

this._eventEmitter = new EventEmitter();

        this._eventEmitter.addListener('modal', (data) => {
            this.setState({
                visibleModal: true,
                modalData: data
            });
        });

Then you can use them like emitter.emit("modal", data)
Edit:
Here is another approach, which also shows you how you can use the methods you were asking in the question.
class Class extends Component {

    onStartShouldSetResponder = () => true;
    onEvent = (e) => {
        let object = {};
        object.locationX = e.nativeEvent.locationX;
        object.locationY = e.nativeEvent.locationY;
        object.pageY = e.nativeEvent.pageY;
        object.pageX = e.nativeEvent.pageX;
        object.target = e.nativeEvent.target;
        //object.touches = e.nativeEvent.touches; //These will trigger a cyclic error while parsing but you can access them
        //object.changedTouches = e.nativeEvent.changedTouches;
        object.identifier = e.nativeEvent.identifier;
        alert(JSON.stringify(object));

        if (object.pageX > this.state.x && object.pageX < (this.state.x + this.state.width) && object.pageY > this.state.y && object.pageY < (this.state.y + this.state.height))
            alert("inside") //Here you can trigger whatever function you need from the underlying view
    }

    onLayout = (event) => {
        this.setState({
            x: event.nativeEvent.layout.x,
            y: event.nativeEvent.layout.y,
            width: event.nativeEvent.layout.width,
            height: event.nativeEvent.layout.height,
        });
    }

    render(){

        return(

            <ScrollView>

            <View ref={"target"} style={{
                position: 'absolute',
                height: 200,
                width: 200,
                left: 100,
                top: 100,
                backgroundColor: 'rgba(0,0,0,0.5)'
            }}
            onLayout={this.onLayout}
            />

            <View
            onl
            onStartShouldSetResponder={this.onStartShouldSetResponder}
            onResponderMove={this.onEvent}
            style={{
                backgroundColor: 'rgba(255,0,0,0.3)',
                width: '100%',
                height: 150
            }}/>

            <TouchableWithoutFeedback
            onPress={this.onEvent}
            onLongPress={this.onEvent}
            style={{
                backgroundColor: 'rgba(0,255,0,0.3)',
                width: '100%',
                height: 150
            }}>
            <View style={{height: 150, backgroundColor: 'rgba(0,255,0,0.3)'}}/>
            </TouchableWithoutFeedback>

            <View
            onTouchStart={this.onEvent}
            onTouchEnd={this.onEvent}
            style={{
                backgroundColor: 'rgba(0,0,255,0.3)',
                width: '100%',
                height: 150
            }}>
            </View>

            </ScrollView>

        );
    }

}

Maybe this will help you pass events to the other views


text:
Q: Möbius transformation by 3 points in the Minkowski model Goal
I'm interested in describing Möbius transformations in the plane, and I'd like to define them in terms of three points and their images.
What I have tried
I know that a projective transformation in $\mathbb{CP}^1$ can be seen as a Möbius transformation, and in that setup I'm well used to finding the corresponding transformation matrix, generalizing this approach.
But I also know that Möbius geometry can be described as an interpretation of $\mathbb{P}(\mathbb R^{3,1})$, as I'll describe in more detail below. My problem is, I don't know how to express a Möbius transformation defined by three points in that world. I know that apart from the points themselves, the circumcircle of the defining points has to map to the circumcircle of their images. But that's still only four constraints, while I believe I need five (since this is a three-dimensional projective space, similar to $\mathbb{RP}^3$).
The last constraint is probably that the light cone must be preserved, but that appears to be a non-linear condition, so I don't know how to incorporate that. Some knowledge about Lorentz transformations might help here, but I don't know much about those. In particular, I don't see how to characterize Lorentz transformations using linear conditions.
I also considered doing the $\mathbb{CP}^1$ approach to find a transformation (described as a matrix in $\mathbb C^{2\times 2}$), but trying to translate that into a $\mathbb R^{4\times 4}$ matrix for Möbius geometry I failed again: an intermediate representation had quadratic terms I couldn't get rid of.
Question
How can I find a matrix in Möbius geometry, modeled as $\mathbb{P}(\mathbb R^{3,1})$, if my input is three points in the plane and their images?
Möbius geometry
Here is my understanding of Möbius geometry in the plane. My primary source for this is currently section 3.2 of this paper (although I did change a sign in my vector below since theirs seemed to be incorrect). It suggests Introduction to Möbius Differential Geometry by Hertrich-Jeromin as well as Vorlesungen über Differentialgeometrie III: Differentialgeometrie der Kreise und Kugeln. The former I find rather hard to read in a cookbook style, while the latter is not available from our library just now.
I imagine $\mathbb{P}(\mathbb R^{3,1})$ similar to $\mathbb{RP}^3$, i.e. projective three-space, but with the following bilinear form:
$$ \langle a,b\rangle = a_1b_1 + a_2b_2 + a_3b_3 - a_4b_4 $$
A circle with center $(x,y)$ and radius $r$ in this world is a vector
$$ \begin{pmatrix}2x \\ 2y \\ x^2+y^2-r^2-1 \\ x^2+y^2-r^2+1 \end{pmatrix} $$
or a multiple thereof. Two circles $a$, $b$ intersect orthogonally if and only if $\langle a,b\rangle = 0$ since
$$\langle a,b\rangle = 2\left(r_a^2 + r_b^2 - (x_a-x_b)^2 - (y_a-y_b)^2\right)$$
A circle of radius zero is a point. This kind of circle is the only one which is orthogonal to itself. Hence the light cone $\left\{p\in\mathbb{P}(\mathbb R^{3,1})\;\middle|\;\langle p,p\rangle = 0\right\}$ characterizes the set of all points. Since a Möbius transformation maps points to points, it has to preserve that light cone.

A: In fact, you are looking for an imbedding
$\text{PGL}_2{\mathbb C}=\text{PSL}_2{\mathbb C}\hookrightarrow\text{PO}({\mathbb R};3,1)=\text{Isom}\,{\mathbb H}_{\mathbb R}^3$
that provides the subgroup of all orientation-preserving isometries of
${\mathbb H}_{\mathbb R}^3$.
Consider the $4$-dimensional ${\mathbb R}$-linear space $H$ formed all hermitian $2\times 2$-matrices. It is easy to verify that $q(h):=\det h\in{\mathbb R}$ defined for all $h\in H$ is a quadratic form of signature $(3,1)$.
The group $\text{SL}_2{\mathbb C}$ acts on $H$ by the rule $g\cdot h:=ghg^*$ (on the right-hand side, we use the matrix multiplication and the hermitian transpose). Obviously, this action preserves the quadratic form $q$ and, therefore, provides the desired imbedding.
The imbedding $g\mapsto i(g)$ is "quadratic" : the coefficients of $i(g)$ are quadratic homogeneous expressions in coefficients of $g$ (they also involve the complex conjugation). This "quadratic" feature is inescapable because, in a sense, an imbedding in question is unique. So, if you need, you can extract from it all particular formulae you may want to.

A: It is   fun to see in an invariant way where the embedding
$\text{PGL}_2{\mathbb C}=\text{PSL}_2{\mathbb C}\hookrightarrow\text{PO}({\mathbb R};3,1)$
  which   Sasha speaks of `comes from'.
Take   $V$ to  be a two-dimensional complex vector space so that  ${\mathbb C} {\mathbb P}^1$
is the quotient of $V \setminus 0$ by the group  ${\mathbb C} \setminus 0$ of nonzero complex scalars.
Now split the group up   as  $ {\mathbb R}^+ \times S^1 = $ (scalings)x (rotations) and form the
same quotient but in two steps: first by rotation, then by scaling.
Divide   $V$  by the rotation group $S^1$ using invariant theory as follows.
A) LEMMA: The vector space $Q$ of real quadratic $S^1$-invariant functions on $V$ forms a 4-dimensional real vector space.  Any $S^1$-invariant polynomial on $V$ is a function of these quadratic invariants. There is a single quadratic relation $R$ amongst the invariants.
STANDARD REALIZATION OF LEMMA. Choose  linear coordinates $z_1, z_2$ for $V$. A basis for $Q$ is then  $|z_1|^2, |z_2|^2, Re(z_1 \bar z_1), Im(z_1 \bar z_2)$. The relation
$R$ comes from $|z_1|^2|z_2|^2 = |z_1 \bar z_2|^2$.
EXERCISE: as a real quadratic form on $Q$ the relation $R$   has signature $3,1$.
B)  Let $Q^*$ be the real dual  vector space to $Q$.
Let $\delta V \to Q^*$ be  evaluation   map $\delta(v) (P) = P(v)$, for $P \in Q$. It follows from the lemma that this map defines an isomorphism $V/S^1$ onto the image of $\delta$. The  image of $\delta$  is the ``positive half'' of the light cone in $Q^*$
relative to the  dual quadratic form to the quadratic form $R$ on $Q$.  (The origin is sent to  the cone point.) In terms of  the standard realization we can write
$\delta(v) = v v^*$ where  $v= (z_1,z_2)$.  We are then identifying $Q^*$ with
the space of Hermitian matrices on $V$.  The components of the rank 1   Hermitian matrix  $v v^*$ are the basis of invariants. The map $\delta$ is  a $Gl(V)=\text{GL}_2{\mathbb C}$ equivariant  map (and $S^1$-invariant) map from $V$ to $Q^*$.
Next, divide by scalings $t \in {\mathbb R}^+$.  Use $\delta(tv) = t^2 \delta (v)$.  Thus dividing by scalings over on the image of $\delta$ side
corresponds to dividing out the positive light cone by positive scalings. We get as a   result a $\text{GL}_2{\mathbb C} : \text{O}({\mathbb R};3,1)$-equivariant embedding
of ${\mathbb C} {\mathbb P}^1$ into real projective 3-space whose  image is the projectivized light cone: a real projective conic.
Where are the circles of Mobius in this real conic? Three distinct points (or rays) on the light cone determine a unique 3-plane in $Q^*$.  The intersection of this 3-plane with the light cone, viewed real-projectively is the corresponding circle connecting the three points.


text:
Q: Can I calculate minimum rise time of a transmission line if I know the length and the loss tangent? Overview: I am trying to work out if it's possible to transmit my 1.2Gbps MIPI data down a 600mm long flexible PCB strip. Assuming I have the impedance correct, will the signal still be degraded by the loss tangent of the dielectric?
Some background: I have already made some test strips, 180mm long using DuPont's AP laminate, and have discovered that the rise time on each is 250ps. When I produce a 600mm long strip, the rise time will be significantly longer.
According to the MIPI spec, I need to achieve a rise time between 150ps - 250ps for my 1.2Gbps DDR clock.
Possible solution: DuPont have another laminate, Pyralux TK, with a lower loss tangent.
Question: Is it possible to estimate the likely benefit of this alternative material. Is there some simple rule of thumb, like: "half the loss tangent implies half the rise time"? Or is this something I simply have to simulate in Polar?
My attempt at an answer: This is a graph from the Pyralux datasheet:

According to my calculations, a rise time of 250ps, gives a bandwidth of 1.4Ghz. Looking at the graph, that equates to a loss of about 0.05dB/cm. Over 60cm, this would be a loss of 3dB, which is equivalent to an amplitude loss of 1.413.
That doesn't seem too bad, although I'm not sure how it relates to my minimum rise time in practice. Do my calculations make sense?


text:
Q: How to convert backslash string to forward slash string in python3? I am using python3 in my ubuntu machine.
I have a string variable which consist a path with backslash and i need to convert it to forward slash string. So i tried
import pathlib
s = '\dir\wnotherdir\joodir\more'
x = repr(s)
p = pathlib.PureWindowsPath(x)
print(p.as_posix())

this will print correctly as
/dir/wnotherdir/joodir/more

but for different other string path, it acts weirdly. Ex, for the string,
'\dir\aotherdir\oodir\more'

it correctly replacing backslashes but the value is wrong because of the character 'a' in original string
/dir/x07otherdir/oodir/more

What is the reason for this behavior?

A: This has nothing to do with paths per-se. The problem here is that the \a is being interpreted as an ASCII BELL. As a rule of thumb whenever you want to disable the special interpretation of escaped string literals you should use raw strings:
>>> import pathlib
>>> r = r'\dir\aotherdir\oodir\more'
>>> pathlib.PureWindowsPath(r)
PureWindowsPath('/dir/aotherdir/oodir/more')
>>>


text:
Q: Referenced Nuget DLL Not Found Working Visual Studio I added a Nuget library called Mpir.Net, which specializes in manipulating gigantic numbers much faster than the in-built BigInteger class does. When I added it in, Visual Studio 2017 was able to find the DLL, add it into my references, and provide suggestions based on the variables and functions defined in the DLL. Visual Studio was clearly able to find the DLL, unlike many questions on here from people with similar problems.
The problem is that when I run the program, it says xmpir64.dll not found, even though Visual Studio can reference things inside it in the code editor.
I've tried changing the target .NET version to no avail. What is the problem?
As a side note, I'm very new to C# and Visual Studio, so please keep that in mind when answering. Here is a link to a picture of my solution explorer.

A: Mpir.Net is a wrapper around an unmanaged library (GMP). When it says it's unable to find the DLL, it's because it's looking for the unmanaged one (xmpir64.dll) which is in your project folder (not the managed one in the references, which is the wrapper).
You probably just need to click on xmpir64.dll (and the x32 one too), look at its properties in the bottom right, and ensure copy to output directory is set to "copy always".
As a side note, Mpir.NET does not dispose of its unmanaged resources correctly, so don't be surprised if you have a big memory leak. I don't think I'd use it for commercial code.


text:
Q: Linux: SSH/SCP Ask for id_dsa passphrase even in key-less connections I have a public/private key pair for ssh connections to a server S, but now, even if do a ssh to another device that does't need any key authentication, I always have the message:
> ssh user@192.168.0.10
Enter passphrase for key '/home/user/.ssh/id_dsa':
user@192.168.0.10's password:

Usually I hit enter in the first question (leaving it blank) and I type the user's password in the second question.
But as I want to write some scripts to automatize some things, the "Enter passphrase for key '/home/user/.ssh/id_dsa': " message bothers me.
Why it appears for every connection request? Can I do something so it won't ask me that for every connection? Just with the server S?
Thanks

A: Assuming you're using Linux ssh-agent to store your keys so you don't have to keep typing it.
Using ssh-agent to manage your keys

A: Based on this ServerFault answer:
ssh -o PubkeyAuthentication=no host.example.org
To avoid typing it every single time, you can add something like this to ~/.ssh/config
Host host.example.org
PubkeyAuthentication no


text:
Q: Virtual TableViewer sorting causes selection problems Our application is an RCP appliction and needs to display table of several thousands items. For this reason, we're using SWT.VIRTUAL in our TableViewer. That works pretty well except for selection.
We're having following issue :

*

*Our TableViewer support sorting and filtering. When we use a virtual tableviewer, changing the selection does not preserve the current selected item but the row currently selected.This leads to another item being selected.
e.g: If Item 'A' present at the 5th row is selected by user and sorting is performed, then after sorting the Item at the 5th row gets selected instead of the Item 'A'.
Using a non virtual TableViewer, everything works fine.

We tried to go into debug and found out that the cache from the AbstractTableViewer.VirtualManager class seems to be up to date with the model.
Forcing the cache to be used in the AbstractTableViewer.virtualSetSelectionToWidget() can be a possible approach.
We have tried to implement a solution suggested in https://bugs.eclipse.org/bugs/show_bug.cgi?id=338696. However it didn't work.
Please suggest some pointers or alternative work around.
Thanks for the answers.

A: As a workaround for working with huge tables I would suggest you to take a look at the Nattable project http://www.eclipse.org/nattable/. It supports everything you need (sorting, filtering, tree structured elements, lazy loading etc.). We successfully use it in our project, where it is necessary to display hundreds of thousands elements as a tree with around 160 columns. It also has some pretty cool styling features, which can make your table more user-friendly and interactive. Hope this helps


text:
Q: Google Calendar API Events.list(). How to get "out of office"? I use EventsResource.ListRequest to get Calendar event. It is request,But when I set "out of office" or "reminder" on Google Calendar,It do not request.
How can I solve this problem or Which parameter with EventsResource.ListRequest should I add?
This my code about EventsResource.ListRequest.
Public Function Fun_List(ByVal oService As CalendarService) As DataTable
    Dim oRequest As EventsResource.ListRequest = oService.Events.List("primary")
    oRequest.TimeMin = Now.ToString("yyyy-MM-dd'T'00:00:00.fffK")
    oRequest.ShowDeleted = False
    oRequest.SingleEvents = True
    oRequest.OrderBy = EventsResource.ListRequest.OrderByEnum.StartTime

    Dim oEvent As Events = oRequest.Execute()
    Dim dt_Calender As DataTable = Fun_CreatTable("Calendar")
        'BUILD DataTable
    Return dt_Calender

The "out of office" and "reminder" is like this image.
image


text:
Q: ERROR > java.lang.NoSuchFieldError: IS_LAF_WINDOWS_XP_ENABLED I m trying to import an existing java project to Netbeans.
I already import related jar files to the project but when I run the main class, it throws this exception.
How can I solve this problem?
Thanks in advance
run:
Exception in thread "main" java.lang.NoSuchFieldError: IS_LAF_WINDOWS_XP_ENABLED
    at com.jgoodies.looks.LookUtils.<clinit>(LookUtils.java:85)
    at com.jgoodies.looks.plastic.PlasticLookAndFeel.<clinit>(PlasticLookAndFeel.java:126)
    at org.addition.epanet.ui.EpanetUI.main(EpanetUI.java:579)
C:\Users\Monster_PC\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 1 second)[enter image description here][1]


text:
Q: Defining nested list into a vector with default R packages myList <- rep(0, 5)
myList <- list('Aa'= c("1","12"), 'Ba'= c("123","321"), 'Ca'= c("444"))
for (x in names(myList)) {
  for (j in myList[x]) {
    sample <- c(unlist(myList[j]))
  } }

sample

In a nested list, want to turn this list to a vector with the

"for"

loop
I can't figure out how to extract the values without defining a function.
sample <- c(unlist(myList[x])

Doing "unlist" does the work just with another codes
> sample
 NULL

But I want all and this one is not working like that. Is there any basic version? No need to be fast or non-complicate. Just with only the base R distribution packages, with the

alternative of "unlist"

if it is possible.
I need something like

     Aa1  Aa2  Ba1  Ba2  Ca1
     "1" "12" "123" "444"

And i think i don't need

myList <- rep(0, 5)

A: I maybe don't quite understand your question right, but doesn't
sample <- unlist(myList)
#   Aa1   Aa2   Ba1   Ba2    Ca
#  "1"  "12" "123" "321" "444"

or
sample <- structure(unlist(myList))
#  Aa1   Aa2   Ba1   Ba2    Ca
#  "1"  "12" "123" "321" "444"

achieve what you want?

A: If I'm understanding you right you want to unlist without unlist in base R. You could do it like so:
res <- NULL
for (i in seq(names(myList))) {
  nm <- names(myList)[i]
  l <- myList[[nm]]
  res<- c(res, setNames(l, paste0(nm, seq(l))))
}
res
# Aa1   Aa2   Ba1   Ba2   Ca1
# "1"  "12" "123" "321" "444"

Check:
unlist(myList)
# Aa1   Aa2   Ba1   Ba2    Ca
# "1"  "12" "123" "321" "444"

A: I also have to admit to not quite understanding what you're trying to achieve, but if you want the result of unlist() without explicitly using that function you can try rapply() - although by default unlist() is being used under the hood:
rapply(myList, f = function(x) x)

  Aa1   Aa2   Ba1   Ba2    Ca
  "1"  "12" "123" "321" "444"

A: Not really sure why you want to avoid unlist, but here's an alternative with flatten_chr.
len <- lengths(myList)
setNames(purrr::flatten_chr(myList),paste0(rep(names(myList),len),sequence(len)))

#  Aa1   Aa2   Ba1   Ba2   Ca1
#  "1"  "12" "123" "321" "444"

If you are ok adjusting the names a bit you can also use make.unique :
setNames(purrr::flatten_chr(myList),make.unique(rep(names(myList), len),sep = ""))

#   Aa   Aa1    Ba   Ba1    Ca
#  "1"  "12" "123" "321" "444"


text:
Q: Previous month query - Databricks I try to find a function where I can extract the result of the last month only
(for exemple if I launch the query in november, I want to display only the resultat of october)
There the result :

I dont know if I have to enter the function in my select or where clause
Thanks for you help!!
CHeers!
I tried the function month(date, -1)
I want to see all the result for the previous month

A: You can try getting the date and applying in the where clause.
Note that there may be more efficient options available.
Query to Use:
WHERE
DATE_TRANSACTION BETWEEN
trunc(date_sub(CURRENT_DATE, dayofmonth(CURRENT_DATE)),'MM')
AND
date_sub(CURRENT_DATE, dayofmonth(CURRENT_DATE))

Explanation:

*

*CURRENT_DATE - Gives the current Date

*dayofmonth(CURRENT_DATE) - Gives the day part of current date.

*date_sub(CURRENT_DATE, dayofmonth(CURRENT_DATE)) - Gives the last day of previous month. Assume current_date is 2022-11-23, dayofmonth will give 23, when you subtract 23 days, it goes to the last day of previous month i.e. 2022-10-31.

*trunc(date_sub(CURRENT_DATE, dayofmonth(CURRENT_DATE)),'MM') - Truncates date to first day of month.

*DATE_TRANSACTION  - between these two days.


text:
Q: Calculus: Local/Global Minima/Maxima
Let $f$ be continuous on $[a,b]$ where $a<b$ such that $f(x)\ne0$ for all $x\in[a,b]$. Prove that there is a $c>0$ where either $f(x)>c$ for all $x\in[a,b]$ or $f(x)<-c$ for all $x\in[a,b]$.

Is this about local/absolute minimum and maximum? I do not know how to approach this question and any guidance to at least start the approach would be very much appreciated. Thank you!

A: Since $f$ is continuous, by the extreme value theorem there exists a lower bound $m$ and an upper bound $M$ on $[a,b]$. Let $q,Q\in[a,b]$ be such that $f(q)=m$ and $f(Q)=M$.
We have that both $m$ and $M$ are non-zero from the definition of $f$, so they are either positive or negative each. Suppose they are of opposite signs, then by the intermediate value theorem there exists some $r$ between $q$ and $Q$ with $f(r)=0$, but the definition of $f$ precludes this.
Hence $m$ and $M$ have the same signs. If they are both positive, we choose $c$ such that $0<c<m$; if they are both negative, we choose $c$ such that $M<-c<0$. Then $c$ or $-c$ is a lower or upper bound on $f$, respectively. This completes the proof.


text:
Q: ValueError: Error when checking input: expected conv2d_3_input to have shape (100, 100, 1) but got array with shape (100, 100, 3) When I try to code a neural network for image recognition, I get the error:

ValueError: Error when checking input: expected conv2d_3_input to have shape (100, 100, 1) but got array with shape (100, 100, 3).

All my images are greyscale with size 100x100 pixels.
Here the code:

# Importing the Keras libraries and packages
import tensorflow as tf
from keras.models import Sequential
from keras.layers import Conv2D
from keras.layers import MaxPooling2D
from keras.layers import Flatten
from keras.layers import Dense
# Initialising the CNN
classifier = Sequential()
# Step 1 - Convolution
classifier.add(Conv2D(32, (3, 3), input_shape = (100, 100, 1), activation = 'relu'))
# Step 2 - Pooling
classifier.add(MaxPooling2D(pool_size = (2, 2)))
# Adding a second convolutional layer
classifier.add(Conv2D(32, (3, 3), activation = 'relu'))
classifier.add(MaxPooling2D(pool_size = (2, 2)))
# Step 3 - Flattening
classifier.add(Flatten())
# Step 4 - Full connection
classifier.add(Dense(units = 128, activation = 'relu'))
classifier.add(Dense(units = 1, activation = 'sigmoid'))
# Compiling the CNN
classifier.compile(optimizer = 'adam', loss = 'binary_crossentropy', metrics = ['accuracy'])
# Part 2 - Fitting the CNN to the images
from keras.preprocessing.image import ImageDataGenerator
train_datagen = ImageDataGenerator(rescale = 1./255,
shear_range = 0.2,
zoom_range = 0.2,
horizontal_flip = True)
test_datagen = ImageDataGenerator(rescale = 1./255)
training_set = train_datagen.flow_from_directory('E:/exercise/dataset/train',
target_size = (100, 100),
batch_size = 32,
color_mode = "grayscale",
class_mode = 'binary')
test_set = test_datagen.flow_from_directory('E:/exercise/dataset/test',
target_size = (100, 100),
color_mode = "grayscale",
batch_size = 32,
class_mode = 'binary')
classifier.fit_generator(training_set,
steps_per_epoch = 40,
epochs = 10,
validation_data = test_set,
validation_steps = 8)

import numpy as np
from keras.preprocessing import image
test_image = image.load_img('E:/exercise/predict_2.jpg', target_size = (100, 100))
test_image = image.img_to_array(test_image)
test_image = np.expand_dims(test_image, axis = 0)
result = classifier.predict(test_image)
training_set.class_indices
if result[0][0] >= 0.5: prediction = 'happy'
else: prediction = 'sad'
print(prediction)

Anyone can show me how to fix this problem. Thank you all!

A: Try adding the parameter preprocessing_function=gray_to_rgb to ImageDataGenerator for both train_datagen & test_datagen, as:
def rgb_to_gray(rgb):     # Using the luminosity formula: grayscale =  0.21 R + 0.72 G + 0.07 B
    return np.dot(rgb[...,:3], [0.299, 0.587, 0.114])

train_datagen = ImageDataGenerator(rescale = 1./255,
shear_range = 0.2,
zoom_range = 0.2,
horizontal_flip = True,
preprocessing_function=rgb_to_gray)
test_datagen = ImageDataGenerator(rescale = 1./255, preprocessing_function=rgb_to_gray)


text:
Q: Check if parameters exist in an URL How can I check if an URL has parameters in it?
for instance, if the string is like this,
form_page_add.php?parent_id=1

return true

But if it is like this,
form_page_add.php?

return nothing

Thanks.
EDIT:
Sorry for not being clear, the URL is submitted from a from as a string. and I will store that string in a variable,
if(isset($_POST['cfg_path'])) $cfg_path = trim($_POST['cfg_path']);

so I need to check this variable $cfg_path whether is has parameters in it.

A: Another way to check would be to use parse_url() method. Check docs here. This function will return an associative array with an element 'query' which will contain the GET parameters.
Use the empty() function to check and see whether this field is empty or not. If empty, then no parameters have been passed.
Code Sample -
<?php

    $url = "http://www.sub.domain.com/index.php?key=value&key2=value2";
    print_r(parse_url($url));
?>

Output
Array
(
    [scheme] => http
    [host] => www.sub.domain.com
    [path] => /index.php
    [query] => key=value&key2=value2
)

A: Could also look for a specific key with array_key_exists(), e.g.
if(array_key_exists('some-key', $_GET))

http://php.net/manual/en/function.array-key-exists.php

A: You can use this simple function:
function url_get_param($url, $name) {
    parse_str(parse_url($url, PHP_URL_QUERY), $vars);
    return isset($vars[$name]) ? $vars[$name] : null;
}

See it in action here.
It will return the value of the parameter if it exists in the url, or null if it does not appear at all. You can differentiate between a parameter having no value and not appearing at all by the identical operator (triple equals, ===).
This will work with any URL you pass it, not just $_SERVER['REQUEST_URI'].
Update:
If you just want to know if there is any parameter at all in the URL then you can use some variant of the above (see Phil's suggestion in the comments).
Or, you can use the surprisingly simple test
if (strpos($url, '=')) {
    // has at least one param
}

We don't even need to bother to check for false here, as if an equals sign exists it won't be the first character.
Update #2: While the method using strpos will work for most URLs, it's not bulletproof and so should not be used if you don't know what kind of URL you are dealing with. As Steve Onzra correctly points out in the comments, URLs like
http://example.com/2012/11/report/cGFyYW1fd2l0aF9lcXVhbA==

are valid and yet do not contain any parameter.

A: If you are looking for whether a URL stored as a string (instead of the URL that is being called to invoke the PHP script), you can use strpos()
So you would be able to search the string for an occurence of ?, and then deal with it appropriately. For example:
$pos = strpos($myString, "?");
if($pos && $pos<strlen($myString){
    //deal with URLs with parameters
}


text:
Q: Python setup.py clone the subfolder and use it as source code The Python project intensively uses common declaration from another repository.
from *another_repository*.common import *class1*, *class2*.

How to properly integrate such folder within own repository, without copying it itself into the current project?
In setuptools.setup there is a field like install_requires. I have tried the next option:
install_requires = [..., 'another_repository @ git+ssh://git@gitlab.com/another_repository@master&subdirectory=common', ...]

But it does not work, since common folder does not contain any setup.py module.

A: As mentioned in the comments and by thinking about the problem, I have found the next possible solutions:

*

*Migrate all common code from the another_repository/common (dataclasses, routines, etc) to the other repository common_repository, and use it as a dependency.

*Use a repo as a submodule it the current project.

*Contribute a setup.py to the another_repository/common, to make it installable.


text:
Q: A measurable set from a sequence of sets Let (X,M, $\mu$) be a measure space and $E_n$ be a sequence of measurable sets. Let k be a fixed integer and G be the set of all those points that belong to $E_n$ for at least k values of n.
a) Prove that G is measurable.
I am trying to find a way to rewrite G as a countable union of countable intersections. I have come up with the following:
For k = 2, $G_2 = (E_1 \cap E_2) \cup (E_1 \cap E_3) \cup...\cup (E_2 \cap E_3) \cup (E_2 \cap E_4) \cup...\cup (E_k \cap E_{k+1}) \cup (E_k \cup E_{k+1})... $
$G_2 = \bigcup_{n=2}^\infty (E_1 \cap E_n) \cup \bigcup_{n=3}^\infty(E_2 \cap E_n) \cup...\cup \bigcup_{n=k+1}^\infty(E_k\cap E_n) \cup....$
$G_2 = \bigcap_{k=1}^\infty \bigcup_{n=k+1}^\infty (E_k \cap E_n)$
Since $G_2$ is a countable union of intersections it is in M and hence measurable.
I'm having trouble generalizing this approach for an arbitrary K...
b) Show $k\mu(G)\le \sum_{n=1}^\infty \mu(E_n)$
One hint was to look at: $\sum_{n=1}^\infty \int_G \chi_{E_n}d\mu$ however without the correct breakdown in part a) I'm not sure if I can proceed.
Edit:
Here's what I have:
$k\mu(G) = \int_G k d\mu \le \int_G \sum_{n=1}^\infty \chi_{E_n}d\mu$ (not confident with the inequality here. Is this because if x is in g, it is in k or more of the En's?)
Continuing by MCT
$\int_G \sum_{n=1}^\infty \chi_{E_n}d\mu = \sum_{n=1}^\infty \int_G \chi_{E_n} d\mu = \sum_{n=1}^\infty \int \chi_G \chi_{E_n}d\mu = \sum_{n=1}^\infty \int \chi_{G \cap E_n} d\mu =\sum_{n=1}^\infty\mu(G\cap E_n) \le \sum_{n=1}^\infty \mu(E_n)$
*I have not learned about Markov inequality. This is a qualifying exam question and Markov inequality is not on the syllabus.

A: Hint: Express $G$ as an upper level set of the measurable function
$$
F:x\mapsto\sum_{n=1}^\infty 1_{E_n}(x).
$$ (What does $F(x)$ mean?) For (b), apply Markov's inequality.
EDIT: Since $F(x)$ is the number of $n$ for which $x\in E_n$, we have
$$
G = \{x\;|\;F(x)\ge k\}
$$ is measurable. Now, observe that $k 1_G(x) \le F(x)$ since $k\le F(x)$ on $G$. Integrate both sides with respect to $\mu$ to get
$$
k\mu(G) = \int k1_G(x)d\mu(x) \le \int F(x)d\mu(x) = \sum_{n=1}^\infty \mu(E_n)
$$ by monotone convergence thereom.

A: Let $\mathscr F$ be the set of all intersections of $k$ $E_n$'s. Then $\mathscr F$ is countable and $G$ is the union of all elements of $\mathscr F$.


text:
Q: I've locked a field but can't even put data in the first place Here is my form:

I want to lock the dateOpened once the user selects a date. However, when I select a date, it doesn't appear in the box when it is "locked" in the property panel. I was wondering if there is a simple trick to circumvent that? Thank you!

A: The Locked property affects the date picker as well.
You should set Locked = False in the property sheet, and in the AfterUpdate event procedure of the date control:
Me!dateOpened.Locked = True

If the user can add new records with this form without it being closed and reopened, you must set .Locked = False in that case.


text:
Q: Selecting polygons within other polygons in the same layer in QGIS I am trying to filter out certain infrastructure from OSM data and convert everything to simple point layers using QGIS.
I have an OSM shapefile containing polygons of schools. In many instances, polygons lie within other polygons, for example, different faculties within a university building. However, if both polygons are categorized as university I just need one polygon with the university's name. (I don't need detailed data, just an overview). Converting every polygon to a point will result in multiple points for one single building.
So I am looking for a way to select the largest polygon and delete or merge the smaller internal polygons if they are within the same class. However, if there is a building containing a school and a kindergarten I want the polygons to remain separate.
I have tried the Select Within plugin to filter the internal polygons, but it obviously selects every single polygon, even the outer ones. The same goes for Select Layer by Location. For this, I have been working with a copy of the same layer.
Dissolving them isn't really an option either, since then I suppose I would have to preselect names first, since the name is not an attribute field and just can be found somewhere in the tags.
Just so you get an idea: I'm doing this for whole countries, so I need a way to automate this in a proper way.
Does anyone have an idea how to go about this issue?
Here is a screenshot of how the data looks. In this case, I want the MultiPolygon on the left to be merged into a single polygon with the label Technical University Munich.


text:
Q: Regex Expression should not be Compulsory i have a regex expression for a textbox which is accepting only 1 place after decimal and value not greater than 6.
but currently it's compulsory/mandatory textbox which i don't want.
^([0-5](?:\.\d)?|6(?:\.0)?)$

Accepted value:
6.0
5.9
0.0
1.1
5
6
blank
not accepted:
6.01
6.1
5.99
0.00
null

A: Check this: ^((?:[0-5](?:\.\d)?|6(?:\.0)?)?)$
I changed your outer group to non-capturing and optional and added new capturing group to capture everything but start and end of line.


text:
Q: get query tree/hierarchy using Python sqlparse I'm working on a customer database which has lots of views created from complex queries with lots of suqueries e and joins, as the example query below.
I'm already using sqlparse to get table names, but now I'm wondering if its possible to get a nested dictionary with the query tree/hierarchy allowing to create a tree-view like below:
The result would be something like:
+-FULL JOIN-+
            |
            +-- QUERY 01 +
            |            |
            |            +-- QUERY 01.01 +
            |                            |
            |                            + -- QUERY 01.01.01
            |                            + -- QUERY 01.01.02
            +-- QUERY 02 +
etc...

and for each QUERY, list the sources in the FROM clause
The example  query:
SELECT --Locais Disponíveis para Abertura de Ordens de corte
 COALESCE(a."Chave", b."Chave") AS "Chave",
 COALESCE(a."Unidade", b."Unidade") AS "Unidade",
 COALESCE(a."Fazenda", b."Fazenda") AS "Fazenda",
 COALESCE(a."Talhao", b."Talhao") AS "Talhao",
 COALESCE(a."Participacao", b."Participacao") AS "Participacao",
 CASE
   WHEN a."Condicao" = 'Disponível Parcial (Moagem)' AND
        b."Condicao" = 'Disponível Parcial (Mudas)' THEN
    'Disponível (Safra+Mudas)'
   ELSE
    COALESCE(a."Condicao", b."Condicao")
 END AS "Condicao",
 COALESCE(a."Estagio", b."Estagio") AS "Estagio",
 COALESCE(a."Variedade", b."Variedade") AS "Variedade",
 COALESCE(a."Ciclo Maturacao", b."Ciclo Maturacao") AS "Ciclo Maturacao",
 COALESCE(a."Propriedade", b."Propriedade") AS "Propriedade",
 COALESCE(a."Proprietario", b."Proprietario") AS "Proprietario",
 COALESCE(a."No. Corte", b."No. Corte") AS "No. Corte",
 (CASE
   WHEN a."Area" IS NULL THEN
0
   ELSE
    a."Area"
 END + CASE
   WHEN b."Area" IS NULL THEN
0
   ELSE
    b."Area"
 END) AS "Area",
 CASE
   WHEN a."Condicao" = 'Disponível Parcial (Moagem)' AND
        b."Condicao" = 'Disponível Parcial (Mudas)' THEN
    ((CASE
      WHEN a."Area" IS NULL THEN
0
      ELSE
       a."Area"
    END + CASE
      WHEN b."Area" IS NULL THEN
0
      ELSE
       b."Area"
    END) * a."TCH")
   ELSE
    a."Toneladas"
 END AS "Toneladas",
 a."TCH",
 COALESCE(a."Distancia", b."Distancia") AS "Distancia"
  FROM (SELECT --Disponibilidade (Moagem)
         A.*,
         a."Area" * b."TCH" AS "Toneladas",
         b."TCH" AS "TCH",
         c."Dist. Terra" + c."Dist. Asfalto" AS "Distancia"
          FROM ((SELECT --ÁREAS DISPONÍVEIS PARA ABERTURA DE ORDEM CORTE DE SAFRA
                  a."Fazenda" * 1000 + a."Talhao" AS "Chave",
                  CASE
                    WHEN a."Unidade" = 15 THEN
                     'USF'
                    ELSE
                     'URD'
                  END AS "Unidade",
                  a."Fazenda",
                  a."Talhao",
                  a."Participacao",
                  CASE
                    WHEN a."Ocorrencia Cadastro" = 'C' THEN
                     'Disponível Total (Moagem)'
                    ELSE
                     'Disponível Parcial (Moagem)'
                  END AS "Condicao",
                  a."Estagio",
                  a."Variedade",
                  a."Ciclo Maturacao",
                  a."Propriedade",
                  a."Proprietario",
                  a."No. Corte",
                  (a."Area" - (CASE
                    WHEN b."Area Fechada" IS NULL THEN
0
                    ELSE
                     b."Area Fechada"
                  END)) AS "Area"
                   FROM (SELECT --ULTIMA ESTIMATIVA DO TALHAO A
                          OBJ.CD_UNID_IND AS "Unidade",
                          OBJ.CD_UPNIVEL1 AS "Fazenda",
                          OBJ.CD_UPNIVEL3 AS "Talhao",
                          OBJ.CD_UPNIVEL1 || ' - ' || F.DE_UPNIVEL1 AS "Propriedade",
                          G.DE_FORNEC AS "Proprietario",
                          CASE
                            WHEN UP3.CD_TP_PROPR IN (1, 2, 3, 11) THEN
                             'Parceria'
                            WHEN UP3.CD_TP_PROPR IN (5, 8) THEN
                             'Fornecedor'
                            WHEN UP3.CD_TP_PROPR = 6 THEN
                             'Fornecedor'
                            WHEN UP3.CD_TP_PROPR = 14 THEN
                             'Parceria'
                            ELSE
                             'Verificar'
                          END AS "Participacao",
                          C.FG_OCORREN AS "Ocorrencia Cadastro",
                          C.DT_OCORREN AS "Data Ocorrencia",
                          B.DA_ESTAGIO AS "Estagio",
                          B.NO_CORTE AS "No. Corte",
                          D.DE_VARIED AS "Variedade",
                          E.DE_MATURAC AS "Ciclo Maturacao",
                          (OBJ.QT_AREA_PROD * 1) AS "Area",
                          (OBJ.QT_CANA_ENTR / 1000) AS "Toneladas"
                           FROM PIMSCS.HISTPREPRO   OBJ,
                                PIMSCS.ESTAGIOS     B,
                                PIMSCS.UPNIVEL3     UP3,
                                PIMSCS.SAFRUPNIV3   C,
                                PIMSCS.VARIEDADES   D,
                                PIMSCS.TIPO_MATURAC E,
                                PIMSCS.UPNIVEL1     F,
                                PIMSCS.FORNECS      G
                          WHERE OBJ.CD_SAFRA =
                                (SELECT MAX(CD_SAFRA) FROM PIMSCS.HISTPREPRO)
                            AND OBJ.CD_UNID_IND IN (15, 19)
                            AND OBJ.CD_ESTAGIO = B.CD_ESTAGIO
                            AND OBJ.CD_UPNIVEL1 = UP3.CD_UPNIVEL1
                            AND OBJ.CD_UPNIVEL3 = UP3.CD_UPNIVEL3
                            AND OBJ.CD_SAFRA = UP3.CD_SAFRA
                            AND OBJ.CD_UPNIVEL1 = C.CD_UPNIVEL1
                            AND OBJ.CD_UPNIVEL3 = C.CD_UPNIVEL3
                            AND OBJ.CD_SAFRA = C.CD_SAFRA
                            AND UP3.CD_VARIED = D.CD_VARIED
                            AND E.FG_MATURAC = D.FG_MATURAC
                            AND OBJ.CD_UPNIVEL1 = F.CD_UPNIVEL1
                            AND F.CD_FORNEC = G.CD_FORNEC
                            AND C.DT_OCORREN =
                                (SELECT MAX(D.DT_OCORREN)
                                   FROM PIMSCS.SAFRUPNIV3 D
                                  WHERE D.CD_UPNIVEL1 = C.CD_UPNIVEL1
                                    AND D.CD_UPNIVEL3 = C.CD_UPNIVEL3
                                    AND D.CD_SAFRA = C.CD_SAFRA)
                            AND OBJ.CD_HIST =
                                (SELECT OBJ2.CD_HIST
                                   FROM PIMSCS.HISTPREPRO OBJ2
                                  WHERE OBJ2.CD_UPNIVEL1 = OBJ.CD_UPNIVEL1
                                    AND OBJ2.CD_UPNIVEL3 = OBJ.CD_UPNIVEL3
                                    AND OBJ2.CD_SAFRA =
                                        (SELECT MAX(CD_SAFRA)
                                           FROM PIMSCS.HISTPREPRO)
                                    AND OBJ2.CD_HIST NOT IN ('E', 'S')
                                    AND OBJ2.CD_EMPRESA IN (15, 19)
                                    AND OBJ2.DT_HISTORICO =
                                        (SELECT MAX(OBJ3.DT_HISTORICO)
                                           FROM PIMSCS.HISTPREPRO OBJ3
                                          WHERE OBJ3.CD_UPNIVEL1 =
                                                OBJ.CD_UPNIVEL1
                                            AND OBJ3.CD_UPNIVEL3 =
                                                OBJ.CD_UPNIVEL3
                                            AND OBJ3.CD_SAFRA =
                                                (SELECT MAX(CD_SAFRA)
                                                   FROM PIMSCS.HISTPREPRO)
                                            AND OBJ3.CD_HIST NOT IN ('E', 'S')
                                            AND OBJ3.CD_EMPRESA IN (15, 19)))) A,
                        (SELECT --ÁREA DE ORDEM DE CORTE DE SAFRA FECHADA B
                          QD.CD_UPNIVEL1 AS "Fazenda",
                          QD.CD_UPNIVEL3 AS "Talhao",
                          SUM(QD.QT_AREA) AS "Area Fechada"
                           FROM PIMSCS.QUEIMA_HE QH, PIMSCS.QUEIMA_DE QD
                          WHERE QH.NO_QUEIMA = QD.NO_QUEIMA
                            AND QD.CD_SAFRA =
                                (SELECT MAX(CD_SAFRA) FROM PIMSCS.HISTPREPRO)
                          GROUP BY QD.CD_UPNIVEL1, QD.CD_UPNIVEL3) B
                  WHERE a."Fazenda" = b."Fazenda"(+)
                    AND a."Talhao" = b."Talhao"(+)
                    AND a."Ocorrencia Cadastro" <> 'F'
                    AND (a."Area" - (CASE
                          WHEN b."Area Fechada" IS NULL THEN
0
                          ELSE
                           b."Area Fechada"
                        END)) > 0)) A
          LEFT JOIN (SELECT --Ultima Estimativa do Talhão
                     A.CD_HIST "Cod. Historico",
                     CASE
                       WHEN A.CD_UNID_IND = 15 THEN
                        'USF'
                       ELSE
                        'URD'
                     END AS "Unidade",
                     A.CD_UPNIVEL1 AS "Zona",
                     A.CD_UPNIVEL3 AS "Talhao",
                     A.DT_HISTORICO AS "Data",
                     A.QT_AREA_PROD AS "Area",
                     (A.QT_CANA_ENTR / 1000) AS "Toneladas",
                     A.QT_TCH AS "TCH"
                      FROM PIMSCS.HISTPREPRO A
                     WHERE A.CD_UNID_IND IN (15, 19)
                       AND A.CD_SAFRA =
                           (SELECT MAX(CD_SAFRA) FROM PIMSCS.HISTPREPRO)
                       AND A.CD_HIST NOT IN ('E', 'S')
                       AND A.QT_AREA_PROD <> 0
                       AND A.DT_HISTORICO =
                           (SELECT MAX(A2.DT_HISTORICO)
                              FROM PIMSCS.HISTPREPRO A2
                             WHERE A.CD_SAFRA = A2.CD_SAFRA
                               AND A.CD_UPNIVEL2 = A2.CD_UPNIVEL1
                               AND A.CD_UPNIVEL3 = A2.CD_UPNIVEL3
                               AND A2.CD_HIST NOT IN ('E', 'S'))) B
            ON a."Fazenda" = b."Zona"
           AND a."Talhao" = b."Talhao"
          LEFT JOIN (SELECT --Distancia Cadastrada
                     A.CD_UPNIVEL1 AS "Zona",
                     A.CD_UPNIVEL3 AS "Talhao",
                     MAX(A.DS_TERRA) AS "Dist. Terra",
                     MAX(A.DS_ASFALTO) AS "Dist. Asfalto"
                      FROM PIMSCS.UPNIVEL3 A
                      LEFT JOIN PIMSCS.SAFRUPNIV3 B
                        ON A.CD_SAFRA = B.CD_SAFRA
                       AND A.CD_UPNIVEL1 = B.CD_UPNIVEL1
                       AND A.CD_UPNIVEL3 = B.CD_UPNIVEL3
                     WHERE A.CD_UNID_IND IN (15, 19)
                       AND A.CD_OCUP = 1
                       AND A.CD_SAFRA =
                           (SELECT MAX(CD_SAFRA) FROM PIMSCS.HISTPREPRO)
                       AND B.CD_SAFRA =
                           (SELECT MAX(CD_SAFRA) FROM PIMSCS.HISTPREPRO)
                       AND B.FG_OCORREN <> 'I'
                       AND B.DT_OCORREN =
                           (SELECT MAX(B2.DT_OCORREN)
                              FROM PIMSCS.SAFRUPNIV3 B2
                             WHERE B.CD_SAFRA = B2.CD_SAFRA
                               AND B.CD_UPNIVEL1 = B2.CD_UPNIVEL1
                               AND B.CD_UPNIVEL3 = B2.CD_UPNIVEL3)
                     GROUP BY A.CD_UPNIVEL1, A.CD_UPNIVEL3) C
            ON a."Fazenda" = c."Zona"
           AND a."Talhao" = c."Talhao") A
  FULL JOIN (SELECT --Disponibilidade (Mudas)
              A.*,
              a."Area" * b."TCH" AS "Toneladas",
              b."TCH" AS "TCH",
              c."Dist. Terra" + c."Dist. Asfalto" AS "Distancia"
               FROM ((SELECT --ÁREAS DISPONÍVEIS PARA ABERTURA DE ORDEM CORTE DE SAFRA
                       a."Fazenda" * 1000 + a."Talhao" AS "Chave",
                       CASE
                         WHEN a."Unidade" = 15 THEN
                          'USF'
                         ELSE
                          'URD'
                       END AS "Unidade",
                       a."Fazenda",
                       a."Talhao",
                       a."Participacao",
                       CASE
                         WHEN a."Ocorrencia Cadastro" = 'C' THEN
                          'Disponível Total (Mudas)'
                         ELSE
                          'Disponível Parcial (Mudas)'
                       END AS "Condicao",
                       a."Estagio",
                       a."Variedade",
                       a."Ciclo Maturacao",
                       a."Propriedade",
                       a."Proprietario",
                       a."No. Corte",
                       (a."Area" - (CASE
                         WHEN b."Area Fechada" IS NULL THEN
0
                         ELSE
                          b."Area Fechada"
                       END)) AS "Area"
                        FROM (SELECT --ULTIMA ESTIMATIVA DO TALHAO A
                               OBJ.CD_UNID_IND AS "Unidade",
                               OBJ.CD_UPNIVEL1 AS "Fazenda",
                               OBJ.CD_UPNIVEL3 AS "Talhao",
                               OBJ.CD_UPNIVEL1 || ' - ' || F.DE_UPNIVEL1 AS "Propriedade",
                               G.DE_FORNEC AS "Proprietario",
                               CASE
                                 WHEN UP3.CD_TP_PROPR IN (1, 2, 3, 11) THEN
                                  'Parceria'
                                 WHEN UP3.CD_TP_PROPR IN (5, 8) THEN
                                  'Fornecedor'
                                 WHEN UP3.CD_TP_PROPR = 6 THEN
                                  'Fornecedor'
                                 WHEN UP3.CD_TP_PROPR = 14 THEN
                                  'Parceria'
                                 ELSE
                                  'Verificar'
                               END AS "Participacao",
                               C.FG_OCORREN AS "Ocorrencia Cadastro",
                               C.DT_OCORREN AS "Data Ocorrencia",
                               B.DA_ESTAGIO AS "Estagio",
                               B.NO_CORTE AS "No. Corte",
                               D.DE_VARIED AS "Variedade",
                               E.DE_MATURAC AS "Ciclo Maturacao",
                               (OBJ.QT_AREA_PROD * 1) AS "Area",
                               (OBJ.QT_CANA_ENTR / 1000) AS "Toneladas"
                                FROM PIMSCS.HISTPREPRO   OBJ,
                                     PIMSCS.ESTAGIOS     B,
                                     PIMSCS.UPNIVEL3     UP3,
                                     PIMSCS.SAFRUPNIV3   C,
                                     PIMSCS.VARIEDADES   D,
                                     PIMSCS.TIPO_MATURAC E,
                                     PIMSCS.UPNIVEL1     F,
                                     PIMSCS.FORNECS      G
                               WHERE OBJ.CD_SAFRA =
                                     (SELECT MAX(CD_SAFRA)
                                        FROM PIMSCS.HISTPREPRO)
                                 AND OBJ.CD_UNID_IND IN (15, 19)
                                 AND OBJ.CD_ESTAGIO = B.CD_ESTAGIO
                                 AND OBJ.CD_UPNIVEL1 = UP3.CD_UPNIVEL1
                                 AND OBJ.CD_UPNIVEL3 = UP3.CD_UPNIVEL3
                                 AND OBJ.CD_SAFRA = UP3.CD_SAFRA
                                 AND OBJ.CD_UPNIVEL1 = C.CD_UPNIVEL1
                                 AND OBJ.CD_UPNIVEL3 = C.CD_UPNIVEL3
                                 AND OBJ.CD_SAFRA = C.CD_SAFRA
                                 AND UP3.CD_VARIED = D.CD_VARIED
                                 AND E.FG_MATURAC = D.FG_MATURAC
                                 AND OBJ.CD_UPNIVEL1 = F.CD_UPNIVEL1
                                 AND F.CD_FORNEC = G.CD_FORNEC
                                 AND C.DT_OCORREN =
                                     (SELECT MAX(D.DT_OCORREN)
                                        FROM PIMSCS.SAFRUPNIV3 D
                                       WHERE D.CD_UPNIVEL1 = C.CD_UPNIVEL1
                                         AND D.CD_UPNIVEL3 = C.CD_UPNIVEL3
                                         AND D.CD_SAFRA = C.CD_SAFRA)
                                 AND OBJ.CD_HIST =
                                     (SELECT OBJ2.CD_HIST
                                        FROM PIMSCS.HISTPREPRO OBJ2
                                       WHERE OBJ2.CD_UPNIVEL1 = OBJ.CD_UPNIVEL1
                                         AND OBJ2.CD_UPNIVEL3 = OBJ.CD_UPNIVEL3
                                         AND OBJ2.CD_SAFRA =
                                             (SELECT MAX(CD_SAFRA)
                                                FROM PIMSCS.HISTPREPRO)
                                         AND OBJ2.CD_HIST = 'S'
                                         AND OBJ2.CD_EMPRESA IN (15, 19)
                                         AND OBJ2.DT_HISTORICO =
                                             (SELECT MAX(OBJ3.DT_HISTORICO)
                                                FROM PIMSCS.HISTPREPRO OBJ3
                                               WHERE OBJ3.CD_UPNIVEL1 =
                                                     OBJ.CD_UPNIVEL1
                                                 AND OBJ3.CD_UPNIVEL3 =
                                                     OBJ.CD_UPNIVEL3
                                                 AND OBJ3.CD_SAFRA =
                                                     (SELECT MAX(CD_SAFRA)
                                                        FROM PIMSCS.HISTPREPRO)
                                                 AND OBJ3.CD_HIST = 'S'
                                                 AND OBJ3.CD_EMPRESA IN (15, 19)))) A,
                             (SELECT --ÁREA DE ORDEM DE CORTE DE MUDAS FECHADA B
                               A.CD_UPNIVEL1 AS "Fazenda",
                               A.CD_UPNIVEL3 AS "Talhao",
                               SUM(A.QT_AREA) AS "Area Fechada"
                                FROM  PIMSCS.OCORTEMD_DE A
                                JOIN PIMSCS.OCORTEMD_HE B
                                  ON A.NO_ORDEM = B.NO_ORDEM
                               WHERE A.CD_SAFRA =
                                     (SELECT MAX(CD_SAFRA)
                                        FROM PIMSCS.HISTPREPRO)
                                 AND B.FG_SITUACAO = 'F'
                               GROUP BY A.CD_UPNIVEL1, A.CD_UPNIVEL3) B
                       WHERE a."Fazenda" = b."Fazenda"(+)
                         AND a."Talhao" = b."Talhao"(+)
                         AND a."Ocorrencia Cadastro" <> 'F'
                         AND (a."Area" - (CASE
                               WHEN b."Area Fechada" IS NULL THEN
0
                               ELSE
                                b."Area Fechada"
                             END)) > 0)) A
               LEFT JOIN (SELECT --Ultima Estimativa do Talhão
                          A.CD_HIST "Cod. Historico",
                          CASE
                            WHEN A.CD_UNID_IND = 15 THEN
                             'USF'
                            ELSE
                             'URD'
                          END AS "Unidade",
                          A.CD_UPNIVEL1 AS "Zona",
                          A.CD_UPNIVEL3 AS "Talhao",
                          A.DT_HISTORICO AS "Data",
                          A.QT_AREA_PROD AS "Area",
                          (A.QT_CANA_ENTR / 1000) AS "Toneladas",
                          A.QT_TCH AS "TCH"
                           FROM PIMSCS.HISTPREPRO A
                          WHERE A.CD_UNID_IND IN (15, 19)
                            AND A.CD_SAFRA =
                                (SELECT MAX(CD_SAFRA) FROM PIMSCS.HISTPREPRO)
                            AND A.CD_HIST = 'S'
                            AND A.QT_AREA_PROD <> 0
                            AND A.DT_HISTORICO =
                                (SELECT MAX(A2.DT_HISTORICO)
                                   FROM PIMSCS.HISTPREPRO A2
                                  WHERE A.CD_SAFRA = A2.CD_SAFRA
                                    AND A.CD_UPNIVEL2 = A2.CD_UPNIVEL1
                                    AND A.CD_UPNIVEL3 = A2.CD_UPNIVEL3
                                    AND A2.CD_HIST = 'S')) B
                 ON a."Fazenda" = b."Zona"
                AND a."Talhao" = b."Talhao"
               LEFT JOIN (SELECT --Distancia Cadastrada
                          A.CD_UPNIVEL1 AS "Zona",
                          A.CD_UPNIVEL3 AS "Talhao",
                          MAX(A.DS_TERRA) AS "Dist. Terra",
                          MAX(A.DS_ASFALTO) AS "Dist. Asfalto"
                           FROM PIMSCS.UPNIVEL3 A
                           LEFT JOIN PIMSCS.SAFRUPNIV3 B
                             ON A.CD_SAFRA = B.CD_SAFRA
                            AND A.CD_UPNIVEL1 = B.CD_UPNIVEL1
                            AND A.CD_UPNIVEL3 = B.CD_UPNIVEL3
                          WHERE A.CD_UNID_IND IN (15, 19)
                            AND A.CD_OCUP = 1
                            AND A.CD_SAFRA =
                                (SELECT MAX(CD_SAFRA) FROM PIMSCS.HISTPREPRO)
                            AND B.CD_SAFRA =
                                (SELECT MAX(CD_SAFRA) FROM PIMSCS.HISTPREPRO)
                            AND B.FG_OCORREN <> 'I'
                            AND B.DT_OCORREN =
                                (SELECT MAX(B2.DT_OCORREN)
                                   FROM PIMSCS.SAFRUPNIV3 B2
                                  WHERE B.CD_SAFRA = B2.CD_SAFRA
                                    AND B.CD_UPNIVEL1 = B2.CD_UPNIVEL1
                                    AND B.CD_UPNIVEL3 = B2.CD_UPNIVEL3)
                          GROUP BY A.CD_UPNIVEL1, A.CD_UPNIVEL3) C
                 ON a."Fazenda" = c."Zona"
                AND a."Talhao" = c."Talhao") B
    ON a."Chave" = b."Chave"

A: You can use recursion:
import sqlparse, re
def has_select(s):
   if any(isinstance(i, sqlparse.sql.Token) and i.value.lower() == 'select' for i in getattr(s, 'tokens', [])):
      yield s
   else:
      yield from [j for k in getattr(s, 'tokens', []) for j in has_select(k)]

def q_tree(s, alias=None):
    c, f = [], None
    for i in s:
       if type(i) in (sqlparse.sql.Token,):
          if re.findall('^from$|join$', i.value, re.I):
             f = i.value
       elif type(i) in (sqlparse.sql.Identifier, sqlparse.sql.IdentifierList, sqlparse.sql.Parenthesis) and f is not None:
          if (s_stml:=next(has_select(i), None)) is not None:
             c.append((f, q_tree(s_stml, None if not isinstance(i, sqlparse.sql.Identifier) else list(i)[-1].value)))
          else:
             fr = ''.join(str(j) for j in i if j.value not in {'as', '\n'})
             c.append((f, [{'table':(t1:=t.split())[0], 'alias':None if len(t1) < 2 else t1[-1]}
              for t in re.findall('(?:\w+\.\w+|\w+)\s+\w+|(?:\w+\.\w+|\w+)', fr)]))
          f = None
    return {'query':c, 'alias':alias}

print(q_tree(sqlparse.parse(query_string)[0]))

Output:
{'query': [('FROM', {'query': [('FROM', {'query': [('FROM', {'query': [('FROM', [{'table': 'PIMSCS.HISTPREPRO', 'alias': 'OBJ'}, {'table': 'PIMSCS.ESTAGIOS', 'alias': 'B'}, {'table': 'PIMSCS.UPNIVEL3', 'alias': 'UP3'}, {'table': 'PIMSCS.SAFRUPNIV3', 'alias': 'C'}, {'table': 'PIMSCS.VARIEDADES', 'alias': 'D'}, {'table': 'PIMSCS.TIPO_MATURAC', 'alias': 'E'}, {'table': 'PIMSCS.UPNIVEL1', 'alias': 'F'}, {'table': 'PIMSCS.FORNECS', 'alias': 'G'}])], 'alias': None})], 'alias': 'A'}), ('LEFT JOIN', {'query': [('FROM', [{'table': 'PIMSCS.HISTPREPRO', 'alias': 'A'}])], 'alias': 'B'}), ('LEFT JOIN', {'query': [('FROM', [{'table': 'PIMSCS.UPNIVEL3', 'alias': 'A'}]), ('LEFT JOIN', [{'table': 'PIMSCS.SAFRUPNIV3', 'alias': 'B'}])], 'alias': 'C'})], 'alias': 'A'}), ('FULL JOIN', {'query': [('FROM', {'query': [('FROM', {'query': [('FROM', [{'table': 'PIMSCS.HISTPREPRO', 'alias': 'OBJ'}, {'table': 'PIMSCS.ESTAGIOS', 'alias': 'B'}, {'table': 'PIMSCS.UPNIVEL3', 'alias': 'UP3'}, {'table': 'PIMSCS.SAFRUPNIV3', 'alias': 'C'}, {'table': 'PIMSCS.VARIEDADES', 'alias': 'D'}, {'table': 'PIMSCS.TIPO_MATURAC', 'alias': 'E'}, {'table': 'PIMSCS.UPNIVEL1', 'alias': 'F'}, {'table': 'PIMSCS.FORNECS', 'alias': 'G'}])], 'alias': None})], 'alias': 'A'}), ('LEFT JOIN', {'query': [('FROM', [{'table': 'PIMSCS.HISTPREPRO', 'alias': 'A'}])], 'alias': 'B'}), ('LEFT JOIN', {'query': [('FROM', [{'table': 'PIMSCS.UPNIVEL3', 'alias': 'A'}]), ('LEFT JOIN', [{'table': 'PIMSCS.SAFRUPNIV3', 'alias': 'B'}])], 'alias': 'C'})], 'alias': 'B'})], 'alias': None}

The result is a nested dictionary that stores basic query information, including alias, along with all subsequent joins, subqueries, and tables.


text:
Q: Is it a good practice to create a sidebar using Javascript? A couple of months ago I realized I needed to update a sidebar annually with a new link. Now instead of going through each page and inserting the link (about 20 pages), I decided to create a javascript file and link it to each page. The script would create links and append them to the page. This meant that each time we needed to create a new link, we'd only need to add a new line to the javascript file once and the change would be reflected on each page. Essentially cutting down on time wasted going through all pages and adding the new link. I wonder if this is a good practice and could there be problems I failed to foresee?
The code is listed below:
function createVolume (text, link){
  var volDiv = document.createElement("div");
  var textDiv = document.createTextNode(text);
  var linkDiv = document.createElement("a");
  linkDiv.setAttribute("href", link);
  volDiv.setAttribute("class", "volume");
  volDiv.appendChild(textDiv);
  linkDiv.appendChild(volDiv);
  var d = document.getElementById("e27");
  d.appendChild(linkDiv);
}
var bhbHome = createVolume("BHB Home", "bhb.html");
var v76 = createVolume("Volume 76", "bhb76.html");
var v75 = createVolume("Volume 75", "bhb75.html");
var v74 = createVolume("Volume 74", "bhb74.html");
var v73 = createVolume("Volume 73", "bhb73.html");
var v72 = createVolume("Volume 72", "bhb72.html");
var v71 = createVolume("Volume 71", "bhb71.html");
var v70 = createVolume("Volume 70", "bhb70.html");
var v69 = createVolume("Volume 69", "bhb69.html");
var v68 = createVolume("Volume 68", "bhb68.html");
var v67 = createVolume("Volume 67", "bhb67.html");
var v6566 = createVolume("Volume 65 and 66", "bhb_65_66.html");
var v64 = createVolume("Volume 64", "bhb64.html");
var v63 = createVolume("Volume 63", "bhb63.html");
var v626160 = createVolume("Volume 60, 61, and 62", "bhb_60_61_62.html");
var v59 = createVolume("Volume 59","bhb59.html");

A: It's not good practice. You should do it with server side code, such as a server side include, php etc. Doing it this way will not work for people without Javscript, and good practice is to do it server side.

A: No, the most straightforward solution is to use a server-side script.
If your pages are mainly static, and update rarely, yea suppose it could work. But really, just use wordpress or something.

A: There are some drawbacks i can think of, the first two assuming the code is run when the DOM is ready:

*

*there can be a re-arrange effect, with the user first seeing the page
without the sidebar and then with it

*you need to make sure that
other code running on the page that requires the sidebar is run only
after the sidebar has been created.

*(@Sheikh Heera) some search engines will not be able to index your entire page

The traditional way of doing things is by using server side includes, so look into that if you can.

A: It's not good practice!!!!!!!!.
Use references to cite why its not a good practice and the possible problems
Don't assume the user has a dynamic HTTP content capable server
Don't assume the user wants search engines getting their links

A: For maintenance purposes it's definitely a good idea to create re-used elements only once. I would, however, always prefer to do this on the server-side for the following reasons:

*

*Including the script client-side will result in unneccessary http requests.

*The browser needs to be Javascript-enabled.

*This causes unneccessary DOM manipulations. I'm far away from being an expert, but I'm sure this will cost some time.

This list is most definitely incomplete, but these are the topics that would bother me the most. If for some reason you don't have the chance or the knowledge to use a server side programming language you might want to dig into Server Side Includes. This provides a very easy-to-use technique for what you want to achieve and it should be available on common web servers.


text:
Q: How can I find out which service started a process so I can disable that service? How do you link a process to an associated service and then disable that permanently?
I know
ps aux | less

will give me the process name and port but I want to get the associated service (and even file location) so that I can disable it at boot if necessary and find out where the files are and whether I need to uninstall something.

A: On Ubuntu 16.04 and newer (using systemd as init), you can use systemctl status <PID> (from this Unix & Linux post):
For service processes:
$ systemctl status 561
● sshd.service - OpenSSH Daemon
   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2017-01-04 15:38:01 JST; 7h ago
 Main PID: 561 (sshd)
    Tasks: 1 (limit: 4915)
   CGroup: /system.slice/sshd.service
           └─561 /usr/bin/sshd -D

For other things, it will probably be in a user session scope:
$ systemctl status $(pgrep chrome -n)
● session-c2.scope - Session c2 of user muru
   Loaded: loaded (/run/systemd/transient/session-c2.scope; transient; vendor preset: disabled)
Transient: yes
   Active: active (running) since Wed 2017-01-04 15:46:30 JST; 7h ago
    Tasks: 422
   CGroup: /user.slice/user-1000.slice/session-c2.scope

Another answer in that U&L post has a simpler command:
ps -o unit -p <PID>

Compare:
$ ps -o pid,unit -p $(pgrep chrome -n) 561
  PID UNIT
  320 session-c2.scope
  561 sshd.service


text:
Q: Registering the iPhone application for push notification not working I have tried out the example found in the link http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12 ,  for my iPhone push notification message. I could successfully run all steps except the steps for registering the app for push notification for the first time.
I have followed different variations of the code:
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];

But none worked for me. I am testing it in my iPhone 4 and my Xode version is 4.2 , OS is Lion.
Please advice.

A: You can try the following:

*

*Make sure your Xcode project is configured to use the explicit bundle ID from the provisioning portal

*Make sure you're not building the target with wildcard or team provisioning profile, check this on the project AND target settings

*If you created your provisioning profile before configuring the app ID for push, regenerate the provisioning profile

Also look at the error object in the UIApplicationDelegate method
application:didFailToRegisterForRemoteNotificationsWithError:

EDIT 1
Open your provisioning profile in a text editor and look for the string
<key>aps-environment</key>

If your profile does not contain this, it is not correctly set up for push.

A: Here is my workin code sample from application delegate (AppDelegate.m)
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [application registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound];
}

To check if registration went OK, implement these three methods
– application:didReceiveRemoteNotification:
– application:didRegisterForRemoteNotificationsWithDeviceToken:
– application:didFailToRegisterForRemoteNotificationsWithError:

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIApplicationDelegate_Protocol/Reference/Reference.html
Or you can go to Settings to see if there is permissions settings available
like this:

A: If this problem appears in production (with your application on the appStore), it's very likely because you created/enabled the APNS production mode of your application AFTER having created the distribution profile.
In this case, no other option but to submit again with a correct certificate...
Rule of thumb: ALWAYS enable/create production certificate for your application BEFORE creating the distribution profile.
You can use the method described by 'nduplessis' (see below) to manually check if you application will run notification once approved.

A: iOS 14 ?
For those who faced with inability to get token, and double checked all the things mentioned above, and developed on iOS 14, and if you have non-english app title, go to Project - Target - Product Name and replace name by $(TARGET_NAME).
I spent entire week on this bug.
Once again: if your app receives token on iOS12, but can not on iOS14, get rid of non-latin chars in names. They say, including entitlements, but as for me, I've managed to make it work and with cyrillic entitlements. To change Product name was enough.

A: Have you ever seen the push notification dialog in your app? If you dismiss the dialog it takes 24 hours to reshow. Check this by setting the time on your iPhone ahead by 2 days and see if it shows.
Also have you implemented the delegate methods:
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {

- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {

- (void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {

Try putting an NSLog(@"") in the didRegisterForRemoteNotificationsWithDeviceToken and didFailToRegisterForRemoteNotificationsWithError and see it is is getting in there?
Also you require an App Id that is setup for Push notification and you need to have generated the Push notification certificates to send the messages.

A: You can only register it with a provisioning profile having an app id with push notification services enabled.please Check those steps also.This a good tutorial for starting push notification http://mobiforge.com/developing/story/programming-apple-push-notification-services

A: Go to Capabilities -> Push Notifications. If there are errors then try out this solution!
If Xcode version was changed from 7 to 8 then try out this solution!
Xcode 7 copies the aps-environment entitlement from your provisioning profile. Turning on push notifications on Xcode 8 adds the entitlement both to your provisioning profile and the entitlements file.
Try adding the aps-environment entitlement to your app's entitlements file, or switch the notification capability off and on again.


text:
Q: Feature detection for CSS3 transition property I was just messing around this modernizr to find out, how do they check if a certain CSS property is supported in a user's browser, basically I just wanted to have a small script that told me if the user's browser supports CSS transitions. I abstracted the modernizr code to something like below:
Elem = document.createElement('Alx');
      eStyle = Elem.style;

      var cssProp = (function check(){
            props = ["transition", "WebkitTransition", "MozTransition", "OTransition", "msTransition"];
            for(var i in props) {
              var prop = props[i];
                console.log(prop);
                if (!contains('-' , prop) && eStyle[prop] !== undefined ) {
                        return prop;
                }
            }
      })();

    /* The contains function */

   function contains( str, substr ) {
      return !!~('' + str).indexOf(substr);
   }

modernizr does almost the same thing, i have just made a few changes and hard coded the array values to simplify things. The script works in the following way.

*

*Create a html element (Doesn't have to be a valid html element).

*execute a IIFE that basically goes through all the possible browser versions of the css property and also the standard W3C variant. check if thing property can be applied to the html element we created, if it can't be applied the if condition fails and undefined is returned

*if the if condition passed the, the correct css-3 supported property is returned and stored in cssProps .
I just wanted to know, is this a bullet proof way of checking what transition is supported in the user's browser? or if its supported at all?
This is really my first attempt at browser feature detection and so I wanted to know.

A: To your larger point of "is this a bullet proof way of checking what transition is supported in the user's browser", the answer is no. While this will almost certainly get you 99.99% of all browsers that do support it, there will inevitably be some bizarre combination of things (a webview on a mid range Samsung android device that uses a custom version of webkit/chrome is a common culprit) that will keep you from truly being "bulletproof".
That being said, while you did a great job of pulling out the logic of what Modernizr does, I would question your need to do so.
As other commenters have mentioned, you can always create a custom build that has just what you want in it. That being said, it would make sense to do what you have done if you wanted the slimmest possible javascript build (since Modernizr almost certainly has support/code for things that are completely irrelevant to what you are doing).
If that is the case, then I would suggest you check out the caniuse results for transition. Its basically all unprefixed with the exception of older android.
That means your detect can be a much, much smaller
var supportsTransitions = function() {
  var style = document.documentElement.style;

  return 'transition' in style || 'webkitTransition' in style
}

this will give you nearly identical results (admittedly ignoring older browsers - its up to you if that matters or not) in a much smaller footprint.
Either way - wonderful start at feature detection, I hope to see you contributing your own to Modernizr soon!


text:
Q: How to extract time and store in an Array/Structure I want to measure the time difference between two time readings in a Python script.
time_stamp_1 = datetime.datetime.now()
# some task
time_stamp_2 = datetime.datetime.now()

time_stamp = time_stamp_2 - time_stamp_1

time_stamp_sec = ??

I got the result as 0:00:04.052000.

*

*What exactly is this time format I am getting?

*How to extract the time in seconds from time_stamp?

*How to store time_stamp in an array like variable (as I want to use a loop and store the time_stamp for each loop)

*How to store time_stamp_sec in an array like variable

A: 1) It's a datetime.timedelta object which is being printed nicely:
>>> import datetime
>>> datetime.timedelta(days=3)
datetime.timedelta(3)
>>> print(datetime.timedelta(days=3))
3 days, 0:00:00
>>> print(datetime.timedelta(hours=3))
3:00:00

2) You can use total_seconds():
>>> t = datetime.timedelta(hours=3)
>>> t.total_seconds()
10800.0

This gives you a float as the datetime.timedelta may represent an amount of time which isn't an exact number of seconds.
3) You can append it to a list at each step in the loop:
>>> d = []
>>> d.append(t)
>>> d
[datetime.timedelta(0, 10800)]

4) You can do the same with the result of total_seconds():
>>> e = []
>>> e.append(t.total_seconds())
>>> e
[10800.0]