Result of $\sum_{k=-N}^N \exp(i k \theta)$

Question: I have aquestion to find
$$\sum_{k=-N}^N \exp(i k \theta)$$
The answer given is: $$\frac{\sin(N+1/2)\theta}{\sin(\theta/2)}$$
My attempt:
$$\sum_{k=0}^N \exp(i k \theta)=\frac{\sin((N+1)/2)\theta}{\sin(\theta/2)} \exp(i k \theta/2)$$
Questions:

Does $\sum_{k=-N}^N \exp(i k \theta)=\sum_{k=0}^{2N} \exp(i k \theta)$?

If this is the case, we could have:
$$\sum_{k=-N}^N \exp(i k \theta)=\frac{\sin(N+1/2)\theta}{\sin(\theta/2)} \exp(i k \theta)$$

Even with a Yes to question one, we are still away from the result. Any hint?
Answer: Hint:
$$\sum_{k=-N}^N \exp(i k \theta)$$
Substitute $k\mapsto k-N$:
$$\sum_{k=0}^{2N} \exp(i (k-N) \theta)=\sum_{k=0}^{2N} \exp(ik\theta-iN\theta)\\=
\sum_{k=0}^{2N} \exp(ik\theta)/\exp(iN\theta)=\frac{1}{\exp(iN\theta)}\sum_{k=0}^{2N} \exp(ik\theta)$$
$$=\frac{1}{\exp(iN\theta)}\sum_{k=0}^{2N} \exp(i\theta)^k$$
Comment: This is the hint I am looking for, crystal clear, thanks!
Answer: Let $\zeta = e^{i\theta}$.  Then the given series is $$S_n = \sum_{k=-n}^n \zeta^k = \zeta^{-n} \sum_{k=0}^{2n} \zeta^k.$$  This is a finite geometric series with common ratio $\zeta$, and therefore has value $$S_n = \zeta^{-n} \frac{\zeta^{2n+1} - 1}{\zeta - 1} = \frac{\zeta^{n+1} - \zeta^{-n}}{\zeta - 1} = \frac{\zeta^{n+1/2} - \zeta^{-n-1/2}}{\zeta^{1/2} - \zeta^{-1/2}}.$$  Now it is trivial to observe the desired result using $$\sin z = \frac{e^{iz} - e^{-iz}}{2i}.$$
Comment: How do you come up with: $$\sum_{k=-n}^n \zeta^k = \zeta^{-n} \sum_{k=0}^{2n} \zeta^k.$$
Comment: Ok, got it, explained by Kamilo9875
Answer: $$\sum_{k=-N}^N \exp(i k \theta)= \exp(-iN\theta)\frac{1-\exp(i(2N+1)\theta)}{1-\exp(i\theta)}=\frac{\exp(-iN\theta-\exp(i(N+1)\theta))}{1-\exp(i\theta)}$$
$$\frac{\exp(-i(N+1/2)\theta)-\exp(i(N+1/2)\theta)}{\exp(-i\theta/2)-\exp(i\theta/2)}$$
$$=\frac{-2i\sin((N+1/2)\theta)}{-2i\sin(\theta/2)}$$
$$\frac{\sin((N+1/2)\theta)}{\sin(\theta/2)}$$


Can we simplify the definition of the probability space?

Question: Since the sigma-algebra composes a set of events. And the sample space composes the set of atom events, we can define the probability as function from the sample space to R. This can create a probability space without the sigma-algebra.
The only thing I can think that may make some difference is the definition may impose some unnecessary restrictions on the general definition.
Answer: This approach works for a countable set of outcomes that you assign some probabilities with your function, and then compose into events via additivity.
In this case, in the usual formalism, the sigma algebra is just $2^\Omega$... nothing interesting going on.
However, we are interested in uncountable sample spaces. For instance, modeling a continuous random variable like a Gaussian involves uncountably many outcomes. Here it doesn't make sense to assign a probability to each outcome: the probability of the variable taking a given value must be zero.
So when you say "the sample space composes the set of atom events" and then that that's all we need, you are assuming everything can be reduced to atoms. But continuous distributions have no atoms... you need something else in the description to assign probabilities to. This is the role played by the measurable sets in the sigma algebra.
Comment: This is a great answer. I'd add that not only to continuous distributions not have atoms in the sample space, but there are often meaningful limits of discrete atomic processes that cannot themselves be reduced to atoms (e.g. the "end behavior" of a discrete time random walk on $\mathbb Z$).


Webpack ReactJS

Question: Estou enfrentando problemas com meu webpack, recebo no terminal esse seguinte erro:
you may need an appropriate loader to handle this file type
webpack.config.js:
var path = require('path');
var webpack = require('webpack');

var DIST_DIR = path.resolve(__dirname, 'src/client/public');
var SRC_DIR = path.resolve(__dirname, 'src');

module.exports = {
  entry: './src/index.js',
  output: {
    filename: 'bundle.js'
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'babel-loader',
        query: {
          presets: ['react', 'es2015']
        }
      }
    ]
  },
};

package.json:
{
  "name": "my-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "axios": "^0.17.0",
    "font-awesome": "^4.7.0",
    "react": "^16.0.0",
    "react-bootstrap": "^0.31.5",
    "react-dom": "^16.0.0",
    "react-if": "^2.2.1",
    "react-scripts": "1.0.16",
    "react-simple-chatbot": "^0.2.9",
    "recharts": "^1.0.0-beta.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "webpack": "webpack",
    "babel": "babel",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  },
  "devDependencies": {
    "babel-core": "^6.26.0",
    "babel-loader": "^7.1.2",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "webpack": "^3.8.1",
    "webpack-dev-server": "^2.9.4"
  }
}

Answer: Oi, para webpack versão 2 e 3, o module.loaders mudou para o seguinte formato:
module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: 'babel-loader',
          options: {
            presets: ['react', 'es2015']
          },
        }
      }
    ]
  },
// ...

Note que agora é module.rules

Webpack ReactJS


The likelihood that a time series is generated by certain ARMA(p,q) ?

Question: I have a group ( only 20 of them, each one has 170 time pointers)  of time series that I can consider as "GOOD", meaning, they have consistent statistical characteristics. I am not sure how they are generated, but they are biological data, so I assume the current point is not independent to its temporal neighbors.  I think ARMA model is the good direction. So I fit the group of time series with ARAM model and get the order (p,q). Note that unfortunately, I don't have any sample from the "BAD" distribution, all other time series that deviates largely from the "GOOD" ones can be considered as "BAD".
Now given a new time series, how can I measure the likelihood that it is generated by ARMA(p,q) ? Or anything that's proportional to the likelihood.
I don't think ARMA itself can infer this probability, but I wonder if there are some other useful techniques that I am not aware of.
Or is there any other approach I can take to tackle the problem?
Thanks
Answer: If you have 20 "good time series" one could test the hypothesis of a common set of parameters using the CHOW test which is incorporated in a commercial piece of software that I have helped develop . Alternatively one could write code to estimate the common parameters based upon the 20 samples and then perform the required F test. Now given that you have been able to conclude about a common set one could then introduce a "new time series" and test the hypothesis that the parameters from this new time series are similar i.e. not statistically significantly different from the common set.


How to deal with DNS requests when using multiple OpenVPN connection and policy based route?

Question: I have 2 subnets in my local network (192.168.4.0/24, 192.168.5.0/24), but only 1 gateway server (192.168.4.223) which has 2 OpenVPN connections (10.100.2.6/24, 10.100.3.6/24). The topology is like:
enter image description here
I want computers in 192.168.4.0/24 (such as Computer B) to connect to the Internet via OpenVPN server 2 and computers in 192.168.5.0/24 (such as Computer A) to connect to the Internet via OpenVPN server 1.
On OPENWRT router:
## What I did:
vi /etc/iproute2/rt_tables
...
110    myovp   # Add a table for 192.168.5.0/24
...
# Then add rules for iproute2 and iptables:
ip rule add fwmark 110 table 110
ip rule add to 192.168.4.0/24 table main
ip route add default via 192.168.4.223 dev br-lan_1 table 110
iptables -t mangle -A PREROUTING -i br-lan_2 -j MARK --set-mark 110

## Some outputs:
# Output of `ip rule`:
0:      from all lookup local
32764:  from all to 192.168.4.0/24 lookup main
32765:  from all fwmark 0x6e lookup myovp
32766:  from all lookup main
32767:  from all lookup default
# Output of `ip route show`:
192.168.4.0/24 dev br-lan_1 proto kernel scope link src 192.168.4.1
192.168.5.0/24 dev br-lan_2 proto kernel scope link src 192.168.5.1
# Output of `ip route show table 110`:
default via 192.168.4.223 dev br-lan_1
# Output of `iptables -t mangle -L PREROUTING -v`
Chain PREROUTING (policy ACCEPT 871K packets, 177M bytes)
 pkts bytes target     prot opt in     out     source               destination
28030 1954K MARK       all  --  br-lan_2 any     anywhere             anywhere             MARK set 0x6e

On Debian Gateway Server:
## What I did:
vi /etc/iproute2/rt_tables
...
110    myovp   # Add a table for 192.168.5.0/24
...
# Then add rules for iproute2 and iptables:
ip rule add fwmark 110 table 110
ip rule add to 192.168.4.0/24 table main
ip rule add to 192.168.5.0/24 table main
ip route add default via 10.100.2.1 dev tun0 table 110
ip route add 192.168.5.0/24 via 192.168.4.1 dev enp4s0
iptables -t mangle -A PREROUTING -i enp4s0 -s 192.168.5.0/24 -j MARK --set-mark 110
# Then add rules for NAT and FORWARD:
iptables -A FORWARD -i enp4s0 -j ACCEPT
iptables -A FORWARD -i tun1 -o enp4s0 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i enp4s0 -o tun1 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i tun0 -o enp4s0 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i enp4s0 -o tun0 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o tun1 -j ACCEPT
iptables -A OUTPUT -o tun0 -j ACCEPT
iptables -t nat -A POSTROUTING -s 192.168.4.0/24 -o tun1 -j MASQUERADE
iptables -t nat -A POSTROUTING -s 192.168.5.0/24 -o tun0 -j MASQUERADE

## Some outputs:
# Output of `ip addr`:
...
4: tun1: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 500
    link/none
    inet 10.100.3.6/24 scope global tun1
       valid_lft forever preferred_lft forever
    inet6 fe80::fd55:444a:552a:a454/64 scope link stable-privacy
       valid_lft forever preferred_lft forever
5: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 500
    link/none
    inet 10.100.2.6/24 scope global tun0
       valid_lft forever preferred_lft forever
    inet6 fe80::af61:acf1:4e9c:b1a8/64 scope link stable-privacy
       valid_lft forever preferred_lft forever
...
# Output of `ip route show`:
0.0.0.0/1 via 10.100.3.1 dev tun1
default via 192.168.4.1 dev enp4s0 proto static metric 100
10.100.2.0/24 dev tun0 proto kernel scope link src 10.100.2.5
10.100.3.0/24 dev tun1 proto kernel scope link src 10.100.3.5
188.8.131.52/1 via 10.100.3.1 dev tun1
192.168.4.0/24 dev enp4s0 proto kernel scope link src 192.168.4.223 metric 100
192.168.5.0/24 via 192.168.4.1 dev enp4s0
# Output of `ip route show table 110`:
default via 10.100.2.1 dev tun0
# Output of `ip rule`:
0:      from all lookup local
32763:  from all to 192.168.5.0/24 lookup main
32764:  from all to 192.168.4.0/24 lookup main
32765:  from all fwmark 0x6e lookup 110
32766:  from all lookup main
32767:  from all lookup default
# Output of `iptables -t filter -L -v`:
Chain INPUT (policy ACCEPT 30661 packets, 3126K bytes)
 pkts bytes target     prot opt in     out     source               destination
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
2117K  194M ACCEPT     all  --  enp4s0 any     anywhere             anywhere
3394K 4191M ACCEPT     all  --  tun1   enp4s0  anywhere             anywhere             state RELATED,ESTABLISHED
    0     0 ACCEPT     all  --  enp4s0 tun1    anywhere             anywhere             state RELATED,ESTABLISHED
 1541  133K ACCEPT     all  --  tun0   enp4s0  anywhere             anywhere             state RELATED,ESTABLISHED
    0     0 ACCEPT     all  --  enp4s0 tun0    anywhere             anywhere             state RELATED,ESTABLISHED
Chain OUTPUT (policy ACCEPT 35596 packets, 22M bytes)
 pkts bytes target     prot opt in     out     source               destination
 1044  108K ACCEPT     all  --  any    tun1    anywhere             anywhere
    0     0 ACCEPT     all  --  any    tun0    anywhere             anywhere
# Output of `iptables -t nat -L -v`:
Chain PREROUTING (policy ACCEPT 208K packets, 34M bytes)
 pkts bytes target     prot opt in     out     source               destination
Chain INPUT (policy ACCEPT 266 packets, 46150 bytes)
 pkts bytes target     prot opt in     out     source               destination
Chain POSTROUTING (policy ACCEPT 98 packets, 5876 bytes)
 pkts bytes target     prot opt in     out     source               destination
27638 2036K MASQUERADE  all  --  any    tun1    192.168.4.0/24       anywhere
  347 19186 MASQUERADE  all  --  any    tun0    192.168.5.0/24       anywhere
Chain OUTPUT (policy ACCEPT 95 packets, 5636 bytes)
 pkts bytes target     prot opt in     out     source               destination
# Output of `iptables -t mangle -L PREROUTING -v`:
Chain PREROUTING (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
 2829  215K MARK       all  --  enp4s0 any     192.168.5.0/24       anywhere             MARK set 0x6e

And on both OpenVPN servers (They are almost the same except for the subnet IP addresses and Internet addresses):
## What I did:
# First set up the OpenVPN server
# Then add rules for NAT and FORWARD:
iptables -A FORWARD -i tun0 -j ACCEPT
iptables -A FORWARD -i tun0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i eth0 -o tun0 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o tun0 -j ACCEPT
iptables -t nat -A POSTROUTING -s 10.100.2.0/24 -o eth0 -j MASQUERADE

## Some outputs
# Output of `ip addr`:
...
5: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 500
    link/none
    inet 10.100.2.1/24 scope global tun0
       valid_lft forever preferred_lft forever
    inet6 fe80::c31e:ba42:4cb5:d887/64 scope link stable-privacy
       valid_lft forever preferred_lft forever
...
# Output of `iptables -t filter -L -v`:
Chain INPUT (policy ACCEPT 16M packets, 1026M bytes)
 pkts bytes target     prot opt in     out     source               destination
Chain FORWARD (policy ACCEPT 1522K packets, 114M bytes)
 pkts bytes target     prot opt in     out     source               destination
 247M  192G ACCEPT     all  --  tun0   any     anywhere             anywhere
    0     0 ACCEPT     all  --  tun0   eth0    anywhere             anywhere             state RELATED,ESTABLISHED
 178M  106G ACCEPT     all  --  eth0   tun0    anywhere             anywhere             state RELATED,ESTABLISHED
    0     0 ACCEPT     all  --  tun0   any     10.100.2.0/24        anywhere
Chain OUTPUT (policy ACCEPT 16M packets, 1047M bytes)
 pkts bytes target     prot opt in     out     source               destination
55959 7717K ACCEPT     all  --  any    tun0    anywhere             anywhere
# Output of `iptables -t nat -L -v`:
Chain PREROUTING (policy ACCEPT 27M packets, 1809M bytes)
 pkts bytes target     prot opt in     out     source               destination
 Chain INPUT (policy ACCEPT 11M packets, 605M bytes)
 pkts bytes target     prot opt in     out     source               destination
Chain OUTPUT (policy ACCEPT 5047 packets, 386K bytes)
 pkts bytes target     prot opt in     out     source               destination
Chain POSTROUTING (policy ACCEPT 996K packets, 83M bytes)
 pkts bytes target     prot opt in     out     source               destination
  16M 1063M MASQUERADE  all  --  any    eth0    10.100.2.0/24        anywhere

Now, the computers in 192.168.4.0/24 (such as Computer B) can connect to the Internet via OpenVPN server 2 prefectly.
But in 192.168.5.0/24, the computers cannot resolve any hostnames. On computer A, ping 18.104.22.168 works fine, and tracert 126.96.36.199 shows it can get to the 188.8.131.52 server via OpenVPN server 1, but nslookup google.com 126.96.36.199 returns Query refused.
Really sorry for such a long post, but I really don't know what to do or what I missed. I'm not a pro of network things, so any specific suggestions and help are appreciated. Thanks!
Answer: Problem solved.
Two rules were added to the iptables on OPENWRT by default for some inexplicable reasons:
iptables -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT --to-ports 53
iptables -t nat -A PREROUTING -p tcp --dport 53 -j REDIRECT --to-ports 53

really don't know why the guy who sold me the router added them. :(


How to handle missing values when using a reverse geocode function?

Question: I am currently working with data (N of 271,848) in R that looks as follows:
Observation   Longitude     Latitude
--------------------------------------
      1        116.38800    39.928902
      2        53.000000    32.000000
      3          NA          NA
      4          NA          NA

And I am using a reverse geocode function from the following post: Convert latitude and longitude coordinates to country name in R
When I run the coords2country(points) line, I get the following error:

"Error in .checkNumericCoerce2double(obj) : non-finite coordinates"

My best guess is that the function does not know how to treat missing values. When I run the code on a subset of observations (excluding NA's/missing values), it works.
I attempted to modify the function slightly (see last line below) to fix this problem, but that still produced the error I am referring to above.
Reproducible example:
Data <- data.frame(
  Observation = 1:5,
  Longitude = c(116.3880005, 53, -97, NA, NA),
  Latitude = c(39.92890167, 32, 32, NA, NA))

library(sp)
library(rworldmap)
    coords2country = function(points)
       {
       countriesSP <- getMap(resolution='low')
       #countriesSP <- getMap(resolution='high') #you could use high res map from rworldxtra if       you were concerned about detail

      # convert our list of points to a SpatialPoints object
      #pointsSP = SpatialPoints(points, proj4string=CRS("+proj=longlat +datum=wgs84"))
      #! andy modified to make the CRS the same as rworldmap
      #pointsSP = SpatialPoints(points, proj4string=CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"))
      # new changes in worldmap means you have to use this new CRS (bogdan):
      pointsSP = SpatialPoints(points, proj4string=CRS(" +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0"))

      # use 'over' to get indices of the Polygons object containing each point
      indices = over(pointsSP, countriesSP)

      # return the ADMIN names of each country
      indices$ADMIN
      #indices$ISO3 # returns the ISO3 code
      #The line below is what I thought could resolve the problem.
      na.action = na.omit
        }

Answer: Better use this instead:
coords2country_NAsafe <- function(points)
{
    bad <- with(points, is.na(lon) | is.na(lat))
    result <- character(length(bad))
    result[!bad] <- coords2country(points[!bad,])
    result
}

Comment: I am using the rworldmaps package. When I performed the code you provided above, and uploaded the RgoogleMaps library, I kept getting the following error: Error in coords2country(points[!bad, ]) :
  could not find function "getMap"
Comment: @ealfons1, please type `require("rworldmap")` and see if that fixes it.
Comment: Actually, the code you provided me ended up working, but now I have a new problem. The values produced by the code I originally provided in my question is not producing ISO3 numeric values that match up correctly. For example, for the lat=39.928902 and long=116.388000 (which is China), I got an ISO3 code of 42 (a nonexistent value).
Comment: @ealfons1, consider posting a new question, with a minimal reproducible example of your new problem.


Using Drush with ENVVARS

Question: I use EnvVars (vhost) to set my MySQL settings so I can have cross-server settings.php file without having to update it 3 different times.
I am wondering if there is a way to get drush to do one of the following.

Read the EnvVars from the VHOST (in which case where so I find the Drush database config gathering stuff).
Override the MySQL settings for pm-update
Answer: This is an existing Drush feature request.  See http://drupal.org/node/1848766 and http://drupal.org/node/1335626.
You could also make a bash alias (one per Drupal site) that set the appropriate environment variables, and then called Drush.

Using Drush with ENVVARS


Linear automorphisms of $y^3 + y^6 = x^6$

Question: I have the curve $C \subset \mathbb{C}^2$ defined by the equation $y^3 + y^6 = x^6$ and I have to prove that the set of maps of the form $\varphi = (f_1,f_2) \in \operatorname{Aut}(\mathbb{C}^2)$ such that $\deg(f_1) = \deg(f_2) = 1$ and $\varphi (C) = C$ is a group isomophic to $\mathbb{Z}/6\mathbb{Z} \times \mathbb{Z}/3\mathbb{Z}$.
It's clear that $\left\{ \varphi (x,y) = \left(e^{\frac{2\pi i}{6} k} x,e^{\frac{2\pi i}{3} k'} y \right): 1 \leqslant k \leqslant 6,1 \leqslant k' \leqslant 3\right\}$ holds all conditions and it's isomophic to $\mathbb{Z}/6\mathbb{Z} \times \mathbb{Z}/3\mathbb{Z}$, but I can't prove that these morphisms are all.
Can somebody give me a guidance?
Answer: Using Jacobian criterion, we see that $(0,0)$ is the only singular point of $C$. As automorphisms preserve the singular locus, this forces $\varphi(0,0)=(0,0)$, hence $\varphi$ is actually linear.
As $f_2^3+f_2^6-f_1^6=0$ on $C$ and the ring of regular functions on $C$ is $\mathbb C[X,Y]/(Y^3+Y^6-X^6)$, we get
$$f_2(X,Y)^3+f_2(X,Y)^6-f_1(X,Y)^6=c(Y^3+Y^6-X^6)$$
for some constant $c\in \mathbb C^*$. Write $f_1(X,Y)=a_{11}X+a_{12}Y, f_2(X,Y)=a_{21}X+a_{22}Y$. Substituting $Y$ with $0$ then gives
$$a_{21}^3X^3+a_{21}^6X^6-a_{11}^6X^6=-cX^6.$$
Hence $a_{21}=0$ and $f_2(X,Y)=a_{22}Y$. Therefore
$$a_{22}^3Y^3+a_{22}^6Y^6-(a_{11}X+a_{12}Y)^6=c(Y^3+Y^6-X^6).$$
This immediately implies that $a_{12}=0$, and $a_{22}^3=c=a_{22}^6$, $a_{11}^6=c$. Hence $a_{22}^3=a_{22}^6/a_{22}^3=c/c=1$ and $c=a_{22}^3=1$, thus $a_{11}^6=1$.
Conclusion: $f_1(X,Y)=aX$ with $a^6=1$, $f_2(X,Y)=bY$ with $b^3=1$ and $\varphi(x,y)=(ax, by)$. This proves there is no other automorphisms than that you already found.
Answer: As QiL observes, an affine automorphism $\alpha$ of the plane which preserves the curve must preserve the singular point, and therefore it must be linear.
There is only one line through the singular point which has order of contact there equal to $6$, namely the line $L$ with equation $y=0$, so this line must be preserved by any linear automorphism.
Moreover, the automorphism maps every line parallel to $L$ to a line parallel to $L$. There are exactly three lines parallel to $L$ which intersect the curve in only one point, and these determines three points and it happens that they are on a line $R$. The line $R$ must be preserved by the automorphism, too. One easily sees that $R$ has equation $x=0$.
It follows that $\alpha$ is not only linear but in fact it is diagonal.
Using this piece of information, one finds all possibilities easily.
A simple way of this this is the following. Suppose $\alpha(x,y)=(ax,by)$; of course $ab\neq0$.  Then whenever $y^3+y^6=x^6$ we have $b^3y^3+b^6y^6=a^6x^6$ and therefore $$(a^6-b^6)y^6+(a^6-b^3)y^3=0. \tag{$\star$}$$ This last equation holds for every $y$ in the field such that there is an $x$ with $(x,y)$ in the curve; since the field is algebraically closed, this condition in fact always holds, and we see that the equality $(\star)$ holds for all $y$. This is only possible if $a^6=b^6=b^3$. It follows at once from this that $b$ is a cubic root of unity and $a$ a sixth root of unity.
Comment: Can someone avoid the computation at the end with a geometric argument in the spirit of what precedes it?


Understanding the concept of polynomial ideals

Question: I am not able to understand the fundamental concept behind a polynomial ideal. What I have so far in terms of $I$ being an ideal of a ring is:

for each $f, g \in I$, we have $-f$ and $f+g \in I$, and
for each $f \in I$ and $g \in \mathbb{K}[X_1,...,X_n]$, we have $f\cdot g \in I$.

The second bullet point being the most interesting part, as it maps a polynomial of the ring into the ideal subset. Now I am trying to construct an example making use of following:

$\langle f_1,...,f_s \rangle=\bigg \lbrace \sum\limits_{i=1}^s h_if_i |
> h_1,...,h_s \in \mathbb{K}[X_1,...,X_n] \bigg \rbrace$

So my example is:
$I=\langle f_1,f_2 \rangle=\langle x+y,x^2 \rangle \subseteq \mathbb{K}[x,y] = \bigg \lbrace h_1\cdot (x+y) + h_2\cdot x^2 | h_1,h_2 \in \mathbb{K}[x,y] \bigg \rbrace$
Now if I take an arbitrary polynomial $g$ out of my ring, e.g. $g = x^3$, it should be mapped into the ideal subset by multiplying it with any members of my ideal set, i.e. $g\cdot f_1$ or $g\cdot f_2$. Now if I do it here I get:
$f_1 \cdot g = (x+y)x^3 = x^4+yx^3$
But how is $x^4+yx^3$ being part of $I$? Do I have to choose $h_1=x^3$ in order to do so? I feel being confused by the whole concept of an ideal and missing the fundamental point here. Is an ideal some sort of a basis for algebraic structures?
Comment: I dont' get the question. An ideal is a subring with the added property that you can multiply by elements of the bigger ring. A particular kind of ideal is the one with the elements of the form $h_1 f  + h_2 g$, in fact $w(h_1 f  + h_2 g)= (wh_1) f  + (wh_2) g$.
Comment: And yes, you pick $h_1 = x^3$. There is nothing deep going on here. I don't understand where the confusion comes from.
Comment: Morover you can prove with this theorem https://en.wikipedia.org/wiki/Hilbert's_basis_theorem that in $K[X_1,X_2,...,X_n]$ every ideal is finitely generated, ie every $I$ is of the form $I=$ (for some $k$ depending on $I$).
Comment: Not quite, as for instance $\langle x+y,x^2 \rangle \subset \langle x,y \rangle  \subset \langle 1 \rangle = \mathbb{K}[x,y]$. But you have the right idea in the sense that $\langle x,y \rangle$ is a *maximal* ideal. In fact every maximal ideal is of the form $\langle x-a,y-b \rangle$. See the [Nullstellensatz](https://en.wikipedia.org/wiki/Hilbert%27s_Nullstellensatz).
Comment: By the way, $\mathbb{K}[X_1,\ldots,X_n]$ is a ring but *not* a field.
Comment: Thank you for the replies, I was just missing the purpose of the ideal set. As a side question, can I think of $\langle x,y \rangle$, as being the biggest ideal lying in the ring $\mathbb{K}[x,y]$? Meaning $\langle x+y,x^2 \rangle \subset \langle x,y \rangle$.
Answer: Let's work over a commutative ring $R$. It might also help to think of ideals $I \subset R$ as precisely those subsets that arise as kernels of homomorphisms, i.e., as those subsets that induce a ring structure on the quotient $R/I$. Indeed the second bullet point that you mention is the one that makes the product operation in $R/I$ well-defined. Check that the kernel of a homomorphism between two rings is an ideal; conversely, any ideal $I \subset R$ arises as the kernel of the quotient map $R \to R/I$.
Once you pass to the quotient $R/I$, the generators of $I$ become relations that elements in the ring must satisfy. For example, if $R = \mathbb{K}[x,y]$ and $I = \langle x+y, x^2 \rangle$, the relation $y = -x$ in $R/I$ means that every term where some instances of $y$ appear can be reduced to a term where only $x$ appears. More formally, the map $R/I \to \mathbb{K}[x]/\langle x^2 \rangle$ that sends $ax+by+c$ to $(a-b)x + c$ is an isomorphism between $R/I$ and the algebra of "dual numbers" $\mathbb{K}[x]/\langle x^2 \rangle$.
Also, properties of ideals correspond to properties of the quotient ring. For example, $I$ is prime iff $R/I$ is an integral domain, and $I$ is maximal iff $R/I$ is a field. Taking your example $I = \langle x,y \rangle$, which as we said is a maximal ideal, we have the relation $x = y = 0$ in the quotient ring, so passing to the quotient kills all the variables and leaves only the constants. Thus $R/I \cong \mathbb{K}$ really is a field.
Answer: You are asking about the purpose of ideals; a very good question!
To understand the interest of this concept, do the following exercise.
Suppose $(R, +, *)$ is a commutative ring, and $J$ is a subset of $R$.
Call two elements in $R$ equivalent if their difference lies in $J$.
Denote by $R/J$ the quotient set of $R$ by this equivalence relation.

What condition should $J$ satisfy so that the $+$ operation
descends to $R/J$ and $(R/J, +)$ becomes a group? Answer:
$J$ should be a subgroup for this to work.
(Really $J$ should be a normal subgroup, but since $+$ is
commutative, all subgroups are normal.)
What extra condition should $J$ satisfy so that the $*$
operation also descends to $R/J$ and $(R/J, +, *)$ becomes
a ring? Answer: $J$ should be an ideal.

So although the definition of ideals looks somewhat arbitrary
if stared at bluntly, once you do the exercise above it becomes
clear why these properties are interesting, and clearly we need
a name for subsets of a ring satisfying these properties.


How to convert from Hexadecimal to Decimal and from Decimal to Binary

Question: I would like how can I include the decimal result from the dance method to the light one. For example, in this program, if I input 5F, the decimal result would be 95. Well, I want that 95 to appear as a static int variable in the light method in order to be converted into a binary number. It would be also very helpful if you could tell me how can I limit the hexadecimal number to only 2 figures. Thanks for reading!
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class test2 {
public static void main(String args[]) throws Exception{
        DANCE(args);
        LIGHTS(args);

}
      public static void DANCE(String[]args) throws Exception {
            BufferedReader reader= new BufferedReader(new InputStreamReader(System.in));
            System.out.println("Enter hex no:"+"");
            int no= Integer.parseInt(reader.readLine(), 16);
            System.out.println("Decimal no:"+no);

}
       public static void LIGHTS(String a[]){
                System.out.println("Binary representation: ");
                System.out.println(Integer.toBinaryString(no));
      }
    }

Comment: You should follow the Java Naming Conventions: method names are written in camelCase.
Comment: Max 2 digit number in hex is FF which is 255 in decimal. You can limit input by checking that the decimal input is <= 255.
Comment: Thank you very much it was very helpful all your comments.
Answer: Welcome to Stackoverflow,
if you want to convert a hexadecimal value to a plain integer you can use:
int i = Integer.parseInt("5F", 16);
System.out.println(i); // will print 95

And if you want your plain integer to be converted into a binary String you could use:
String j = Integer.toBinaryString(i); // from the above variable j which contains 95
System.out.println(j); // will print 1011111

Comment: Thank you very much, I've understood how to make it. Thanks again :)


Sysprep without audit mode?

Question: In preparing a (windows 7) machine for cloning, does one need to run it in audit mode before installing/customising? I have a customised machine I would like to sysprep and clone, without having to re-create in audit mode.
And from where does one run sysprep? Is the command included in the windows distro, or do I need to run it from the AIK, or from a PE environment?
Answer: Sysprep is located in C:\windows\System32\sysprep on Windows 7. No need to pull it off the CD anymore.
When you say customized, do you mean the user account is set up like you want it? I have been cloning Windows 7 using the Out of Box Experience option and the Generalize option. You have to go through the mini-setup again, and set up a new user account. Hope this helps a little bit.

Sysprep without audit mode?


Como carregar scripts encadeados recursivamente com o javascript?

Question: Olá, pessoal. Estou tentando fazer uma função que funciona como o require de algumas linguagens, como Ruby.
Usar createElement depois que a página já estiver carregada é tranquilo, mas em cadeia e em tempo de carregamento é uma tarefa complicada.
Com o document.write("


nginx - selective rewrite within a location block

Question: Assuming a location block needs to handle URLs like

/test_api/group_1/version   (several URLs fall in this group.  For example, /test_api/aaa/version, /test_api/bbb/version)
/test_api/group_2/revision  (several other URLs fall in this group.  For example, /test_api/yyy/revision, /test_api/zzz/revision)

How can I selectively rewrite "/test_api/group_1/version" while passing "/test_api/group_2/revision" to a default server within a location block?  If that's not possible, are there other ways to achieve the same goal.
Below is my current non-discriminating location block.
location /test_api {
    types    { application/json json; }
    root     /usr/local/www/data;
    rewrite  "/test_api/([^/]+)/version(.*)/?$"   /api_response/test_api_$1.json   break;
}

Comment: Might be better addressed in SuperUser SE
Answer: when you make two locations like
location /test_api/group_1/version {
  ...
}

location /test_api {
  ...
}

the LONGEST one will always match, so yours group_2 will not match 1st rule
Comment: Thanks for the suggestion.  I have many URLs that fall in each group so I can't code it like that.  I've updated the question to make it more clear.


How do I show that $x+(1-\alpha)y < 0$ for all $0<\alpha < 1$?

Question: Suppose that $x\in\mathbb{R}^{-}$, $y\in\mathbb{R}^{+}$, and $0<\alpha <1$. I would like to construct an argument to show that the expression $x+(1-\alpha)y$ is negative. My take on it is as follows:
$$
x+(1-\alpha)y\leq x-|\alpha-1|y<0.
$$
I think that this does it. However, I'm worried about what I did with $(1-\alpha)$, knowing that $0<\alpha<1$. Am I thinking correctly, or is there something I'm missing here?
Comment: Seems pretty ok to me
Comment: Take $\alpha=0$ and $y=-2x$. Then $x+(1-\alpha) y=-x>0$.
Comment: Also the inequality you've written is wrong - you need that $1-\alpha \le -|\alpha - 1|$ while in fact since $\alpha < 1,$ it is a triviality that $1-\alpha > 0 > -|\alpha - 1|.$
Answer: This result is not true for all $x \in \mathbb{R}^-$, $y \in \mathbb{R}^+$ and $\alpha < 1$. For example, take $\alpha = 1/2 < 1$. Then you would like for $x + (1-\alpha)y = x + y/2$ to be always negative. However, it cannot be true for any $x > 0$ and $y < 0$ since you can take $y > -2x$, and hence $x + y/2 > x - 2x/2 = 0$.
To see what's wrong in your proof, remember that by the definition of the absolute value, for all $x \in \mathbb{R}$ we have $-|x| \leq x \leq |x|$, so it is certain that $\alpha - 1 \leq |\alpha - 1|$. However, since $y$ is positive, the inequality you used here is true if $(1-\alpha) \leq -|\alpha - 1|$, which is equivalent to $|\alpha - 1| \leq \alpha - 1$. So this can be true only if $|\alpha - 1| = \alpha - 1$, that is if $\alpha - 1 > 0$, or $\alpha > 1$. It obviously contradicts your hypothesis.


Specs for minimal quantity and quality of drumkit for child

Question: Inspired by discussion at "It takes dedicated PARENTS to produce a good drummer" -- Tell me more
What is the minimum needed, in terms of quantity and quality, when assembling a drumkit for a child who enjoys drumming as a secondary instrument?
He's not aiming to become a Gene Krupa at this point -- but if he settles into drums as his primary interest as time goes on, then I can spend some $$ on better than minimal quality.
Comment: Regarding close votes: isn't this more of a "what to look for?" question and not a product recommendation question? E.g., http://music.stackexchange.com/questions/23045/what-things-to-look-for-when-buying-my-first-ukulele  http://music.stackexchange.com/questions/3290/what-to-look-for-when-buying-a-digital-piano-for-a-beginner http://music.stackexchange.com/questions/1496/how-do-you-identify-a-good-acoustic-guitar/1499#1499
Comment: Related, arguably duplicate: http://music.stackexchange.com/questions/15598/advice-for-choosing-a-beginner-drum-kit
Answer: You can learn a lot with just a snare drum.
The absolute bare minimum to learn the basics of modern rock/pop/funk/etc. kit drumming is snare, hi-hat, and kick drum.
The most popular starting setup for someone learning to play a drum kit is a student level five-piece set that includes snare, kick, and three toms, plus a cymbal set that includes hi-hat, crash, ride, and sometimes an additional cymbal like a splash or china. Many times not all of the necessary hardware (e.g., cymbal stands) is included, so that is an extra expense. Thrones, sticks, extra heads, etc. are rarely included. You might get a free cymbal bag with the purchase of a cymbal set. In the USA, the new (i.e., not used) price for a five-piece kit plus a hat, crash, and ride cymbal pack and necessary hardware will likely end up between 600 and 1000 USD, more often on the higher end of that range for decent equipment.
One thing I would avoid in terms of cymbal packs are packs that include a "crash-ride" cymbal instead of a ride cymbal. Personally, if I were going to invest money in a cymbal to use as a ride cymbal, I want it to be an actual dedicated ride cymbal. The ride is arguably the cymbal with the most articulation options, so compromising it with a "crash-ride" design would be a detriment to learing the nuances of playing the ride. Plus, eventually one would want a real ride and a second dedicated crash, and at that point a "crash-ride" is most likely useless.
The minimum quality would be good enough to not fall over when struck, drums should be tunable and actually sound different when struck dead center versus at the edges, and cymbals should sound different when struck with the tip versus the shank of the stick. Any quality above that would be unlikely to be appreciated by an absolute beginner, but may serve as further inspiration and enjoyment of playing.
Comment: Personally, drum tuning & damping is "a lot of guessing til it sounds right" combined with having done it for 40 years ;-) ...though there is a great resource, the [Drum Tuning Bible](http://www.menet.umn.edu/~kgeisler/Tuning.pdf)
Comment: I recently saw a jazz group at a party in someone's home and the drummer had a cajon which he sat on and used his heel(s) as kick, a snare, and then 3 or 4 small rides (maybe 6 inch through 10 inch). That was it. He got huge sound out of it.
Comment: I'm with Todd on this one, but just to counterpoint slightly, one of my favourite kits I bought from a junk shop for 50 UKP - kick, snare, ride tom. Not sure whether it was meant to be a 'child's kit' or a 'toy' [they're all non-standard sizes, can't get skins for them], but I add a subset of my regular hardware, hats, kick pedal, one 13" crash, optional ride, + stool & I have a lovely little cocktail kit - easy to play & very sweet sounding, once tuned/damped correctly.
Comment: +1 especially for the notes about crash-ride. I had one on a set that I got and it was SOOOO ringy that in my bedroom I could never really figure out what to do with it if I was playing more than a few bars. After playing some (better) kits, I've found that a little duct tape is a wonderful thing on a practice set.
Comment: @Tetsujin - How do you damp correctly?  Tell me if I should create another question (for it to be promptly closed again....).


Calculating if Romeo and Juliet will stay together always or not.

Question: I have two equations which describe the Love of Romeo for Juliet (R) and Love of Juliet for Romeo (J) as a function of time, $t$.
$R=-c_1e^{3t}-c_2e^{2t}$
$J=2c_1e^{3t}+c_2e^{2t}$
They will stay together forever if $R(t) \gt 0$ and $J(t) \gt 0$, for all $t  \ge 0$.
How to determine if they will stay forever or not?
Comment: Out of interest, where is this problem from?
Comment: @JeremyJeffreyJames Saw it on chegg, but I thought the answer was wrong in it. So I solved the system of equations, and go the above result, but I was confused on ways to proof the duration of this love.
Answer: Focus on the feeling, not the intensity (divide by $^{3}$), and let time pass towards eternity ($\to \infty$); or the end of it.


How to include and use text field in installer

Question: I would like to include license-check into my NSIS installer. Simple Text field and button would be enough for me, but I didn't find any example how to include Text field (text box) into page and how to read its value.
Will you help me with it, please?
Answer: I had this problem and found a different solution:
<code>!include nsDialogs.nsh
!include LogicLib.nsh

...

Page custom MyPageFunc MyPageFuncLeave

...

Var txt
Var myTextBox

...

Function MyPageFunc
    nsDialogs::Create 1018
    ${NSD_CreateLabel} 0 0 50u 10u "Username:"
    ${NSD_CreateText} 70 0 100u 12u ""
    Pop $myTextBox
    nsDialogs::Show
FunctionEnd

Function MyPageFuncLeave
    ${NSD_GetText} $myTextBox $txt
FunctionEnd
</code>
Later pages and their function then have access to $txt, which has the text from the textbox.
Answer: You can use this to create a text field :
<code>!include nsDialogs.nsh
!include LogicLib.nsh
...
Var EDIT
...
${NSD_CreateText} 0 35 100% 12u SomeDefaultText
Pop $EDIT
</code>
And get the input (Not sure for this one) :
<code>System::Call user32::GetWindowText(i$EDIT,t.r0,i${NSIS_MAX_STRLEN})
</code>
(As show in example\nsDialogs\example.nsi)


How to access a variable passed from AngularJS via http in PHP?

Question: I am passing an object into a PHP script like this:
$http({
    method: 'POST',
    url: 'updateCoins.php',
    data: {flips: $scope.data.flips, error: $scope.data.pe},
})

In my PHP script I tried:
$data = file_get_contents("php://input");

and
$data = json_decode(file_get_contents("php://input"));

I then tried echoing back the received value like this:
echo $data.flips

or
echo $data[flips]

or
echo $data->flips

I keep on getting either a blank result or the word "flips" back. How do I access those variables?
Comment: its in the post suerperglobal `echo $_POST['flips'];`
Comment: There's no reason to use `$_POST` over `php://input`, especially if you're sending JSON -- you're fine with what you're doing there already. Try dumping `$data` to see what's actually in it
Answer: If the data was sent JSON-encoded, then it would make sense to json_decode().  I suspect that your data is x-www-form-urlencoded (eg: name=john&age=7).  In this case, PHP parses it into the $_POST array for you.  If you wish to do it on your own, and handle either case, you could do something like:
// Read content-type to determine whether it's JSON data
$type = $_SERVER["CONTENT_TYPE"];
$content = file_get_contents('php://input');

if(strpos($type,'json') > -1):
    $data = json_decode($content, true);
else:
    parse_str($content, $data);
endif;

print_r($data);

You can always visually inspect the data with echo file_get_contents('php://input');
Comment: When I try to echo 'file_get_contents', I get this error in the console: POST http://msolonko.net/updateCoins.php 500 (Internal Server Error)  AND Possibly unhandled rejection: {"data":"","status":500,"config":{"method":"POST","transformRequest":[null],"transformResponse":[null],"jsonpCallbackParam":"callback","url":"updateCoins.php","data":{"flips":10,"error":20},"headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json;charset=utf-8"}},"statusText":"Internal Server Error"}
Comment: My data is in JSON - your code helped me realize that and then I used print_r to see the array structure.
Answer: Php won't grab the posted data from $_POST if the post is formatted in json. You can serialize the post data and submit it thusly
var data = 'flips='+$scope.data.flips+'&error='+$scope.data.pe;

$http({
    method: 'POST',
    url: 'updateCoins.php',
    headers: {'Content-Type': 'application/x-www-form-urlencoded'},
    data: data
});

OR you can do like BeetleJuice recommended. In my application I just do the following so that the rest of the code is uninterrupted.
if (empty($_POST) && file_get_contents('php://input')!==""){
    $_POST = json_decode(file_get_contents('php://input'), true);
}

at which point you can access it with $_POST['flips'] and $_POST['error']


DataTable, Facing issue with select filter when using mRender

Question: I need to filter specific text only but it short only exact value.

I want to show row if a value in filter select is match.
Comment: in datatables, there is a search box
Comment: @Tarif Khan, yes but why don't you want to use the built-in search box?
Comment: Your question is not very clear to what exactly you are trying to achieve. Also a jsFiddle would be helpful...
Comment: @juntapao
here is a demo
http://jsfiddle.net/tarifrudrapur/kg2gyp5e/8/
Comment: @MaVRoSCy Find my demo in comments. If user hi a option there should be all related list display in table
Answer: I recommend using the search functionality of datatables.
However if you insist, change the regex pattern, instead of
column.search( val ? '^'+val+'$' : '', true, false ).draw();

replace it with (removing ^ and $ to search anywhere in the string)
column.search( val ? val : '', true, false ).draw();

See sample below:
http://jsfiddle.net/kg2gyp5e/10/


Proof regarding factorials.

Question: Suppose $a$ and $k$ are positive integers, then how would you prove(not intuitively) that:
$a!k! \leq (ak)!$
Although it is apparent that the inequality is correct, but how can I show this algebraically?
Comment: Your conditions are insufficient. A and K need to be *positive* integers, and strictly positive at that: 2! * 0! is not LTE (2*0)!... As for the proof itself, i have a "gut feeling" it can be done using induction, but i haven't (yet) fully worked it out.
Comment: But, induction does the trick.
Answer: $[1\cdot2\cdot3\dots k][(k+1)\cdot(k+2).\dots (2k)][(2k+1)\cdot(2k+2)\dots (3k)]\dots[(ak-k+1)\cdot(ak-k+2)\dots (ak)]$
$=k!a![(k+1)\cdot(k+2)\cdot\dots (2k-1)(k)][(2k+1)\cdot(2k+2)\dots (k)]\dots [(ak-k+1)\cdot(ak-k+2)\dots (k)]\ge k!a!$
I am taking $1$ from last term of the the first third bracket (1st group of k terms) $2$ from the last term of the 2nd third bracket(2nd group of k terms) , $3$ from the last term of the 3 rd third bracket(3rd group of k terms) and so on to form $a!$
For a more comprehensive answer look at this,
Divide the expression $(mn)!$ into m groups each group consisting of the nos. $\{(kn+1)(kn+2).....((k+1)n)\}$, here k runs from $0$ to $m-1$
So we have ,$\displaystyle (mn)!=\prod_{k=0}^{m-1}(kn+1)(kn+2).....((k+1)n)$
In each group first $n-1$ nos is divisible by $(n-1)!$ as we have m groups so the total product is divisible by $((n-1)!)^m$ (Using the fact that product of $k$ consecutive nos is divisible by $k!$)
Product of the last nos. of the group is $\displaystyle \prod_{k=0}^{m-1}(k+1)n=m!.n^m$
So the whole product is divisible by $((n-1)!)^m.m!.n^m=m!(n!)^m$
Hence proving the fact that $\displaystyle \frac{(mn)!}{m!(n!)^m}$ is an integer.
So $m!n!\le m!(n!)^m\le (mn)!$
Comment: If you use the same \dots for actual dots and multiplication then things are confusing. Use \cdot for multiplication and, if you want, \ldots for three dots. Still, it isn't clear what you did above.
Comment: That's it, but it might not be immediately apparent that you're using the last term of each group of k terms (which is of the form "n.k") and separating it to get the "a!"...
Comment: Now I think its ok @DonAntonio
Comment: Yes, it is now. +1
Answer: Assume $a, k\geq1$.
\begin{align}
\frac {(ak)!} {k!} &= (ak)(ak-1)\cdots(k+1) \\\\
a!&=a(a-1)\cdots2 \\\\
\implies \frac {(ak)!} {a!k!} &= \frac {(ak)(ak-1)\cdots(k+1)}{a(a-1)\cdots2} \geq 1
\end{align}
The numerator has $ak-(k+1)+1=(a-1)k$ terms, while the denominator has $a-1$ terms (which is the same or less by our assumption). Matching each term from the denominator with one from the numerator:
$$ak\geq a\\
ak-1\geq a-1\\
\vdots$$
you get the inequality.
Answer: If $a,k\gt1$ then $(a-1)(k-1)\gt0$; that is, $ak\gt a+k-1$. Since $a,k\in\mathbb{Z}$, we have $ak\ge a+k$.
As an element in Pascal's Triangle, $\displaystyle\frac{(a+k)!}{a!\,k!}=\binom{a+b}{a}\in\mathbb{Z}$, and since $ak\ge a+k$, we have $\dfrac{(ak)!}{(a+k)!}\in\mathbb{Z}$. Therefore,
$$
\frac{(ak)!}{a!\,k!}=\frac{(a+k)!}{a!\,k!}\frac{(ak)!}{(a+k)!}\in\mathbb{Z}\tag{1}
$$
Since $a!\,k!\mid(ak)!$ and $(ak)!\ne0$, we have that $a!\,k!\le(ak)!$.
Now all we have left to do is handle the case where $a$ or $k$ is $1$. In that case, $a!\,k!=(ak)!$, so we are done.

Proof regarding factorials.


Criar função que retorna números aleatórios em C

Question: Estou precisando criar uma função que me retorne números aleatórios sem repetição entre 2 intervalos.
Queria criar um tipo de um jogo de cartas, onde as cartas são embaralhadas, e quando elas retornam nunca saem repetidas.
No meu código está repetindo os valores.
Código retirado por questões de privacidade
Comment: Oi Marconi. Por que excluiu a pergunta, mesmo com uma resposta tão completa? Aliás, você já excluiu várias perguntas! Lembre-se de que o conteúdo postado aqui no site não é para usuários específicos, mas sim para toda a internet. Uma resposta que resolve o seu problema pode também resolver o de outras pessoas. Nós moderadores conversamos e decidimos desfazer a exclusão desta pergunta, ok? De agora em diante, por favor pense duas vezes antes de excluir uma postagem. Se quiser discutir o assunto, estamos à disposição. Obrigado.
Comment: @bfavaretto As Perguntas que excluir ou não houveram respostas, ou foram mal planejadas. Peço desculpas.
Antes de exclui-las irei repensar as perguntas.
Comment: Ok Marconi, obrigado pela compreensão.
Answer: Função randômica
Imagino que você apenas queira usar uma função assim. Criar uma não é tarefa muito simples. melhor usar o que já existe pronto.
#include <time.h>
#include <stdlib.h>
#include <stdio.h>

int main(void) {
    srand(time(NULL));
    int r = rand() %13; //é número de cartas de cada naipe
    printf("Número sorteado %d", r);
    return 0;
}

Veja funcionando no ideone. E no repl.it. Também coloquei no GitHub para referência futura.
A documentação da função rand() e srand() pode ser encontrada aqui.
Algoritmo sem repetição
Acredito que a solução completa que você esteja precisa é baseada no algoritmo Fisher-Yates. Algo assim (se acordo com essa resposta no SO):
int rand_int(int n) {
    int limit = RAND_MAX - RAND_MAX % n;
    int rnd;

    do {
        rnd = rand();
    } while (rnd >= limit);
    return rnd % n;
}

void shuffle(int *array, int n) {
    int i, j, tmp;

    for (i = n - 1; i > 0; i--) {
        j = rand_int(i + 1);
        tmp = array[j];
        array[j] = array[i];
        array[i] = tmp;
    }
}

Aí agora é adaptar para sua necessidade.
Baralho
Achei um exemplo mais ou menos pronto para o que você quer nessa página.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define CARDS 52
#define DRAW 5

void showcard(int card);

int main() {
    int deck[CARDS];
    int c;

/* initialize the deck */
    for (int x = 0; x < CARDS; x++) deck[x] = 0;
    srand((unsigned)time(NULL));
    for (int x = 0; x < DRAW; x++) {
        for(;;) {                 /* loop until a valid card is drawn */
            c = rand() % CARDS;     /* generate random drawn */
            if(deck[c] == 0) {       /* has card been drawn? */
                deck[c] = 1;        /* show that card is drawn */
                showcard(c);        /* display card */
                break;              /* end the loop */
            }
        }                       /* repeat loop until valid card found */
    }
}

void showcard(int card) {
    char *suit[4] = { "Spades", "Hearts", "Clubs", "Diamonds" };
    switch (card % 13) {
        case 0:
            printf("%2s","A");
            break;
        case 10:
            printf("%2s","J");
            break;
        case 11:
            printf("%2s","Q");
            break;
        case 12:
            printf("%2s","K");
            break;
        default:
            printf("%2d",card%13+1);
    }
    printf(" of %s\n",suit[card/13]);
}

Veja funcionando no ideone. E no repl.it. Também coloquei no GitHub para referência futura.
Comment: @Marconi [rand + modulus = fail](http://stackoverflow.com/questions/13104478/uniformity-of-random-numbers-taken-modulo-n) => pegue um compilador C++ razoavelmente moderno, facilite sua vida, [use algo politicamente correto](http://stackoverflow.com/questions/22600100/why-are-stdshuffle-methods-being-deprecated-in-c14). Estude.
Comment: @pepper_chico sei muito pouco de C. conheço mais em asp.net C#.
Comment: @Marconi não se preocupe, você está fazendo um exercício de escola e não um sistema para controlar o banco central. Mas nem importa, tem gente que gosta de uma linguagem e fica defendendo ela mesmo que não traga nenhuma vantagem verdadeira.
Comment: @bigown Obrigado.
Comment: @Marconi recomendo altamente que você leia o primeiro link, puro C. O outro é pra facilitar a sua vida somente, você pode implementar distribuição uniforme em C também, ou usar uma lib qualquer com distribuição uniforme de inteiros de forma correta. É bom que você saiba isto, eu mesmo passei bom tempo sem ficar atento pra isto quando é preciso. Um jogo viciado ou criptografia viciada são portas pra hackers. A vantagem [fato] do C++ é que isto já está na lib padrão.
Comment: @Marconi rand + modulo é tão infame quanto a função gets.
Comment: @pepper_chico Ok, muito obrigado.


How to modify the commerce price formatter label to match shipping service?

Question: Please see attachment. Using Commerce Kickstart 2.
I have a working solution, but I am hoping someone can tell me how to improve it, as it 'feels' poor.
The footer for the default shopping cart view is a footer called commerce_order_total which shows a subtotal for each line item type... typically labeled 'Subtotal' for products and then a generic 'Shipping' label for shipping line items.
That generic 'Shipping' label is hated by our customers. They expect to see the actual shipping service (UPS, Fedex, etc.) So I created a work-around, which I show below, but I fear it is not an efficient solution... basically I just made a tweaked copy of the default commerce code for the price formatter.
What I hope to improve...

Surely there must be a more robust way for the footer to be 'aware' of whether the page being viewed is a cart or an order from history without having to look at the URI, right?
And is there a faster/cheaper way to retrieve the shipping service without loading the entire order -and- all line items?
I was thinking there must be a more granular way to override the description of 'Shipping' in that footer without having to re-invent the entire wheel. I just gave up and did the old cut/paste.

TIA,
---JC

function MYTHEME_commerce_price_formatted_components($variables) {
  global $user;
  $line_item_title = '';
  $order_number = '';
  $path_parts = explode('/', request_path() );
  if( sizeof($path_parts) == 4 && $path_parts[0] == 'user' && $path_parts[2] == 'orders') {
    $order = commerce_order_load($path_parts[3]);
    // dpm($order);
  }
  if( isset($order) && !$order )
    $order = commerce_cart_order_load($user->uid);
  if( isset($order) && $order) {
    foreach ($order->commerce_line_items['und'] as $line) {
      $line_item = commerce_line_item_load($line['line_item_id']);
      $line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);
      // line item TYPE display title
      $line_item_type_title = commerce_line_item_type_get_name($line_item_wrapper->type->value());
        // for shipping line items
      if ($line_item_wrapper->type->value() == "shipping") {
          // shipping data
        $shipping_data = $line_item_wrapper->value()->data;
          // shipping method display title
        $line_item_title = $shipping_data['shipping_service']['title'];
      }
    }
  }
  // Add the CSS styling to the table.
  drupal_add_css(drupal_get_path('module', 'commerce_price') . '/theme/commerce_price.theme.css');
  // Build table rows out of the components.
  $rows = array();
//  dpm($variables['components']);
  foreach ($variables['components'] as $name => $component) {
//    dpm($component);
    if($component)
    $rows[] = array(
      'data' => array(
        array(
          'data' => ($component['title'] == 'Shipping' && $line_item_title ) ? $line_item_title :  $component['title'],
          'class' => array('component-title'),
        ),
        array(
          'data' => $component['formatted_price'],
          'class' => array('component-total'),
        ),
      ),
      'class' => array(drupal_html_class('component-type-' . $name)),
    );
  }
  return theme('table', array('rows' => $rows, 'attributes' => array('class' => array('commerce-price-formatted-components'))));
}

Answer: I think this is equivalent - not sure there's a better way than loading all the line items.
function HOOK_commerce_price_formatted_components_alter(&$components, $item, $entity) {
  foreach ($entity->commerce_line_items['und'] as $line) {
    $line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $line['line_item_id']);

    if ($line_item_wrapper->type->value() == "shipping") {
      $shipping_data = $line_item_wrapper->value()->data;
      $service_title = $shipping_data['shipping_service']['title'];
      break;
    }
  }

  if (isset($service_title)) {
    $components['shipping']['title'] = $service_title;
  }
}

(The title is coming from the price component type - maybe one could use hook_commerce_shipping_service_info_alter() to change the price_component to something per shipping service, and set the title in hook_commerce_price_component_type_info(), but that probably isn't any neater.)


recurrence relation for the number of ways to make a pile of $n$ poker chips using red, white, and blue chips

Question:
Find a recurrence relation for the number of ways to make a pile of $n$ poker chips using red, white, and blue chips and such that no two red chips are together (consecutive).

My workings:
Consider the color of the top chip, if it is red, then he one below cannot be red and the remaining $n-2$ chips give $a_{n-2}$ different ways.
If it is not red, then the remaining $n-1$ chips give $a_{n-1}$ different ways. Then I believe my recurrence relation is
$$a_n = 2a_{n-1}+2a_{n-2}$$
My questions are the following:
1) are my workings correct?
2) should this be for n>2
3) is $a_1=3, a_2=8$ and why?
Answer: 1) and 2) seem correct.

is $a_1=3, a_2=8$ and why?

If you have two poker chips you have 8 ways to make a pile without
two consecutive red chips: $wb,bw,rw,wr,rb,br,ww, bb$. Or you
calculate all possible ways and substract the $rr$ combination: $a_2=3^2-1=8$
Similar for $a_1$: The are 3 ways without two consecutive red chips:
$r,b,w\Rightarrow a_1=3$
Comment: thanks for your detailed answer!
Comment: @user104 You´re welcome.
Comment: is there a $a_0$ term?
Comment: @user104 No.You cannot make a pile of $0$ poker chips.
Comment: good point haha was hoping since now I am trying to solve this recurrence relation


SSSD fails service discovery for AD Global Catalog despite explicitly defined URIs

Question: I'm running into problems with SSSD and Active Directory integration. My AD is setup with a setup of 9 Domain Controllers, some of which are firewalled and inaccessible for various security reasons. Therefore, service discovery won't work with SSSD. This should be fine, as I should be able to explicitly define the URIs as needed.
I have the relevant sections of my sssd.conf that define these URIs looks like this:
[domain/ad.utah.edu]
ldap_uri = ldap://myserver.domain
ldap_backup_uri = ldap://backup-server.domain
krb5_server = myserver.domain

However, when trying to test this configuration with a getent group firstname.lastname@example.com, I see these messages at the start of the activity related to that lookup in the sssd domain logs (debuglevel = 9):
(Tue Nov  7 17:20:26 2017) [sssd[be[mydomain]]] [sdap_id_op_connect_step] (0x4000): beginning to connect
(Tue Nov  7 17:20:26 2017) [sssd[be[mydomain]]] [fo_resolve_service_send] (0x0100): Trying to resolve service 'AD_GC'
...
(Tue Nov  7 17:20:26 2017) [sssd[be[mydomain]]] [ad_get_dc_servers_send] (0x0400): Looking up domain controllers in domain mydomain
(Tue Nov  7 17:20:26 2017) [sssd[be[mydomain]]] [resolv_discover_srv_next_domain] (0x0400): SRV resolution of service 'ldap'. Will use DNS discovery domain 'mydomain'

It eventually finds a DC that is inaccessible, and fails the service resolution:
(Tue Nov  7 17:20:26 2017) [sssd[be[mydomain]]] [sdap_connect_host_resolv_done] (0x0400): Connecting to ldap://inaccessible-host.mydomain:389
....
(Tue Nov  7 17:20:56 2017) [sssd[be[mydomain]]] [fo_resolve_service_timeout] (0x0080): Service resolving timeout reached
(Tue Nov  7 17:20:56 2017) [sssd[be[mydomain]]] [sss_ldap_init_state_destructor] (0x0400): closing socket [26]
(Tue Nov  7 17:20:56 2017) [sssd[be[mydomain]]] [sdap_handle_release] (0x2000): Trace: sh[0xc861f0], connected[0], ops[(nil)], ldap[(nil)], destructor_lock[0], release_memory[0]
(Tue Nov  7 17:20:56 2017) [sssd[be[mydomain]]] [be_resolve_server_done] (0x1000): Server resolution failed: 14
(Tue Nov  7 17:20:56 2017) [sssd[be[mydomain]]] [sdap_id_op_connect_done] (0x0400): Failed to connect to server, but ignore mark offline is enabled.
(Tue Nov  7 17:20:56 2017) [sssd[be[mydomain]]] [sdap_id_op_connect_done] (0x4000): notify error to op #1: 5 [Input/output error]
(Tue Nov  7 17:20:56 2017) [sssd[be[mydomain]]] [acctinfo_callback] (0x0100): Request processed. Returned 3,5,Group lookup failed

I've scoured the man pages for an option to either disable service discovery (it seems should be accomplished by specifying the URIs I have defined in my config), or some option to control the behavior of this 'AD_GC' service (which I've inferred is the AD Global Catalog service from this article: https://community.hortonworks.com/articles/92314/sssd-1.html).
I'm at a loss, however, as to how to control this behavior and disable it or to point it to the appropriate server.
I'm running SSSD version 1.13.4 on ubuntu 16.04.3 if that helps at all.
Comment: Sounds like a DNS problem. If there are domain controllers in a perimeter network or a spoke site that only services local clients, their DNS records should never be returned in a DCLocator lookup. This is typically accomplished using the DNS Mnemonics to prevent the domain controller from registering specific DNS records.
Comment: Good point, I hadn't considered that these inaccessible servers really shouldn't be listed in any meaningful way, if they really are supposed to be inaccessible. I appreciate the suggestion.
Comment: Turns out these domain controllers were properly labeled with different "site" information, and I could tell SSSD to only discovery servers within the proper site. Many thanks for pointing me in the right direction. I'm still not sure why SSSD was performing service discovery when I had the LDAP servers explicitly defined, and perhaps this is still a bug, but at least you helped me find a workable solution.
Answer: I don't know about SSSD - however I do know the relationship between AD and DNS. This line SRV resolution of service 'ldap' combined with the fact that you have purposely isolated Domain Controllers, leads me to believe that it's erroring out once it tries to query an isolated DC from the list of LDAP SRV records in the domain. If that's the case, prevent those DCs from registering their SRV records in DNS.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters
Value name: DnsAvoidRegisterRecords
Data type: REG_MULTI_SZ
Data value: Ldap

Comment: That is a good suggestion, indeed, and I would love to be able to do it and continue to take advantage of SSSD's AD service discovery. However, I don't have much control over Active Directory (I work for a small department within a much larger organization). I'm not sure why these servers have this information published, however, especially if they are part of an isolated network. Your suggestion does make me want to ask our central IT the reason that these domain controllers are publishing their information in DNS if these servers really are inaccessible.

Thanks for the suggestion.
Comment: After digging around some more, I found that the domain controllers that were accessible were labeled with specific "site" information, and SSSD supports the ability to specify this information with an attribute specifies which "site" to use. Thanks again for pointing me in the right direction.
Answer: After a couple of suggestions wondering why there were SRV DNS records for inaccessible servers, I realized that all of the domain controllers had "site" information describing which sites they were intended to serve. It turns out that SSSD can be directed to use specific sites when discovering services with this configuration option:
dns_discovery_domain = SiteName._sites.example.com

Specifying this information wasn't fully supported (keberos discovery didn't respect the site specification) until version 1.12 it looks like (https://pagure.io/SSSD/sssd/issue/2486).
As far as I can tell, SSSD shouldn't be doing any service discovery if I've explicitly defined the LDAP and kerberos URI, but at least I have a solution to my original problem.


What is the best way to transfer 4tb image from windows to centos?

Question: My windows server has 4tb image files, images are scattered in folders by year(10 years), i want to transfer these images to centos. Is there a tool that can upload multiple(not one by one in queue), and retry upload when fail?
Comment: The best way depends, you can copy over the network (by means of exporting a  network share to the other server, or plethora of other networking protocols like rsync, ftp, scp etc.) copy the data to a portable drive and connect that to the new server, or remove the hard disks from the existing server and (temporarily) install them in the new
Answer: Assuming you have network access between both machines, use RSYNC. There is a version for Windows as well.
Answer: You can setup a FTP server (ProFTPd, Pure-FTPd) on your CentOS machine. There are FTP clients for Windows which support auto retry on failure. FTP clients which support auto retry: Flash FXP, Cute FTP of Leech FTP.


Image style effect for removing empty space around image

Question: There can be a lot of situations when e. g. set of logos in png format are not cropped regularly and some images can have different white spaces around the actual logo in the image.
Is there any module that adds an image style effect capable of cropping white space (transparent or white) around image?
Answer: I don't think you can with a module. The only solution is use Photoshop or else.
ImageCache Actions is the best module for custom style image, but I don't believe is going to...


Irreducibility of polynomials over a field

Question: I want to check whether $f(x)=x^3+2x^2+x-1$ is irreducible over $\mathbb Q, \mathbb R, \mathbb Z_2, \mathbb Z_3$?
Definitely, since $f(x)$ is a polynomial of degree 3, therefore, if it is reducible over any of the fields, there exists a zero of $f(x)$ on that field. But I do not think there is any zero of the polynomial in any of the given fields.
Am I right?
Answer: Well, in $\Bbb R$ it must have a root, as $\displaystyle\lim_{-\infty}f=-\infty$ and $\displaystyle\lim_{+\infty}f=+\infty$, and also, $x=1$ would do it for $\Bbb Z_3$. Else, correct:)
Answer: Since the degree of the polynomial is odd, you know that it reduces over $\mathbb{R}$. This is because there is a real root of the polynomial. To determine whether the root is rational you can try to apply the Rational Root Theorem.
For roots over $\mathbb{Z}_2$ and $\mathbb{Z}_3$ try to look for roots. This is easily done because these fields are small.
Comment: By Rational Root theorem, 1 and -1 are the only possible zeros. Definitely, they are not zeros of $f(x)$.
Comment: @Anupam: That is correct.
Answer: HINT: Recall the Mod $p$ Irreducibility Test. I shall state the test for you.

Let $p$ be a prime and suppose that $f(x)\in \mathbb Z[x]$ with $\deg f(x)\ge 1$. Let $\bar f(x)$ be the polynomial in $\mathbb Z_p[x]$ obtained from $f(x)$ by reducing all the coefficients of $f(x)$ modulo $p$. If $\bar f(x)$ is irreducible over $\mathbb Z_p$ and $\deg\bar f(x)=\deg f(x)$, then $f(x)$ is irreducible over $\mathbb Q$.

Another Hint: There is a theorem that states,

Let $f(x)\in \mathbb Z[x]$. If $f(x)$ is reducible over $\mathbb Q$, then it is reducible over $\mathbb Z$.

Hopefully these hints help!


Item do menu ativo mas não funciona mais como link

Question: uma pergunta básica sobre JQuery mas intrigante. O 'li' ativo em menu.
Essa lógica que usei funciona. Porem, a tag 'a' perde sua característica principal que é um link para as outras páginas.

Item 1

Item 2

Item 3

Comment: Esse HTML vem do servidor certo, podes fazer essa mudança de classe no servidor? ou então via url? senão tens de verificar no javascript o url com o link e é meio mau :)
Comment: Sáo links mesmo ou vc vai realizar a operação por jquery tb? olha [aqui](http://jsfiddle.net/oujjy7fp/) o exemplo que eu montei... veja se é isso
Comment: Sérgio. Quando removo o 'e.preventDefault();' os links âncoras para outras páginas voltam a funcionar, como você explicou. Só que perdem a propriedade 'ativa' quando clicamos em um deles.
Answer: Isso acontece devido ao e.preventDefault() adicionado na função de Callback de click. Esse preventDefault() impede que o evento de clique execute seus procedimentos padrões, como o de submeter um formulário HTML, ou seguir o endereço de um link em um elemento .
Mais sobre o preventDefault pode ser lido aqui. (Em inglês).
Answer: Em seu script você está utilizando o e.preventDefault(); que serve para impedir que o evento padrão ocorra, em seu caso, ir para outras páginas.
Para resolver este "problema", basta remover o e.preventDefault(); de seu código, ficando assim:

Veja seu código em funcionamento no Fiddle.
Nesta resposta você possui uma excelente explicação de seu funcionamento.

li.ativa{ color:#f00; }

  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title> - jsFiddle demo by randrade</title>

  <link rel="stylesheet" type="text/css" href="/css/result-light.css">

Menu Redirecionando

Item 1

Item 2

Item 3

Item 1

Mussum ipsum cacilds, vidis litro abertis. Consetis adipiscings elitis. Pra lá , depois divoltis porris, paradis. Paisis, filhis, espiritis santis. Mé faiz elementum girarzis, nisi eros vermeio, in elementis mé pra quem é amistosis quis leo. Manduma pindureta quium dia nois paga. Sapien in monti palavris qui num significa nadis i pareci latim. Interessantiss quisso pudia ce receita de bolis, mais bolis eu num gostis.

Suco de cevadiss, é um leite divinis, qui tem lupuliz, matis, aguis e fermentis. Interagi no mé, cursus quis, vehicula ac nisi. Aenean vel dui dui. Nullam leo erat, aliquet quis tempus a, posuere ut mi. Ut scelerisque neque et turpis posuere pulvinar pellentesque nibh ullamcorper. Pharetra in mattis molestie, volutpat elementum justo. Aenean ut ante turpis. Pellentesque laoreet mé vel lectus scelerisque interdum cursus velit auctor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam ac mauris lectus, non scelerisque augue. Aenean justo massa.

Casamentiss faiz malandris se pirulitá, Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer Ispecialista im mé intende tudis nuam golada, vinho, uiski, carirí, rum da jamaikis, só num pode ser mijis. Adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.

Item 2

Mussum ipsum cacilds, vidis litro abertis. Consetis adipiscings elitis. Pra lá , depois divoltis porris, paradis. Paisis, filhis, espiritis santis. Mé faiz elementum girarzis, nisi eros vermeio, in elementis mé pra quem é amistosis quis leo. Manduma pindureta quium dia nois paga. Sapien in monti palavris qui num significa nadis i pareci latim. Interessantiss quisso pudia ce receita de bolis, mais bolis eu num gostis.

Suco de cevadiss, é um leite divinis, qui tem lupuliz, matis, aguis e fermentis. Interagi no mé, cursus quis, vehicula ac nisi. Aenean vel dui dui. Nullam leo erat, aliquet quis tempus a, posuere ut mi. Ut scelerisque neque et turpis posuere pulvinar pellentesque nibh ullamcorper. Pharetra in mattis molestie, volutpat elementum justo. Aenean ut ante turpis. Pellentesque laoreet mé vel lectus scelerisque interdum cursus velit auctor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam ac mauris lectus, non scelerisque augue. Aenean justo massa.

Casamentiss faiz malandris se pirulitá, Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer Ispecialista im mé intende tudis nuam golada, vinho, uiski, carirí, rum da jamaikis, só num pode ser mijis. Adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.

Item 3

Mussum ipsum cacilds, vidis litro abertis. Consetis adipiscings elitis. Pra lá , depois divoltis porris, paradis. Paisis, filhis, espiritis santis. Mé faiz elementum girarzis, nisi eros vermeio, in elementis mé pra quem é amistosis quis leo. Manduma pindureta quium dia nois paga. Sapien in monti palavris qui num significa nadis i pareci latim. Interessantiss quisso pudia ce receita de bolis, mais bolis eu num gostis.

Suco de cevadiss, é um leite divinis, qui tem lupuliz, matis, aguis e fermentis. Interagi no mé, cursus quis, vehicula ac nisi. Aenean vel dui dui. Nullam leo erat, aliquet quis tempus a, posuere ut mi. Ut scelerisque neque et turpis posuere pulvinar pellentesque nibh ullamcorper. Pharetra in mattis molestie, volutpat elementum justo. Aenean ut ante turpis. Pellentesque laoreet mé vel lectus scelerisque interdum cursus velit auctor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam ac mauris lectus, non scelerisque augue. Aenean justo massa.

Casamentiss faiz malandris se pirulitá, Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer Ispecialista im mé intende tudis nuam golada, vinho, uiski, carirí, rum da jamaikis, só num pode ser mijis. Adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.

Comment: Removi o e.preventDefault(); e voltei a estaca zero. O item ativo não funciona mais.
Comment: O link está fazendo referência à que? Uma página `html`, uma `âncora`, um **site**?
Comment: Uma âncora no site.
Comment: Editei a resposta. Veja se lhe ajuda.
Comment: Funciona perfeitamente seu código. O meu não funciona. Estou usando require_once(toposite.php); e require_once(rodape.php); Só mudam o conteúdo das páginas. O link clicado não fica ativo usando o mesmo código lá.
Comment: Coloque seu `script` dentro da tag **body** e teste.


Redirecting a page after form submission

Question: If I have a module that is creating a page, after form submission for that page, how would I redirect? Is there a function to do this in Drupal? I imagine that I would put the redirect command inside my function that executes after form submission, correct?
Comment: Have you read [Form API reference](https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7), especially [Working with #redirect](https://api.drupal.org/comment/18139#comment-18139) post?
Comment: Which is better, the drupal_goto() or the redirect property?
Comment: Property is there specifically to work with forms. It's less universal than goto, but also practically immune to conflict with other form mechanisms.
Answer: Beside the drupal_goto() function there's also the 'redirect' property in the $form_state
See https://api.drupal.org/comment/18139#comment-18139


Storing the path to folders and inner folders

Question: i'm having difficulties trying to read from sub-folders that are inside a folder. What im trying to do is: i have my path "C:\Dataset" which has 2 folders inside them and inside both folders, i have person names that have pictures for example: "C:\Dataset\Drunk\JohnDoe\Pic1", "C:\Dataset\Sober\JaneDoe\Pic1". I want to be able to read each picture and store them in a path variable.
At the moment, what i got so far, basically, i get the images as long as they are inside Drunk and Sober only, for instance: 'C:\Dataset\Drunk\Pic1', and the code that i am using to do is this:
DATADIR = "C:\Dataset"
CATEGORIES = ["Positive", "Negative"]

for category in CATEGORIES:
    path = os.path.join(DATADIR, category)
    for img in os.listdir(path):
        img_path = os.path.join(path,img)
        img_data = open(img_path, 'r').read()
        break
    break

Basically, what i am trying to do is that when i iterate inside Drunk folder it also iterates inside the inner folders, reading the path to the pictures that are in C:\Dataset\Drunk\JohnDoe\nthPic, C:\Dataset\Drunk\JoeDoe\nthPic, C:\Dataset\Drunk and Sober \nthJoe\nthPic C:\Dataset\Drunk\JamesDoe\nthPic. Therefore, when I do the reading, it grabs the whole folder map
This is basically what my goal is.
Comment: Can't you just retrieve all the images that are in your subdirectories (and the directories that lay below that) and just iterature over that? For instance, you can get all `png` files like this: `glob.glob('C:\Dataset/**/*.png',,recursive=True)`
Answer: You need one nesting more:
It saves all images in the dictionary images, key is the full path.
DATADIR = "C:\Dataset"
CATEGORIES = ["Drunk", "Sober"]

images = {}

for category in CATEGORIES:
    path = os.path.join(DATADIR, category)
    for person in os.listdir(path):
        personfolder = os.path.join(path, person):
        for imgname in os.listdir(personfolder):
            fullpath = os.path.join(personfolder, imgname)
            images[fullpath] = open(fullpath, 'r').read()


Is this integral finite? (convergent)

Question: I came to this problem and I got very curious to know... intuitively I would say this integral is not finite but maybe it is. Let us consider $\mathbb{R}^2$ and only the region $R=\{(x,y)\in \mathbb{R}^2: \, |x|>1, |y|>1\}$. Is the following integral finite?
$$\int_{R} \frac{1}{(\max \{x,y\})^2} dxdy.$$
Any ideas? :)
Thanks a lot :)
Comment: you should split your domain of integration into sectors where $x>y$ or $y>x$, then you should get integrals which can be analysed very easily. I guess you will get a logaritmic divergence in every sector separately.
Answer: This is infinite. Take the region $\hat{R}=\{(x,y)\in \mathbb{R}^2: 1<y\leq x \leq n\}$, we have:
$$
\int_{\hat{R}}\frac{1}{x^2}dxdy = \int_{1}^{n}\int_{y}^{n}\frac{1}{x^2}dxdy\\
=\int_{1}^{n}\left[-\frac{1}{x}\right]_{y}^{n}dy=\int_{1}^{n}\left[\frac{1}{y}-\frac{1}{n}\right]dy\\=\left[\ln y-\frac{y}{n}\right]_{1}^{n}=\ln n-1+\frac{1}{n}
$$
Hence
$$
\int_{R}\frac{1}{x^2}dxdy>\lim_{n \to \infty}\int_{\hat{R}}\frac{1}{x^2}dxdy = \lim_{n \to \infty}\left(\ln n-1+\frac{1}{n}\right)=+\infty
$$

Is this integral finite? (convergent)


Amping the output of my audio interface

Question: I have a Steinberg UR22 MKII audio interface to use with my e-drums and a VST. A few months ago I bought new IEM's and found them to be quite harsh when listening through the interface. I had a Fiio E06 lying around and found that if I used that it somehow fixed the sibilance. I'm not sure what's the issue with the interface, but I would like to upgrade to over the ear headphones and I would probably have to get a better amp for it.
Is there something inherently wrong about plugging an amp after my interface, double-amping wise? I would be open to just getting a different interface if it could give me better hardware and lower latency, but maybe that's a different question alltogether.
On the other hand, I couldn't find a way to have my VST send the audio to something other than my interface when using ASIO, in which case I could just use the amp independently.
Comment: Bus-powered audio interfaces cannot drive headphones as well as dedicated heaphone amplifiers can. There's simply not enough power available from the USB bus, and the UR22 MKII has many other things to do with the few watts it's getting. Did you try an EQ plugin in your DAW's master bus to tame down the sibilance?
Comment: ASIO drivers are generally restricted to one device (your audio interface) or inefficient for low-latency (ASIO4All).  If you're sending MIDI to your PC rather than audio then this might not be a concern.
Answer: The Steinberg UR22 MKII has line outputs, you can attach a headphone amp to those.
Comment: Maybe I wasn't clear. I'm not asking if it's possible, mostly if it's recommended or if getting another interface with better internals would be most ideal.
Comment: There are no technical reasons to choose one or the other. You already have a usable combination, I'd just keep using that until this combo no longer meets your needs.
Answer: You should check to ensure that the sending and receiving units are using line-out, but long as you use the phones out, and a headphone amp, I think that this is the same issue you would have with chaining mixers etc.: it is more an issue of ensuring the first (sending) amp is at unity or below. If they have visual meters, ensure your levels are not peaking.
In some cases, a re-amp device for impedance matching is desirable, such as when taking from audio interface back to a guitar amplifier instrument input that expects guitar hi-Z. Even this shouldn't cause damage, but sans-reamp can result in altered sound. In fact, input gain and treble loss or treble overemphasis are symptoms of impedance mismatch which might be described as sibilance.
Comment: The OP isn't talking about "re-amping" but using a separate headphone ampifier to drive his headphones. :)

Amping the output of my audio interface


Does $\det(A+xB)$ have a nice form for $3 \times 3$ matrices?

Question: I know that if $A,B \in M_2(\mathbb{C})$, then
$$\det(A+xB)=x^2 \det B +x(\operatorname{Tr}A\cdot \operatorname{Tr}B-\operatorname{Tr}(AB))+\det A.$$
What if $A,B \in M_3(\mathbb{C})$? Can we find a similar relation for $\det(A+xB)$?
Comment: Is $x$ a complex scalar? When I try to work out the relation for $2 \times 2$ matrices, assuming $x\in\mathbb{C}$, I get $a_{12}b_{21} + a_{21}b_{12}-a_{11}b_{21}-a_{22}b_{11}$ for the coefficient in $x$, which is different from $\textrm{trace} A \cdot \textrm{trace} B - \textrm{trace} A B$.
Comment: Yeah,it is a complex scalar.
Comment: For the $2 \times 2$ case I used that $\det(A)=\frac{1}{2}((Tr A)^2-Tr(A^2)),\forall A\in M_2(\mathbb{C})$(this is derived from the Hamilton-Cayley theorem).
Comment: Ok, I see where I made a mistake.
Comment: I wanted to edit the sign of the linear term in $x$, but didn't manage to do that since edits need to be at least 6 characters. Take for example $A=I$ and $B = \begin{bmatrix} 0 & 0 \\ 0 & 1 \end{bmatrix}$. Then $\det(A+xB)=1-x$, while $Tr A \cdot Tr B - Tr(AB) = 1$.
Comment: $\det(A+xB)=x+1$ @KoenTiels
Comment: Yes, sorry, you are right.
Answer: First notice that setting $x = 0$ gives that the constant term in $x$ is $\det A$, and appealing to symmetry gives that the leading term is $(\det B) x^3$, so it remains to find the two intermediate terms.
Temporarily assume $A$ is invertible---we'll remove this restriction later. Factoring gives $A + x B = A (I + x A^{-1} B),$ and taking the determinant gives
\begin{align}
\det(A + x B)
&= \det A \det (I + x A^{-1} B) \\
&= \det A [1 + x \operatorname{tr}(A^{-1} B) + x^2 \sigma_2(A^{-1} B) + x^3 \det (A^{-1} B)] .
\end{align}
Here we've just exploited the definition of eigenvalues to write $\det (I + C)$ in terms of the usual symmetric polynomials $\operatorname{tr}, \sigma_2, \det$ of the eigenvalues of $\lambda_i$. Explicitly, $$\sigma_2(C) = \lambda_2 \lambda_3 + \lambda_3 \lambda_1 + \lambda_1 \lambda_2 = (c_{22} c_{33} - c_{23} c_{32}) + (c_{33} c_{11} - c_{31} c_{13}) + (c_{11} c_{22} - c_{12} c_{21}) .$$
So, the coefficient of $x$ in $\det (A + x B)$ is $$\det A \operatorname{tr}(A^{-1} B) .$$ We can write this without using the inversion operator, after which we can appeal to continuity to show that our resulting formula doesn't require the condition that $A$ is invertible.
Using the same trick as before lets us expand the characteristic polynomial of $A$ in terms of symmetric polynomials of the eigenvalues of $A$:
$$\phantom{(\ast)} \qquad p_A(t) = \det(t I - A) = t^3 - (\operatorname{tr} A) t^2 + \sigma_2(A) t - \det A . \qquad (\ast)$$
In particular, the Cayley-Hamilton Theorem gives
$$0 = p_A(A) = A^3 - (\operatorname{tr A}) A^2 + \sigma_2(A) A - (\det A) I ,$$
and (using again that $A$ is invertible) rearranging gives
$$A^{-1} = (\det A)^{-1} [A^2 - (\operatorname{tr} A) A + \sigma_2(A) I].$$ Substituting now gives that the coefficient of $x$ in $\det(A + x B)$ is
\begin{align}
\det A \operatorname{tr}(A^{-1} B)
&= \det A \operatorname{tr}[(\det A)^{-1} [A^2 - (\operatorname{tr} A) A + \sigma_2(A) I] B] \\
&= \boxed{\operatorname{tr}(A^2 B) - \operatorname{tr}(AB) \operatorname{tr} A + \sigma_2(A) \operatorname{tr} B} .
\end{align}
The coefficient of $x$ and the boxed expression are continuous functions that agree where $A$ is invertible, and since this is dense in the set of all $3 \times 3$ matrices, continuity implies that they agree everywhere.
We can calculate the coefficient of $x^2$ in $\det(A + x B)$ similarly, but, as we did for the leading and constant terms in $x$ we can just appeal to symmetry, giving $$\boxed{\operatorname{tr}(B^2 A) - \operatorname{tr}(BA) \operatorname{tr} B + \sigma_2(B) \operatorname{tr} A} .$$ Putting this all together and rearranging a little for aesthetic reasons gives
$$\color{#df0000}{\boxed{\det (A + x B) = x^3 \det B + [\operatorname{tr}(A B^2) - \operatorname{tr} B \operatorname{tr}(AB) + (\operatorname{tr} A) \sigma_2(B)] x^2 \\ \qquad\qquad\qquad\qquad\qquad\qquad + [\operatorname{tr}(A^2 B) - \operatorname{tr} A \operatorname{tr}(AB) + \sigma_2(A) \operatorname{tr} B] x + \det A}} .$$
Finally, we have
$$\sigma_2(C) = \lambda_2 \lambda_3 + \lambda_3 \lambda_1 + \lambda_1 \lambda_2 = \frac{1}{2}[(\operatorname{tr} C)^2 - \operatorname{tr} (C^2)],$$ so substituting lets us produce an expression that relies only on the more familiar trace and determinant operators:
$$\color{#df0000}{\boxed{\det (A + x B) = x^3 \det B + \left[\operatorname{tr}(A B^2) - \operatorname{tr} B \operatorname{tr}(AB) + \frac{1}{2} (\operatorname{tr} A) [(\operatorname{tr} B)^2 - \operatorname{tr} (B^2)]\right] x^2 \\ \qquad\qquad\qquad\qquad\qquad\qquad + \left[\operatorname{tr}(A^2 B) - \operatorname{tr} A \operatorname{tr}(AB) + \frac{1}{2}[(\operatorname{tr} A)^2 - \operatorname{tr} (A^2)] \operatorname{tr} B\right] x + \det A}} .$$
The general procedure here works just as well for finding the coefficients of $\det(A + x B)$ for matrices of any size.
Comment: Cheers, I'm glad you found it useful! If one instead proceeds to compute the coefficient of $x^2$ as we did for the coefficient of $x$, one ends up with a term with a factor $\sigma_2(A^{-1} B)$. We can handle this as before (taking some care to use that $\sigma_2$ is quadratic in its arguments, and not linear like the trace) and produce a formula in which $\sigma_2$ occurs more often and $\operatorname{tr}$ less. In particular, there are multiple formulas in terms of the operators $\det, \sigma_2, \operatorname{tr}$. I'm not even sure that the one in my answer is the simplest.
Comment: I added a short comment to the my answer and another formula for $\det(A + x B)$ that results from it: We can write $\sigma(C)$ just in terms of $\operatorname{tr}$ and $C$ and hence write $\det(A + x B)$ using only $\operatorname{tr}$, $\det$, $A$, $B$, and $x$.
Comment: This is exactly what I was looking for. Excellent work !
Answer: Let $A_1,A_2,A_3$ the columns of $A\in M_3(\mathbb{C})$ and $B_1,B_2,B_3$ the columns of $B\in M_3(\mathbb{C})$. For the property of the determinant of a matrix to be a multilinear application of its columns we must
\begin{align}
\det(A+xB)
=&
\det \Big(A_1+xB_1\;\Big|\;A_2+xB_2\;\Big|\; A_3+xB_3 \Big)
\\
=&
\det \Big(A_1\;\Big|\;A_2+xB_2\;\Big|\; A_3+xB_3 \Big)
\\
+&\det \Big(xB_1\;\Big|\;A_2+xB_2\;\Big|\; A_3+xB_3 \Big)
\\
=&
\det \Big(A_1\;\Big|\;A_2\;\Big|\; A_3+xB_3 \Big)
\\
+&
\det \Big(A_1\;\Big|\; xB_2\;\Big|\; A_3+xB_3 \Big)
\\
+&
\det \Big(xB_1\;\Big|\;A_2\;\Big|\; A_3+xB_3 \Big)
\\
+&
\det \Big(xB_1\;\Big|+xB_2\;\Big|\; A_3+xB_3 \Big)
\\
=&
\det \Big(A_1\;\Big|\;A_2\;\Big|\; A_3 \Big)
\\
+&
\det \Big(A_1\;\Big|\;A_2\;\Big|\;xB_3 \Big)
\\
+&
\det \Big(A_1\;\Big|\; xB_2\;\Big|\; A_3\Big)
\\
+&
\det \Big(A_1\;\Big|\; xB_2\;\Big|\; xB_3 \Big)
\\
+&
\det \Big(xB_1\;\Big|\;A_2\;\Big|\; A_3 \Big)
\\
+&
\det \Big(xB_1\;\Big|\;A_2\;\Big|\; xB_3 \Big)
\\
+&
\det \Big(xB_1\;\Big|\;xB_2\;\Big|\; A_3\Big)
\\
+&
\det \Big(xB_1\;\Big|\;xB_2\;\Big|\; xB_3 \Big)
\end{align}
Then
\begin{align}
\det(A+xB)
=&
\det(A)
\\
&+
x\left(\det(A_1|A_2|B_3)+\det(A_1|B_2|A_3)+\det(B_1|A_2|B_3)\right)
\\
&+
x^2\left(\det(A_1|B_2|B_3)+\det(B_1|A_2|B_3)+\det(B_1|B_2|A_3)\right)
\\
&+
x^3\det(B)
\end{align}
Comment: Thank you ! Do those determinants have a nice form? Or is this the best one?
Comment: @JustAnAmateur No, they do not have a nice form (in terms of the dash of an array for example). The standard is in terms of even determinants.


JS for-loop how to get the first value

Question: I'm sorry for the dumb question. I've been trying to do this for hours now, and i really can't get it to work. So i have a for-loop that loops though some numbers.
But it doesn't take the first value(71990000).
How can this be achieved?
This is what i've got so far:
        var minNr = 0000;
        var maxNr = 10000;
        var prefix = 7199;

        function Nummer(min,max)
        {
            var regex = /^(\d{2})\1$/;

            var guld_nr;
            for(guld_nr = minNr; guld_nr < maxNr;)
            {
                if(regex.test(guld_nr))
                {
                    $(".resultat").append(prefix + "" + guld_nr + "
");
                }

                guld_nr++;
            }

        }

The output is this:
71991010
71991111
71991212
71991313

But i also need the number: 71990000
How can i do that ?
Answer: Use string:
var minNr = '0000';

It's the start value for the regex test, and you need the four zeroes for that. If it would be a number, then you get only one zero for testing. it would help, if you pad it with leading zeroes.

var minNr = '0000',
    maxNr = 10000,
    prefix = 7199;

function Nummer(min,max)        {
    var regex = /^(\d{2})\1$/;

    var guld_nr;
    for(guld_nr = minNr; guld_nr < maxNr;guld_nr++)            {
        if(regex.test(guld_nr))                {
            document.write(prefix + "" + guld_nr + "
");
        }
    }
}

Nummer(minNr, maxNr);
Comment: Thanks! That did the job! Can you tell me, why i needed the zero's to be a string? I would like to know, for another time
Comment: it's the start value for the regex test, and you need the four zeroes for that. if it would be a number, then you get only one zero for testing. it would help, if you pad it with leading zeroes.
Answer: Numbers don't zero-pad themselves; 0000; // 0
Make a custom zero-pad method for it so you can do zpad(0, 4); // "0000"
function zpad(x, digits) {
    var pad = '0';
    x = x.toString();
    digits -= x.length;
    while (digits > 0) {
        if (digits & 1) x = pad + x;
        pad += pad;
        digits >>>= 1;
    }
    return x;
}

Now adjust Nummer accordingly
function Nummer(min, max, prefix) {
    var regex = /^(\d{2})\1$/,
        i, str;
    prefix = prefix || '';

    for(i = min; i < max; ++i) {
        str = zpad(i, 4);
        if(regex.test(str)) console.log(prefix + str);
    }
}

and use
Nummer(minNr, maxNr, '7199');

Side note

Nummer is not constructing an Object, consider camel casing it
Answer: It's because your regex is rejecting the number 0; the first time through the loop, minNr has the numeric value 0 (setting it to 0000 doesn't help; it's just a fancy way of saying 0).  The regex expects two digits followed by the same pattern, but what you're giving it is the string '0'.
You could set minNr to be a string instead on the first pass through ('0000'), and this will solve the problem for '0000', but you will miss '0101', '0202', etc. (which will convert to the strings '101', '202', and so on.)
One solution would be to zero pad the string representation of your number.  The following function will take any number and left zero pad it to fit a given width:
function zeropad(n, w) {
    n = String(n);
    while(n.length < w) n = '0' + n;
    return n;
}

You can use it to convert minNr for the regex:
regex.test(zeropad(guld_nr, 4))

Also note that Number is a built-in object wrapper for literals in JavaScript (all of the primitives have object wrappers: Number, Boolean, String), and by creating a function called Number, you are occluding this built-in object, which is inadvisable (code that needs to use it will invoke your function instead, which is incompatible and has a different purpose).
Comment: I've just tried your solution, and it works more or less. Altho i'm getting the output: 71990, 7199101, 7199202, which means i'm missing a zero in the front of the number. Like it should be 71990101.
Comment: You need to use the `zeropad` function _wherever_ you're converting the number to the string and you need it padded with zeros.  In my answer, I tried to address the understanding of the issue; that numbers are not strings.  They can be converted to a _string representation_ which does _not normally include left-padded zeros_.
Answer: You could use arithmetic to do the digit pattern check, and keep the result numerical:

var minNr = 0; // it does not help to put 4 zeroes here.
var maxNr = 10000;
var prefix = 7199;

function Nummer(min,max) {
    for (var guld_nr = min; guld_nr < max; guld_nr++) {
        if (Math.floor(guld_nr/100) === guld_nr % 100 ) {
            $(".resultat").append((prefix * 10000 + guld_nr) + "
");
        }
    }
}

Nummer(minNr, maxNr);

The problem with your code is when the lower numbers are tested against the regular expression, they are implicitly converted to string, and do not get prefixed zeroes, so they fail on the regular expression.
Anyway, the code will be more efficient when sticking to numbers instead of strings, so I would suggest working with numbers all the way up to the point of outputting them in the browser.
Even more efficient is this code:

var minNr = 0; // it does not help to put 4 zeroes here.
var maxNr = 10000;
var prefix = 7199;

function Nummer(min,max) {
    var test = Math.floor(min/100)*100 + Math.floor(min/100)%100;
    var guld_nr = test < min ? test + 101 : test;
    for (; guld_nr < max; guld_nr+=101) {
        $(".resultat").append((prefix * 10000 + guld_nr) + "
");
    }
}

Nummer(minNr, maxNr);

Comment: There is, but that was treated in some of the other answers. I wanted to focus on efficiency. Regex forces you to use strings, and the conversion + regex execution are costly in terms of execution time. I just added another version of the code that just steps up 101 at a time. No more need to match anything.
Comment: Thanks, so there's no why to use regex, and still get the 0000, 0101, 0202 etc?

JS for-loop how to get the first value


CakePHP include external php file in plugin

Question: I'm making a main app in CakePHP 1.3.10 that has a couple of plugins. In one of them, I need to use a very big array ($array_test) populated "manually".
The way I have it now (which works perfectly) is that I declare the array in the controller of the plugin that I want to use it in (plugin1_home_controller.php for example), doing something like var $array_test = array(1,2,3,4,5...), and I can access it perfectly from the views in that controller.
The thing is that I would prefer having the array declared somewhere else in the plugin, since it's too big, and then load it when I need it.
So I'm trying to create a array_test.php file with the array declared in it, put in /app/plugins/plugin1/webroot/php/array_test.php, and then load it from the view using include "/php/array_test.php" (I also tried include "/plugin1/php/array_test.php" as the CakeBook says in the plugins assets section), but none of them work.
How can I get the right path? Or is there any good alternative to what I want to do? Thank you so much in advance!
Answer: If your plugin is in the app's directory use:
APP_PATH.'plugins'.DS.'plugin1'.DS.'webroot'.DS.'php'.DS.'array_test.php'

If your plugin is installed in the common cake directory:
CORE_PATH.'plugins'.DS.'plugin1'.DS.'webroot'.DS.'php'.DS.'array_test.php'

Comment: Cool! It works! Thank you very much. I just found out that I can use `App::import('Plugins', 'plugin1.php/array_test.php');` as well, but then I have to declare the array as a property of a class. What way is better? Your way needs less code, that's for sure, but I don't know if there's any benefit of using the Import and a class...
Comment: A simple include has less overhead