Is it rigorous to write $\frac{dy}{dx}$ with "$y=f(x)$" instead of $\frac{df(x)}{dx}$ ? Can "dependent variables" be defined mathematically?

Question: In my understanding, to make a rigorous use of the Leibniz notation, one must write either
$\frac{df(x)}{dx}$ $ \ \ \ $ i.e. $ \ \ $ $f'$ $ \ \ $ (which denotes a function)
or
$\frac{df(x)}{dx}(a)$ $ \ \ $ or $ \ \ $ $\frac{df(x)}{dx}|_{x=a}$ $ \ \ $ i.e. $ \ $ $f'(a)$ $ \ \ $ (which denotes a value)
(where $f$ is a function that is differentiable at $a$, and $x$ is just a placeholder/a bound variable)
Thus, I suppose that writing $\frac{df}{dx}$ for $f'$ or $\frac{df}{dx}|_{x=a}$ for $f'(a)$ is merely a common abuse of notation, since the $\frac d{dx}$ must be followed by a literal expression dependant on $x$, not by a function. (See also this question)
What disturbs me is that I sometimes see the notation $\frac{dy}{dx}$ for $\frac{df(x)}{dx}$ where $y=f(x)$ is a "dependent variable".
How can $y$ have any mathematical meaning ? It's seemingly neither a function (because it equals $f$ evaluated at $x$) nor a constant number (because it depends on $x$). So it is apparently a weird mathematical object linked by convention to a variable called $x$.
(I think this illustrates one of the big problems with Leibniz notation: it requires assigning fixed letters to the variables of a function, which is bogus since a function should be independent of the name given to its argument. The same problem occurs with the Leibniz notation for partial derivatives: if $f$ is a function $\mathbb{R}^2 \rightarrow \mathbb{R}$, then unlike the unambiguous notation $\partial_1f$ (for the partial derivative w.r.t. the first argument), the Leibniz notation $\frac{\partial f}{\partial \, r}$ presupposes that the first variable of the function will always be denoted by $r$)
So is there a rigorous way to define a « dependent variable », or is this just pseudo-mathematical quirkiness ?
Edit: What is driving my question is that I have the impression that Leibniz's notation consistently treats everything as variables dependent on each other rather than as functions and arguments. As in the chain rule $\frac{dy}{dx}=\frac{dy}{dg}\frac{dg}{dx}$ that acts as if $y$ depends on $g$ even though $g$ is a function. I would like to know if there is a there is a purely mathematical aspect behind it, perhaps related to something in higher math like maybe manifolds. (I don't know what manifolds are, I don't even necessarily want to try to understand the mathematical definition of a "dependent variable", I would just like to know if this rigorous mathematical aspect exists or not).
Edit: This thread asks questions similar to mine, but I haven't found satisfactory answers on it.
Comment: Lots of mathematical notation is technically ambiguous and requires context to interpret correctly, but this isn't particularly problematic. We aren't writing computer programs, we're communicating with other humans.
Comment: $\frac{df}{dx}$ is another notation for $f'$, and $\frac{df(x)}{dx}$ is another notation for $f'(x)$ (the derivative of $f$ evaluated at $x$). The notation $\frac{df(x)}{dx}(a)$ is not correct and is never used.
Comment: In $\frac{dy}{dx}$ I like to think of both $x$ and $y$ as values that vary simultaneously, e.g. as functions of time $x(t)$ and $y(t)$.
Comment: Thx for your answer. According to the Wikipedia article I linked, "the derivative of the function $f$" (which is presumably synonymous with $f'$) can be written as $\frac{d(f(x))}{dx}$. Besides, $\frac{df}{dx}$ is a bizarre notation for $f'$ because the $x$ isn't involved (would $\frac{df}{dz}$ mean anything different ?) Moreover, $\frac{df(x)}{dx}$ for $f'(x)$ is also bizarre because that would imply writing $f'(0.5)$ as $\frac{df(0.5)}{d0.5}$
Comment: I dislike writing the chain rule as $\frac{dy}{dx} = \frac{dy}{dg} \frac{dg}{dx}$ because two different functions are both being called by the same name $y$. This is a very common abuse of notation and it's a frequent source of confusion on this site. It would be preferable in my opinion to define $\hat y(x) = y(g(x))$ and then write the chain rule as $\frac{d\hat y}{dx} = \frac{dy}{dg} \frac{dg}{dx}$. Even better opinion would be to write the chain rule as $\hat y'(x) = y'(g(x)) g'(x)$.
Comment: I dislike it too, but I thought maybe there is a mathematical way to make it rigorous.
Comment: @Karl Again, this refers seemingly to the derivative of a function with respect to another function. This does not make any rigorous sense unless somehow we consider all letters as variables that depend on each other, rather than functions.
Comment: Instead of thinking of the variables as dependent or independent, think of them as just varying together subject to a constraint given by an equation relating the variables to each other. $dy/dx$ is the ratio of the rate of change of $y$ to the rate of change of $x$ as we move around on the graph of the given equation. This perspective is also natural when doing implicit differentiation.
Comment: There **is** a process where we think of all variables as dependent variables -- implicit differentiation.  There is also a variant where we think of all but one variable as dependent variables (so we make the reduction $\frac{\mathrm{d}x}{\mathrm{d}x} = 1$ among the forest of primes).
Comment: @littleO and Mr Jackie: There **is** a way to make it mathematically rigorous, as sketched [in this answer](http://math.stackexchange.com/a/2118909/21820) (see "Notes").
Comment: @Karl: Indeed, in practical applications of implicit differentiation [such as here](http://math.stackexchange.com/a/2176223/21820), these *variables* (in the older sense and not the modern sense) are generally functions of time, and so having *variables* of the sort compatible with Leibniz notation (see my other linked post) makes it very intuitive to do implicit differentiation.
Answer:
Is it rigorous to write $\frac{dy}{dx}$ with $y=f(x)$ instead of $\frac{df(x)}{dx}$?

Mathematical notations are for communications. There is no such notion of "rigorous notation". As long as the context is clear and the definition is correctly stated, one can use whatever notation one likes. Of course, there is a matter of following the "convention" so that the intended communication is effective.
There are various notations of derivatives. People use different notations in different contexts.

In the Leibniz notation $\dfrac{dy}{dx}$, one can tell from the notation that $y$ is the dependent variable and $x$ is the independent variable.

Euler's notation $Df$ treats the derivative as an operator.

Newton notation $\dot{f}(x)$ and the Lagrange notation $f'(x)$ suggest that the derivative is more like a function.

People sometimes also use a combination of these versions of notations.

These notations are all useful in different scenarios:

When solving a simple ODE like $y'+y=\sin(x)$, the Leibniz notation allows you to formally manipulate "differentials".
In functional analysis, the Euler notation is convenient for statements regarding the derivative operators. For instance, one may phrase a question like "is $D:C^\infty(\mathbb{R})\to C^\infty(\mathbb{R})$ diagonalizable?"
The Newton notation is often used in differential geometry to denote derivatives with respect to the arc length parameter.
The Lagrange notation is a compact way to write derivatives. For instance: $\|ff'\|_{L^1}\le \|f\|_{L^2}\cdot \|f'\|_{L^2}$.

There is no good-for-all notation.

Can "dependent variables" be defined mathematically?

Mathematics is mostly carried out in natural language, which has no formal grammar. If one wants to do everything in a formal (which may be a more suitable word than "rigorous" in your question) way, one should study logic. In logic, a certain collection of expressions are chosen to be the "variables" at the outset; the semantics of the formal languages allow these variables to refer to various mathematical objects.
See also: Is there a way of defining the notion of a variable mathematically? and two answers there:

https://math.stackexchange.com/a/133680/
https://math.stackexchange.com/a/133632/
Comment: Thank you for taking the time to respond, but I find this a bit beside the point. My question was not about the validity of Leibniz's notation compared to other notations (although I must say that I strongly disapprove of it). Rather, I was wondering if it was possible to describe rigorously (or formally) what an "independent variable" is, an object that seems at first sight very strange because it is neither a function nor a constant value. Moreover, I was wondering if this related to a wider mathematical theory like manifolds.
Comment: @MrJackie: you ask the notation question explicitly *in the title* of your post, thus the answer. The question regarding formal definitions of "independent variables" is answered in the last part of my post.
Answer: First, to your very first claim.  Neither $\frac{\mathrm{d}f(x)}{\mathrm{d}x}$ nor $f'$ are primary, the definition of the derivative is primary and all notations are shorthand references to that definition.  Notation cannot be rigorous because notation is just syntax.  Reasoning about the semantics of the objects described by syntax can be rigorous, but the syntax is just strings of symbols having whatever semantics we have defined them to have.  Since we give the string of symbols "$\frac{\mathrm{d}f}{\mathrm{d}x}$" semantics, that string of symbols has that meaning.  That string of symbols also makes it easier to communicate precisely about rigorous reasoning about the abstract process that string of symbols labels.
Additionally, there is a property of equality.  If the equality $A = B$ holds, then in any expression, anywhere $A$ appears, it may be replaced with $B$ and vice versa.  So, once we have $y = f(x)$, then \begin{align*}
D_x(y) &= D_x(f(x))  \text{,}  \\
\partial_1 y &= \partial_1 f(x)  \text{,}  \\
y' &= \left( f(x) \right)' = f'(x)  \text{,}  \\
y^{(1)} &= \left( f(x) \right)^{(1)} = f^{(1)}(x)  \text{,}  \\
\frac{\mathrm{d}y}{\mathrm{d}x} &= \frac{\mathrm{d}f(x)}{\mathrm{d}x}  \text{, and}  \\
\frac{\partial y}{\partial x} &= \frac{\partial f(x)}{\partial x}    \text{.}
\end{align*}
Further, if we are working in calculus of a single variable, the above list of equivalences are also equivalent to $D(y) = D(f) = \partial_1 f = f' = f^{(1)} = \frac{\mathrm{d}f}{\mathrm{d}x} = \frac{\partial f}{\partial x}$, for the reason that in the calculus of a single variable, functions can only have one argument, so differentiation is with respect to that argument.
You say "the $\frac{\mathrm{d}}{\mathrm{d}x}$ must be followed by a literal expression dependant on $x$, not by a function."  However, a literal expression dependent on $x$ does denote a function dependent on $x$.  "$x^2$" is a function, dependent on $x$, that squares its argument.  Further, the operator "$\frac{\mathrm{d}}{\mathrm{d}x}$" need only be followed by something that can be differentiated with respect to $x$.  If we have "$y = f(x) = x^2$", then $y$, $f$, and $x^2$ are all functions depending explicitly on $x$.  Consequently, the strings of symbols "$\frac{\mathrm{d}}{\mathrm{d}x} y$", "$\frac{\mathrm{d}y}{\mathrm{d}x}$", "$\frac{\mathrm{d}}{\mathrm{d}x}f(x)$", "$\frac{\mathrm{d}f(x)}{\mathrm{d}x}$", "$\frac{\mathrm{d}}{\mathrm{d}x} x^2$", and "$\frac{\mathrm{d} x^2}{\mathrm{d}x}$"  all denote the same operation.
You write "[in "$y = f(x)$", $y$ is] neither a function (because it equals $f$ evaluated at $x$) nor a constant number (because it depends on $x$)".  However, you can't have it both ways.  Either $y$ is evaluatable for various values of $x$ or $f(x)$ is not.  The equality establishes that the value on the left of the equation equals the value on the right of the equation.  The expression on the right of the equation, "$f(x)$", evaluates when $x$ has a value.  Consequently, $y$ evaluates when $x$ has a value.
The problem you are not exactly stating, which is "how do I know what the independent variable is if all I see is '$f$'?" is exactly the same problem one has with any partial derivative and can be made worse by using notation badly.  What's $\frac{\partial f(x,x,x)}{\partial x}$?  The meaning of that expression is not communicated clearly by that expression in isolation ... because the "$x$" in the $\partial x$ is required to be either the label of a formal parameter when the function $f$ was declared or is required to be the label of one argument in "$\partial f(x,x,x)$".  You recite the notation $\partial_1 f$, which is frequently also given the notations $\partial_1 f = f_1 = f^{(1,0,0)}$ to improve the situation, to explicitly enumerate the formal parameter that is treated as the independent variable (and in the latter two notations I recite, to allow multiple derivatives without excessive repetition of the symbol "$\partial$").
Consequence: Leibniz notation is unambiguous when the function appearing in the "change of output" portion of the simplified difference quotient that is the notation $\frac{\mathrm{d}f}{\mathrm{d}x}$, is either nullary or unary, i.e. has zero or one formal parameter.  Certainly, if $g$ is declared $g(y,z)$ then $\frac{\mathrm{d}g}{\mathrm{d}x}$ has the same problem that partial differentiation of $g$ with respect to $x$ has.  However, $\frac{\mathrm{d}g(x,x)}{\mathrm{d}x}$ has no such ambiguity and has a definite value, unlike when we notate partial differentiation.  This is one of the few places where explicitly listing the parameters to the function in the "top" of a derivative usefully communicates something.
You say "...one of the big problems with Leibniz notation: it requires assigning fixed letters to the variables of a function, which is bogus since a function should be independent of the name given to its argument."  This leaves you in a tight spot.  Either you should be able to provide precise notation for a function that doesn't make a choice of formal parameter, for instance, you should be able to express $f(x) = x^2$ without any recourse to "$x$" or an equivalent, or you make a very clear argument that function definitions requires a choice of formal parameter.  If we choose to be imprecise about the formal parameter, then $\frac{\mathrm{d}f(x)}{\mathrm{d}t}$ suddenly becomes semantically valid -- it's the derivative of the $f$ with respect to its only formal parameter, but it is ambiguous whether we intend to express the result in terms of the formal parameter $x$ or the formal parameter $t$.
In comments to the Question, you write "Moreover, $\frac{\mathrm{d}f(x)}{\mathrm{d}x}$ for $f′(x)$ is also bizarre because that would imply writing $f′(0.5)$ as $\frac{\mathrm{d}f(0.5)}{\mathrm{d}0.5}$" is only valid if you make the same error in both "$f′(0.5)$" as "$\frac{\mathrm{d}f(0.5)}{\mathrm{d}0.5}$".  In "$f'(0.5)$", there is the potential ambiguity: are you differentiating $f$ and then evaluating the resulting derivative function at $0.5$, or are you evaluating $f$ at $0.5$, obtaining a constant (hence constant function), then differentiating that to obtain $0$.  The latter is useless, so no person communicating something worthwhile ever uses notation to express that process -- differentiate first.  Additionally, $\frac{\mathrm{d}f}{\mathrm{d}x}$ is a function, so there should never be any confusion that $\frac{\mathrm{d}f}{\mathrm{d}x}(0.5)$ has the semantics $\left. \frac{\mathrm{d}f}{\mathrm{d}x}\right|_{x=0.5}$, that is, differentiate, then specialize the value of the argument, yet another argument in favor of the notation you seem to dislike.
Answer: One way to make sense of "variables" is to think of the mathematics as modeling an underlying physical reality. Imagine, say, a ball dropped from a cliff. The underlying reality is a set of states of the system. The "variables" are real valued functions on the states, often written with suggestive letters. So you have $t$ for the time, $d$ for the distance the ball has fallen,  $v$ for the velocity, $a$ for acceleration, $k$ for  kinetic energy ...
The values of these functions (the variables) are related. So when you say $d = f(t)$ you are really writing function composition: each state $s$ of the world
$$
d(s) = f(t(s)).
$$
In beginning calculus you are often told that relation in the form
$$
d = 16t^2.
$$
There is no intrinsic sense in which any of the variables is independent or dependent. You could equally easily write the relation between the variables (the functions) $d$ and $t$ as
$$
t(s) = \frac{\sqrt{d(s)}}{4}
$$.
When you see simply
$$
y = f(x)
$$
you can think of the underlying set being modeled as the graph of the function $f$. For each point $P$ on the graph you have the two coordinate functions $x$ and $y$ whose values are related by the numerical recipe given by $f$.
The implicit assumption is that you are thinking of the $x$ coordinate as an independent "cause" that produces the point $(x,f(x)$ on the graph, so you say $x$ is the independent variable.
Answer: Let's start with the function $f$. Generally, a function is defined as a set of ordered pairs such that $y_1=y_2$ whenever $(x,y_1)\in f$ and $(x,y_2)\in f$. (This is the bare-bones definition of a function, which ignores the codomain.) The notation $y=f(x)$ means nothing more or less than $(x,y)\in f$. Here $x$, $y$, etc. are arbitrary names for mathematical objects that may (or may not) occur as the first or second component of an ordered pair belonging to $f$. Usually, by writing notation such as $y=f(x)$, we are announcing that $x$ is in the domain of $f$ (the set of first components of the ordered pairs that constitute $f$) and $y$ is the unique element of the set of second components such that $(x,y)\in f$. It is this uniqueness property of a function that allows us to consistently use the convention that, while $x$ may be any element of the domain, $y$ is fixed as soon as $x$ is fixed.
It is a tradition of mathematical writing that $x$ and $y$ are used in this way. "Dependent variable", as you have observed, is not really a mathematical term. Rather, it is description of a notational convention that we adhere to when discussing a particular function. It is the function that has mathematical reality; variables can be considered as names of mathematical objects—objects that, for the present at least, we have chosen not to fix. However, having announced the convention "$y=f(x)$", once we have fixed $x$ (say $x=3$), then we are obliged to fix the value of $y$ accordingly (i.e. $y=f(3)$ in this case).
Continuing in this way with $y=f(x)$, where $f$ has a derivative $f'$, notation such as $\mathrm dy/\mathrm dx$, which means the same as $\mathrm df(x)/\mathrm dx$,
can be thought of as a dependent variable: namely its meaning is fixed when $x$ is fixed. It is not correctly described as a function. Here the corresponding function is $f'$ or $x\mapsto\mathrm dy/\mathrm dx$.
In the case of partial derivatives, where we have (say) $z=f(x,y)$, it is similarly fine to write $\partial f(x,y)/\partial x$ or $\partial z/\partial x$. The function here is properly written $\partial_1f$. Unfortunately (in my view), you will come across notation such as "$\partial f/\partial x$", which is intended to mean $\partial_1f$ despite its appearance as something depending on $x$.


$f(n)=f(n-\lfloor\sqrt{n}\rfloor) + n$ Prove that f(n) is less than or equal to $3n\sqrt n$

Question:
In the question above, I need help with part B
I tried many things like induction, showing the limit of the ratio goes to $0$, Defining $g(n)=f(n)-3n\sqrt n$ and proceeding with showing it will become negative. Finally kept trying to find patterns. I got that $f(n)-n=f(n-k)$ where $k$ is the position of the square number closest to $n$ in the set $\{1,4,9,16,\ldots\}$
I have a feeling none of these is working so what is a proper way to solve this and also please teach me how to approach similar problems like these in the future.
Comment: Please do not rely on pictures of text.
Comment: At least the rate of the convergence is trivial. Note that each iteration is $a_{n} = a_{n-1} - \sqrt{a_{n-1}}$. You can upper bound it, based on the fact that each square root is no greater than $\sqrt{n}$. Hence, there are no more than $C n / \sqrt{n}$ iterations, and each iteration greatest term is $n$.
Comment: @openspace what is $a_n$ here
Comment: You can define $a_n = n$ and calculate till the $a_1$. Or the same way $a_0 = n$, $a_{i+1} = a_{i} - \sqrt{a_i}$.
Answer: We can use $n_0 = 1$, and prove
$$f(n) \le 3n\sqrt{n} = g(n) \tag{1}\label{eq1A}$$
is true for all $n \ge n_0$ using strong induction. The base case of $n = 1$ has $1 = f(1) \le 3(1)(\sqrt{1})$. Assume, for some $k \ge 1$, that \eqref{eq1A} is true for all $1 \le n \le k$. With $n = k + 1$, for some positive integer $m$, then
$$m = \lfloor \sqrt{n}\rfloor \;\;\to\;\; n = m^2 + j, \;\; 0 \le j \le 2m \tag{2}\label{eq2A}$$
From the definition of $f(n)$, and the induction hypothesis, we then get
$$\begin{equation}\begin{aligned}
f(n) & = f\left((m^2 + j) - m\right) + m^2 + j \\
& \le 3(m^2 + j - m)\sqrt{m^2 + j - m} + (m^2 + j)
\end{aligned}\end{equation}\tag{3}\label{eq3A}$$
Next, consider
$$\begin{equation}\begin{aligned}
h(n) & = g(n) - \left(3(m^2 + j - m)\sqrt{m^2 + j - m} + (m^2 + j)\right) \\
& = 3(m^2 + j)\sqrt{m^2 + j} - \left((m^2 + j) + 3(m^2 + j - m)\sqrt{m^2 + j - m}\right) \\
& = (m^2+j)\left(3\sqrt{m^2 + j} - 1\right) - 3(m^2 + j - m)\sqrt{m^2 + j - m}
\end{aligned}\end{equation}\tag{4}\label{eq4A}$$
Unfortunately, using just $\sqrt{m^2+j} \ge m$ and $\sqrt{m^2 - j + m} \lt m + \frac{1}{2}$ doesn't result in $h(n) \ge 0$. Instead, splitting the handling of the range of $j$ into $2$ parts allows the use of more accurate inequalities. First, with $0 \le j \le m$, we have
$$\begin{equation}\begin{aligned}
& m^2 + j \ge m^2 \;\to\; \sqrt{m^2 + j} \ge m \\
& m^2 + j - m \le m^2 \;\to\; \sqrt{m^2 + j - m} \le m
\end{aligned}\end{equation}\tag{5}\label{eq5A}$$
Using this in \eqref{eq4A} gives that
$$\begin{equation}\begin{aligned}
h(n) & \ge (m^2+j)(3m - 1) - 3(m^2 + j - m)(m) \\
& = (m^2+j)(3m - 1) - 3m(m^2+j) + 3m^2 \\
& = -(m^2 + j) + 3m^2 \\
& = 2m^2 - j \\
& \gt 0
\end{aligned}\end{equation}\tag{6}\label{eq6A}$$
Second, with $m+1 \le j \le 2m$, we then get
$$\begin{equation}\begin{aligned}
& m^2 + j \gt m^2 + m + \frac{1}{4} \;\to\; \sqrt{m^2 + j} \gt m + \frac{1}{2} \\
& m^2 + j - m \lt m^2 + m + \frac{1}{4} \;\to\; \sqrt{m^2 + j - m} \lt m + \frac{1}{2}
\end{aligned}\end{equation}\tag{7}\label{eq7A}$$
Using this in \eqref{eq4A} results in
$$\begin{equation}\begin{aligned}
h(n) & \gt (m^2+j)\left(3\left(m+\frac{1}{2}\right) - 1\right) - 3(m^2 + j - m)\left(m+\frac{1}{2}\right) \\
& = (m^2+j)\left(3m + \frac{1}{2}\right) - (m^2 + j)\left(3m+\frac{3}{2}\right) + 3m\left(m+\frac{1}{2}\right) \\
& = -(m^2 + j) + 3m^2 + \frac{3m}{2} \\
& = 2m^2 + \frac{3m}{2} - j \\
& \gt 0
\end{aligned}\end{equation}\tag{8}\label{eq8A}$$
Thus, \eqref{eq6A} and \eqref{eq8A} together show that $h(n) \gt 0$ so, from \eqref{eq4A} and \eqref{eq3A}, we get \eqref{eq1A} is also true for $n = k + 1$ and, therefore, by strong induction, it's true for all $n \ge 1$.

Note tighter bounds for $f(n)$ also work, e.g., reducing $3$ to $2$ in \eqref{eq1A} to get $f(n)\le 2n\sqrt{n}$. Then \eqref{eq6A} results in $m^2 - j \ge 0$, and \eqref{eq8A} ends up as $m^2 + m - j \ge 0$.
Comment: Nice work ! $\rm {+1 }$.
Answer: I found a general formular for $f(n)$
\begin{align*}
f(n)&=n(2x^2+2x+1-n)\\
&-\dfrac{x(x+1)(6x^2+2x+1)}{6}\\ &+\left\lfloor\frac{n-x^2}{x+1}\right\rfloor(2x+1)(n-x^2-x)\end{align*}
For all $n\ge1$, where: $x=\lfloor\sqrt n\rfloor$
This sequence
Comment: I personally think you should not be listing this as an answer if [you yourself are not sure it is the right closed form](https://math.stackexchange.com/questions/4820778/fn-fn-lfloor-sqrt-n-rfloorn), nor does this really make it clear how to establish the bound in question.


Unable to write the correct XML data from CLOB column

Question: /* I have written the below procedure which writes the CLOB column data to the physical location in the XML format. The file gets successfully written but getting truncated or missing the correct XML format.*/
CREATE OR REPLACE PROCEDURE p_generate_xml
IS

  c_amount         BINARY_INTEGER := 32767;
  l_buffer         VARCHAR2(32767);
  l_chr10          PLS_INTEGER;
  l_clobLen        PLS_INTEGER;
  l_fHandler       UTL_FILE.FILE_TYPE;
  l_pos            PLS_INTEGER    := 1;
 l_clob           CLOB;
 l_message_num number;
 l_cnt number;
 l_err_msg varchar2(3000);
 v_sysdate date;

BEGIN

l_message_num := 1;

   for c2 in ( SELECT xml_clob , case_id FROM AUDIT_XML_CLOB where case_id = '2006S1000018')
   loop

   select  count(1) into l_cnt from AUDIT_XML_CLOB where nvl(DBMS_LOB.GETLENGTH(xml_clob),0) > 0;

    if l_cnt > 0 then

      l_pos := 1;

       SELECT xml_clob
        INTO  l_clob
        FROM AUDIT_XML_CLOB where case_id = c2.case_id;

          l_fHandler := UTL_FILE.FOPEN('MY_DIR1', 'test.xml','W',c_amount);

l_clobLen  := DBMS_LOB.GETLENGTH(l_clob);

             WHILE l_pos < l_clobLen
              LOOP

                l_buffer := DBMS_LOB.SUBSTR(l_clob, c_amount, l_pos);

                EXIT WHEN l_buffer IS NULL;

 UTL_FILE.PUT_line(l_fHandler, l_buffer,TRUE);
                l_pos := l_pos + LEAST(LENGTH(l_buffer)+1,c_amount);
                dbms_output.put_line('l_pos:'||l_pos);

UTL_FILE.FFLUSH (l_fHandler);

END LOOP;

  UTL_FILE.FCLOSE(l_fHandler);

l_message_num := l_message_num +1;

end if;
    end loop;
commit;
dbms_output.put_line('4');
EXCEPTION
WHEN OTHERS THEN
  IF UTL_FILE.IS_OPEN(l_fHandler) THEN
    UTL_FILE.FCLOSE(l_fHandler);
  END IF;
  --RAISE;
l_err_msg:= substr(sqlerrm,1,3000);

dbms_output.put_line(l_err_msg);

END;
/

Answer: 1) Fast way to dump clob to new file is use DBMS_XSLPROCESSOR.clob2file(...)
2) What is wrong with your xml?
begin
   for c2 in ( SELECT xml_clob , case_id FROM AUDIT_XML_CLOB where case_id = '2006S1000018')
   loop
      dbms_xslprocessor.clob2file(CL=> c2.xml_clob, FLOCATION=>'MY_DIR1', FNAME=>'test.xml', CSID=>0);
   end loop;
end;

Where MY_DIR1 exists and you have privilege to write in this location.
Comment: Some of the tags got omitted in the downloaded XML file
Comment: Can you please let me know how to use dbms_xlsprocessor.clob2file in the above code?


Getting "Must enable billing on Google Cloud Project"

Question: I am sending an address to the Maps API, need the Lat & Lon of the address.
I pass in the request https://maps.google.com/maps/api/geocode/xml?address=.....
and the error message is what you see in the subject.
I am in the Cl
Comment: Well, do you have billing enabled on GCP?
Comment: You know the solution which is to enable billing for your project. What is the problem?
Comment: Pay for what you want to use, this is what it says. And now what is the business related question?
Answer: Some Google Cloud Services are free and you can use it right away, but some others require to have an associated billing account although they are free, just in case you exceed the free usage allowed.
You have to enable billing account on the Google Cloud Project.
If you don't have one, first create a billing account:
https://cloud.google.com/billing/docs/how-to/manage-billing-account
Then, associate the project to the billing account:
https://cloud.google.com/billing/docs/how-to/modify-project


Como montar o foreach para pegar valores do array

Question: Boa tarde.
Como devo montar o foreach para pegar os valores:

barcode;
link;
charge.

deste array:
array (
  'code' => 200,
  'data' =>
  array (
    'barcode' => '00000.00000 00000.000000 00000.000000 0 00000000000000',
    'link' => 'https://visualizacaosandbox.gerencianet.com.br/emissao/196843_16_MEHZE5/A4XB-AAAAAA-AAAAAA-AAAAAA',
    'pdf' =>
    array (
      'charge' => 'https://download.gerencianet.com.br/196843_16_MEHZE5/196843-AAAAAA-AAAAAA.pdf?sandbox=true',
    ),
    'expire_at' => '2019-09-04',
    'charge_id' => 758277,
    'status' => 'waiting',
    'total' => 10000,
    'payment' => 'banking_billet',
  ),
)

PHP
foreach ($row_rs["dataBoleto"]["data"] as $row) {
  echo $row["code"];
}

Obrigado.
var_dump($row_rs);
array(20) { ["ID_Receita"]=> string(2) "20" ["id_cadastro"]=> string(2) "11" ["nome"]=> string(20) "Aluno de teste teste" ["matricula"]=> string(14) "70-47064508-19" ["parcela"]=> string(6) "1 de 4" ["planoDeConta"]=> string(5) "1.1.3" ["valor"]=> string(6) "175.00" ["dataLanc"]=> string(10) "2019-09-03" ["dataVenci"]=> string(10) "2019-10-03" ["dataPago"]=> NULL ["contaBancaria"]=> string(1) "2" ["formaEntrada"]=> string(1) "6" ["obs"]=> NULL ["cheqNomeProprietario"]=> NULL ["cheqBanco"]=> NULL ["cheqAgencia"]=> NULL ["cheqConta"]=> NULL ["cheqNumero"]=> NULL ["cheqDataDeposito"]=> NULL ["dataBoleto"]=> string(409) "{"code":200,"data":{"barcode":"00000.00000 00000.000000 00000.000000 0 00000000000000","link":"https://visualizacaosandbox.gerencianet.com.br/emissao/196843_16_MEHZE5/A4XB-AAAAAA-AAAAAA-AAAAAA","pdf":{"charge":"https://download.gerencianet.com.br/196843_16_MEHZE5/AAAAAA-AAAAAA-AAAAAA.pdf?sandbox=true"},"expire_at":"2019-09-04","charge_id":758277,"status":"waiting","total":10000,"payment":"banking_billet"}}" }

Comment: Tentou assim: `echo $row["barcode"];`
Answer: Não precisa do foreach para isso.
$data    = $row_rs["dataBoleto"]["data"];
$barcode = $data["barcode"];
$link    = $data["link"];
$charge  = $data["pdf"]["charge"];

Se precisar percorrer por vários itens dentro de $row_rs, você precisará:
foreach($row_rs as $dataBoleto) {
    $data    = $dataBoleto["data"];
    $barcode = $data["barcode"];
    $link    = $data["link"];
    $charge  = $data["pdf"]["charge"];
}

Você só precisa percorrer pelos sub-arrays dentro do seu row.

Atualização
No seu var_dump, o índice "dataBoleto" contém uma string JSON dentro:
["dataBoleto"]=> string(409)

Portanto, você deverá converter antes para um objeto notável antes de trabalhar com ele. No exemplo, ficaria mais ou menos isso:
$dataParsed = json_decode($row_rs["dataBoleto"], true /* para Array */);

$data    = $dataParsed["data"];
$barcode = $data["barcode"];
$link    = $data["link"];
$charge  = $data["pdf"]["charge"];

E então, dentro de $dataParsed, terá os objetos como um array e não uma string.
Comment: Olá, obrigado pela ajuda. Esta aparecendo esse erro `Warning: Illegal string offset 'data' in`
Comment: @Tiago o array que colocou no status pertence a que objeto?
Comment: Todo o array esta dentro do `$row_rs["dataBoleto"]`
Comment: Estranho, porque no exemplo, `$row_rs["dataBoleto"]` contém o índice `data`, que aponta para o restante do conteúdo. Coloca na sua publicação o `var_dump` de `row_rs`.
Comment: Atualizei o código
Comment: @Tiago atualizei a resposta.
Comment: Vamos [continuar esta discussão no chat](https://chat.stackexchange.com/rooms/98299/discussion-between-tiago-and-cypherpotato).


Most appropriate statistical test for count data (2x2 contingency)

Question: This is a dummy dataframe resembling my real-life data:
<code>structure(list(cond = c("WT", "WT", "WT", "WT", "WT", "WT", "WT",
"WT", "WT", "WT", "WT", "WT", "WT", "WT", "WT", "WT", "WT", "WT",
"WT", "WT", "WT", "WT", "WT", "WT", "KO", "KO", "KO", "KO", "KO",
"KO", "KO", "KO", "KO", "KO", "KO", "KO", "KO", "KO", "KO", "KO",
"KO", "KO", "KO", "KO"), class = c("N", "N", "N", "N", "N", "N",
"Y", "Y", "Y", "Y", "N", "N", "N", "N", "Y", "Y", "N", "Y", "N",
"N", "Y", "N", "Y", "N", "N", "N", "Y", "Y", "Y", "N", "N", "Y",
"N", "N", "N", "Y", "Y", "N", "N", "N", "N", "N", "N", "N"),
    lattice = c(72.4394527831179, 70.1486049154573, 71.2024262282001,
    70.095774734531, 73.1687587160835, 73.4725521658284, 71.1213324059112,
    69.4426450566097, 67.7407461727878, 67.3598397689386, 69.5170866395342,
    68.751790570905, 73.2734806165999, 72.0386374169852, 70.293510845974,
    68.9576642114016, 69.4472846093111, 70.8520303262601, 69.967844969872,
    69.7957750105144, 76.3165495002798, 70.8237308152673, 70.5087804854601,
    70.0768856496865, 49.4569953395058, 52.0898768763027, 44.3112116723351,
    53.0069841435797, 49.6755152863985, 50.3014101181505, 49.0856479592249,
    48.3511098818039, 50.0812079766985, 50.4035212282794, 54.0992908724316,
    43.4055868143946, 50.1834254159389, 54.7298925145524, 55.1516389972744,
    51.4685454381875, 52.253317158648, 52.8558395390657, 51.5377616093217,
    57.7792154694597)), row.names = c(NA, -44L), class = "data.frame")
</code>
Those are two experiment conditions ("WT" & "KO"). In each condition, observations might be classified as "Y" or "N" depending on whether the organism exhibits some measured trait or not.
I would like to compare those 2 groups (experimental conditions) & to infer, whether there is a statistically significant difference in amount of observations regarded as "Y" between the groups (and if it is the case, whether there are more or less "Y"-s in "KO" with respect to "WT" or not).
I do not know what type of statistical test would be more appropriate for this task: Fisher's, Chi-squared, etc.
Info: the "lattice" is another feature of the dataset, I am comparing this parameter between conditions using the Wilcoxon rank test. For this question it might be ignored. I just decided to show an entire structure of df, including this column.
EDITS:

the experiment does not have fixed marginals.
there was a time window, in which the data were collected.
conditions are independent (those were cell-sorting experiments).
afaik, this cannot be addressed with McNemar's test which is applicable for dependent variables, so the question was incorrectly assigned as duplicate.
Comment: I have voted to reopen because this question seems to have nothing to do with McNemar test which is about multiple scores *within the same subject*.
Comment: Welcome to CV, ramen! Does the answer to the question  "[McNemar test with multiple scores for the same subject](https://stats.stackexchange.com/q/260565/44269)" answer your needs?
Comment: did all the subjects undergo both experimental conditions? I.e. are your variable paired?
Comment: This question was closed as a duplicate of one dealing with paired observations, as might be addressed with McNemar's test.  However, there's no indication in the question that this was the design used, and the data presented don't reflect such a design.  In addition, the cited question deals with more than two conditions, as in Cochran's Q test.
Comment: @Alexis - but I am the OP of that question. And I performed the experiment. The observations are independent. Nothing was repeated here. Cochran's test is applicable for 3 or more related groups, which is not the case here. Here I have 2 conditions (groups) which yield dichotomous result ("Y" or "N"). I could just stick to the chi-square but I have serious doubts. In real life data, the "N" prevails and the "Y" is incidental, so I am not sure whether chi-square approximates distribution correctly.
Comment: *"the entire cultures were collected and transferred to machine (flow cytometer) in which they were measured, counted & characterized (i.e. their morphology was assessed)"* do you only have the N/Y characteristic, or did you measure multiple aspects on a single cell? In that case some test that combines these multiple aspects as a whole might be better (and you get close to something like McNemar test).
Comment: @SextusEmpiricus thank you kind soul. So, there are also other aspects assessed for each cell (e.g. the position of the flagellum). I wonder if it is possible to test at once whether the amount of Y to N in the given condition is somehow related to the lattice (following the provided example) it would be awesome. For now I decided to stick to the Fischers, since in multiple instances I have less Y observations than required for Chi2.
Comment: It is a bit different question (example [here](https://stats.stackexchange.com/questions/224441/is-logistic-regression-a-valid-way-of-analyzing-a-b-testing-results)), but you could possibly model that with binomial regression. You consider the state Y/N as binomial distributed where $p$ is a function of the type WT/KO and also the lattice (I do not know what lattice means).
Comment: @Alexis unfortunately not, since the conditions are independent.
Comment: @utobi - nope. To be more specific: each row in the dataframe represents single reading from the cytometer. This was the cell sorting experiment in which cells were grown in 2 separate Petri dishes. They were then subjected to cytometry, counted and sorted for each phenotype (condition) separately.
Comment: @ramen I am not following your comment: the OP describes two repeated measures, which is (1) canonically what paired (dependent) observations are, and (2) what Cochran's $Q$ test is for.
Comment: Hi ramen, sorry for missing that your are the OP! :) I thought Cochran's $Q$ was appropriate for you because "In each condition ["WT" and "KO"], observations might be classified as "Y" or "N" depending on whether the organism exhibits some measured trait or not." This sounds like you are measuring WT and KO **in each organism**, hence I labeled it "repeated measures" (i.e. I measured the organism for WT, and then I measured the *same organism* for KO). ←That's a repeated measures design (i.e. *paired* data). Dependency arises from the *same organism* part. Can you clarify your study design?
Comment: @Alexis sure thing. The experiment concerns 2 cell sets, which are kept in 2 separate containers under the same conditions (e.g. growing medium). The cells are from the same species. First population, "WT" are wild-type cells, similar to those, which could be encountered in the environment (they have unaltered genetic makeup). The second population ("KO") is genetically-engineered. One of the genes involved in controlling cell size, divisions & flagellar motility is knocked-down in this cells. This experiment is meant to check, whether the genetic modification was successful (to be continued)
Comment: @Alexis ... and whether the cells are affected by loss of this gene (for instance, they should be smaller, some cell structures should look malformed, the flagella should be located improperly and should be less flexible, they should divide slower than their "normal" counterparts etc.). The cells of both types were kept for n days in the same conditions, and after that the entire cultures were collected and transferred to machine (flow cytometer) in which they were measured, counted & characterized (i.e. their morphology was assessed).
Comment: @ Alexis ... and this was performed for each of the conditions (WT & KO) until the entire cultures were assessed. The "Y" or "N" column in the dummy example contains info, whether the cell currently undergoes division or not. So my null hypothesis should be that there are no differences between the cultures in terms of the content of dividing cells (amount/percentage). However, if such difference is present and statistically significant, I would like to know the direction (whether there is more dividing cells in WT or in KO). And that is the design.
Comment: @ramen I came across this question that I previously answered and one thing is not clear to me. What is the 'lattice' variable? Is your experiment to observe whether there is a difference in cell 'division' (Y and N) among the WT and KO cells, or is it about a difference in 'lattice'?
Comment: Did you start with a single cell of each type WT/KO and counted how many cells you had at the end? Is your test about testing a difference in the total amount of cells of each type WT/KO, or a difference in the ratio Y/N? Your marginals are not fixed, but an interesting effect is that you do have some potential influences on the marginals as the number of cells could be determined stochastically by growth. (The no margins fixed case assumes a multinomial distribution)
Answer: It is easier to present these data in a 2x2 contingency table.
$$\begin{array}{c|cc|c}
&\text{Y}&\text{N} & \text{marginal sum}\\ \hline
\text{WT} & 15 & 9 &  24\\
\text{KO} & 14 & 6 &  20 \\\hline
\text{marginal sum} & 29 & 15 & 44 \\
\end{array}$$
The type of test to be performed depends on the boundary conditions (whether one or more marginals are fixed or not, e.g. whether the experiment selected a fixed number of cases with WT/KO and/or Y/N) and on the stopping rule (whether the test had a fixed number of the total 44 cases, or whether the test was continued untill some number of a particular class had been observed).
You can read about this in an article by Lydersen, Fatherland and Laake Recommended tests for association in 2×2 tables, but possibly also in many other places and also question already asked here.
Depending on the number of marginals that are fixed

both marginals fixed: the values have one degree of freedom which follows a hypergeometric distribution.
You can perform Fisher's exact test.
Example: the lady tasting tea experiment

one marginal fixed: the values have two degrees of freedom which follow a binomial distribution.
You can perform several types of tests. For instance Barnard's test. Also a z-test for differences in proportions is commonly used.
Example: a/b testing.

no marginal fixed the values follow a multinomial distribution.
You can perform a chi-squared test, which approximates the multinomial distribution with a multivariate normal distribution. The null hypothesis is that the cell probabilities are a product of class probabilities.
Example: an observational study where both of the two variables are not controlled.

A situation based on a stopping rule.

When we have fixed number of two classes, and observe untill a number of cases have occurred, then the distribution follows a binomial distribution and you can perform tests for that distribution.
Example: testing the vaccins against Covid. (Which statistical model is being used in the Pfizer study design for vaccine efficacy?)


Need to reference and use a C# dll in Java

Question: I need to reference a .Net dll in java. I have used jni4net libraries for the same. I have followed the steps mentioned in the video below :
https://www.youtube.com/watch?time_continue=351&v=8OoSK_RWUe4
I have followed all the steps required to reference jni4net libraries but i get the following runtime Exception:
Exception in thread "main" java.lang.UnsatisfiedLinkError: orionforpython.DynamicOrion.__ctorDynamicOrion0(Lnet/sf/jni4net/inj/IClrProxy;)V
at orionforpython.DynamicOrion.__ctorDynamicOrion0(Native Method)
at orionforpython.DynamicOrion.<init>(DynamicOrion.java:25)
at com.orion.OrionForJava.main(OrionForJava.java:16)

After following all the steps, This is my code:
    package com.orion;
    import net.sf.jni4net.Bridge;
    import orionforpython.*;
    import java.io.*;
    class OrionForJava {
    public static void main(String[] args) throws IOException {
    Bridge.setVerbose(true);
    Bridge.init();
    File proxyAssemblyFile=new File("OrionForPython.dll");
    Bridge.LoadAndRegisterAssemblyFrom(proxyAssemblyFile);
    DynamicOrion orion=new DynamicOrion();
    String res=orion.ReqLogin("user", "pwd", "");
    System.out.print(res);
  }}

I have tried executing the same using NetBeans 8.1 IDE but with no success. I am using jni4net-0.8.8.0 version and Eclipse IDE for Java Developers
Version: Oxygen.3 Release (4.7.3)
Any assistance would be helpful!
Answer: I used jni4net library to call c# dlls from java and it is working fine. I used a lightly different approach to initialize jni4net.
try {
        Bridge.setVerbose(true);
        Bridge.init(new File("Full path to jni4net.n.w64.v40-0.8.8.0.dll"));
        // where dlls to load is jni4net.n.w64.v40-0.8.8.0.dll,jni4net.n-0.8.8.0.dll,MyOriginalNETDll.dll,MyOriginalNETDll.j4n.dll (after proxygen processing)
        for (String str : dllsToLoad) {
            File dll = new File(rutaDlls + str);
            Bridge.LoadAndRegisterAssemblyFrom(dll);
        }
    } catch (IOException e) {
        LOG.error("Error jniBrige.", e);
    }

I needed to use full path c:... to the dll to make it work. I also had to take care about .net framework version used to create assembly (need to use 4.0 in my case and java version 8)
Hopes this helps
Answer: We use JCOBridge which can be used in .NET Core (>= 3.1), .NET 5/6 and .NET Framework (>= 4.6.1). Referencing the DLL you need to call you will have full access to it and you can use it in your projects.
Consider the following C# snippet class available in a generic TestBridge.dll:
using System;

namespace TestBridge
{
    public class MyClass
    {
        /// The method <c>HelloWorld</c> return the "Hello World!!" string
        public String HelloWorld()
        {
            return "Hello World from C#!!";
        }

        /// The method <c>Add</c> return the sum of two double
        public double Add(double a, double b)
        {
            return a + b;
        }

        /// The method <c>Add</c> return the sin of a double
        public double Sin(double a)
        {
            return Math.Sin(a);
        }
    }
}

The methods of the previous class can be invoked from the following java code snippet:
import java.io.IOException;
import org.mases.jcobridge.*;

public class CSharpClassUse {

  public static void main(String[] args) {
    try {
      try {
        try {
          JCOBridge.Initialize();
          } catch (JCException e) {
            e.printStackTrace();
          }
        } catch (IOException e) {
          e.printStackTrace();
          return;
        }
        //declare and create JCOBridge instance
        JCOBridge bridge;
        bridge = JCOBridge.CreateNew();
        // adds the path where external assemblies can be found
        bridge.AddPath("Path where is TestBridge.dll assembly");
        // add REFERENCES to the .dll file you want to invoke
        bridge.AddReference("TestBridge.dll");
        // INSTANTIATE the .NET Object: JCObject is a meta object
        JCObject theNetClassInstance = (JCObject) bridge.NewObject("TestBridge.MyClass");
        double a = 2;
              double b = 3;
              double c = Math.PI/2;
              //Invoke the C# class methods
              String hello = (String) theNetClassInstance.Invoke("HelloWorld");
              double result = (double) theNetClassInstance.Invoke("Add", a, b);
              double sin = (double) theNetClassInstance.Invoke("Sin", c);
              System.out.println(String.format("%s %.0f + %.0f = %.0f and sin(%.8f) = %.8f", hello, a, b, result, c, sin));
      } catch (JCException jce) {
      jce.printStackTrace();
      System.out.println("Exiting");
      return;
    }
  }
}

The previous java code produces the following output:

Hello World from C#!! 2 + 3 = 5 and sin(3,14159265) = 1,00000000

The previous example shown how use a C# class available in a DLL. If you need to invoke/integrate .NET graphic, that in generic sense are C# DLL too, JCOBridge also manages GUI integration (WPF/WinForms/AWT/Swing): look at these Examples
Hope it was useful and clear.


Notice: Undefined index in php for displaying image from database

Question: i am working on kind of social networking type of project in php but stucked somewhere to display use image from database & getting this
Notice: Undefined index: usimg in C:\wamp\www\collegenetwrking\profileleft.php on line 19
profile.php
<?php
include("header.php");
include("profilesql.php");
include("friends.php");
?>

<?php include("head.php"); ?>
<?php
include("menu.php");
$result = mysql_query("SELECT * FROM profile ORDER BY RAND()");
$i=0;
while($row = mysql_fetch_array($result))
  {
      if($row["userid"] != $_SESSION["stuid"] )
{
$img[$i] = $row["image"];
$uid[$i] = $row["userid"];
$city[$i] = $row['city'];
$i++;
  }
  }
  $result = mysql_query("SELECT * FROM stuacc where id");

$strec = mysql_query("SELECT * FROM stuacc WHERE email='$_SESSION[logid]' ");

while($row = mysql_fetch_array($strec))
  {
$_SESSION["stuid"] =  $row["id"];

  }

$colrec = mysql_query("SELECT * FROM profile WHERE userid='$_SESSION[stuid]' ");

while($row = mysql_fetch_array($colrec))
  {
$cname = $row["coluni"];
  }

$acrec1 = mysql_query("SELECT * FROM stuacc WHERE id='$uid[0]' ");

while($row = mysql_fetch_array($acrec1))
  {
      $stid1 = $row["id"];
$name1 = $row["firstname"];
$gen1= $row["iam"];
  }

  $acrec2 = mysql_query("SELECT * FROM stuacc WHERE id='$uid[1]' ");

while($row = mysql_fetch_array($acrec2))
  {
          $stid2 = $row["id"];
$name2 = $row["firstname"];
$gen2= $row["iam"];
  }

  $acrec3 = mysql_query("SELECT * FROM stuacc WHERE id='$uid[2]' ");

while($row = mysql_fetch_array($acrec3))
  {
          $stid3 = $row["id"];
$name3 = $row["firstname"];
$gen3= $row["iam"];
  }

  $acrec4 = mysql_query("SELECT * FROM stuacc WHERE id='$uid[3]' ");

while($row = mysql_fetch_array($acrec4))
  {
          $stid4 = $row["id"];
$name4 = $row["firstname"];
$gen4= $row["iam"];
  }
?>

    <?php include("profileleft.php"); ?>

          Welcome, <?php echo $_SESSION["logid"]; ?>

          Number of visitors:
              <?php
if(isset($_SESSION['views']))
 $_SESSION['views']=$_SESSION['views']+1;
   else
 $_SESSION['views']=1;
 echo $_SESSION['views'];
 ?>

         <?php if(isset($cname)) { ?> College Name : <?php echo $cname ; ?>	<?php } ?>

          Request Friends

            <a href="friendsprofile.php?fid=<?php echo $stid1 ; ?>"><img src="<?php echo $img[0] ; ?>" width="100" height="150" border="0" alt="">

             <?php echo $name1 ; ?>

            <a href="friendsprofile.php?fid=<?php echo $stid2 ; ?>""><img src="<?php echo $img[1] ; ?>" width="100" height="150" border="0" alt="">

              <?php echo $name2 ; ?>

            <a href="friendsprofile.php?fid=<?php echo $stid3 ; ?>""><img src="<?php echo $img[2] ; ?>" width="100" height="150" border="0" alt="">

             <?php echo $name3 ; ?>

            <a href="friendsprofile.php?fid=<?php echo $stid4 ; ?>""><img src="<?php echo $img[3] ; ?>" width="100" height="150" border="0" alt="">

              <?php echo $name4 ; ?>

                  <?php echo $fname. " " . $lname; ?>

        <?php if(isset($cname)) { ?>College Name : <?php echo $cname ; ?>	 <?php } ?>

        <?php if(isset($fmes)) { ?>City :<?php echo $_GET["fmes"]; ?>	<?php } ?>

        State:
        <?php if(isset($state)) { ?><?php echo $state; ?>	<?php } ?>

        Pincode:
        <?php if(isset($pincode)) { ?><?php echo $pincode; ?>	<?php } ?>

        Country:
        <?php if(isset($country)) { ?><?php echo $country; ?>	<?php } ?>

      My friends

    <img src="<?php echo $img[0] ; ?>" alt="" width="71" height="53" />
    <img src="<?php echo $img[1] ; ?>" alt="" width="71" height="53" />

    <img src="<?php echo $img[2] ; ?>" alt="" width="71" height="53" />

    <img src="<?php echo $img[3] ; ?>" alt="" width="71" height="53" />

    View all

    View all

    Advertisement

<?php include("footer.php"); ?>

Comment: simple variable `$usimg`  not set
Comment: @SatishSharma can you please help me somewhere in detail?
Comment: you are using `$usimg` variable in line `<img src="<?php echo $usimg;?>"...`. but it not set in the page. assign something in `$usimg` before use it.
Answer: change this line
<img src="<?php echo $usimg;?>" alt=""
width="90" height="106" />

to this

 <?php if(isset($usimg)) { ?>
  <img src="<?php echo $usimg;?>" alt="" width="90" height="106" />
  <?php } ?>

add isset function. If userimg exists show the image. You can add an else part and show some generic image  in case user do not have an image.
Docs Link: http://www.php.net/isset
Comment: ok try this  if(isset($row["userid"]) && $row["userid"] != $_SESSION["stuid"] )
Comment: i need some more your help. see i just updated my question.. please have a look
Comment: im happy that i was able to help and solve your issue
Comment: please tell me what is undefined index error because i am getting this error on other pages also.
Comment: when you use some array whether it is ain PHP code or you are getting from database, Every array has keys and values. like $arr = array('a'=>'xyz'), in this array a is key and xyz is value. now if you  use echo $arr['a']. it will echo the value xyz but if you do echo $arr['b'] you will get undefined index array
Comment: Or normally  when we get some array from DB this issue occurs so solution to this is that with other if - else conditions use isset as well. that will fix undexfined index issue
Comment: and just an extra information if you use any variables in your code always initialize them on top before using so you will not get undefined variable issue in future some time.


Desenhar triângulo com estrutura de repetição em Python

Question: Preciso desenhar um triângulo da forma:
....1
...12
..123
.1234
12345

Devo usar estruturas de repetição. Pelo que entendi como dica, devo usar duas estruturas concatenadas.
Sou iniciante e já tentei diversas vezes mas não está saindo.
Um exemplo do que tentei:
n = int(input())

def triângulo2(n):

  s = ''
  i = n
  c = 1
  while i>=1:
    s = s + str('.')
    print(s)
    i = i-1
triângulo2(n)

Answer: Uma alternativa é fazer um loop de 1 até n, ir aumentando o número (acrescentando o novo dígito no final) e imprimir usando as opções de formatação:
def triangulo(n):
    x = 0
    for i in range(1, n + 1):
        x = i + (x * 10)
        print(f'{x:.>{n}}')

triangulo(5)

A cada iteração eu multiplico o número por 10 e somo o novo dígito (assim, 1 se torna 12, que depois se torna 123, etc).
Para imprimir eu uso .>{n}, que diz para imprimir o número alinhado à direita (>), ocupando n posições e preenchendo os espaços faltantes com o ponto.

Claro que também dá pra fazer concatenando strings:
def triangulo(n):
    x = '1'
    pontos = '.' * (n - 1)
    for i in range(1, n + 1):
        print(f'{pontos}{x}')
        x += str(i + 1) # adiciona um dígito
        pontos = pontos[:-1] # remove um ponto

triangulo(5)

Mas eu acho desnecessário ficar criando tantas strings (cada iteração cria uma nova string para o "número" e outra para os pontos), quando algumas contas simples e o uso das opções de formatação já resolvem.
Comment: Muito bom! obrigado!!
Answer: Olá,
A princípio pode parecer um pouco complexo, mas basta utilizar 2 métodos de listas em Python para te ajudar.
O que você precisará fazer é criar uma lista preenchendo-a com os pontos '.'
Os 2 métodos que irão te auxiliar serão o .pop() que remove uma posição específica de uma lista (a última caso nada seja passado) e o .append() que irá adicionar um elemento ao final da lista. Entendendo estes 2 métodos, facilmente você irá conseguir resolver o problema.
lista = [1, 2, 3, 4, 5]

lista.pop(0)
# A lista agora eh: [2, 3, 4, 5]

lista.append(6)
# A lista agora eh: [2, 3, 4, 5, 6]

Uma outra dica é utilizar o lista.pop(0) no while! Como condição de parada.
Comment: Não conhecia o pop, muito bom!


Rewrite URL based on HTTP_HOST

Question: Basically I want users can access the page via intranet and internet.
If users access the page via intranet, they can typing intranet IP of server on their browser address bar to 192.168.x.x.
But when users access the page via internet, they can typing public IP of server, I will rewrite the URL to public IP of server.
I have tried this, but I get the page not properly redirected.
RewriteEngine   On
RewriteBase     /mypath/
RewriteCond     %{REQUEST_FILENAME} !-f
RewriteCond     %{REQUEST_URI}      !(.*)/$
RewriteCond     %{REQUEST_METHOD}   GET
RewriteCond     %{HTTP_HOST}        !192.168.0.1
RewriteRule     ^(.*)$          http://<public.ip.of.server>/mypath/$1/ [L,R=301]
RewriteCond     %{HTTP_HOST}        !<public.ip.of.server>
RewriteRule     ^(.*)$          http://192.168.0.1/mypath/$1/   [L,R=301]

I have tried this too, but I get the page 500 internal server error.
<If "%{HTTP_HOST} == '192.168.0.1'">
RewriteEngine   On
RewriteBase     /mypath/
RewriteCond     %{REQUEST_FILENAME} !-f
RewriteCond     %{REQUEST_URI}      !(.*)/$
RewriteCond     %{REQUEST_METHOD}   GET
RewriteRule     ^(.*)$          http://192.168.0.1/mypath/$1/   [L,R=301]
</If>
<If "%{HTTP_HOST} == 'public.ip.of.server'">
RewriteEngine   On
RewriteBase     /mypath/
RewriteCond     %{REQUEST_FILENAME} !-f
RewriteCond     %{REQUEST_URI}      !(.*)/$
RewriteCond     %{REQUEST_METHOD}   GET
RewriteRule     ^(.*)$          http://<public.ip.of.server>/mypath/$1/ [L,R=301]
</If>

Am I doing something wrong?
Comment: There's a typo in the second block: you have `HTPP` twice instead of `HTTP`
Comment: What version of apache are you using?
Comment: @TomSmilack I'm sorry for typo, actually I have the right HTTP_HOST on my htaccess. I'll fix my code here.
Comment: @JonLin I'm using Apache 2.2.3
Comment: Your ancient version of Apache has known security issues... Hope the script kiddies don't find you.
Comment: Thanks for warning. I actually use the apache from Centos 5.8 distribution. I will update it soon.
Answer:
I'm using Apache 2.2.3

The <If> Directive is part of Apache 2.4's core. Those directives will cause a 500 server error if you put them in 2.2. It's not clear at all what you're trying to do, but you can replace the <If> blocks with a simple RewriteCond.
The important concept here is that RewriteConds only apply to the immediately following RewriteRule directive, they won't apply to any other ones, only just that single one. So you need to duplicate conditions if you need them to be applied to multiple rules.
RewriteEngine   On
RewriteBase     /mypath/

RewriteCond     %{HTTP_HOST} ^192.168.0.1$
RewriteCond     %{REQUEST_FILENAME} !-f
RewriteCond     %{REQUEST_URI}      !(.*)/$
RewriteCond     %{REQUEST_METHOD}   GET
RewriteRule     ^(.*)$          http://192.168.0.1/mypath/$1/   [L,R=301]

RewriteCond     %{HTTP_HOST} ^public.ip.of.server$
RewriteCond     %{REQUEST_FILENAME} !-f
RewriteCond     %{REQUEST_URI}      !(.*)/$
RewriteCond     %{REQUEST_METHOD}   GET
RewriteRule     ^(.*)$          http://<public.ip.of.server>/mypath/$1/ [L,R=301]

But you can just get rid of all of that because you can redirect without using the http://hostname bit:
RewriteCond     %{REQUEST_FILENAME} !-f
RewriteCond     %{REQUEST_URI}      !(.*)/$
RewriteCond     %{REQUEST_METHOD}   GET
RewriteRule     ^(.*)$  /mypath/$1/   [L,R=301]

And that would accomplish the above for any host.
Comment: Shame on me. I saw wrong documentation :lol: Thanks for correcting it.
I've tried both, first code works. But second one does not work. I do not know why. Thank you very much.

Rewrite URL based on HTTP_HOST


on mouse over show associated div

Question: I have a div class "asset-container" with a data-id attribute.
I also have a div class "popover-content" with an associated data-id.
When I hover over "asset-container", I want the "popover-content" show.
There are a lot of these, which is why I have data-id attached to each of the two divs so I can call the associated div to show.
I have tried several iterations of script and am not getting anywhere
js:
$(document).ready(function() {
    custom_popover();
});
function custom_popover() {
    $(".asset-container").mouseover(function() {
    $('.popover-content [data-id=' + this.value + ']').show();

   });
}

html:

    <video class="img-responsive portrait" type="video/mp4" src="https://ternpro-development.s3.amazonaws.com/media/films/71/mobile/3.mp4" data-id="71">      </video>

    <video class="img-responsive landscape" type="video/mp4" src="https://ternpro-development.s3.amazonaws.com/media/films/69/mobile/2.mp4" data-id="69"></video>

Comment: I don't see an element with class `popover` anywhere. Is the element on the same `.asset-container`?
Comment: The issue is that `.asset-container` does not have an attribute `value`. You could try replacing `this.value` with `$(this).children("video").data("id")`.
Comment: yes I noticed that and so I added the data-id attribute value to the asset-container but still no luck
Comment: Oh wait it did work!
Comment: now the only thing is, is that sometimes, there are assets with the same data-id, but in different containers that should not show, this might be another question
Comment: please see my edit above
Answer: Change your code to:
$(".asset-container").mouseover(function() {
   var id = $(this).children("video").data("id");
   $(this).parent().children('.popover-content[data-id=' + id + ']').show();
});

on mouse over show associated div


Show different fields when adding a content depends on the language

Question: i have a question about a multilanguage feature which i don't find. I have contenttype with many fields (about 20 fields). Now i want to translate this page in a few languages. My problem is that some fields (the content of the fields) are only visible for a specific language like italian for example.
So the first idea could be to add additional fields to the contenttype for the specific languages. In aspect to the code i would render the specific field depending of what language is selected on the page.
But in relating of adding a content this could be very confusing with many languages.
So my question is: Is it possible to show fields when adding a content depending on what language is selected for the new content. For example when i have a field which should only visible for the italian translation.
Is this a known problem?
Answer: If you have some specific fields which only should be viewed based on language , the best way to do that is by using page manager and panels .

Download and enable this modules
go to Structure -> pages
enable node_view
add a variant and select Selection Rules
now add a rule based on user->language and node->type
and now you can make a custom view based on language
Comment: Ok that sounds good. The main problem in my opinion is the confusing backend page (when adding the content) with all the fields. I will try your solution
Comment: in this case "node_edit" option of page manager can help. hope that works
Comment: i think your answer is the solution. Just one question: As mentioned above i have many fields. In the overview were i can the fields which i want to show, is there a way to select all and then diselect the fields which are language specific. Cause now i must add all things like the submit buttons, the publish option etc.. individual. And sorry that i can't upvote your answer
Comment: I hope this will help a bit : https://drupalize.me/videos/quickly-duplicating-variants-cloning?p=1137
not to import all fields very fast but at least you can use what you have done now in the future.
Comment: i have another question. On the pages overview where all the pages with url are listed (for example the Url: /node/%node/edit). How can i add the /node/add/%node Url to the list? Cause when i try to add this Url it always said that the Url is already in use. I can't get it to work. Is this Url possible to add?
Comment: check if this works : https://www.drupal.org/project/pm_existing_pages
Answer: I think it would be easier for you to have only one field that you would be translated with the appropriate function : t()
https://api.drupal.org/api/drupal/includes!bootstrap.inc/function/t/7
You may then translate it directly via the code or with the translation interface in the admin menu.


Trying to serialize a XML to JSon c#

Question: I'm new at c#, and in my job I have a aplication that returns this xml
 <ListaResultado PaginaAtual="1" TotalPaginas="1">
      <ItemMenu name="consultas" id="123" caminho="abc" />
     <ItemMenu name="consultas2" id="123" caminho="abc2" />
     <ItemMenu name="consultas3" id="123" caminho="abc3" />
</ListaResultado>

and output of no it's nod valid cause the final result it's
"ListaResultado":{"PaginaAtual":1,"TotalPaginas":"3",
"ItemMenu":{"name":"consultas", "id":"123", "caminho":"abc"},
"ItemMenu":{"name":"consultas2", "id":"123", "caminho":"abc2"},
"ItemMenu":{"name":"consultas3", "id":"123", "caminho":"abc3"}}

i'm need the correct
"ItemMenu":[{"name":"consultas", "id":"123", "caminho":"abc"},{"name":"consultas2", "id":"123", "caminho":"abc2"},{"name":"consultas3", "id":"123", "caminho":"abc3"}]

someone have some clue? the examples that i found use que correct xml 123 that's not my case...
thanks !!!
Comment: So parse the XML and re-serialize it as JSON. Are you having trouble with this (if so post your code and where exactly you are going wrong)?
Comment: how did you get the `json`?
Answer: First you can use LoadXml, then use JSON.NET for reserializing it to JSON:
    XmlDocument xml = new XmlDocument();
    xml.LoadXml(@"<ListaResultado PaginaAtual='1' TotalPaginas='1'>
          <ItemMenu name='consultas' id='123' caminho='abc' />
          <ItemMenu name='consultas2' id='123' caminho='abc2' />
          <ItemMenu name='consultas3' id='123' caminho='abc3' />
     </ListaResultado>");
    var doc = JsonConvert.SerializeXmlNode(xml);

Trying to serialize a XML to JSon c#


Is it possible to create a menu item and leverage path aliases?

Question: I am trying to create a menu item that loads a view mode that calls the callback function with the path alias.
<code>$items['node/%/%'] = array(
  'page callback' => '_node_view_load',
  'page arguments' => array(1, 2),
  'access callback' => TRUE,
  'type' => MENU_CALLBACK
 );

function _node_view_load($node_id, $view_mode = 'default') {
  return drupal_render(node_view(node_load($node_id), $view_mode));
}
</code>
This works if you go to /node/%/view_mode. However, it does not work if you got to /alias/view_mode. I get page not found. Is there a way to bind menu items to path aliases?
Comment: I would rather use `node/%node/%`, and the call to `node_load()` would not be necessary; the last `%` is a catch-all, and it could match paths already defined by other modules.
Comment: How did you create the alias? If "test-page" is the alias for "/node/1," when you visit http://example.com/test-page you will see the content of http://example.com/node/1, which means the callback associated with "/node/%node" is invoked.
Answer: You'd have to extend the pathauto system to handle your specific pattern, like it does for node/x/feed items.
Answer: I think that the Sub-path URL Aliases module will do what you want.


Python OpenCV curved image to square image

Question: I have the following image:

I would like to remove the distortion using Python OpenCV. Is this possible.
I am trying to follow the tutorial at Sudoku Solver, but I get a blob with array dimensions 7,1,2 instead of 4,1,2; which I assume is due to the distortion in my image. My code so far is:
import cv2
import numpy as np

def rectify(h):
        h = h.reshape((4,2))
        hnew = np.zeros((4,2),dtype = np.float32)

        add = h.sum(1)
        hnew[0] = h[np.argmin(add)]
        hnew[2] = h[np.argmax(add)]

        diff = np.diff(h,axis = 1)
        hnew[1] = h[np.argmin(diff)]
        hnew[3] = h[np.argmax(diff)]

        return hnew

img = cv2.imread('blokkies.jpg')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

# GaussianBlur(src, ksize, sigma1[, dst[, sigma2[, borderType]]]) -> dst
gray = cv2.GaussianBlur(gray, (5, 5), 0)

# adaptiveThreshold(src, maxValue, adaptiveMethod, thresholdType, blockSize, C[, dst]) -> dst
thresh = cv2.adaptiveThreshold(gray, 255, 1, 1, 11, 2)

contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)

# Biggest blob is the square we are looking for. Results in 4x1x2 array.
# First row is the TOP-RIGHT corner. Second row is the TOP-LEFT corner. Third row is the BOTTOM-LEFT corner. Finally, fourth one is the BOTTOM-RIGHT corner.
# The problem is that, there is no guarantee that for next image, the corners found out will be in this same order.
# Change to uniform order with rectify. [TOP-LEFT, TOP-RIGHT, BOTTOM-RIGHT, BOTTOM-LEFT]
biggest = None
max_area = 0
for i in contours:
    area = cv2.contourArea(i)
    if area > 100:
        peri = cv2.arcLength(i, True)
        approx = cv2.approxPolyDP(i, 0.02 * peri, True)
        if area > max_area and len(approx) == 4:
            biggest = approx
            max_area = area

print(approx.shape)
approx = rectify(approx)

h = np.array([ [0,0],[449,0],[449,449],[0,449] ],np.float32)

cv2.imshow('image', h)
cv2.waitKey(0)
cv2.destroyAllWindows()

Answer: Turns out the bug in the tutorial was to use:
approx = rectify(biggest)

Also there is this
Removing curve


Merging AND concatenation elements withing one SubNode and one element with XSLT 1.0

Question: For a few hours I'm  struggling to find a solution for this. I've seen many answers to questions like this but I can't seem to get them work for me.
So what I need is not only to merge same SubNodes (with the same names) but also to concatenate elements of these SubNodes into one element and then to merge (concatinate) the result into one element in one SubNode. I neeed to do it using XSLT transformation and I can only use XLST 1.0 (but I will also appreciate ways with 2.0 and 3.0).
Let's say I have the following XML:
 <ns0:INVOIC>
 <ns0:node1></ns0:node1>
 <ns0:node2></ns0:node2>
 .......
 <ns0:LOOPLin>
  <ns0:SubNode1></ns0:SubNode1>
  <ns0:SubNode2></ns0:SubNode2>
  ..........
  <ns0:FTX_5>
   <FTX01>ZZZ</FTX01>
   <ns0:С108_05>
     <C10801>1</C10801>
     <C10802>2</C10802>
     <C10803>3</C10803>
     <C10804>4</C10804>
     <C10805>5</C10805>
   </ns0:С108_05>
  </ns0:FTX_5>
  <ns0:FTX_5>
   <FTX01>ZZZ</FTX01>
   <ns0:С108_05>
     <C10801>6</C10801>
     <C10802>7</C10802>
     <C10803>8</C10803>
     <C10804>9</C10804>
   </ns0:С108_05>
  </ns0:FTX_5>
  ..........
  <ns0:SubNodeN></ns0:SubNodeN>
 </ns0:LOOPLin>

 <ns0:LOOPLin>
  <ns0:SubNode1></ns0:SubNode1>
  <ns0:SubNode2></ns0:SubNode2>
  ..........
  <ns0:FTX_5>
   <FTX01>ZZZ</FTX01>
   <ns0:С108_05>
     <C10801>11</C10801>
     <C10802>12</C10802>
   </С108_05>
  </ns0:FTX_5>
  <ns0:FTX_5>
   <FTX01>ZZZ</FTX01>
   <ns0:С108_05>
     <C10801>16</C10801>
     <C10802>17</C10802>
     <C10803>18</C10803>
   </ns0:С108_05>
  </ns0:FTX_5>
  ..........
  <ns0:SubNodeN></ns0:SubNodeN>
 </ns0:LOOPLin>

 <ns0:LOOPLin>
  <ns0:SubNode1></ns0:SubNode1>
  <ns0:SubNode2></ns0:SubNode2>
  ..........
  <ns0:SubNodeN></ns0:SubNodeN>
 </ns0:LOOPLin>
 ...........
 <ns0:nodeN></ns0:nodeN>
</ns0:INVOIC>

What I want to achieve:
<ns0:INVOIC>
 <ns0:node1></ns0:node1>
 <ns0:node2></ns0:node2>
 .......
 <ns0:LOOPLin>
  <ns0:SubNode1></ns0:SubNode1>
  <ns0:SubNode2></ns0:SubNode2>
  ..........
  <ns0:FTX_5>
   <FTX01>ZZZ</FTX01>
   <ns0:С108_05>
     <C10801>1 2 3 4 5 6 7 8 9</C10801>
   </ns0:С108_05>
  </ns0:FTX_5>
  ..........
  <ns0:SubNodeN></ns0:SubNodeN>
 </ns0:LOOPLin>

 <ns0:LOOPLin>
  <ns0:SubNode1></ns0:SubNode1>
  <ns0:SubNode2></ns0:SubNode2>
  ..........
  <ns0:FTX_5>
   <FTX01>ZZZ</FTX01>
   <ns0:С108_05>
     <C10801>11 12 16 17 18</C10801>
   </ns0:С108_05>
  </ns0:FTX_5>
  ..........
  <ns0:SubNodeN></ns0:SubNodeN>
 </ns0:LOOPLin>

 <ns0:LOOPLin1>
  <ns0:SubNode1></ns0:SubNode1>
  <ns0:SubNode2></ns0:SubNode2>
  ..........
  <ns0:SubNodeN></ns0:SubNodeN>
 </ns0:LOOPLin>
 ...........
 <ns0:nodeN></ns0:nodeN>
</INVOIC>

I tried to apply solution provided and modified by John Ernst and it works almost perfect BUT I loose all SubNodes in every LINLoop. That's what I get:
   <ns0:INVOIC>
     <ns0:node1></ns0:node1>
     <ns0:node2></ns0:node2>
     .......
     <ns0:LOOPLin>
      <ns0:FTX_5>
       <FTX01>ZZZ</FTX01>
       <ns0:С108_05>
         <C10801>1 2 3 4 5 6 7 8 9 </C10801>
       </ns0:С108_05>
      </ns0:FTX_5>
     </ns0:LOOPLin>

     <ns0:LOOPLin>
      <ns0:FTX_5>
       <FTX01>ZZZ</FTX01>
       <ns0:С108_05>
         <C10801>11 12  16 17 18  </C10801>
       </ns0:С108_05>
      </ns0:FTX_5>
     </ns0:LOOPLin>

     <ns0:LOOPLin>
      <ns0:FTX_5/>
     </ns0:LOOPLin>

     <ns0:nodeN></ns0:nodeN>
    </INVOIC>

So as you can see I miss all SubNodes and I have extra spaces in C10801 in case if not all C10801..5 are present and I have empty FTX_5 in case if source LINLoop misses FTX_5.
I added few lines and now I'm trying to use this XSLT:
  <xsl:template match="ns0:INVOIC">
    <ns0:INVOIC>
      <xsl:apply-templates />
    </ns0:INVOIC>
  </xsl:template>

    <xsl:key name="myKey" match="ns0:FTX_5" use="concat(generate-id(..), FTX01)"/>

    <xsl:template match="ns0:LINLoop">
       <ns0:LINLoop>
        <xsl:variable name="LoopNodeID" select="generate-id(.)"/>
        <xsl:copy-of select="./*[not(self::ns0:FTX_5)]" />
            <ns0:FTX_5>

                <xsl:for-each select="ns0:FTX_5[generate-id(.) = generate-id(key('myKey', concat($LoopNodeID, FTX01))[1])]">
                    <FTX01>
                        <xsl:value-of select="FTX01" />
                    </FTX01>
                    <ns0:C108_5>
                        <C10801>

                            <xsl:for-each select="key('myKey', concat($LoopNodeID, FTX01))">
                                <xsl:value-of select="concat(normalize-space(concat(ns0:C108_5/C10801/text(), ' ', ns0:C108_5/C10802/text(), ' ', ns0:C108_5/C10803/text(), ' ', ns0:C108_5/C10804/text(), ' ', ns0:C108_5/C10805/text())), ' ')"/>
                            </xsl:for-each>
                        </C10801>
                    </ns0:C108_5>
                </xsl:for-each>
            </ns0:FTX_5>
       </ns0:LINLoop>
    </xsl:template>

    <xsl:template match="node()|@*">
        <xsl:copy>
            <xsl:apply-templates select="node()|@*"/>
        </xsl:copy>
    </xsl:template>

Now it's almost perfect. That's what I get:
<ns0:INVOIC>
 <ns0:node1></ns0:node1>
 <ns0:node2></ns0:node2>
 .......
 <ns0:LOOPLin>
  <ns0:SubNode1></ns0:SubNode1>
  <ns0:SubNode2></ns0:SubNode2>
  ..........
  <ns0:SubNodeN></ns0:SubNodeN>
  <ns0:FTX_5>
   <FTX01>ZZZ</FTX01>
   <ns0:С108_05>
     <C10801>1 2 3 4 5 6 7 8 9 </C10801>
   </ns0:С108_05>
  </ns0:FTX_5>
 </ns0:LOOPLin>

 <ns0:LOOPLin1>
  <ns0:SubNode1></ns0:SubNode1>
  <ns0:SubNode2></ns0:SubNode2>
  ..........
  <ns0:SubNodeN></ns0:SubNodeN>
  <ns0:FTX_5>
   <FTX01>ZZZ</FTX01>
   <ns0:С108_05>
     <C10801>11 12 16 17 18 </C10801>
   </ns0:С108_05>
  </ns0:FTX_5>
 </ns0:LOOPLin>

 <ns0:LOOPLin1>
  <ns0:SubNode1></ns0:SubNode1>
  <ns0:SubNode2></ns0:SubNode2>
  ..........
  <ns0:SubNodeN></ns0:SubNodeN>
  <ns0:FTX_5/>
 </ns0:LOOPLin>
 ...........
 <ns0:nodeN></ns0:nodeN>
</INVOIC>

So everything is present but FTX_5 moved to the end of every LINLoop. It's not critical for me but nevertheless my final questions are:

Is there any way to achieve the desired result in more smart way, without <xsl:copy-of select="./*[not(self::ns0:FTX_5)]" />?
Is there a way to leave FTX_5 on it's place, not in the end of LINLoop (probably related to Q1)?
Is there a way to get rid of empty FTX_5 if source LINLoop does not contain it?

John Ernst, thank you so much for your help!
Comment: While asking an XSLT question you need to provide a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example):
(1) Input XML.
(2) Your logic, and XSLT that tries to implement it.
(3) Desired output, based on the sample XML in the #1 above.
(4) XSLT processor and its conformance with the XSLT standards: 1.0, 2.0, 3.0, or 4.0.
Comment: Well, it sounds as if you want to group `LoopSubNodeN` elements by the `ConstantElement` child element value, it is not clear whether you want to do that inside each `LoopNode` or for all `LoopNode`s. Processing all known elements sounds easy, you just select `*` or perhaps only `Element1 | Element2 | Element3 | Element4 | Element5` if there are other elements. For grouping see https://stackoverflow.com/tags/xslt-grouping/info.
Answer:

<xsl:key name="myKey" match="LoopSubNodeN" use="concat(generate-id(..), ConstantElement)"/>

<xsl:template match="LoopNode">
  <xsl:variable name="LoopNodeID" select="generate-id(.)"/>
  <xsl:copy>
    <xsl:element name="LoopSubNodeN">

      <xsl:for-each select="LoopSubNodeN[generate-id(.) = generate-id(key('myKey', concat($LoopNodeID, ConstantElement))[1])]">
        <xsl:element name="ConstantValue">
          <xsl:value-of select="ConstantElement"/>
        </xsl:element>
        <xsl:element name="LoopSubSubNode">
          <xsl:element name="Element1">

            <xsl:for-each select="key('myKey', concat($LoopNodeID, ConstantElement))">
              <xsl:value-of select="concat(LoopSubSubNode/Element1, ' [', LoopSubSubNode/Element2, ' ', LoopSubSubNode/Element3, ' ', LoopSubSubNode/Element4, ' ', LoopSubSubNode/Element5, '] ')"/>
            </xsl:for-each>
          </xsl:element>
        </xsl:element>
      </xsl:for-each>
    </xsl:element>
  </xsl:copy>
</xsl:template>

<xsl:template match="node()|@*">
  <xsl:copy>
    <xsl:apply-templates select="node()|@*"/>
  </xsl:copy>
</xsl:template>

Comment: What is the reason for using `xsl:element` e.g. `` to create result elements instead of using literal result elements with e.g. ``?
Comment: Hey @MartinHonnen,  Good question.  It's a force of habit for me as I don't usually want the namespaces carried along with new elements.  But, I refer MichaelMS to your answer from 2014 in case he wants the namespaces.  Thanks for pointing it out.  https://stackoverflow.com/questions/20947581/xslt-exclude-namespace-when-adding-new-elements
Comment: @John Ernst, thank you so much for your answer! It partially solves my task but there are two problems:

1. If I use the solution above I miss all subnodes (of course except LoopSubNodeN) in LoopNode;

2. root element may contain few LoopNode nodes and ConstantElement is reallly constant in all of them; so grouping by ConstantElement groups all Element1 .. Element5 withing ALL LoopNode nodes but I need to group them withng every LoopNode.

Maybe I was not specific enough when giving XML structure above. This comment is too short but I can provide you real XML if you please.
Comment: @MichaelMS Try this variation.  If this doesn't work for you, post the XML and desired results along with any further description.  The Muenchian method is a little harder to implement when what you really need is push programming.  But, I've kind of put the two together.  You should be able to adapt this to your liking.
Comment: @John Ernst, I corrected my initial message and tried to be more specific in giving XML structure.

Thank you so much for your help!


Suggestions for improving the fit of probability density

Question: I am comparing the error between wind turbine production and predictions from 24 hours ahead. The graphs below are using the normal distribution.
But can I do better?
Comment: Your two sets of graphs, the bottom one fitting better than the top... what are they?  Are you trying to say that the ones on the bottom are from simulated data?
Answer: Maybe use the laplace distribution, which has density
$$ \frac{1}{2s} {\rm exp} \left( -\frac{|x-\mu|}{s} \right ) $$
where $\mu \in \mathbb{R}, s > 0$ are parameters. As Wolfgang pointed out, your distribution appears to be symmetric but has higher kurtosis than the normal distribution; the laplace distribution has these properties and the QQ plot looks pretty similar to what you're observed from your data:
<code>library(VGAM)
x=rlaplace(1000)
qqnorm(x)
qqline(x)
</code>
(you will need to download the package VGAM). The logistic distribution could also work but the QQ plots don't agree with what you've observed as well.
Answer: You could look at Box-Cox transformations.  The boxcox function in the MASS package for R will compute a confidence interval on the value of lambda that gives the best transformation.  Combine that with what you know of the science to choose an appropriate transform.


Bases and pseudo-bases in topological spaces

Question: Let $X$ be a topological space and $x \in X$.

A base for $X$ at $x$ is a collection $\mathcal{B}$ of open sets of $X$, all of them having $x$ as one of its elements such that for every open neighborhood $U$, of $x$, there is a $B\in \mathcal{B}$ such that $B \subseteq U$.
A pseudo-base for $X$ at $x$, on the other hand, is a collection $\mathcal{B}$ of open sets, such that $\bigcap \mathcal{B}= \{x\}$.

For $T_1$ spaces, every base at a point is a pseudo-base at that same point.
However, I am having trouble coming up with examples of pseudo-bases that are not bases, so I would like some. Also, are there any sufficient conditions on $X$ that make these two notions coincide?
Answer: The character $\chi(x,X)$ of $x \in X$ is the least infinite cardinal $C$ such that there exists a base $B$ at $X$ whose cardinal is $\leq C.$ If $\chi(x,X)=\aleph_0$ for every $x\in X$ then $X$ is called first-countable.
If $X$ is $T_1$ then the pseudo-character $\psi(x,Z)$ of $x\in X$ is the least infinite cardinal $P$ such that $\{x\}=\cap F$ for some open family $F$ whose cardinal $\leq  P.$
We always have $\psi(x,X)\leq \chi(x,X)$ for a $T_1$ space $X$.
If $X$ is a metric space then $\psi(x,Z)=\chi(x,X)=\aleph_0.$ If X is a linear space we have $\psi(x,X)=\chi(x,X).$ To get $\psi(x,X)=\aleph_0$ and $\chi(x,Z)\geq \aleph_1$ for some $x\in X$ we need something less ordinary.
Let $\Bbb R$ have the usual (standard) topology and let $X$ be the quotient space $\Bbb R_{/\Bbb N}.$ Equivalently, $X=(\Bbb R$ \ $\Bbb N) \cup \{p\}$ with $p\not \in \Bbb R$ where:
(i). If $p\in S\subset  X $ then $S$ is open in $X$ iff $(S$ \ $\{p\})\cup \Bbb N$ is open in $\Bbb R.$
(ii).  If $p\ne S\subset X$ then $S$ is open in $X$ iff $S$ is open in $\Bbb R.$
We have $\psi(p,Z)=\aleph_0$ because $S_n=\{p\}\cup (\cup_{m\in \Bbb N}(m-1/n,m)\cup (m,m+1/n)\;)$ is open in $X$ for every $n\in \Bbb N$ and we have $\cap_{n\in \Bbb N}S_n=\{p\}.$
Let $B=\{B_n:n\in \Bbb N\}$ be a countable  open family in $X$ with $p\in B_n $ for every $n.$ For each $n$ there is a function $f_n:\Bbb N\to \Bbb R^+$ such that   $(-f_n(m)+m,f_n(m)+m) \backslash \{m\} \subset B_n$ for every $m\in \Bbb N.$
Let $g(m)=\frac {1}{3}\min \{f_n(m): n\leq m\}$ for each $m\in \Bbb N.$  Let $A=\{p\}\cup (\cup_{m\in \Bbb N}(-g(m)+m,g(m)+m)\;).$ Then $A \backslash \Bbb N$ is open in $X$ and $ p\in A\backslash  \Bbb N.$ But no $B_n$ is a subset of $A\backslash \Bbb N$ because  $n+\frac {2}{3}f_n(n)\in B_n$ \  $(A \backslash \Bbb N).$
So no countable open family $B$ can be a base at $p$ in $X.$
BTW. With the usual topology on $\Bbb R$ the Box-Product topology on $\Bbb R^{\Bbb N}$ also has countable pseudo-character and uncountable character but I think this answer is already long enough
Comment: Regarding the def'ns of $\chi$ and $\psi$, it has been said that "There are no finite cardinals in Point-Set Topology".
Answer: A not-too-enlightening example of a pseudo-base at a point which is not a local base at that point is the following. In the real line $\mathbb{R}$ consider the family
$$
\mathcal{B} = \{ ( - \tfrac 1n , \tfrac 1 n ) \cup (n,n+1) : n \in \mathbb{R} \}.
$$
$\mathcal{B}$ can be readily shown to be a pseudo-base at $0$, but it is clearly not a local base at $0$.
Similar to this, fix $V_{-1} = (1,2)$ and $V_{1} = (2,3)$, then $$\mathcal{B}^\prime = \{ \{ ( - \tfrac 1n , \tfrac 1 n ) \cup V_{(-1)^{n}} : n \in \mathbb{R} \}$$ is also a pseudo-base at $0$ which is not a local base at $0$.
These examples hint that the notions of (local) base and pseudo-base are difficult to make coincide for a point $x$ in a space $X$. Generalising the second example above, if there are two disjoint open sets $V , W \subset X$ such that $x \notin \overline{V} \cup \overline{W}$, then we can construct a pseudo-base at $x$ which is not a local base: Fix a local base $\mathcal{B}$ at $x$ and set $$\mathcal{B}^\prime = \{ U \cup V : U \in \mathcal{B} \} \cup \{ U \cup W : U \in \mathcal{B} \}.$$
The only T1-spaces I can think of where every pseudo-base at a point is also a local base are the one-point space and the two-point discrete space.
As DanielWainfleets's answer indicates, the importance is generally on the "cardinal functions" defined in terms of these notions.
Answer: Plainly, a countable $\text T_1$ space has a countable pseudo-base at every point. This is not true with "pseudo-base" replaced by "base".
As in my answer to this old question, define a topology on $\mathbb N=\{1,2,3,\dots\}$ by calling a set $S\subseteq\mathbb N$ open if
$$\text{either}\quad1\notin S\quad\text{or else}\quad\sum_{n\in\mathbb N\setminus S}\frac1n\lt\infty.$$
With this topology $\mathbb N$ is a regular Hausdorff space, also zero-dimensional and normal, and of course it has a countable pseudo-base at every point. However, it is easy to see that there is no countable base for the neighborhoods of $1$.


Adding the averages and standard deviations of different sets correctly

Question: I have $12$ balls with mean weight of $500$g, and S.D $25$g. I have $5$ balls with mean weight $200$g and S.D $10$g. If I combine all of them, is the mean just $8000\over17$ i.e. $$8000=500\cdot12+200\cdot10$$ and divided by $17$ since there are $17$ balls. What is the new S.D.? Is it just $$\sqrt{25\cdot12+10\cdot5}$$
Comment: how do you define the SD?
Comment: edited. I define them as weights, not percentages.
Comment: I got that. the thing is that the variance of a sample can be defined in two ways https://en.wikipedia.org/wiki/Variance#Population_variance_and_sample_variance
Answer:
For the mean: Yes, this approach is correct, but actually it should be $$500\cdot12+200\cdot5=7000$$ since in the second sample you have $5$ balls and not $10$.
For the standard deviation. One approach is to use the pooled standard deviation $s_p$ which is the root of the pooled variance $s_p^2$ with $$s^2_p=\frac{(n_1-1)s^2_1+(n_2-2)s^2_2}{(n_1-1)+(n_2-1)}=\frac{(12-1)25^2+(5-1)10^2}{(12-1)+(5-1)}$$


different quantities of coin denominations resulting in the same value

Question: The three coin denominations used in Coinistan have values $7$ cents, $12$ cents and $23$ cents.  Fareed and Krzysztof notice that their two Coinistan coin collections have the same number of coins and the same total value, but not the same number of $7$-cent coins.  What is the smallest possible value of Krzysztof's collection?
Ans.  192 cents.
Source:  MathCounts, 2021
We need to minimize the value, so it looks like one person will have no coins of one denomination (for example no $7$-cent coins, but a positive number of $12$- and $23$-cent coins).  The other person will have no coins of $2$ denominations and a positive number of coins of the third denomination (for example some positive number of $7$-cent coins only).
I drew up a list of products of $7$, $12$, and $23$ with residuals in mod of the other $2$ numbers.  So for example I wrote all the residuals of products of $7$ and $23$ in $\pmod {12}$ and so on for each pair of coins.
Eventually I looked at my list of residuals of products $7$ and $23$ and wrote down the combinations that resulted in a sum that was equivalent to $ 0 \pmod{12}$.  So for example, in my list I had seven $7$-cents and one $23$-cent coin yields $72$ cents which can be replaced with 6 $12$ cent coins for the same value.  But not the same number of coins.  ($8$ versus $6$.)  I continued down my list until I found that eleven $7$-cent coins and five $23$-cent coins yields a value of $192$ cents, and can be exchanged for sixteen $12$-cent coins.  Same number, same value.
This process was time-consuming, and I'm wondering if I'm missing an insight that would save me time here.  Thank you!
Answer: The only way to get an exchange equation is to rewrite some numbers of  low and high coins as the (sum of the numbers) middle coins. This means you want to solve
$$7x+23y=12z,\ \ x+y=z.$$
That is, $7x+23y=12(x+y),\ (23-12)y=(12-7)x.$ So it is $11y=5x$ with smallest solution $x=11,y=5.$ This gives the value $7\cdot 11+23 \cdot 5=192=12 \cdot 16.$   Note that as desired both are the same number of coins, i.e. $11+5=16.$
Comment: OMG, this is so elegant, thank you!
Comment: Glad you like it. I remember setting up such exchanges for US coins, so I could make up questions for a class I taught which had various answers. For example 6 coins as 5 pennies and 1 quarter or as 6 nickels. To get more exchanges I proceeded as in above answer but different coin values.


Similar as simple harmonic oscillator differential equation

Question: In some physics problem I got next differential equation: x''=kx
I know that simple harmonic oscillator problem are solved using complex numbers, but i don't know why solution is like: $x=A\cos\left(bt+d\right)$
I tried to solve this way.
$x''-kx=0$
$x=ae^{rt}$
$ar^2e^{rt}-kae^{rt}=0$
$r^2-k=0$
$$x=ae^{\pm\sqrt{k}t}$$
What did I do wrong?
Comment: For some basic information about writing mathematics at this site see, *e.g.*, [here](/help/notation), [here](//math.meta.stackexchange.com/q/5020), [here](//meta.stackexchange.com/a/70559) and [here](//math.meta.stackexchange.com/q/1773).
Comment: [This might be the solution.](https://math.stackexchange.com/q/1575291/1181491)
Comment: Note that $\mathrm e^x =\cos(-\mathrm i x)+\mathrm i \sin(-\mathrm i x)$.
Answer: The equation should be $x^{"}+kx=0$ where $k \ge 0$, in your case k should be negative and $r$ will have imaginary solutions so it brings sin and cos.


Exercise book to complement Mathematics for Machine Learning

Question: I was learning the book Mathematics for Machine Learning by Marc Peter Deisenroth. While the book is rigorous and well-structured, it lacks a great amount of exercise. Are there any similar resources that I can get my hands dirty? (In particular, the chapter for linear algebra and vector calculus will be great.
Answer: The companion webpage to the MfML book contains this link to additional exercises. Though there are only three questions on linear algebra (Ch. 2) and one question on vector calculus (Ch. 5). The webpage also contain links to third-party Jupyter notebooks that implements and visualises the examples used in the book if that is your thing.
The main text of the MfML book (link to PDF made available by the authors) also provided some textbook references, e.g. in Section 2.9:

There are many resources for learning linear algebra, including the textbooks by Strang (2003), Golan (2007), Axler (2015), and Liesen and
Mehrmann (2015).

I haven't check the referenced textbooks, but surely at least one of them would have contained more exercises.
Prior to this book being published, the recommended mathematical methods textbook for Computing students at Imperial College London (where Marc Deisenroth taught) is G. Stephenson (1973) Mathematical Methods for Science Students. Chapters 16, 17, and 19 (and their exercises) should be relevant for linear algebra and vector calculus.


How to Pass List of data from View to Controller

Question: I have List like below in .cshtml
@using (Html.BeginForm("About","Home"))
{

@for (int i = 0; i <= @Model.Count()-1;i++ )
{

        @Html.TextBoxFor(x => x[i].DeptId)

        @Html.TextBoxFor(x => x[i].DeptName)

 }

<input type="button" value="HitMe" onclick="Save()" />

}

The Save function will do the ajax method and serialize all the data and pass to controller.
Controller Code:
    [HttpPost]
    public ActionResult About(List<Dept> obj)
    {
        ViewBag.Message = "Your app description page.";

        return View();
    }

When i executed obj is null but if i change the  type="Submit" in obj i am getting the List data. So how to fill obj in ajax call.
Answer: You need to serialize form not div
@using (Html.BeginForm("About","Home",FormMethod.Post,new {id="frm_Test"}))
{
.....

...

}

In script provide Id of form to serialize


How to configure gmap in template file

Question: I override node display for content type Match Fixtures by creating node--match-fixtures.tpl.php file and put code below:
<code><?php
$location = $content['field_stadium'][0]['#locations'];
$stadium_map = array('id' => 'stadium_map',
             'latitude' => $location['latitude'],
             'longitude'=> $location['longitude'],
             'zoom'     => 13,
             'width'    => '100%',
             'height'   => '400px',
             'type'     => 'Satellite',
);

echo theme('gmap', array('#settings' => $stadium_map))
?>
</code>
But it show wrong map and also not 100% width. I use gmap and location module. What is the correct way?
Answer: If its showing the wrong map, you might be displaying the wrong view mode. Make sure you have set the gmap display for view mode full.

How to configure gmap in template file