text:
Q: How to match a pattern but not when a specific tag is present I'm trying to match: --This is a text and it can contain other  tags--
I will wrap matched pattern with
But i'm trying to avoid
 tag only. I.e it shouldn't match if the string has
 in between --
text.replace(/(?:--)(?:(?!--|\s))((?!
).*?)(?:--)/g,'$1')

Unfortunately, my regex matches
--This is a text, can contain othertags but don't match if
 is present--
I don't expect it to match since
 is present.

A: Make (?!
). as a group, then quantify this group, instead of quantifying . only. Aslo, ? is redundant after * because ? means 0 or 1 while * means 0 or more, which already cover 1.
(?:--)(?:(?!--|\s))((?:(?!
).)*)(?:--)

Bonus: You don't need capture group if you use positive look ahead and positive look behind for --, if your environment support it. This match itself will exclude the --.
(?<=--)(?:(?!--|\s))(?:(?!
).)*(?=--)

A: First check if string does not contain
 and then continue regex:
if (!/--.*?
.*?--/.test(text)) {
    text.replace(/(?:--)(?:(?!--|\s))((?!
).*?)(?:--)/g,'$1')
}


text:
Q: Force Varnish to Use Proxy Protocol 1 I have HaProxy terminating SSL and passing the requests back to Varnish which then either serves the cached page or requests from Nginx. However, Varnish seems to be treating the request from HaProxy as HTTP/1 not HTTP/2 and failing to serve.
I can see in the Nginx logs the following when I try to hit a page:
" while reading PROXY protocol, client: 127.0.0.1, server: 127.0.0.1:8181
2016/08/11 06:53:31 [error] 5682#0: *1 broken header: "GET / HTTP/1.1
Host: www.example.com
User-Agent: curl/7.50.2-DEV
Accept: */*
X-Forwarded-For: IP_Removed
Accept-Encoding: gzip
X-Varnish: 32777

I've found something that relates to this here which states that the reason for this is that Nginx does not work with v2 PROXY only v1. So, as a result of this I've forced the use of protocol 1 in HaProxy using the send-proxy rather than send-proxy-v2 switch. But when it gets to Varnish I think that Varnish is converting this in some way to protocol 2 which is causing it to then fail to communicate properly with Nginx.
I have removed Varnish from the equation and connected HaProxy direct to Nginx and it works perfectly via HTTP/2. The problem is something is happening in the Varnish stack and the likely suspect is the proxy protocol v2 being used by Varnish.
So, to cut a long story short, how do I force Varnish to adhere to PROXY1 rather than PROXY2 protocol? I've tried adding PROXY1 into the launch daemon options but Varnish won't accept that. Any help is appreciated. Thanks!
UPDATE - I tested HaProxy > Nginx with the send-proxy-v2 switch on the HaProxy backend and it causes the identical problem to when Varnish is introduced into the stack. Switching back to send-proxy on HaProxy fixes the issue. So, I'm convinced that the issue is Varnish using protocol 2 rather than protocol 1. But how to tell it not to?

A:
I understand that Varnish isn't HTTP/2 or does SSL but it should be passing the protocol back as is to Nginx no?

No.
But first, let's clarify.  HTTP/2 and Proxy protocol V2 have absolutely nothing to do with each other.  Remove HTTP/2 from your mind, as it is not applicable here in any sense.
Your question is, in fact, this:

If HAProxy is sending Proxy Protocol V1 to Varnish, and Nginx is configured behind Varnish to expect Proxy Protocol V1, why does Nginx complain of broken headers?  Does Varnish not forward Proxy Protocol V1 to the backend?  Does it for some reason send Proxy Protocol V2, instead?

And the answer to that question is that Varnish isn't sending either one.  Neither V1 nor V2.
The only thing you need the Proxy protocol for is so that an HTTP-aware component can receive the client IP address (and port) from a upstream, non-HTTP-aware component, such as HAProxy using mode tcp or Amazon ELB with a listener in TCP mode, either of which is typically doing SSL offloading for you and not HTTP request routing, so it needs an alternative mechanism of passing the client address.
The first HTTP-aware component can take that address and set it in an HTTP header, customarily X-Forwarded-For, for the benefit of the remaining components in the stack.  As such, there's no reason for Varnish to forward the Proxy protocol onward.  It isn't doing that in your example, and there is no obvious reason why Varnish would even be capable of forwarding the Proxy protocol.¹
And this brings us to the error.  You are misdiagnosing the problem that Nginx is reporting.  The broken header error means that Nginx is receiving something other than Proxy protocol V1.  With Varnish in the loop, there is no Proxy protocol header² present at all in the request to Nginx -- and when a listener is configured to expect the Proxy protocol header, that header is mandatory.
If a component is configured to expect Proxy protocol V1 and it is not present, that is always an error.  But "not present" means exactly that.  A V1 header is not present.  That does not mean V2 is.  It isn't.

So, I'm convinced that the issue is Varnish using protocol 2 rather than protocol 1.

You have convinced yourself incorrectly.  Proxy V2 into Nginx -- as you have tried with HAProxy -- is an error, and no Proxy protocol header at all -- as you are seeing from Varnish -- is an error, as explained above.  Both are misconfigurations, though of a different type.  What you have done here is duplicated the error but for an entirely different reason.
If you are sending all requests through Varnish, then configure Varnish to set X-Forwarded-For in the forwarded request using the information it learns from the incoming Proxy protocol mesaage.  Remove Proxy protocol from the Nginx configuration.
Or configure HAProxy to operate in HTTP mode and let it insert the header using option forwardfor.

¹ Clearly, from the error, Varnish is just sending ordinary HTTP headers -- nothing that looks like Proxy protocol.  I don't think it even supports the option of sending Proxy protocol to the origin server, but somebody say something if I've overlooked that capability.
²  I would assert that the Proxy protocol "header" is not properly called a header, given what that implies.  It is a preamble, not a header, though it was unfortunately called a "header" in the standard.  It's most certainly not an HTTP header.

A: If you upgrade Varnish to 5.0 it can send PROXY Protocol version 1 to NGINX by setting ".proxy_header = 1"

redpajama_set_name: RedPajamaStackExchange


text:
Q: When an Activator class/"Bundle-Activator" is needed in plug-in and when it's not? I've implemented "New Wizard" plug-in for my content-type.
Tested it - it works.
Then I've found that neither Bundle-Activator was declared, nor the Activator class was defined.
The question is - when the Activator class is really needed in plug-in.
And when it doesn't needed at all?

A: You only need the Bundle-Activator when you need to to something at the start and / or stop of your bundle. If your bundle is only a lib that is exporting some packages, you don't need the activation.
If you didn't need one for your bundle to function as it is supposed to, then it probably doesn't need one :)


text:
Q: Generate random numbers between 1-100 and stop when it hits 99 and count the amount of attepmts it took Im currently working on something that i really need help with. Im gonna make a while or do while loop that with the rand fuction generates random numbers between 1 and 100. When the random numbers hits 99 the loop should stop and the show the amount of attempts it took to hit the number 99 like this:
"It took 53 attempts to hit the number 99"
If someone could help me with a simple solution I would be so grateful!

A: A simple loop like this ought to do what you are after
$count=0;
$i=0;
$target=99;

while( $i!=$target ){
    $i=rand(1,100);
    $count++;
}
printf('it took %u attempts to reach %u',$count,$target);

A: A for loop is fine for this;
for ($count = 1; rand(1, 100) != 99; $count++);
echo "It took {$count} attempts to hit the number 99";

Example output;
It took 47 attempts to hit the number 99

A: In my code, I declare flag variable have value true. While loop will continue and add push value in $arrRandNum, until random value is 99.
Once 99 generates it sets flag value as false and loop will terminate.
<?php
    $flag = true;
    $randNum;
    $arrRandNum = array();
    while($flag){

        $randNum = rand(1,100);
        if(99 !== $randNum){
            array_push($arrRandNum,$randNum);
        }else{
            $flag = false;
        }
    }
    print_r("total attempts: ".count($arrRandNum)."<br/>");
    print_r($arrRandNum);
?>


text:
Q: How can I increase spaces between ticks, make the first tick nearer the the axis and remove empty spaces from a pgfplot? The question title explains it all, my plot isn't looking nice. I want to increase the spacing between each xtick, make the first xtick nearer the y axis and remove that space with no x ticks on the right side of the plot.
If possible, also indicate how can I set each legend's color/drawing, because each legend column's have a lot in commom, so I wanted to make each legend in a column have the same color but different drawing. I don't know if anyone will understand this, but I tried.
Here's the output:

My code is HUGE, but here it is:
    \documentclass{standalone}
    \usepackage{booktabs}
    \usepackage{pgfplotstable}

    \usepackage{pgfplots}

    \begin{document}

    \begin{tikzpicture}
    \begin{axis}[
    height=10cm,
    width=15cm,
    grid=major,
    legend columns = 3,
    legend style={
    at={(0.5,-0.15)},
    anchor = north},
    xtick = data,
    xlabel = Rodadas,
    ylabel = Qualidade,
    ]

\addplot coordinates {
(1, 0.678806)
(2, 0.707318)
(3, 0.735688)
(4, 0.758773)
(5, 0.850093)
(6, 0.850093)
(7, 0.850093)
(8, 0.850093)
(9, 0.850093)
(10, 0.871927)
(11, 0.871927)
(12, 0.871927)
(13, 0.871927)
(14, 0.871927)
(15, 0.871927)
(16, 0.873799)
(17, 0.875102)
(18, 0.914746)
(19, 0.914746)
(20, 0.914746)
(21, 0.914746)
(22, 0.914746)
(23, 0.914746)
(24, 0.914746)
(25, 0.914746)
(26, 0.914746)
(27, 0.914746)
(28, 0.914746)
(29, 0.914746)
(30, 0.914746)
};

\addplot coordinates {
(1, 0.755057)
(2, 0.770508)
(3, 0.786410)
(4, 0.817386)
(5, 0.835345)
(6, 0.837206)
(7, 0.841269)
(8, 0.850456)
(9, 0.855433)
(10, 0.856709)
(11, 0.865922)
(12, 0.866900)
(13, 0.884384)
(14, 0.904939)
(15, 0.909285)
(16, 0.909285)
(17, 0.912864)
(18, 0.922196)
(19, 0.942011)
(20, 0.945971)
(21, 0.945971)
(22, 0.946822)
(23, 0.949695)
(24, 0.951748)
(25, 0.955744)
(26, 0.955744)
(27, 0.955744)
(28, 0.955744)
(29, 0.955744)
(30, 0.955830)
};

\addplot coordinates {
(1, 0.779965)
(2, 0.805282)
(3, 0.822174)
(4, 0.831721)
(5, 0.871130)
(6, 0.883848)
(7, 0.889126)
(8, 0.891892)
(9, 0.915892)
(10, 0.932662)
(11, 0.937660)
(12, 0.941063)
(13, 0.954651)
(14, 0.954651)
(15, 0.954651)
(16, 0.954651)
(17, 0.955258)
(18, 0.964528)
(19, 0.964528)
(20, 0.966332)
(21, 0.972416)
(22, 0.973069)
(23, 0.973069)
(24, 0.973069)
(25, 0.975399)
(26, 0.976746)
(27, 0.978759)
(28, 0.986392)
(29, 0.989421)
(30, 0.989421)
};

\addplot coordinates {
(1, 0.248592)
(2, 0.270525)
(3, 0.270525)
(4, 0.274079)
(5, 0.274079)
(6, 0.274079)
(7, 0.276394)
(8, 0.276394)
(9, 0.276394)
(10, 0.276394)
(11, 0.277121)
(12, 0.277121)
(13, 0.277121)
(14, 0.277121)
(15, 0.277121)
(16, 0.277121)
(17, 0.277121)
(18, 0.277121)
(19, 0.291238)
(20, 0.291238)
(21, 0.308117)
(22, 0.316756)
(23, 0.316756)
(24, 0.316756)
(25, 0.316756)
(26, 0.316756)
(27, 0.316756)
(28, 0.316756)
(29, 0.316756)
(30, 0.316756)
};

\addplot coordinates {
(1, 0.301701)
(2, 0.301701)
(3, 0.301701)
(4, 0.301701)
(5, 0.301701)
(6, 0.347555)
(7, 0.347555)
(8, 0.347555)
(9, 0.347555)
(10, 0.347555)
(11, 0.347555)
(12, 0.347555)
(13, 0.347555)
(14, 0.347555)
(15, 0.347555)
(16, 0.347555)
(17, 0.347555)
(18, 0.347555)
(19, 0.369908)
(20, 0.372418)
(21, 0.372418)
(22, 0.372418)
(23, 0.372418)
(24, 0.372418)
(25, 0.372418)
(26, 0.372418)
(27, 0.372418)
(28, 0.372418)
(29, 0.372418)
(30, 0.372418)
};

\addplot coordinates {
(1, 0.301701)
(2, 0.301701)
(3, 0.308213)
(4, 0.309166)
(5, 0.310629)
(6, 0.324628)
(7, 0.324628)
(8, 0.335789)
(9, 0.338966)
(10, 0.346886)
(11, 0.349949)
(12, 0.350236)
(13, 0.355030)
(14, 0.358046)
(15, 0.358046)
(16, 0.360049)
(17, 0.360609)
(18, 0.363103)
(19, 0.367216)
(20, 0.368751)
(21, 0.372306)
(22, 0.376436)
(23, 0.376436)
(24, 0.376436)
(25, 0.376892)
(26, 0.380644)
(27, 0.380780)
(28, 0.385106)
(29, 0.389572)
(30, 0.390048)
};

    \legend{32-2 com busca local, 128-4 com busca local, 256-8 com busca local, 32-2 sem busca local, 128-4 sem busca local, 256-8 sem busca local}

    \end{axis}
    \end{tikzpicture}

    \end{document}

A: To remove the empty space on the left and right edge, you can set enlarge x limits=false.
To influence the plot styles, you can either provide options like red, mark=* to the \addplot [...] options, or you can set a cycle list that takes a list of plot styles.

    \documentclass{standalone}
    \usepackage{booktabs}
    \usepackage{pgfplotstable}

    \usepackage{pgfplots}

    \begin{document}

    \begin{tikzpicture}
    \begin{axis}[
    height=10cm,
    width=15cm,
    grid=major,
    enlarge x limits=false,
    legend columns = 3,
    legend style={
    at={(0.5,-0.15)},
    anchor = north},
    xtick = data,
    xlabel = Rodadas,
    ylabel = Qualidade,
    cycle list={
        cyan, mark=*, mark options={fill=white}\\
        orange, mark=*, mark options={fill=white}\\
        green!70!black, mark=*, mark options={fill=white}\\
        cyan, mark=*, mark options={fill=gray!80}\\
        orange, mark=*, mark options={fill=gray!80}\\
        green!70!black, mark=*, mark options={fill=gray!80}\\
    }
    ]

\addplot coordinates {
(1, 0.678806)
(2, 0.707318)
(3, 0.735688)
(4, 0.758773)
(5, 0.850093)
(6, 0.850093)
(7, 0.850093)
(8, 0.850093)
(9, 0.850093)
(10, 0.871927)
(11, 0.871927)
(12, 0.871927)
(13, 0.871927)
(14, 0.871927)
(15, 0.871927)
(16, 0.873799)
(17, 0.875102)
(18, 0.914746)
(19, 0.914746)
(20, 0.914746)
(21, 0.914746)
(22, 0.914746)
(23, 0.914746)
(24, 0.914746)
(25, 0.914746)
(26, 0.914746)
(27, 0.914746)
(28, 0.914746)
(29, 0.914746)
(30, 0.914746)
};

\addplot coordinates {
(1, 0.755057)
(2, 0.770508)
(3, 0.786410)
(4, 0.817386)
(5, 0.835345)
(6, 0.837206)
(7, 0.841269)
(8, 0.850456)
(9, 0.855433)
(10, 0.856709)
(11, 0.865922)
(12, 0.866900)
(13, 0.884384)
(14, 0.904939)
(15, 0.909285)
(16, 0.909285)
(17, 0.912864)
(18, 0.922196)
(19, 0.942011)
(20, 0.945971)
(21, 0.945971)
(22, 0.946822)
(23, 0.949695)
(24, 0.951748)
(25, 0.955744)
(26, 0.955744)
(27, 0.955744)
(28, 0.955744)
(29, 0.955744)
(30, 0.955830)
};

\addplot coordinates {
(1, 0.779965)
(2, 0.805282)
(3, 0.822174)
(4, 0.831721)
(5, 0.871130)
(6, 0.883848)
(7, 0.889126)
(8, 0.891892)
(9, 0.915892)
(10, 0.932662)
(11, 0.937660)
(12, 0.941063)
(13, 0.954651)
(14, 0.954651)
(15, 0.954651)
(16, 0.954651)
(17, 0.955258)
(18, 0.964528)
(19, 0.964528)
(20, 0.966332)
(21, 0.972416)
(22, 0.973069)
(23, 0.973069)
(24, 0.973069)
(25, 0.975399)
(26, 0.976746)
(27, 0.978759)
(28, 0.986392)
(29, 0.989421)
(30, 0.989421)
};

\addplot coordinates {
(1, 0.248592)
(2, 0.270525)
(3, 0.270525)
(4, 0.274079)
(5, 0.274079)
(6, 0.274079)
(7, 0.276394)
(8, 0.276394)
(9, 0.276394)
(10, 0.276394)
(11, 0.277121)
(12, 0.277121)
(13, 0.277121)
(14, 0.277121)
(15, 0.277121)
(16, 0.277121)
(17, 0.277121)
(18, 0.277121)
(19, 0.291238)
(20, 0.291238)
(21, 0.308117)
(22, 0.316756)
(23, 0.316756)
(24, 0.316756)
(25, 0.316756)
(26, 0.316756)
(27, 0.316756)
(28, 0.316756)
(29, 0.316756)
(30, 0.316756)
};

\addplot coordinates {
(1, 0.301701)
(2, 0.301701)
(3, 0.301701)
(4, 0.301701)
(5, 0.301701)
(6, 0.347555)
(7, 0.347555)
(8, 0.347555)
(9, 0.347555)
(10, 0.347555)
(11, 0.347555)
(12, 0.347555)
(13, 0.347555)
(14, 0.347555)
(15, 0.347555)
(16, 0.347555)
(17, 0.347555)
(18, 0.347555)
(19, 0.369908)
(20, 0.372418)
(21, 0.372418)
(22, 0.372418)
(23, 0.372418)
(24, 0.372418)
(25, 0.372418)
(26, 0.372418)
(27, 0.372418)
(28, 0.372418)
(29, 0.372418)
(30, 0.372418)
};

\addplot coordinates {
(1, 0.301701)
(2, 0.301701)
(3, 0.308213)
(4, 0.309166)
(5, 0.310629)
(6, 0.324628)
(7, 0.324628)
(8, 0.335789)
(9, 0.338966)
(10, 0.346886)
(11, 0.349949)
(12, 0.350236)
(13, 0.355030)
(14, 0.358046)
(15, 0.358046)
(16, 0.360049)
(17, 0.360609)
(18, 0.363103)
(19, 0.367216)
(20, 0.368751)
(21, 0.372306)
(22, 0.376436)
(23, 0.376436)
(24, 0.376436)
(25, 0.376892)
(26, 0.380644)
(27, 0.380780)
(28, 0.385106)
(29, 0.389572)
(30, 0.390048)
};

    \legend{32-2 com busca local, 128-4 com busca local, 256-8 com busca local, 32-2 sem busca local, 128-4 sem busca local, 256-8 sem busca local}

    \end{axis}
    \end{tikzpicture}

    \end{document}


text:
Q: On a pair of pants, complete geodesics do not cover the whole surface I am reading a thesis by Jenya Sapir. In her thesis, she mentions that "on a pair of pants, complete geodesics no longer cover the whole surface".
I could not figure out how can we come up with this claim but I knew that, when the length of each geodesic at the boundary of the surface is long enough, then this claim is true obviously.
Further questions, whether this property holds when we consider any hyperbolic surface with boundary?
Thank you in advance!

A: I do not think it is clear if the claim is true, I suggest to write to Sapir and ask for details. (It is also not entirely clear what it is claimed, namely if she means "for some" hyperbolic pairs --- in which case the claim is proven below of pants or "for all" --- in which case the claim is unclear.)
Here is what one can say in general. Let $S$ be a connected metrically complete hyperbolic surface with nonempty geodesic boundary and of finite area. Then $S=C/\Gamma$ where $C$ is a convex subset in ${\mathbb H}^2$ (with nonempty geodesic boundary) and $\Gamma< Isom({\mathbb H}^2)$ is a discrete subgroup preserving $C$. Let $\Lambda$ denote the limit set of $\Gamma$: $C$ is the closed convex hull of $\Lambda$. Let $\Delta$ denote the diagonal in $\Lambda \times \Lambda$. There is a map
$$
f: (\Lambda \times \Lambda - \Delta)\times {\mathbb R}\to C,
$$
sending a pair of distinct points $\lambda_1, \lambda_2$ in $\Lambda$ to a (parameterized with the unit speed) oriented geodesic in the hyperbolic plane asymptotic to $\lambda_1, \lambda_2$. (Fix a base-point $o\in {\mathbb H}^2$ and send $(\lambda_1,\lambda_2,0)$ to the point on the hyperbolic geodesic spanned by $\lambda_1,\lambda_2$ which is closest to $o$. Then extend to the rest of $(\lambda_1,\lambda_2,t)$ in the obvious fashion.)
The question is if this map is non-surjective. (It is equivalent to asking if $S$ is not covered by biinfinite geodesics.)
One can work, for instance, with the Klein model of the hyperbolic plane and check that the map $f$ is (locally) Lipschitz (the target is equipped with the restriction of the Fubini-Study metric on $RP^2$). Then the Hausdorff dimension of the domain  of the map is $2d+1$ where $d$ is the Hausdorff dimension of $\Lambda$. The target, of course, has Hausdorff dimension $2$, so the map is not surjective if $d<1/2$ since Lipschitz maps cannot increase Hausdorff dimension. However, if $S$ has finite area, it can be always equipped with a different metric, for which $d$ is as close to $1$ as you like (but, necessarily, $<1$). Similarly, one can always find a metric with $d$ as close to $0$ as you like.
The domain of the map $f$ has topological dimension $1$. There is a common fallacy that Lipschitz maps cannot increase topological dimension. (In fact, they can.) A worry is that the cited claim relies upon this common fallacy.
Edit.  Here is a proof that $dim(\Lambda\times \Lambda \times {\mathbb R})= 2d+1$. In general, if $X, Y$ are (separable) metric spaces (in our case, these are subsets of Euclidean spaces) then
$$
dim(X)+dim(Y) \le dim(X\times Y)\le dim(X) + dim_B(Y),
$$
where $dim_B$ is the box-counting dimension. See for instance, here. In particular, if $dim_B(Y)=dim(Y)$ then
$$
dim(X\times Y)=dim(X) + dim(Y).
$$
In our case, we are multiplying $\Lambda$ (twice) and ${\mathbb R}$. For ${\mathbb R}$, of course, $dim=dim_B$. If $\Gamma$ is a geometrically finite Kleinian group then $dim(\Lambda)=dim_B(\Lambda)$, see for instance
B.Stratmann, M.Urbanski, The box-counting dimension for
geometrically finite Kleinian groups, Fund. Math, 1996.
(More general results were proven by Bishop and Jones.) I am not sure what happens for squares of limit sets of geometrically infinite groups but you probably do not care.


text:
Q: x11vnc | ssvnc 'ReadExact: Socket error while reading' I have a x11vnc (http://www.karlrunge.com/x11vnc/) server running.
If encryption = 0 everything is working as expected and I can connect to the server via TightVNC Viewer without any problems.
If encryption = 1 I have to use SSVNC (http://www.karlrunge.com/x11vnc/ssvnc.html) to connect to the server. The client is successfully connecting, fetching the certificate, but then it fails to connect.
The x11vnc is running inside of this Docker container:
- https://hub.docker.com/r/dcflachs/veracrypt-gui/ (https://github.com/dcflachs/docker-containers/tree/master/veracrypt)

System: Windows 10 64bit
Software: ssvnc_windows_only-1.0.30.zip (http://ssvnc.sourceforge.net/dev/ssvnc_windows_only-1.0.30.zip)

A: [SSVNC] is a VNC viewer that adds encryption security to VNC connections.
While the Linux version of [SSVNC] works well, the Windows version has some
issues.  At the time of writing, the latest version 1.0.30 is not functional,
as a connection fails with the following error:
ReadExact: Socket error while reading

However, for your convienence, an unoffical and working version is provided
here:
https://github.com/jlesage/docker-baseimage-gui/raw/master/tools/ssvnc_windows_only-1.0.30-r1.zip
The only difference with the offical package is that the bundled version of
stunnel has been upgraded to version 5.49, which fixes the connection
problems.
Source: https://github.com/jlesage/docker-handbrake#ssvnc


text:
Q: Contact form message appears but no email I have built a contact form but the problem is, sometimes it sends the message, and sometimes it wont, I have added a searchbar to the site and have styled that input submit button differently, can that be the interfearence?
Here's the code.
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'From: info@epicconcepts.nl';
$to = 'info@epicconcepts.nl';
$subject = 'Contact formulier bericht';
$human = $_POST['human'];

$headers = "From: info@epicconcepts.nl\r\n";
$headers .= "Reply-To: ". strip_tags($_POST['email']) . "\r\n";
$headers .= "CC: quincynorbert@gmail.com\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

$body = '<!DOCTYPE html>

'.$name.'
'.$email.'

'.nl2br($message).'

';
if ($_POST['submit']) {
if ($name != '' && $email != '') {
if ($human == '4') {
if (mail ($to, $subject, $body, $headers)) {
echo '
Uw bericht is succesvol verzonden!
';
} else {
echo '
Er is iets verkeerd gegaan, probeer het nog eens!
';
}
} else if ($_POST['submit'] && $human != '4') {
echo '
U heeft de veiligheidsvraag verkeerd beantwoord!
';
}
} else {
echo '
U heeft niet alle verplichte velden ingevuld!
';
}
}
?>

        <form method="post" action="contact.php">

            Naam
            <input name="name" placeholder="Type hier">

            Email
            <input name="email" type="email" placeholder="Type hier">

            Bericht
            <textarea name="message" placeholder="Type hier"></textarea>

            Hoeveel is 2+2?
            <input name="human" placeholder="Type hier">

            <input id="submit" name="submit" type="submit" value="Verzend">

        </form>

A: Give this a try. I commented out a few lines. After testing it with my own email, I sent out 10 test emails with the code below and received them all.
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
// $from = 'From: info@epicconcepts.nl'; // COMMENTED OUT - conflicting
$to = 'info@epicconcepts.nl';
$subject = 'Contact formulier bericht';
$human = $_POST['human'];

$headers = "From: info@epicconcepts.nl\r\n";
$headers .= "Reply-To: ". strip_tags($_POST['email']) . "\r\n";
// $headers .= "CC: quincynorbert@gmail.com\r\n"; // Commented out for testing. May be a problem
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

$body = '<!DOCTYPE html>

'.$name.'
'.$email.'

'.nl2br($message).'

';

if ($_POST['submit']) {
if ($name != '' && $email != '') {
if ($human == '4') {
if (mail ($to, $subject, $body, $headers)) {
echo '
Uw bericht is succesvol verzonden!
';
} else {
echo '
Er is iets verkeerd gegaan, probeer het nog eens!
';
}
} else if ($_POST['submit'] && $human != '4') {
echo '
U heeft de veiligheidsvraag verkeerd beantwoord!
';
}
} else {
echo '
U heeft niet alle verplichte velden ingevuld!
';
}
}
?>


text:
Q: Different Effects of Detection Probability Between Presence and Count Data at the Same Location I'm modeling habitat suitability for a large, mobile animal using occurrence data (presence only---I have no true absence data in this case) collected from camera traps (stations with automatic motion/heat sensing cameras). At each camera trap location I have 0 to several occurrences recorded.
Typically, when such data is modeled, they are modeled as count data, and detection probability is included in order to mitigate for covariates that affect detection, which otherwise may be identified as covariates that affect suitability. For example, an area where detection is less likely due to, say, dense vegetation, may be mistaken as less suitable due to that vegetation structure when in fact that may not be the case (or even the opposite may be true).
My question is, if the count variable were to instead be used as a detection/no-detection variable (so, a binary) would the probability of detection have less of an effect on the model (when modeling relative suitability, not probability of occurrence)? It doesn't seem like probability of detection would change, or would be more homogeneous across the study area with this change, but it seems like the effects would would be smaller in magnitude by not reinforcing differences in detection probability with multiple occurrences.
Also, I understand that it's not desirable to toss out all the other occurrences assuming you can calculate detection probability. I'm asking this in an attempt to better understand the possible differences in outcome between these two modeling approaches when using such data, as I've seen both methods in the literature, but have not seen this question specifically addressed. If you could reference any publications that may shed light on this, I'd be very appreciative.


text:
Q: Confused by CSS selector So.. I have this code:

As you can see the first div have a class named "current" and that's the div that i want to select. The divs are positioned on top of eachother with position: absolute;
My CSS:
#slider div {
    position:absolute;
    z-index: 0;
}
#slider div.previous {
    z-index: 1;
}
#slider div.current {
    z-index: 2;
}

I'm trying to give the first div, the one with class "current" a z-index of "2".
The selector i use for doing this is:
.current {
   z-index: 2;
}

But that doesnt seem to work, that way the image wont appear on the top.
But if i instead write the selector this way:
#slider div.current {
   z-index: 2;
}

Now it works.
And im a bit confused by this, doesnt those two selectors basically work the same way? What's the difference between them in this case?
Made a jsfiddle out of this https://jsfiddle.net/x1L4tfw4/5/ If you remove the "#slider div" part from the css selector you will see the difference.

A: You haven't stated that you have the #slider div selector in your CSS as-well.
This overrides the .current selector because its more specific.

A: This is a specificity issue. #slider div has a specificity of 101. #.current has a specificity of of 10.
#slider div.current comes in at 111.
The selector with the highest specificity is the one used. Now, how did I get those numbers?
The CSS standard says that you add numbers with an infinitely large base together to get it. In practice, you can think of it as being digits.
Tag names are worth one point.
Class names or attribute values are worth ten* points.
ID names are worth 100 points.
(and !important things are worth 1000 by the way).
So you add them up and see which has the highest number. That's the rule that gets applied. If two rules come with the same specificity, the one that appears last in the source code is the one that is used.

*

*I said ten here for simplicity, but remember that the spec said infinitely large base (though browsers actually use base 256, fun fact). So ten classes do NOT equal one ID: a single ID is more specific than any number of classes (in theory).

A: This is due to the CSS specificity in the selectors that you're providing (or perhaps a third party library is providing). Here is a good resource to understand how CSS specificity and inheritance works.
Summary
Here is the key part from the linked article relating to how the different CSS selectors are related:

*

*Element, Pseudo Element: d = 1 – (0,0,0,1)

*Class, Pseudo class, Attribute: c = 1 – (0,0,1,0)

*Id: b = 1 – (0,1,0,0)

*Inline Style: a = 1 – (1,0,0,0)

I've included their examples below to help understand how this works:

*

*p: 1 element – (0,0,0,1)

*div: 1 element – (0,0,0,1)

*#sidebar: 1 id – (0,1,0,0)

*div#sidebar: 1 element, 1 id – (0,1,0,1)

*div#sidebar p: 2 elements, 1 id – (0,1,0,2)

*div#sidebar p.bio: 2 elements, 1 class, 1 id – (0,1,1,2)

Your Scenario
Now for your particular case. The first selector you use is .current which according to the information above has a specificity of:
.current (0,0,1,0)

As @Admir Geri noted in his answer, you also have a selector #slider div which has a specificity of:
#slider div (0,1,0,1)

Since the specificity of your second selector outweights that of the first, the second takes precedence and therefore you don't see your changes.
Your last selector #slider div.current has the following CSS specificity:
#slider div.current (0,1,1,1)

Since this score outweights that of any other selector. Your changes will be displayed when using this selector which is why you see them on the screen.

A: The way you did the CSS is quite confusing . I Think you know that , these CSS do respect a straight forward system for ID and Class . Javascript Does care about ID . And Browser has their specific advantages for ID's . But CSS doesn't care about ID and class. Not until you pull this type of confusion .
Never use #id element .class in your stylesheet if you have more than one same <element-tag> in your markup. This will ruin the style .


text:
Q: Download image when clicking on the image in react I have a simple app that fetches images from Unsplash API. I would like users to click on the image, and download it and also maybe for the image to open in a new tab too.
The urls.regular is just a simple url like https://images.unsplash.com/photo-1543332164-6e82f355badc?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=1080&fit=max&ixid=eyJhcHBfaWQiOjE3OTUzOH0
After reading other issues on stackoverflow, I added "download" at the end of my a tag.

I have also tried the following in my a tag:
                    href={urls.regular}
                    target="_blank"
                    rel="noopener noreferrer"
                    download={urls.regular}

A: You should define onclick event for the a tag.

function onClick(url) {
    window.open(url, '_blank');
}


text:
Q: Select data from xml using mysql ExtractValue() I want to extract location id from give xml, and also want to put condition that extract it if location does exists.
<?xml version="1.0" encoding="UTF-8"?>
<id>1006221342207</id>
<name>Hitesh Modha</name>
<email>hitesh.99@hotmail.com</email>
<location>
    <id>115440481803904</id>
    <name>Ahmedabad, India</name>
</location>

I have tried :
SET location = ExtractValue(xml, '//locations//id');
SELECT ExtractValue(location, '//id');

but it is not working.
Please help

A: The SQL
SELECT
  ExtractValue('<?xml version="1.0" encoding="UTF-8"?>
<id>1006221342207</id>
<name>Hitesh Modha</name>
<email>hitesh.99@hotmail.com</email>
<location>
    <id>115440481803904</id>
    <name>Ahmedabad, India</name>
</location>', '//location//id');

returns only an empty result, because the path //locations//id is empty for the XML fragment you use.
You're more likely looking for '/location/id' for the xpath expression, as it will return the id text() value: 115440481803904
Next mistake you do is that you think ExtractValue would return an XML fragment you can re-run ExtractValue on. That's just not the case (only if - which is not the case in your example - there would have been XML encoded as CDATA in the located text() node).
All the details are explained in detail here:

*

*http://dev.mysql.com/doc/refman/5.1/en/xml-functions.html#function_extractvalue
If you can not work around these misconceptions, there is no further suggestion I can give you.


text:
Q: Stitcher class OpenCV I have two Images with a Overlapping area of about 25% - but the Stitching fails.
How can I handle this problem?
I tried using orb and surf, as well as I changing the Threshold. Are there any other options I should consider?
Mat pano;
Stitcher stitcher = Stitcher::createDefault(try_use_gpu=false);
//Stitcher::Status status = stitcher.stitch(imgs, pano);

//stitcher.setWarper(new PlaneWarper());
stitcher.setWarper(new SphericalWarper());
stitcher.setFeaturesFinder(new detail::SurfFeaturesFinder(1000,3,4,3,4));
//stitcher.setFeaturesFinder(new detail::OrbFeaturesFinder());
stitcher.setRegistrationResol(0.1);
stitcher.setSeamEstimationResol(0.1);
stitcher.setCompositingResol(0.6);
stitcher.setPanoConfidenceThresh(1);
stitcher.setWaveCorrection(true);
stitcher.setWaveCorrectKind(detail::WAVE_CORRECT_HORIZ);
stitcher.setFeaturesMatcher(new detail::BestOf2NearestMatcher(false,0.3));
stitcher.setBundleAdjuster(new detail::BundleAdjusterRay());
tstart = clock();
Stitcher::Status status = stitcher.stitch(imgs, pano);

A: 25% overlapping are definitely not enough. 40% will give somewhat better results but still not good enough. If you want good overlapping, try with something between 60% and 80%. It is important that the next image in your sequence that you want to stitch together overlaps the central area of the previous one since there is/shouldn't be any distortion. With 80% overlapping for example not only that happens but also the central areas of both images come pretty close together so you can neglect distortions and find plenty of matches provided that the texture quality of your images allows it. My advice is to first look at the samples provided by the library itself. You can find the latest version at https://github.com/Itseez/opencv/tree/master/samples/cpp/stitcher.cpp and https://github.com/Itseez/opencv/blob/master/samples/cpp/stitching_detailed.cpp. Then it is also good to dig inside the source itself (https://github.com/Itseez/opencv/blob/master/modules/stitching/src/stitcher.cpp) and also look up the provided documentation in the reference manual of OpenCV (online or download as a PDF).


text:
Q: std::search extracting current iterator and moving iterator forward using std::advance I have a function which utilizes std::search to look over a certain memory region provided from start to end and find a certain byte pattern. However, under certain conditions I would like to skip over a portion of this region rather than iterate over it from start to end byte by byte. For example move 50 bytes forward from current iterator position or something similar. Is there a way extract the current iterator object and move the iterator forward using std::advance?
const auto address = std::search( address_start, address_end, byte_pattern.cbegin(), byte_pattern.cend(),
    []( const uint8_t &current_byte, const memory::byte_t &pattern_byte ) {
        // address of current byte in memory
        // this is also the current position of the search itterator
        const auto data = &current_byte;

        if( CERTAIN CONDITION ) {
            MOVE ITTERATOR FORWARD SO THAT WE MOVE FORWARD IN MEMORY WE ARE SCANNING BETWEEN [address_start, address_end]

        }

        return pattern_byte.compare( current_byte );
    }
);

A: There is no way to access the iterators used internally by standard library algorithms. If you need more control over iterations then you have to use iterators manually.
cppreference.com shows you possible implementations for standard library algorithms. Just copy/paste them into your code and tweak as needed. For instance, for std::search(), it shows this implementation:
template<class ForwardIt1, class ForwardIt2, class BinaryPredicate>
constexpr ForwardIt1 search(ForwardIt1 first, ForwardIt1 last,
          ForwardIt2 s_first, ForwardIt2 s_last,
          BinaryPredicate p)
{
    for (; ; ++first) {
        ForwardIt1 it = first;
        for (ForwardIt2 s_it = s_first; ; ++it, ++s_it) {
            if (s_it == s_last) {
                return first;
            }
            if (it == last) {
                return last;
            }
            if (!p(*it, *s_it)) {
                break;
            }
        }
    }
}

Change ++s_it as needed.


text:
Q: What is the best way to build a validator function? PHP I have many forms and was wondering wouldn't it be better to build a function that validates user entries?
So for example we would forward the data into the function and it would return whatever and display a message with an error but i have no idea how to go about this since i am new to PHP. I don't even know if this is the best way to go about my problem.
Any tutorials or tips for validating lots of forms? Best practices?
BTW i have to avoid using external libraries. So creating simple code is the way forward.

A: Your modular approach is good. But I think having a common function for multiple page validation might lead to unnecessary execution of multiple instructions failing the actual purpose of using it. So you would basically be trading off on performance for code optimisation.
In case your pages are more or less similar in terms of the data accepted, you can always invoke the same function and pass it a parameter which indicates the page from which it has been invoked and based on that you can parse and hence validate the data received.


text:
Q: Covert html date value to RFC 2822 I have following code,
$date = $_POST["s-date"]; // get from  form. value pass correctly.
 $time =  "".$hour.":".$minute.":".$second.""; // ok
   echo RFC2822($date,$time);

function RFC2822($date,$time = '00:00') {
   $array =  list($d, $m, $y) = explode('-', $date);
    list($h, $i, $s) = explode(':', $time);

    return date('r', mktime($h,$i,0,$m,$d,$y));
}

When I execute this script, time fragment is printed correctly, But date is displayed as Jul 08 2025 always even passing different date to the function. How to fix this.

A: You must need to check the value of this input $_POST["s-date"] it must be follow this format of date:
`DD-MM-YY`

because, you are creating list in this format (DD-MM-YY):
$array =  list($d, $m, $y) = explode('-', $date);

UPDATE 1:
As you mentioned, you are using HTML date and HTML date format is
'YYYY-MM-DD', now just change the list variable order as per date format.

A: From what I can gather your problem lies not with the code you've shared, but somewhere else. If I copy-paste your script and put in a fixed date on $date, it works as expected. (I've removed $time for missing vars)
$date = "27-02-2014";
echo RFC2822($date);

function RFC2822($date,$time = '00:00:00') {
   $array =  list($d, $m, $y) = explode('-', $date);
    list($h, $i, $s) = explode(':', $time);

    return date('r', mktime($h,$i,0,$m,$d,$y));
}

Outputs
Thu, 27 Feb 2014 12:00:00 +0100

From this I expect that your $_POST['s-date'] var somehow gets a fixed 08-07-2025 or some other input that will make it 08 Jul 2025.


text:
Q: Duplicate database entries with passenger_min_instances when I have timer in the application I'm running a meteor application with Phusion Passenger & Nginx. To have better response to end users. I have set up passenger_min_instances to 3. In the application, there is a timer to process some data and store in the MongoDB. I found that when there are some users visiting user site, it will write multiple entries to MongoDB. Is there any way to avoid this? Or is this not cause for generating multiple entires? The timer is setup in the server startup block so it keeps running forever.

A: I end up adding unique indexes to the collections to avoid this but I do think this is kinda strange behavior.


text:
Q: Which is the fastest way to return the number of different rows in a matrix A? If i have the following matrix A:
A = {1,2,3}
    {7,9,1}
    {5,3,2}

how i can easily return the number of different rows in the Matrix? In this case the output must be : "3"
i tried to make a function "rows":
void rows (int a[N][N], int row[N], int x){

    for (int i=0;i<N;i++){

        row[i]=a[x][i];

    }

}

then, with the function "check" i tried to check if the rows are different:
int check ( int a[N][N])
{

    int row1[N];
    int row2[N];

    int j=0;

    rows(a,row1,j);
    rows(a,row2,j+1);

    int count = 0;

    for ( int i=0; i<N; i++){
        for ( int j=0; j<N; j++){

            if ( row1[i] != row2[j]){

                count++;

            }

        }
    }

    return count;

}

but return the wrong number , any suggestions ?

A: Your algorithm is entirely wrong. With an added break it "works" when all rows are different, but it breaks when some of the rows are the same. It counts the number of rows such that there exists another row that's different from it. For example, if you run it on
1 2 3
4 5 6
1 2 3

you will get an answer 3, but you should get a 2.
The algorithm should go like this:

*

*Assume that all rows are distinct (result = N)

*For each row i, look at the rows below it

*If any of the rows j below the row i is equal to row[i], decrement the result and break out of the inner loop

*At the end of the outer loop, result contains your answer.

A: try to add inequality variable into:
int count = 0;

for ( int i=0; i<N; i++){
inequalty=0;
    for ( int j=0; j<N; j++){

        if ( row1[i] != row2[j]){

            inequality=1;
            break; //this makes even faster

        }

    }
 if(inequality!=0)count++;
}

even a single element's inequality makes the row inequal right?

A: Implement a 'CompareRows' functor as a predicate for set.  Then, all you need to do is --
typedef vector<int> Rows;
set<Rows, CompareRows> UniqRows;

for ( int i = 0 ; i < N ; ++i )
  UniqRows.insert(Rows(a[i], a[i] + N));

UniqRows.size();


text:
Q: MySQL Lock Database on Slave I am doing data replication. I have one master server and one slave server and my data is successfully replicated from master to slave. Now i want to lock my slave server database for writing.
I used LOCKED TABLE mytable READ and it successfully locked my table on slave for instance "myIns1". But when i open MySQL using other instance and i try to write on same database so it writes easily and sometimes also hangs. I want my slave server database to be locked completely for all MYSQL instances and users.
Please help.

A: You can use the read-only option in the slave. This prevents users with no SUPER privilege from updating the database. Take a look here for more:

Cause the slave to permit no updates except from slave threads or from users having the SUPER privilege. On a slave server, this can be useful to ensure that the slave accepts updates only from its master server and not from clients. This variable does not apply to TEMPORARY tables.

A: Which version you have using it ? And MySQL Replication has option to replicate only particular databases , configure it .
Other option remove access for not required database , but it will show error when not required database having any changes in master . It will write binlog and send to slave server .


text:
Q: MSIE Speech Recognition ActiveX I'm writing some code on MSIE+SAPI technology, and I wanted to experiment with speech recognition.
I've been able to use text to speech as follows:
var KC_TTS = new ActiveXObject("Sapi.SpVoice");
// ...
KC_TTS.Speak("Hello, world!", 1);

So, by convention, there must be some speech recognition ActiveX that can be loaded and used similarly. However, I can't seem to be able to find the name of this ActiveX, and as such, I can't find any associated documentation as well.
My questions
What is the name of the MS ActiveX that allows speech recognition?
Where can I find some documentation on its use?

A:
What is the name of the MS ActiveX that allows speech recognition?

You can use SAPI.SpInprocRecognizer  or SAPI.SpSharedRecognizer

Where can I find some documentation on its use?

http://msdn.microsoft.com/en-us/library/ms722071(v=VS.85).aspx
See example here
http://julius.sourceforge.jp/sapi/Samples/JavaScript/dictcommand.html


text:
Q: Paypal Error PayPal gateway has rejected request. %1 in Magento2.2.8 I just setup paypal checkout system but after paypal payment window it redirects me to store page to place an order to store the order in backend orders panel.
but when i press the button to place an order system gives me the following error
PayPal gateway has rejected request. %1


text:
Q: How to call a package in QGIS python console? I'm learning python and I'm also learning GIS (QGIS to be exact).   What I'm trying to do is use the python console in QGIS to practice and get comfortable with python.
Tutorials that I have found are pretty straightforward.  Moving forward, I'm looking at creating a package and calling that package in the QGIS python console.  Specifically, I have created the following on:
E:\OneDrive\Documents\PythonQGis\PythonScripts
File: crsLayers.py
# just a simple function to test accessibility.
def getDefaultProjectCrs():
    return iface.mapCanvas().mapRenderer().destinationCrs().authid()

I have also incuded __init__.py file in the PythonScripts folder.
it has a single line:
__all__ = ["crsLayers"]

In my QGIS python console I issue the following commands:
import sys
sys.path.append("E:\OneDrive\Documents\PythonQGis\PythonScripts")

I have tried the following:
import PythonScripts
import PythonScripts.crsLayers
crsLayers.getDefaultProjectCrs()

They all return error messages:

Traceback (most recent call last):   File "", line 1, in
     File
  "C:/PROGRA~1/QGISWI~1/apps/qgis-ltr/./python\qgis\utils.py", line 478,
  in _import
      mod = _builtin_import(name, globals, locals, fromlist, level) ImportError: No module named PythonScripts.crsLayers

or

Traceback (most recent call last):   File "", line 1, in
   NameError: name 'crsLayers' is not defined

What am I missing?


text:
Q: Movie with "White box dimensions" where woman is shot at the end My dad was watching a movie on TV roughly 15 years ago (maybe a little less), where people were dying in what looked like "White box dimensions". I say this because that's what it looked like, from what I remember it looked like a group of people were trapped in an all-white space where they were dying one by one. I think there was an old man who got ripped apart by some mirror-like transparent prisms.
Sorry for the rough details, I was a bit young when I saw it. The one solid detail I remember is that at the end the last surviving woman appeared to wake up in some shallow water. After she woke up she was met by some government agency looking type men, one of whom shot her in the head.

A: This is Cube2: Hypercube from 2002.
The ending matches your description. A woman escapes a futuristic dungeon and is executed by MiBs.

and in this clip, you see a guy being ripped to shreds by prisms.


text:
Q: How not to lose parallel testing with tfs build and keep build agents work I'm setting up a TFS testing build and want to support full parallel testing.
Only some of our tests run in parallel and therefore after they finished running on the build agent - the build agent do not getting new tests to test.
Therefore, a build that took us 30 minutes start to take an hour and more because all the renaming tests running on only one build agent.
All the other 20 build agents stop to run after several minutes because they finished running their bulk of tests.
We run our parallel tests with MSTest2.
Our RunSettings.runSettings declare to run as parallel and are correct.
We tried different Advanced Execution Options on the build. We tried based on past running time of tests. based on number of tests and agents and based on test assemblies.
None of them work - after the agent finished his bulk of tests he just go back to idle.
We tried giving the machine in the build to get only one test each bulk and it was indeed faster but we lost the privilege of parallel testing on each machine.
We want our build to run on this way:
We start it, and the tests start to run. All the machines will get count of tests to run. When the build agent finish to run all the tests he was given,
it will get tests from a machine that didn't finish to run his tests. This way we'll enjoy parallel testing build and parallel tests on a machine.
We don't want to get to the  point where our build has 2 steps - 1 step that run the tests parallel and another one that run our tests which are not parallel.
Does it possible to create a build that answer all of the above?
We started to lose our heads because of this and we didn't find examples to builds that will do as we want.
Or how at least change the settings to prevent from build agent to stop getting new tests after he finished his bulk.
Best regards and I hope that I made myself clear enough.

A: No this is not possible. The tests are distributed at the start of the test run. What you can do is the following:

*

*Make sure all your slow tests are marked using a [TestCategory("slow")] attribute.

*Create one Run Tests task in Azure Pipelines and use the filter to run all tests except slow tests. This will distribute the remaining tests across all agents.

*Create one Run Tests task in Azure Pipelines and use the filter to only run the slow tests. This will distribute all slow tests to all agents

You end up with two test runs, but your tests will be more equally distributed.
As an added advantage your slow tests can optionally be skipped if one of your fast tests already fail.
Basically what I blogged here:

*

*Modern builds: https://jessehouwing.net/staged-execution-of-tests-in-azure-devops-pipelines/

*XAML builds: https://jessehouwing.net/xaml-build-staged-execution-of-unit-tests/


text:
Q: AdMob AdView only appearing in landscape orientation Ok, I'm officially at my wit's end here.  Working on an Android app that uses AdMob.  Everything is set up to the letter following their instructions, no errors, etc.
Problem is:  I only see ads when the phone is in landscape orientation.
I've searched online and done every last thing I can think of to test this:

*

*Tried it in test mode and normal mode

*Removed the orientation configChanges from my main activity's manifest and their handlers in the code, in case they were causing it

*Removed all functionality of the app so that onCreate looked like the one in the instructions above

*Tried every possible change of main layout - placing it in different locations, removing other widgets, different layouts, etc

These are just a summary of a few hours of testing, every time the result is the same.  Portrait shows no ad, landscape shows the ad (as/where expected - not stretched, but the max width issue is well known and not a problem).
Logcat shows everything to be working properly in both orientations:  Requests are made, ads are returned.  I can click on the ads that appear in landscape, but tapping the area they're meant to be in portrait does nothing.
It's driving me mental!  Any ideas?
Edit:  Okay, the problem is gone but I'm afraid I can't really call it a "fix".  I remembered ads working fine in a previous but similar app.  It was using a different version of the AdMob SDK - I don't know any details, but admob-sdk-android.jar is 77kb rather than 136kb.
I copied the 77kb one from the old app into the new app, along with the attrs.xml file, which necessitated changing the primaryTextColor attribute in the AdView to textColor, and that's it.  Works perfectly now - and as a bonus, the ads stretch horizontally across the whole screen in landscape view as well!
I'm posting this as an edit rather than an answer since it seems more appropriate and I'd still love to know if anyone can shed some light on the issue.  Was it an AdMob SDK issue?

A: I also encountered this issue, you should check if the parent container is padded, if it is, remove padding and all of sudden ads will appear. I don't find it very logical but it helps.

A: Not sure if this will help, but i had a similar issue, where in a landscape game, the ads would appear in portrait mode only. On a tab 2 i borrowed for testing from someone. Turned out there was some sort of screen lock on the device which caused it. Spent hours trying to chase the bug down.

A: Check this layout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    tools:context=".AddTest"
    tools:ignore="MergeRootFrame" >

    <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        ads:adSize="BANNER"
        ads:adUnitId="@string/banner_ad_unit_id"
        >
    </com.google.android.gms.ads.AdView>

</RelativeLayout>

I have same problem in tools:ignore = "aaaaaaaaa" and padding


text:
Q: How to create ECR Repo before ECS with Terraform Current Issue:
I am working with Terraform, and I am deploying AWS ECS with Fargate. I have all the applicable .tf files to do all of this, and they work, but I am also automating the deployment. So, first I would need to apply the ecr.tf file to create the ECR repo, then push the docker image to the repo, and then I get the repository_url attribute from the ECR resource to build the infrastructure for the ECS and Fargate. The issue I am having is that I have a deployment folder with all the .tf files, and I only want to apply my network/ecs/fargate files after I have set up my ecr resource by applying my ecr.tf and provider.tf. None of the things I have tried below are working so if anyone has any help they could provide that would be great.
Files:
root main.tf
variable "aws_region" {
  description = "Which region should the resources be deployed into?"
}

provider "aws" {
  shared_credentials_files = ["~/.aws/credentials"]
  shared_config_files = ["~/.aws/config"]
}

module "ecr" {
  source = "./ecr"
}

module "ecs" {
  source = "./ecs"
  aws_region = var.aws_region
  repository_url = module.ecr.repository_url
}

ecr.tf
resource "aws_ecr_repository" "ecr_repo" {
  name = "ecr-automation"
}

output "repository_url" {
  value = aws_ecr_repository.ecr_repo.repository_url
}

provider.tf
variable "aws_region" {
  description = "Which region should the resources be deployed into?"
}

provider "aws" {
  shared_credentials_files = *****
  shared_config_files = ****
}

Solutions I have tried:

*

*Using terraform apply -target=file. This didn't throw errors but the ECR  repo was also not created.

*Create a main module with a main.tf file. Separate the ECR files and ECS files into their own separate modules, and include them in the main.tf file. Outputting the repository_url from the ecr.tf file, and accessing that from the main.tf file within the ecs module so that I can pass it to the files that need it. This is shown in my code example above, and is giving me the unsupported argument error. I assume I am doing it wrong, but I don't know how to fix it.

A: try to use depends_on = [module.ecr] inside ecs module:
module "ecs" {
  source = "./ecs"
  aws_region = var.aws_region
  repository_url = module.ecr.repository_url
  depends_on = [module.ecr]
}

Note: Module support for depends_on was added in Terraform version 0.13, and prior versions can only use it with resources.
https://developer.hashicorp.com/terraform/language/meta-arguments/depends_on


text:
Q: SQL Server 2005 Import and Export Wizard With reference to Import and Export Wizard, in SQL Server 2005 environment, I would like to receive some suggestions on how to select the best field separator: the table I need to export as flat file for example contains columns with commas inside them, so I can't use comma as field separator.
I have thought to search in all tables what is the ASCII character (0-255) NOT PRESENT, and use this character as separator, but this search operation is computationally heavy.

*

*What type of character could I use for exporting a table as flat file?

*Could I use a couple of characters, for example ,$    ?

*Is it preferable to use fixed length fields?

Any suggestion would be appreciated.
The best suggestion will be accepted.

A: Standard practice is to use a delimiter (usually comma ,) and a text qualifier (usually double quote ")
The output is then:
"Field A","Field B","Field With, A Comma"
Using a text qualifier means you do not need to worry about the delimiter appearing in your fields.
And I wouldn't bother using fixed widths, that could lead to truncation later on if you change the design of the table and forget to update all of your export scripts.
Use the csv extension (file.csv) so that other programs recognise the file type. CSV stands for Comma Seperated Values.

A: I suggest you use TABS , the "|" character,  or  ";"
these are commonly used
Cheers!


text:
Q: Angular2 Aux route with parameters I am building an Angular2 app, that has aux routing.
I was using this plunker http://plnkr.co/edit/jZv8jj?p=preview
to help me with the setup, but I need to pass parameters to my aux link.
How do I do that? (note: this example uses the old hash routing, I am using he new html5, but it doesn't work in either method).
@Component({
    selector: 'basic-routing',
    template: `Home
              Product Details
              <router-outlet></router-outlet>
              <router-outlet name="chat"></router-outlet>
              Chat`,
    directives: [ ROUTER_DIRECTIVES]
})
@RouteConfig([
    {path: '/',        component: HomeComponent, as: 'Home'},
    {path: '/product', component: ProductDetailComponent, as: 'ProductDetail'  },
    new AuxRoute({path: '/chat', component: ChatComponent, as: 'Chat'})
])

A: Ok, I figured it out... I am not sure this is the correct way to do it, but when I removed the paramenters from the aux path i.e.:
{aux:'/memory', name: 'Memory',   component: MemoryComponent}

instead of
{aux:'/memory/:id', name: 'Memory',   component: MemoryComponent}

it worked fine!


text:
Q: How does one transform a sum into a telescoping sum? Very possibly this has been asked before, but as I couldn't find it:
Let $(a_n)_{n\in\mathbb N}$ be a sequence, and
$$\sum_{n= 0}^\infty a_n $$
an infinite sum.
I'm looking for general methods of transforming this sum into a telescoping sum, i.e. finding a solution to the recurrence formula
$$a_n= r(n) - r(n-1) $$
This can be seen as an inhomogenous recurrence equation:
$$r(n)=  r(n-1)+a_n $$
One failed attempt would be this:
Using the methods of discrete math, we can show that the generating function of $r(n)$ has the closed form:
$$ \sum_{i=0}^\infty r(i)x^i = \frac{r(0) - \sum_{n=d}^\infty a_n x^n}{1-x}$$
However, to make use of this, we would first need to find a closed form for
$$ \sum_{n=d}^\infty a_n x^n$$
However, if we find a closed form for that, we might as well find a closed form for
$$\sum_{n=0}^\infty a_n x^n$$
, substitute $x=1$ and be done with it.
TL, DR: In this form, my approach either is missing something, or plain pointless. What are other possible ways of going about solving this recurrence equation, or other general ways to transform sums into telescopic-sum-form?

A: In general, there is no suitable technique for all cases. Some series don't exactly have telescoping components that are easy to track. One example of types of series that may have a telescoping component are hypergeometric series, whre we wish to sum anything of the form
$$\sum_{k=0}^n\frac{(a_1)_k...(a_p)_k}{(b_1)_k...(b_q)_k}$$
where the notation $(a)_k$ denotes the ascending factorial function. Hypergeometric functions are any functions that can be written in such a fashion, along with the term $x^k/k!$ and the upper limit is taken as infinite. Finding the telescoping series for these requires the use of Gosper's Algorithm, or its modified version Zielberger's Algorithm. Here is an example of how to use Gosper's algorithm.
Suppose that we want a closed form for the sum
$$S_m=\sum_{k=0}^m(-1)^k\binom{n}{k}$$
where $m\leq n$. To evaluate
$$S_m=\sum_{k=0}^ma_k$$
we notice that $S_m-S_{m-1}=a_m$. This, the sum $S_m$ is a sort of antiderivative of the discrete sum. As such, $S_m$ is sometimes called the indefinite sum of $a_k$. Without going into detail, we wish to write the ratio of the terms such that
$$\frac{a_{k+1}}{a_k}=\frac{p_{k+1}}{p_k}\frac{q_k}{r_k}$$
for some polynomials $p_k,q_k$, and $r_k$. One condition that we must enforce (for complicated reasons) is that if $(k+\alpha)$ divides $q_k$ and $(k+\beta)$ divides $r_k$, then $\alpha-\beta-1$ cannot be a positive integer. This is always possible by multiplying appropriate terms to the polynomial $p_k$ until this is true. For our problem, we have
$$\frac{a_{k+1}}{a_k}=\frac{(-1)^{k+1}\binom{n}{k+1}}{(-1)^k\binom{n}{k}}=\frac{k-n}{k+1}$$
Here, $p_k=1$, $q_k=k-n$, and $r_k=k+1$, which satisfy our hypotheses. Gosper's Algorithm states that if a hypergeometric telescoping term exists, then it must take the form
$$S_{k-1}=\frac{r_{k-1}a_ks_k}{p_k}$$
for some polynomial $s_k$ (again, the reasoning is complicated). The polynomial $s_k$ is the solution to
$$p_k=q_ks_{k+1}-r_{k-1}s_k$$
Throwing in our equations, we have
$$1=(k-n)s_{k+1}-ks_k$$
If we assign $s_k=-1/n$, which is a polynomial in $k$ of degree $0$, then this satisfies the polynomial condition. Thus, we have
$$S_{k-1}=(-1)^{k+1}\frac{k\binom{n}{k}}{n}=(-1)^{k+1}\binom{n-1}{k-1},\;\;\;\;S_k-S_{k-1}=a_k$$
An important rule when dealing with hypergeometric terms is if a factorial ever becomes negative, we simply regard it as $0$. Our final answer is
$$\sum_{k=0}^m(-1)^k\binom{n}{k}=S_m-S_{-1}=(-1)^{m}\binom{n-1}{m}$$
Plenty of other hypergeometric sums and series can be established, such as $k!$, $1/(k^2-1)$, etc. More generally, however, we can't always use this, but we can find recursion relations between similar series. For example, Let's consider the sum
$$S=\sum_{k=0}^n\binom{n}{k}^2$$
Gosper's Algorithm will yield no polynomial $s_k$ that we need. Instead, we seek to use Gosper's Algorithm on the modified sum
$$S=b_0\sum_{k=0}^n\binom{n}{k}^2+b_1\sum_{k=0}^{n+1}\binom{n+1}{k}^2$$
for some coefficients $b_n$ to be specified later. Applying the term ratio gives
$$\frac{a_{k+1}}{a_k}=\frac{b_0\binom{n}{k+1}^2+b_1\binom{n+1}{k+1}^2}{b_0\binom{n}{k}^2+b_1\binom{n+1}{k}^2}=\frac{b_0(k-n)^2+b_1(n+1)^2}{b_0(k-n-1)^2+b_1(n+1)^2}\frac{(k-n-1)^2}{(k+1)^2}$$
We assign $p_k=b_0(k-n-1)^2+b_1(n+1)^2$, $q_k=(k-n-1)^2$, and $r_k=(k+1)^2$. The polynomial $s_k$ satisfies
$$b_0(k-n-1)^2+b_1(n+1)^2=(k-n-1)^2s_{k+1}-k^2s_k$$
Without going into detail, the quantity $s_k=2k-3(n+1)$ satisfies the equation with $b_0=-2(2n+1)$ and $b_1=n+1$. We now have
$$S_{k-1}=\frac{k^2(-2(2n+1)\binom{n}{k}^2+(n+1)\binom{n+1}{k}^2)(2k-3(n+1))}{-2(2n+1)(k-n-1)^2+(n+1)^3}$$
We then have partial sums of
$$-2(2n+1)\sum_{k=0}^m\binom{n}{k}^2+(n+1)\sum_{k=0}^m\binom{n+1}{k}^2=\frac{(m+1)^2(-2(2n+1)\binom{n}{m+1}^2+(n+1)\binom{n+1}{m+1}^2)(2(m+1)-3(n+1))}{-2(2n+1)(m-n)^2+(n+1)^3}$$
Letting $m$ be large enough such that the factorial terms vanish, we have that the indefinite sum vanishes, and
$$\sum_{k=0}^{n+1}\binom{n+1}{k}^2=\frac{2(2n+1)}{n+1}\sum_{k=0}^n\binom{n}{k}^2$$
This yields a recursion relation for the sum in question. For $n=0$, the sum is $1$. Using the recursion, we get the next sums are $2,6,20,$ etc. These are precisely the central binomial coefficiants, so we finally have
$$\sum_{k=0}^n\binom{n}{k}^2=\binom{2n}{n}$$.
This algorithm may be employed many times over on many different sums, where the sums may also be infinite.

A: You are looking for
$$
a(n) = r(n) - r(n - 1)
$$
or, what is more standardly adopted
$$
a(n) = s(n + 1) - s(n) = \Delta s(n)
$$
Then $s(n)$ is called the Antidelta or Indefinite Sum of $a(n)$, and same as for integrals
some functions have a closed form for the Antidelta, and some don't.
You can find more details in the indicated link.

A: You are essentially asking for a general method to sum any finite or infinite series
(or indefinite sum). Correct? There is no such method. For certain special families of series, there do exist methods. For instance, summing of polynomial sequences, that is, $\sum_n n^k$ using Bernoulli numbers. An important special case similar to telescoping series is using Wilf–Zeilberger pairs which requires a computer algorithm.


text:
Q: Samba share stopped working I have the following share on my Ubuntu machine:
#VERSION 2
path=/home/pitel/Videa
comment=
usershare_acl=S-1-1-0:R,S-1-22-1-1000:F
guest_ok=y
sharename=Videa

It used to worked, but when I tried to connect to it today from my Raspberry Pi, I get the following error:
sudo mount -v /mnt/smb

mount.cifs kernel mount options: ip=192.168.0.4,unc=\\192.168.0.4\Videa,user=,pass=********
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

The fstab line (on RPi):
//192.168.0.4/Videa /mnt/smb/ cifs guest,ro 0 0

Log from the server (Ubuntu:)
[2016/11/27 17:35:57.008909,  0] ../source3/param/loadparm.c:3247(process_usershare_file)
process_usershare_file: stat of /var/lib/samba/usershares/videa failed. Permission denied

File permissions on Ubuntu:
drwxr-xr-x 5 root  root       4,0K led  5  2016 /var/lib/samba
drwxrwx--T 2 root  sambashare 4,0K lis 27 17:33 /var/lib/samba/usershares
-rw-r--r-- 1 pitel pitel      110  lis 27 17:33 /var/lib/samba/usershares/videa

I did not knowingly changed anything. Might there be some recent broken upgrade?

A: What is the user configured as the Guest on the SMB Server?
If you don't know, likely it is the default of nobody, which has no permissions on the share.
Either use the guest account = parameter in the share settings to set the guest account to pitel (if that is how you want to go)...
Or set the permissions via chmod on the share to be more permissive (setting the Other bit to 7 for RW or 5 for RO).
More information is available at the samba.org docs.


text:
Q: Infinite loop onAppear in SwiftUI, but init() gives me another error I want to call "getTestCounts" before displaying "Text(testCounts.counts[index].number)".
However, if I use onAppear, I end up with an infinite loop.
I think that since we are creating unique IDs with UUID and spinning them around in ForEach, we end up with an infinite loop.
Infinite loop when using onAppear in SwiftUI
I tried to solve this problem using init() with reference to
"Cannot use instance member 'calendar' within property initializer; property initializers run before 'self' is available"
The following error occurs.
How can I solve this problem? Thanks for suggestions.
Here is the UI I want to create
I want to display the API response value under the date.
Here is the source code where the infinite loop occurs.
struct CalendarView: View {
    @Binding var year: String
    @Binding var month: String
    @Binding var day: String
    @EnvironmentObject var testCounts: TestCounts
    var body: some View {
        let calendar = Calendar(identifier: .gregorian)
        let selectedDate = calendar.date(from: DateComponents(year: Int(year), month: Int(month), day: Int(day)))
        let calendarDates = generateDates(selectedDate!)

        LazyVGrid(columns: Array(repeating: GridItem(.fixed(60.0), spacing: 0), count: 7), spacing: 0) {
            ForEach(calendarDates) { date in
                Button(action: {}, label: {
                    VStack(spacing: 0) {
                        if let date = date.date, let day = Calendar.current.day(for: date) {
                            Text("\(day)").fontWeight(.semibold).frame(width: 45, alignment: .leading).foregroundColor(Color("dayTextBrown"))
                            ForEach(0 ..< testCounts.counts.count, id: \.self) { index in
                                if testCounts.counts[index].date == DateTime.dateToStr(date) {
                                    Text(testCounts.counts[index].number)
                                    Text(testCounts.counts[index].hcount)
                                }
                            }
                        } else {
                            Text("").frame(width: 45, alignment: .leading)
                        }
                   }.frame(width: 60, height: 60).onAppear {
                       getTestCounts(date.date ?? Date(), "all")
                   }
               }).background(.white).border(Color("drabBrown"), width: 1)
            }
        }
    }

    func getTestCounts(_ date: Date, _ timeType: String) {
        let since = Calendar.current.startOfMonth(for: date)
        let stringSince = DateTime.dateToStr(since!)

        let until = Calendar.current.endOfMonth(for: date)
        let stringUntil = DateTime.dateToStr(until!)

        TestCountsApi(LoginInformation.shared.token, shopId: LoginInformation.shared.defaultShopId, since: stringSince, until: stringUntil, timeType: timeType).request { json, error, result in
            switch result {
            case .success, .successWithMessage:
                TestCounts.shared.setTestCounts(json!)
            case .apiError:
                errorMessage = json!.message!
            case .communicationError:
                errorMessage = error!.localizedDescription
            case .otherError:
                errorMessage = "otherError"
            }
        }
    }
}

struct CalendarDates: Identifiable {
    var id = UUID()
    var date: Date?
}

func generateDates(_ date: Date) -> [CalendarDates] {
    var days = [CalendarDates]()

    let startOfMonth = Calendar.current.startOfMonth(for: date)
    let daysInMonth = Calendar.current.daysInMonth(for: date)
    guard let daysInMonth = daysInMonth, let startOfMonth = startOfMonth else {
        return []
    }

    for day in 0 ..< daysInMonth {
        days.append(CalendarDates(date: Calendar.current.date(byAdding: .day, value: day, to: startOfMonth)))
        }
    }

    guard let firstDay = days.first, let lastDay = days.last,
          let firstDate = firstDay.date, let lastDate = lastDay.date,
          let firstDateWeekday = Calendar.current.weekday(for: firstDate),
          let lastDateWeekday = Calendar.current.weekday(for: lastDate)
    else { return [] }

    let firstWeekEmptyDays = firstDateWeekday - 1
    let lastWeekEmptyDays = 7 - lastDateWeekday

    for _ in 0 ..< firstWeekEmptyDays {
        days.insert(CalendarDates(date: nil), at: 0)
    }

    for _ in 0 ..< lastWeekEmptyDays {
        days.append(CalendarDates(date: nil))
    }
    return days
}

class TestCounts: ObservableObject {
    struct TestCount {
        var date: String
        var number: Int
        var hcount: Int
    }

    static let shared = TestCounts()
    @Published var counts: [TestCount] = []

    func setTestCounts(_ json: TestCountsJson) {
        counts = []

        if let countsJsons = json.counts {
            for countJson in countsJsons {
                counts.append(TestCount(
                    date: countJson.date ?? "",
                    number: countJson.number ?? 0,
                    hcount: countJson.hcount ?? 0
                ))
            }
        }
    }
}

Here is the source code that tries to use init().
struct CalendarView: View {
    @Binding var year: String
    @Binding var month: String
    @Binding var day: String
    @EnvironmentObject var testCounts: TestCounts

    let calendar = Calendar(identifier: .gregorian)
    let selectedDate = calendar.date(from: DateComponents(year: Int(year), month: Int(month), day: Int(day)))
    let calendarDates = generateDates(selectedDate!)

    var body: some View {
        LazyVGrid(columns: Array(repeating: GridItem(.fixed(60.0), spacing: 0), count: 7), spacing: 0) {
            ForEach(calendarDates) { date in
                Button(action: {}, label: {
                    VStack(spacing: 0) {
                        if let date = date.date, let day = Calendar.current.day(for: date) {
                            Text("\(day)").fontWeight(.semibold).frame(width: 45, alignment: .leading).foregroundColor(Color("dayTextBrown"))
                            ForEach(0 ..< testCounts.counts.count, id: \.self) { index in
                                if testCounts.counts[index].date == DateTime.dateToStr(date) {
                                    Text(testCounts.counts[index].number)
                                    Text(testCounts.counts[index].hcount)
                                }
                            }
                        } else {
                            Text("").frame(width: 45, alignment: .leading)
                        }
                    }.frame(width: 60, height: 60)
                }).background(.white).border(Color("drabBrown"), width: 1)
            }
        }
    }
}

class TestViewModel {
    var date: Date
    var timeType: String
    var errorMessage = ""

    init (date: Date, timeType: String) {
        self.date = date
        self.timeType = timeType
       getTestCounts(date, timeType)
    }
    func getTestCounts(_ date: Date, _ timeType: String) {
        let since = Calendar.current.startOfMonth(for: date)
        let stringSince = DateTime.dateToStr(since!)

        let until = Calendar.current.endOfMonth(for: date)
        let stringUntil = DateTime.dateToStr(until!)

        TestCountsApi(LoginInformation.shared.token, shopId: LoginInformation.shared.defaultShopId, since: stringSince, until: stringUntil, timeType: timeType).request { json, error, result in
            switch result {
            case .success, .successWithMessage:
                print("success")
                TestCounts.shared.setTestCounts(json!)
            case .apiError:
                self.errorMessage = json!.message!
                print("errorMessage")
            case .communicationError:
                self.errorMessage = error!.localizedDescription
                print("errorMessage")
            case .otherError:
                self.errorMessage = "otherError"
                print("errorMessage")
            }
        }
    }
}


text:
Q: How do I pull data from two end points into one table, based on the id of a record? I am using an API to get data.
The first end point pulls records of products and one product record looks like this:
Array
(
    [page_size] => 1
    [page_number] => 1
    [total_results] => 110
    [offers] => Array
        (
            [0] => Array
                (
                    [tsin_id] => 59239867
                    [offer_id] => 85865212
                    [sku] => 711841704001
                    [barcode] => 711841704001
                    [product_label_number] => 9900858652127
                    [selling_price] => 595
                    [rrp] => 995
                    [leadtime_days] => 5
                    [leadtime_stock] => Array
                        (
                            [0] => Array
                                (
                                    [merchant_warehouse] => Array
                                        (
                                            [warehouse_id] => 7477
                                            [name] =>
                                        )

                                    [quantity_available] => 44
                                )

                        )

                    [status] => Buyable
                    [title] => HouzeComfort Memory Foam Gel Contour Cooling Pillow and Cushion
                    [offer_url] => https://somesite.com/x/PLID56138113
                    [stock_at_warehouse] => Array
                        (
                            [0] => Array
                                (
                                    [warehouse] => Array
                                        (
                                            [warehouse_id] => 1
                                            [name] => CPT
                                        )

                                    [quantity_available] => 3
                                )

                            [1] => Array
                                (
                                    [warehouse] => Array
                                        (
                                            [warehouse_id] => 3
                                            [name] => JHB
                                        )

                                    [quantity_available] => 22
                                )

                        )

                    [stock_on_way] => Array
                        (
                            [0] => Array
                                (
                                    [warehouse] => Array
                                        (
                                            [warehouse_id] => 1
                                            [name] => CPT
                                        )

                                    [quantity_available] => 0
                                )

                            [1] => Array
                                (
                                    [warehouse] => Array
                                        (
                                            [warehouse_id] => 3
                                            [name] => JHB
                                        )

                                    [quantity_available] => 6
                                )

                        )

                    [total_stock_on_way] => 6
                    [stock_cover] => Array
                        (
                            [0] => Array
                                (
                                    [warehouse_id] => 1
                                    [stock_cover_days] => 5
                                )

                            [1] => Array
                                (
                                    [warehouse_id] => 3
                                    [stock_cover_days] => 38
                                )

                        )

                    [total_stock_cover] => 24
                    [sales_units] => Array
                        (
                            [0] => Array
                                (
                                    [warehouse_id] => 1
                                    [sales_units] => 16
                                )

                            [1] => Array
                                (
                                    [warehouse_id] => 3
                                    [sales_units] => 22
                                )

                        )

                    [stock_total] => 25
                    [date_created] => 2019-09-19 15:53:11
                    [storage_fee_eligible] =>
                    [discount] => 40%
                    [discount_shown] => 1
                    [replen_block_jhb] =>
                    [replen_block_cpt] =>
                )

        )

)

The second end point pulls sales for the above mentioned products. The one record of sales data looks like this:
Array
(
    [page_summary] => Array
        (
            [total] => 593
            [page_size] => 1
            [page_number] => 1
        )

    [sales] => Array
        (
            [0] => Array
                (
                    [order_item_id] => 181333015
                    [order_id] => 109708669
                    [order_date] => 05 Jul 2022 07:34:24
                    [sale_status] => Preparing for Customer
                    [offer_id] => 200392229
                    [tsin] => 90268994
                    [sku] => 632726275259
                    [product_title] => HouzeComfort Aluminum Chinese Stir Fry Wok and Pan with Flat Bottom
                    [url_mobi] => https://www.somesite.com/x/PLID90233576
                    [selling_price] => 595
                    [quantity] => 1
                    [dc] => CPT
                    [customer] => Johnny Meyer
                    [url] => https://www.somesite.com/x/PLID90233576
                )

        )

)

On the display products page I display the products in a table with various columns like this:
function showProducts($data, $pagesize = 100)
{
    $results = getData($data);

    //STATS FOR THE PAGE
    $current_page = $results['page_number'];
    $total = $results['total_results'];
    $product_count = getProductCount();
    $num_pages = $total / $pagesize;
    echo "

There are " . $total . " products in total.

";
    echo "
";
    for ($page = 0; $page < $num_pages; $page++) {
        if ($page == $current_page - 1) {
            echo "
";
            echo $page + 1;
            echo "
";
        } else {
            echo "
";
            echo $page + 1;
            echo "
";
        }
    }
    echo "

";
    //TABLE WITH ALL THE PRODUCTS
    $items = $results['offers'];
    $stocklevel = array('In Stock', 'Low Stock', 'No Stock');
    echo "
";
    echo "
Product	Stock Available	Sales Revenue
";
    echo "
";
    echo "
";
    echo "

    Title
    Price
    Status
    Level
    Total
    CPT
    JHB
    LT Stock
    Days
    Past Month
    Past Year
    Total

";
    foreach ($items as $key => $row) {
        foreach ($row['stock_at_warehouse'] as $val) {
            foreach ($val['warehouse'] as $value) {
                if ($value == 1) {
                    $cpt = $val['quantity_available'];
                }
            }
        };
        foreach ($row['stock_at_warehouse'] as $key => $val) {
            foreach ($val['warehouse'] as $key => $value) {
                if ($value == 3) {
                    $jhb = $val['quantity_available'];
                }
            }
        };
        foreach ($row['leadtime_stock'] as $key => $val) {
            $lts = $val['quantity_available'];
        };
        if ($row['stock_total'] > 0 && $row['stock_total'] < 10) {
            $level = $stocklevel[1];
        } else if ($row['stock_total'] > 10) {
            $level = $stocklevel[0];
        } else if ($row['stock_total'] == 0) {
            $level = $stocklevel[2];
        }
        echo
        "

        " . $row['title'] . "
        " . "R" . $row['selling_price'] . "
        " . $row['status'] . "
        " . $level . "
        " . $row['stock_total'] . "
        " . $cpt . "
        " . $jhb . "
        " . $lts . "
        " . $row['leadtime_days'] . "

";
    }
    echo "
";
    return $items;
};

function showStandard($page_num = 1)
{
    $request = "https://api.somesite.com/v2/offers?page_size=100&page_number=" . $page_num;
    showProducts($request);
}

There are three columns with headings:
    Past Month
    Past Year
    Total

I need to display the sales totals for every product in that table in those columns. The problem is the sales records are only given to you 100 at a time and there are multiple pages. So you first have to get all the records which I do here:
function getSales($page)
{
    $data = getData("https://api.somesite.com/v2/sales?page_size=100&page_number=" . intval($page));
    $items = $data['sales'];
    return $items;
}

$allrecords = array();
for ($i = 0; $i <= 8; $i++) {
    $record = getSales($i);
    $allrecords[] = $record;
}

I can then get the total sales according to whatever field I want. I would like to get the sales for each product based on its id and then populate the cell with the value. I presume writing a function to loop through the records and based on the id of the product get all the sales for that product for a given period and then use the result as the value that must go into the cell. Not sure how to write that function and could really use some help. I also do not want the function to go and fetch the data every time for every record as that would make the site slow so I would like suggestions on how to pull all the data and then work with only the pulled data.


text:
Q: Apache with Flask executes the whole Webapp.py file everytime a request is hit to the Webapi I already have an apache server that's configured and running successfully in the background.
However, there are some files that I am initliaizing outside my Flask function call but whenever a request is sent to it via Postman, it executes the whole Webapp.py file where my Flask functions are stored.
Is there any way in which I don't have to load the CSV file again and again when the service is called via Postman?
Sample Webapp.py file below
app=Flask(__name__)

file=pd.read_csv('Filename.csv')
file1=pd.read_csv('Filename1.csv')

@app.route('/Index')
def function(methods=['GET','POST']):
     if request.method=='POST':
        response=Function_call()

     return response

app.run(debug=True)


text:
Q: How to build responsive Accordion Tabs without duplicated tab content in TailwindCSS & Alpine.js? I'm trying to build an Accordion Tabs component in TailwindCSS & Alpine.js, similar to A11y Accordion Tabs.
In mobile viewports, the component should behave like an Accordion.
On desktop, it should behave like Tabs.
But how to avoid duplicating the same content in the page?  Ideally the content inside the tab/accordion should be only in the page once so that the HTML isn't bloated.
Here's a codepen and here is what I have so far:

        Tab A

      Tab A content

        Tab B

      Tab B content

        Tab C

      Tab C content

      Tab A content should not be duplicated here

      Tab B content should not be duplicated here

      Tab C content should not be duplicated here

A: The answer here is to duplicate the tab headings instead of the content:

        Tab A

        Tab B

        Tab C

      Tab A

    Tab A content

      Tab B

    Tab B content

      Tab C

    Tab C content


text:
Q: I am glad to have met you If I met a person yesterday, could I say, now, "I am glad to have met you" ?
Or is it better to say: It's been a pleasure to meet you?

A: If you met them yesterday, and you're talking with them today — and you actually want to express that you are glad to have met them, rather than just express a friendly and polite formality — you should say "I'm glad [that] we met [yesterday]". This is especially true if you want to say it when you are not parting from one another, and you wish to continue by explaining some reason why your meeting was timely or fortunate.

A: I think the better one is..
"It's been a pleasure to meet you"
'I am glad to have met you' is far too formal and one would only say it if the person in question has had a considerable impact on him/her or helped him/her in some way.

A: "I'm glad to have met you" sounds better. It's equivalent to saying "I'm glad to have known you."
I'd say "It's been a pleasure to meet you" just before saying goodbye to someone (e.g. at the end of a business meeeting).

A: Further application:
It's been a pleasure reading your comment, WS2 -
That does flow better than: It's been a pleasure to read your comment.

A: I checked it out on my book and luckily found this.
"Perfect form is required when the action The Infinitive expresses precedes the situation The Predicate conveys."

Source:张道真,2002(2007.3 reprint),张道真实用英语语法,外教版,on page:301
One example it provides on the same page

"He was pleased to have made your acquaintance."
So I think your first expression fit the context well.


text:
Q: How to Populate Multiple Form Fields from onClick of Multiple EJS Data Fields I apologize if this is answered elsewhere, please point me in that direction.
From a dynamically populated list, I've figured out how to click one item in the list and have that text go to my form input.
My ejs code...
 <% for(var i=0; i<BeerList.length; i++) {%>

      <a onclick="document.getElementById('beerName').value='<%= BeerList[i].beer.beer_name %>'" >
        <%= BeerList[i].beer.beer_name %>

 <% } %>

...will show a list of beer names...
Raspy Angel Bourbon Stout
MEOWSA!
Vă-da
Magnanimous IPA
B-Bomb (2019)
And when I click on a beer name, that one name will populate my form input field.
Form code...
<form>
<input type="text" id="beerName" />
</form>

This works fine, but I can't figure out how to add a separate piece of data to a separate form input.
For example, if I want to include the Brewery Name in addition to the Beer Name, I try something like this...
 <% for(var i=0; i<BeerList.length; i++) {%>

      <a onclick="document.getElementById('beerName').value='<%= BeerList[i].beer.beer_name %>'" >
        <%= BeerList[i].beer.beer_name %>
        <%= BeerList[i].brewery.brewery_name %>

 <% } %>

<form>
   <input type="text" id="beerName" />
   <input type="text" id="breweryName" />
</form>

This obviously won't work as my onClick isn't even able to look for id=breweryName. If I give the form the id like form id="beerANDbrewery", I don't know how to go about getting each item into the appropriate input field.
Thank you so much for any help you can provide!

A: You can make a function that handles both cases. The function should take as parameters the values you want.
<% for(var i=0; i<BeerList.length; i++) {%>

        <a onclick="addText('<%= BeerList[i].beer.beer_name %>', '<%= BeerList[i].brewery.brewery_name %>') " >
        <%= BeerList[i].beer.beer_name %>
        <%= BeerList[i].brewery.brewery_name %>

<% } %>

<form>
   <input type="text" id="beerName" />
   <input type="text" id="breweryName" />
</form>


text:
Q: How to migrate to code review Related: On migrating from SO: how to do this efficiently and appropriately.
I've just come accross a question which I believe is ideal for code review. However it's already got an accepted answer.
I can't flag that it should go on code review, and I'm not sure flagging is the best approach.
Should I ignore or flag the question?
In general (assuming no accepted answers) how should I mark questions as suitable for CR?
The question in question is How can I reduce the Cyclomatic Complexity of this?
EDIT 1
To me this is the definition of a proper code review question.

*

*Its a beginner who is asking about best practice.

*It contains functional code.

*There are several comments already which are off topic for SO about the use of instanceof and proper OO practices.

Code review could give better answers because more of the other information that is being freely offered is on topic there.
Infact the most upvoted answer pretty much is talking about practices. Not the accepted answer.

A: @Malachi almost said it all. I'll only add this:
From the CodeReview Help Center:

[For a question] to be on-topic the answer must be yes to all questions:

*

*Does my question contain code? (Please include the code in the question, not a link to it)

*Did I write that code?

*Is it actual code from a project rather than pseudo-code or example code?

*Do I want the code to be good code, (i.e. not code-golfing, obfuscation, or similar)

*To the best of my knowledge, does the code work?

*Do I want feedback about any or all facets of the code?

Code-review SO questions that pass the above test should be migrated. Ignoring them, not migrating them or closing them as off-topic is likely to just frustrate the OP and, when/if they find out about CR, encourages cross-posting.
Migrating good CR candidates, however, can have a highly positive impact on CR traffic (and voting!), as migrated questions still show up in SO's questions list. One of the latest SO questions migrated to CR actually made it to the top of that week's top hits in the CR weekly newsletter. Wasn't a really great question, not even an exciting code review (was a beginner question with trivial code), but it was nice to see votes pile up on a CR question (~125 votes generated with the top 3 answers), and I think a big part of that was all thanks to the visibility granted by migration.

A: when I want to flag a question for Code Review I just use the
other (needs ♦ moderator attention)

option on the flag option list and then say why I think it should be moved to Code Review.  sometimes the Moderator says no.
from what I understand, the reason why it isn't an option to migrate to Code Review is because it is still a Beta Site, so flagging it that way is the only way to get it migrated. (As far as I know)


text:
Q: Emphasizing a string in code example using showexpl I am writing documentation for a package using the showexpl package which in turn uses the listings package. When using listing I can highlight a portion of the code like this:
\documentclass{article}

\usepackage{xcolor}
\usepackage{listings}

\lstset{
  moredelim=[is][\color{red}]{<}{>}
}

\begin{document}

\begin{lstlisting}
  This is an <emphasized string>.
\end{lstlisting}

\end{document}

But passing the moredelim option to a LTXexample environment does not have the desired effect, the code remains black.
\documentclass{article}

\usepackage{xcolor}
\usepackage{showexpl}

\lstset{
  basicstyle=\ttfamily\small,
  moredelim=[is][\color{red}]{<}{>}
}

\begin{document}

\begin{LTXexample}
  This is an <emphasized string>.
\end{LTXexample}

\end{document}

Is there something I am missing about passing the moredelim option to the LTXexample environment correctly?

A: you'll get problems with frames when using a different color:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{xcolor}
\usepackage{showexpl}
    \lstset{
  basicstyle=\ttfamily\small,
  explpreset={moredelim=[is][\color{red}]{<}{>}}}

\begin{document}

\begingroup
\catcode`\<=\active \def<{}
\catcode`\>=\active \def>{}
\begin{LTXexample}
  This is an <emphasized string>.
\end{LTXexample}
\endgroup
\end{document}

A: When you use moredelim the delimiter are stripped already from the code when showexpl writes the code to a temporary file. (Check the tmp-file). So when the listing is printed the delimiters are simply not there. You can avoid it by using explpreset (don't use both  moredelim and explpreset this leads to confusion.)
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{xcolor}
\usepackage{listings}
\usepackage{showexpl}
\lstset{
% moredelim=[is][\color{red}]{:}{.}
 explpreset={moredelim={[is][\color{red}]{:}{.}}}
}

\begin{document}

\begin{lstlisting}
  This is an :emphasized string.
\end{lstlisting}

\begin{LTXexample}
  This is an :emphasized string.
\end{LTXexample}

\end{document}


text:
Q: apex chart donut items border raduis I am looking to make my donut chart items corners round please guide
what I want
what I have made
const Chart = dynamic(() => import('react-apexcharts'), { ssr: false });

 const series = [54, 45];
  const options: ApexCharts.ApexOptions = {
    chart: {
      width: 380,
      type: 'donut',
    },
    labels: ['Active Users', 'Inactive Users'],
    plotOptions: {
      pie: {
        expandOnClick:false,
        donut: {
          size:'85%',
          labels: {
            show: true,
            name: {
              show: true,
              fontSize: '12px',
              fontWeight: '400',
              color: '#6E7191'
            },
            value: {
              show: true,
              fontSize: '22px',
              fontWeight: '600',
              color: '#2E285C'
            },
            total: {
              show: true,
              color: '#BCC1C8',
              fontWeight: 600,
            }
          }
        }
      }
    },
    dataLabels: {
      enabled: false,
    },
    responsive: [{
      breakpoint: 480,
      options: {
        chart: {
          width: 200
        },
        legend: {
          show: false
        }
      }
    }],
    legend: {
      position: 'left',
      offsetY: 50,
    },
    colors: ['#645CAA', '#BFACE0'],
    title: {
      text: '264',
      align: 'left',
      floating: false,
      style: {
        fontSize: '36px',
        fontWeight: '500',
        color: '#2E285C'
      },
    }
  }

<Chart series={series} options={options} type="donut" />

That I have been tried but I cannot find any solution to change border radius of this chart. I have searched on google but could not find it That I am writing because stackoverflow saying its too much code write Details(alflsjdfakfjlkasdhkf jdfjkhdfkjd kdjfjkdhfkjhd jfsdjhfkdh kdfhsdkfj jdfksjhdfkj ksdjfkdjhf jkjkdhfkdsf jhdfkhsfjk jsdhjfkhdk jfhsdkjf jfksjdh fjdksjhf djfkh kjdsjkf jfhskdf )

A: Sorry that I couldn't find any official solutions for border-radius in Donut chart, however, you may try RadialBar or Circular Gauge chart as an alternative.
There, Apexchart provides you a lineCap option (in stroke), which allows 3 values butt, square & round. I also tried the lineCap: round for Donut chart but unfortunately, it didn't worked.
And, so, if you really need the border of the donut, you can create an issue in their GitHub.