Zend Framework 2 headscript

Question: It seems I remember that in Zend Framework, we could add styles/scripts via headScript in the action of a page. In Zend2, this doesn't seem to be an option.
I don't see much in the documentation about handling this.
Basically my question is; is it proper to add these styles/scripts in the view? Or is there there a new way to add them in the controller action?
Thanks
Comment: See the headScript() view helper -> http://framework.zend.com/manual/2.1/en/modules/zend.view.helpers.html#headscript-helper
Comment: Yes, I saw this... and I understand how it works in the layout, but what about adding scripts or styles to specific views? Is there a method available in the action? Should I just repeat this in the view? The documentation is not very clear.
Comment: Yes, the helper is available in views and layouts, I think the only caveat may be that you need to use prepend in views, but ymmv.
Answer: In your controller action:
$this
    ->getServiceLocator()
    ->get('viewhelpermanager')
    ->get('HeadScript')
    ->appendFile('/js/custom.js')
;

You could make this easier by creating an "invokable"  "service locator aware" controller plugin.
You can do that in your modules config file:
...
'controller_plugins' => array(
    'invokables' => array(
        'Head' => 'Application\Controller\Plugin\Head',
    )
),
...

Creating the "Head" class in module/Application/src/Application/Controller/Plugin/Head.php that implements ServiceLocatorAwareInterface and build some methods like javaScript() or styleSheet for example that simply grab the view helper and return it:
return $this
    ->getServiceLocator()
    ->getServiceLocator() // Main service Locator
    ->get('viewhelpermanager')
    ->get('HeadScript')
;

Then in your controller it's more like:
$this->Head()->javaScript()->appendFile('/js/custom.js');

You could get as fancy as you wanted about it though. Maybe even Magento style with the XML governing the layout per action.
UPDATE
Output is buffered if you're using the ZF2 MVC. So i've found that adding scripts and stylesheets to a page is best done from the template file attached to your view model:
$this->headScript()->appendFile('/js/custom.js', 'text/javascript');
$this->headLink()->appendStylesheet('/css/custom.css');
Keep it out of the controller since it is view related.
Answer: I'm don't understand what about Marshall House talk.
Plugin need implements PluginInterface. Why implements ServiceLocatorAwareInterface ?
Where paste this code?
return $this
->getServiceLocator()
->getServiceLocator() // Main service Locator
->get('viewhelpermanager')
->get('HeadScript');

Also AbstractPlugin (if extend from it) doesn't have getServiceLocator() methos. What it mean?
Main service Locator? Please write some example.
Comment: That would be the contents of a method like `javascript()` in the controller plugin.

Zend Framework 2 headscript


Dashboard is empty for roles apart from admin

Question: I want to create a role specific dashboard on drupal 7.
So I have added some blocks on the dashboard and also the "View dashboard" permission for this role.
However,when I login using the above role,the dashboard is empty.
What is the reason for this and how can I fix that?
P.S.Admin can see these blocks on dashboard
Answer: May be you have assign blocks to the region of non admin theme. If so, you have to assign the blocks to the region of admin theme(seven or enabled admin theme in your drupal system).


Algorithm runnning time $T(n) = \sqrt{n} \cdot T(\sqrt{n}) + \sqrt{n} $ using substitution

Question: I need to solve the following recurrence, only using the substituion method (CLRS):
$$ T(n) = \sqrt n \cdot T(\sqrt n) + \sqrt n $$
This is what I have done so far:

Changing variables
$$ m = \log_{2}n$$
$$ n = 2^{m} $$
$$ \log n = m $$
Updating the recurrence function, so that $T(2^{m}) = S(m)$

$$ T(2^{m}) = 2^\frac{m}{2} \cdot T(2^\frac{m}{2}) + 2^\frac{m}{2}$$
$$ S(m) = \frac{m}{2} \cdot T(\frac{m}{2}) + \frac{m}{2}$$
And then here, I'm not sure how to proceed nor if my argument is correct so far.
I tried to follow a similar example answered here, but I wasn't able to properly translate it.
Comment: Are you sure about $\sqrt n = m$? :) The substitutions $n = 2^m$ and $T(2^m) = S(m)$ are fine. First, write the correct recurrence relation for $S$ (why did $2^{m/2}$ outside of $T$ become $m/2$?). Then take $S(m) = 2^m F(m)$ and apply the master theorem.
Comment: @Maxim Thanks for pointing the mistake. $\log n = m$ should be. I have updated the question. I cannot use the Master Theorem here. Should be only by substitution.
Answer: Go a little further with $n = 2^{2^m}$.
Since $\sqrt{2^{2^m}} = 2^{2^{m-1}}$, this becomes
$T(2^{2^m}) = 2^{2^{m-1}}T(2^{2^{m-1}})+2^{2^{m-1}}$.
Letting $T(2^{2^m}) = s(m)$, this becomes
$s(m) = 2^{2^{m-1}}s(m-1)+2^{2^{m-1}}$.
Dividing by $2^{2^{m}}$ this is
$\frac{s(m)}{2^{2^{m}}} = \frac{s(m-1)}{2^{2^{m-1}}}+\frac{1}{2^{2^{m-1}}}$.
Letting $u(m) = \frac{s(m)}{2^{2^{m}}}$, this becomes
$u(m) = u(m-1)+ \frac{1}{2^{2^{m-1}}}$.
$u(m)$ converges to a constant $c$, so
$s(m) \to c2^{2^{m}}$ so
$T(2^{2^m})  \to c2^{2^{m}}$
or $T(n) \to cn$.
Putting this into the original equation, we get
$cn = \sqrt{n}c\sqrt{n}+\sqrt{n}$
which is approximately true.
To get a more accurate answer, let
$T(n) = c n+r(n)$
and see what you can find about
$r(n)$.
Comment: Thanks for answering. I'm trying to understand. Why is it that $n = 2^{2^{m}} $ and not $n = 2^{m} $ instead as I wrote it in my question?
Comment: Because that works with $\sqrt$. $2^m$ works with t(n) = a t(n/2) and $b^m$ works with $t(n) = a t(n/b).
Answer: Hint.
Using another approach, intending to obtain a comparison result, with
$$
\mathcal{T}(\cdot) = T\left(4^{(\cdot)}\right), z = \log_4 n,\ \ \mathbb{T}(\cdot) = \mathcal{T}\left(2^{(\cdot)}\right),\ u = \log_2 z
$$
we obtain the recurrence
$$
\mathbb{T}(u)=2^{2^u}\mathbb{T}(u-1)+2^{2^u}
$$
with solution
$$
\mathbb{T}(u)= 4^{2^u}C_0+4^{2^u}\sum_{k=0}^{u-1}4^{-2^k}
$$
After returning to $T(n)$ we have
$$
T(n) = n C_0 + n\sum_{k=0}^{\log_2(\log_4 n)-1}4^{-2^k}
$$


Prove by induction that $\sum_{r=0}^{n}\binom nr =2^k$

Question: I have to prove by induction that $$\sum_{r=0}^{n}\begin{pmatrix}n \\ r \end{pmatrix}=2^k$$, using the identity $\begin{pmatrix}n \\ r-1 \end{pmatrix}+\begin{pmatrix}n \\ r \end{pmatrix}=\begin{pmatrix}n+1 \\ r \end{pmatrix}$.
I'm fine with everything except the inductive step, where I only managed to get as far as $$\sum_{r=0}^{k+1}\begin{pmatrix}n \\ r \end{pmatrix}= \sum_{r=0}^{k}\begin{pmatrix}n \\ r \end{pmatrix}+\begin{pmatrix}n \\ k+1 \end{pmatrix}$$
I tried to then use the identity and substitute $\begin{pmatrix}n \\ r \end{pmatrix}=\begin{pmatrix}n+1 \\ r \end{pmatrix}-\begin{pmatrix}n \\ r-1 \end{pmatrix}$ but all this did was just take me around in a circle. I also couldn't substitute $2^k$ for $\sum_{r=0}^{k}\begin{pmatrix}n \\ r \end{pmatrix}$ since this didn't properly simplify to give $2^{k+1}$. However, I think that I have to obtain the expression $\sum_{r=0}^{k}\begin{pmatrix}n \\ r \end{pmatrix}$ since it simplifies to $2^{k+1}$. But I've not been able to obtain this in anyway so I'm wondering if anyone can guide in what I need to or what direction I need to take to complete the inductive step.
Answer: You're mixing up your $n$'s and $k$'s. Where you write:

$$\sum_{r=0}^{k+1}\begin{pmatrix}n \\ r \end{pmatrix}= \sum_{r=0}^{k}\begin{pmatrix}n \\ r \end{pmatrix}+\begin{pmatrix}n \\ k+1 \end{pmatrix}$$

That should be:
$$\sum_{r=0}^{k+1}\begin{pmatrix}{k+1} \\ r \end{pmatrix}= \sum_{r=0}^{k}\begin{pmatrix}{k+1} \\ r \end{pmatrix}+\begin{pmatrix}{k+1} \\ k+1 \end{pmatrix}$$
And the inductive hypothesis is:
$$\sum_{r=0}^{k}\begin{pmatrix}k \\ r \end{pmatrix}=2^k$$
And now when you use Pascal's identity you should be fine.
Answer: Assume this is true for base case id est $$2^n=\sum_{r=0}^n{n \choose r}$$So
$$2^{n+1}=2\cdot \sum_{r=0}^n{n \choose r}=2\cdot{n \choose 0}+2\cdot{n \choose 1}+...+2\cdot{n \choose n}={n \choose 0}+\left({n \choose 0}+{n \choose  1}\right)+...+\left({n \choose n-1}+{n \choose n}\right)+{n \choose n}$$
Using your identity
$${n \choose 0}+{n \choose 1}={n+1 \choose 1}$$
Doing this with every term
and noting that ${n \choose 0}={n+1 \choose 0}$ and ${n \choose n}={n+1 \choose n+1}$
gives $$\sum_{r=0}^{n+1}{n+1 \choose r}=2^{n+1}$$
Answer: A possible way of writing down the proof is
\begin{align}
\sum_{i=0}^{n+1} \binom{n+1}{i}
&=
\sum_{i=0}^{n+1} \left(  \binom{n}{i} + \binom{n}{i-1}\right)
\\&=
\sum_{i=0}^{n} \binom{n}{i} + \sum_{i=1}^{n+1} \binom{n}{i-1}
\\&=
\sum_{i=0}^{n} \binom{n}{i} + \sum_{j = 0}^{n} \binom{n}{j}
\\&= 2^{n} + 2^{n} = 2^{n+1},
\end{align}
with the change of variable $j = i - 1$
$$
\sum_{i=1}^{n+1} \binom{n}{i-1} = \sum_{j = 0}^{n} \binom{n}{j}.
$$


the surface is the part of hyperbolic paraboloid $z=xy$ which is cut by the cylinder $x^2+y^2=4$ and sketch the graph

Question: Calculate the surface integral of a scalar function $f=z$
$I=\int {f\cdot ds}$
the surface is the part of hyperbolic paraboloid $z=xy$ which is cut by the cylinder $x^2+y^2=4$ and sketch the graph
How am i supposed to start? i am confused with all these shapes.
How can i find the limits i have to use?
Answer: Note that you are integrating on the surface $z=xy$ where $x^2+y^2\leq4$, in other words on the hyperbolic paraboloid where $(x,y)$ has length $\leq2$. First of all, you need a parameterization of your surface (let's call it $S$), for example:
$$
\phi: [0,2\pi]\times (0,2]\longrightarrow S\\
(\theta,\rho)\mapsto \left(\rho\cos(\theta),\rho\sin(\theta),\frac{\rho^2}{2}\sin(2\theta)\right).
$$
Now you should know that any surface integral in "regular" condition is defined by
$$
\int_Sfd\sigma=\iint_Df(\phi(u,v))\,|d_u\phi\wedge d_v\phi|du\,dv,
$$
where $\phi:D\to S$ is a parameterization of the surface $S$, "$\wedge$" is the cross-product in $\mathbb{R}^3$ and "$|\cdot|$" is the usual euclidean norm in $\mathbb{R}^3$ (this is a classical definition and you can find it in most basic analysis books). Hence in this case we have
$$
\int_Sfd\sigma=\int_0^{2\pi}d\theta\int_0^2d\rho \frac{\rho^2}{2}\sin(2\theta)\rho\sqrt{\rho^2+1}.
$$
Try to calculate $|d_u\phi\wedge d_v\phi|$ by yourself, is not hard, just a little bit time expensive.

here the plot of your surface... a Pringles, as you can see.
Comment: thank you so much


Array[i] = scnr.nextInt(); causing Exception in thread "main" java.util.NoSuchElementException

Question: I can't figure out why i keep getting this error. The code is supposed to output the middle integer when given a list of integers in an odd number. A negative value at the end ends the input. This line of code is throwing a main exception error and I can not figure out why. I have also tried using a temp varialbe. userValues[i]=scnr.nextInt();
Exception in thread "main" java.util.NoSuchElementException
    at java.base/java.util.Scanner.throwFor(Scanner.java:937)
    at java.base/java.util.Scanner.next(Scanner.java:1594)
    at java.base/java.util.Scanner.nextInt(Scanner.java:2258)
    at java.base/java.util.Scanner.nextInt(Scanner.java:2212)
    at LabProgram.main(LabProgram.java:16)

Here is my code.
import java.util.Scanner;

public class LabProgram {
   public static void main(String[] args) {
      Scanner scnr = new Scanner(System.in);
      int[] userValues = new int[10];  // Set of data specified by the user
      int count = 0;
      int temp = 0;

for (int i=0; i<10; i++)
{
      if (scnr.hasNextInt());
      {
           userValues[i]=scnr.nextInt(); // this line is giving me the error
      }

      if (userValues[i]>=0)
      count = count +1;
}

if (userValues[10]==0) {
int outp = count / 2 + 1;
System.out.println(userValues[outp]);
//}

else
System.out.println("Too many inputs");

   }
}

Comment: Typo. Remove the semicolon at `if (scnr.hasNextInt());` Note that if the next input is not an `int`, you need to **consume** it or you won't get any values.
Comment: If you are accessing 10th index of array , It should be 9 because size is 10
Comment: that was it, thank you Elliott!
Answer:
Remove semicolon from If condition.
for (int i=0; i<10; i++)
 {
  if (scnr.hasNextInt()) //remove semicolon

   {
   userValues[i]=scnr.nextInt();   error
  }

  if (userValues[i]>=0)
      count = count +1;
 }

Array size is 10.
If you are accessing 10th index of array, It should be 9 or You will get ArrayIndexOutOfBoundsException exception
   int[] userValues = new int[10]; //array size is 10

   if (userValues[9]==0) {
        int outp = count / 2 + 1;
         System.out.println(userValues[outp]);
       }


MVC3 Force Validation of Hidden Fields

Question: I need to enable the validation of hidden fields using ASP.net MVC3 unobtrusive validation.
The reason behind this is a jquery plugin which hides the original input field to show something fancier. But this disables validation of the field as it becomes hidden.
I tried to use the following code but without success.
<code>$("form").validate({
    ignore: ""
});
</code>
Thanks
Answer: With a hint from this Question I was able to manipulate the options of the unobtrusive validator object.
<code>var validator = $("#myFormId").data('validator');
validator.settings.ignore = "";
</code>
Comment: Nice work this has been driving me nuts for a very long time :-)
Comment: Awesome!!!. I was looking for an answer. Hmm I need to start looking more into inner workings for MVC3 unobtrusive plugin.

MVC3 Force Validation of Hidden Fields


SAP HANA SQL - Relative Date in Query

Question: We are trying to build better dynamic reporting in our SQL queries from SAP HANA. Currently we either have to hard code the values, or we have a python tool which we update the values, but we are looking to point Tableau Server direct to SAP HANA and not have to go in and update the date ranges we are looking at.
We are looking to get a dynamic date selection for current and prior year where the structure is YYYYMMM in both the FROM and TO functions.
FROM "_SYS_BIC"."fvr.Revenue.FVRRsummary/ST_FVRR_COPA" (
'PLACEHOLDER' = ('$$IP_FROM_FISCAL_YR_PER$$', '2019001'),
'PLACEHOLDER' = ('$$IP_TO_FISCAL_YR_PER$$', '2020012')

Answer: There's no need to use external tool to update parameter's values, because HANA Calculation View has ability to calculate parameter's dafault value (e.g. when no external value passed to it from SQL/MDX).
You can use simple calculations to set default value for parameter in parameter definition screen. They can be based on constants, some other parameter's value or meta-information (like current date, logon language).
For your case you can use a parameter type Direct and set default values as follow:

IP_FROM_FISCAL_YR_PER: format(addmonths(now(), -12), 'yyyy"001"').
IP_TO_FISCAL_YR_PER: format(now(), 'yyyy"012"').
Answer: Use this sample query for HANA
-----*******
do begin
DECLARE DT TIMESTAMP;
DT:='2005-03-31';
SELECT  CASE WHEN (MONTH(:DT)) <= 3
THEN cast((YEAR(:DT))-1 AS varchar)     || '-' || RIGHT(cast((YEAR(:DT)) AS varchar)   ,2)
ELSE
cast((YEAR(:DT)) AS varchar)  || '-' || RIGHT(cast((YEAR(:DT)) AS varchar)   ,2)+1 END AS "FYear"
FROM "DUMMY";
END
;
Comment: As it's currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer).

SAP HANA SQL - Relative Date in Query


Conceptual questions on Estimation theory: Beginner level

Question: I have just started to study Estimation theory and following the book "Fundamental of Statistical Signal Processing" by Steven M. Kay Vol 1. Most of the examples are based on the assumption that data follows a Gaussian distribution. COnsider, the example of estimating an unknown parameter $A$ from the relation: $x[n] = A + w[n]$ where w[n] is said to be $i.i.d$ random gaussian noise of known variance and zero mean. I have few conceptual questions and would appreciate intuitive notion behind them
Q1: Performing, $x[n]-w[n] = A$ would yield the unknown parameter A since w[n] is known. Then why does one need to consider the estimation using the estimator $\hat{A} = \frac{1}{N}\sum_{n=0}^{N-1}x[n]$ (Pg 12, Sec 2.3 Unbiased Estimators)
Q2: In general, does the number of samples, n play any role in estimation? Say n= 10 and n=1000, would this consideration affect the possibility of finding better estimates?
Q3: In general, why do we consider the samples and the noise to be $i.i.d$ ?? Is it ever possible that the samples are not iid? If so then when are they correlated?
Thank you
Answer: Q1: you know the distribution of $w_n$, you don't know the value of $w_n$ for a give $n$. For a stupid example, you know that when you toss a coin $P(\text{head})=50\%$, but you don't know what the result of the next toss will be.
Q2: of course. $\hat{A}=\frac{1}{N}\sum_{n=1}^N x_n$, so its expected value is:
$$E\left[\hat{A}\right]=E\left[\frac{1}{N}\sum_{n=1}^N x_n\right]=\frac{1}{N}\sum_{n=1}^N E[x_n]\overset{iid}{=}\frac{1}{N}\sum_{n=1}^N E[x]=\frac{1}{N}NE[x]=E[x]$$
but
$$\text{Var}\left(\hat{A}\right)=\text{Var}\left(\frac{1}{N}\sum_{n=1}^N x_n\right)\overset{ind}{=}\frac{1}{N^2}\sum_{n=1}^N\text{Var}(x_n)\overset{id}{=}\frac{1}{N^2}N\text{Var}(x)=\frac{\text{Var}(x)}{N}$$
I.e. $\hat{A}$ is a good (unbiased) estimate, but its uncertainty (variance) decreases as $N$ increases. For another stupid example, if you get 2 heads in three tosses ($\hat{A}=2/3$) you can't say that the coin is unbalanced, but if you get 2000 heads in 3000 tosses ($\hat{A}$ is still $2/3$)... it's another matter!
Q3: because the iid assumption makes all simpler ;-) Samples may be not iid (e.g. in multistage sampling) and $x_n$ may be correlated to $A$. In such cases you have to use more complex estimation strategies, but learning the simpler ones at first is better.
Comment: If each $w_n$ has a normal distribution with zero mean ($E[w_n]=0$ for all $n$) and the same variance ($\text{Var}(w_n)=\sigma^2$ for all $n$ - this is called _homoskedasticity_), then they are identically distributed. If they are independent, then $\text{Cov}(w_i,w_j)=0$ when $i\ne j$, i.e. they are not _autocorrelated_. Noise is tipically iid in experimental settings, when a measurement is repeated several times with the same instrument. If $A$ is not stochastic and $w_n$ is iid, then $y_n$ is iid because it's just a linear transformation of $w_n$.
Comment: Thank you for your reply. Could you kindly elaborate the significance of iid? Why do we call independent and identically distributed? Under what circumstances or when is noise iid? What are the features for a signal to be labelled as iid?
Comment: For the same question I had a doubt what if we need to estimate the variance of $w$ when $A$ is known to be rayleigh fading channel?


Rudin W. Principles of Mathematical Analysis page 256

Question: https://notendur.hi.is/vae11/%C3%9Eekking/principles_of_mathematical_analysis_walter_rudin.pdf
(37) $\ \int_{\phi} cw =c\int_{\phi} w$
He says by (37),
(39)$\ \int_{\phi} (-w) =-\int_{\phi} dw$
How does property (39) Come about in page 256? I don't think he even defined the differential of a differential form.
Comment: Looks to me like a typo; should be $\int_\phi(-w)=-\int_\phi w$.
Comment: It's a typo: the differential of an $n$-form is an $n+1$-form, which is not defined on an $n$-dimensional surface
Answer: To get this off the unanswered queue,

Looks to me like a typo; should be $\int_{\phi}(-w)=-\int_{\phi}w$.

Answer by kimchi lover


Question about $o$, $O$ and $\sim$

Question: Let $f$ and $g$ be functions defined on real line and let $g(x)\ne 0$ from some sufficiently large $x$.
Please let me know if this is correct:

$f\sim g \iff \lim_{x\rightarrow\infty}\frac{f(x)}{g(x)}=1$
$f=O(g) \iff \lim_{x\rightarrow\infty}\frac{f(x)}{g(x)}=c$, where $c$ is some positive constant
$f=o(g) \iff \lim_{x\rightarrow\infty}\frac{f(x)}{g(x)}=0$
Comment: I thought you could define these for any limit. That is, you could say $f \sim g$ as $x\rightarrow -\infty$ as well. I could be remembering incorrectly though...
Comment: $f = O(g)$ is $\limsup |f/g| < \infty$
Answer: Not quite. You should have

$f\sim g \iff \lim_{x\rightarrow\infty}\left|\frac{f(x)}{g(x)}\right|=1$
$f=\Theta(g) \iff \lim_{x\rightarrow\infty}\left|\frac{f(x)}{g(x)}\right|=c$, where $c$ is some positive constant
$f=O(g) \iff \lim_{x\rightarrow\infty}\left|\frac{f(x)}{g(x)}\right|=c$, where $c$ is some non-negative constant
$f=o(g) \iff \lim_{x\rightarrow\infty}\left|\frac{f(x)}{g(x)}\right|=0$

Also, it is not strictly necessary that we take these limits as $x \to \infty$, but that part is context dependent.
Comment: In $f = O(g)$ it is a limsup. And in $f = \Theta(g)$ it is $0 < \liminf \le \limsup < \infty$.

Question about $o$, $O$ and $\sim$


Can AIC determine which data better fit the same model?

Question: Many moons ago, I asked how to differentiate between two very similar non-linear fits and which was better.  Finally got that all straightened out after many headaches and three different software packages -- calculating AIC, AICc, and BIC and all give a consistent result.
Now I'm trying to apply a slight modification to the data and re-fit.  The question is, since $\chi^2$ is fairly useless on very non-linear models, can I use AIC to tell me if the original data or new data are better fits to that model?  As in, I use an $f(x)$ model, fit it with dataset1, and then I fit the SAME model to dataset2, and I calculate AIC/AICc/BIC of both fits.  Is that a meaningful comparison, or can they only be used to rate between two different fits to the same data?
Comment: Why not simply compare $s^2$?
Comment: Sorry, not a stats person ... $s^2$ is ... ?
Comment: The residual standard error. Essentially, the standard deviation of the residuals. It's a measure of how close the points are to your nonlinear model. It, or $s$, should be an output of your nonlinear fit.
Answer: The comparison is utterly meaningless.
Consider, for instance, fitting iid data $\mathbb{x} = (x_1, \ldots, x_n)$ to a location-scale family having a continuous pdf
$$f(x; \mu, \sigma) = f\left(\frac{x-\mu}{\sigma}\right) / \sigma.$$
The log likelihood for these data equals
$$\Lambda(\mathbb{x}; \mu, \sigma) = \sum_{i=1}^n \log \left(f\left(\frac{x_i-\mu}{\sigma}\right)/\sigma\right) = -n \log(\sigma) + \sum_{i=1}^n \log f\left(\frac{x_i-\mu}{\sigma}\right).$$
Because $\frac{x-\mu}{\sigma} = \frac{\alpha x-\alpha\mu}{\alpha\sigma}$ for any positive real number $\alpha$, $(\hat{\mu}, \hat{\sigma})$ maximize the log likelihood for $\mathbb{x}$ if and only if $(\alpha \hat{\mu}, \alpha \hat{\sigma})$ maximize the log likelihood for a corresponding dataset $(\alpha x_1, \ldots, \alpha x_n)$ obtained by rescaling the original data.  This is tantamount to a change in their units of measurement, so the "fit" to the model cannot be any better or worse.  However,
$$\Lambda(\mathbb{x}; \hat{\mu}, \hat{\sigma}) = n\log(\alpha) + \Lambda(\alpha\mathbb{x}; \alpha\hat{\mu}, \alpha\hat{\sigma}).$$
It follows that we may change the optimal value of the log likelihood by any arbitrary amount $n\log(\alpha)$ by means of an appropriate choice of $\alpha$ without changing the fit (at least not in any statistically reasonable sense).  For instance, if your data are lengths measured in meters and you were to re-express those lengths in kilometers, you would thereby increase the maximum log likelihood by $n\log(1000)$ without changing the "fit."
Because both AIC and BIC differ from the optimal value of $\Lambda$ by functions depending only on $n$, which does not change, the same conclusion holds for them, too.
Answer: Given the model has stayed the same, the number of parameters component of AIC is irrelevant. Than means the remaining component of the AIC is the maximised log likelihood.
So if the new AIC < old AIC then the log likelihood of the data under the model should have increased.
I'm not sure what this tells you in the case of having changed the data, but I assume you have your reasons.
Comment: In plain English, if the log likelihood of the data increased (as in AIC decreased), then that means ... ?  FYI, the reason for slightly modifying the data is that I have what I measured, but some folks think that one should apply a dynamic correction based on location.  I want to be able to say whether that makes the fit better or not.


A question from the proof of topologists sine curve being not path connected

Question: Let $S = \bigl\{ (x,\sin\frac{1}{x} ) : 0 < x \le 1 \bigr\} \cup \bigl\{ (0,y) : -1 \le y \le 1 \bigr\}$. Show that $S$ is connected but not pathwise connected.
Consider the proof below:

Q 11.8 It is clear that the set $\Gamma=\{(x,\sin(1/x)) : 0<x\leq1\}$ is pathwise connected and therefore connected. So $\overline\Gamma$ is connected. But $\overline\Gamma=S$ (Q 3.4). So $S$ is connected. Now suppose there exists a continuous path $f\colon[0,1]\to S$ that joins $(0,0)$ to some point of $\Gamma$. Let $r=\sup(f^{-1}(S\setminus\Gamma))$. Note that $f^{-1}(S\setminus\Gamma)$ is closed because $S\setminus\Gamma$ is closed, so that $f(r)\in S\setminus\Gamma$. So $r<1$ because $f(1)\in\Gamma$ by hypothesis. Since $f$ is continuous at $r$, there exists $\delta\in(0,1-r]$ such that $f([r,r+\delta])$ is included in the ball $B$ of radius $1/2$ around $f(r)$. It is easy to check that the connected component of $B\cap S$ that contains $f(r)$ is $B\cap(S\setminus\Gamma)$, so that $f(r+\delta)\in S\setminus\Gamma$, contradicting the definition of $r$. So there is no such continuous path $f$.

I couldn't understand why the connected component of $B \cap S$ that contains $f(r)$ is $B \cap (S\setminus\Gamma)$ ?
Could someone please give me some insight.  Thank you for reading through
Comment: For (i) the answer is yes. For (ii) it follows from the fact that $S\cap B$ **is not** locally connected for sufficiently small $B$, i.e. a ball of radius at most $1$ (that's because diamater is at most $2$ and $\Gamma$ oscilates between $x=1$ and $x=-1$ lines, the distance between them is $2$) Actually if you take the set $A=\{0,1,1/2,1/3,\ldots, 1/n,\ldots\}$ then $S\cap B$ is homeomorphic to $(-1,1)\times A$. Connected components of that set are line segments $(-1,1)\times\{a\}$. I know this is not a formal proof, that's why I leave it as a comment.
Comment: Please stop making trivial edits to artificially bump your question. https://math.meta.stackexchange.com/questions/23056/is-it-bad-etiquette-to-make-trivial-edits-for-more-views
Comment: @AlexProvost would you be kind enough to provide me with some insight. I have been stuck for almost 4 days now. The edits were never intended to be rude to anyone. And I don't go to school for some reasons. I pick up books and self study. For some, stack exchange is the only way. Thanks
Answer: A standard method to show that a set $C$ is the connected component of a point $p\in C$ (in some topological space $X$) consists of two parts,

showing that $C$ is connected, and
showing that every $q \notin C$ can be separated from $p$, i.e. there are disjoint open sets $U_q,V_q$ with $p \in U_q$, $q \in V_q$, and $X = U_q \cup V_q$.

The first part is rather simple here. $L = \{0\} \times [-1,1] = S \setminus \Gamma$ is a convex subset of $\mathbb{R}^2$, the ball $B$ is also a convex subset of $\mathbb{R}^2$, hence their intersection is a convex subset of $\mathbb{R}^2$. Convex sets in $\mathbb{R}^d$ are path-connected, hence connected. So $B \cap L = B \cap (S\setminus \Gamma)$ is a connected subset of $X = B \cap S$ that contains the point $p = f(r)$.
It remains to show that every point of $B \cap \Gamma$ can - in $B \cap S$ - be separated from $p$. The fundamental idea to see this is that the graph $\Gamma$ must leave the ball $B$ between the point $q = (x_0, \sin (1/x_0))$ and the line segment $L$ because $\sin (1/x)$ has infinitely many oscillations of amplitude $2$ in the interval $(0,x_0)$, and the radius of the ball is too small for it to contain points with second component $1$ as well as points with second component $-1$. And if $(t, \sin (1/t)) \in \Gamma \setminus B$ for some $0 < t < x_0$, then the open half-planes $H_1 = \{ (x,y) : x < t\}$ and $H_2 = \{(x,y) : x > t\}$ separate $p$ from $q$. Clearly we have $H_1 \cap H_2 = \varnothing$, $p \in U_q := H_1 \cap X$, and $q \in V_q := H_2 \cap X$. It remains to see that $U_q \cup V_q = X$, that is, that $X = B \cap S$ contains no point with first component $t$. But since $t > 0$ there is only one point with first component $t$ in $S$, namely $(t, \sin (1/t))$. And we specifically demanded that this point lie outside $B$, so we have our separation showing that $q$ does not lie in the connected component (with respect to $X$) of $p$. Since $q \in X \setminus (B \cap L) = B \cap \Gamma$ was arbitrary, it follows that indeed $B \cap L$ is the connected component of $f(r)$ in $B \cap S$.
We have not yet proved our assertion that $\Gamma$ leaves $B$ (infinitely often) between the point $(x_0, \sin (1/x_0))$ and the line segment $L$. For $n \in \mathbb{N}$ define
$$a_n := \frac{1}{\bigl(n + \frac{1}{2}\bigr)\pi}.$$
Then $0 < a_n < 1$ for all $n$, and $a_n \to 0$. Also $\sin (1/a_n) = (-1)^n$ and hence the distance between $(a_n, \sin (1/a_n))$ and $(a_{n+1}, \sin (1/a_{n+1}))$ is larger than $1$, so at most one of these two points can lie in $B$. Pick $t = a_n$ for an $n$ sufficiently large that $a_n < x_0$, and such that $(a_n, \sin (1/a_n))\notin B$.
Comment: Thank you very much for replying. Could I ask you some queries. I understand that for a sufficiently close $x_0$ to $0$, the graph $\Gamma$ must leave the ball  $B$ between the $q = (x_0, \sin (1/x_0))$ and the line segment $L$. However, how do we know that   , $p \in U_q := H_1 \cap X$, and $q \in V_q := H_2 \cap X$. Thanks
Comment: I mean, I am unable to visualize where $p$ and $q$ are
Comment: $p = f(r)$ is a point on the line segment $L$, so its $x$-coordinate is $0$. Since the $t$ determining the open half-planes $H_1,H_2$ is positive, we have $p \in H_1$. And since we chose $t$ to be smaller than $x_0$, we have $q \in H_2$. Since $p$ and $q$ are by assumption points of $X$, we have $p \in H_1 \cap X$ and $q \in H_2 \cap X$. And finally, since we chose $t$ so that $(t,\sin (1/t))$ does not belong to $X$, it follows that each point in $X$ lies in one of $H_1$ and $H_2$, so $H_1\cap X$ and $H_2\cap X$ is a decomposition of $X$ into two disjoint nonempty open sets.
Comment: okay .. does $q$ belong to the ball $B$?
Comment: Yes. We want to determine a connected component of $X = B \cap S$, so we're only interested in points in $B$. We wouldn't consider $q$ if it belonged to $S\setminus B$.
Comment: Thank you very much for the wonderful solution. I spent a bit of time understanding it but it opened many other concepts for me.


Replacement for _drush_file_private_path()

Question: I'm trying to get File Permissions working in Drupal 8.9 with Drush 9. The old code calls _drush_file_private_path(), which doesn't exist anymore, and _drush_file_public_path() is probably a no-go as well.
What is the proper way to do the following in Drush 9?
define('DS', DIRECTORY_SEPARATOR);

// Define default paths and variables.
$default = 'sites' . DS . 'default';
$private = $default . DS . 'private';
$files = $default . DS . 'files';
$directories = array();

// Check for Private Files subdirectory.
$private_directory = _drush_file_private_path();
if (empty($private_directory)) {
  $private_directory = $private;
}
$directories[] = $private_directory;

// Check for Public Files subdirectory.
$public_directory = _drush_file_public_path();
if (empty($public_directory)) {
  $public_directory = $files;
}
$directories[] = $public_directory;

As an additional note, it would be amazing if a resource existed to see all deprecated/removed functions and their equivalent replacements. I can't even get decent results when using a search engine and the function name.
Comment: @leymannx Yeah, that works. Including the word "deprecated" when searching seems to improve the results significantly. Thanks. Consider writing an answer.
Comment: It should also be noted that DuckDuckGo doesn't return good search results, but Google does.
Comment: When I google those functions together with the word "deprecated" I come to https://github.com/drush-ops/drush/pull/2654/files#diff-c1ffcbd9df5e90cffe2b7be05366d1b6L335-L341. Have you tried `\Drupal\Core\StreamWrapper\PrivateStream::basePath()` and `\Drupal\Core\StreamWrapper\PublicStream::basePath()` already?
Comment: No there is noch such resource. Simply scan the Drush codebase to look for similar patterns.
Comment: Yep, that's true. I have DuckDuckGo as default search engine but for work-related stuff most of the time I have to search via Google (with a logged in dummy account to have even better results later). I have `g` as keyword in the address bar for Google Search and then only have to type `g` and then press tab and can enter the search query I want to feed to Google.
Answer:
_drush_file_private_path()
_drush_file_public_path()

in the end were just wrapper functions of

\Drupal\Core\StreamWrapper\PrivateStream::basePath()
\Drupal\Core\StreamWrapper\PublicStream::basePath()

And you probably get the same from

\Drupal::service('file_system')->realpath('private://')
\Drupal::service('file_system')->realpath('public://')


Is console.debug faster than console.log?

Question: Here's what I tried:
const log = () => {
    console.time("Log");
    console.log("Test");
    console.timeEnd("Log");
}

const debug = () => {
    console.time("Debug");
    console.debug("Test");
    console.timeEnd("Debug");
}

When I run these results are as follows:
Test
VM406:4 Log: 0.06396484375 ms
Test
VM500:4 Debug: 0.059814453125 ms

And most of the time I see debug having a slight edge on log. Is it just co-incidence or debug is actually faster than log? And if so should we just stop using log at all cases and use debug instead?
Comment: Total coincidence.
Comment: Pointless question. If you're producing output for debugging purposes then performance is not the issue.
Comment: [Which is faster?](//ericlippert.com/2012/12/17/performance-rant)
Comment: You're jumping to conclusions.  You're making a hasty generalization about performance from a terrible tournament of test cases.  Just because Adam beat Bob in a race doesn't mean you can predict the outcome of every future race between Adam and Bob.
Answer: No, the log level is handled as a string within the console object, and there is no reason to think that debug is faster than log.
The fact that trying to execute your code is likely to reproduce the output is  due to the fact that log is executed before debug, and I can suppose that most of the internal objects of console gets cached by the JavaScript engine. For this reason, the second execution will always be a bit faster than the first

const log = () => {
    console.time("Log");
    console.log("Test");
    console.timeEnd("Log");
}

const debug = () => {
    console.time("Debug");
    console.debug("Test");
    console.timeEnd("Debug");
}

log();
debug();

const log = () => {
    console.time("Log");
    console.log("Test");
    console.timeEnd("Log");
}

const debug = () => {
    console.time("Debug");
    console.debug("Test");
    console.timeEnd("Debug");
}

debug();
log();


toolchain parameter in gradle

Question: My question is about toolchain.languageVersion.set(JavaLanguageVersion.of(17)) parameter in gradle.
I have java project written in Java 8 and built using gradle 6.7:
cat build.gradle

plugins {
    id 'java'
    id 'application'
    id 'com.palantir.docker' version '0.25.0'
}

I have upgraded java 8 to java 17 by adding toolchain.languageVersion.set(JavaLanguageVersion.of(17)) parameter to build.gradle.
This update forced me to upgrade gradle from 6.7 to 8.1.1, as well as update the version of one of the plugins. Putting all together, build.gradle file looks like this:
plugins {
    id 'java'
    id 'application'
    id 'com.palantir.docker' version '0.35.0' //update version from 0.25.0 to 0.35.0
}

java {
    toolchain {
        languageVersion.set(JavaLanguageVersion.of(17))
    }
}

The toolchain parameter tells gradle to use java 17 for running gradle-tasks, as well as to set source compatibility and target compatibility parameters.
When I have java 17 installed on my local machine - the build is successful, but if I use java 8, then I get an error:
"java.lang.UnsupportedClassVersionError: com/palantir/gradle/docker/DockerComponent has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0"
It's wrong behaviour, because the toolchain config should resolve this problem.
How can I fix this?
P.S.
There is the same question of gradle site but without an answer:
https://discuss.gradle.org/t/specifying-gradle-version-and-java-toolchain-version-isnt-enough/41111
Also I have read an article about toolchain parameter:
https://stefma.medium.com/sourcecompatibility-targetcompatibility-and-jvm-toolchains-in-gradle-explained-d2c17c8cff7c
There are 3 interesting paragraphs there:

With this setup, it "no longer matters" which JDK version you use to
run Gradle (tasks). You can even use your locally installed JDK in
version 8. Gradle will detect that it should use a JDK in version 17
to build (compile, test, etc.), so it will download it for you and
store it in ~/.gradle/jdks for later reuse.
The attentive reader may notice the double quotes I put around no
longer matters, in the section above. This is intentional, because the
catch to all of this, is that it does matter which JDK you have
installed locally (and on the continuous integration server machine)
to run Gradle (tasks).
As mentioned at the beginning of this blog, AGP 8.0 requires Java 17.
And that is what it means. This doesn't mean that the source code or
target (bytecode) needs to be written in version 17, it means that the
AGP itself requires Java 17, since it is compiled with a JDK in
version 17, or at least targetCompatibility is set to version 17.

But I didn't understand them because they condratict each other
Answer:
java.lang.UnsupportedClassVersionError:
com/palantir/gradle/docker/DockerComponent has been compiled by a more
recent version of the Java Runtime (class file version 55.0), this
version of the Java Runtime only recognizes class file versions up to
52.0

The toolchain parameter tells gradle to use java 17 for running gradle-tasks, as well as to set source compatibility and target compatibility parameters.

When building Java projects, there are multiple instances of JVMs running.
The first JVM process is Gradle itself. Gradle is a Java program, and therefore needs a JVM instance to execute in. This is whatever version you have installed globally on your machine.
Next, for any compilation, running, or testing of your own Java project, Gradle spins up a new JVM process for each of those. This JVM process does not need to be the same JVM version that the Gradle process itself is running with. That is where the toolchain comes it. It is only for the child processes that are spawned when Gradle needs to run, for example, compilation or tests. Gradle will download a JDK via the toolchain functionality only for those child JVM processes that are used for working with your own Java code.
Gradle will not download its own JDK to execute itself in because it needs a pre-installed JDK in order to parse its own files and download the toolchain JDK.
The error you are getting is because you need to have at least JDK 11 to use that particular version of the com.palantir.docker plugin (https://docs.oracle.com/javase/specs/jvms/se20/html/jvms-4.html#jvms-4.1-200-B.2), but lets say that you have JDK 11 pre-installed on your system. Here would be the sequence of events:

You execute the Gradle command: gradle compileJava

JVM 11 process spins up on your machine running Gradle

Gradle parses its own files, downloads the plugin JARs, and executes the
plugins

Gradle looks at toolchain settings and checks to see if you have version JDK 17 installed already on your system

If not, Gradle downloads a version JDK 17

Gradle (JVM 11 process) spawns a child Java compile process (via the
compileJava task) from the JDK 17 that it downloaded

Your code is compiled with the Java 17 compiler

The Java 17 compiler exits

The compileJava task (in JVM 11 process) finishes

The main Gradle program (in JVM 11 process) finishes

JVM 11 process exits

The command prompt is returned to you

So, in summary, the toolchain has no bearing on the main Gradle process. Gradle will execute the downloaded JDKs from tool chain as child processes.
Comment: so, to run the task `gradle build`, not my local jdk is used, but the one that gradle will download itself based on the toolchain. It should run the `gradle build` command on java17, and it doesn't matter which java I have installed. Why am I still getting the error?
Comment: Your local JVM is used to execute Gradle itself, but then Gradle executes a separate JVM process (the JVM from the toolchain) to run the build.

toolchain parameter in gradle


Console.WriteLine in ASP.NET

Question: What does Console.WriteLine(exception.Message); do on an ASP.NET website?
In ASP.NET, where is the Console? If I use Console.WriteLine(exception.Message); on an ASP.NET website, does this output the message in a log file stored on the server somewhere?
Answer: It does nothing, because there is no Console, so there is nowhere to output whatever you are trying to output. It will not be automatically logged anywhere - you must set that up yourself.
--
To expand just slightly
The Console class specifically refers to the console window in a console application (i.e., a non-graphical DOS style executable program).
In ASP.net, your code runs on a web server, and there is no such thing as a console.
If you need to log debug/exception output, look into using Log4net or something similar, or roll your own.
Comment: FYI - in ASP.NET, since there is no console, the `Console` object is backed by `Stream.Null` which essentially means it ignores input. A reasonably good explanation can be found here: http://stackoverflow.com/a/1432088/1630665
Comment: +1. Also it is probably possible to allocate and attach console even to server process... Never tried it so no idea if it would actually work (but again there would be no way to see output - purely theoretical exercise :) )
Comment: Thank you @David! I will accept when the timer allows me.

Console.WriteLine in ASP.NET


SQLSTATE[42000]: Syntax error or access violation (db_insert Function)

Question: I try to build new module in drupal 7
I try to insert some data in some where inside the code
it was working in many functions
but suddenly when I try to do the following
  db_insert('payment_request')
    ->fields(array(
      'payment_item' => $data['payment_item'],
      'change' => $data['change'],
      'via' => $data['via'],
      'userlist' => serialize($userlisthidden),
      'startdate' => strtotime($data['startdate']),
      'enddate' => strtotime($data['enddate']),
      'hash' => $hash
    ))->execute();

it gives me an error
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'change, via, userlist, startdate, enddate, hash) VALUES ('2', '1', '1', 'a:1:{i:' at line 1

I checked the table and the fields and the values
every thing are correct
so I decide to insert static data like the following :
  db_insert('payment_request')
    ->fields(array(
      'payment_item' => 'qq',
      'change' => 'qq',
      'via' => 'qq',
      'userlist' => 'qq',
      'startdate' => 'qq',
      'enddate' => 'qq',
      'hash' => 'qq'
    ))->execute();

But it gives me the same error
so, what i miss here, please help me
Answer: CHANGE is a reserved word in MySQL. PDO doesn't have a built-in function for quoting identifiers (just string literals and dates), so presumably Drupal simply hasn't tried to implement this on PDO's behalf.
Using a different column name would be the simplest solution.
Answer: Reserved Word are permitted as identifiers if you quote them.
For example:
instead of using keyword interval like this:
CREATE TABLE interval (begin INT, end INT);

You could try
CREATE TABLE `interval` (begin INT, end INT);

Comment: That's certainly true, but the docs do explicitly state only to use `db_insert()` for insert queries (not `db_query()`). So yes, it can be done, but you might find it breaks portability to another DBMS. Obviously this may or may not be a problem depending on requirements, but it might not be suitable for, e.g., a contrib module


Add ellipses to content that spills over 3 lines

Question: I am creating a tumblr theme and when you hover over a photo post it shows a description (example description shown below).
The designer only wants the first three lines of the description to show and place ellipses after after the description if it overspills 3 lines.
What's the best way of going about this considering that a character count isn't a good enough?
Thanks for the help...
http://brendan-rice.tumblr.com/
Example Photo Post

        <input type="hidden" value="22186233340" class="id">

            staff:

                Attention West Coast: Check out our official Tumblr meetup in Los Angeles on Tuesday 5/1! RSVP here.

            (Source: meetups)

            Follow

            Reblog

            Like

Comment: Which element do you actually want the ellipsis on?
Comment: So everything in the body yeah? The item with the text that starts "Attention West Coast..."?
Comment: ideally I would like to work on span.title
Comment: The text starts at the start of the span and ends at eth end of the span I have no control of the contents but need to add the elipses. I am at a loss, any ideas? Effectively (.........)
Answer: EDIT: just found this: http://dotdotdot.frebsite.nl/ which should solve your issue (jquery plugin)
As far as I know there is no way to make it wrap to three lines and then ellipsis.
If you just want the ellipsis after 1 line, use:
.class{
  width:200px;
  text-overflow:ellipsis;
  white-space:nowrap;
  overflow:hidden;
}

However, you can do some tricky css to emulate it, though it won't be perfect 100%. I've attached a jsfiddle with the emulation: http://jsfiddle.net/ET3F8/
Essentially, its wrapping to 3 lines and then becoming hidden. There is an element containing the ellipsis text ("...") which is positioned at the bottom right of the container. It will cover the text and emulate ellipsis.
Issues:
- It will always display. You could perhaps use some JS to hide it if the text is not overflowing.
- It sometimes will break a letter.
Anyway, just an idea!
Comment: Came across dotdotdot myself, it works perfect, thanks for the help
Answer: Just use text-overflow: ellipsis, but you'll need to fix the width of whatever it is you want the content restricting on. Something like:
.myClass
{
    width: 200px;
    text-overflow: ellipsis;
}

Comment: I have tried that and it doesn't seem to work.Thanks for the answer
Answer: Does this CSS meet your needs?
text-overflow: ellipsis;

Comment: I have tried that and it doesn't seem to work.Thanks for the answer
Answer: You're bound to a specific height but does the trick for me.
.description .title {
height: 3.7em;
overflow: hidden;
}


Views query alter or condition not works

Question: Want add some or conditions in view queries. I tried two solutions but it not working. What I do wrong?
<code>function up_coaching_custom_views_query_alter(&$view, &$query) {
  $search_string = empty($_GET['filter']) ? '' : '%' . db_like($_GET['filter']) . '%';
  if ($view->name != 'users' || empty($search_string)) {
    return;
  }

  // First way
  $condition = db_or()
      ->condition('users.mail', $search_string, 'LIKE')
      ->condition('field_data_field_company.field_company_value', $search_string, 'LIKE')
      ->condition('field_data_field_user_name.field_user_name_value', $search_string, 'LIKE')
      ->condition('field_data_field_title.field_title_value', $search_string, 'LIKE');
  $query->add_where(2, $condition);

  // Second way
  $query->where[2] = array(
    'args' => array(),
    'type' => 'OR',
    'conditions' => array(
      array(
        'field' => 'users.mail',
        'value' => $search_string,
        'operator' => 'LIKE',
      ),
      array(
        'field' => 'field_data_field_company.field_company_value',
        'value' => $search_string,
        'operator' => 'LIKE',
      ),
      array(
        'field' => 'field_data_field_user_name.field_user_name_value',
        'value' => $search_string,
        'operator' => 'LIKE',
      ),
      array(
        'field' => 'field_data_field_title.field_title_value',
        'value' => $search_string,
        'operator' => 'LIKE',
      ),
    ),
  );
  $query->set_where_group('AND', 2);
  dpm($query);
}
</code>
Answer: Ok, both solutions are work. The problem is in query fields that not exist because need add field tables. I didn't unserstand this because of this:
<code>    catch (Exception $e) {
        $view->result = array();
        if (!empty($view->live_preview)) {
          drupal_set_message($e->getMessage(), 'error');
        }
        else {
          vpr('Exception in @human_name[@view_name]: @message', array('@human_name' => $view->human_name, '@view_name' => $view->name, '@message' => $e->getMessage()));
        }
      }
</code>
Views didn't show me error.


Does this theorem have a name?

Question:
Let P(x) be a polynomial of degree n. Let H(i) represent the number of 1's in the binary expansion of the integer i. Although reasonably easy to prove, it may seem surprising that the following identity holds:

$\sum_{i=0}^{2^{n+1}-1} (-1)^{H(i)}P(i) = 0$
This was asked here on the "Complex Projective 4-Space" blog by apgoucher.
Comment: There has to be a typo in the summation. The range should be either from $0$ to $2^{n+1}-1$ or from $1$ to $2^{n+1}$. Both work, I think.
Comment: This question has been handled in Math.SE at least [here](http://math.stackexchange.com/q/163369/11619). I have seen the result in a number theory book. My copy of that book is in my office (if not with a student), so can't check before Monday, whether the author attributes the theorem to somebody. IOW, I'm not sure that coding theory is the best tag for this.
Comment: I added "coding theory" because apgoucher titled his post "Polynomials and Hamming Weights".
Comment: You are correct, the lower bound is zero. I will fix it.
Answer: I don't know if the theorem has a name. I found the result (with variations) from the very nice book Elementary Number Theory - A Problem Oriented Approach written in beautiful calligraphy by Joe Roberts, p. 88 to be precise. I warmly recommend that book to aspiring students from high school age and up.
Anyway, he indicates that the result was first published by M.E. Prouhet in an article titled Mémoire sur quelques relations entre les puissances des nombres that appeared in Comptes Rendus in 1851.

Does this theorem have a name?


Colocar imagens em cima de links

Question: Oi! Eu queria que uma imagem aparecesse quando eu passasse o mouse em cima de um link em HTML...
Aqui, o que eu tenho agora...

Objetivos

Spawn on Sanctuary Central...

Farm Wood and Stone...

Build a House Lv. 1...

Craft Single Panel Flag...

Tame a Doedicurus...

Craft Bola...

Tame a Pterodon...

Craft Dino Leash...

Tame a Managarmr...

Tame a Snow Owl...

Free Pterodon...

Craft Awesome Teleporter...

Go to: 45.1, 46.2

Build a Green House on 45.1, 46.2...

Tame a Velonasaur...

Defend a Element Node...

Craft Cryofridge...

Craft Cryopods...

Craft Tek Armor...

Tame a Thylacoleo...

Maybe

Tek Bridge

Scout Remote

Eu queria que quando passasse o mouse em cima do item ou do Dino, aparecesse a foto dele...
Isso é possível? Obrigado pelo seu tempo!
Comment: Cara coloque o que vc já tem de código ai, ou pelo menos o layout que vc está tentando replicar. Da forma como vc  perguntou a pergunta fica muito ampla
Answer: É possível sim e essa é uma possibilidade:

a.y:hover {
 width: 256px;
 height: 256px;
 color: #ffffff;
 font-weight: bold;
 text-decoration:none;
 display: block;
 background-image : url(https://i.pinimg.com/originals/dc/ff/62/dcff629625d17e9c90981c6f07798a80.png);
 background-repeat: no-repeat;
 }

 a.z:hover {
 width: 256px;
 height: 256px;
 color: #000000;
 font-weight: bold;
 text-decoration:none;
 display: block;
 background-image : url(https://i.pinimg.com/originals/8f/d6/d0/8fd6d0e4b94ede5ca1d90c2e32e62b1d.jpg);
 background-repeat: no-repeat;
 }

Tek Bridge

Scout Remote

coloque uma classe no link e desenvolva o css para essa classe conforme exemplificado nessa resposta
Comment: Muito gentil da sua parte! Sério, você é muito legal por isso, mais, eu queria que cada link tivesse uma imagem diferente, é possível com isso?
Comment: Sim, varios css
Comment: @MaxWhite na solução que coloquei abaixo, você poderia encapsular o link e a imagem em uma `div` e substituir apenas o endereço da imagem, acredito que irá funcionar.
Answer: Você pode fazer da seguinte forma

.imageSumida {
    display: none;
}
.hoverImage:hover ~ .imageSumida {
    display: block;
}
  Uma imagem deve aparecer. PASSE o MOUSE e descubra

Sendo a propriedade :hover uma espécie de evento em CSS que é executado quando o elemento anterior aos : tem o mouse passado em cima dele e o ~ como seletor de elementos irmãos, você pode ver mais AQUI
No exemplo que você deu, acredito que se colocar sua lista assim, irá resolver

.imageSumida {
    display: none;
}
.hoverImage:hover ~ .imageSumida {
    display: block;
}

    A imagem irá aparecer, tenha FÉ

    Outra imagem irá aparecer

Colocar imagens em cima de links


Formal Reduction: Pushdown Automata recognizing context free languages with bounded stack

Question: I am studying for an exam in automata theory and I am having trouble solving the following:
Consider pushdown automata and context free languages. Show that the following decision problem is undecidable by providing a formal reduction from a known undecidable problem.
Input: A context free language $\mathcal{L}$ given in form of a grammar $\mathcal{G}$.
Question: Is there a push down automaton $\mathcal{P}$ which recognizes $\mathcal{L}$ with bounded stack usage, i.e. there is a bound $k \in \mathbb{N}$ such that no run of $\mathcal{P}$ needs more than $k$ symbols on the stack.
Hint: The decision problem whether a given context free language $\mathcal{L}$ is regular is undecidable.
My thoughts so far:

If stack is bounded, push down automata can be transformed into an NFA
NFA recognize regular languages
Context free languages are not recognizable by bounded pushdown automata
Comment: As you observed, if there exists a stack-bounded automata, then $\mathcal{L}$ is regular. Moreover, NFA is a stack-bounded automaton (with bound being 0), so this is an "if and only if" connection between existence of appropriate stack-bounded automata and NFAs. This way, given an algorithm that solves your problem, you can tell whether a context free language is regular.
Comment: @dtldarek your comment may be suited for an answer, isn't it?
Comment: @wece Done. ${}$
Answer: As you observed, if there exists a stack-bounded automata, then $\mathcal{L}$ is regular. Moreover, NFA is a stack-bounded automaton (with bound being 0), so this is an "if and only if" connection between existence of appropriate stack-bounded automata and NFAs. This way, given an algorithm that solves your problem, you can tell whether a context free language is regular.
I hope this helps $\ddot\smile$


Evaluate without L'Hopital: $\lim_{x \to 3} (x-3)\csc\pi x $

Question: I'm supposed to evaluate this limit without using L'Hopital's rule.

$$\lim_{x \to 3} (x-3)\csc\pi x $$

I find the indeterminate form of $0$ or $\frac{0}{0}$. The latter tells me that L'Hopital's is an option, but since we haven't seen derivatives yet I'm not allowed to used it.
Previously I already tried swapping the $\csc\pi x$ for $\frac{1}{\sin\pi x}$ but when doing this I can't seem to get rid of the sinus. I also believe that since the limit goes to $3$ and not to $0$, the $\lim_{x \to 0}\frac{\sin ax}{ax} = 1$ rule is not an option either.
I tried making the $\sin(\frac{\pi}{2})$ so that $=1$, but without any success. Can anyone give me a hint? I don't need a full solution as I want to try and find it myself.
Answer: (Edited because I just realised you don't want a full solution)
Hint: $\sin(x) = -\sin(x + 3\pi)$. Try a substitution such that the limit you mentioned is an option!
Comment: Yes, it is indeed. But now take the substitution $y = x-3$, in which case $\lim_{x \to 3}$ is the same as $\lim_{y \to 0}$.
Comment: Sorry, I'm still having some trouble. By "such that the limit you mentioned is an option" do you mean $\lim_{x \to 0}\frac{\sin ax}{ax} = 1$ ? Because i thought this was only viable when the limit goes to 0.
Comment: Typo: $\sin(x\color{red}-3\pi)$.
Comment: @YvesDaoust $+3\pi$ and $-3\pi$ have a difference that is a multiple of $2\pi$, so it's not a typo. And I wanted it to have $+3\pi$ in there because that's what you obtain once you substitute.
Comment: The limit is that of $-(x-3)/\sin(\pi x-\pi 3)=-y/\sin(\pi y)$. It would make no sense to use a $+$.
Comment: Perhaps my use of $x$ in my hint is confusing. My idea was to substitute $\sin(\pi x) = \sin(\pi(y+3)) = \sin(\pi y + 3\pi)$, in which case it does make sense.
Answer: By a change of variable,
$$\lim_{x\to3}\frac{x-3}{\sin\pi x}=\lim_{y\to0}\frac{y}{\sin(\pi y+3\pi)}=-\frac1\pi\lim_{y\to0}\frac{\pi y}{\sin(\pi y)}.$$
Comment: May I ask how you were able to work away the $3\pi $ inside the sine?
Comment: @TheAlPaca02: no, this is trivial.


O meu botão do carrossel parou de funcionar quando coloquei as imagens

Question: Boas,
Eu coloquei um carousel do bootstrap no meu HTML mas quando coloquei as imagens os botões para trocar de slide pararam de funcionar.
Podem ver o que está errado?

 <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">

          Previous

          Next

Imagem da pasta:
Comment: Você, não pode utilizar mais do que um `id` em um elemento, apenas em `class`.
Answer: O seu erro está nessa linha

Basta retirar o slides do id da div. Deixe apenas o carouselExampleIndicators.

Dessa forma deve funcionar.
Eu simulei com o seguinte exemplo aqui na minha máquina, mudando apenas as imagens e retirando aquele id.

    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
        integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">

        Previous

        Next


PreExistingConfigException: Configuration objects provided by progweb_migration already exist in active

Question: I'm playing with migrations from D7 to D8 and I've found that, when you register a module with a migration, if you disable it, next time you enable the module gets stuck on this:
[vagrant@devbox] /[...]/default $ drush en progweb_migration -y
PHP Warning:  Module 'imagick' already loaded in Unknown on line 0
PHP Warning:  Module 'imagick' already loaded in Unknown on line 0
The following extensions will be enabled: progweb_migration
Do you really want to continue? (y/n): y
exception 'Drupal\Core\Config\PreExistingConfigException' with message 'Configuration objects[error]
(migrate.migration.custom_user) provided by progweb_migration already exist in active
configuration' in /www/drupal8/core/lib/Drupal/Core/Config/PreExistingConfigException.php:70
Stack trace:
#0 /www/drupal8/core/lib/Drupal/Core/Extension/ModuleInstaller.php(162):
Drupal\Core\Config\PreExistingConfigException::create('progweb_migrati...', Array)
#1 /opt/drush7/vendor/drush/drush/commands/core/drupal/environment.inc(129):
Drupal\Core\Extension\ModuleInstaller->install(Array, true)
#2 /opt/drush7/vendor/drush/drush/commands/core/drupal/environment.inc(196):
drush_module_install(Array)
#3 /opt/drush7/vendor/drush/drush/commands/pm/pm.drush.inc(1120): drush_module_enable(Array)
#4 [internal function]: drush_pm_enable('progweb_migrati...')
#5 /opt/drush7/vendor/drush/drush/includes/command.inc(359):
call_user_func_array('drush_pm_enable', Array)
#6 /opt/drush7/vendor/drush/drush/includes/command.inc(210): _drush_invoke_hooks(Array,
Array)
#7 [internal function]: drush_command('progweb_migrati...')
#8 /opt/drush7/vendor/drush/drush/includes/command.inc(178):
call_user_func_array('drush_command', Array)
#9 /opt/drush7/vendor/drush/drush/lib/Drush/Boot/DrupalBoot.php(46): drush_dispatch(Array)
#10 /opt/drush7/vendor/drush/drush/drush.php(76):
Drush\Boot\DrupalBoot->bootstrap_and_dispatch()
#11 /opt/drush7/vendor/drush/drush/drush.php(16): drush_main()
#12 {main}

It's like the migration is being registered but not de-registered. In D7 there is a method for that, but no luck so far trying in D8:
function progweb_migration_enable() {
  Migration::registerMigration('custom_user');
  Migration::registerMigration('custom_blog');

  Migration::registerMigration('ProgwebBlog');
  Migration::registerMigration('ProgwebUser');
}

function progweb_migration_disable() {
  Migration::deregisterMigration('custom_user');
  Migration::registerMigration('custom_blog');

  Migration::deregisterMigration('ProgwebBlog');
  Migration::registerMigration('ProgwebUser');

}

Any ideas?
Answer: This is a core issue, not specific to Migrate. The problem is, config entities are copied into the active store when you enable your module but not deleted when you remove your module. This is what causes the errors when re-enabling your module.
I would highly suggest Config Devel for developing migrations. It will allow you to synchronise your migrations back into the active store without re-installing.
Answer: in case you need to uninstall the module (Ben answer is good), you'd need to add this to remove the config:
/**
 * hook_uninstall.
 */
function progweb_migration_uninstall() {
  db_query("DELETE FROM {config} WHERE name LIKE 'migrate.migration.progweb_custom_blog%'");
  db_query("DELETE FROM {config} WHERE name LIKE 'migrate.migration.progweb_custom_user%'");

  drupal_flush_all_caches();
}

Answer: You can do this with Drush.
First check the available migrations using: drush config-list
Then use drush config-delete migrate.migration.custom_user (from your example)


Wordpress: Redirect Old to New Permalink Structure

Question: My sites old permalink structure was example.com/%postname%
Now, I changed my all posts permalink to new structure example.com/people/%postname%
Problem is that old permalinks not redirecting to the new structure. I tried "redirection" plugin but it does not work.
Is there any plugin or htaccess code to solve this issue?
Answer: Yoast provides a free tool which will allow you to generate the code for the .htaccess file, you can find it here and the associated blog post
This should do what you are asking
<code>RedirectMatch 301 ^/([^/]+)/$ http://www.example.com/$1
</code>


Syntax Highlight e TinyMCE4

Question: Sempre que coloco um script JS, PHP ou CSS no tinymce dentro das tags
, como manda o Syntax Highlight, funciona perfeitamente, porém se quero um script HTML, como o tinymce é um editor de HTML ele retira a minha tag
 e joga o HTML para fora. Desse modo o Syntax Highlight não consegue ler e formatar o script. Como resolver isso?
Answer: O TinyMCE, assim como todos os editores de textos para campos em página web eles convertem as tags, <tag>, em  caracteres especiais para que seja exibido em uma página HTML.
Por exemplo, se você entra no campo com o seguinte:

          Conteúdo da Div

O resultado desse campo será:
<pre>
     <div>
          Conteúdo da Div
     </div>
</pre>

Com isso, se você quer exibir com o Syntax Highlight, você teria (ou por linguagem PHP, ou JavaScript ou qualquer outra que desejar) setar o texto dentro de uma tag
, dessa forma ficaria:

     <pre>
          <div>
               Conteúdo da Div
          </div>
     </pre>

Syntax Highlight e TinyMCE4


while deploying in firebase i got "The specified file was not found on this website. Please check the URL for mistakes and try again."

Question: i am currently deploying a react project with firebase
below path i am using
<Route exact path="/product-type/laptop" element={<Allproductpage type={'Laptop'} />} />
this is working correctly for localhost but not working well for after deploy. and getting the error page not found .
how to fix it
Answer: This user had the same problem as you in this question:
404 page not found when running firebase deploy
Looks like there's a problem in your firease.json configuration.


deserializing a string which has more nodes then type that will be returned in c#

Question: I have an XML string which is retrieved as an xml string from API call. I need to convert this into view model in my application so that this can be displayed in the view.
however as the viewmodel only has few nodes/elements as there are in the xml document I get an exception thrown when I try to deserialize it. below is the code and the error.
API End Point returns this
<response>
  <data>
    <categories>
      <category>
        <id>1</id>
        <name>hats</name>
      </category>
    </categories>
  </data>
</response>

Code:
namespace CatApp.Models
{
[XmlRoot("Categories")]
public class CategoriesViewModel
{
    public CategoriesViewModel()
    {
        _categories = new List<Category>();
    }

    private  List<Category> _categories;
    [XmlElement("Category")]
    public List<Category> Categories
    {
        get { return _categories; }
        set { value = _categories; }
    }

    public class Category
    {
        [XmlElement("Id")]
        public int Id { get; set; }

        [XmlElement("Name")]
        public string Name { get; set; }
    }

  }
}

  public static async Task<CategoriesViewModel> GetAllCategories()
  {
        var model = new CategoriesViewModel();
        try
        {
            var response = await client.GetStreamAsync(uri);
            model = DeserializeXMLToObject<CategoriesViewModel>(response);

        }
        catch (Exception ex)
        {
            var exception = ex;
        }
        return model;
    }

   public static T DeserializeXMLToObject<T>(Stream stream)
   {
        T returnObject = default(T);
        try
        {
                XmlSerializer serializer = new XmlSerializer(typeof(T));

                returnObject = (T)serializer.Deserialize(stream);
        }
        catch (Exception ex)
         {

        }
        return returnObject;
    }

Error     at
  System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader
  xmlReader, String encodingStyle, XmlDeserializationEvents events)
  at System.Xml.Serialization.XmlSerializer.Deserialize(Stream stream)
  at CatApp.Controllers.HomeController.DeserializeXMLToObject[T](Stream
  stream) in
  C:\Users\umerh\source\repos\CatAPI\CatApp\Controllers\HomeController.cs:line
  50
Comment: I don't see a `Response` class with a nested Data property of type `Data` in it
Comment: this is an external class, I am calling external API and have no control over it.
Answer: First, the element names in the C# attributes must match the element names in the XML. Case sensitive: Categories not equal categories and so on.
[XmlRoot("categories")] // <--
public class CategoriesViewModel
{
    public CategoriesViewModel()
    {
        _categories = new List<Category>();
    }

    private List<Category> _categories;

    [XmlElement("category")] // <--
    public List<Category> Categories
    {
        get { return _categories; }
        set { value = _categories; }
    }

    public class Category
    {
        [XmlElement("id")] // <--
        public int Id { get; set; }

        [XmlElement("name")] // <--
        public string Name { get; set; }
    }
}

Second, you can skip some of the xml elements as follows:
public static T DeserializeXMLToObject<T>(Stream stream)
{
    T returnObject = default(T);
    try
    {
        XmlSerializer serializer = new XmlSerializer(typeof(T));

        using (var xmlReader = XmlReader.Create(stream))
        {
            xmlReader.ReadToFollowing("categories"); // Skip elements before categories node
            returnObject = (T)serializer.Deserialize(xmlReader);
        }
    }
    catch (Exception ex)
    {

    }
    return returnObject;
}

Comment: works like a charm!! Superb, case sensitivity was bit silly mistake.


Displaying the first in simple Show / Hide content menu with active a

Question: Followed a simple tutorial here, but I want the first in the list to display on page load -
Then vanish if another clicked. I also want an active class added to the button if its the one that is being viewed, how would I achieve this using jquery?
Here be the fiddle
HTML

Web Design & Build

SEM/SEO

Graphic Design

User Experience Design

Brand Strategy

Digital Prototyping

Marketing

Digital Marketing

Digital Strategy

Digital Consulting

Email Marketing

Pay Per Click

Advertising

Data Analysis

Web Design & Build

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras nibh eros, commodo sit amet risus a, bibendum venenatis mi. In sed tempus ante. In ac molestie tortor. Proin convallis, diam facilisis volutpat blandit,

Quisque quis suscipit augue. Quisque eu augue eu elit imperdiet posuere. Integer tempor metus consectetur interdum porta. Fusce condimentum, metus eu commodo dapibus, diam metus vestibulum lacus,

Nullam facilisis nibh nec lacinia eleifend. Sed diam mi, tempus vel feugiat ac, venenatis elementum magna. Suspendisse iaculis viverra odio ut dignissim. Nam rhoncus congue bibendum. Maecenas eget metus

accumsan facilisis. Nam scelerisque auctor mauris, volutpat lobortis tellus molestie et. Ut commodo volutpat venenatis. Donec luctus commodo scelerisque. Pellentesque odio libero, adipiscing et urna blandit, gravida hendrerit sem.

...

SEM/SEO

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras nibh eros, commodo sit amet risus a, bibendum venenatis mi. In sed tempus ante. In ac molestie tortor. Proin convallis, diam facilisis volutpat blandit,

Quisque quis suscipit augue. Quisque eu augue eu elit imperdiet posuere. Integer tempor metus consectetur interdum porta. Fusce condimentum, metus eu commodo dapibus, diam metus vestibulum lacus,

Nullam facilisis nibh nec lacinia eleifend. Sed diam mi, tempus vel feugiat ac, venenatis elementum magna. Suspendisse iaculis viverra odio ut dignissim. Nam rhoncus congue bibendum. Maecenas eget metus

accumsan facilisis. Nam scelerisque auctor mauris, volutpat lobortis tellus molestie et. Ut commodo volutpat venenatis. Donec luctus commodo scelerisque. Pellentesque odio libero, adipiscing et urna blandit, gravida hendrerit sem.

...

Graphic Design

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras nibh eros, commodo sit amet risus a, bibendum venenatis mi. In sed tempus ante. In ac molestie tortor. Proin convallis, diam facilisis volutpat blandit,

Quisque quis suscipit augue. Quisque eu augue eu elit imperdiet posuere. Integer tempor metus consectetur interdum porta. Fusce condimentum, metus eu commodo dapibus, diam metus vestibulum lacus,

Nullam facilisis nibh nec lacinia eleifend. Sed diam mi, tempus vel feugiat ac, venenatis elementum magna. Suspendisse iaculis viverra odio ut dignissim. Nam rhoncus congue bibendum. Maecenas eget metus

accumsan facilisis. Nam scelerisque auctor mauris, volutpat lobortis tellus molestie et. Ut commodo volutpat venenatis. Donec luctus commodo scelerisque. Pellentesque odio libero, adipiscing et urna blandit, gravida hendrerit sem.

...

User Experience Design

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras nibh eros, commodo sit amet risus a, bibendum venenatis mi. In sed tempus ante. In ac molestie tortor. Proin convallis, diam facilisis volutpat blandit,

Quisque quis suscipit augue. Quisque eu augue eu elit imperdiet posuere. Integer tempor metus consectetur interdum porta. Fusce condimentum, metus eu commodo dapibus, diam metus vestibulum lacus,

Nullam facilisis nibh nec lacinia eleifend. Sed diam mi, tempus vel feugiat ac, venenatis elementum magna. Suspendisse iaculis viverra odio ut dignissim. Nam rhoncus congue bibendum. Maecenas eget metus

accumsan facilisis. Nam scelerisque auctor mauris, volutpat lobortis tellus molestie et. Ut commodo volutpat venenatis. Donec luctus commodo scelerisque. Pellentesque odio libero, adipiscing et urna blandit, gravida hendrerit sem.

...

Brand Strategy

Your brand has always been important but now, more than ever, it has to be strong enough to be successful across a variety of platforms and a huge range of audiences.

Our brand strategy consultation service covers everything you need to build and grow an effective and future-proof brand. We are experts in revamping older brands and we have extensive experience with creating ones from the ground up.

We take a holistic approach to development and work closely with you and your team to identify how to make your brand work for you.

What your customers want, as well as your market in a broader sense, are all critical factors and help us deliver a strategy which focuses on improving how people interact with your business to drive growth, trust and recognition. To see our branding work, click here.

...

Digital Prototyping

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras nibh eros, commodo sit amet risus a, bibendum venenatis mi. In sed tempus ante. In ac molestie tortor. Proin convallis, diam facilisis volutpat blandit,

Quisque quis suscipit augue. Quisque eu augue eu elit imperdiet posuere. Integer tempor metus consectetur interdum porta. Fusce condimentum, metus eu commodo dapibus, diam metus vestibulum lacus,

Nullam facilisis nibh nec lacinia eleifend. Sed diam mi, tempus vel feugiat ac, venenatis elementum magna. Suspendisse iaculis viverra odio ut dignissim. Nam rhoncus congue bibendum. Maecenas eget metus

accumsan facilisis. Nam scelerisque auctor mauris, volutpat lobortis tellus molestie et. Ut commodo volutpat venenatis. Donec luctus commodo scelerisque. Pellentesque odio libero, adipiscing et urna blandit, gravida hendrerit sem.

...

Marketing

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras nibh eros, commodo sit amet risus a, bibendum venenatis mi. In sed tempus ante. In ac molestie tortor. Proin convallis, diam facilisis volutpat blandit,

Quisque quis suscipit augue. Quisque eu augue eu elit imperdiet posuere. Integer tempor metus consectetur interdum porta. Fusce condimentum, metus eu commodo dapibus, diam metus vestibulum lacus,

Nullam facilisis nibh nec lacinia eleifend. Sed diam mi, tempus vel feugiat ac, venenatis elementum magna. Suspendisse iaculis viverra odio ut dignissim. Nam rhoncus congue bibendum. Maecenas eget metus

accumsan facilisis. Nam scelerisque auctor mauris, volutpat lobortis tellus molestie et. Ut commodo volutpat venenatis. Donec luctus commodo scelerisque. Pellentesque odio libero, adipiscing et urna blandit, gravida hendrerit sem.

...

Digital Marketing

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras nibh eros, commodo sit amet risus a, bibendum venenatis mi. In sed tempus ante. In ac molestie tortor. Proin convallis, diam facilisis volutpat blandit,

Quisque quis suscipit augue. Quisque eu augue eu elit imperdiet posuere. Integer tempor metus consectetur interdum porta. Fusce condimentum, metus eu commodo dapibus, diam metus vestibulum lacus,

Nullam facilisis nibh nec lacinia eleifend. Sed diam mi, tempus vel feugiat ac, venenatis elementum magna. Suspendisse iaculis viverra odio ut dignissim. Nam rhoncus congue bibendum. Maecenas eget metus

accumsan facilisis. Nam scelerisque auctor mauris, volutpat lobortis tellus molestie et. Ut commodo volutpat venenatis. Donec luctus commodo scelerisque. Pellentesque odio libero, adipiscing et urna blandit, gravida hendrerit sem.

...

Digital Strategy

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras nibh eros, commodo sit amet risus a, bibendum venenatis mi. In sed tempus ante. In ac molestie tortor. Proin convallis, diam facilisis volutpat blandit,

Quisque quis suscipit augue. Quisque eu augue eu elit imperdiet posuere. Integer tempor metus consectetur interdum porta. Fusce condimentum, metus eu commodo dapibus, diam metus vestibulum lacus,

Nullam facilisis nibh nec lacinia eleifend. Sed diam mi, tempus vel feugiat ac, venenatis elementum magna. Suspendisse iaculis viverra odio ut dignissim. Nam rhoncus congue bibendum. Maecenas eget metus

accumsan facilisis. Nam scelerisque auctor mauris, volutpat lobortis tellus molestie et. Ut commodo volutpat venenatis. Donec luctus commodo scelerisque. Pellentesque odio libero, adipiscing et urna blandit, gravida hendrerit sem.

...

Digital Consulting

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras nibh eros, commodo sit amet risus a, bibendum venenatis mi. In sed tempus ante. In ac molestie tortor. Proin convallis, diam facilisis volutpat blandit,

Quisque quis suscipit augue. Quisque eu augue eu elit imperdiet posuere. Integer tempor metus consectetur interdum porta. Fusce condimentum, metus eu commodo dapibus, diam metus vestibulum lacus,

Nullam facilisis nibh nec lacinia eleifend. Sed diam mi, tempus vel feugiat ac, venenatis elementum magna. Suspendisse iaculis viverra odio ut dignissim. Nam rhoncus congue bibendum. Maecenas eget metus

accumsan facilisis. Nam scelerisque auctor mauris, volutpat lobortis tellus molestie et. Ut commodo volutpat venenatis. Donec luctus commodo scelerisque. Pellentesque odio libero, adipiscing et urna blandit, gravida hendrerit sem.

...

Email Marketing

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras nibh eros, commodo sit amet risus a, bibendum venenatis mi. In sed tempus ante. In ac molestie tortor. Proin convallis, diam facilisis volutpat blandit,

Quisque quis suscipit augue. Quisque eu augue eu elit imperdiet posuere. Integer tempor metus consectetur interdum porta. Fusce condimentum, metus eu commodo dapibus, diam metus vestibulum lacus,

Nullam facilisis nibh nec lacinia eleifend. Sed diam mi, tempus vel feugiat ac, venenatis elementum magna. Suspendisse iaculis viverra odio ut dignissim. Nam rhoncus congue bibendum. Maecenas eget metus

accumsan facilisis. Nam scelerisque auctor mauris, volutpat lobortis tellus molestie et. Ut commodo volutpat venenatis. Donec luctus commodo scelerisque. Pellentesque odio libero, adipiscing et urna blandit, gravida hendrerit sem.

...

Pay Per Click

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras nibh eros, commodo sit amet risus a, bibendum venenatis mi. In sed tempus ante. In ac molestie tortor. Proin convallis, diam facilisis volutpat blandit,

Quisque quis suscipit augue. Quisque eu augue eu elit imperdiet posuere. Integer tempor metus consectetur interdum porta. Fusce condimentum, metus eu commodo dapibus, diam metus vestibulum lacus,

Nullam facilisis nibh nec lacinia eleifend. Sed diam mi, tempus vel feugiat ac, venenatis elementum magna. Suspendisse iaculis viverra odio ut dignissim. Nam rhoncus congue bibendum. Maecenas eget metus

accumsan facilisis. Nam scelerisque auctor mauris, volutpat lobortis tellus molestie et. Ut commodo volutpat venenatis. Donec luctus commodo scelerisque. Pellentesque odio libero, adipiscing et urna blandit, gravida hendrerit sem.

...

Advertising

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras nibh eros, commodo sit amet risus a, bibendum venenatis mi. In sed tempus ante. In ac molestie tortor. Proin convallis, diam facilisis volutpat blandit,

Quisque quis suscipit augue. Quisque eu augue eu elit imperdiet posuere. Integer tempor metus consectetur interdum porta. Fusce condimentum, metus eu commodo dapibus, diam metus vestibulum lacus,

Nullam facilisis nibh nec lacinia eleifend. Sed diam mi, tempus vel feugiat ac, venenatis elementum magna. Suspendisse iaculis viverra odio ut dignissim. Nam rhoncus congue bibendum. Maecenas eget metus

accumsan facilisis. Nam scelerisque auctor mauris, volutpat lobortis tellus molestie et. Ut commodo volutpat venenatis. Donec luctus commodo scelerisque. Pellentesque odio libero, adipiscing et urna blandit, gravida hendrerit sem.

...

Data Analysis

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras nibh eros, commodo sit amet risus a, bibendum venenatis mi. In sed tempus ante. In ac molestie tortor. Proin convallis, diam facilisis volutpat blandit,

Quisque quis suscipit augue. Quisque eu augue eu elit imperdiet posuere. Integer tempor metus consectetur interdum porta. Fusce condimentum, metus eu commodo dapibus, diam metus vestibulum lacus,

Nullam facilisis nibh nec lacinia eleifend. Sed diam mi, tempus vel feugiat ac, venenatis elementum magna. Suspendisse iaculis viverra odio ut dignissim. Nam rhoncus congue bibendum. Maecenas eget metus

accumsan facilisis. Nam scelerisque auctor mauris, volutpat lobortis tellus molestie et. Ut commodo volutpat venenatis. Donec luctus commodo scelerisque. Pellentesque odio libero, adipiscing et urna blandit, gravida hendrerit sem.

...

CSS
#div1, #div2, #div3, #div4, #div5, #div6, #div7, #div8, #div9, #div10, #div11,
#div12, #div13, #div14 {
    display: none;
}

.togglediv1 #div1, .togglediv1 #div2, .togglediv1 #div3, .togglediv1 #div4,
.togglediv1 #div5, .togglediv1 #div6, .togglediv1 #div7, .togglediv1 #div8,
.togglediv1 #div9, .togglediv1 #div10, .togglediv1 #div11, .togglediv1 #div12,
.togglediv1 #div13, .togglediv1 #div14 {
    display: block;
}

Script
$("#divtoggle").delegate("a", "click", function (e) {
  var toggled = ($(this).prop("id"));
  $("div#wrap").prop("class", toggled);
});

Answer: I'd make a few slight changes to make life easier on yourself. For your buttons... change so that the correct ID in the href as an anchor.
E.g.:

Web Design & Build

Then i'd simplify your jquery somewhat... how about this (untested):
$(document).ready(function() {

    // On page load hide all divs except first...

    $('.content:not(:first)').hide();

    $('#divtoggle a').click(function(e) {
        $('.content').hide(); // Hide all
        $('.active').removeClass('active');
        var toShow = $(this).attr('href');
        $(toShow).show();
        $(this).addClass('active');
        e.preventDefault();
    });

});

You can also avoid having all the display:none / display: blocks in the css by doing it all in Javascript.
This way if anyone has javascript disabled it should still work with all items shown, and anchoring down when buttons clicked.
Comment: If wanting the same result from other links again use a link like link text and create a duplicate of the .click function targeting this 'toggle' class
Comment: To achieve something similar from another page you'd want to include a reference to the section to be shown in the query string of the URL and use either server side technology, or javascript to look for that parameter & show the relevant section. Should be possible though.
Comment: That's a great example of extracting the query string from a url in JS - should work a treat.
Comment: Have a go with that example - if any problems best to post a new question with the up-to-date code in a fiddle or similar and see if we can help from there :) Good luck.
Comment: Your method seems to be the best of whats posted so far.
What would be the way to link to this from outside of the menu.. say in the footer if I wanted a link to scroll and open the slide

     Link

?
Comment: tried this earlier, here,

Check the footer links for the functionality im after but with this simpler content method :) http://jsfiddle.net/veT6z/29/
Comment: What if its a link on another page?
Comment: Any ideas on this one steve?
Comment: Was thinking the only solution would be something similar to this,
http://stackoverflow.com/questions/4656843/jquery-get-querystring-from-url
Comment: I will have a go :)
Any issues will post and see if you can help hehe,
Thanks for your input so far - im learning oodles trying to get this functionality the way I want it heh.
Comment: Or could you suggest a simpler method?
Comment: Here you go steve changing my method because I needed two of the content slides :)
http://stackoverflow.com/questions/20858678/jquery-show-hide-content-navigation-links
Answer: Using the current coding, I would suggest doing something like this:
jsFiddle example
$("#divtoggle a").click(function(){
    $("#wrap").attr("class", $(this).attr('id'));
    $('.active').removeClass('active');
    $(this).addClass('active');
});

Alternatively, here is another approach. It is much cleaner as the only CSS used is the styling for the .active class.
Using this approach, all div elements except the first one are hidden by default. An .active class is added to the clicked element, which is then used to determine which div is displayed.
jsFiddle example
$('#divtoggle li:first-child a').addClass('active');
$('.content').hide(); $('#div1').show();
$("#divtoggle a").click(function(){
    var active = (this.id).replace( /^\D+/g, '');
    $('.content').hide(); $('#div' + active).show();
    $('.active').removeClass('active');
    $(this).addClass('active');
});

Comment: The second example works fine, now my issue is how to get another link on the same page (in the footer) To link to these sections + how to get a link from another page to link to them? Any ideas?
Comment: Something like this?

http://stackoverflow.com/questions/6295896/executing-jquery-after-page-load-only-after-clicking-a-specific-link
Answer: My own suggestion is the following:
$("#divtoggle").delegate("a", "click", function (e) {
    // don't use jQuery to get the id
    var toggled = this.id;
    $("div#wrap").prop("class", toggled);

    // remove the 'active' class-name from the previously-active element:
    $('.active').removeClass('active');

    // add the active class to the clicked element:
    $(this).addClass('active');
// then we find 'a' elements,
// select only the first,
// and trigger the click event on that element (invoking the above click-handling)
}).find('a').first().click();

JS Fiddle demo.
References:

addClass().
click().
find().
first().
removeClass().
Answer: Not sure if I'm interpreting your question correctly, but this code will make it so that if you click any list element, the first list element will be removed.
$('li').click(function() {
    $(this).siblings().find('#togglediv1').hide();
});

If you want to remove whatever is first in the list, then you could use this:
$('li').click(function() {
    $(this).siblings(':visible').first().hide();
});

Have a fiddle!
Also maybe consider using newer versions of jQuery if possible.


How to make a content type field unique per user

Question: I want a date field to be unique per user so they can't add two nodes with the same date. I have Unique Field installed. Unfortunatly, they don't offer user scope.
Anyone know how to achieve this?
Answer: I don't know the Unique Field module, but I have a suggestion instead.
Create a little utility module which alters the node form of that node type and adds a custom validation. That validation could check for anything on the form, date inclusive.
In the Drupal 6 days it worked like this. I hope this is enough for a starting point. [Also, reading the book Pro Drupal 7 Development can help you a lot if you haven't written a module yet.]
Comment: I've created a basic module before. Basically, I would have to check in the database if the value of my date field is already present for the user? I'll start making the date field required with a custom module and then continue from there. Thanks alot for this starting point.
Comment: "Basically, I would have to check in the database if the value of my date field is already present for the user?" - yes, that's the validation criteria. You're welcome! :)
Answer: I would like to thank Scorchio for pointing me in the right direction. I managed to achieve what I wanted putting this code in a custom module :
<code>function node_calendar_form_alter(&$form, &$form_state, $form_id) //alter the form
{
  if($form_id == 'training_node_form') //specify form with form id
  {
    $form['#validate'][] = 'my_custom_validate_function'; //declare a custom validation function
  }

}

function my_custom_validate_function($form, &$form_state)
{
    global $user; //because I needed the uid
    $query = new EntityFieldQuery();
    $dates_array = array(); //this will contain the dates to check for

    $query
    ->entityCondition('entity_type', 'node', '=')
    ->propertyCondition('type', 'training')
    ->propertyCondition('uid', $user->uid); //my query, checks for content type and current uid

    $trainings_query = $query->execute();

    if ($trainings_query) { //if query is successful
       $session_nodes = node_load_multiple(array_keys($trainings_query['node'])); //load the nodes
       foreach ($session_nodes as $training) {
           array_push($dates_array, substr($training->field_training_date['und'][0]['value'], 0, -9)); //push the dates in $dates_array after trimming the 00:00:00
       }
    }
    if (in_array(substr($form_state['values']['field_training_date']['und']['0']['value'], 0, -9), $dates_array)) { //if the date is already used
       form_set_error('field_training_date', t("Vous avez déjà un entrainement pour cette date. Veuillez modifier l'entrainement ou pour éviter de la duplication de contenu.")); //throw in error
    }
}
</code>
I commented my code for anyone who would like to do something like this in the future.
Answer: The Drupal module https://drupal.org/project/field_validation does this. Just add a "Unique values" validator to the field and set the scope to "entity" or "bundle". There is then an option for "Per user" uniqueness across the field.
Answer: The user scope functionality you are asking for is available in Unique Field Module by default. There is an option called "Choose whether values must be unique individually or in combination". Select  "The combination of values from the specified fields must be unique" option. And for the fields select your required field (date field in your case) along with the author field.