Do the type of cleats matter?

Question: So, I've been playing soccer for a while now and when I play with flat soccer cleats (the one you wear when you play indoor soccer on cement or wooden floor) on a soccer field with grass, I don't play the same as when I use the cleats that  are supposed to be used on soccer fields. I can't dribble the same way and shoot the same so, I want to know if the type of shoes you wear (cleats or football flat shoes for indoor football) have anything to do when playing a match.
Comment: There's so many things to consider, condition of the pitch, weather conditions, personal feel...Some guidelines could be given I suppose, but still too opinion based and rather broad too.
Comment: @Don_Biglia - I think it's pretty clear cut. You wouldn't use indoor shoes on a muddy surface, and you certainly wouldn't use soft ground shoes on a dustbowl unless you want to roll your ankles.
Answer: There are four main types of shoes that footballers commonly use.

Soft ground shoes consist of a small number of long studs (usually 6 - 8 ) that penetrate wet or loose soil / mud to provide traction. These studs may be metal screw-ins. If used on firm ground, the studs won't dig in and the player is at risk of being unbalanced, leading to injuries such as sprained ankles.
Firm ground shoes consist of a larger number (usually 10 - 15) small, moulded studs that distribute weight evenly. These boots grip into the grass on the surface of the pitch, but do not penetrate into soil. If used on soft ground, there will be a lack of traction, as the grass will come out of the ground and move under the shoe. If used on artificial turf or indoor, they will damage the surface, as well as provide a lack of grip due to reduced surface area.
Turf shoes have numerous slightly-raised rubber studs or lugs that grip onto astro turf. They will typically mark wooden floors, so should not be used indoors. If used on natural turf, the grass will move too much underneath them, which may cause a loss of traction.
Indoor shoes are made of non-marking gum rubber and are designed to grip on wooden floors. They will slide around on artificial and natural turf surfaces too much to be of use in those environments.

Also worth mentioning are blades and artificial turf shoes. These are less common, but artificial turf shoes are being used more regularly as more artificial turf pitches are being constructed in areas where grass does not grow easily, readily or cheaply.
I've sourced the information from personal experience and from Kitbag's blog, Pro-Direct Soccer and ebay's football boot buying guide.

Do the type of cleats matter?


Finding formula for a Summation.

Question: I'm given the sum of even squares to be $\frac{2n(n+1)(2n+1)}{3}$ e.g. 4+16+36+...
I'm also given the sum of odd squares to be $\frac{n(2n-1)(2n+1)}{3}$ 1+9+25+...
The problem is to find the summation formula of the series 1-4+9-16+25-... using the above facts.
I know I can write the sum of the even starting at 0 (e.g. 0+4+16+36+...) by $\frac{2(n-1)((n-1)+1)(2(n-1)+1)}{3}$ but I cannot figure out how to combine them to get the target series ( 1-4+9-16+25-...)
When just subtracting the evens starting from zero from the odds I always seem to get a sum that has more of the series than I want (1,6,15,28) when it should give (1,-3,6,-10) can anybody point me in the right direction?
Comment: We have been given two gift expressions, one for the sum of the first $n$ even squares and one for the sum of the first $n$ odd squares. **Throw away** the second gift expression, divide the first gift expression by $4$. You get the formula for the sum of the first $n$ squares. (Presumably that's not what is intended, too simple!)
Comment: What about separately considering the cases of n odd and n even?  If n is odd, there's one more odd square than even.  If n is even, there are equal numbers of odd and even squares.  Though from the first few results, you might have a good guess already.
Comment: First, please state when your sums begins and when it ends. It should just make the task easier to evaluate the sum. And similarly for 1-4+9-16 : do they both start from k=1 and stop at n ? And by the way your relation for the sum of the odds is only correct for n nonzero.
Comment: @Ismail: The formulas are clearly intended to give the sum of the first $n$ positive even and odd squares, respectively, so they both work fine for $n=0$.
Answer: Let $e_n$ be the sum of the squares of the first $n$ even positive integers, and let $o_n$ be the sum of the squares of the first $n$ odd positive integers; you have formulas for these. Let $s_n$ be the sum of the first $n$ terms of the target series, $1-4+9-16+-\dots$. Consider two cases, $n$ even and $n$ odd. (Note that I will be assuming throughout that $n$ is a positive integer.)
Suppose that $n$ is even, say $n=2m$. Then $$\begin{align*}
s_n&=s_{2m}\\
&=o_m-e_m\\
&=\frac{m(2m-1)(2m+1)}3-\frac{2m(m+1)(2m+1)}3\\
&=\frac{m(2m+1)}3\Big((2m-1)-2(m+1)\Big)\\
&=-m(2m+1)\;.
\end{align*}$$
Now suppose that $n$ is odd, say $n=2m+1$. Then $$\begin{align*}
s_n&=s_{2m+1}\\
&=o_{m+1}-e_m\\
&=\frac{(m+1)(2m+1)(2m+3)}3-\frac{2m(m+1)(2m+1)}3\\
&=(m+1)(2m+1)\;.
\end{align*}$$
Let's run a quick spot-check. The first formula yields $s_4=-10$, which is correct, and the second yields $s_5=15$, which is also correct. All that remains is to combine them into a single nice expression, if possible. We have
$$s_n=\begin{cases}
-m(2m+1),&\text{if }n=2m\\
(m+1)(2m+1),&\text{if }n=2m+1\;.
\end{cases}$$
The algebraic sign is easily taken care of with a factor of $(-1)^{n+1}$, and $$\lceil n/2\rceil=\begin{cases}
m,&\text{if }n=2m\\
m+1,&\text{if }n=2m+1\;,
\end{cases}$$
so it only remains to handle the factor of $2m+1$. This can be done in many ways, but since we're already using $\lceil n/2\rceil$, one easy way is to note that $2m+1=2\lceil n/2\rceil+(-1)^n$ no matter whether $n=2m$ or $n=2m+1$. Thus, we can finally write $$s_n=(-1)^{n+1}\left\lceil\frac{n}2\right\rceil\left(2\left\lceil\frac{n}2\right\rceil+(-1)^n\right)\;,$$ or, if you prefer, $$s_n=2(-1)^{n+1}\left\lceil\frac{n}2\right\rceil^2-\left\lceil\frac{n}2\right\rceil\;.$$

Finding formula for a Summation.


Xcode iOS: How to reset a sound once it has played using AVFoundation

Question: So I made a soundboard for the hospital I work for, it plays different respitory sounds for the RT's to listen too for furthering education and for trainees.  I can stop and start the sounds fine.  The problem Im having is when the sound is complete.  You have to tap any button twice to play the next sound.  So I am wondering how you would reset soundfiles upon completion.  I am pretty new to obj-c and my gut is telling me to implement NSTime, however I cant figure out how to do it, or if this is even what I want to do.
Thanks in advance!
- (IBAction)play {
    if (soundIsPlaying == YES) {
        [audioplayer release];
        soundIsPlaying = NO;
    }

    else if (soundIsPlaying == NO) {
        NSString *path = [[NSBundle mainBundle] pathForResource:@"breathe1" ofType:@"wav"];
        audioplayer=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
        audioplayer.delegate = self;
        audioplayer.volume = 1.2;
        audioplayer.numberOfLoops = 0;
        [audioplayer play];
        soundIsPlaying = YES;
    }
}

Answer: If you are using AVAudioPlayer, there is a property named numberOfLoops that you can set.
Checkout the AVAudioPlayer class reference on Apple web site.
Comment: Im not using AVAudioPlayer but I will take a look at it
Comment: According to your code, you are using AVAudioPlayer and you set your numberOfLoops = 0 which meant playing only 1 time.
Comment: You know what your right I am...I have a head cold so its not helping my thought process.
Comment: Not a problem.  Glad to help.
Answer: You can catch the completion of your sound file by implementing the audioPlayerDidFinishPlaying delegate, see AVAudioPlayerDelegate: http://developer.apple.com/library/IOs/#documentation/AVFoundation/Reference/AVAudioPlayerDelegateProtocolReference/Reference/Reference.html
Then you can reset/release your player in that handler.
Answer: I'm not sure if this will work but perhaps if you change
audioplayer.numberOfLoops = 0;

to
audioplayer.numberOfLoops = -1;

so that it looped until stopped.
Comment: some of the sound files are short.  I had thought about looping until stopped however I did not want too because I want the users to know when breathing has completed.  Also this helps with pattern breathing detection, but I wont go into boring details about what the RT's want.  thanks for the feedback!


Redirect to another form on login

Question: I have created a test site using drupal 7.
My requirement is to do an additional operation on user login.
I need to redirect the users to another form when the user clicks on login button.
In this form there will be a question and 2 buttons 'update' and 'no'.
If the user chooses update a DB update will happen and also default login action.
But if the user chooses 'no' ,login should not happen.
I have already tried user_login alter, multi-step forms and confirm_form. But nothing seems to be working. Can anyone help.?
Comment: So you want to force user to Update , or he/she is not able to login?
Comment: yes. That is what I am trying to achieve
Comment: Why don't you provide an agreement check-box in login button itself?
should this action happens only one time?
Comment: no i need to do this in a separate form.
Comment: are you familiar with module development in drupal?
I can send you some codes about how to redirect and logout if you can build up the form yourself
Answer: You can make your own login form (or alter default login form, i think) with two submit buttons calling different callback functions:
<code>function xxx_login_form($form, &$state) {

  // .. usename and password fields here

  $form['submit_update'] = array(
    '#type' => 'submit',
    '#value' => t('Update'),
    '#submit' => array('xxx_login_submit_update'),
  );

  $form['submit_no'] = array(
    '#type' => 'submit',
    '#value' => t('No'),
    '#submit' => array('xxx_login_submit_no'),
  );

  return $form;

}

function xxx_login_submit_update($form, &$state) {

      if(user_authenticate($state['values']['username'], $state['values']['password'])) {
        // log in user
        $user_obj = user_load_by_name($username);
        $form_state = array();
        $form_state['uid'] = $user_obj->uid;
        user_login_submit(array(), $form_state);

        // .. do some updates

        return true;
      } else {
        return false;
      }

}

function xxx_login_submit_no($form, &$state) {

   // do what you need but do not log user in.

}
</code>
You can of course add custom validate functions, messages or what you need. If you want redirect to another page after button is pressed, you can use
<code>'#action' => 'some/page/1'
</code>
for the buttons.
Answer: Login Toboggan provides that feature along with many other useful ones.
Comment: I prefer custom code than using a contributed module
Comment: Well then you'll likely achieve that altering the native login form, adding your custom fields, custom validation and custom submit functions
Answer: There are number of contributed module (like Login Toboggan) for such functionality but don't want to use contributed module. So you can do it with the help Rules and a custom module (to display confirmation form). You can also combine the rule in your custom module.

Redirect to another form on login


onclick event not working on mobile

Question: what I currently have is

Iyanya – "Hold On " (Prod. by Don Jazzy)

and the javascript function is

function a() {
    setTimeout(function () {
        url = "http://www.google.com"
        document.location = url;
    }, 1000);
}

The code first downloads the resource and after one-second redirects to the new URL we want.
It is working perfectly on desktop browsers... but not working on mobile browsers... I am unable to find why?. Kindly suggest the solution...
Comment: Please try to use `onmouseup` together with `onclick` and see if it work?
`onclick="a();" onmouseup="a();"`
Comment: No... It still doesn't work...
Answer: try this

function a() {
    setTimeout(function () {
        url = "http://www.google.com"
        window.location = url;
    }, 1000);
}
Comment: window.location is the same as document.location

onclick event not working on mobile


Can I have both Language and Country path prefixes?

Question: On our site, paths are all prefixed by language and country. For example:
http://example.com/en/us/about
In Drupal 7, a previous vendor implemented this by using the Persistent URL module, which rewrites all on-page URLs to include the prefix of your choice. PURL was used to add add the country as a prefix to each path. However, it fails when URL Prefix language negotiation is turned on, requiring a core hack to locale.inc to make both work together to avoid the language negotiation from stomping over our prefix:
<code>@@ -462,7 +462,7@@ -462,7 +462,7 @@ function locale_language_url_rewrite_url(&$path, &$options) {

       case LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX:
         if (!empty($options['language']->prefix)) {
-          $options['prefix'] = $options['language']->prefix . '/';
+          $options['prefix'] = $options['language']->prefix . '/' . $options['prefix'];
         }
         break;
     }
</code>
We are rebuilding the site in Drupal 8, and this is one of the things we need to figure out. Obviously, we'd like to avoid having to reinstate some kind of core hack, but by the same token, we can't change the URL structure due to client requirements.
Is there any way we can pass and preserve both language and country information via path prefixes?
Answer: you can either use pathauto patterns or pathologic which is still -dev .. to adapt your paths.


How can I calculate a column data for different conditions using single query in sql server?

Question: I am using below query to count a particular column data based on single condition.
SELECT COUNT(DISTINCT(S.INVOICENO)) AS LESSTWO , YEAR(S.invoicedate) YER,
    Month(S.invoicedate) MNTH
FROM SALESDATA S
where S.BILLINGTYPE='INVOICE'
    AND (S.invoicedate >='4-1-2009' and S.invoicedate <='4-30-2010')
    AND S.TAXABLEAMT <=2000
GROUP BY YEAR(S.invoicedate) ,Month(S.invoicedate)
ORDER BY YEAR(S.invoicedate) ,Month(S.invoicedate)

But I have to calculate for 3 more conditions. Is it possible to count based on 3 conditions(i.e. 2001 - 3000,3001 - 4000, 4001 - 5000,>5000) and I want result set for all the conditions?
Regards,
N.SRIRAM
Answer: I think you really need to split up the query into 3 distinct queries - one for each of the conditions you require
Answer: Untested, but should be about right:
SELECT CASE
          WHEN S.TaxableAmt <= 2000 THEN '<=2000'
          WHEN S.TaxableAmt <= 3000 THEN '2001-3000'
          WHEN S.TaxableAmt <= 4000 THEN '3001-4000'
          ELSE '>5000'
       END as Bracket,
COUNT(DISTINCT(S.INVOICENO)) AS LESSTWO , YEAR(S.invoicedate) YER,
    Month(S.invoicedate) MNTH
FROM SALESDATA S
where S.BILLINGTYPE='INVOICE'
    AND (S.invoicedate >='20090401' and S.invoicedate <='20100430')
GROUP BY
      CASE
          WHEN S.TaxableAmt <= 2000 THEN '<=2000'
          WHEN S.TaxableAmt <= 3000 THEN '2001-3000'
          WHEN S.TaxableAmt <= 4000 THEN '3001-4000'
          ELSE '>5000'
       END,
YEAR(S.invoicedate) ,Month(S.invoicedate)
ORDER BY YEAR(S.invoicedate) ,Month(S.invoicedate)

You have to repeat the case expression in the GROUP BY clause (or put it all in a subquery), and I've fixed your date constants so that they're unambiguous.
Comment: Thank you sir. I modified your query as below.


Como posicionar corretamente um pedaço da View criado em java?

Question: Após carregar minha View, se o usuário clique no botão então aparece um menu na frente como mostra na imagem:

A camada mais superior deste menu é um FrameLayout, gostaria de deixa-lo com Gravity RIGHT e BOTTOM, mas não sei passar essas características por java
estou fazendo desta forma:

FrameLayout.LayoutParams lparams = new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.WRAP_CONTENT,
            FrameLayout.LayoutParams.WRAP_CONTENT,
            Gravity.RIGHT);
    frame_dados.setLayoutParams(lparams);

Quero configura-lo em desta forma:
<FrameLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|right"/>

Comment: Seu linear_dados é um LinearLayout?
Comment: Boa, funcionou aqui!
Comment: Isso, deixa-lo bottom | Right, essa é minha dúvida, o resto arrumo depois
Comment: É um frame, tinha escrito errado
Answer: Essa definição do FrameLayout no XML, exemplo:
<FrameLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|right"/>

É equivalente a esta programaticamente:
FrameLayout.LayoutParams lparams = new FrameLayout.LayoutParams(
    FrameLayout.LayoutParams.WRAP_CONTENT,
    FrameLayout.LayoutParams.WRAP_CONTENT);
lparams.gravity = Gravity.RIGHT | Gravity.BOTTOM;

Veja mais detalhes na documentação.


Difference between rexp and qexp in R

Question: I need to write a simulation that requires the use of exponential distribution. I was wondering what is the difference between the following two approaches in drawing random numbers from an exponential distribution?
qexp(p=runif(1),rate)

rexp(1, rate)

Thanks in advance
Answer: The only difference is that rexp(1, rate) is just a little easier.
It's also almost twice as fast, but it's unlikely that the simulation of exponential samples would be slowest part of your simulation, so there's not much point in worrying about that.
Answer: Here is a comparison between both implementations (which have exactly the same degree of validity):
> library(microbenchmark)
> microbenchmark(x=qexp(p=runif(1e5),rate=2.3))
Unit: milliseconds
 expr      min       lq     mean   median       uq      max neval
    x 7.704467 8.669387 13.04644 11.41903 13.79021 57.00468   100
> microbenchmark(x=rexp(1e5,rate=2.3))
Unit: milliseconds
 expr      min       lq     mean   median       uq      max neval
    x 6.139942 7.356238 9.206156 8.243386 10.59891 17.29152   100

rexp() is thus slightly faster than the inverse cdf approach.

Difference between rexp and qexp in R


Modular Drupal content-type (variable sections)

Question: I'm trying to build a modular and quite dynamic backend. I'm using Drupal for the task but haven't been able to spin my head around how to make it happen.
I need ideas on how I might solve this rather complex task.

To explain what I would like to end up with, I've faked a screenshot showing in steps what I would like the end result to look like.
Step 1

Step 2

My client wants to display his different cases. To make each case different, he wants a system where he can pick and choose how parts of his content is displayed. I suggested a modular approach where he can choose a "module type" in a dropdown, and fill in the needed fields.

There are plenty more, but for the sake of this questions, lets just stick with those.

Needs:

Possible amount of modules should be infinite.
Possible to fill in all information on the different 'modules' on the 'case' page.

Do you have any idea on how this might be solved?
Answer: You can do this with the Field Collection module.
Add a field collection to your Case node and then add then add fields of the types you require to the field collection restricted to the amount of images or videos you want to display. An with the correct image styles assigned.
You could use the Field Group module to collapse the fields to improve the admin interface.
Edit:
Another option would be use Conditional fields module and add image fields to the case content type set the the amount of images to be displayed in each and the image style required. Then add a list field to the case content type with option on 1 image, 2 images, 3 images etc and then use Conditional fields to link this to display and hide the image fields.
Comment: Hi again. First of all: Thank you so much for helping me out. I've made some progress since my last comment and have found a patch (https://www.drupal.org/node/1464950#comment-8419673) for my problem, which sorted out things. I didn't apply the patch but edited the code as it stated in the comment. I now get my intended outcome - again, really appreciate your help!
Comment: Sorry - it's complex to explain, and even more so with no linebreak in my text. As you can see in my ref. image in "Step 1" it has a dropdown which determines how many fields should be visible. That part I could not figure out how to do in the "Field Collection"-plugin.
Comment: I have added to my answer above
Comment: I think we've come very very close. Unfortunately the "Conditional Fields"-plugin does not seem to take effect. I have made a selectfield with the options, which should, when I choose an option make the group invisible. I figured it might have something to do with using it together with "Field Groups", however, having it disabled doesn't change much. Also I've chosen the standard admin theme and made sure that $scripts are printed in my html.tpl file without any luck.
Comment: If conditional fields is not working well with field groups a few lines of javascript would do the job reacting on the change event of the select is to hide the image fields.
Answer: You might be interested in this usage of Display Suite example video from Drupal Camp 2011 LA a few years back:
http://replay.uci.edu/clients/drupal/Advanced_Display_Suite_-Flash(Large)_-_20110806_01.59.54PM.html
If you watch the video he has dozen such templates for the client to choose how a page is displayed. I believe he had a way to set like the template from a field choice when building the node.
Of course you the programmer need to define the templates -- but using DS + Views as he does makes this easier to manage (in code).
Comment: Hi - I tried looking at Display suite, which unfortunately did not suit my needs (at least the examples shown in the video did not match my problem), but I managed to figure it out as you can see above. Thanks for helping though!
Answer: There is finaly a module which does the work: Paragraphs
Same here


Isomorphism of an endomorphism ring, how can $R\cong R^2$?

Question: I'm aware that over a commutative ring, two free finitely generated modules of finite rank are isomorphic if and only if they have the same rank.
I'm trying to understand a curious example of why this does not hold over a noncommutative ring.

Let's take $M=\oplus_{i\in\omega}\mathbb{Z}$. Then let $R=\text{End}(M)$, which is not commutative. Then $R\cong R^2$ as left $R$-modules.

It seems like one could possibly make a basis of $R$ using only endomorphisms which act on the even or odd coordinates of elements of $M$, which might suggest such an isomorphism. Is there a clear proof of why $R\cong R^2$?
Comment: Actually, you probably want to take $M=\oplus_{i\in\omega}\mathbb{Z}$, rather than the product. The advantage is that $M$ is a free abelian group, whereas your $M$ is not free, which makes describing the endomorphisms more difficult.
Comment: At first you seem only interested in finitely generated modules, but your noncommutative example is infinitely generated. But then you might as well look at $R=\mathbb Z^\omega$, which is a countable product of $\mathbb Z$'s and is isomorphic to $R^2$.
Comment: @ArturoMagidin OK, I've changed that if it makes it easier to explain.
Answer: One is tempted (as I was originally), to argue as follows: since $M\cong M\oplus M\cong M\times M$, we have
$$R = \mathrm{Hom}(M,M) \cong \mathrm{Hom}(M,M\times M) \cong \mathrm{Hom}(M,M)\times\mathrm{Hom}(M,M) = R\times R,$$
and stop there. The problem with the argument is that in some instances we are dealing with these objects as $\mathbb{Z}$-modules rather than as $R$-modules (specifically the isomorphisms are isomorphism from $\mathrm{Hom}(M,M)$ to $\mathrm{Hom}(M,M\times M)$ is, right now, just an isomorphism as $\mathbb{Z}$-modules), so some care needs to be exercised to make the argument actually work.
First, note that $M\cong M\times M$  as $\mathbb{Z}$-modules.
Define a homomorphism $\varphi\colon M\to M\times M$ by maping $(m_i)$ to $\bigl((m_{2i-1}), (m_{2i})\bigr)$. That is, $(m_1,m_2,m_3,\ldots)$ maps to $\bigl( (m_1,m_3,m_5,\ldots),(m_2,m_4,m_6,\ldots)\bigr)$.
The elements of $R$ can be thought of as infinite "column-finite matrices"; that is, each endomorphism $M\to M$ corresponds to a family of functions $(\mathbf{f}_i)_{i\in\omega}$, with $\mathbf{f}_i\colon\mathbb{Z}\to M$; hence $\mathbf{f}_i = \sum_{j\in\omega}f_{ji}e_j$, where $e_j$ is the element of $M$ that has $1$ in the $j$th coordinate and $0$s elsewhere, $f_{ji}\in\mathbb{Z}$, and $f_{ji}=0$ for almost all $j$.
If we take an element of $\mathbf{f}=(f_{ij})$ of $R$, and compose it with the isomorphism $M\to M\times M$, we obtain a homomorphism $M\to M\times M$, given by $\bigl( (f_{i,2j-1}), (f_{i,2j})\bigr)$. So the map $\mathrm{Hom}(M,M)\to\mathrm{Hom}(M,M)\times \mathrm{Hom}(M,M)$ maps $(f_{ij})$ to $\bigl( (f_{i,2j-1}),(f_{i,2j})\bigr)$.
If we compose maps $\mathbf{f}=(f_{ij})$ and $\mathbf{g}=(g_{ij})$, we get the map
$(h_{ij})$, where
$$h_{ij} = \sum_{k=1}^{\infty}g_{ik}f_{kj}.$$
Since $f_{kj}=0$ for almost all $k$, the sum is finite and $h_{ij}$ makes sense.
This gives the action of $R$ on $\mathrm{Hom}(M,M)$. The action of $R$ on $\mathrm{Hom}(M,M)\times\mathrm{Hom}(M,M)$ is then given by
$$
\mathbf{g}\bigl((f_{ij}),(f'_{ij})\bigr) = \bigl( \mathbf{g}(f_{ij}), \mathbf{g}(f'_{ij})\bigr)
= \bigl( (h_{ij}), (h'_{ij})\bigr)$$
where
$$h_{ij} = \sum_{k=1}^{\infty}g_{ik}f_{kj},\quad\text{and}\quad h'_{ij}=\sum_{k=1}^{\infty}g_{ik}f'_{kj}.$$
To see that the map from $\mathrm{Hom}(M,M)$ to $\mathrm{Hom}(M,M\times M)$ respects the action of $R$ (that is, that we get an $R$-module homomorphism, not merely a $\mathbb{Z}$-module homomorphism), let $(f_{ij})\in\mathrm{Hom}(M,M)$ and $\mathbf{g}\in R$. The element $\mathbf{g}(f_{ij})$ is mapped to
$$\left( \Bigl(\sum_{k=1}^{\infty}g_{ik}f_{k,2j-1}\Bigr),\Bigl( \sum_{k=1}^{\infty}g_{ik}f_{k,2j}\Bigr)\right)$$
On the other hand, if we let $\mathbf{g}$ act on $\bigl( (f_{i,2j-1}), (f_{i,2j})\bigr)$, we get
$$\mathbf{g}\left( (f_{i,2j-1}), (f_{i,2j})\right) =  \left(\Bigl( \sum_{k=1}^{\infty}g_{ik}f_{k,2j-1}\Bigr), \Bigl( \sum_{k=1}^{\infty}g_{ik}f_{k,2j}\Bigr)\right),$$
that is, the same as the image of $\mathbf{g}(f_{ij})$. So the homomorphism $\mathrm{Hom}(M,M)\to\mathrm{Hom}(M,M)\times\mathrm{Hom}(M,M)$ given by $(f_{ij})\longmapsto ((f_{i,2k-1}),(f_{i,2k}))$ is actually a homomorphism as $R$-modules. Since the original map as $\mathbb{Z}$-modules was a bijection, so is this one, hence $\mathrm{Hom}(M,M)$ and $\mathrm{Hom}(M,M)\times\mathrm{Hom}(M,M)$ are isomorphic not only as $\mathbb{Z}$-modules, but also as $R$-modules. So we obtain:
$$R = \mathrm{Hom}(M,M) \cong \mathrm{Hom}(M,M)\times\mathrm{Hom}(M,M) =R\times R,$$
with the isomorphism being an isomorphism of $R$-modules, as desired.
Comment: One should be careful when following the module structures along those isomorphisms, though!
Comment: Thanks! Do you mind explaining what exactly you mean by interweaving the coordinates to get $M\cong M\times M$?
Comment: @Danielle: There is a gap that needs explaining, but I'm going away for a bit. I'll delete and be back.
Comment: Amazing, thanks!
Answer: You probably mean that "two FREE finitely generated $R$-modules  $M_1$ and $M_2$ are isomorphic iff they have equal rank".
It's not so surprising this doesn't work in the infinite dimensional case. Just look at infinite-dimensional vector spaces.
You should be careful when you talk about modules over a non-commutative ring. You should indicate whether you're talking about left/right modules, etc.
Edit: Not sure if this is correct, but you can write down an explicit isomorphism once you choose a bijection from the set of integers to the set of even integers. (Or something like that.)
Comment: OK, I've edited it to try to tighten up the language.


2015 Community Moderator Election Results

Question: Magento's first moderator election has come to a close, the votes have been tallied, and the 3 new moderators are:

philwhinkle will be installed as a moderator shortly — please thank them for volunteering, and share your assistance and advice with them as they learn the ropes!
Please join me in thanking Alex, who is stepping down as pro tem moderator. We are incredibly grateful to all the moderators who helped guide this site through the pre-election period.
For details on how the voting played out, you can download the election results here, or view a summary report online.
Comment: Thank you @Alex for your awesome support so far. And congratulation winners -Marius -philwinkle -benmarks. Community won by the way :)
Comment: congrats Marius , Philwhinkle  , Benmarks
Comment: Thank you Alex for great support
Comment: Congrats, again! :-)
Comment: Congrats all! Great team
Comment: Congratulations guys!
Comment: Congrats all :)
Comment: grats to you all :) let's keep this thing rolling
Comment: Congrats to all :)
Answer: Thank you all for participating. I am both humbled and grateful. For me it is business as usual - answer questions and vote. Let's get busy helping people and make this a great resource for the entire Magento community at-large!
Comment: Congrats on your little diamond near your name. I really hope you are back "full time" on SE not just for moderating, but for answering also. I missed your answers.
Comment: Yes we really like you(r hair :P) and  can you please style your hair as diamond :P
Comment: congrts @philwinkle .Ben& marius


cocreateinstance crashes on 32bit

Question: I'm trying to instantiate WMEncoder with CoCreateInstance() function, it's working fine on 64bit but crashes the program on 32bit os version.
<code>HRESULT hr = E_FAIL;
IWMEncoder2 *g_pEncoder = NULL;

hr = CoInitialize(NULL);
if (FAILED(hr))
    return hr;

hr = CoCreateInstance(CLSID_WMEncoder, NULL, CLSCTX_INPROC_SERVER, IID_IWMEncoder2, (void**)&g_pEncoder);
if (FAILED(hr)) {
    CoUninitialize();
    return hr;
}
</code>
Even on 64bit it generates access violation exception. here is windbg output:
<code>...
ModLoad: 75580000 761ca000   C:\Windows\syswow64\SHELL32.dll
ModLoad: 6fb40000 6fbc4000   C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.7601.17514_none_ec83dffa859149af\COMCTL32.dll
ModLoad: 74a10000 74a29000   C:\Windows\SysWOW64\OLEPRO32.DLL
ModLoad: 74f70000 74f86000   C:\Windows\SysWOW64\CRYPTSP.dll
ModLoad: 74a50000 74a8b000   C:\Windows\SysWOW64\rsaenh.dll
ModLoad: 73110000 7311e000   C:\Windows\SysWOW64\RpcRtRemote.dll
(1d48.1ea8): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for C:\Program Files (x86)\Windows Media Components\Encoder\WMEncEng.dll -
eax=08b7801f ebx=001807a8 ecx=00000000 edx=00000000 esi=00454c28 edi=00734258
eip=00734258 esp=0280f574 ebp=0280f5bc iopl=0         nv up ei pl nz na po nc
cs=0023  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00010202
00734258 c7442404284c4500 mov     dword ptr [esp+4],454C28h ss:002b:0280f578=001807a8
</code>
Comment: And what does hr equal to?
Comment: it crashes the program before returning an error code.
Comment: where exactly (what line) it crashes?
Comment: when calling CoCreateInstance(), it doesnt return
Comment: but when i change the context to CLSCTX_LOCAL_SERVER, it fails with error 0x80040154
Comment: The code is `0x80040154` `REGDB_E_CLASSNOTREG` "Class not registered" so you apparently don't have respective COM class available to your code. And the class belongs to Windows Media Encoder you supposedly just don't have installed. See https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/27d10f58-34a6-47c0-8492-6bbb10be39f6/cocreateinstance-clsidwmencoder-fail
Comment: do i need to register it explicitly, all i have done is install WMEncoder package found at microsoft website, and it worked very well on 64bit version
Comment: i did. i installed both WMEncoderSDK and WMEncoder itself, im aware of that. the registry keys are there as well.
Answer: If you only installed the 64-bit version, you won't be able to instantiate it in 32-bit code.
Comment: No, I installed the 32-bit version, and here is the link to it [http://www.microsoft.com/en-us/download/details.aspx?id=17792](http://www.microsoft.com/en-us/download/details.aspx?id=17792)

cocreateinstance crashes on 32bit


Performance issue HYPER-V : VM shows very high CPU use, but the Physical machine shows very small CPU use

Question: My Hyper-V VM(Server2008R2, SP1) shows very high (almost 100%) CPU use when fully under heavy load (6cores from total physical 8cores, 25Gb RAM from total 32GB) - used as TS, Picture TOP right corner
VM2 (SQL machine, Server 2008R2, SP1) shows almost no CPU use (1 core, 4GB RAM) - picture TOP LEFT
And funny thing :Physical machine (Bottom picture) has only 1core dedicated out of 8cores + 4GB dedicated out of 32GB just enough to run primary OS and hypervisor) -This physical machine shows almost no load !! for ALL cores of both quad-core CPUs! - Picture on bottom.
Problem/Question :
1, Are my CPUs working on 100%, but it doesnt show the Load which is in VMs? (so here the CPU graph is not correct in terms of "physical machine total CPU use")
- or
2, The CPU graph in Physical machine is correct, and all the Cores are beeing bored and not used for even 10% in the physical machine.(Rooftop of virtualization??)

or....??

Does anybody has experience with such a performance issue/performance evaluating of Hyper-V VMs vs physical machine?
I just want to know, if all my CPU power is beeing used as it shows in VM...If so I have to get new hardware, if not : My hardware should be fine, only some tweeking might be needed....or?
Picture attached : https://plus.google.com/photos/58146/albums/433/770?banner=pwa&pid=770&oid=58146
LEFT : VM SQL  load (not important)
RIGHT : Application VM 100% load!!!!!
BOTTOM : Physical machine load showing tiny CPU use
Comment: What is the host CPU config, and how many vCPUS have you assigned to the guest? It's not a 1-to-1 comparison when assigning vCPU against host physical hardware.
Comment: You image link seems to be broken.  Can you please re-upload that on http://imgur.com/?
Comment: HI, probably redirected URL, here valid one : https://picasaweb.google.com/lh/photo/HTHOX_Kr6oF9mVBNGKugMIevm7XataxtnMGhBSpe2d0?feat=directlink
Comment: CONFIG :
Physical machine Dell poweredge 2950 : 2x CPU Xeon 3ghz quadcore, 32Gb RAM, RAID10 4xSAS 15K + 2xSSD for OS and MSSQL.
Application Virtual machine : assigned from total : 6 cores, 25GB, RAID for data, 1xSAS for OS
MSSQL machine : assigned :1 core, 4Gb RAM.
Comment: @Jozef: Did you manage to solve this? (Also Image-Links are dead.)
Answer: try this tool to show the real CPU usage of guests:

http://hyperv.veeam.com/task-manager-hyper-v-announce/
Comment: Hi, thank you, I will give it a try. great!!!
Do you think running this tool on host and guest will show correct-the same results ?
Comment: try it on the host and look if the CPU usage is now displayed correctly.
Comment: HI, seems my OS is not supported... :-( SERVER 2008R2, SP1
Comment: maybe it only works with Server 2012.
Comment: hi, I see that, but both my OS (guest and host) are Server 2008R2, any   tools for this?
Comment: Ask the support of the tool if they can make it 2008R2 compatible.


Condition on two random variables

Question: I'm trying to set up the proper assumptions for a proof I'm working on:
Given that $P(A|e) = P(A)$ and $P(A|c,e) = P(A|e)$, can we prove that $P(A|c)=P(A)$?
I understand that A is independent of e and A is also independent of c given e, thus we can say A is independent of c.
I think this is relatively trivial to prove but I can't just give it out. Do I miss any assumptions to make it work?
Answer: The statement is true. You can use the fact the fact that you can obtain a marginal probability by taking the expectation of a conditional probability, i.e.
\begin{align*}
\mathbb{P}(A \mid C=c) &= \mathbb{E}[\mathbb{P}(A \mid C =c,E) \mid C=c] \\
&= \mathbb{E}[P(A) \mid C =c ] \\
&= P(A).
\end{align*}
This is the breakdown of each equality

The first equality holds by integrating the conditional probability. To see the intuition for why, suppose that $E$ is discrete
$$ \mathbb{P}(A \mid C =c) = \sum_e \mathbb{P}( A \mid C = c,E=e)\mathbb{P}(E = e \mid C = c) $$
The second equality substitutes the relationship in your problem.
The third equality uses the fact that $\mathbb{P}(A)$ is a constant.

Condition on two random variables


How to get element based on their innerHTML

Question: I have a for loop where I am iterating over array selected items. I want to get the element from select list where my value is equal with innerText of select list. How I can do that using jQuery ?
I have tried this, but got stuck
 var selectedClubs = $('#select2-3 option:selected');

    console.log(selectedClubs[0].innerText);

    for (let i = 0; i < selectedClubs.length; i++) {
        if (selectedClubs[i].innerText == value) {
        var c = $("#select2-3 option:contains(" + selectedClubs[i].innerText + "')");
        console.log(c.innerText);
      }
    }

Answer: You don't need the loop if you're using :contains:
var selectedClub = $(`#select2-3 option:selected:contains("${value}")`);

Alternatively you can use filter():
var selectedClubs = $('#select2-3 option:selected');
var selectedClub = $selectedClubs.filter((i, el) => el.innerText === value);

Comment: Yes, but I want to get element from `$('#select2-3')` list, and then remove it from selected items.
Comment: Well that's an important detail which you should have mentioned in the question. To do it just call `remove()` on the selector.


How do you generate service and other classes with T4 templates in EF Core?

Question: For years I have been using the Entity Framework in .Net applications using an EDMX file.  I was able to create T4 templates that could read the EDMX file and generate service classes and even controllers/views in MVC web apps.  I'm new to .Net Core (trying to use .Net 5.0), and I'm trying to figure out how I can do something similar with EF Core.  Ideally I'd have a T4 template in a separate Service project that could read the Data project and spit out Service classes.  Is this possible?
Answer: This is possible. You can import the Data project/assembly in your template with the assembly directive:
<#@ assembly name="$(SolutionDir)YourProject\bin\Debug\YourSolution.DataProject.dll" #>

The downside is, if you declared classes as internal in the data project, it's very tricky to expose them to the T4 file.
Answer: In EF Core, it is called Scaffolding or Reverse Engineering. It's most basic form is a simple command line call:
dotnet ef dbcontext scaffold "Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=Chinook" Microsoft.EntityFrameworkCore.SqlServer

EF Core 7 added support for Custom Reverse Engineering Templates once again using T4 (though not the EDMX file anymore). You essentially add the template package at the command line:
dotnet new install Microsoft.EntityFrameworkCore.Templates

then add the default templates to your project:
dotnet new ef-templates

This puts the default templates in CodeTemplates/EFCore where you can modify them as you choose. You can create multiple files by writing the GenerationEnvironment like so:
<#+
void OutputFileAbsolue(string absoluteFileName, bool clearCurrentOutput)
{
    File.WriteAllText(absoluteFileName, GenerationEnvironment.ToString());
    if (clearCurrentOutput) {
        GenerationEnvironment.Clear();
    }
}
#>


Find 95% confidence intervals from grouped dataset

Question: I have got the following dataset, which comes from a Normal Distribution, and that can be grouped by 3 months in total and the monthly observations are the ones that interest me:
Date          Height
01-01-1990    120
01-01-1990    187
01-01-1990    113
01-02-1990    154
01-02-1990    160
01-02-1990    167
01-03-1990    137
01-03-1990    190
01-03-1990    159

I need to find the 95% confidence intervals and I was wondering if I can use all the dataset in order to calculate the mean, standard deviation and size of the sample population OR if by doing so I will create biases in the output.
1)
The possible outcome, by considering all the observations singularly, would be:
Mean of Height = 154.1111
Standard deviation of Height = 26.78826
Size of Height = 9

Error of Height = 17.50134

Low 95% C.I. = 154.1111 - 17.50134 = 136.6098
High 95% C.I. = 154.1111 + 17.50134 = 171.6125

2)
Another possibility that I was thinking is to compute the Height mean for each month (3 values in total) and use them as input to calculate the C.I., as follows:
x = Height mean for 01-01-1990 = 140.0000
y = Height mean for 01-02-1990 = 160.3333
z = Height mean for 01-03-1990 = 162.0000

Mean of Height = mean of x, y, z = 154.1111
Standard deviation of Height = sd of x, y, z = 12.24896
Size of Height = 3

Error of Height = 13.86075

Low 95% C.I. = 154.1111 - 13.86075 = 140.2504
High 95% C.I. = 154.1111 + 13.86075 = 167.9719

Which of the two calculations is correct?
Or there exist any better way to calculate these C.I.?
Thanks

######    UPDATE

What if I have got a dataset with only multiple observations in the same month (and year)?
e.g.
Date          Height
01-01-1990    120
01-01-1990    187
01-01-1990    113
01-01-1990    154
01-01-1990    160
01-01-1990    167
01-01-1990    137
01-01-1990    190
01-01-1990    159

Assuming that I want to remain consistent, in the analysis, with the previous dataset (3 months), how can I calculate my C.I. now, assuming that I desire a sample size = 1 (because only one month exists in the dataset)?
If I apply the stratified version as 2) my standard deviation will be = NA and therefore I cannot calculate the C.I. as per the other dataset.
Thanks
Answer: The answer will depend on how you interpret values coming from the same month.
Independent Version
What if every value is a sample spaced 10 days? Then your month indications are relatively meaningless. Crossing the month barrier does not matter and you should lump all of the data together independent of months. You've already done that in your first equation.
Stratified Version
Month matters here in some way to cause values to cluster together or it's in some way a meaningful grouping variable. In this case you might use your second calculation. What you're doing is averaging the values within a month together in order to get a better estimate for a particular month. It will likely reduce your between month variability and make your estimate not about the mean value per se but about the mean value expected for any month.
Your Update
A CI based on your final example will mean a different thing. Without multiple months the CI can't generalize across months and can only say something about January but not months in general. I will be a CI for January or Januaries. You could try to extrapolate it to other months but it wouldn't be as strong inferentially as either of the other CIs calculated using data from multiple months.
As you keep developing examples and trying to test things remember that you need to think about interpretation and what things can mean as much as the calculations.
(BTW, there are other ways to deal with the averaging more explicitly in multi-level modelling which you might want to read up on for more advanced data problems like this)
Comment: Hi John and thanks. I am interested in the stratified version you mentioned but I need the overall (3 months) C.I.. Is it possible to know the steps to follow in order to calculate them?
Comment: see updated answer
Comment: you just deleted it!!! :)
Comment: thanks @John. I updated my question with an extra question and I have also this awaiting an answer http://stats.stackexchange.com/questions/247710/test-statistical-significance-with-confidence-intervals-example-needed . I will wait a couple of days before mark the best answers. Thanks
Comment: Hi @John. so how can I calculate the CI for my update question by remaining consistent with the Stratified version? you didn't specify this in your answer..
Comment: Magic? How could you expect to have the same generalizability when you only have data from one month? It's not really a matter of how you do the calculation but what the result means.


Pagination and displaying records in rows with Django templates

Question: I'm trying to get some pagination of GAE for python, but I cannot even get the tutorial (https://docs.djangoproject.com/en/dev/topics/pagination/) working. I'm seeing conflicting responses here about where to go. Here is the code I'm using:
class EditCompanyHandler(webapp.RequestHandler):

    # https://docs.djangoproject.com/en/dev/topics/pagination/

    def get(self):
        company_list = Company.all()
        paginator = Paginator(company_list, 25)

You are using the default Django version (0.96). The default Django version will change in an App Engine release in the near future. Please call use_library() to explicitly select a Django version. For more information see https://developers.google.com/appengine/docs/python/tools/libraries#Django

E 2012-05-25 06:31:36.341

<type 'exceptions.ImportError'>: cannot import name Paginator
Traceback (most recent call last):
  File "/base/data/home/apps/s~XX/1.359153909296057586/showcompanies.py", line 24, in <module>
    from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger

I 2012-05-25 06:31:36.343

This request caused a new process to be started for your application, and thus caused your application code to be loaded for the first time. This request may thus take longer and use more CPU than a typical request for your application.

I'm looking for a straightforward way to paginate.
If I update the djnago version to 1.1, I get the following:
<type 'exceptions.ImportError'>: cannot import name Paginator
Traceback (most recent call last):
  File "/base/data/home/apps/s~biomapit/1.359154059826228765/showcompanies.py", line 25, in <module>
    from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger

Comment: that `def get(self)...` is all the code you're using? No imports?
Comment: Try extending the `EditCompanyHandler` class with Paginator too, like this `class EditCompanyHandler(webapp.RequestHandler, Paginator):`
Answer: I know that , you should use django > 0.96 version if you want to import paginator.
And you add "from django.core.paginator import Paginator"  this module in showcompanies.py at the top.
I think that you can define the wrong code section this (from django.core.paginator import Paginator) module
I used django 1.2 version and paginator was running in my project.


What is the ordinary differential equation for double exponential summation?

Question: Given the following ordinary differential equation (ODE)
$$\frac{dy}{dx} = a y$$
its general solution is $y = c e^{a x}$, where $c$ is a constant. If we know
$$y = c_{1} e^{a_{1} x} + c_{2} e^{a_{2} x}$$
what is the corresponding ordinary differential equation for this solution?
Comment: If there is two linelely independent solution which is solution of second order  linear homogeneous differential equation.
Answer: General method:  From an expression with two parameters $c_1, c_2$, to find the second-order DE with that solution.
Step 1, solve for $c_1$
Step 2, differentiate to eliminate $c_1$
Step 3, solve for $c_2$
Step 4, differentiate to eliminate $c_2$.
The result is an equation involving $y, y', y''$.
Answer: If $y''(x) + ay'(x) + by(x) = 0$, then it is well known that the general solution is:
$$c_1 e^{\alpha x} + c_2 e^{\beta x}$$
where $\alpha, \beta$ are the roots of the quadratic $x^2+ax + b = 0$.
This result can be obtained by letting $y = e^{rx}$, finding $y'(x)$ and $y''(x)$, and then substituting those values into the differential equation.
So the original problem has been transformed into: given the roots of a quadratic equation, how can I find the original quadratic? This is easy if you just expand $(x + \alpha)(x + \beta) = 0$, or use Vieta's formulas.
Answer: $$y=c_{1}e^{a_{1}x}+c_{2}e^{a_{2}x}$$
The characteristic polynomial is:
$$(r-a_1)(r-a_2)=0$$
$$r^2-(a_1+a_2)r+a_1a_2=0$$
Then you deduce the differential equation:
$$y''-(a_1+a_2)y'+a_1a_2y=0$$


Fast Chord Identification

Question: How would someone go about identifying chords quickly and efficiently? While sight reading, I would often come up to some strange chord and try to decipher it. It normally takes me (what feels like) ages to figure out what chord it is. I have seen other people look at complex chords and instantly identify it.
What is the most efficient way to teach myself good chord recognition techniques?
Comment: In what context?  Are you talking about playing piano?  Guitar?  Reading an improv section of a big band chart?
Comment: @Andrew It was in reference to reading piano sheetmusic chords.
Comment: I've wondered the same thing. I mean, there are pages such as http://www.scales-chords.com where you can enter the notes and it will find chords for you. I was wondering whether there are any tools where you play a chord on the keyboard and on your screen you immediately see the list of matching chords...
Comment: I am struggling with identifying chords but I found something which helps me a little bit. E.g., if you consider triads, in root position tonical note is the most bottom note, in 1st inversion, in the middle, in 2nd inversion at top. So I don't really need to read all notes to read a chord. This can be extended to X7, X5 with notes in octave. If ou read intervals well, these may help you. If you cannot read intervals perhaps practising intervals should be your next step
Answer: Learn to recognize intervals between notes quickly. For example, notes that skip a line or space are a third apart. Notes that skip seven are an octave apart. When reading a chord quickly, read the root/lowest note and then the intervals above it and place them in the key. With experience you will be able to recognize common voicings by shape alone.
Answer: From what I see, you are a "working backwards" personality. You are like a painter who just mix your colors to get your desired shade and then just paint. After that, you ask yourself: "What did I do just now and how did I get that color?" You get the desired sound first and then try to decipher it. So, to achieve your end, learn the below and then work backwards to decipher the names. I will explain as we go along:
I am assuming that you already know the fundamental Major Chords for all the scales already, am I right?
Now, just think in terms of semitones (or half-steps in American Terms) and sharps and flats. With only 9 formulas, you can create at least 144 chords. There is absolutely nothing complicated with forming chords if you do it this way.
You already learnt that Chords are formed by pressing the Root note, next note 4 half steps up and then 3 half steps up. ie. C E and G in C chord. You can get every other major chords by using this R - 4 - 3 formula.
Now, to get the minor chord, just flatten the middle note (i.e. E flatted to E flat). So Cm chord = C Eb G. I do not want to use R - 3 - 4 because by doing so, you end up memorizing 12 formulas at least. I just want you to remember 9 for the time being)
For the suspended chord, just sharpen the middle note (i.e. E sharpened to F) Sharpen means raise the note 1 half step. So for Csus or Cs4 or Csus4 = C F G. You will get this is "McGyver's theme"
For the Diminished Fifth chord, just flatten the rightmost (fifth) note (i.e. G flatted to G flat). So Cm chord = C E Gb. It is most commonly used in m7-5 like in Cm7-5 which is C Eb Gb Bb. It will most commonly be used as Bm7-5 when playing songs in A minor key. Bm7-5 = B D F A. When playing Dm E7 Am progression, replace the Dm with Bm7-5 and you will get the an even more beautiful color to your song.
For the Augmented 5th chord, just sharpen the fifth, rightmost note (i.e. G sharpened to G#) So for CAug or C+5 or CAug5 = C E G+. You will find this is "Greatest Love of All" and "James Bond Theme"
Now for the 6th, 7th and Major 7th. Basically it means:
For 6th ADD a note 2 half steps from the 5th note. C6 will result in C E G A. You will find these sweet sounding chords prevalent in Hawaiian songs.
For 7th ADD a note 3 half steps from the 5th note. C7 will result in C E G Bb. These chords with "unfinished" feelings alway appear in pairs with root chords. I.e. G7 with C chord in C key; C7 with F Chord in F key; etc.
For Major7th ADD a note 4 half steps from the 5th note. CMaj7; CMaj;CM7 will result in C E G B. You will find these big broad sounding chords prevalent in Movie Themes to give you the big countryside feelings. You will also find it in songs with minor keys long root chord progressions like Feelings which goes Am - AmM7-Am7-Am6-Dm...
For Diminished Chords, this is a special exception. All the 4 notes are 3 half steps apart. ie. Cdim = C Eb Gb A. You will find these weird sounding chords prevalent in Hawaiian and Jazz songs as a passing chord ie. C C#dim Dm G7.... or C Ebdim Dm G7..... One of Bach's songs also uses this (I forgot the name) which is commonly used in Dracula Vampire movies. Try it out and see.
For all the above, you will see that all these adds to the color of sound and like an artist, these are your shades that will help you paint your masterpieces. How you use them will determine the quality and output of your music.
With the above, you can create 144 chords at least. Test it out as below
Major (try out all the 12 chords)
Minor (try out all the 12 chords)
7th (try out all the 12 chords)
m7th (try out all the 12 chords)
m7-5 (try out all the 12 chords)
dim (try out all the 12 chords)
6th (try out all the 12 chords)
7th (try out all the 12 chords)
Maj7  (try out all the 12 chords)
Dim (try out all the 12 chords)
Aug5 (try out all the 12 chords)
Sus4  (try out all the 12 chords)
Now, for the final crunch!: Assuming you pressed F Ab C# E and you like the sound to fit that section of your song, then just take the F as your root note and know that F Major is F A C. With reference to that, find out what happened to the other notes: ie. Ab is lower than A, therefore it should be a Minor; C# is higher than C, so it should be Augmented and E should be 4 halfsteps above C, so it should be Maj7. Putting it all together, it should be FmMaj7Aug5! Get it? Get this first. Then we deal with the 9th, 11ths and 13ths once you have grasped this.
If not, you can always write to me for further clarifications.
Enjoy!!!
Comment: I don't see how this answer is related to the question at all.
Answer: To Rein Henrichs very good advice, I would add:

When you look at a chord, try to visualize, play, hear and name its simple inversions (basically putting the lowest note one octave higher, or its highest note one octave lower, you can repeat the process several times until you come back to the original chord).
It will reinforce your sight-reading of intervals and shapes and you will be surprised how many chords in a piece are in fact related and close variations of each other.
Answer: Something that's always helped me, particularly when learning specific-but-related-sets of items (such as notes and then chords), is to simply make flashcards.
Writing things down (in general) seems to make a big difference in one's ability to recall that information. And, for me at least, this includes making flashcards.
Answer: Recognizing the intervals between notes is very vital in understanding and being able to identify chords, but there is a lot more to it then that especially since you may play the chord in any voicing where the notes of the chord are not in an order you recognize and you may also only be playing part of the chord. To be able to identify chords efficiently, you need to understand the building blocks of them and be able to arrange them so they make sense.
Breakdown of a Voicings
Let's look at this example below:

These three notes come together to make a chord. From bottom up, the notes are B♭, E, and C. Just by looking at all the intervals, you see B♭ up to E is an augmented fourth (A4), B♭ to C is a major second (M2) or major ninth (M9) depending on how you want to look at it and E to C is a minor sixth (m6).
Looking at B♭ as the root doesn't get you too far as you only have an augmented 4th and a major second which isn't a typically defined chord. However if you play with the order that you are looking at the notes, you'll see something very different. If we want to look at C as the root, then we have a major third (M3) from C to E and we have a minor seventh (m7) from C to B♭. Now if you look at typically built chords you see that we have everything we need to build a dominant 7th chord to get a C7 except the 5th which is omitted, but that is typical for the 5th.
This may not be a common voicing for a C7, but you should be able to recognize it. Switching the order of the notes will help a lot when you don't really see what is going on due to the voicing and after practicing, you'll be able to rearrange the notes in your head no problem.
Close Voicings
Another thing that helps recognize chords is understanding the basic close position chord shapes/voicings. Let's take a look at an example:

All three chords are a C major triad, but in different close position voicings. The first is a root position where you have the root, third, and fifth of the chord in that order. The next is a first inversion close position voicing where you have the  third, fifth, and root of the chord in that order. The last is a  second inversion close position voicing where you have the fifth, root, and third in that order. If you spot one of these close position triads, it's easy to identity the root and from there determining the chord will be much easier.
Answer: Was it question on guitar and jazz lead sheet chords sight-reading, i would advice (i've picked it up from one of Joe Pass DVD) - SIMPLIFY !!!:)
When You see something like this: G7b5b9 - You play simply essential notes of G7 (would be 7th, 3rd, root - in order of importance). In "playing in the Band" - this method will be not very sophisticated but will not result in any "crash notes"
C69 - You play B,E,C of C major
etc.
This way You need to recognize and be able to play major, minor, dominant, augumented and diminished chords.
Afterwhile when You build up Your chord vocabulary - you will slowly start to add those b5 and #9 notes.
I know this is different context, but maybe this will help :)
Answer: Here is an article about how to spell any chord you want.
http://bassoridiculoso.blogspot.com/2011/01/spelling-chords-fastly-by-knowing-your.html
However, you still need to know how chords are created, that is the step you are missing. There is no shortcut there, it is just like learning your times tables, there are very well known and VERY well documented recipes for every chord that there is out there. Here is just one -
http://lilypond.org/doc/v2.15/Documentation/notation/common-chord-modifiers
That list will not help you unless you know how those chords are made or what they are used for. There is no shortcut for that other than just looking at a lot of music and asking specific questions when encountering something you have not seen before.
Its like asking "how do I know what a word means in Spanish" but you don't speak Spanish.....You can look it up in a dictionary but there is a lot more to the language than just knowing that "gato" means "cat".
Answer: To answer your question: The most efficient way to learn how to more quickly identify chords is by composing.  When you compose in four voices, you are forcing yourself to analyze what you want to write, what comes next, and then going back and reviewing what you already wrote and making adjustments.  When you create a chord from scratch, you understand what it is made of and how it became to be a chord; now take this on a higher level (building a harmonic progression, building a section, building an entire piece).  This is most "efficient", I believe.
However, if you are not a composer, and you do not have a solid grasp on theory, then it might be better for you to simply just practice sight reading.
As others have said, you need to start looking at a triad as three notes, but as one "entity".  Similar to how when you look at a bus driving by, instead of seeing every single window with every single kid inside, you see the bus as one single entity.  When you look at a chord, all you need is to look at the bottom note (or top) and based off the actual physical shape of the chord be able to recognize what chord it is.  If there are accidentals, then take that into account (While always remembering what key you are in).
I know that sounds like a lot for the brain to process, but it comes with time and practice, just like everything else in life.
Edit: Obviously as others have pointed out, knowing your intervals completely is an absolute requirement.
Answer: Nothing beats knowing what all the common chords sound like in the key you are playing.  See link below.  I would play all these chords in various inversions, and also see what they sound like if you omit a note.
http://www.piano-keyboard-guide.com/key-of-c.html

Fast Chord Identification


How do I change the perspective of a Matplotlib pie chart to make it look tilted?

Question: I'm trying to change the perspective of a matplotlib pie chart.  I want it to look tilted like this (notice it looks like an oval):
instead of flat (looks more like a circle), like this:

Here is my code
<code>    # Build Pie Chart
poll = [6.8, 30.5, 62.7]
SnackType = ['Candy', 'Chips & Crackers', 'Healthy']
Colors = ['gold',"violet", 'green']
explode= [0, 0, .1]

plt.pie(poll, labels=SnackType, colors=Colors, explode=explode, shadow=True, startangle=150)
plt.title("% of favorite snacks")

plt.show()
</code>
Answer: My quick solution was to add
<code>plt.axis("auto")
</code>
However, it'd still like to be able to control the tilt.  Preferably, I'd like to make it look more tilted.
Comment: Well, that doesn't exactly make it look *tilted*, but rather *squeezed*. However, if that is the kind of adaption you want to make, you can just set the limits, `plt.ylim(-2,2)`, change the numbers to whatever you like.


Script adding domain groups to local groups fails 50% of the time

Question: We have a script that automatically adds a freshly imaged computer to the domain. The functionality of joining the domain is always successful. However, when the script attempts to add the domain groups, it fails 50% of the time. Below is the script. I didn't write it, I just have to figure out why it is failing. I replaced company identifying information. Any ideas?
<code>    On Error Resume Next

Const HKEY_LOCAL_MACHINE = &H80000002
Dim WShell, oReg
Dim intReturn
Dim strComputer, strKeyPath, strPortConf, strValue, strTempDir, strUser, strChassis, strPath
Dim strDomain, strDomainUser, strDomainPW, strDomainOU
Dim booDesktop, booLaptop
Dim strPCName, objWMIService

strDomain = "ourDomain.com"
strDomainUser = "serviceaccountname"
strDomainPW = "serviceaccountpassword"
strDomainOU = "OU=Production,OU=General Workstations,DC=SOMETHING,DC=GOES,DC=HERE,DC=COM"

booLaptop = False
booDesktop = False

Set WShell = Wscript.CreateObject("Wscript.Shell")
Set fs = CreateObject("Scripting.FileSystemObject")

strComputer = "."

strUser = ""
strPath = ""
strTempDir = ""

strPath = GetPath(wscript.scriptfullname)
strTempDir = "C:\Windows\IT\scripts"

If right(strPath,1) <> "\" Then
    strPath = strPath + "\"
End if

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
'------------
' Start code
'------------

Set oReg   = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colChassis = objWMIService.ExecQuery _
("Select * from Win32_SystemEnclosure",,16)
For Each objChassis in colChassis
  For Each objItem in objChassis.ChassisTypes
    Select Case objItem
    Case 1 booDesktop = True 'Maybe Virtual Machine
    Case 2 strChassis = "??"
    Case 3 booDesktop = True
    Case 4 booDesktop = True
    Case 5 strChassis = "Pizza Box"
    Case 6 booDesktop = True
    Case 7 booDesktop = True
    Case 8 booLaptop = True 'Portable
    Case 9 booLaptop = True 'Laptop
    Case 10 booLaptop = True 'Notebook
    Case 11 strChassis = "Hand Held"
    Case 12 strChassis = "Docking Station"
    Case 13 strChassis = "All in One"
    Case 14 strChassis = "Sub Notebook"
    Case 15 booDesktop = True 'Space-Saving, SFF - Our standard desktop
    Case 16 strChassis = "Lunch Box"
    Case 17 strChassis = "Main System Chassis"
    Case 18 strChassis = "Lunch Box"
    Case 19 strChassis = "SubChassis"
    Case 20 strChassis = "Bus Expansion Chassis"
    Case 21 strChassis = "Peripheral Chassis"
    Case 22 strChassis = "Storage Chassis"
    Case 23 strChassis = "Rack Mount Unit"
    Case 24 strChassis = "Sealed-Case PC"
    End Select
  Next
Next

'Add the machine into the domain if it is a Desktop or a Laptop
If booLaptop Then strDomainOU = "OU=Back Office,OU=Laptops," + strDomainOU
If booDesktop Then strDomainOU = "OU=Back Office,OU=Desktops," + strDomainOU

Set domFile = fs.CreateTextFile( strTempDir + "\dominfo.xml" )

domFile.WriteLine "<?xml version=""1.0"" encoding=""UTF-8""?>"
domFile.WriteLine "<configuration>"
domFile.WriteLine " <DOMAIN>" + strDomain + "</DOMAIN>"
domFile.WriteLine " <USERID>" + strDomainUser + "</USERID>"
domFile.WriteLine " <PASSWORD>" + strDomainPW + "</PASSWORD>"
domFile.WriteLine " <OUTOJOIN>" + strDomainOU + "</OUTOJOIN>"
domFile.WriteLine "</configuration>"
domFile.WriteLine()
domFile.Close()

'Join the Workstation to the Domain
intReturn = WShell.Run(strTempDir + "\jdom /F " + strTempDir + "\dominfo.xml",0, true)

strKeyPath = "SOFTWARE\Novell\Login\TAB SETTINGS\NT Credentials"
oReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, "Sync NDS Username", "1"

'Delay the remainder of the script for 30000 milliseconds (30 seconds).
WScript.Sleep(30000)

'Add the Back Office Admins group to the local administrators group
WShell.Run strTempDir + "\jdom /A ""Back Office - Local Admins"" ""Group"" ",0, true

'Add the Back Office Power Users group to the local Power Users group
WShell.Run strTempDir + "\jdom /P ""Back Office - Power Users"" ""Group"" ",0, true

'*********************
'* Main Join Script  *
'*      (END)        *
'* ----------------- *

Function GetPath(ByVal gpFileName)
on error resume next
    Dim gpSlash, gpLast

    If IsEmpty(gpFileName) Then
        GetPath = ""
    Else
        gpSlash = InStr(gpFileName, "\")
        gpLast = gpSlash
        Do While gpSlash <> 0
            gpSlash = InStr(gpSlash + 1, gpFileName, "\")
            If gpSlash > 0 Then
                gpLast = gpSlash
            End If
        Loop
        if gpLast = InStr(gpFileName, "\") then gpLast = gpLast + 1
        GetPath = Left(gpFileName, gpLast - 1)
    End If
on error goto 0
End Function
</code>
Comment: So you want to add some groups to the local administrators group? Why don't you use a GPO for that? You can find it in: Computer Configuration -> Policies -> Windows Settings -> Security Settings -> Restricted Groups.
Comment: It looks like the actual work is done by the unfortunately named "jdom" script, and that's probably where the trouble lies, not in this code.
Comment: Normally you need to reboot in order to join a domain, so I'm amazed this works even 50% of the time.
Comment: @ZEDA-NL I am going through group policy to replace this script when we implement Windows 7 throughout the company. It is in testing right now and has 100% success but the management team is not confident in allowing me to use it because 10 years ago they did the same thing (incorrectly) and locked everyone out of the entire domain because they accidentally removed all admins instead of just adding them.
Comment: @Harry Johnston Amazingly, it used to work 100% of the time. I don't understand why that changed.
Comment: @KevinShoaf The GPO can remove members form the group indeed, but I think that's a good thing. When you find that too risky though, you can also add group members (without deleting membership) with Group Policy Preferences. Please take a look at Computer Configuration -> Preferences -> Control Panel Settings -> Local Users and Groups.
Answer: it's probably that line that says wscript.sleep(30000). I'd bet the times it fails is because the script resumes execution before the computer is added to the domain. an obvious patch / test would be to up the wait time to a minute or so, but it's less than optimal. maybe something like what zeda proposes in the comments is a better solution. Still, upping the wait time should work as a patch
Comment: Actually, the wait time was added when the issue started. We've upped it to 15 minutes and it still occured.
Answer: We took out the group additions and went with group policies. We found the issues with the groups being added via script to be latency in the domain controllers. Until it can be resolved, there was no solution other than group policies, which it should have been to begin with.


What is this Called?

Question: There is a stand to keep music sheets while playing the piano. It is also there for electronic keyboards, but it is made of plastic. What is this called?
Comment: The... music stand? Did you try a web search for "music stand" or "keyboard music stand" yet?
Comment: I searched for music stand, but I only got the notation stand, not the one for keyboards
Answer: It is often called the "music stand" but the correct term is "music rack".
It is sometimes also called the "music rest" or "music desk."
On portable keyboards, the "stand" is usally the part between the instrument and the floor, not the part which holds the sheet music.

What is this Called?


Where is the source code for the jar program?

Question: Where is the source code of the Jar program ?
Specifically, looking for a way to implement the jar uvf feature to update or append to an existing archive. Looking at this bug report, there seems to be no hope of doing this from the regular Java JAR/ZIP API.
Answer: Unrelated to the question, but perhaps you should also look at Commons Compress to check if provides the feature(s) you want.
Answer: You can download the sources of OpenJDK on the OpenJDK website. From there you will be able to browse the sources of the complete JDK (including the jar application).
Answer: Check here: OpenJDK: Core Libraries Group, look for "JAR" on that page. There is list of packages and directories related to this tool. You can download sources from Mercurial or as a source bundle on same site.
Answer: A recent source file at
http://hg.openjdk.java.net/jdk7/tl/jdk/file/6bc450d87125/src/share/classes/sun/tools/jar


How do I print logic field on page--node.html.twig?

Question: This code printing 0 or 1
<code>{{ node.field_some_logic.value }}
</code>
I want he print NO or YES.
Somobody know, how to do this?
Answer: With simple logic, you could try using
<code>{{ node.field_some_logic.value ? 'YES' : 'NO' }}
</code>
See ternary operator on https://twig.sensiolabs.org/doc/2.x/templates.html


Drupal Webform Radio button slider?

Question: I have created a webform in Drupal. It has a pagebreak after every question.
What I want to achieve is the following: When someone clicks on a radio button, the next question should slide up without the user clicking the next page button.
I have tried with theming, but I am not very experienced with Drupal, PHP, or jQuery.
This is the link to my webform.
Answer: You can add to your page something like

This is better done by adding a .js file via drupal_add_js(). Be aware that, since you are forcing your user to submit a form, you should provide a way to get back and resubmit a different choice.
Comment: hi thanks for ur help i have actually done that but it keeps going backwords after one question also i have radio buttons with text field which a person has to fill in the text and hen press next page on some of the questions
Comment: I edited the answer to solve your "going backwards" problem. I didn't notice that you actually have two submit buttons in your forms after the first. To address your other question, you need to have a different class attached to your radio buttons that you need to perform automated next behavior, and put that in place of the `$('.form-radio')` selector.

Drupal Webform Radio button slider?


Minimal sufficiency of smallest order statistic

Question: I am attempting to show that the smallest order statistic T is minimally sufficient for the mean of a distribution when the variance is known. In particular, iid random variables $X_1,\ldots,X_n$ have a pdf that is given by $f(x;θ)=(1/\sigma)e^{(-(x-\theta)/\sigma)}$.
I know that the two necessary conditions for minimal sufficiency are: i.) sufficiency; and ii.) that the statistic cannot be further reduced to another sufficient statistic. After having shown that T is sufficient, I failed to prove the second condition.
Since the statistic is clearly minimally sufficient (I wouldn't have been told to prove it, otherwise), it must be true that $T$ cannot be reduced to another arbitrarily defined, sufficient statistic $T'$. In other words, $T$ must be a defined function of $T'$. However, if $T' = \sum_i X_i$, for example, i.e. $T'$ is sufficient, then $T$ would only be a defined function of $T'$ if $n=1$. Hence, the second condition of minimal sufficiency would not hold. I must be missing something...
Comment: Given that the dimension of your proposed minimally sufficient statistic is (fill in the blank) ___, can it be REDUCED to another sufficient statistic, i.e., to one with smaller dimension?
Comment: @jbowman: I don't think that is true! (while it might be a good initial guess). An example: $X \sim \cal{U}(-\theta, \theta)$. Then clearly $X$ is sufficient for $\theta$, but so is $\mid X \mid$, so $X$ is not *minimally* sufficient. You could construct similar examples based on the $\cal{N}(0,\sigma^2)$ family.
Comment: @kjetilbhalvorsen So, you're saying that $|X|$ is a reduction of $X$ because there are two $X$'s for every $|X|$?
Comment: Yes, I say so. So to prove minimal sufficiency more is needed than just pointing out the statistic is one-dim!
Comment: By that logic, wouldn't $X^2$ also be a reduction? I don't think it is but could be wrong.
Comment: @kjetilbhalvorsen - you are quite right, and I should have remembered that there's more to "minimal" than "dimension".   Just lazy thinking on my part, I suppose.
Comment: @DavidS: Yes, $X^2$ would also be a reduction. After all, there is a one-one relation between $X^2 $ and $\mid X \mid $.
Comment: Clearly I misunderstood the definition of reduction. By your logic, it then follow that every one-dimensional, sufficient statistic is minimally sufficient, correct?
Comment: That's correct.  It's all about the dimensionality of the sufficient statistic; once you've found a minimal sufficient statistic, any 1-1 transform of it is also a minimal sufficient statistic.
Answer: Some hints: The question about sufficiency is asked and answered before, for instance at UMVUE of two-parameter exponential family distribution   For minimal sufficiency, use the same method as at Finding a minimal sufficient statistic and proving that it is incomplete,  that is, look at the ratio of the likelihood functions for two different samples, and show it is independent of the parameter iff the two samples have the same value of the statistic $T$.
The following post explains why this works:  Understanding a characterization of minimal sufficient statistics


Web-scraping a link from web-page

Question: New to web-scraping here. I basically want to extract a link from a web page into my jupyter notebook as shown in the image below :

Following is the code that I tried out:
from flask import Flask, render_template, request, jsonify
from flask_cors import CORS, cross_origin
import requests
from bs4 import BeautifulSoup as bs
from urllib.request import urlopen as uReq

flipkart_url = "https://www.flipkart.com/search?q=" + 'acer-aspire-7-core-i5'
uClient = uReq(flipkart_url)
flipkartPage = uClient.read()
flipkart_html = bs(flipkartPage, "html.parser")

#Since I am only interested in the class "_1AtVbE col-12-12"
bigboxes = flipkart_html.findAll("div", {"class": "_1AtVbE col-12-12"})

Now here's the thing, I don't exactly understand what bigboxes is storing. The type of bigboxes is bs4.element.ResultSet, the length is 16.
Now if I run:
box = bigboxes[0]
productlink = "https://www.flipkart.com" + box.div.div.div.a['href']

I am getting an error. However when I run:
box = bigboxes[2]
productlink = "https://www.flipkart.com" + box.div.div.div.a['href']

I am successfully able to extract the link. Can someone please explain to me why the third element was able to read the link? I have a basic knowledge of HTML (at least I thought so) and I don't understand the layers to it. What exactly is bigboxes storing? Clearly, the HTML script shows no layers as such.
Comment: That points to the "Filters" text element off to the left and there's no link in it. If there's some data you want to get, you might want to mention that so I can write a more useful answer than this.
Comment: @ggorlen following is the website I am targetting: https://www.flipkart.com/search?q=acer-aspire-7-core-i5
I want to know how can I enter inside a product's details to scrap the reviews. I want to automate this process for 1000s of products.
Answer: Your class filter is not very specific.
The first and second elements are pointing to html nodes which do not contain the link. Thus you are getting error.
A more specific class to check could be: _13oc-S
bigboxes = flipkart_html.findAll("div", {"class": "_13oc-S"})

Web-scraping a link from web-page


tcpdump cannot capture none-broadcast/multicast packets from bridge interface in OpenWRT

Question: (Originally, I posted it on StackOverflow. I move it to networkengineering and then here.)
I have TP-LINK WR841N v9 router and install OpenWRT firmware CHAOS CALMER (15.05.1, r48532).
I have /etc/config/network content:

config interface 'lan'
    option force_link '1'
    option type 'bridge'
    option proto 'static'
    option ipaddr '10.15.252.3'
    option netmask '255.255.254.0'
    option gateway '10.15.252.1'
    option ifname 'eth0 eth1'

Here is the output of ip link ls:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br-lan state UP mode DEFAULT group default qlen 1000
    link/ether c4:6e:1f:b6:8e:24 brd ff:ff:ff:ff:ff:ff
3: eth1: <NO-CARRIER,BROADCAST,MULTICAST,PROMISC,UP> mtu 1500 qdisc fq_codel master br-lan state DOWN mode DEFAULT group default qlen 1000
    link/ether c4:6e:1f:b6:8e:25 brd ff:ff:ff:ff:ff:ff
4: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether c4:6e:1f:b6:8e:24 brd ff:ff:ff:ff:ff:ff
5: br-lan: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default
    link/ether c4:6e:1f:b6:8e:24 brd ff:ff:ff:ff:ff:ff

I have two computers cable-connecting to 2 of the 4 LAN ports. Let's say computer A and B.

A keeps pinging B and it works well.
On the router, I use tcpdump to captuer traffic from bridge br-lan: tcpdump -i br-lan -n 'arp or icmp'.

I did see arp traffic, but there are no ICMP traffic.
I tried to setup iptables rules to block traffic to B in both INPUT and output chain, and it's not working.
Here is the output of command brctl and ip:

bridge name bridge id       STP enabled interfaces
br-lan      7fff.c46e1fb68e24   no      eth0
                            eth1

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    RX: bytes  packets  errors  dropped overrun mcast
    63107      580      0       0       0       0
    TX: bytes  packets  errors  dropped carrier collsns
    63107      580      0       0       0       0
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br-lan state UP mode DEFAULT group default qlen 1000
    link/ether c4:6e:1f:b6:8e:24 brd ff:ff:ff:ff:ff:ff
    RX: bytes  packets  errors  dropped overrun mcast
    64256004   445450   0       6       0       0
    TX: bytes  packets  errors  dropped carrier collsns
    8775980    43685    0       0       0       0
3: eth1: <NO-CARRIER,BROADCAST,MULTICAST,PROMISC,UP> mtu 1500 qdisc fq_codel master br-lan state DOWN mode DEFAULT group default qlen 1000
    link/ether c4:6e:1f:b6:8e:25 brd ff:ff:ff:ff:ff:ff
    RX: bytes  packets  errors  dropped overrun mcast
    0          0        0       0       0       0
    TX: bytes  packets  errors  dropped carrier collsns
    0          0        0       0       0       0
4: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether c4:6e:1f:b6:8e:24 brd ff:ff:ff:ff:ff:ff
    RX: bytes  packets  errors  dropped overrun mcast
    0          0        0       0       0       0
    TX: bytes  packets  errors  dropped carrier collsns
    0          0        0       0       0       0
5: br-lan: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default
    link/ether c4:6e:1f:b6:8e:24 brd ff:ff:ff:ff:ff:ff
    RX: bytes  packets  errors  dropped overrun mcast
    57777761   444757   0       60579   0       0
    TX: bytes  packets  errors  dropped carrier collsns
    8871188    44499    0       0       0       0

There are surely lots of TX and RX packets on interfaces.
So, my questions are:
1. How to use tcpdump to caputer traffic flow through bridge br-lan? (Bridge works on layer-2 and it is suppose to work, isn't it?)
2. If I want to mirror traffic in/out of computer B to another port(e.g wan port), what should I do? (I tried to use this port-mirroring tool, but it is not working.)
(I want to try ebtables, but I couldn't get it installed on the router due to insufficient space. Also, I couldn't find tool bridge to check the forward DB on the bridge.)
I found another relevant thread: Tcpdump/Iptables on bridge interface without assigned IP address and tcpdump on bridge interface (virbr) does not receive any packets destined for one of its addresses, but it's not working.
Comment: Bridges learn which MAC addresses are connected to which interfaces, and they only send traffic to the interface where the MAC address is connected. On the other hand, ARP is broadcast, meaning that it is sent to every interface on a bridge.
Comment: @RonMaupin TCPDUMP cannot get packets before it sends out to the right "LAN" ports of the router?  TCPDUMP picks the packets right after the interface fetches it.
Comment: Don't confuse bridges and routers. Bridges operate at layer-2, and routers operate at layer-3. A WAN interface is a layer-3 interface, but a switch interface is a layer-2 interface. You don't mirror layer-2 traffic to a layer-3 interface. A layer-3 device, e.g. router, strips off the layer-2 fraem to get to the layer-3 packet, and it creates a new frame for the new interface.
Comment: @RonMaupin Thanks, got that. Mirroring to WAN interface is not correct. Still, how can I use tcpdump to capture unicast packets **flow through** the bridge? From the output of  `ip link` command, `br-lan` is already in **PROMISC** mode. I starts thinking the TCPDUMP is buggy.
Comment: @RonMaupin Also, there are 4 LAN **physical** port on the router. But, the `ifconfig` command-alike only shows 2 physical ports **eth1** and **eth0**, and they are attached to `br-lan` bridge. I am not an hardware guy, but it really confused me.
Comment: With bridges, you capture frames (layer-2), not packets (layer-3). Are you certain that the frames are passing through the bridge interface? If the source and destination MAC addresses are outside the same interface, the bridge interface will never see the frames. You should capture the frames that originate outside of one ethernet interface and are destined out the other ethernet interface.
Answer: I have reconfigured the router to do the followings:
1. Assign both eth0 and eth1 to bridge br-lan;
2. cable-connect computer B to eth1 port (wan port);
3. In port-mirroring config file, forward traffic from eth1 to IP of A.
Now, I can listen all the traffics in/out of B. And of course, tcpdump can also capture traffic flow through br-lan.