There is some known deficiency through the Lebesgue Integral?

Question: The Integral in the Riemann sense has a lot of deficiencies, and the Lebesgue Integral can solve almost all of them.
I know that over limited intervals, Lebesgue Integral is a generalization of the Riemann Integral. But
$$\int_a^\infty\frac{\sin(x)}{x}dx$$
converges in Riemann sense, but it is not true in the Lebesgue sense. So, we could consider this like a deficiency.
But... There is some known deficiency through the Lebesgue Integral over limited intervals?
I read (in wikipedia) that in some cases, the Henstock–Kurzweil Integral is more general than the Lebesgue one. Is it a deficiency? What kind of cases are they talking about?
Comment: Other than issues of measurability (where in a certain sense there is nothing that can be done), it comes down to these oscillatory integrals (like $\int_1^\infty \frac{\sin(x)}{x} dx$ or $\int_{-1}^1 \frac{1}{x} \sin \left ( \frac{1}{x^3}  \right ) dx$), which converge "conditionally". Like conditionally convergent sums, there is some sense in which we shouldn't say they converge "as sums" at all, because we have the well-known result about rearrangements of conditionally convergent series. You might call this a deficiency anyway.
Comment: If somebody know a textbook where I can find examples and comparisons of the Lebesgue Integral with others integrals, please tell me.
Comment: I haven't read *A Modern Theory of Integration*, but it might be what you're looking for. (http://www.amazon.com/Modern-Integration-Graduate-Studies-Mathematics/dp/0821808451/)
Comment: The most obvious deficiency is that, assuming the axiom of choice, there are still bounded functions on finite intervals that the Lebesgue integral cannot integrate (ie non measurable functions).
Comment: This [comparison at PlanetMath](http://planetmath.org/comparisonbetweenlebesgueandriemannintegration) may be helpful.  See especially the discussion following the article.
Comment: @EricStucky I will take a look in the book soon. Thanks for the hint.
Comment: @NateEldredge Can you please give me an example? The simplest that you know.
Comment: @hardmath Looks like a part of what I was searching for. It will certainly help me.
Comment: @Ian I never notice that really maybe there are cases like this. Integrals over limited intervals that converges conditionally. This is the what implies the first non-convergence of the first integral in Lebesgue sense. In the second, (i mean $\int_1^{-1}\frac{1}{x}\sin(\frac{1}{x^3})dx$), how can I prove?
Comment: The standard example of a non-measurable function is the [indicator function](https://en.wikipedia.org/wiki/Indicator_function) of a [Vitali set](https://en.wikipedia.org/wiki/Vitali_set).
Comment: @NateEldredge Helpful. Thanks.
Comment: @FernandoJunior An easy way to cook up an example: $\int_1^\infty \frac{\sin(x)}{x} dx=\int_0^1 \frac{\sin(1/u)}{u} du$ (per the substitution $u=1/x$).
Comment: @Ian I know how to prove that $\int_1^\infty\frac{\sin(x)}{x}dx$ converge conditionally. But, how can I prove that $\left|\frac{1}{x}\sin\left(\frac{1}{x^3}\right)dx\right|$ is not integrable in Lebesgue sense.
Comment: @FernandoJunior: Simply find a lower bound for the Lebesgue integral. Use intervals that correspond to amplitude of at least say $\frac{1}{2}$ on the $\sin$ curve. You will find that the total measure of rectangles under those parts of your function is infinite.
Comment: @FernandoJunior Another approach is to show that if $\int_0^1 \frac{\sin(1/u)}{u} du$ converged absolutely, then $\int_1^\infty \frac{\sin(x)}{x} dx$ would have to converge absolutely, but it doesn't.
Answer: Let $L$ the set of all Lebesgue-integrable functions. There are some deficiencies with the class $L$:
(1) There exists improper Riemann integrable functions that aren't inside $L$. For example, the important Dirichlet integral $\int_0^{\infty}\frac{\sin(x)}{x}dx$;
(2) The FTC (Fundamental Theorem of Calculus) version for class $L$ is not too efficient. For example, if $F'(x)=f(x)$ for all $x\in[a,b]$, so to write $$F(b)-F(a)=\int_a^bf(x)dx$$ we have to assume that $f$ is limited or that $F$ is absolutely continuous. The Henstock-Kurzweil integral solve this problem definitively;
(3) $L$ is not closed under product of funcitons. For example, let $f(x) = 1/\sqrt{2}$ if $x\in(0,1]$ and $f(0)=0$. So $f\cdot f\notin L$. BUT, if one of the functions is limited, then the product belongs to $L$. However, this deficiency belongs to Lebesgue, Henstock and (I think) any generalization of the Riemann integral that do not require limitation for integration;
(4) This is not a deficiency, but a observation from the pedagogical point of view. The Lebesgue theory evolves high abstraction (needs a measure theory), and generally have none connection with those integrals that we studied in calculus or basic analysis. The Lebesgue-Riesz integral may be a solution at the first contact. But the abstraction is needed to reach all of the power that the Lebesgue integral have to be applied in more general than the euclidean space, etc. Some application require abstraction, so we have to do abstraction.
(Again, apologize the bad English)
Comment: #3 in some sense is a manifestation of the fact that one cannot multiply distributions (in the Schwarz sense of the word "distribution"). In view of this fact, I don't see how you would ever change that without requiring boundedness.
Comment: @Ian I agree. Thanks, Ian, for that help in the other question the I made. =)
Answer: One thing you might consider a deficiency of the Lebesgue integral is that there are integrable functions whose derivatives are not integrable. For example (taken from Priestley's Introduction to Integration) $f(x)=x^2 \sin(x^{-2})$ is integrable on $(0,1]$ (since it extends continuously to $[0,1]$) but its derivative
$$ f'(x) = 2x\sin(x^{-2})-2x^{-1}\cos(x^{-2})$$
is not integrable on $(0,1]$. The first term is integrable, the second isn't because the integral of its absolute value diverges.


SLURM / Sbatch creates many small output files

Question: I am running a pipeline on a SLURM-cluster, and for some reason a lot of smaller files (between 500 and 2000 bytes in size) named along the lines of slurm-XXXXXX.out (where XXXXXX is a number). I've tried to find out what these files are on the SLURM website, but I can't find any mention of them. I assume they are some sort of in-progress files that the system uses while parsing my pipeline?
If it matters, the pipeline I'm running is using snakemake. I know I've seen these types of files before though, without snakemake, but I they weren't a big problem back then. I'm afraid that clearing the working directory of these files after each step of the workflow will interrupt in-progress steps, so I'm not doing anything with them at the moment.
What are these files, and how can I suppress their output or, alternatively, delete them after their corresponding job is finished? Did I mess up my workflow somehow, and that's why they are created?
Comment: I guess that your snakemake workflow submits a lot of jobs to the cluster, each one generating one of these files.
Answer: You might want to take a look at the sbatch documentation.  The files that you are referring to are essentially SLURM logs as explained there:

By default both standard output and standard error are directed to a
  file of the name "slurm-%j.out", where the "%j" is replaced with the
  job allocation number.

You can change the filename with the --error=<filename pattern> and --output=<filename pattern> command line options.  The filename_pattern can have one or more symbols that will be replaced as explained in the documentation.  According to the FAQs, you should be able to suppress standard output and standard error by using the following command line options:
sbatch --output=/dev/null --error=/dev/null [...]
Comment: Oh, that's great! I don't know how I missed that... Thanks for the help :-)


Comparing (hidden) regression coefficients in simple linear regression?

Question: I am doing text modeling, where each document can belong to multiple topics. I specify the desired topic number to be 3 and the three topics to be weather, sports, and education. So the model will output a triplet representing the topic mixture of each document.
Let $p_1,p_2,p_3$ denote Pr(weather), Pr(sports), Pr(education), respectively. So a news article that talks about a football match being canceled due to the bad weather may have a triplet $(p_1,p_2,p_3)=(0.4,0.5,0.1)$. The three elements in the tuple sum to $1$.
Now I wish to explore the relationship between topics and the popularity of the document. I start with multiple linear regression. Since $p_1+p_2+p_3=1$, I should only include two of $p_1,p_2,p_3$ like
$$y=\beta_0+\beta_1p_1+\beta_2p_2,$$
where $y$ is the reader-rated popularity of the documents.
Denote $p_3$'s coefficient by $\beta_3$ (not in the current model above). Is it possible to test all of the following three hypotheses with the model above?

$\beta_1=\beta_2$;
$\beta_2=\beta_3$;
$\beta_1=\beta_3$.

Is my existing answer below correct? If not, how can I do that?
Comment: This question appears to be undefined.  Since $\beta_1$, $\beta_2$, and $\beta_3$ cannot be simultaneously estimated--they are defined only up to a one-dimensional family of linear relations among them--then these three hypotheses cannot be simultaneously defined, either. To make sense of them you have to be more specific about what exactly you mean by "$\beta_3$", since it's not in the model and it makes no sense to include it in the model once $\beta_1$ and $\beta_2$ have been included.
Comment: @EdM This is true, but it doesn't seem to be a great issue in my problem, because the documents in hand are ensured to be just on the three topics. :-)
Comment: You can obtain pairwise p-values exactly as you would in any regression.  *Interpreting* them will be fraught with the usual difficulties. I'm only suggesting that many of the apparent complications in your situation disappear when you treat all three variables on an equal footing simply by leaving out the constant in the model.
Comment: $\beta_3$ is never defined. What is $\beta_3$?
Comment: @JakeWestfall that's in the original question linked in the first line of this question, where the OP wrote a model with all $x_i$ included.
Comment: @whuber I have updated my question to clarify. Hopefully, the question is defined now. Thanks a lot!
Comment: @JakeWestfall I have updated my question to clarify. Thanks a lot!
Comment: Forcing these 3 topic scores to sum to 1 seems like a bad idea as it ignores all the other potential topics. In your former use of fruit sweetness as an analogy it would be like omitting the water content that dilutes the sugars (here, other boring topics that give your choice of 3 topics less salience in an article) and omitting some really important sweeteners (here, like the topic `politics`).
Comment: From what I can tell, you seem to be asking that we consider, in turn, models in which the parameters are $(\beta_0,\beta_1,\beta_2)$, $(\beta_0,\beta_2,\beta_3)$, and $(\beta_0,\beta_1,\beta_3)$. Do you want to test those three hypotheses separately or simultaneously?
Comment: @whuber Simultaneously. Because I wish to finally come to a magnitude relationship, like A > B > C.
Comment: Just fit the equivalent model $\mathbb{E}(Y) = \beta_1 p_1 + \beta_2 p_2 + \beta_3 p_3$ (without a constant) and compare it to the reduced model $\mathbb{E}(Y) = \beta$ using an F test. If that is significant, use the coefficient estimates in the first model to decide the order of the $\beta_i$.
Comment: @whuber Thanks for the advice! But by doing this can I obtain pairwise p-values? For example, something like A > (p < 0.001) B > (p < 0.001) C.
Answer: EDIT to respond to the altered question:
Again you phrase your hypothesis based on parameters outside this model, which makes it a little uncertain what exactly you are going at. But interpreting your hypotheses to be referring to the marginal effect of each of the three topics being covered in one text, I think what you are trying to do can be done. Basically then the answer is  given by following the suggestion in D. Stroet's answer, which is (sort of) equivalent to your own answer  and the edited part in @EdM's answer:

$\beta_1=0$ indicates that increasing the content of weather [holding sports constant and consequently reducing education]  has no bearing on reader rating. This is equivalent to saying that weather and education are contributing equally to reader popularity.

$\beta_2=0$ the same reasoning applies. This is equivalent to saying that sports and education contribute equally to reader popularity.

$\beta_1=\beta_2$ can be tested just as you intended in you question. Finally, this implies that sports and weather contribute equally to reader popularity

Original Anwer:

I can not comment, hence I'm putting this in an answer. Whoever can, please convert this into a comment.
@Sibbs, can you give a reasonable example, where testing equality of these partial effects (I assume that's what you mean, since you never define $\beta_3$) makes sense, yet such a restriction ($x_1+x_2+x_3=1$) holds? As @EdM points out your "solution" already points to the conceptual flaw of your model/question. Maybe if you elaborate on what brought you there, someone could help you.
It would help to know more about the actual data underlying your model, as presented in the first question. You provided a 3-variable case "for simplicity" but that leads to this problem with only 2 independent coefficients when all $x_i$ must add up to 1. If these are data on fruit, however, there may be additional "components" (like water content, fiber) that have no bearing on perceived "sweetness" other than their influences on the effective concentrations of the sweetness-associated $x_i$. Knowing more about all the original data, as opposed to how some variables have already been transformed in a way that requires them to add to 1, may help resolve your underlying issue without trying to perform a set of comparisons that can't really be done with the restrictions you have imposed.
Comment: (+1) for asking the OP to clarify the underlying scientific issue. Often it's better to help the OP reformulate the approach to the underlying issue rather than to give an answer to the question that was initially posed. I think this should stay as an answer; I may edit to bring this into the context of the question that was first asked several months ago and is linked in the present question.
Comment: I have updated my question to clarify. Please kindly take a look. Thanks a lot for your kind help!
Answer: To test if $\beta_1=\beta_3$, we need to "reframe" the regression a bit.
$$Y=\beta_0+\beta_1x_1+\beta_2x_2$$
$$Y=\beta_0+\beta_1x_1+\beta_2(1-x_1-x_3)$$
$$Y=\beta_0+\beta_2+(\beta_1-\beta_2)x_1-\beta_2x_3$$
Now $\beta_1=\beta_3$ is equivalent to $\beta_1-\beta_2=-\beta_2$, becoming $\beta_1=0$. So just test if $\beta_1=0$ for $\beta_1=\beta_3$.
Comment: You are correct, that testing whether $\beta_1=0$ is equivalent to testing whether $\beta_1=\beta_3$.  The algebra works fine.  The final component is, of course, that testing whether $\beta_2=0$ is equivalent to testing whether $\beta_2=\beta_3$
Comment: Thank you all for the great analyses! I learned a lot! Unfortunately, the bounty can be given to only one person. Hats off and sincere thanks too to @EdM and @whuber!
Comment: I believe D. Stroet would have deserved the bounty. Anyways... To make it clearer to future readers you could update this (your) answer to get rid of any &\beta_3$s in there.
Answer: It's not possible to do all 3 pairwise comparisons of regression coefficients that you wish, because you only really have two regression coefficients.
The value of $\beta_3$ in a linear regression would be the effect of a change in $x_3$ on $Y$ with $x_1$ and $x_2$ held constant. That is not possible in your situation where the $x_i$ must all add up to 1.
All of the information about your regression is included in any choice of 2 of your 3 $x_i$. This is why your algebra came up with the result that the only way for $\beta_1=\beta_3$ is for both to be zero.
Edit based on further reflection:
What you can do in this case comes from the answer by @Glen_b to your previous question. The $\beta_0$ intercept in the model you present on this page represents the value of the Sweetness outcome variable ($Y$) when $x_3$ is the only fruit component present ($x_1$, $x_2$ both 0).
In that context, $\beta_1$ represents the change in Sweetness per change in $x_1$ when $x_2$ is held constant. Since all the $x_i$ must add to 1 and all are (presumably) non-negative, the only way for this to occur is for $x_3$ to go down as $x_1$ goes up. Thus $\beta_1$ represents the excess Sweetness of $x_1$ as it replaces $x_3$ in the mix; the same argument holds for $\beta_2$ as the excess Sweetness provided by $x_2$ as it replaces $x_3$.
So to compare the relative contributions of the $x_i$ to Sweetness, significantly non-zero values of $\beta_1$ and $\beta_2$ mean that $x_1$ resp. $x_2$ contribute differently to sweetness than does $x_3$. The comparison between $\beta_1$ and $\beta_2$ distinguishes $x_1$ from $x_2$.
Although this answers your fundamental question (not the question you posed for the way you originally wanted to proceed), I urge you to consider the original data underlying this work and whether you would be better served by analyzing data closer to their original forms rather than in a form forced to add up to 1, as the answer by @sheß suggests. When data take on necessarily restricted ranges I worry that linear regression might not model the data adequately; I trust that you have extensively examined diagnostics to make sure that your model actually works here.
Comment: Yes, testing $\beta_1=0$ tells whether weather and education have the same influence on popularity. No, your answer is not correct as you present it. If $\beta_1=0$ and $\beta_1=\beta_3$ then $\beta_3=0$ also. Yet you seem to think of $\beta_3$ as representing the contribution of education content to the popularity of an article. There is no useful way to think about a $\beta_3$ here.
Comment: @SibbsGambling  if you insist on forcing the 3 topic scores to sum to 1 then you can get the information you want about relative importance of the 3 topics but it does not involve any alleged $\beta_3$. As this answer points out, translated into your new text modeling formulation $\beta_0$ represents popularity of an education-only article, and $\beta_1$ or $\beta_2$ represents the _change_ in popularity as weather or sports replace education in the topic mix. This answer specifies the tests you would run.
Comment: Exactly! I cannot agree more with "The intercept represents the popularity of an education-only article, and $\beta_1$ and $\beta_2$ represent the change!". From here, can't I then conclude: if $\beta_1=0$ => replacing education with weather makes no difference in popularity => weather and education have the same degree of influence on popularity => my existing answer is correct?
Comment: Yes, I agree with you, but fail to see how this contradicts my answer. So your point is, my answer is not right? If it is wrong, how does one test $\beta_1=\beta_3$? Could you please kindly help make your stance clearer? Thanks a lot!
Comment: I have updated my question to clarify. Please kindly take a look. Thanks a lot for your kind help!
Answer: My suggestion is to interpret the t-statistics of $x_1$ and $x_2$ in relation to $x_3$, because the latter is the reference group.
That will answer 2. and 3. Test the equality of $x_{1}$ and $x_2$ separately with an appropriate test which will answer 1.
Comment: Downvote after the question was reformulated. Thanks.


Immediate logout after login with PAM, Kerberos, and LDAP

Question: I've set up remote login on a computer using Kerberos and LDAP. I've also configured NFS to mount onto /home so that the user's home directory is the same wherever they login.
Kerberos authentication seems to work fine. I can get a ticket using kinit user1 (assuming user1 is a remote user) and see the ticket with klist.
I'm pretty sure LDAP is working because I see the proper output from getent passwd, which lists all the remote users.
The contents of /home are present when I list the files.
The problem is: when I try to login as a remote user the session is immediately ended. Why is it not letting me stay logged in? Here is the output from /var/log/messages after a login attempt:
# /var/log/messages:
Oct  9 10:57:53 tophat login[6472]: pam_krb5[6472]: authentication succeeds for 'user1' (firstname.lastname@example.com)
Oct  9 10:57:53 tophat login[6472]: pam_krb5[6472]: pam_setcred (establish credential) called
Oct  9 10:57:53 tophat login[6472]: pam_krb5[6472]: pam_setcred (delete credential) called

EDIT:
The distro is openSUSE. Here are the common-* files in /etc/pam.d:

# /etc/pam.d/common-account
account required        pam_unix.so

# /etc/pam.d/common-auth
auth    sufficient      pam_krb5.so minimum_uid=1000
auth    required        pam_unix.so nullok_secure try_first_pass

# /etc/pam.d/common-session
session optional        pam_umask.so umask=002
session sufficient      pam_krb5.so minimum_uid=1000
session required        pam_unix.so

There doesn't appear to be a /var/log/auth.log file nor a /var/log/secure file.
Comment: Before you login via `ssh` start `sshd` in debug-mode on the console. That will give you more information than anything else. My feeling is that you should do this with native sshd-means instead of using pam.
Comment: Which distro is this? Please also add the contents of the relevant configuration files `/etc/ssh/sshd_config`, `/etc/pam.d/common-*`, as well as the logiles `/var/log/auth.log` or `/var/log/secure`, depending on your distro.
Comment: Did the user do something silly like put `logout` in their `.bashrc`?
Answer: Some questions to think about:
Does the user have a valid shell (that isn't /bin/false or similar)?  Is the user's UID >= 1000 (required by your pam_krb5.so config)?
Is the uid the same on the NFS fileserver (or uids are mapped correctly) - i.e. does the user have rwx perms on their own home directory on the host concerned?
Can the user login on other hosts which also NFS-mount the home directory.
BTW, SUSE doesn't separate logfiles into logical (facility-based) categories, you'll have to look in /var/log/syslog or /var/log/messages.
Comment: This helped since a misconfiguration in LDAP was causing the shell to be "nologin" for all users. I think the Kerberos configuration is still incorrect though. Thanks for the help, Craig!


Azure AD B2C: Bad Request - Request Too Long HTTP Error 400. The size of the request headers is too long. After login

Question: I know a similar question is already asked earlier at stack overflow but it didn't worked for me. Kindly read the entire question before answering/commenting.
I have implemented AD B2C in two web application all were working fine till last week. Now all of a sudden we are getting

Bad Request - Request Too Long HTTP Error 400. The size of the request
  headers is too long.

when the user tries to login into the website. Since my website requires every user to be logged in, it has blocked us completely.
My web app are also not working in incognito/inprivate window. Browser: Chrome, Firefox and Edge
When I open the application in chrome(not incognito) after deleting all the history I can see there are around 160+ cookies from the the web app url.
Yes too much cookies seems to be killing my webapp, but its happening even after deleting all the history of browser and in private browsing too.
Even I have reduced the claims attribute to 3 suspecting that more claims attributes might be increasing the header size.

I have tried this too but in vain.
Bottom Line: Deleting cookies and reducing claims both are not working for us and we are blocked. Thanks in advance.
Comment: Some kind of infinite redirect loop maybe?
Comment: Did you check same by running against your localhost? Are you seeing the same issue?
Comment: @Ramakrishna: It works perfectly fine in localhost. it is happening in Azure only.
Answer: I got this fixed after raising a ticket with Microsoft Support team.
Cause: There is a well-known issue with Owin Middle ware where it doesn't set the authentication cookie and we end up being in a login loop. I was using an older version of OWIN.
Resolution: OWIN Version 18.104.22.168 has integrated the fix in terms of a cookie manager.
NOTE: In-spite of using the fix, we can run into issues if we have custom SESSIONSTATE handler being used in the application. In STARTUP.AUTH.CS, we will need to make the following changes
Old:
app.UseCookieAuthentication(new CookieAuthenticationOptions{});

New:
app.UseCookieAuthentication(new CookieAuthenticationOptions   {
      AuthenticationType = "Cookies",
      CookieManager = new Microsoft.Owin.Host.SystemWeb.SystemWebChunkingCookieManager()
  });

Below is the question discussing the same:
Second sign-in causes infinite redirect loop after the first successful login MVC .NET 5 OWIN ADAL OpenIDConnect
Hope this helps other.
Happy Coding.
Comment: I'm encountering this issue for a site built from the .NET Core 3.0 default template.
Answer: I got the same error when integrating Microsoft Entra ID (formerly Azure Active Directory) via OpenID Connect into my own implementation of an Identity Server with ASP.NET Core Identity, deployed on IIS.
After logging into Microsoft, some users have too much information in the cookies, so my troubleshooting focused on allowing my Windows Server to support the volume of additional data received in the header.
To achive this I have added two new values in the following Windows Registry path:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\HTTP\Parameters

Name
Value Type
Value Data

MaxFieldLength
DWORD
65534 (Decimal)

MaxRequestBytes
DWORD
415028 (Decimal)

Here is the official Microsoft documentation that helped me resolve it: HTTP 400 Bad Request (Request Header too long) responses to HTTP requests - Workaround 2: Set MaxFieldLength and MaxRequestBytes registry entries.


Usar WhereRaw com DateDiff

Question: Preciso pegar a diferença em dias entre a data atual e a data armazenada no banco, subtrair essa diferença por 90 e então verificar se o resultado é igual a 7. Onde está o erro?
whereRaw("90 - (DATEDIFF(now(), 'updated_at')) = 7")

Comment: Eu fiz uma resposta dá uma olhada acredito que não seja aspas ali, porque é um campo!
Answer: Não seria assim, ou seja, o campo updated_at sem aspas, porque é um campo da sua tabela:
whereRaw("(90 - (DATEDIFF(now(), updated_at))) = 7")

Usar WhereRaw com DateDiff


Expectation of (sum subtract the expectation of sum)

Question: Let's say we have random variables $\mathbf{X}$, and we have $P(\mathbf{X}\in [a, b])=1$, we have $\mathbf{S}_n = \mathbf{X}_1 + \mathbf{X}_2, +\dots + \mathbf{X}_n$.
If $\mathbf{X}_1, \mathbf{X}_2, \dots, \mathbf{X}_n$ are independent, I believe we have:
$$
\mathbb{E}[\mathbf{S}_n - \mathbb{E}[\mathbf{S}_n]] = \sum_{i=1}^n\mathbb{E}[\mathbf{X}_i-\mathbb{E}[\mathbf{X}_i]]
$$
because I saw this as one step in the proof of Hoeffding's inequality. For example, see here.
Can anyone help me understand why we can get this equation?
And what if $\mathbf{X}_1, \mathbf{X}_2, \dots, \mathbf{X}_n$ are not independent. Let's say we only have the first $m$ out of these $n$ variables to be independent, can we get something like:
$$
\sum_{i=1}^n\mathbb{E}[\mathbf{X}_i-\mathbb{E}[\mathbf{X}_i]] \leq \mathbb{E}[\mathbf{S}_n - \mathbb{E}[\mathbf{S}_n]] \leq \sum_{i=1}^m\mathbb{E}[\mathbf{X}_i-\mathbb{E}[\mathbf{X}_i]]
$$
Answer: Independent or not, the equality always holds and also equal to $0$:
$$\begin{align}E[S_n-E[S_n]]&=E[S_n]-E[E[S_n]]=E[S_n]-E[S_n]=0\end{align}$$
Similarly,
$$\sum_{i=1}^n E[X_i-E[X_i]]=\sum_{i=1}^n (E[X_i] - E[X_i])=0$$
Comment: I don't see your expression in the proof in wikipedia. The expected value there have exponential term and $E[e^X]\neq e^{E[X]}$
Comment: This is actually what I suspected, but then I don't understand why Hoeffding's inequality only applies to independent variables. This equation seems to be the only place when the proof of Hoeffding's inequality dealing with independence (expanding $\mathbf{S}_n$).


X11 proxy: Unsupported and WRONG

Question: I use tera term with xming on windows 10 to log-in ubuntu server.
When I run eog on the server, it didn't work and output following errors:

PuTTY X11 proxy: Unsupported authorization protocol
** (eog:945): WARNING **: Could not open X display PuTTY X11 proxy: Unsupported authorisation protocol Cannot open display: Run 'eog
  --help' to see a full list of available command line options.

I found some questions similar to this, but all seem for putty users. I don't use putty but tera term and all didn't work for me.
Why I got such errors? And how I can solve this?
Followings are about my envs.

$ env | grep DISPLAY
DISPLAY=localhost:10.0
$ xauth list
my-server/unix:11  MIT-MAGIC-COOKIE-1  XXXXXXXXXX
my-server/unix:10  MIT-MAGIC-COOKIE-1  XXXXXXXXXX
Answer: if you are getting this error when trying from root account and it's working fine with your own user (e.g. if you are able to open Xclock), simply copy the .Xauthority file from user home to the root user home. it should work.
Thanks,
K.

X11 proxy: Unsupported and WRONG


Find the probability that the second of the twins is a boy under the condition that the first of them is a boy.

Question: It is known that the probability that two twins are the same sex $p=0.64$ where in general the probability of the births of a boy is $q= 0.51$. Find the probability that the second of the twins is a boy under the condition that the first of them is a boy.
I can't solve this problem. And I searched it typical problems on Google. But I can't solve this. Any help, any suggestions. Thanks for all!
Comment: I think, we need the unconditioned probability that we have two boys. In this case, we can apply Bayes' theorem.
Answer: There are for combinations boy|boy, boy|girl, girl|boy and girl|girl which we define as $f_{00},f_{01},f_{10},f_{11}$.
We are given that "probability that two twins are the same sex $p=0.64$" which is $f_{00}+f_{11}=0.64$.
We are given that "general the probability of the births of a boy is q=0.51" which is "$f_{00}+f_{01}=0.51$ and $f_{00}+f_{10}=0.51$.
Given that the total probability is $f_{00}+f_{01}+f_{10}+f_{11}=1$.
We invoke our knowledge of algebra, so after removing $f_{00}+f_{11}=0.64$ we have $f_{01}+f_{10}=0.36$ adding $f_{00}+f_{01}=0.51$ we get $2f_{01}+f_{00}+f_{10}=0.87$ and given that $f_{00}+f_{10}=0.51$ we get $f_{01}=0.18$ and $f_{00}=0.51-0.18=0.33$.
Comment: You wrote $f_{01}$ twice in $2f_{01}+f_{00}+f_{01}=0.87$. It turns out the same in the end if you assume (as you do) that $f_{01}=f_{10}.$
Comment: @DavidK thanks for spotting a mistake. You're right, assumption is $f_{01}=f_{10}$, as it's stems from the fact that "in general the probability of the birth of a boy..".
Answer: There are four possible outcomes $S = \{BB, BG, GB, GG\}$. It is given that
$$ P(BB) + P(GG) = 0.64 $$
It is stated that the probability that the birth of a boy is $0.51$.
$$ P(\text{No Boy}) = 1 - P(\text{Boy}) = 1-0.51 = 0.49 = P(GG)$$
Hence $P(BB) = 0.15$. This gives us $P(BG) + P(GB) = 0.36$ and assuming that $P(BG) = P(GB)$ based on the information provided in the question, we get $P(BG) = 0.18$. To answer the original question,
$$P(\text{Second twin is boy}|\text{First twin is boy}) = \frac{P(BB)}{P(BB)+P(BG)} = \frac{0.15}{0.15+0.18} = \frac{5}{11}$$
Comment: BUT this answer is not correct
Comment: Could you please clarify what is meant by 'Probability of births of a Boy'?


VM Distributed Switch Networking on Same VMKernel Adapter

Question: I have built 5 new hosts and I have added the management network from our distributed switch fine on an existing cluster but we have 2 more networks/port groups I need to add which must all be on the same vmkernel adapter. Everything I try just keeps adding the a new vm adapter with the port group assigned to it.
I have 4 NICs which have set policy to only use 2 dvuplinks and 2 as standby and they all show green. On the other hosts in the same cluster they have the port groups all on the one vm adapter which was set by a colleague who left end of last year. I have always added networking as a new adapter but this is not allowed so must go through the one adapter.
Answer: A VMkernal adapter is equivalent to a NIC within the host/hypervisor. It is connected (assigned) to a port group, not vice versa. Also, it cannot be connected to multiple port groups but you can connect multiple VMK adapters to the same port group.
If you need VMkernel adapter functionality on more than one port group you need to create more VMK adapters. You can connect a new adapter to an already present port group or create a new one with it.


Can we form a Python List Comprehension in this case?

Question: I recently learnt that we can include multiple loops in a python list comprehension, just like the sequence of the for loop in traditional manner.
So, a nested for loop instead another for loop can be added as a list comprehension as under:
result_list = [sub for part in parts for sub in part if sub > 10]

However, I got confused in one scenario where the number of 'sub' is too long, while the condition of if can be completely ignored on the rest if even one sub breaks the rule. So instead of checking all the sub in the part, I break the loop when the condition breaks and move on to next parts.
I am sharing a scenario from the code I am working on.
for part in parts:
    for sub in part:
        if sub not in a_list:
            var = False
            break
    if var == True:
        b_list.append(part)

The above code works. Just out of curiosity to learn the language, can we do this in list comprehension format?
I am at this, so sorry if I miss something.
Comment: Making a few assumptions, I *think* you need something like `[part for part in parts if all(sub in a_list for sub in part)]`. Generally, you can't "break" out of a loop in a list comprehension. Fundamentally, list comprehensions are for expressing mapping/filtering operations. But you can use `all` in the conditional here in this specific case
Comment: @Oso you actually *can't* it would throw a SyntaxError and not even *compile*
Comment: You can im working on it
Comment: `pass` is reserved in python, you shouldn't use it as a variable name
Comment: you dont need to pass and break values in a list comprehension
Comment: @juanpa.arrivillaga i kind of thought that would be the case, but assumed the code example worked :D
Comment: So what is this code supposed to do?  It is not clear. Your inner loop basically checks if all the elements of `sub` are in `a_list`. Is that what you intend?
Answer: The list comprehension syntax adds support for optional decision making/conditionals . The most common way to add conditional logic to a list comprehension is to add a conditional to the end of the expression:
like so:
new_list = [expression for member in iterable (if conditional)]

Here, your conditional statement/if statement comes just before the closing bracket or after the loop if there are more than one loop like i your scenario.
Conditionals/decision making are important because they allow list comprehensions to filter out unwanted values, which would normally require a call to filter():
Here is the complete list comprehension that you asked for:
b_list = [part for part in parts if all(sub in a_list for sub in part)]

For more information or help on list comprehensionsgo here
Comment: This list comprehension is definitely not equivalent
Comment: This should probably be something like `[part for part in parts if all(sub in a_list for sub in part)]`, of course, again assuming several things because the OP's code, for example, the boolean flag variable, and where that happens matters, and indeed, couldn't even use `pass` as a variable.
Comment: It is beacuse you only need to check once if it is in a_list and therefore you dont need to check if `pass = false`
Comment: and if it isnt can you please explain why, thank you
Comment: For starters, because you would potentially add `N*N` elements to the final list, where `N` is the length of `parts`, if the condition always passes. The loop above (assuming some corrections, because it *doesn't even compile*) would at most ad `N` elements to the list.
Comment: Now with the edit you've made, it would throw a `NameError`, because you have the incorrect order. It would have to be `for part in parts for sub in part`
Comment: Thank you @TERMINATOR and @juanpa.arrivallaga .

`b_list = [part for part in parts if all(sub in a_list for sub in part)]` this worked as per my objective.

Does this do the same thing, taking the same time as the nested loops earlier?
Comment: @Meet its a pleasure, I adjusted my answer to work in your case


Load balance pods with Nginx ingress

Question: How to balance requests between each pod using proxy-next-upstream setting on Nginx ingress.
Nginx ingress should try all pods available before returning an error to client.
If I understand correctly ingress is going to load balance between services not pods. So if there is one service proxy-next-upstream is useless? Should I create separate service for each pod or there are better solutions?
Answer: The ingress in your case will have a service type object as backend.
The service itself then has multiple pods as backends to it.
This way in a micro service architecture one ingress can have multiple services as backends for example for multiple different URL contexts that are served by different applications.
You can read all about the different kind of services that exist here

Load balance pods with Nginx ingress


How to Graph x^2 + (y - (x^2)^(1/3))^2 = 1 on a TI-83+

Question: I was trying to graph this equation, but it seems that on the TI-83, none of the graphing modes can support this. How would I go about this?
PS: I wasn't sure whether-or-not to put this on Math.Stackexchange, or to put it here. If it should go under Math.stackexchange, please let me know.
Answer: If you're just trying to graph the equation, use something like Desmos or Wolfram|Alpha. These sort of general-purpose tools are much more powerful than graphing calculators, and can graph almost anything you can think of, including implicit equations.
If you want to graph on the TI-83+ specifically, you'll need to do some easy math:
x² + (y-x^(2/3))² = 1

(y - x^(2/3))² = 1 - x²

y - x^(2/3) = ±√(1 - x²)

y = x^(2/3) ± √(1 - x²)

Now you have Y in terms of X. The TI-83+ series doesn't have a ± sign, though, so you'll need to graph the two equations as a list. Type this in in Y= mode:
X^(2/3)+{1,-1}√(1-X²)


A fly stationed at a point on the circumference of the base of a cylindrical tower of radius $12$ feet

Question: I was helping a somebody on a problem when a wild question appears. It goes like this:

A fly stationed at a point on the circumference of the base of a cylindrical tower of radius $12$ feet. Find that he can just see a distant flagstaff by walking along the tangent line to the base either a distance $8$ feet in one direction or $5$ feet in the other direction. Find the distance of the foot of the flagstaff from the center of the base of the tower.

My work
This is what I imagined...

Adding some finer details...

We see the figure above that...
$$x^2 = 4^2 + z^2$$
$$y^2 = 7^2 + z^2$$
Then...
$$x^2 = 4^2 + (y^2 - 7^2)$$
$$x^2 = y^2 - 33$$
$$x^2 - y^2 = -33$$
I guess I'm stuck. We got one equation and two unknowns. How to answer the above question?
Comment: It looks like there is a mistake in the problem. The fly supposedly sees the flagstaff from different sides of the tower at points located 13 feet apart, but the diameter of the tower is 24 feet. Have you perhaps copied the numbers wrong? Or maybe12 feet is the diameter rather than the radius?
Comment: You've got the fly **on top of** the tower, whereas the fly is in fact **at the base of** the tower, and when it walks it *leaves* the tower, not walks along the top of it..
Comment: @AakashM I thought the fly is on top of tower, which happens to be an upper base of cylindrical tower.....
Comment: A tangent line touches a circle at just one point and is outside the circle everywhere else, so while walking on the tangent line the fly cannot be standing over the interior of the tower. Also, there's no reason to think that there is _any_ point on top of the tower's base from which the flagstaff is not visible; no other objects have been specified that could obstruct the view. And if the view is obstructed by some object not described in the problem statement, the geometry could be almost anything. Altogether it makes no sense for the fly to walk on top of the tower.
Comment: @TaneliHuuskonen I properly copied it. When I searched the same problem on the internet, I have the same question on other sites. But none of them has an answer. This might be the first time the problem above will be answered.....soon...
Comment: @DavidK A fly walking through the tangent line while going to the center of the cylindrical tower? Maybe it means a fly crossing through the tangent line on the side of tower while going to the center of the cylindrical tower. Even other sites doesn't have an answer to the problem above.  We'll persists...
Comment: The problem statement says "along the tangent line". Not through, not across. If the person writing this problem meant for the fly to walk anywhere other than upon the tangent line itself, the problem is incorrectly written. It seems in any case that if your transcription is accurate, the problem was incorrectly written, because the things it describes cannot all happen in the same model.
Comment: I have posted an answer to the problem. You may not like the answer, but I believe it is the correct answer.
Answer: The following figure is a view of the tower from above.

The shaded disk is the base of the tower.
Point $F$ is the starting point of the fly on the circumference of the base of the tower.
The fly is constrained to walk along a line tangent to the base of the tower; the only such line that includes the fly's starting position is the line
$GFH.$
The points $G$ and $H$ are respectively $8$ feet from the fly's starting position in one direction along the tangent line and $5$ feet from the fly's starting position in the other direction along the tangent line.
Region $A$ (including line $GFH$ and all points to its left)
contains points all of which are visible from $F,$ $G,$ $H,$ and any point between those points; no point in that region is "just" visible from either $G$ or $H.$
Points in regions $B$ and $C$ are not visible from $H$;
points in regions $C$ and $D$ are not visible from $G.$
No point is "just" visible from $G$ and "just" visible from $H,$
so there is no point at which a flagpole can be placed that satisfies the conditions in the problem statement.
Conclusion: The statement of this problem is a mistake.
It has no solution.
Comment: Googling "just see a distant flagstaff" suggests that this problem has as its source ['Solid Mensuration, With Proofs', Kern& Bland (1938)](https://books.google.co.uk/books/about/Solid_Mensuration.html?id=Y6cAAAAAMAAJ), which in turn got the *general* problem (with numbers $r$, $p$, $q$) from "Advanced Trigonometry - Durell & Robson (1930)". This earlier book asked the reader to come up with a general formula, but Kern and Bland appear to have used specific values that don't make sense. I wonder what the 'proof' given by them for this problem is!
Comment: I suspect someone wrote "radius" instead of "diameter".
Comment: @TaneliHuuskonen I think so too. In fact I think that is the mistake in the statement of the problem.
Comment: @TaneliHuuskonen I guess the problem is ugly. No answer. No wonder other sites having this question still remained unanswered......
Comment: @DavidK The question sucks......unanswerable....We'll condemn this question to oblivion.....:-D


PHP Group array by date

Question: I have the following array that gathers data from purchases, visits and coupons generated in my application:

    array:10 [
      0 => array:2 [
        "dt" => "2020-11-18"
        "cupoms" => 9
      ]
      1 => array:2 [
        "dt" => "2020-11-19"
        "cupoms" => 1
      ]
      2 => {#1421
        +"dt": "2020-11-14"
        +"visits": 1
      }
      3 => {#1423
        +"dt": "2020-11-15"
        +"visits": 1
      }
      4 => {#860
        +"dt": "2020-11-16"
        +"visits": 9
      }
      5 => {#530
        +"dt": "2020-11-18"
        +"visits": 48
      }
      6 => {#1527
        +"dt": "2020-11-19"
        +"visits": 3
      }
      7 => array:2 [
        "dt" => "2020-11-15"
        "orders" => 1
      ]
      8 => array:2 [
        "dt" => "2020-11-17"
        "orders" => 3
      ]
      9 => array:2 [
        "dt" => "2020-11-19"
        "orders" => 4
      ]
    ]

I need to group it by date (more specifically the 'dt' field), so that the data is like as follows:

    "dt" => "2020-11-18"
    "cupoms" => 9
    "visits"=> 48

    "dt" => "2020-11-19"
    "cupoms" => 1
    "visits" => 3
    "orders" => 4

    "dt" => "2020-11-14"
    "visits"=> 1

I tried a few loops, but to no avail
Comment: where are these loops that you're referring, you forgot to add it in your question
Comment: It seems some of your array elements are arrays, and others are objects. Is this correct?
Comment: If you are using laravel, the best and easiest way to do it, is using collections, see https://laravel.com/docs/8.x/collections#method-groupby
Comment: @nick Yes, i converted objects to array and used Manuvo solution. Thank you
Comment: @r1tt3r Please take a look again at my answer as I found an oversight on my part, I already updated it. You're welcome
Answer: Update:
    I edited the answer because I realized that it wasn't adding the numerical values together, it was just taking the first value; The code got a bit more complicated but there is no straightforward way to do it with collections, I'd sill recommend using collections instead of loops of arrays

With laravel you can take advantage of collections, they are very powerfull, here is a working example:
        $array = [
      [
        "dt" => "2020-11-18",
        "cupoms" => 9
      ],
      [
        "dt" => "2020-11-19",
        "cupoms" => 1
      ],
      [
        "dt"=> "2020-11-14",
        "visits"=> 1
      ],
      [
        "dt"=> "2020-11-15",
        "visits"=> 1
      ],
      [
        "dt"=> "2020-11-16",
        "visits"=> 9
      ],
      [
        "dt"=> "2020-11-18",
        "visits"=> 48
      ],
      [
        "dt"=> "2020-11-19",
        "visits"=> 3
      ],
      [
        "dt" => "2020-11-15",
        "orders" => 1
      ],
      [
        "dt" => "2020-11-17",
        "orders" => 3
      ],
      [
        "dt" => "2020-11-19",
        "orders" => 4
      ]
    ];

    $collection = collect($array);

    $grouped = $collection->groupBy('dt');

    //up to this step($merged_rec) you already preserved and grouped all the values
    //and you can sum the values manually if you wish,
    //but in the next step I will suggest a solution using collections
    $merged_rec = $grouped->map(function ($items) {
        return collect($items)->reduce(function ($carry, $item) {
            return collect($carry)->mergeRecursive($item);
        }, collect([]));
    });

    //this will reduce the numeric arrays to a single value (sum)
    //using collections
    $summed = $merged_rec->map(function ($items){
        return collect($items->map(function($subitems) {
            if( is_array($subitems) && count($subitems) > 0 && is_numeric($subitems[0]) ){
                return collect($subitems)->sum();
            } else {
                return $subitems;
            }
        }));
    });

    print_r($summed->toArray());

this will output:
    array:6 [
      "2020-11-18" => array:3 [
        "dt" => array:2 [
          0 => "2020-11-18"
          1 => "2020-11-18"
        ]
        "cupoms" => 9
        "visits" => 48
      ]
      "2020-11-19" => array:3 [
        "dt" => array:3 [
          0 => "2020-11-19"
          1 => "2020-11-19"
          2 => "2020-11-19"
        ]
        "cupoms" => 1
        "visits" => 3
      ]
      "2020-11-14" => array:2 [
        "dt" => "2020-11-14"
        "visits" => 1
      ]
      "2020-11-15" => array:3 [
        "dt" => array:2 [
          0 => "2020-11-15"
          1 => "2020-11-15"
        ]
        "visits" => 1
        "orders" => 1
      ]
      "2020-11-16" => array:2 [
        "dt" => "2020-11-16"
        "visits" => 9
      ]
      "2020-11-17" => array:2 [
        "dt" => "2020-11-17"
        "orders" => 3
      ]
    ]

Read more: https://laravel.com/docs/8.x/collections#method-groupby
Answer: Just loop and sum the different values:
foreach($array as $v) {
    if(!isset($result[$v['dt']])) {
        $result[$v['dt']] = array('dt' => $v['dt'], 'cupoms' => 0, 'visits' => 0, 'orders' => 0);
    }
    $result[$v['dt']]['cupoms'] += $v['cupoms'];
    $result[$v['dt']]['visits'] += $v['visits'];
    $result[$v['dt']]['orders'] += $v['orders'];
}

If you want to eliminate ones that have no visits or orders, then inside the loop after summing:
$result[$v['dt']] = array_filter($result[$v['dt']]);

Then if you want integer keys (no reason for it), after the loop:
$result = array_values($result);

PHP Group array by date


Algebras: Finite Additivity $\implies$ Countable Additivity (Idea?)

Question: Given an algebra $\mathcal{A}$.
Consider a set function $\mu:\mathcal{A}\to\mathbb{R}_+$:
Then countable additivity follows from finite additivity:
$$\mu(A+B)=\mu(A)+\mu(B)\implies\mu(A)=\sum_{n\in\mathbb{N}}\mu(A_n)$$
Can you explain the idea behind the proof?
(I always forget the precise steps probably because I haven't understand it yet.)
Comment: http://math.stackexchange.com/questions/1000608/an-outer-measure-is-countable-additive-on-the-measureable-sets/1000639#1000639
Answer: I think there is something missing in yiur question.
To see this, consider the algebra(!) of all subsets $A \subset \Bbb{N}$ which are finite or for which $A^c$ is finite.
Define $\mu(A)=0$ if $A$ is finite and $\mu(A)=1$ otherwise. It is easy to verify that $\mu$ is finitely additive, but not countably additive.
Comment: Ah I'm missing monotony ...let me add it to the assumptions!
Comment: But for algebras monotony follows from additivity. So there must be a flaw somewhere in your example?
Comment: $\mu$ is monotone. If $A \subset B$ and $\mu(A) \not\leq \mu(B)$ (for contradiction), then $\mu(A)=1$ and $\mu(B)=0$, which (by definition) yields that $B$ is finite, so that $A\subset B$ is also finite, a contradiction to $\mu(A)=1$. BTW: I did not downvote.
Comment: Ah and yes it needs more to be automatically countably additive - something like continuity?
Comment: Ya I guess there's somebody voting down on all of my threads (c'est la vie).
Comment: Continuity from below will do the trick, i.e. if $B =\bigcup B_n$ (all contained in the algebra) with $B_n \subset B_{n+1}$, then $\mu(B_n)\to \mu(B)$. This (together with additivity) suffices for countable additivity, the proof is not really difficult. If the measure is finite, then continuity from above is also enough. There is also some topological condition one can impose, iirc, that is if $\mu$ is inner regular (and finite) on the algebra, this will also suffice.


Add a reference to the System.IdentityModel.Tokens DLL

Question: How do I add a reference to the System.IdentityModel.Tokens dll?
It does not seem to come up in the Nuget Package Manager.
Do I need to download the DLL?
I have .Net 4.5 installed.
The following code will not compile without the reference:
SessionSecurityToken sst = e.SessionToken;

Answer: In your solution, right click the References folder and choose "Add Reference"
From the Assemblies->Framework (.NET 4.5) list, select (check) System.IdentityModel and the press ok.
Add the using statement to the top of your class - using System.IdentityModel.Tokens;
Answer: It does exist on NuGet, and was last published 2013-02-08, so I don't understand why you couldn't find it. Try searching for System.IdentityModel.Tokens.ValidatingIssuerNameRegistry.
The best way is to install it is using the NuGet packet manager.
You can find the package here:
https://www.nuget.org/packages/System.IdentityModel.Tokens.ValidatingIssuerNameRegistry/4.5.0
Comment: You are right. It does exist and it comes up now simply by typing "system.identitymodel.tokens". I am not sure why it did not come up before either.
Answer: In case it helps someone else.
Depending on what class you need you may also need reference to
System.IdentityModel.Tokens.ValidatingIssuerNameRegistry.dll

This may not be obvious as it may be implicitly required by specific element in web.config file and not explicitly required in code.


Recuperar um ID e inserir no ComboBox para alterardados

Question: O que eu preciso fazer é recuperar o id e inseri-lo no combobox para poder alterar os dados mas o combobox fica vazio não sei porque, se alguém puder me ajudar eu agradeço.
Recupera os Dados do Banco
<?php
   session_start();
    $ID_Cliente = $_SESSION['ID_Cliente'];

    $conexao = mysql_connect("localhost:3306","root","root") or die("Erro durante a conexão do banco de dados");
    mysql_select_db("prestadora",$conexao);
    mysql_query("SET NAMES 'utf8'", $conexao);
    mysql_query('SET character_set_connection=utf8', $conexao);
    mysql_query('SET character_set_client=utf8', $conexao);
    mysql_query('SET character_set_results=utf8', $conexao);
    $consulta= "select * from pedido where ClienteID_Cliente='$ID_Cliente' " ;
    $resultado=mysql_query($consulta,$conexao) or die ("Não foi possível Consultar os seus dados.");
    mysql_close($conexao);

      while($consulta=mysql_fetch_array($resultado)){

        $Tipo_Servico=$consulta["Tipo_Servico"];
        $DataVisita=$consulta["DataVisita"];
        $HoraVisita=$consulta["HoraVisita"];
        $EnderecoVisita=$consulta["EnderecoVisita"];
        $ID_Pedido=$consulta["ID_Pedido"];

      }

?>

Formulario do Alterar

Home

Cadastra-se

Login

    <fieldset id="form_field">
        <legend id="form_legend">Alterar Pedido</legend>

        <?php
        include "_php/listarpedido.php";
        ?>

              <form method="post" action="_php/alterarpedido.php">
                 Escolher qual alterar<select name="ID_Pedido">
                 <option value="<?php echo $ID_Pedido;?>"></option> </select>

                 Tipo de Serviço: <select name="Tipo_Servico"  value="<?php echo $Tipo_Servico;?>">
                 <option name="Reforma Predial">Reforma Predial</option>
                 <option name="Jardinagem">Jardinagem</option>
                 <option name="Eletricista">Eletricista</option>
                 <option name="Encanador">Encanador</option>
                 </select>
                 Data de Visita: <input type="text" name="DataVisita" value="<?php echo $DataVisita;?>">
                 Hora de Visita: <input type="text" name="HoraVisita" value="<?php echo $HoraVisita;?>">

                 Endereço de Visita: <input type="text" name="EnderecoVisita" value="<?php echo $EnderecoVisita;?>" >
                <fieldset id="form_field">
                      <legend id="form_legend">Alterar</legend>
                      <input type="submit" id="botao" value="Alterar">
                      <input type="reset" id="botao" value="Resetar">
                </fieldset>
            </form>

Alterar no Banco

Home

Cadastra-se

Login

    <?php

    $ID_Pedido=$_POST["ID_Pedido"];
    $Tipo_Servico=$_POST["$Tipo_Servico"];
    $DataVisita=$_POST["DataVisita"];
    $HoraVisita=$_POST["HoraVisita"];
    $EnderecoVisita=$_POST["EnderecoVisita"];

    $conexao = mysql_connect("localhost:3306","root","root") or die("Erro durante a conexão do banco de dados");
    mysql_select_db("prestadora",$conexao);
    mysql_query("SET NAMES 'utf8'", $conexao);
    mysql_query('SET character_set_connection=utf8', $conexao);
    mysql_query('SET character_set_client=utf8', $conexao);
    mysql_query('SET character_set_results=utf8', $conexao);
    $atualiza= "update cliente set Tipo_Servico='$Tipo_Servico',DataVisita='$DataVisita',HoraVisita='$HoraVisita',EnderecoVisita='$EnderecoVisita' WHERE ID_Pedido='$ID_Pedido'" ;
    mysql_query($atualiza,$conexao) or die ("Não foi possível executar a atualização.");
    mysql_close($conexao);

    echo"<fieldset id='form_field'><legend id='form_legend'>Dados do Pedido</legend>

Dados do Pedido Alterados com Sucesso !!!
</fieldset>";

    ?>
<fieldset id="form_field">
     <legend id="form_legend">Voltar</legend>
    Voltar
</fieldset>

Comment: Onde esta sua duvida exatamente, nao ta faltando um js ai nao?
Comment: nesse trecho "Escolher qual alterar
 ";
Comment: ele fica vazio o combobox,não recebe as id do banco
Comment: Tmb nao tem validacoes o server le todas indormacoes mesmo que nao seja post e faz a query mysql. Outra se vc estiver apenas atualizando um sistema que ja esta escrito e tem um php menor que o 5.6 ai tudo bem. Senao sugiro vc atualizar seu php.
Comment: Fica vazio pq vc nao mandou exibir nada. Tenta ver o source HTML impresso pelo browser. Garanto que no select o campo value esta com o id. Porem no form nao vai aparecer nada pq nao ta mandando imprimí nada. Tem que mandar exibir o id ou o nome dentro da tag option
Comment: mas ta aqui
Comment: Faça ``. Lembre-se que o `value` do *option* não é exibido e sim aquilo que está entre as tags.
Comment: agora ta exibindo o numero 3 que é o terceiro registro de id mas não exibe todos os id cadastro na tabela
Comment: ou melhor dizendo não exibe os demais,o resto dos id da tabela
Comment: Ai voce tem q implementar outra sql com os dados e fazer um loop
Comment: e faria o que para mudar os outros atributos quando eu mudasse o ID do combobox ?
Comment: Ai tenta com ajax ou jQuery.
Comment: tem algum turtorial ou algum exemplo parecido ??. Para eu seguir porque isso ai eu não conheço nada ainda, estou em processo de aprendizagem kkkk
Answer: Agora sim. Voce deve mandar exibir dentro da tag option assim
<option value="<?php echo $id;?>"><?php echo $id;?></option>

Comment: se vc estiver usando o chrome tente usar as ferrementas do desenvolvedor e vc vai ver no html que a tag option tem valor mas esta vazia para exibir o nome no browser algo assim: ``


the write button writes the text but the read button is not working

Question: <code> private void btnRead_Click_1(object sender, EventArgs e)
        {try{
            FileStream f = new FileStream("demo.txt", FileMode.OpenOrCreate, FileAccess.Read);
            StreamReader sr = new StreamReader(f);
            tb1.Text = sr.ReadToEnd();
            sr.Close();
            f.Close();
           }Catch(Exception ee){
             MessageBox.Show(ee.Message);
             }
        }
</code>
Comment: Please post a [mcve].
Comment: https://learn.microsoft.com/en-us/dotnet/standard/io/common-i-o-tasks
Comment: Try using the full path of that file, you app may look in a different folder than you think
Answer: I tried your code in linqpad, everything works fine. However, there's a typo, the 'Catch' should be 'catch' though.
You can set a break point on the reader, and see if it read anything.


Different logic in Facets functionality

Question: what I am trying to achieve is to filter the site's search results and produce results of 5 content types. Search API has helped me do that and very well I must say. There is one more thing though that I need to do and I am wondering it already supports such behaviour and/or if it can be solved by theming OR if I have to create a custom solution; so here it is:
Say my aforementioned content types are: Alpha, Bravo, Charlie, Delta, Echo. I want my facets to be produced in this manner:

All (23)
Alpha (10)
Bravo (4)
Charlie (0)
Delta (1)
Echo (8)

So what i need furthermore than the options your module provides is the "All" option as long as showing Facets which yielded no results.
Apart from that, I also need to bypass the "filter-like" functionality the module provides by default, where I have to click the "-" sign next to the link to go back to the main selection, and make clicking the link filter the results while leaving the other options there for clicking. So if I was to switch from "All" to "Bravo" i'd just had to click Bravo, something like a contextual filter of Content Types in a View, oh and yes, my results are in a view-page.
Thanks in advance.
Answer: In the end I did all of this with jQuery alone.
I created a block that contains the

All (23)
Alpha (10)
Bravo (4)
Charlie (0)
Delta (1)
Echo (8)

options, I add the number with jQuery by counting the grouped results, and by JQuery again, I hide the appropriate grouping blocks. So the Facet API block was of no use to me and neither was the View's exposed filter.
Comment: It would be better if you can explain how you achieved your needs.

Different logic in Facets functionality


Usar {% for %} e {% if %} no template Django

Question: Tenho 3 videos salvos no banco Postgres onde eu seto um star_date e o vídeo só aparece no template quando o start_date <= date.today()
O meu problema está no template. Tenho 3 botões, um para cada vídeo, minha ideia é que qualquer vídeo que não tenha sua start_date <= date.today() tenha o seu botão com uma opacity: 0.3;
Porém da forma que estou fazendo, quando qualquer vídeo estiver ativo ele recebe o botão com a images/01.png e com o  e qualquer um que esteja inativo recebe o botão com a images/02.png e com o
Quando ativos preciso que o images/01.png tenha o images/02.png tenha e o images/03.png tenha
Estou fazendo da seguinte forma:
video-list.html:

    {%for video in videos%}

        {%if video.is_visible%}

        {%endif%}

        {%if video.is_visible == False%}

        {%endif%}

    {%endfor%}

views.py:
# LISTA DOS VIDEOS
def video_list(request, position):

    if 'lead_id' in request.session:
        video = Video.objects.filter(position=position).first()
        videos = Video.objects.order_by("position").all()

        return render(request, 'video-list.html', {'video': video, 'position':position, 'videos': videos})

    return redirect('registrations:create_lead')

models.py:
class Video(models.Model):
    url = models.CharField(max_length=500, verbose_name='Link Embed')
    title = models.CharField(max_length=255, verbose_name='Título')
    description = models.TextField(max_length=1000, verbose_name='Descrição do video')
    start_date = models.DateField(verbose_name='Estará disponível quando')
    position = models.IntegerField(verbose_name='Qual posição')

    @property
    def is_visible(self):
        return self.start_date <= date.today()

Será que alguém consegue me dar essa força ?
Answer:       {%if video.is_visible == False%}

Deveria ser
      {%if not video.is_visible %}

ou melhor, simplesmente use
      {% else %}

Comment: então @nosklo o problema é que no `{%for%}` eu gero um botão para cada video ativo e outro botão para cada video inativo, só que da forma que estou fazendo, todos ativos sempre vão receber `

` e todos inativos `

` e como eu tenho 3 videos eu preciso que os botões seja dinamicos, exemplo se um o video 1 e 2 estivem ativos fique ativo o botao 1 e 2
Comment: atualmente se eu tiver 2 videos ativos vou gerar 2 botoes pro video 1 e não um pra cada video, sacou ?
Comment: Não entendi @RaphaelMeloDeLima ... Se você usar um `if` com `else` dentro do `for` então pra cada vídeo ele vai gerar somente um botão, ou ativo ou inativo. Não tem como ele gerar os dois! O `else`  impede que os dois códigos sejam executados, é um ou outro
Comment: o problema era a geração de botões com propriedades diferentes, consegui resolver, vou mandar a resposta aqui
Comment: muito obrigado pela ajuda cara, vc sempre me da uma força por aqui, valeu mesmo
Answer: Consegui resolver o problema da seguinte forma:
Antes:
video-list:

    {%for video in videos%}

        {%if video.is_visible%}

        {%endif%}

        {%if video.is_visible == False%}

        {%endif%}

    {%endfor%}

Agora:
video-list:

            {%for video in videos%}

                {%if video.is_visible%}

                {%else%}

                {%endif%}

            {%endfor%}

usando o método {{forloop.counter}} eu vou atribuindo um valor conforme cada item da lista no caso do {{forloop.counter0}} uso 0 pois o counter começa com 1, dessa forma consigo tornar dinâmica minha pagina


Auto Camera Upload on Windows 10 UWP App

Question: I would like to add to my app UWP on Windows 10 auto camera upload to the cloud function.
So basically I need this functionality, which according to other sources was not supported in WP8.1 so I dropped the idea.
Now when Lumia 950 and Windows 10 Mobile is out I would very much liked to add this function to my app, but unfortunately I can't find anything about it on newest Windows Mobile. Maybe you can help?
Answer: The page you link to is only about having a specific page for the auto upload settings within an app. It doesn't do the automatic uploading for you.
That list was only in WP8 and is not in Windows10 so you can't be added to a list that doesn't exist.
To do the uploading you should look at the Background Transfer API. Specifically the BackgroundUploader class.
There's even a sample. (sample is for Win8.1 but should work with minimal modification.)
update - based on coments
I don't know how Dropbox do it (they may have special privileges not available to every developer) but you could create the functionality to upload newly taken photos by having a background task based on a timed event that checks for new files in the camera roll and uploads any it finds.
Comment: I know, but this background transfer must be triggered automatic on taking a photo and that's the real case
Comment: @Piachu the automatic triggering of uploads of photos is not what the functionality you linked to does. There is no way to do that.
Comment: I thought so too, but for example univerasal dropbox app have function to auto upload photos to dropbox. I want to do just that
Answer: this feature is only supported by Silverlight app model, not Universal Windows Platform model.
You might want to use the OneDrive SDK to upload your photo/video to the Cloud https://github.com/onedrive/onedrive-sdk-csharp
Comment: I have an app that uploads files to Google Drive, but I want auto-upload new photos from camera roll
Comment: You can use the same app model using the Google Drive APIs. Here's a great starting point using @pedro-lamas GDrive sample on GitHub

https://github.com/PedroLamas/GDrive
Comment: I saw that, but it's wrong example - my app can already do more than that - and it's WP7 app, without autoupload


Sitemap Index versus Child Sitemaps

Question: I have a question about Sitemaps; More specifically a Sitemap Index that links Child Sitemaps...
I know through what I have read that if you submit your sitemap index to the webmaster tools in Google or Bing, the robots will eventually get around to processing the child sitemaps you have in your sitemap index. I have one Sitemap index and ten child sitemaps linked in the index. Everything is working and I do not get any errors. My question is... Is there any harm in submitting both the sitemap index and the child sitemaps to google? The reason I ask is I submitted the ten child sitemaps one by one... After I did all of that I learned that I should have a sitemap index (I'm still really new at web design) Should I be removing these child sitemaps from Google Webmaster Tools? Or can they just stay? I do not want to do something that will have a negative impact with search engines...
Any opinions on this topic would be greatly appreciated.
Thanks
Eric
Answer: As per the google support docs:

As long as you've uploaded and saved all your Sitemaps, you don't need to submit each Sitemap individually. Just submit the Sitemap index file and you're good to go.

The downside of submitting the child sitemaps individually may be that, if you remove a child sitemap later you have to manually remove it. I can't actually verify that as I've not done it before.

Sitemap Index versus Child Sitemaps


Local coordinates on $n$-dimensional torus

Question: Let $\mathbb{T}^n$ be the $n$-dimensional torus, $U \subset \mathbb{T}^n$ an open set and $\phi_1, \phi_2 : U \to \mathbb{R}^n$ local coordinates on $U$ which are inverses of $\pi$, where $\pi : \mathbb{R}^n \to \mathbb{T}^n$ is the projection that takes a point $x = (x_1, ..., x_n) \in \mathbb{R}^n$ to the point in the torus by taking each component modulo one, i.e
$$\pi(x_1, ..., x_n) = (x_1, ..., x_n) \mod 1.$$
I don't understand who is the inverse of $\pi$, i.e I don't understand what form have the functions $\phi_1, \phi_2$.
Can someone help me, please?
Answer: The torus $\mathbb{T}^n$ is the quotient of $\mathbb{R}^n$ by $f_{p_1,...,p_n}(x_1,...,x_n)=(x_1+p_1,...,x_n+p_n)$ where $p_1,...,p_n$ are integers. Let $\pi:\mathbb{R}^n\rightarrow\mathbb{T}^n$ be the quotient map. If you take $V$ an pen subset of $\mathbb{R}^n$ such that for every $(p_1,...,p_n)$ $f_{p_1,...,p_n}(V)\cap V$ is empty, for example, take $V=B(x,r), r<1$, then $g(V)=U$ is an open subset of $\mathbb{T}^n$ such that ${\pi}_{\mid V}:V\rightarrow U$ is an homeomorphism. Take $\phi_U=({\pi_{\mid V}})^{-1}:U\rightarrow V\subset\mathbb{R}^n$. You can find a covering $(U_i)_{i\in I}$ of $\mathbb{R}^n$ such that $V_i=B(x_i,r_i), r_i<1$. Write $U_i=p(V_i)$, and $\phi_i=(\pi_{V_i})^{-1}$ you obtain an atlas $(U_i,\phi_i)$ of $\mathbb{T}^n$.


Reported Attack Page : how to resolve this problem

Question: My site bccfalna.com is working normal before 2 days but now its not open in firefox/chrome and other browser and come below error message
Reported Attack Page!
This web page at www.bccfalna.com has been reported as an attack page and has been blocked based on your security preferences.
so, how to solve this security problem, please help me to resolve it....
Answer: Your website has been balcklisted by Google Safe browsing. It is integrated in Firefox, Safari, and Chrome (not Internet Explorer).
First check what Google Safe Browsing says about your domain on the diagnostic page:
Malicious software is hosted on 1 domain(s), including addonrock.ru/

So, somewhere, you have a link to this domain. Indeed, on all your pages, you'll find this at the end of the code, after the  tag:

You're web application has been hacked! If you are using an open-source application, check if you are running the latest version (check the plugins as well). There may be a known vulnerability.
Here is what to do next:

understand how your site was hacked: known vulnerability in application, problem with your hosting provider, vulnerability in your code (remote file inclusion, etc.), etc.
plug the hole: upgrade your application, fix your own code, etc.
check all your files and databases for any malicious code
restore a safe backup

Step 4 is OK if you are sure that the attackers has not left any backdoor. Of course, you can never be 100% sure.... If you have enough time and money, use a new server to host your website.
Comment: +1 Excellent answer - more specific than the accepted one, which results in more useful information.
Answer: Well, assuming that you are not deliberately distributing malware, my bet is that you got hacked and either viruses or malware are being distributed from your website.
This page has details on what's going on.
Take everything down and restore from a known-good backup.
Comment: Have you any idea to solve this problem
Comment: As stated in my answer above, the only reasonable solution to your problem is to delete all the files in your DocumentRoot (and possibly re-install your whole server) and restore from a known-good backup.
Answer: Scripts from addonrock.ru and alienradar.ru get inserted via FTP.
Some Windows malware picks up the FTP login info from Filezilla and other common FTP clients.
So basically:
1) Clean your client machine.
2) Change all passwords on server.
3) Replace all infected files. If you don't have access to a log, just replace all of them.
Comment: Do you have a link to back this up?
Comment: +1 Wipe and reload machines, including clients where credentials for the server has been used.


How to solve Logical Equivalence

Question: okay I have an equivalence that I have to prove. these equivalences use biconditionals and boolean algebra.
but I'm not sure which order I apply the laws of logical equivalence.
EDIT:
It is an assignment. I've been stuck on it for days getting different answers different times.
<code>-(p V (q ^ -r)) ^ q == (-p ^ q) ^ r
</code>
I don't necessarily want anyone to solve it, I want them to explain, in a generic way, how they would go about solving it and the order they apply the laws. that way I can learn from it.
Comment: We can't help much without knowing the actual problem you are trying to solve. Also this sounds like homework. Make sure you include your attempts to solve the problem, what Google told you, what specifically you don't understand, etc.
Answer: Well there's only so many equivalencies to go around.  Through these kinds of classes and mathematics ones too, commonly you didn't have but a few tricks in the toolbox so to speak.  De Morgans laws, etc.  A chapter might mention like 4-5 rules and you should definitely try all of those.
Might help to work from the opposite side too if you've only been working the equation in one direction.  It's very much a play around with it until you get enough experience to identify a better initial guess.  But as you play with it you'll start to see a few manipulations to get reasonably close and then the problem solving comes in to figure out the 1-2 manipulations left you aren't seeing.  Even my best professors told me you have to beat your head on a desk til it works.
Comment: ah ok, i feel I may have got the answer correct, but i'll work it backwards and check the result against a truth table for each stage of the mainipulating(that will work right?) thanks anyway!
Comment: great you got it ;D.  You should just be able to apply everything you did in reverse as well.  I don't know what the problem was or what you did exactly.  If you do the truth tables correctly, they should of course be equivalent--it might be a lot to write out though!
Comment: well its an assessment, so I'm gonna make sure I get it right haha. I reckon what I was doing was applying the laws in the wrong order, therefore the operators were not used in order of precedence. I think anyways...
Answer: -(p V (q ^ -r)) ^ q
-((p V q) ^ (p V -r)) ^ q  [by distr of V over ^]
(-(p V q) V -(p V -r)) ^ q [by DeMorgan]
((-p ^ -q) V (-p ^ r)) ^ q     [by DeMorgan]
(-p ^ -q) ^ q V (-p ^ r) ^ q   [by distr of V over ^]
-p ^ (-q ^ q) V (-p ^ r) ^ q   [by assoc of ^]
-p ^ F V (-p ^ r) ^ q          [by A ^ -A == F, where F is falsity (0)]
F V (-p ^ r) ^ q  [by A ^ F == F, where F is falsity (0)]
(-p ^ q) ^ r  [by A v F == A, where F is falsity (0)]

How to solve Logical Equivalence


Optimal paper-cutting

Question: I have a paper size $25 \text{ inches} \times 35.5\text{ inches}$. I need to print $8.268 \text{ inches} \times 11.693 \text{ inches}$ (A4) size in the big paper. How to maximize the number of paper that I can get from it? How to model this?
Comment: Note that you can easily cut 9 sheets in a 3x3 arrangement and there is very little paper left over, so that is probably the best possible.
Comment: Do you mean you want to cut as many sheets of A4 size as possible from the 25'' x 35.5'' sheet?
Comment: @Rahul actually I know that I can get 9 sheet of A4 size, but I want to know how to do the equation for optimization in calculus
Comment: I don't think you can do this with calculus, since the key quantity involved is discrete -- you can cut 7 sheets or 8 sheets or 9 sheets, but you can't cut 8.5 sheets or 9.01 sheets.
Answer: A $3\times3$ arrangement is possible, and there will be $17.4$ square inches left over. As an A4 sheet has an area of $>17.4$ square inches no arrangement in the world will allow to obtain $10$ sheets.
Here the invariant "area" has allowed to circumvent a difficult impossibility proof in terms of combinatorial geometry.
Answer: If you assume that only horizontal and vertical orientations are allowed (in other words, all cuts of the original sheet are parallel to an axis), you can use either mixed integer linear programming or constraint programming to solve a problem like this. This is a well-studied problem. The search phrase to use is "two-dimensional cutting stock problem". (If cuts must go all the way across the piece, every cut going from one edge all the way to the opposite edge, I believe you want to add the term "guillotine" to the search phrase.)

Optimal paper-cutting


Access kubernetes resource information through api

Question: I have kubernetes config with recourse limits for each container, something similar to this:
apiVersion: v1
kind: Pod
metadata:
  name: frontend
spec:
  containers:
  - name: app

Is it possible to retrieve requests and limits configuration through kubernetes api or any other way to access it?
Comment: Anything that can retrieve the Pod spec will include the resource constraints, from `kubectl get pod -o yaml` up through basic use of a Kubernetes SDK.  What have you already tried?
Answer:
Is it possible to retrieve requests and limits configuration through kubernetes api or any other way to access it?

Yes, everything in Kubernetes can be accessed via APIs. You can use the REST-API directly, but it is easiest to use a Kubernetes client library for your favorite programming language, because authentication can be a bit tricky otherwise.
Access Kubernetes API with curl using proxy
Example of accessing the API using curl is documented in Using kubectl proxy.
First, use kubectl proxy to access the API:
kubectl proxy --port=8080 &

Then use that port, e.g.:
curl http://localhost:8080/api/

with output:
{
  "versions": [
    "v1"
  ],
  "serverAddressByClientCIDRs": [
    {
      "clientCIDR": "0.0.0.0/0",
      "serverAddress": "10.0.1.149:443"
    }
  ]
}

Comment: Could you give an example of how to access REST-API directly please?
Comment: Sorry, which url to call to get resources and limits?
Comment: It is in the Pod API, see e.g. https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#podspec-v1-core
Comment: Hi Jonas, thanks for your reply. Are you familiar with k8s java client? Could you please check my another question https://stackoverflow.com/questions/75279588/get-kubernetes-pods-information-through-microservice


how can i make a twig node path variable multilingual compatible in a view template?

Question: I have not found the path field in a view so i have added in my template for views_view_fields.

     {{ fields.view_node.content }}

This provide the path to the content of the default language.
How can i make a twig variable node path multilingual compatible in a view template?
Comment: Have you checked the `Rendering Language` (middle column in the views UI)? Is a content translation available for the item you want to show?
Comment: Doing this with Twig logic is wrong. Configure your view correctly. See `Rendering Language` in views admin UI. If using view with fields: add "Link to Content" field. If using view with rendered entity: use normal "{{ url }}" in node template.
Comment: Views does not work this way, such a variable does not exist. Try [searching for work-arounds](https://drupal.stackexchange.com/search?q=%5Bviews%5D+get+field+value+in+twig)
Comment: not changing anything when displaying   {{ fields.view_node.content }}.
Comment: is there another variable available for the path?
Comment: I don't know of one, but it also shouldn't be necessary. Whenever you render an entity, it should automatically use the correct language. Are you asking for the lang path of a row/item inside the view, or the path to the page display of that view?
Comment: i need each row path to make a link button to the content
Comment: what's the variable name corresponding to 'link to content'?
Answer: how simple is that ?

        {% trans %}Read more{% endtrans %}


Wampserver 2.2 PHP version 5.4.3, Apache 2.4.2 and MySql 5.5.24

Question: I have been searching for Wampserver 2.2 (with PHP version 5.4.3, Apache 2.4.2 and MySQL 5.5.24) all day, I want this specific version because its the only one that runs on my computer without errors, please can someone direct me to a link where I can download it. thanks.
Answer: I am not sure that mix actually exists but all versions of WAMPServer can be downloaded from here


what wrong i am doing here? curunt time to 2 minutes countdown

Question: what's wrongdoing here I am creating current time to 2 minutes countdown using moment js here I am phasing issues timer stop  at 1:59 not decrease time after 1:59

const CountDownTimer = () => {
  const [duration, setDuration] = useState(null);

  const getFinalTime = useCallback((duration) => {
    const currentDuration = moment.duration(duration, "milliseconds");
    let finalMinutes = currentDuration?.minutes();
    let finalSeconds = currentDuration?.seconds();
    finalMinutes = finalMinutes < 10 ? `0${finalMinutes}` : finalMinutes;
    finalSeconds = finalSeconds < 10 ? `0${finalSeconds}` : finalSeconds;
    return `${finalMinutes}:${finalSeconds}`;
  }, []);

  useEffect(() => {
    const startTimer = moment(billData?.createdAt);
    const endTimer = moment(billData?.createdAt).add(2, "minutes");
    const duration = moment.duration(endTimer.diff(startTimer), "milliseconds");
    const interval = setInterval(() => {
      const newDuration = moment
        .duration(duration - 1000, "milliseconds")
        .asMilliseconds();
      setDuration(newDuration);
    }, 1000);
    return () => clearInterval(interval);
  }, [billData?.createdAt]);

  // in getFinalTime passing duration

  return <>{getFinalTime(duration)}</>;
};

export default CountDownTimer;

Comment: @Kantivekariya You're not even using the `getFinalTime` function in the code you've pasted.
Comment: You're not telling us what there is wrong with it, so very hard to tell.
Comment: What's not working? Is there an error code? This needs more information.
Comment: @AKX description updated
Comment: @AKX they just passing duration time
Comment: You added a line that calls `getFinalTime`, but you don't use the return value.  I highly doubt that's how your app works. Please edit your post to include all of the actual related code.
Comment: @AKX updated pls check
Answer: You seem to be doing a whole lot of unnecessary work for a countdown timer.
See below for a simple implementation.

The timer component accepts a deadline Date object.
The timer component has internal state that just ensures it gets updated every second by way of the effect.
Computing the time left is a matter of computing the millisecond difference between the current time and the deadline, followed by a div/mod operation to extract minutes and seconds. (You could add another div/mod to get hours and minutes.)

function CountdownTimer({ deadline }) {
  const [, setUpdate] = React.useState(0);
  React.useEffect(() => {
    const interval = setInterval(() => {
      setUpdate((u) => u + 1);
    }, 1000);
    return () => clearInterval(interval);
  }, []);
  const timeLeftTotal = Math.max(
    0,
    Math.ceil((+deadline - +new Date()) / 1000)
  );
  const timeLeftMinutes = Math.floor(timeLeftTotal / 60);
  const timeLeftSeconds = timeLeftTotal % 60;
  const mmss = [timeLeftMinutes, timeLeftSeconds]
    .map((s) => String(s).padStart(2, "0"))
    .join(":");
  return
Time left: {mmss}
;
}

function getDeadline(secondsInFuture) {
  return new Date(+new Date() + secondsInFuture * 1000);
}

function App() {
  const [deadline, setDeadline] = React.useState(() => getDeadline(120));
  return (

      <CountdownTimer deadline={deadline} />

      <button onClick={() => setDeadline(getDeadline(60))}>
        Reset deadline to 1 minute in the future
      </button>

  );
}

ReactDOM.render(<App />, document.getElementById("root"));


Prove that $\left(\sum_{j=1}^n a_jb_j\right)^2 \le \left(\sum_{j=1}^n ja_j^2\right)\left(\sum_{j=1}^n b_j^2/j\right)$

Question: $$\left(\sum_{j=1}^n a_jb_j\right)^2 \le \left(\sum_{j=1}^n ja_j^2\right)\left(\sum_{j=1}^n b_j^2/j\right)$$
For all real numbers $a_1,...,a_n$ and $b_1,...,b_n$.
I tried applying the Cauchy-Schwarz inequality, tried a different summation order.. didn't get very far. It's from "Linear Algebra Done Right" by Sheldon Axler.
Also I have other questions from this exercise section, I wonder if I should ask them separately or put them in the same thread?
Thanks!
Comment: Have you try using $a_j\sqrt{j}$ and $b_j/\sqrt{j}$.
Comment: Even though it is from a book about linear algebra, I do not think that ([tag:linear-algebra]) is a good tag for this.
Comment: I agree, it's just that I couldn't come up with a better one as I was about to post. :)
Now I know of a new tag, haha!
Answer: It's just Cauchy-Schwarz on : $x_j^2:=ja_j^2$ and $y_j^2:=b_j^2/j$
Comment: Rather, $x_j := \sqrt{j}a_j$ and $y_j := b_j/\sqrt{j}$, no?
Comment: @AdarHefer Relax, if Grothendieck thought that [57 is a prime](https://mfluch.wordpress.com/2007/12/26/57-the-grothendieck-prime/), then we, mere mortals, are free to slip on little things like that.
Comment: Happens (: . You're welcome
Comment: yes. I was to lazy because the answer was really obvious. Will edit.
Comment: I feel like a retard. This was really obvious and I somehow managed to miss it. Thanks.


How to use a different input to draw community polygons in igraph for R?

Question: Could you please help me?
I love plotting networks with igraph for R. One nice feature is drawing polygons around the communities detected by a given algorithm.
When you use one of the community detection algorithms built in igraph, that's pretty straightforward. Like in this example with a random bipartite graph:
library(igraph)
graph <- sample_bipartite(10, 10, p = 0.5)
graph
graph.lou = cluster_louvain(graph)
graph.lou$membership
length(graph.lou$membership)
plot(graph.lou, graph)

But how can I use another kind of input to draw those polygons?
For instance, I usually calculate modularity using the package bipartite for R, because it has other algorithms that are better suited for two-mode networks.
So I'm trying to use the output from bipartite as an input for drawing community polygons in igraph. As in the following example:
library(bipartite)
matrix <- as_incidence_matrix(graph)
matrix
matrix.bec = computeModules(matrix, method = "Beckett")
modules <- module2constraints(matrix.bec)
modules
length(modules)
plot(modules, graph)

From the output of the computeModules function I'm able to extract a vector with community memberships using the module2constraints function. When I try to use it as a plotting input, I get this error message:
Error in xy.coords(x, y, xlabel, ylabel, log) :
  'x' and 'y' lengths differ

Is it possible to use this output from bipartite in igraph, so polygons are automatically drawn around the communities?
I've looked into the documentation, searched here on StackOverflow, experimented some tricks, but found no solution.
Thank you very much!
Answer: I've found a solution, with help given in another question!
Actually, another way to draw polygons around communities in igraph for R is by using the argument mark.groups of the function plot.
However, this argument accepts only lists of community membership. So, if you want to use an output of the package bipartite in the format of a vector together with an igraph object, you need to convert it to a list first.
The info contained in the vector modules described in the original question needs to be complemented with vertex names and first become a data frame, then a list:
number <- seq(1:10)
row <- "row"
rowlabels <- paste(row, number, sep = "")
column <- "col"
columnlabels <- paste(column, number, sep = "")

matrix <- matrix(data = rbinom(100,size=1,prob=0.5), nrow = 10, ncol = 10,
                  dimnames = list(rowlabels, columnlabels))

library(bipartite)
matrix.bec <- computeModules(matrix, method = "Beckett")
modules <- module2constraints(matrix.bec)

df <- data.frame(c(rownames(matrix), colnames(matrix)), modules)
colnames(df) <- c("vertices", "modules")
list <- split(df$vertices, df$modules)

Now the object list can be used as a drawing input together with an igraph object:
library(igraph)
graph <- graph_from_incidence_matrix(matrix, directed = F)

plot(graph,
     mark.groups = list)

That's one way to make bipartite and igraph talk to one another!
Thank you very much!


Where do I place a FLV file to stream on a local Red5 server?

Question: I installed the latest Red5 server, but I'm not sure where to put my .flv file to stream it.  There is no "streams" or "ofla" directory like in some tutorials I've found online.
Where do I place the .flv file to stream it?
Comment: have you found the correct way to locate the resource?
Comment: @Kai Chan's answer seemed to work, though I haven't looked at this in awhile.
Answer: Red5 comes with some demos but they are not installed by default. That is why the directory is not there. Suppose you installed Red5 on yourmachine at /path/to/red5. After starting Red5, open http://yourmachine:5080/installer/ in your browser and install oflaDemo there. After that, you will see a directory named /path/to/red5/webapps/oflaDemo/streams. That is where the .flv file should go.
Comment: Thanks! Follow-up question: where would I point a resource to find the stream? rmtp://localhost:1935/oflaDemo/streams/avatar.flv doesn't seem to work.
Comment: In linux: `/usr/lib/red5/webapps/oflaDemo/streams` In windows: `c:/program files/red5/webapps/oflaDemo/streams` That is where the .flv file should go.
Comment: I'm not able to install the OflaDemo. It stayed for hours with the message: installing oflaDemo-r3989-java6.war... but nothing is happening and the application folder is still empty. Any clue?
Comment: Makram, it may have installed but the alert did not clear. Check your webapps directory and your server log for information.
Comment: ofla_demo is in as2. if we write up a basic as3 app to connect to it we can establish the connection. pointing to the video fla resource does not work i.e ns.play("rmtp://localhost/oflaDemo/streams/avatar.flv ") does not work. what is the correct way to give the url for it to work??


Does Xcode Always Compile from Scratch

Question: I sometimes see that change I made shows up on third or 4th build run. It's as if xcode "cache" old compilation.
How to delete all compiled file and start from scratch
One thing that's particularly frustating is this:
I got a compile warning
for this code:
 [self.currentBusiness addCategoriesObject:self.currentCategory];
I know what the problem. The automatically generated core data code do not have
- (void)addDistrictsObject:(District *)value;
- (void)addCategoriesObject:(Category *)value;
on Business.h. The function is defined in Business.m though.
So I added those 2 lines. Guess what, still the same warning. I had this exact same problem several time with no issue. I know the solution. I put the line right there in business.h. Nothing changes.
Yet now I get the same compiler warning even though the method is CLEARLY defined in business.h.
As if xcode do not care about the last change I put.
I am so frustated. I added #import "Business.h" again in my utilities.h. Shouldn't change anything given that  "Business.h" is already included through other channel. Guess what, it works.
But then I thought, ah that's the problem. I curiously remove that //#import "Business.h" again so it's back like usual. If that's really the issue then the error should show up again right? Wrong.
The error is gone.
So changes I made do not show results right away. Either the compiler or the precompiler must use some sort of cache.
This is important. There are bugs that are introduced 2-3 builds before that I don't know how to debug. If code changes right after the first build after I make that change I know that something is wrong.
Also that autorestore doesn't seem to work. I create a snapshot, restore the snapshot into another directory and get lots of compile error.
Comment: Follow these steps to solve the problem,  Go to Build -> Clean All Targets.   and you will be done, then again compile and run to see your changes
Answer: Xcode does incremental builds. You can do a clean build by going to the Product menu item and select Clean (or press Shift+Cmd+K). That will delete all intermediate files and start from scratch.
Answer: NO, It only compile the file in which any kind of any editing took place.
Answer: Click xcode -> Empty Caches.
Here is a screenshot.
Comment: There is no empty Caches option
Comment: Now I get it. If one of the dependence change, xcode doesn't count that as change.

Does Xcode Always Compile from Scratch