How to pick AWS CIDR within the CIDR ranges of VPC?

Question: When i try to add a new subnet in my VPC I get this message:

172.22.128.0/24 CIDR is not within the CIDR ranges of VPC.

My current VPC CIDR is 172.22.130.0/28
Any help?
Comment: Hi, if the response below answered your question please upvote and accept it. That's the ServerFault way of saying *Thanks* for the time someone took to help you :)
Answer: The best start is to refer to VPC and Subnet Basics which explains the VPC addressing and sizing reqirements.
Not sure if you are familiar with CIDR addressing? Essentially the bigger the number after / the less hosts and subnets you can fit inside such network.
For example:

Your VPC CIDR is 172.22.130.0/28 where /28 means that out of the 32 bits in the IP address the first 28 bits are the network address (that part has to be the same for all resources in your VPC) and only the remaining 4 bits (= 32 - 28) can be used to address your instances.
That gives you at most 24 = 16 IP addresses in your subnet. With 5 IPs reserved by AWS you can only use 11 IP addresses.

Also because the minimum subnet size is /28 you can really create only one subnet in your /28 VPC and it has to have the same CIDR range, i.e. 172.22.130.0/28.
That effectively prevents you from placing your instances in multiple availability zones because subnets can not span across AZs.

Much better practice is to allocate rather large CIDR blocks for your VPC. At least /24 but even larger if you can. Where larger means /22 or /20 or even /16. That will give you an opportunity to create subnets in multiple availability zones and create both private and public (DMZ) subnets.
In your case you can allocate 172.22.128.0/24 to the VPC and then create 4 subnets inside the VPC:

Public A = 172.22.128.0/26 (in Availability zone a, e.g. ap-southeast-2a)
Public B = 172.22.128.64/26 (in AZ b, e.g. ap-southeast-2b)
Private A = 172.22.128.128/26 (in AZ a again)
Private B = 172.22.128.192/26 (in AZ b again)

That will give you around 60 IP addresses in each subnet and you can have some hosts in Private subnets and some in Public, you can balance load across availability zones, etc.
If you want to go one step higher and allocate 172.22.128.0/22 to your VPC the addressing then would be like this:

VPC CIDR = 172.22.128.0/22
Public A = 172.22.128.0/24
Public B = 172.22.129.0/24
Private A = 172.22.130.0/24
Private B = 172.22.131.0/24

For the difference between Public and Private subnets refer to this answer: NAT gateway for ec2 instances
Hope that helps :)
Comment: @omarjalloh I'm glad I could help :) If you're happy with the answer please upvote and accept it. Thanks!
Answer: The subnet you're trying to add is

not within your VPC's IP range
bigger than your VPC's IP range

As such, you can't add it.
Side note: I didn't know AWS would even let you make a /28 VPC. You'll only have fourteen usable IPs in there.
Comment: @omarjalloh You should delete the VPC and start over. A `/28` is way too small for virtually any use case on AWS.
Comment: Ok,  any ideas what subnet range I can use?
Comment: You can use /16 to /28 in AWS. A /28 is appropriate for a up to about 9 servers, which is a valid use case for some rare needs. Consider a single server that never needs to scale, has no ELB, etc, and your IP address range has to integrate with a large corporate range without NAT.


Filter deep nested menu array if menu name includes in allowed menu string array

Question: Hello i am trying to filter this menu to permitted menu
I have a menu structure as follows:
 const routes = [
    {
      path: '/dashboard',
      name: 'dashboard',
      children: [
        {
          path: '/style-guide',
          name: 'style_guide',
        },
      ],
    },
    {
      path: '/tables-management',
      name: 'tables_management',
      children: [
        {
          path: '/auxiliary',
          name: 'auxiliary',
          children: [
            {
              path: '/reporting-code',
              name: 'reporting_code',
            },
            {
              path: '/budget-levels',
              name: 'budget_levels',
            },
            {
              path: '/qr-codes',
              name: 'qr_codes',
            },
            {
              path: '/error-code',
              name: 'error_code',
            },
          ],
        },
    },
  ];

and this is the allowed routes
const pages= ["style_guide", "reporting_code", "qr_codes"]

and i want to filter the routes that includes in the pages array without hiding the parent route if have any children
so the results should show the dashboard route since style_guide is a visible child
i was trying to do so but its returning more than expected
const filter = (arr => {
    return arr.filter(obj => {
      if (obj.children && obj.children.length) {
        return filter(obj.children);
      }

      return !!(obj.name && pages.includes(obj.name));

    });
  });

what am i missing?
whats the best way to implement it
anyhow to it by spread operators?
thanks
Answer: You need to reduce the array, because filter does not change the children array.
For an approach without mutating data, you need to create new objects.

const
    getAllowed = (routes, pages) => routes.reduce((r, o) => {
        if (pages.includes(o.name)) {
            r.push(o);
        } else if (o.children) {
            let children = getAllowed(o.children, pages);
            if (children.length) r.push({ ...o, children });
        }
        return r;
    }, []),
    routes = [{ path: '/dashboard', name: 'dashboard', children: [{ path: '/style-guide', name: 'style_guide' }] }, { path: '/tables-management', name: 'tables_management', children: [{ path: '/auxiliary', name: 'auxiliary', children: [{ path: '/reporting-code', name: 'reporting_code' }, { path: '/budget-levels', name: 'budget_levels' }, { path: '/qr-codes', name: 'qr_codes' }, { path: '/error-code', name: 'error_code' }] }] }],
    pages = ["style_guide", "reporting_code", "qr_codes"],
    result = getAllowed(routes, pages);

console.log(result);
.as-console-wrapper { max-height: 100% !important; top: 0; }


Is there a way to see that the map $\gamma:V\rightarrow \text{Cl}(V)$ is injective from construction?

Question: Let $(V,Q)$ be a $\mathbb{C}$ or $\mathbb{R}$ linear vector space with a symmetric bilinear form $Q$. Then we can construct a Clifford algebra by taking the tensor algebra $T(V)$, and taking the quotient by the ideal $I$ generated by the subsets:
$$I=\{v\otimes v+Q(v,v):v\in V\}$$
Let $\gamma=\pi\circ i$, where $i:V\rightarrow T(V)$ is the inclusion map, and $\pi:T(V)\rightarrow T(V)/I$ is the quotient map. If one could show that $I\cap V=\{0\}$ it should then follow that the map $\gamma:V\rightarrow T(V)/I$ is injective. Let $v\in I\cap V$, then:
$$v=\sum_{i}a_i\otimes (v_i\otimes v_i+Q(v_i,v_i))\otimes b_i$$
Since $v\in V$ we can assume that for each $i$ the degree of $a_i$ and $b_i$ sum to $1$, i.e.
either $a_i$ is a vector, and $b_i$ is a scalar or vice versa. Since $v\in V$, we need:
$$\sum_ia_i\otimes (v_i\otimes v_i)\otimes b_i=0$$
My question is then, can we use this to show that:
$$\sum_{i}a_i\otimes b_i Q(v_i,v_i)=0$$
I don't see a way forward to prove this, and I suspect these conditions are a little to0 general to see why this should be immediately clear. I believe it should be true, since there are other ways to show that $\gamma$ is an injection.
One thought I had was to consider the map:
$$Q':V^{\otimes 4}\rightarrow V^{\otimes 2}$$
given on simple tensors by:
$$Q'v_1\otimes v_2\otimes v_3\otimes v_4\rightarrow v_1\otimes v_4 \dot Q(v_2,v_3)$$
but then I quickly remembered that one of $a_i$ or $b_i$ is a scalar, so I would really need a map from $V^{\otimes 3}\rightarrow V$, and since $a_i$ or $b_i$ could be a vector on either side of $v_i\otimes v_i$, I don't think there is a consistent way of obtaining a map like that. Any help would be appreciated.
Comment: See the answer by MTS to the MO question [here](https://mathoverflow.net/questions/68378/clifford-algebra-non-zero).
Comment: @KCd this is the other way of proving it I know. I was wondering if there was a way to get directly from the construction, by directly showing that $I\cap V=\{0\}$
Comment: Oh!  You should've given that background context in your question. To be honest, working with the ideal $I$ in a direct way seems like it would be a mess. Have you looked in books that develop Clifford algebras to see how they compute the dimension to be $2^n$? Jacobson's Basic Algebra II is one such book. Any proof of the dimension ought to include at least implicitly an argument that $V$ embeds into the Clifford algebra of $(V,Q)$.
Answer: $
\newcommand\Ext{\mathop{\textstyle\bigwedge}}
\newcommand\Cl{\mathrm{Cl}}
\newcommand\gtensor{\mathbin{\hat\otimes}}
\newcommand\gen[1]{\langle#1\rangle}
$I'm having a surprisingly hard time finding this result (though one should really expect I'd find it if I keep looking). Pertti Lounesto references Bourbaki 1959 and T.Y. Lam 1973 in Clifford Algebras and Spinors, but I've not had success finding a copy of either. Ian Porteous goes a much different route in Clifford Algebras and the Classical Groups by constructing real/complex Clifford algebras as matrix algebras or direct sums of matrix algebras.
Larry Grove gives the following "proof" in Classic Groups and Geometric Algebra (which I paraphrase here):

Proposition 8.7. The linear transformation $\pi$ restricted to $V$ is 1-1.
Proof. Note that $\ker \pi|_V = V\cap I$. Since $V \subseteq T(V)$ has no elements of degree greater than 1, whereas $I$ is generated by elements of degree 2, it is clear that $V\cap I = 0$.

This doesn't make any sense to me, and indeed if this argument worked then it would work just as well if $V$ were a module over an arbitary ring; but Jacques Helmstetter and Artibano Micali give Example 3.1.3 on page 106 of Quadratic Mappings and Clifford Algebra as a counterexample.
So below I give my proof in terms of the ideal $I$, and then also a corresponding proof in terms of universal properties and the fundamental isomorphism $\Cl(V,Q) \cong \Cl(V_1,Q)\gtensor\Cl(V_2,Q)$ where $V = V_1\oplus V_2$ is an orthogonal decomposition.
In Terms of $I$
We write $\Cl(V, Q) = T(V)/I$ and $Q(w) = Q(w,w)$.
The result is almost trivial when $Q$ is non-degenerate. Suppose there is nonzero $v$ such that $\pi(v) = 0$. For any $w \in V$ we have
$$
  2Q(v, w) = \pi(v + w)^2 - \pi(v)^2 - \pi(w)^2 = \pi(v)\pi(w) + \pi(w)\pi(v) = 0.
$$
Thus $v$ must be in the radical $V^\perp$, and so we have
Lemma. If $Q$ is non-degenerate then $\pi$ restricted to $V$ is injective. Equivalently, $V\cap I = \{0\}$.

Note: the following argument is likely broken, see the comments. However, I believe the argument in terms of universal properties further down is sound.

Now consider an orthogonal decomposition $V = V_1 \oplus V^\perp$; it follows that $V_1\cap I_1 = \{0\}$ where $I_1$ is the ideal of $T(V_1) \subseteq T(V)$ generated by elements of the form $v\otimes v - Q(v)$ for $v \in V_1$.
Every $w \in V$ can be uniquely written $w = u + r$ for $u \in V_1$ and $r \in V^\perp$. Thus if $v \in V\cap I$ we may write
$$
  v = \sum_ia_i\otimes X_i\otimes b_i
$$
where
$$
  X_i
    = w_i\otimes w_i - Q(w_i)
    = u_i\otimes u_i - Q(u_i) + r_i\otimes r_i + u_i\otimes r_i + r_i\otimes u_i
$$
with $u_i \in V_1$ and $r_i \in V^\perp$. We may assume that each term of the sum in $v$ has grade 1; WLOG we may assume $(a_i, b_i) = (v'_i, 1)$ for $v'_i \in V_1$ or $v'_i \in V^\perp$.
Let $X'_i = u_i\otimes u_i - Q(u_i)$. Since $v'_i\otimes X_i$ has grade 1 it follows that $w\otimes X_i$ has grade 1 for all $w \in  V$, in particular $w \in V_1$. But then $w\otimes X'_i$ is in $V_1\cap I_1$ and so must be zero:
$$
  0 = w\otimes X'_i = -Q(u_i)w.
$$
Whether or not $V_1$ is trivial we get $Q(u_i) = 0$. So now
$$
  X_i = u_i\otimes u_i + r_i\otimes r_i + u_i\otimes r_i + r_i\otimes u_i
$$
and every term of $v$ is of grade at least 2, hence $v = 0$.
In Terms of Universal Properties
Essentially what I will do now is show that the subalgebra generated by $V^\perp$ is isomorphic to its exterior algebra while also preserving the map $\pi : V^\perp \to \Cl(V,Q)$. Then since the natural map $V \to \Ext V^\perp$ is injective we get that $\pi$ is injective on $V^\perp$. First we prove the all-important universal property.
Theorem 1. $\Cl(V,Q)$ satisfies the following universal propery: for any other associative algebra $A$ and linear $f : V \to A$ such that $f(w)^2 = Q(w)$ there is a unique algebra homomorphism $F : \Cl(V,Q) \to A$ such that $F(\pi(w)) = f(w)$ for all $w \in V$.
Proof. By the universal propery of $T(V)$ there is a unique algebra homomorphism $G : T(V) \to A$ such that $G(w) = f(w)$ for all $w \in V$. We write $\iota \in I$ as
$$
  \iota = \sum_ia_i\otimes(v_i\otimes v_i - Q(v_i))\otimes b_i
$$
whence
$$
  G(\iota) = \sum_iG(a_i)(f(v_i)^2 - Q(v_i))G(b_i) = 0.
$$
Thus $G$ descends to the desired homomorphism $F : \Cl(V,Q) \to A$. $\quad\Box$
Definition. The $\mathbb Z/2\mathbb Z$-graded tensor product $A\gtensor B$ of two $\mathbb Z/2\mathbb Z$-graded algebras $A, B$ is a $\mathbb Z/2\mathbb Z$-graded algebra defined with underlying set $A\otimes B$ and such that
$$
  (a\otimes b)(a'\otimes b') = (-1)^{\partial a'\partial b}(aa')\otimes(bb')
$$
where $b, a'$ are homogeneous with degrees $\partial b, \partial a'$.
Theorem 2. Let $V = V_1\oplus V_2$ be an orthogonal decomposition. Identify $T(V_1)$ and $T(V_2)$ as subalgebras of $T(V)$ and let $\pi_i$ denote the natural projection of $\Cl(V_i, Q)$. Then there is an algebra isomorphism
$$
  \psi : C = \Cl(V_1,Q)\gtensor\Cl(V_2, Q) \cong \Cl(V,Q)
$$
such that $\psi(\pi_1(w)) = \pi(w)$ for all $w \in V_1$ and $\psi(\pi_2(w)) = \pi(w)$ for $w \in V_2$.
Corollary. $\pi$ is injective on $V$ for any $Q$.
Proof. We choose $V_2 = V^\perp$ whence $\Cl(V_2, Q) = \Ext V^\perp$. If $\Ext V^\perp = T(V^\perp)/I_\perp$ with $I_\perp$ the appropriate ideal, then if $v \in V^\perp\cap I_\perp$ we see that $v = 0$ since every element of $I_\perp$ has degree at least 2. Hence $\pi_2$ is injective on $V^\perp$ and so $\pi = \psi\circ\pi_2$ is injective on $V^\perp$. Similarly $\pi_1$ is injective on $V_1$ by the Lemma and so $\pi$ is injective on $V_1$. Hence $\pi$ is injective on $V = V_1\oplus V_2$. $\quad\Box$
Proof of Theorem 2. For each $i = 1,2$, by the universal property of $\Cl(V_i, Q)$ we get a homomorphism $\psi_i : \Cl(V_i,Q) \to \Cl(V,Q)$ such that $\psi_i(\pi_i(w)) = \pi(w)$ for $w \in V_i$. Define $\psi = \psi_1\otimes\psi_2$. By the universal property of $\Cl(V,Q)$ we get $\phi : \Cl(V,Q) \to C$ such that
$$
  \phi(\pi(w_i)) = \pi_i(w_i)\quad\text{when }w_i \in V_i.
$$
If $X_1 \in T(V_1)$ and $X_2 \in T(V_2)$ it now easily follows that
$$\begin{aligned}
  \phi\Bigl(\psi(\pi_1(X_1)\otimes\pi_2(X_2))\Bigr)
    &= \phi\Bigl(\psi_1\bigl(\pi_1(X_1))\otimes\psi_2(\pi_2(X_2)\bigr)\Bigr)
\\
    &= \phi(\pi(X_1))\otimes\phi(\pi(X_2))
\\
    &= \pi_1(X_1)\otimes\pi_2(X_2).
\end{aligned}$$
Every element $C$ is a sum of elements of the form $\pi_1(X_1)\otimes\pi_2(X_2)$, so by linearity $\psi = \phi^{-1}$ is an isomorphism with the requisite properties. $\quad\Box$
Comment: Thank you, this is very nice. I do wish there was a way to prove it without assuming $Q$ was non degenerate though.
Comment: @Chris I don't assume that. I prove it for the case $Q$ is non-degenerate (the Lemma) and then use that fact to prove it in the general case. Or are you saying you wish there were a way that didn't make this sort of case analysis?
Comment: Oh you are right, I got confused, my bad.
Comment: Wait why can we assume with out loss of generality that $(a_i,b_i)=(v'_i,1)$? We can't swap tensor product, so there could be terms like $(a_i,b_i)=(1,v'_i)$, no?
Comment: @Chris Maybe not the best choice of words. What I mean is the proof is almost exactly the same regardless of what side $v_i'$ is on.
Comment: I see, however, I can't see how we can assume each term in the sum of $v$ has grade one. I agree we can rewrite $v$ as a sum of grade one terms, but that get's rid of the grade two terms in $X_i$. In other words, I don't believe it is correct to say that $w\otimes  X_i$ is grade one for all $i$, because $X_i=w_i\otimes w_i-Q(w_i)$, so $w\otimes X_i$ is inhomogenous.
Comment: Actually, I believe your conclusion in the first part is incorrect. Particularly, if $V=\mathbb{R}^n$, and the orthogonal decomposition is $V=\mathbb{R}^t\oplus\mathbb{R}^s$, where $t+s=n$, and $Q$ is identically zero on $t$, but is the euclidean inner product on $\mathbb{R}^t$, then we can't have $Q(u_i)=0$.
Comment: @Chris To your first point: I think you're right, what we can say is that the sum is zero or that each term has a grade 1 component. This probably breaks the argument, I will add a disclaimer. To your second point: we absolutely can have $Q(u_i) = 0$, it just means that $u_i = 0$.
Comment: My original intent was to translate the universal property argument to ideal language, but then I had thought I had stumbled upon something simpler.
Comment: Oh yes of course, it means that $u_i=0$, my bad. Regarding your response to the first point, I will play around with it some more, I still think there is something to be done here without making the assumption.


Hide the "view exposed filter" form or reload the page after submit the form?

Question: I am using view exposed filter on a view display as "block". The block is added to dashboard.
I added a second function to "Apply" button using hook_form_alter. I want to hide the expose form of view after submit it. I added the jquery to hide the element using drupal_add_js. But it didn't work.
Is there any way to hide the form or reload the page after submit of expose form so i can hide the form on page load?
Answer: Try this:
function custom_form_views_exposed_form_alter(&$form, &$form_state, $form_id) {
  if ($form['#id'] == 'views-exposed-form-YOURVIEWNAME') {
    if($_GET['xxx'] == 0){
      hide($form);
    }
  }
}

Comment: Thanks. But I don't even remember my scenario. It was a very very old question. :P :)


What does the "Test of Epoch [number]" mean in Mozilla DeepSpeech?

Question: What does the "Test of Epoch [number]" mean in Mozilla DeepSpeech?
In the following example, it says Test of Epoch 77263, even though there should be just 1 epoch from my understanding, since I gave --display_step 1  --limit_train 1  --limit_dev 1  --limit_test 1 --early_stop False --epoch 1 as arguments:
dernoncourt@ilcomp:~/asr/DeepSpeech$ ./DeepSpeech.py --train_files data/common-voice-v1/cv-valid-train.csv,data/common-voice-v1/cv-other-train.csv --dev_files data/common-voice-v1/cv-valid-dev.csv --test_files data/common-voice-v1/cv-valid-test.csv --decoder_library_path /asr/DeepSpeech/libctc_decoder_with_kenlm.so --fulltrace True --display_step 1  --limit_train 1  --limit_dev 1  --limit_test 1 --early_stop False --epoch 1
W Parameter --validation_step needs to be >0 for early stopping to work
I Test of Epoch 77263 - WER: 1.000000, loss: 60.50202560424805, mean edit distance: 0.894737
I --------------------------------------------------------------------------------
I WER: 1.000000, loss: 58.900837, mean edit distance: 0.894737
I  - src: "how do you like her"
I  - res: "i "
I --------------------------------------------------------------------------------
I WER: 1.000000, loss: 60.517113, mean edit distance: 0.894737
I  - src: "how do you like her"
I  - res: "i "
I --------------------------------------------------------------------------------
I WER: 1.000000, loss: 60.668221, mean edit distance: 0.894737
I  - src: "how do you like her"
I  - res: "i "
I --------------------------------------------------------------------------------
I WER: 1.000000, loss: 61.921925, mean edit distance: 0.894737
I  - src: "how do you like her"
I  - res: "i "
I --------------------------------------------------------------------------------

Answer: Explanation by Tilman Kamp:

This is actually not a bug, as the current epoch is computed on base
  of your current parameters and the snapshot-persisted global
  step-count. Take a close look into this excerpt:
# Number of GPUs per worker - fixed for now by local reality or cluster setup
gpus_per_worker = len(available_devices)

# Number of batches processed per job per worker
batches_per_job  = gpus_per_worker * max(1, FLAGS.iters_per_worker)

# Number of batches per global step
batches_per_step = gpus_per_worker * max(1, FLAGS.replicas_to_agg)

# Number of global steps per epoch - to be at least 1
steps_per_epoch = max(1, model_feeder.train.total_batches // batches_per_step)

# The start epoch of our training
# Number of GPUs per worker - fixed for now by local reality or cluster setup
gpus_per_worker = len(available_devices)

# Number of batches processed per job per worker
batches_per_job  = gpus_per_worker * max(1, FLAGS.iters_per_worker)

# Number of batches per global step
batches_per_step = gpus_per_worker * max(1, FLAGS.replicas_to_agg)

# Number of global steps per epoch - to be at least 1
steps_per_epoch = max(1, model_feeder.train.total_batches // batches_per_step)

# The start epoch of our training
self._epoch = step // steps_per_epoch

So what happens is that your set-size during training differs from
  your current set size. Thus the strange epoch number.
Simplified example (without confusing batch size): If you once trained
  5 epochs of a 1000 sample training-set, you got 5000 "global steps"
  (persisted as a number in your snapshot). After this training you
  change the command line parameters to a set of size 1 (your --limit_*
  parameters). "Suddenly" you'll get displayed epoch 5000, because 5000
  global steps means applying a data-set of size 1 5000 times.

Take away: use the --checkpoint_dir argument to avoid this kind of issues.


How to notate a non-standard hexatonic key

Question: I am writing part of a piano piece in a hexatonic "key" containing these notes:
C - D# - E - G - Ab - B
(I say "key" instead of scale because I'm treating it like a key, deriving not just melody but also the chords from this "key", and staying mostly "in key". If you think that this is not a key but a scale, feel free to call it a scale in your answer.)
The "key" is the same when transposed up or down a major third, but it makes most sense to see this part as being in some sort of key of C, because it starts with a C minor-ish feel and ends with a C major-ish feel.
Now I'm wondering how to notate this. Do I consider the D# and E to be an Eb and Fb in order to have a key signature with only flats? Or would three flats just confuse people into thinking the part is in Eb? Do I use a novel key signature with a sharp and a flat? Or should I notate this in  C and use accidentals for D# and Ab? Maybe there is a precedent?
Answer: If you want it to be read and played, use an open key signature and accidentals.
If you want it to be analysed and discussed, maybe concoct a non-standard key signature.
Comment: Non-standard key signatures can be confusing if not clearly called out.  Many players will not actually look at the lines the accidentals are on but simply count how many of them there are, so if you put e.g. 3 flats in the signature, but not in the usual places, people will wrongly assume Eb maj/C min without checking what notes they're actually on.  A signature with mixed sharps and flats might be unusual enough to make people pay more attention though...
Comment: Although the other answers are stronger on details, this is an important distinction.  BTW, A famous use of nonstandard signatures (in Bartók's [Mikrokosmos](https://en.wikipedia.org/wiki/Mikrokosmos_(Bart%C3%B3k))), was described by it's composer as "...half-serious, half-jesting procedure was used to demonstrate the absurdity of key signatures in certain kinds of contemporary music." (Thanks to [this answer](https://music.stackexchange.com/a/59293/27385) which references *Bartók for Piano: A Survey of His Solo Literature* by David Yeomans.)
Answer: Use accidentals.  Do not use a key signature.
Further, do not automatically notate all notes of the 2nd and 5th scale degrees as D# and Ab, respectively.  Using Eb and G# might make more sense in certain contexts.  (Generally, you should avoid notating augmented intervals.)
I know from experience that this is the best way.  I have composed with this scale and countless other scales.  While it is initially tempting to use a non-standard key signature in such a case, it is not a good idea.  Here are some reasons:

Most performers have spent their lives internalizing and optimizing for standard notation and will be tripped up by any non-standard elements.  To avoid confusion and performance mistakes, only deviate from standard notation when absolutely necessary.  Include explanations of any such deviations with the score.  The liberal use of accidentals isn't really a deviation from normal at all and requires no explanation.  It is certainly a smaller deviation than a whacky key signature mixing sharps and flats.
While a non-standard key signature might technically be feasible for some scales, this is not generally the case for any and all scales.  For example, it is impossible to devise a key signature for the octatonic scale.  I'm inclined to go with an approach that is more broadly applicable.
You might want to use more than one scale in the same composition.  Then what, change key signature?  What if you're using two scales simultaneously (eg augmented in the left hand, double harmonic in the right)?  Then it will get messy.  It's best to just use accidentals.

In other words, K.I.S.S.
Answer: There's no particular rule for this, so you can go with whatever makes the most sense for your music.
The particular scale you're using is more commonly known as the Augmented Scale and is notated C - Eb - E - G - G# - B. The name comes from the presence of two augmented chords – C, E, G# and Eb, G, B. The scale spelling also clarifies its construction as an interleaved C minor triad and E major triad.
Wikipedia lists several compositions and composers who have employed this scale.
Comment: @Italkedwithazombie A good place to start would be [Ian Rings website](https://ianring.com/musictheory/scales/2457)
Comment: Thank you. I'll have a look at the list on Wikipedia and check out the scores. It's an obvious scale and I assumed it had been used before, but I didn't really know how to search for it.
Comment: @Italkedwithazombie You may also find the Reddit thread [Usage of the Augmented Scale](https://www.reddit.com/r/musictheory/comments/8z5pmx/usage_of_the_augmented_scale/) useful.
Comment: If spelled as C–E♭–E–G–G♯–B, I would have considered it an interleaved C augmented triad and E♭ augmented triad.  But why not consider it an interleaved C aug and G aug, spelled as C–D♯–E–G–G♯–B.
Comment: @Theodore Short of knowing the specific origins of the scale, spelling it a C aug + G aug obscures the presence of the C minor triad.
Comment: @It'sHEDLEY I was just thinking it's called an augmented scale, why not consider it made of augmented chords?
Comment: @Italkedwithazombie Is is: C augmented and Eb augmented.
Answer: Hexatonic pole of C! I (and plenty other composers among history) used this here and there when composing in a more modal atmosphere. I love the suspensions made by this progression I-bvi-I with pads of sustained chords. There's a traditional association with archetypes of death and sadness/melancholy.
Usually, no key signature and accidentals wherever needed. I prefer to explicit the pole (using C Maj and Ab min triads), but in some passages this enharmonic spelling will be easier to read. In melodic flux, I see no problem on the alternating naturals and flats, but may be confusing to some instrument idioms and, maybe, some performers. If you're not writing having one specific musician in mind, spell the notes in the manner you find more legible and coherent. And, obviously, adhere to this pattern of spelling throughout the entire piece/movement.


Bootstrap bug on mobile. Can only replicate on live site. 100% stuck

Question: I have been working on website and my CTA Buttons look fine on computers, but on mobile they turn gradient. I can not get the gradient bug to reproduce with devtools.
I have tried everything I can think of to try and get this to reproduce. I am out of ideas.
I am new to coding, so my code is a little sloppy. Please forgive me. I have added the code to codepen here: https://codepen.io/rob-connolly/pen/JjXQJgq
live site where you can see bug on mobile: https://grobconnolly.github.io/cloverweb/

@import url(//fonts.googleapis.com/css?family=Montserrat:300,400,500);
.service-5 {
  font-family: "Montserrat", sans-serif;
  color: #636468;
  font-weight: 300;
}

.service-5 h1,
.service-5 h2,
.service-5 h3,
.service-5 h4,
.service-5 h5,
.service-5 h6 {
  color: #3e4555;
}

.service-5 a {
  text-decoration: none;
}

.service-5 .linking {
  color: #3e4555;
}

.service-5 .linking:hover {
  color: #316ce8;
}

.service-5 .font-weight-medium {
  font-weight: 500;
}

.service-5 .bg-light {
  background-color: #f4f8fa !important;
}

.service-5 .subtitle {
  color: #8d97ad;
  line-height: 24px;
}

.service-5 .card.card-shadow {
  -webkit-box-shadow: 0px 0px 30px rgba(115, 128, 157, 0.1);
  box-shadow: 0px 0px 30px rgba(115, 128, 157, 0.1);
}

.service-5 .wrap-service5-box .card-body {
  padding: 30px;
}

.service-5 .wrap-service5-box .text-success-gradiant {
  background: #f47820;
  background: -webkit-linear-gradient(legacy-direction(to right), #f47820 0%, #f47820 100%);
  background: -webkit-gradient(linear, left top, right top, from(#f47820), to(#f47820));
  background: -webkit-linear-gradient(left, #f47820 0%, #f47820 100%);
  background: -o-linear-gradient(left, #f47820 0%, #f47820 100%);
  background: linear-gradient(to right, #f47820 0%, #f47820 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-fill-color: transparent;
}

.service-5 .wrap-service5-box .icon-size {
  font-size: 45px;
}

.service-5 .btn-md {
  padding: 15px 45px;
  font-size: 16px;
}

#textWhite {
  color: white;
  font-size: 25px;
}

.featureSection {
  margin-top: 30px;
}

.ourFeatures {
  margin-bottom: 50px;
}

* {
  font-family: "Montserrat", sans-serif;
  color: #636468;
}

.heroText {
  font-weight: 900;
  font-size: 50px;
  color: #373E42;
  padding-top: 4%;
  padding-bottom: .3%;
}

#subHeroText {
  font-size: 40px;
  font-weight: 400;
  color: #6b7175;
  margin-top: 0px;
}

#setupText {
  font-size: 22px;
  color: rgb(107, 113, 117);
  margin-bottom: 0.3em;
  padding-top: 1em;
}

#heroButton {
  font-size: 25px;
}

#cancelAnytime {
  font-size: 22px;
  color: rgb(107, 113, 117);
  padding-bottom: 1em;
}

.mainSubjects {
  font-weight: 400;
  font-size: 28px;
  padding-top: 1em;
  padding-bottom: .2em;
}

.footer {
  padding: 30px 0;
  background: #eee !important;
  width: 100%
}

.priceText {
  font-size: 15px;
  font-weight: 100;
}

.secondSection {
  background-color: white;
  width: 100%;
}

.extraPad {
  padding-bottom: 4%;
}

.question1 {
  border: 1px solid black;
}

.priceBox {
  border-width: thin;
  border-color: #E9EEF1;
  border-style: solid;
  padding-top: 3%;
}

.dollarSymbol,
.mo,
.amount {
  padding-bottom: 4%;
}

#extraSpace {
  padding-left: 100px;
  padding-right: 100px;
}

.dollarSymbol {
  font-size: 20px;
  font-weight: 400;
}

.amount {
  font-size: 60px;
  font-weight: 900;
}

.mo {
  padding-top: 3%;
  padding-left: 3%;
}

.faq {
  padding-top: 20px;
  padding-bottom: 20px;
}

#priceIcons {
  padding-left: 20%;
}

.iconFeatures {
  padding-left: 0%;
}

.iconTextPrice {
  padding-left: 3%;
  font-size: 14px;
  font-weight: 200;
  padding-top: 1%;
}

.iconUs {
  left: 27%;
  padding-top: 3%;
  padding-bottom: 4%;
}

.textIcon {
  color: black;
  font-weight: 200;
}

#heroButtonPricing {
  font-size: 20px;
  width: 300px;
}

li {
  font-size: 12px;
  justify-content: left;
}

.heroBottom {
  background-color: white;
}

.heroSection {
  background-color: #F8FBFC;
}

.liRight {
  text-align: left;
  margin-left: 3em;
}

.navbar {
  background-color: #F8FBFC;
}

li.borderless {
  border: 0 none;
  padding-top: 0;
}

.subHeroTextBottom {
  font-size: 12px;
  color: rgb(107, 113, 117);
  padding-top: 1px;
}

.mainSubjects {
  font-weight: 400;
  font-size: 28px;
  padding-top: 1em;
  padding-bottom: .2em;
}

.mainSubjectsWhy {
  font-weight: 400;
  font-size: 28px;
  padding-top: 2em;
  padding-bottom: .2em;
}

.mainSubjectsFaq {
  font-weight: 400;
  font-size: 28px;
  padding-top: 8em;
  padding-bottom: .2em;
}

.subjectHeader {
  font-weight: 400;
  font-weight: 100;
  font-size: 18px;
  padding-top: 0;
  padding-bottom: .2em;
}

.readyToSignUp {
  font-weight: 100;
  font-size: 18px;
  padding-top: 0;
  margin-bottom: .1em;
}

.secondSubject {
  padding-top: 15px;
}

.thirdTitle {
  padding-top: 15px
}

.calButton {
  padding-top: 400px;
}

.featureIconLeft1 {
  left: 10%;
}

.featureTextLeft1 {
  left: 6%;
}

.featureIconRight2 {
  left: 5%;
}

.featureTextRight2 {
  left: 1%;
}

.robpic {
  width: 200px;
}

.name {
  font-size: 10px;
  padding-bottom: 0;
  margin-bottom: 0px;
}

.title {
  font-size: 8px;
  padding-bottom: 2em;
}

.sectionSpace {
  margin-top: 0px;
  padding-top: 1.2em;
}

.backGround {
  background-color: #F8FBFC;
  width: 100%;
}

.tjFooterLogo {
  max-width: 100px
}

#noBorder {
  border: none;
  width: 30%;
  padding-top: 3%;
  padding-bottom: 4%;
  background-color: #F8FBFC;
}

.footerText {
  font-size: 12px;
  padding-bottom: .5em;
}

.fullWidth {
  margin-right: 0px;
  margin-left: 0px;
  padding-right: 0px;
  padding-left: 0px;
}

.footerLogo {
  width: 50%;
  padding-top: 8%;
  padding-bottom: 4%;
}

.footerTextCopy {
  font-style: normal;
  color: rgb(107, 113, 117);
  font-size: 10px;
}

.name {
  font-size: 18px;
  font-weight: 200;
}

.title {
  font-size: 14px;
  font-weight: 400;
}

@media only screen and (min-width: 980px) {
  .mainSubjects,
  .mainSubjectsWhy {
    font-size: 32px;
  }
  .subjectContent {
    font-size: 22px;
  }
}

@media only screen and (min-width: 1224px) {
  .heroText {
    font-size: 64px;
    padding-top: 4%;
    padding-left: 20%;
    padding-right: 20%;
  }
  .subHeroText {
    font-size: 20px;
    word-spacing: .2em;
  }
  .btn-primary {
    width: 150px;
  }
  .mainSubjects {
    font-size: 40px;
    font-weight: 900;
  }
  .subjectContent {
    font-size: 20px;
  }
  .name {
    font-size: 20px;
    font-weight: 400;
  }
  .title {
    font-size: 15px;
    font-weight: 200;
  }
  .footerLogo {
    width: 20%;
    margin-top: 0;
    padding-top: 2em;
    padding-bottom: 10px;
  }
  .footerText {
    font-size: 15px;
  }
}
<!DOCTYPE html>

  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <link rel="stylesheet" type="text/css" href="style.css">
  <link href="https://fonts.googleapis.com/css2?family=Overpass:wght@200;400;900&display=swap" rel="stylesheet">
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
  <link href="/open-iconic/font/css/open-iconic-bootstrap.css" rel="stylesheet">
  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.14.0/css/all.css" integrity="sha384-HzLeBuhoNPvSl5KYnjx0BT+WB0QEEqLprO+NBkkk5gbc67FTaL7XIGa2w1L0Xbgc" crossorigin="anonymous">

  <title>Clover Networks and TextJet Loyalty</title>

    <button type="button" class="navbar-toggler" data-toggle="collapse" data-target="#navbarCollapse">

        </button>

        How it Works
        FAQ
        Pricing

        Sign Up
        Login

Powerful loyalty software for small businesses!

Now available on Clover Networks!

Get set-up in minutes.

          Sign Up

No commitment. Cancel anytime.

Powerful Loyalty

Streamline your loyalty platform to maximize your reach. TextJet helps you turn occasional customers into loyal fans. We have spent countless hours designed and developing a system that will give you the upper hand over your competition. Not sure
          if TextJet is right for you... schedule a demo and find out why hundreds of businesses rely on TextJet.

Marketing Autopilot

We know running a business can be time restraining. With TextJet Marketing Autopilot we provide a powerful marketing suite without little to no effort on your part! After you set-up your account with one of our Customer Support Representatives,
          everything will be in place for you to see results with TextJet!

Retention Plus

TextJet retention plus is a really cool tool we built to help you keep your customers coming back. Let's pretend Suzy comes into your store today, but you don't see her for 30+ days. TextJet retention starts to go to work for you. Our tools help
          entice Suzy to come back to your store. It's really an amazing tool for your business!

Our Features

Rich
                                            Messaging

Send beautiful images or videos directly to your customers' cell phones.

Retention
                                            Plus

TextJet tracks how long it's been since a customer has been to your store. We set-up triggers to bring them back to your store.

Handsfree
                                            Marketing

TextJet is an easy to use marketing solution built for small businesses. It takes about 4 minutes to set-up and your account will be ready to go.

Analytics &
                                            Tracking

We have reporting in place so you can see how your account is performing. We want you to see the value of TextJet!

2-Way
                                            Messaging

You can have a 2-way conversation with your customers using TextJet. This is a great customer service tool.

SmartPulse
                                            (coming soon)

Find out how your customers feel about your store. Resolve issues and keep your customers happy

Get set-up in minutes.

              Sign
                                    Up

No commitment. Cancel anytime.

Pricing

Our plans are designed to grow with you! No contracts, no set-up fees, and awesome customer support is included in all packages.

Starter Plan

$1 /
                                            mo

Points Rewards

Custom Branding

Handsfree Markting

Fraud Protection

Promo Text Messaging

2-way Messaging

Reporting

50 SMS/ Month

              <button type="button" class="btn btn-lg btn-block btn-primary">Get
                                        started</button>

Business Plan

$39 /
                                            mo

Points Rewards

Custom Branding

Handsfree Markting

Fraud Protection

Promo Text Messaging

2-way Messaging

Reporting

1000 SMS/ Month

              <button type="button" class="btn btn-lg btn-block btn-primary">Get
                                        started</button>

Pro Plan

$89 /
                                            mo

Points Rewards

Custom Branding

Handsfree Markting

Fraud Protection

Promo Text Messaging

2-way Messaging

Reporting

5000 SMS/ Month

              <button type="button" class="btn btn-lg btn-block btn-primary">Get
                                        Started</button>

Ready to see the TextJet difference?

We are here to help you grow your business!

Get set-up in 15 minutes.

                    Sign
                            Up

No commitment, Cancel anytime.

Pricing

FAQ

Contact Support

Privacy Policy

Terms of Service

Anti-Spam Policy

                    © Copyright 2020 Textjet LLC

Mobile Version
[Web Version2
Comment: Have you used the element inspector to see *where* this style is coming from?
Comment: I can confirm dev tools doesn't reproduce and I see the issue on mobile device
Comment: Looks fine, no client will ever notice this.
Comment: @FluffyKitten I have. I have found the btn btn-success tag, i have even searched for everything with the word Gradient in css, changed the all to the orange color and I have searched for everything under @ mobile.   I am lost!
Comment: Surely the OS of the mobile you are using sets a default style to the  tag ... which OS and mobile are you using?
Comment: @bru17 Catalina and IOS 14
Answer: It's less a mobile issue and more a Safari issue as I'm able to see it on desktop and mobile on macOS / iOS respectively.
The issue is type="button" which you've applied to your hyperlink.  In Bootstrap the following CSS is applied:
[type=button], [type=reset], [type=submit], button {
  -webkit-appearance: button;
}

That is overriding elements of the .btn class.  Removing type="button" causes your hyperlink to display as expected.
Comment: This has resolved the issue Robert.  Thank you, I would've never guessed that. I really appreciate it! Cheers!


When to use the Wilcoxon rank-sum test instead of the unpaired t-test?

Question: This is a followup question to what Frank Harrell wrote here:

In my experience the required sample size for the t distribution to be
  accurate is often larger than the sample size at hand. The Wilcoxon
  signed-rank test is extremely efficient as you said, and it is robust,
  so I almost always prefer it over the t test

If I understand it correctly - when comparing the location of two unmatched samples, we would prefer to use the Wilcoxon rank-sum test over the unpaired t-test, if our sample sizes are small.
Is there a theoretical situation where we would prefer the Wilcoxon rank-sum test over the unpaired t-test, even that the sample sizes of our two groups are relatively large?
My motivation for this question stems from the observation that for a single sample t-test, using it for a not-so-small sample of a skewed distribution will yield a wrong type I error:
<code>n1 <- 100
mean1 <- 50
R <- 100000
P_y1 <- numeric(R)
for(i in seq_len(R))
{
    y1 <- rexp(n1, 1/mean1)
    P_y1[i] <- t.test(y1 , mu = mean1)$p.value
}
sum(P_y1<.05) / R # for n1=n2=100 -> 0.0572  # "wrong" type I error
</code>
Comment: To me, 0.0572 seems close enough to 0.05.
Comment: I agree that it's incorrect. I just meant that it seems close enough for practical purposes.
Comment: A related question: [How to choose between t-test or non-parametric test e.g. Wilcoxon in small samples](http://stats.stackexchange.com/questions/121852/how-to-choose-between-t-test-or-non-parametric-test-e-g-wilcoxon-in-small-sampl), which considers both paired and unpaired tests, as well as alternatives to Wilcoxon such as Brunner-Munzel. There is also an excellent answer by Frank Harrell which explains why he feels justified in his approach in more detail than the above extract (e.g. the importance of the invariance of ranks under monotonic transformation).
Comment: Hi Mark - when conducted under 100000 repetition of the null hypothesis, we do not expect to get this level of difference from 0.05.  Generally we would expect a difference of plus minus something like two times of sqrt(0.05*0.95/100000) from 0.05
Comment: @TalGalili : why would you not expect to get this level of difference, considering you are doing a t-test and the normality assumption is violated (I see that your sample is exponentially distributed)? I am asking from a novice perspective, here. I am just trying to understand what we are expecting, doing a one sample t-test when the normality assumption is violated. Why should the average type I error be smaller than 5%, or bigger than 5%, or anything? The way I see it, what we are testing is $H_0: \mu=50$ and the distribution is normal.
Answer: Let me bring you back to our discussion in comments to this your question. Wilcoxon sum-rank test is equivalent to Mann-Whitney U test (and its direct extension for more-than-two samples is called Kruskal-Wallis test). You can see in Wikipedia as well as in this text that Mann-Whitney (or Kruskal-Wallis) generally compares not means or medians. It compares the overall prevalence of values: which of the samples is "stochastically greater". The test is distribution-free. T-test compares means. It assumes normal distribution. So, the tests engage in different hypotheses. In most cases, we don't plan to compare specifically the means, rather, we want to know which sample is greater by values, and it makes Mann-Whitney the default test for us. On the other hand, when both distributions are symmetric the task of testing whether one sample is "greater" than the other degenerates into the task of comparing the two means, and then, if the distributions are normal with equal variances t-test becomes somewhat more powerful.
Comment: By "which of the samples is "stochastically greater" ", do you mean "which one of the samples generally take greater values compared to the other"? If not, what do u mean? Could u elaborate on this a little further please?
Comment: @Erdogan, yes, we may say like you said. The strict wording is this: in a randomly chosen pair of objects, one from each sample, the object from the "stochastically more dominant" sample will be higher (by the value) than the object from the other sample with probability >0.5.
Comment: +1 for tying your answer back to the meaning of the hypotheses being tested.
Answer: Yes, there is.  For example, any sampling from distributions with infinite variance will wreck the t-test, but not the Wilcoxon.  Referring to Nonparametric Statistical Methods (Hollander and Wolfe), I see that the asymptotic relative efficiency (ARE) of the Wilcoxon relative to the t test is 1.0 for the Uniform distribution, 1.097 (i.e., Wilcoxon is better) for the Logistic, 1.5 for the double Exponential (Laplace), and 3.0 for the Exponential.
Hodges and Lehmann showed that the minimum ARE of the Wilcoxon relative to any other test is 0.864, so you can never lose more than about 14% efficiency using it relative to anything else.  (Of course, this is an asymptotic result.)  Consequently, Frank Harrell's use of the Wilcoxon as a default should probably be adopted by almost everyone, including myself.
Edit: Responding to the followup question in comments, for those who prefer confidence intervals, the Hodges-Lehmann estimator is the estimator that "corresponds" to the Wilcoxon test, and confidence intervals can be constructed around that.
Comment: http://biostat.mc.vanderbilt.edu/WilcoxonSoftware shows how to use R to get the Hodges-Lehmann estimate and its confidence interval.
Comment: (+1) from a stodgy anti-rank traditionalist. However, a challenge for rank tests is that the hypothesis is vague. It is generally not the same hypothesis as the t-test. The t-test tests a mean difference always, Wilcoxon tests a weighted mean rank difference. Certainly if the rank-mean difference is statistically significant, we know the distributions must differ, even if their means are the same. Neither test is powered to detect distributional differences in *all* cases. I only say as much because I favor interpretability. (1/2)
Comment: Is there an easy way to get a confidence interval if the Wilcoxon test is used? It seems to encourage people to put too much emphasis on the p-value, even more than they would with a parametric method.
Comment: A bigger challenge yet is for analysts to pre-specify such a test rather than fall back to it when the t-test is "non-significant". (2/2)
Comment: Yes, the Hodges-Lehmann estimator is the relevant estimator, and I've edited the body of the response so that future readers don't have to go through the comments.
Comment: Thanks jbowman. I'm not familiar with the Hodges-Lehmann estimator, but will see what I can find out about it.


Is this use of L'Hôpital's rule incorrect?

Question: For the question:

Find the $\lim_{x \to 1}  \frac{3x^3 - 5x^2 + x + 1}{x^2 - 2x + 1}$

I couldn't see how to factorize the numerator and noticed that it was in intermediate form $\frac{0}{0}$ so I applied L'Hôpital's rule twice which left me with:
$\frac{18x - 10}{2}$
which I evaluated at $x \rightarrow 1$ to get the limit of 4.
I then typed the problem into wolfram alpha and noticed that, although I got the same answer, WA had factored out $x^2 - 2x +1$ which cancels with the denominator and then the function can be evaluated to equal 4 without using L'Hôpital's.
I was wondering if my use of L'Hôpital's rule here is unjustified, and if so, what would have been the method to factor the numerator?
Comment: Since, the numerator when evaluated at $1$ is $0$, you must observe $x-1$ is a factor of the polynomial in the numerator.
Comment: There is nothing wrong with using L-Hôpital's rule here, but you could have factorised if you recalled the remainder theorem, or well, the factor theorem.
Comment: As long as the limit you want to calculate is not used in finding the value of the derivative (as in the case of very elementary limits) the use of l'Hospital's rule is correct (if the other hypotheses needed are satisfied).
Answer: As I teach to my students (I'm italian, so there might be an issue about pedagogical viewpoints and tradition), you can apply De l'Hospital's theorem whenever its assumptions are satisfied. In you problem they surely are. Anyway, many colleagues think that limits should be solved without derivatives whenever possible. I guess the answer to your question depends on the rules given by your teacher. Mathematically speaking, your application of De l'Hospital's rule is correct.
Answer: $$\lim_{x \to 1}  \frac{3x^3 - 5x^2 + x + 1}{x^2 - 2x + 1}$$
If you saw that you get $0/0$, that should tell you how to factor both the numerator and the denominator.  I.e., if you plug in a number---call it $c$---and get $0$, that tells you that $(x-c)$ is one of the factors.  In this case you plugged in $1$ and got $0$, so $(x-1)$ is one of the factors.  So you get
$$
\lim_{x \to 1}  \frac{(\cdots\cdots)(x-1)}{(\cdots\cdots)(x-1)}.
$$
You can then use long division to fill in the remaining blanks, if all else fails.  But once you get this far, you can often fill in the blanks by staring at the thing.  You get
$$
\lim_{x \to 1}  \frac{(3x^2-2x-1)(x-1)}{(x-1)(x-1)}
$$
and this becomes
$$
\lim_{x \to 1}  \frac{3x^2-2x-1}{x-1}.
$$
You've still got $0/0$, so do it again:
$$
\lim_{x \to 1}  \frac{3x^2-2x-1}{x-1}=\lim_{x\to 1} \frac{(\cdots\cdots)(x-1)}{(\cdots\cdots)(x-1)}.
$$
One problem with L'Hopital's rule: It will get you the limit, but it's valid only if your method of finding derivatives is valid.  Sometimes you use limits involving $0/0$ to prove that methods of finding derivatives are valid.  If you use those methods to find the limits, and then use the limits to prove those methods are valid, then you've got the two methods vouching for each other, so there's a gap in the logic.
Answer: L'Hopital's rule
To factorize the numerator :
$3x^3-5x^2+x+1=3x^3-6x^2+x^2+3x-2x+1=(3x^3-6x^2+3x)+(x^2-2x+1)=$
$=3x(x-1)^2+(x-1)^2=(3x+1)(x-1)^2$
Hence :
$\displaystyle\lim_{x \to 1} \frac{(3x+1)(x-1)^2}{(x-1)^2}=4$


There are seats for 40 people, 8 rows 5 seats each row. M, A, W, E, and J arrive first.

Question: The question asks "How many arrangements are there of seating if M and J sit together in front row and other 3 sit together in one of the other rows"
My attempt:
First I found the number of ways arranging M and J in the first row- 4 x 2! = 8 ways
Then I found number of ways of arranging the 3 others - 3 x 3! x 7C1 = 126 ways
I added the ways together to get 126 + 8 = 134 ways of seating
However the correct answer states that there are 1008 ways ( 8 x 126)
Why are 8 and 126 multiplied instead of sum?
Comment: It is the multiplication principle. For each arrangement of M&J in the first row, there are $126$ different arrangements for other three people
Answer: This is the multiplicative principle, which states that if an event $A$ can occur in $n$ ways, and for each possibility of $A$ an event $B$ can happen in $m$ ways, then events $A$ and $B$ can occur in $n \times m$ ways.
You can think of it this way: you know that the number of ways $M$ and $J$ can sit together at the front row is
$$\binom{4}{1}\cdot 2! = 8. $$
For each of these ways, the others ($A,W$ and $E$) can pick seats in
$$\binom{7}{1}\cdot \binom{3}{1}\cdot 3! = 126$$
ways. The key here is the for each. So consider a specific seating arrangement for $M$ and $J$:
$$\Huge \circ  \circ  \circ \small \ \  M \ \ \ J$$
$$\Huge \circ \circ \circ \circ \circ$$
$$\Huge \circ \circ \circ \circ \circ$$
$$\Huge \circ \circ \circ \circ \circ$$
$$\Huge \circ \circ \circ \circ \circ$$
$$\Huge \circ \circ \circ \circ \circ$$
$$\Huge \circ \circ \circ \circ \circ$$
$$\Huge \circ \circ \circ \circ \circ$$
For this choice, $A,W$ and $E$ can pick seats in 126 ways. Now consider another specific seating for $M$ and $J$:
$$\Huge \circ \circ \small \ \ M \ \ \  J \ \ \Huge \circ $$
$$\Huge \circ \circ \circ \circ \circ$$
$$\Huge \circ \circ \circ \circ \circ$$
$$\Huge \circ \circ \circ \circ \circ$$
$$\Huge \circ \circ \circ \circ \circ$$
$$\Huge \circ \circ \circ \circ \circ$$
$$\Huge \circ \circ \circ \circ \circ$$
$$\Huge \circ \circ \circ \circ \circ$$
Once $M$ and $J$ have sat down, $A,W$ and $E$ can still pick seats in 126 ways. So, given these two starting positions, we have now found $126 + 126 = 252$ ways to seat everyone. If you continue with this logic, you will find that for each of the $8$ seating positions for $M$ and $J$, there are $126$ ways for the other to sit, so we end up with a total of
$$126 \cdot 8 = 1008$$
for all of them to sit.


Solve $\begin{cases}x^2+y^4=20\\x^4+y^2=20\end{cases}$

Question: Solve $$\begin{cases}x^2+y^4=20\\x^4+y^2=20\end{cases}.$$ I was thinking about letting $x^2=u,y^2=v.$ Then we will have $$\begin{cases}u+v^2=20\Rightarrow u=20-v^2\\u^2+v=20\end{cases}.$$ If we substitute $u=20-v^2$ into the second equation, we will get $$v^4-40v^2+v+380=0$$ which I can't solve because we haven't studied any methods for solving equations of fourth degree (except $ax^4+bx^2+c=0$). Any other methods for solving the system?
Comment: I flagged for moderator attention since this is very negative behavior.
Comment: What on earth is with all of the downvotes on the answers here? Seems like someone is serially downvoting (of sorts)...
Comment: @CameronWilliams with you on that
Comment: @CameronWilliams good,it is definetly intentional,because after 2 seconds or so after the answer being posted there is a downvote,I cant fathom the downvoter to read an anwer within 2 seconds unless the downvoter is a superhuman
Comment: @AlbusDumbledore, thank you for the response! I would like a solution without guessing, though. Can I ask what do you mean by "due to symmetry"? What is symmetric in the system?
Answer: There is actually a much, much neater method. Following your solutions, we subtract the equations (or substitute $20$) to get,
$$(u-v)+(v^2-u^2)=0$$
Using the familiar identity $a^2-b^2$ $=(a-b)(a+b)$,
$$-(v-u)+(v-u)(v+u)=0$$
which, on factoring, implies
$$(v-u)(-1+v+u)=0$$
which implies
$$v=u\text{ or }v=1-u$$
All that remains is mere substitutions into our original equations.
Hope this helps. Have a wonderful day. Ask anything if not clear :)
Comment: Now this is  a good answer(upvoted with all force i could muster!)
Comment: Thank you all very much! +64 is a huge amount ;) (=
Comment: Someone downvoted! Plus some other reps from other posts.
Comment: ultraedge you mean +65?
Comment: But no one has downvoted *this* post
Comment: Probably the website counted the -1 from the downvote I gave earlier to a PhysicsSE post.
Comment: Oh i got it , i misread your comment as if someone dwonvoted your post ofcourse, thats where the -1 comes from
Answer:  Edited: thanks to several comments below, I find that the original answer made a (serious) mistake in counting the degrees of relevant polynomials and thus a mistaken use of the fundamental theorem of algebra. I apologize for the errors. A not-so-elegant way to fix the argument is added.

Systems of nonlinear equations are in general difficult; solutions are found by numerical methods.
Nevertheless, for this particular problem,
by inspection$\dagger$, there are at least four solutions:
$$
(-2,-2),\quad (-2,2),\quad (2,-2),\quad (2,2)\tag{1}
$$
We claim that the system has at most four solutions.
On the other hand, by symmetries, it suffices to show that $(2,2)$ is the unique solution in the first quadrant: any other solution not in (1) would give you one more solution in the first quadrant.
If you introduce the new variables $u=x^2$ and $v=y^2$:
$$
v=20-u^2,\quad u=20-v^2,\quad u,v>0
$$
The pair $(u,v)$ is the intersection of two parabolas on the $u$-$v$ plane.
If one draws a picture$\dagger\dagger$, one can see that one has only one intersection on the first quadrant, which implies that the first-quadrant solution to the original system is unique.

$\dagger$Notes. The observation $20=4+16$ gives an obvious hint to get a solution.
$\dagger\dagger$ Yes, this is just a hand-waving geometric "proof".
Comment: This downvote is undeserved.
Comment: The fundamental theorem of algebra says us that the equation has at most four solutions IN $v$, and you only suggested TWO possible $v$'s, so there might be more (actually there are)
Comment: "...you get a polynomial of degree four": degree eight, surely? It is of degree four in $x^2$, but four solutions for $x^2$ means up to eight solutions for $x$. So I think this answer is wrong.
Comment: @IDoktorova: I made a mistake; I edited my answer.
Comment: [+1] from me. Thank you!
Comment: Can I ask you what do you mean by "the system can be reduced to a polynomial of degree four"? How can I do that?
Comment: @TonyK: yes. That was a silly mistake. I edited my answer. Thank you very much for your comment.
Comment: @SeewooLee: that was certainly a mistake. Thank you very much for your comment. I edited the answer.
Answer: By substracting the two equations you get
$$ x^2(1-x^2) + y^2(y^2-1) = 0$$
$$ -(x^2-\frac12)^2 + (y^2-\frac12)^2 = 0 $$
so
$$ x^2 - \frac12 = \pm (y^2-\frac12) $$
that is
$$ x^2 = y^2 $$
or $$ x^2 = 1- y^2 $$
Analysing theses two cases it's easy to solve the equations.
Comment: I dont know who it is but there is one downvoter who is roaming here to downvote each and every post including the question!
Comment: @IDoktorova expand the second equation. It'll be clear from there. It's just a clever form of $0$.
Comment: Can you explain to me how do we get from the first to the second line?
Answer: First, you can guess the answer, which might be $(u, v) = (2, 2)$. Since there might exist other solutions, we need to think more.
The next thing is: I believe that you can draw the graph of $u = 20 - v^{2}$ and $v = 20 -u^{2}$ on $(u, y)$-plane, which gives two parabolas that are reflections each other with respect to the line $u = v$. And, you have another guess: The other solutions do not satisfy $u\geq 0$ and $v\geq 0$, which should happen since $u = x^{2}$ and $v = y^{2}$. (Note that there are 3 more intersection points) So we can say confidently that the only solution is $(u, v) = (2, 2)$, but this is not a proof. There's another solution that you can guess that corresponds to another intersection point with $u = v$ other than $(4, 4)$. If you set $u = v$, then you obtain $u = -5, 4$ by solving a quadratic equation.
At last, to prove that this is the only solution, note that the degree 4 polynomial should be divisible by $(v-4)$ and $(v+5)$ since $4, -5$ are roots of it. We have
$$
v^{4} - 40v^{2} +v + 380 = (v-4)(v+5)(v^{2} - v - 19)
$$
and $v^{2} - v - 19  = 0 \Leftrightarrow v = \frac{1 \pm \sqrt{77}}{2}$, where both of them fail to satisfy $(u \geq 0) \wedge (v \geq 0)$. So the only answer is $(u, v) = (2, 2) \Leftrightarrow (x, y) = (\pm 2, \pm 2)$.
Answer: You have the following problem: $$\begin{bmatrix}x^2+y^4=20\\ x^4+y^2=20\end{bmatrix}$$
In the first equation, you can isolate $x$ to get $x=\sqrt{20-y^4}$ and $\:x=-\sqrt{20-y^4}$. You then substitute the $x$ values into the second equation to get:
$$\left(\sqrt{20-y^4} \right)^4 +y^2=20, \left(-\sqrt{20-y^4} \right)^4 +y^2=20$$
Simplifying the equations will result in $y=2, y=-2$. You can then substitute the solution into the first equation and you will get $x=2,-2$ depending on which value of $y$ you substitute. Therefore, the final solutions are:
$$\begin{pmatrix}x=2,\:&y=2\\ x=-2,\:&y=2\\ x=2,\:&y=-2\\ x=-2,\:&y=-2\end{pmatrix}$$


Azure Data Factory - SQL

Question: I would like to ask you if is it possible to use "output inserted" SQL statement in data flow (Azure Data Factory)
Currently, I am getting an error:

at Source 'source1': shaded.msdataflow.com.microsoft.sqlserver.jdbc.SQLServerException: A nested INSERT, UPDATE, DELETE, or MERGE statement is not allowed in a SELECT statement that is not the immediate source of rows for an INSERT statement.

Using this statement:

What I did:
I also checked stored procedures but they do not provide any output.
What I want:
I would like to get the 'Id' of row of inserted elements (Insert+Select in one operation).
Answer: As error shows, insert statement isn't allowed.
As a work around, you can do like this.

create a Lookup activity and enter your SQL like this:

create a data flow and create a parameter inside it.
expression:@activity('Lookup1').output.firstRow.ID

3.Inside data flow, choose your table as your source and enter this expression:
concat('select ID from dbo.test6 where ID =',toString($ID))

4.If your need to do some transform, you can create a DerivedColumn and do like this:
Comment: How about this?`"Select ID from dbo.test6 WHERE ID = '{$ID}'"`

Azure Data Factory - SQL


init.d script not starting on startup

Question: I have what I consider to be a pretty simple script that I want to run on startup, however I'm pretty new to init.d scripts, and maybe there is a better way to do this in general.
Basically I want my script to run when the system starts, so I have a ruby script, which I've moved to /usr/bin, and named just consumer
For the sake of brevity say it looked like this, but actually did something:
#!/usr/bin/env ruby

# just example code
puts "do stuff"

Then I have my init.d script placed in /etc/init.d and named just consumer.
#!/bin/bash
### BEGIN INIT INFO
# Provides:          consumer
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.
### END INIT INF

# /etc/init.d/consumer
#

# Some things that run always
touch /var/lock/consumer

# Carry out specific functions when asked to by the system
case "$1" in
  start)
    echo "Starting Consumer"
    consumer &
    echo "Consumer started successfully."
    ;;
  stop)
    echo "Stopping Consumer"
    echo "Nothing happened..."
    ;;
  *)
    echo "Usage: /etc/init.d/consumer {start|stop}"
    exit 1
    ;;
esac

exit 0

Now if I save this file and I just run sudo /etc/init.d/consumer start, it works perfect! It starts and gives me the desired output. So then I run:
$ sudo update-rc.d consumer defaults
Adding system startup for /etc/init.d/consumer ...
  /etc/rc0.d/K20consumer -> ../init.d/consumer
  /etc/rc1.d/K20consumer -> ../init.d/consumer
  /etc/rc6.d/K20consumer -> ../init.d/consumer
  /etc/rc2.d/S20consumer -> ../init.d/consumer
  /etc/rc3.d/S20consumer -> ../init.d/consumer
  /etc/rc4.d/S20consumer -> ../init.d/consumer
  /etc/rc5.d/S20consumer -> ../init.d/consumer

But when rebooting the system my script never gets started, any ideas? I'm not sure what action to take next. I've adjusted all the scripts permissions to 775, and made sure root owned them all as well.
Any help would be hugely helpful.
Answer: Doing "consumer &" will simply background the task and go on. If the owning shell terminates, it will terminate any background tasks. You say the script works on command line, but your daemon won't survive if you log out?
You want to start your daemon with something like start-stop-daemon.
EDIT: actually, on reading your text again, I'm not sure if consumer is a daemon at all? If you just want to run some code on startup (e.g. housecleaning), you write a line in /etc/rc.local.
If the script takes a long time to run, you may want to disown it. I.e:
consumer &
disown %1

The script will now survive the shell termination. Note tho, that if the shell outputs text, it will retain the same tty, which may cause problems, depending on what happens to it after its owning shell terminates.
Comment: You're doing fine. If it is a  sheel script, you may want to have a look at the trap command. It allows you to react to signals. Typically interesting signals is 1) HUP, which means the script should reread its config and rotate any files it has open, 2) TERM which means someone is trying to shutdown your script, and 3) USR1,USR2 which means your script should perform some action meaningful to its context, e.g. stop sleeping and doing its job.
Comment: Well I guess its not a daemon, it's really just a script that loops, but I want it to do so forever, and ideally I should devise some way to make this a proper program that I can monitor. I'm sort of new to this sort of programming as I come from the web development world, any thoughts?
Answer: Try specifying the full path to consumer. I would suspect that it isn't in the default path at that point, hence it's failing to execute it.
Answer: If you are using Ubuntu, try using this:
http://manpages.ubuntu.com/manpages/hardy/man8/update-rc.d.8.html
Answer: just use:
sudo systemctl enable consumer.service
to enable
sudo systemctl disable consumer.service
to disable
if your script is LSB compliant will work just fine.-

init.d script not starting on startup


Android Data Type Recommendation

Question: I'm having a problem designing some code to handle dynamic, two-dimensional data in my Android applicaton.  I've tried solving this using an ArrayAdapter, but there's a problem:
As far as I can tell, there's no way to remove data from an ArrayAdapter by its position (or index).  Using an ArrayAdapter, you have to remove by value like this:
arrayAdapter.remove (stringValue1);

This is fine for half my data because the first value in the pair (the "x-value") is guaranteed to be unique (among the x'es), but this isn't reliably true for the second value.  I've tried some stupid gymnastics to make the "y-value" unique, but that's not proving to be a very good idea.
Can anyone recommend an Android data type (or Java, I guess) that will be both dynamically re-sizeable and will allow me to remove precisely the data I need to??
Thanks,
R.
Comment: An ArrayList will do what you want
Comment: Working on finding an example right now.  Thx.
Answer: An ArrayList of String objects, sounds like it would do the job, and it's dynamically resizable as well:
ArrayList<String>

http://docs.oracle.com/javase/6/docs/api/java/util/ArrayList.html
Remove by index:
remove(int index)

Removes the element at the specified position in this list.

Check if it contains a certain object by object comparison:
contains(Object o)

Returns true if this list contains the specified element.

Android Data Type Recommendation


How to create a static library which includes another static library

Question: I have a C++ project called testlib.pro (using Qtcreator) which will create a static library libtest.a.
The project is also included staticlib.a (example) and staticlib1.a. i.e using someother static libraries im creating one static library. After creating static library, Im creating C wrapper (testApi.c) to use the C++ code using the static library. I am compiling the testApi.c using the below option
gcc -o demo testApi.c -L ./testlib -ltest
But it is giving linker errors which stats that it requires the static libraries which i used to link the libtest.a. So i recompile the program with below comment and it works fine
gcc -o demo testApi.c -L ./testlib -ltest -lstatuclib -lstaticlib1
My understanding is If I ship the libtest.a to someother machine and try to compile testApi.c file it may requires staticlib.a and staticlib1.a in that machine. But I would like to use only newly created static library libtest.a. Am i missing any?
NOTE: I have included staticlib.a, staticlib1.a using -l option in my testlib.pro
Comment: Remember that static libraries are nothing more than archives of object files. So it's possible to extract the object files from the "other" static library, and add them to your own. Not that I really recommend it though.
Comment: take a look at this https://stackoverflow.com/questions/3821916/how-to-merge-two-ar-static-libraries-into-one
Answer: If your library uses other static libraries then they will also need to be provided at link time.
There is an ugly way around it (on Linux). You can unpack existing static library (or several of them) and repack them into a new library. So you could, if you felt particularly frisky, unpack those libraries that yours depends on, then pack their contents along with your own stuff into a new library. Ugly, confusing, possibly causing all sorts of other problems, but if that is the way you want to go...
Comment: @ssbssa - feel free to bootstrap the following Makefile.am: https://pastebin.com/1ti5eUEz - repeat this experiment, and then explain how `world.o` winds up in `libhello.a` without libtool doing what I said it does.
Comment: That ugly way happens to be exactly what libtool does, so if one learns how to use libtool and build static libraries with libtool, libtool will do all that nastiness for you.
Comment: @SamVarshavchik Are you sure that libtool does that? Then what's the `dependency_libs` entry of the libtool *.la files for?
Comment: They are what libtool, the script, uses to do all of this.
Comment: @SamVarshavchik I don't think that's true, from what I can see libtool reads these *.la files in the linker stage, and adds these dependencies to the linker command. The static libraries itself are not modified.
Comment: @SamVarshavchik Nice, I didn't know libtool could do that.
Answer: The static library concept is archaic in nature.  When a program had a lot of modules, it was sometimes impossible to put them  all in the command line for the linker to add them to the program.  Also, for libraries, as the .o modules where all being included in the final executable, there had to be some mechanism to allow the linker select only the needed modules and not to include all of them in the final executable, or the executables will grow a lot including modules that the program will not use.  Both things where solved with the introduction of dynamic shared objects, so using .a files is somewhat deprecated today and it is only used for statically linking programs.
Anyway, the algorithm to select the object modules in the linker is not recursive, so when it opens a .a library to search for dependent files to be included in the final executable, it searches only for .o (and probably .so, but I have not tested this), and it will ignore any .a file it finds in there.  Many systems include an index file in the archive that has a mapping between provided identifiers, and the name of the module that provides them, so in one pass the compiler knows which archived objects need to be extracted.  That index file should be appended (and rebuilt) in case a library (with its own index) where included in the file, so this justifies not using recursion at all in the library search.
The solution for this problem, is to link all those libraries you need to make the final executable, or as you have already been told, to extract the .o files in the library and put them in another library.  There is still a third solution, that is: The linker allows you to specify a file that has options (and you can specify library names, and .o files you want it to scan) and it will read that file to check the set of libraries you want it to scan.
Another point is that the linker never includes a library as such.  A library is just an archive (like a .tar or .zip file) in which the linker explores and extracts the files it needs, so there's no need to make the search algorithm recursive at all.  And there's no difference between an archived file in a library and that same file out of the archive.


Is there any extension theorem about $n$-sphere?

Question: Let $A$ be a closed subset of $n$-sphere, $f$ a continuous surjective map from $A$ to $n$-sphere, could it be extended to the whole $n$-sphere? If not, what conditions should be added to make it true?
Since there exists surjective map from $[0,\infty)$ to $\mathbb{R}^n$, thus to $S^n$, I want to make use of it and find a proof similar with Tietze extension theorem, but I haven't thought of anything concrete.
Comment: If $A$ is nice, there is a (way overkilled) solution using PDE. The problem $\Delta g = 0, g_{|\partial A} = f$ has a unique solution, and the function $\tilde(f)(x) = f(x)$ if $x \in A$ and $\tilde f(x) = g(x)$ if $x \notin A$ solves the problem.
Comment: @N.H. Thanks. It seems that this problem is beyond my poor ability. By the way how nice must it be?
Comment: This was a stupid remark, I'm not very into PDE so I don't know how nice $A$ should be. You problem reminded me that any continous function $f : S^1 \to \mathbb R$ can be extend to $D^2$ by solving $\Delta g = 0$ and $g_{| S^1} = f$. But I don't exactly know how this generalise.
Answer: For metric spaces $X$ the following is true: suppose $f: A \rightarrow S^n$ is continuous and where $A \subseteq X$ is closed. Then there is an open subset $U$ of $X$ that contains $A$ such that $f$ can be continuously extended to $U$. This is saying that $S^n$ is an ANR (=ANE) for metric spaces. (ANR =absolute neighbourhood retract, ANE = absolute neighbourhood extender; an AE (Absolute extender) =essentially any space $X$ we can use as $[0,1]$ like in Tietze). As you cannot extend the identity embedding from $S^1 \subset B^2$ to all of $B^2$ (the non-retraction theorem), this is the best one can hope for. But the dimension $\operatorname{Ind}(B^2)= 2 > 1$ turns out to be the problem:
$X$ has large inductive dimension (see here e.g.) $\operatorname{Ind}(X) \le n$ iff for every closed subset $A \subseteq X$, every continuous $f:A \rightarrow S^n$ can be continuously extended to $X$.
(A proof of this theorem, and probably better references can be found in Jan van Mill's book, "infinite dimensional topology, introduction and prerequisites", and probably in Engelking's "theory of dimensions, finite and infinite")
This last theorem shows that this indeed holds for $X = S^n$ as asked for.


Need help with reading this fragment from piano sheet

Question: I'm a beginner in playing the piano and I came across these signs that I don't know. What do they mean and how should it be played?

Second measure, first notes for the right hand:

the three dots after the notes
and the mini crossed note before them
Comment: You have to look for *music symbols*
Answer: A dot after a note extends the length of the note by half. In this case, the eighth notes are extended the length of 3 sixteenth notes. There's a sharp sign before the dotted eighth on G which means to play a G# (half step above the G.) The note with a slash is a grace note. Depending on the style, a grace note is played just before the main note or "crushed" at the same time (played quickly and released while the main note is held.)
Comment: 'A dot after a note extends the length of the note by half'. Talking of a one beat note,(crotchet, quarter note),  that's always true! A dotted one beat note is extended by half, becoming one-and-a-half beats long. Reason for picking up on this is a dot *increases a note's value by half of its own value*. Lots of newbies get confuse by this!


MySQL fulltextsearch: no results

Question: i use this query for a fulltextsearch in my table:
SELECT Titel FROM cmsa WHERE MATCH(Titel) AGAINST ('+"Ort" +"Berlin"' IN BOOLEAN MODE)

but the result is empty.
If i use
SELECT Titel FROM cmsa WHERE Titel LIKE '%Berlin%'

the result would be (without quotes):
"Ort - Berlin"

Why the fulltextsearch didnt find this result. The word "Ort" and the word "Berlin" are both in the field Titel of the entry.
Other fulltext searches works great.
Any Idea?
Answer: Try without double quotes and make sure Mysql engine is MYISAM
SELECT
         Titel
FROM
         cmsa
WHERE
         MATCH(Titel) AGAINST ('+Ort +Berlin' IN BOOLEAN MODE)

Some explanation
Boolean Mode Searches
SELECT headline, story FROM news
WHERE MATCH (headline,story)
AGAINST ('+Hurricane -Katrina' IN BOOLEAN MODE);

The above statement would match news stories about hurricanes but not those that mention hurricane katrina.
Query Expansion
The Blind Query Expansion (or automatic relevance feedback) feature can be used to expand the results of the search. This often includes much more noise, and makes for a very fuzzy search.
In most cases you would use this operation if the users query returned just a few results, you try it again WITH QUERY EXPANSION and it will add words that are commonly found with the words in the query.
SELECT headline, story FROM news
WHERE MATCH (headline,story)
AGAINST ('Katrina' WITH QUERY EXPANSION);

The above query might return all news stories about hurricanes, not just ones containing Katrina.
A couple points about Full-Text searching in MySQL:

Searches are not case sensitive
Short words are ignored, the default minimum length is 4 characters. You can change the min and max word length with the variables ft_min_word_len and ft_max_word_len
Words called stopwords are ignored, you can specify your own stopwords, but default words include the, have, some - see default
stopwords list.
You can disable stopwords by setting the variable ft_stopword_file to an empty string.
Full Text searching is only supported by the MyISAM storage engine.
If a word is present in more than 50% of the rows it will have a weight of zero. This has advantages on large datasets, but can make
testing difficult on small ones.
Comment: thanks for your help this expression works for the case. But how do i search for +Ort +"Berlin Kreutzberg" without double quotes?
Answer: I guess it is because MySQL has a server parameter - The minimum length of the word to be included in a FULLTEXT index. Default value for this parameter is 4 so your first word Ort is not included in this index. You should change this system parameter, restart server and then rebuild all FULLTEXT indexes.
REPAIR TABLE cmsa QUICK;

Change the full text index minimum word length with MySQL
Answer: Your query was working perfectly for me. Please check your table is MYISAM or not because full text search working in only myisam engine.
Comment: The full text search works in other cases in the same table too. Its a MyISAM table with a fulltext index on Titel.

MySQL fulltextsearch: no results


Path of the mid-point of AB

Question: Question:

The variable lines goes through the intersection point of  $\frac{x}{p}+\frac{y}{q}=1$  and
$\frac{x}{q}+\frac{y}{p}=1$ intersects OX and OY axes at A, B respectively. Show that the path of M which is the mid-point of AB is given by,
  $2\left(p+q\right)xy=pq(x+y)$
  ($p$, $q$ are discrete positive constants)

My attempt:
Any line which goes through the intersection point of above lines can be written,
$\left(px+qy-pq\right)+\gamma \left(qx+py-pq\right)=0\ \ \ ;\ \gamma \ is\ a\ parameter$
$\left(p+\gamma q\right)x+\left(\gamma p+q\right)y-pq\left(1+\gamma \right)=0$
$\frac{x}{\frac{pq(1+\gamma )}{\left(p+\gamma q\right)}}+\frac{y}
{\frac{pq(1+\gamma )}{\left(\gamma p+q\right)}}=1$
Which implies,
$A \equiv\left(\frac{pq(1+\gamma )}{\left(p+\gamma q\right)},\ 0\right)$
$B \equiv\left(0,\frac{pq(1+\gamma )}{\left(\gamma p+q\right)}\ \right)$
Now, since $M$ is the mid-point of $AB$,
$M \equiv \left(\frac{pq(1+\gamma )}{2\left(p+\gamma q\right)},\frac{pq(1+\gamma )}{2\left(\gamma p+q\right)}\right)$
And  since $M$ is variable,
$M\equiv \left(x,y\right)\ \equiv \ \ \left(\frac{pq(1+\gamma )}{2\left(p+\gamma q\right)},\frac{pq(1+\gamma )}{2\left(\gamma p+q\right)}\right)$
$\textit{x} =  y\left(\frac{\left(\gamma p+q\right)}{\left(p+\gamma q\right)}\right)$
Here, I am stuck.How do I go about this?
Answer: $$x=\frac{pq(1+\gamma )}{2\left(p+\gamma q\right)} \text{ and }y=\frac{pq(1+\gamma )}{2\left(\gamma p+q\right)}$$
Thus,
$$\frac{1}{x}+\frac{1}{y}= \frac{2\left(p+\gamma q\right)}{pq(1+\gamma )}+\frac{2\left(\gamma p+q\right)}{pq(1+\gamma )}=\frac{2}{pq(1+\gamma)}(p+q)(1+\gamma)$$
$$=\frac{2(p+q)}{pq}$$
Thus,
$$\frac{1}{x}+\frac{1}{y}=\frac{2(p+q)}{pq}$$
Or,
$$2\left(p+q\right)xy=pq(x+y)$$
Comment: Thanks a lot.How blind was I to see the final step after coming that far???

Path of the mid-point of AB


TemplateNotFound: index.html with Google App Engine & Jinja2

Question: I'm trying to build my first GAE app with jinja2. After overcoming a dozen small errors, now I'm stuck with this:
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2\webapp2.py", line 1536, in __call__
    rv = self.handle_exception(request, response, e)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2\webapp2.py", line 1530, in __call__
    rv = self.router.dispatch(request, response)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2\webapp2.py", line 1278, in default_dispatcher
    return route.handler_adapter(request, response)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2\webapp2.py", line 1102, in __call__
    return handler.dispatch()
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2\webapp2.py", line 572, in dispatch
    return self.handle_exception(e, self.app.debug)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2\webapp2.py", line 570, in dispatch
    return method(*args, **kwargs)
  File "C:\Users\CG\Documents\udacity\HiMon\main.py", line 31, in get
    template = jinja_environment.get_template('index.html')
  File "C:\Program Files (x86)\Google\google_appengine\lib\jinja2\jinja2\environment.py", line 719, in get_template
    return self._load_template(name, self.make_globals(globals))
  File "C:\Program Files (x86)\Google\google_appengine\lib\jinja2\jinja2\environment.py", line 693, in _load_template
    template = self.loader.load(self, name, globals)
  File "C:\Program Files (x86)\Google\google_appengine\lib\jinja2\jinja2\loaders.py", line 115, in load
    source, filename, uptodate = self.get_source(environment, name)
  File "C:\Program Files (x86)\Google\google_appengine\lib\jinja2\jinja2\loaders.py", line 180, in get_source
    raise TemplateNotFound(template)
TemplateNotFound: index.html

Here my yaml file:
application: himother
version: 1
runtime: python27
api_version: 1
threadsafe: yes

handlers:
- url: /favicon\.ico
  static_files: favicon.ico
  upload: favicon\.ico

- url: .*
  script: main.app

libraries:
- name: webapp2
  version: "2.5.1"
- name: jinja2
  version: "2.6"

Here my code:
import os
import webapp2

import jinja2

jinja_environment = jinja2.Environment(autoescape=True,
    loader=jinja2.FileSystemLoader(os.path.join(os.path.dirname(__file__), 'templates')))

class MainPage(webapp2.RequestHandler):
    def get(self):
        template_values = {
            'name': 'Serendipo',
            'verb': 'extremely happy'
        }

        template = jinja_environment.get_template('index.html')
        self.response.out.write(template.render(template_values))

app = webapp2.WSGIApplication([('/', MainPage)],
                              debug=True)

Here my .html template:
<!DOCTYPE html>

        <title>Look Ma, I'm using Jinja!</title>

        Hi there - I'm {{ name }}, and I {{ verb }} programming!

Despite the error message, I have a folder called "templates" and, within it, created the index.html file:

I also have installed jinja2.
Does anyone have any idea of the cause of this error now?
Answer: You should probably be using the jinja2 version that's included in webapp2_extras.
The example of getting this set up is here: http://webapp-improved.appspot.com/api/webapp2_extras/jinja2.html#webapp2_extras.jinja2.Jinja2
The key difference is that instead of setting up the jinja2.Environment yourself, you do...
from webapp2_extras import jinja2
jinja = jinja2.get_jinja2(app=self.app)
jinja.render_template("index.html")

You will also likely need to include jinja2 in your libraries section of app.yaml:
libraries:
- name: jinja2
  version: "2.6"

Comment: Hi, @jgeewax, I included "- name: jinja2 version: 2.6" in my libraries section (actually, it was already there, I make a mistake when pasting it in this question). I'll study the jinja2 version issue reading the link you pointed.
Answer: Man.. I was facing the same problem as you and just found the answer.
jinja_environment = jinja2.Environment(autoescape=True,
    loader=jinja2.FileSystemLoader(os.path.join(os.path.dirname(__file__), 'templates')))

class MainPage(webapp2.RequestHandler):
    def get(self):
        template_values = {
            'name': 'Serendipo',
            'verb': 'extremely happy'
        }

        template = jinja_environment.get_template('index.html')
        self.response.out.write(template.render(template_values))

The "jinja_environment" part don't need the extra [, 'templates']. This you should place before your index.html file string like:
template = jinja_environment.get_template('templates/index.html')

At least this is how it worked for me (oh, and I wasn't using the autoescape=True part either, but I guess its optional).
Thinking again, maybe you could even leave the [, 'templates'] part, but you would need to put a "/" before the 'index.html', making '/index.html', but this is another guess.
Comment: the ``autoescape=True``  was just right for the udacitity course on web development introducing templates
Answer: After using the webapp2_extras setup described in [1] and here, I still had this error. I tried logging.info(jinja2.default_config). This showed that the undocumented default directory for templates is app-yaml-dir/templates/ ('template_path': 'templates'). I have tried everything but that. You can reset it, or leave it as it is, once you know it.
jinja2.default_config['template_path'] = "html"

If you prefer to put templates in various directories, just set it to empty and use the full path when rendering render_response('module/home.html', **context)
jinja2.default_config['template_path'] = ""

http://webapp-improved.appspot.com/api/webapp2_extras/jinja2.html#webapp2_extras.jinja2.Jinja2
Answer: jinja_environment = jinja2.Environment(autoescape=True,
    loader=jinja2.FileSystemLoader(os.path.join(os.path.dirname(__file__), 'templates')))

Actually the line in your code means that you direct your request to the templates folder but it seems like you have not stored your "index.html" in the templates folder so just remove the redirection or transfer your index file to templates folder.


Unable to use File read and write in c# .net

Question: For some reason, I'm unable to use File read and write in c# .net, error display like below

Where I do have the System.IO.Compression.FileSystem under my Reference

Does anyone know why and how could I resolve this issue?
Answer: That File is referring to the Controller.File method.
It's enough to fully qualify the type:
var sw = System.IO.File.CreateText(filePath);


What kind of data each freeradius table store in database?

Question: i got a project to create a freeradius like application, but i don't understand what kind of data each table store in the database. Anyone care to explain ? here's the list of those tables:

nas
radacct
radcheck
radgroupcheck
radgroupreply
radpostauth
radreply
radusergroup

any help will be very appreciated, and sorry for my english
Answer: First you need to read up on how the user's file works, as the logic of the SQL module is based on that.
The tables in the default schema are used for the following:

nas - Definitions of RADIUS clients.  These are the IP addresses and shared secrets of NAS (Network Access Servers) that will be talking to FreeRADIUS.  This contains the same basic information as the clients.conf file.  These are read in from the SQL database on startup, and provide a convenient way of sharing client definitions across a cluster of FreeRADIUS instances.

radpostauth - This contains a record of the result of an authentication attempt. Usually it will hold the username, when the authentication attempt was made, and whether authentication was successful or not.  Many people customize this to record extra information.  Some even record incorrect passwords to help helpdesk users (though this is not recommended).

radacct - This stores RADIUS accounting data. RADIUS accounting data describes a service session.  The session usually starts immediately after authentication, and ends when the user either disconnects from the network service (disassociates from the wireless access point, pulls out the ethernet cable etc...), or is administratively terminated via a PoD Packet of Disconnect, or a session timer (see the Session-Timeout attribute).
This table stores the username, connection point, and traffic stats for the session,  as well as many other fields.
Not all columns will be useful for all deployments, so its a good idea to remove ones that you're not using, and update the queries appropriately.
Only one row is created per session, and is updated over the lifetime of that session.

radcheck - This has identical logic to the first line of a user's file entry.  It has check and control pairs which are differentiated by the operator used.  If the check pairs match then radreply is queried for reply pairs to add to the reply list.  Both radcheck and radreply are indexed by user by default (it can be altered).  Only one set of radcheck/radreply items is permitted per index value.

radreply - Contains reply pairs to add if the radcheck check items matched.

radusergroup - Contains mappings between users and groups.  If a mapping exists for a user, the radgroupcheck and radgroupreply tables will be queried with the same logic as radcheck and radreply, the main difference being that check and reply items are being looked up for the group and not the user. This is also used when the SQL-Group attribute is used in a condition.  SQL-Group is a magic attribute which results in radusergroup being queried, evaluating to true if the user is a member of a group, and false if they are not.

radgroupcheck - Identical to radcheck but indexed by group instead of user.

radgroupreply - Identical to radreply but indexed by group instead of user.

The configuration files for rlm_sql are split.  There's the main config file in mods-available/sql, and then the SQL dialect specific one in mods-config/sql/main/<dialect>/queries.conf

mods-available/sql is where you set connection parameters (IP address of the server, port, credentials, database flavour).
queries.conf is where you can alter the default queries and index values.


Possible to setup a ftp proxy at home so i can work from coffee shops?

Question: My company has firewall rules that only allow my home IP access to their servers.
Can i set up an ftp proxy at my house so i can ftp into the servers from other places? Is this sort of thing possible? if so, how? Sometimes i get sick of working from my home office =)
Thanks
Comment: Home internet connections are on dynamic IPs, except in rare circumstances and you're specifically charged for a fixed IP. Are you sure it's tied to your IP?
Comment: it is tied to my ip. when my ip changes i have to give my boss my new ip in order to get into the servers.
Answer: The first thing that comes to mind is an SSH tunnel. However, FTP is not the most tunnel-friendly protocol (it is somewhat possible, see wikipedia for details).
To forward a port from your laptop to your work computer (184.108.40.206) via your house computer (188.8.131.52), you can do something like:
ssh -L10099:184.108.40.206:99 188.8.131.52

Now accessing local port 10099 will connect you to your work computer port 99 (I do not remember if there are some settings to change in ssh_config or sshd_config).
If tunneling does not work, another possible option in Linux is to ssh to your home computer and download the files there, then you can mount the directory locally with sshfs. Just a bit better than double FTP (work->home->laptop).
Finally, you can set up a VPN between your laptop and house and have ad-hoc IP routing to your work computer.
Comment: im going to go with remote desktoping into my home computer and downloading the files. then using sshfs. thanks a lot


Can someone explain the logic of combinations in this question?

Question: Problem:

An ancient human tribe had a hierarchical system where there existed one chief with 2 supporting chiefs, each of whom had 2 equal, inferior officers. If the tribe at one point had 10 members, what is the number of different ways to choose the leadership of the tribe? That is, in how many ways can we choose a chief, 2 supporting chiefs, and two inferior officers reporting to each supporting chief?

Source: AoPS Alcumus
Given Solution:

There are 10 choices for the chief. For each choice, there are $\binom{9}{2}$ to choose the 2 supporting chiefs from the remaining members, for a total of $10\cdot \binom{9}{2}$ ways to choose the chief and supporting chiefs. There are then $\binom{7}{2}$ ways to choose the inferior officers for the first supporting chief and $\binom{5}{2}$ ways to choose the inferior officers for the second supporting chief. This gives us a total of $10\cdot\binom{9}{2}\cdot \binom{7}{2}\cdot\binom{5}{2} = \boxed{75600}$ ways to form the leadership of the tribe.

My questions:

How can they do $\binom{9}{2}$ for the first level chiefs when it is not given that they are indistinct? I would normally go about $^9P_2=9\cdot8$ i.e. 9 choices for the first and 8 choices for the second chief.
Why it that we do $\binom{7}{2}\cdot\binom{5}{2}$ for the inferior officers? Why not $\binom{7}{4}$?

I am sorry but I am new to this stuff so these might seem obvious to you but are not so for me. Thus, can some one please explain the answers for my questions exactly? Thanks!
Answer: "How can they do ${9 \choose 2}$ when it's not given they are indistinct?"
I think they are indicating that they are indistinct when they distinguish both as "supporting chiefs".  It's implied that if Bob is the head chief and Martha and Taylor are the support chiefs is the same thing as Bob being the head chief and Taylor and Martha are the support chiefs.
"Why ${7 \choose 5} \cdot {5 \choose 3}$ and not ${7 \choose 4}$?"
Because two inferior officers work for specific support chiefs and the pairs are distinguishable.  If Sheila and Conception work for Martha while Enrico and Clyde work for Taylor, this is different than if Sheila and Enrico work for Martha while Conception and Clyde work for Taylor, even though those are the same 4 inferior officers.
In short for m out of n:
If order matters:  n*(n-1)....(n-m+1) = n!/(n-m)!
If order doesn't matter:  [n!/(n-m)!]/m! = ${n \choose m}$
If there are two groups r and v and order doesn't matter: ${n \choose r}*{{n -r} \choose v}$.
And If there are two groups r and v and order does matter: $n!/(n - r)!*(n - r)!/(n - r -v)! = n!/m!$. (Note: if order matters size and number of groups do not!)
Answer: On point (1), if the original problem had specified "2 equal supporting chiefs"
instead of just "2 supporting chiefs," it would be easier to see that the intended solution was to regard the two supporting chiefs as interchangeable,
that is, "Chief Mary with supporting chiefs Tom and Ed" would be the same as
"Chief Mary with supporting chiefs Ed and Tom."
But consider the wording at the very end of the original question:
"in how many ways can we choose a chief, 2 supporting chiefs, and two inferior officers reporting to each supporting chief?"
If we just insert the words "from a tribe of ten members" in an
appropriate place, the end of the question is a complete question in itself,
and we can regard everything that came before it as material to help
understand what we mean by those words. That is, when the problem identifies
two officers in a particular position, their roles are interchangeable.
Obviously, the wording of the whole problem is not completely consistent
and logical. The trick is to extract the most obvious meaning.
As for part (2), I see fleablood already answered that part while I was
working on this.
Comment: Sorry 'bout that.
Comment: @fleablood No problem. I liked your answer. :-)
Answer: For question 1, I would venture to say that people (chiefs in this case) are by nature distinct. For question 2, you could pick four inferior officers all at once, but then you would have to choose two of them for inferior chief A and two for inferior chief B.
Comment: People may be distinct but their positions need not be.  If you need to hire two secretaries and your chooses are Mary, Bill, and Fred, you can choose Mary and Bill, Mary and Fred, or Bill and Fred.  It doesn't matter if once you hire (say Mary an Fred) you seat Fred on the left an Mary on the right, or Mary on the left and Fred on the right.  All that matters is you had 2 equivalent positions to fill.