Openlayer - filter layer by another one (intersect?)

Question: I have two point on a map, one red, one blue.
On this map is also a grey area.
Of my two point, I would like to display only the blue one, which inside the area.
To sum things up, I would like to filter the geometry of a layer (point) by the geometry of another layer (area)
what is the proper way to do this, with intersect?
Here is a working example :

//Point layer Json
var GeoJSON = {
    "type": "FeatureCollection",
    "totalFeatures": 2,
    "features": [{
            "type": "Feature",
            "id": "1",
            "geometry": {
                "type": "Point",
                "coordinates": [
                    294958.91163697134,
                    6246510.814409403
                ]
            },
            "geometry_name": "GEOMETRY",
            "properties": {
                "ID": 1,
                "color": "blue"
            }
        },
        {
            "type": "Feature",
            "id": "2",
            "geometry": {
                "type": "Point",
                "coordinates": [
                    255020.37350418963,
                    6246791.991868377
                ]
            },
            "geometry_name": "GEOMETRY",
            "properties": {
                "ID": 2,
                "color": "red"
            }
        }
    ],
    "crs": {
        "type": "name",
        "properties": {
            "name": "urn:ogc:def:crs:EPSG::3857"
        }
    }
};

//Base layer
var osm = new ol.layer.Tile({
    source: new ol.source.OSM()
});

//Areal layer
let areal = new ol.layer.Vector({
    source: new ol.source.Vector({
        url: "https://wxs.ign.fr/administratif/geoportail/wfs?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&srsName=EPSG:3857&typenames=ADMINEXPRESS-COG-CARTO.LATEST:departement&outputformat=application/json&CQL_FILTER=insee_dep=77",
        format: new ol.format.GeoJSON()
    }),
    style: new ol.style.Style({
        stroke: new ol.style.Stroke({
            color: 'grey',
            width: 2
        }),
        fill: new ol.style.Fill({
            color: 'darkgrey'
        })
    })
});

//Point layer
var point =
    new ol.layer.Vector({
        source: new ol.source.Vector({
            features: (new ol.format.GeoJSON()).readFeatures(GeoJSON, {
                featureProjection: 'EPSG:3857'
            })
        }),
        style: (feature) => {
            return new ol.style.Style({
                image: new ol.style.Circle({
                    radius: 8,
                    fill: new ol.style.Fill({
                        color: feature.get("color")
                    }),
                    stroke: new ol.style.Stroke({
                        color: 'white',
                        width: 2
                    })
                })
            })
        }
    })

// The map
var map = new ol.Map({
    target: 'map',
    view: new ol.View({
        zoom: 8,
        center: [255000, 6266791]
    }),
    layers: [
        osm,
        areal,
        point
    ]
});

    <link rel="stylesheet" href="https://openlayers.org/en/latest/css/ol.css">

Answer: If you have a single polygon or multipolygon feature you could use the intersectsCoordinate method to test if the geometry contains the point coordinate when styling the point.

//Point layer Json
var GeoJSON = {
    "type": "FeatureCollection",
    "totalFeatures": 2,
    "features": [{
            "type": "Feature",
            "id": "1",
            "geometry": {
                "type": "Point",
                "coordinates": [
                    294958.91163697134,
                    6246510.814409403
                ]
            },
            "geometry_name": "GEOMETRY",
            "properties": {
                "ID": 1,
                "color": "blue"
            }
        },
        {
            "type": "Feature",
            "id": "2",
            "geometry": {
                "type": "Point",
                "coordinates": [
                    255020.37350418963,
                    6246791.991868377
                ]
            },
            "geometry_name": "GEOMETRY",
            "properties": {
                "ID": 2,
                "color": "red"
            }
        }
    ],
    "crs": {
        "type": "name",
        "properties": {
            "name": "urn:ogc:def:crs:EPSG::3857"
        }
    }
};

//Base layer
var osm = new ol.layer.Tile({
    source: new ol.source.OSM()
});

//Areal layer
let areal = new ol.layer.Vector({
    source: new ol.source.Vector({
        url: "https://wxs.ign.fr/administratif/geoportail/wfs?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&srsName=EPSG:3857&typenames=ADMINEXPRESS-COG-CARTO.LATEST:departement&outputformat=application/json&CQL_FILTER=insee_dep=77",
        format: new ol.format.GeoJSON()
    }),
    style: new ol.style.Style({
        stroke: new ol.style.Stroke({
            color: 'grey',
            width: 2
        }),
        fill: new ol.style.Fill({
            color: 'darkgrey'
        })
    })
});

let areaGeometry;

//Point layer
var point =
    new ol.layer.Vector({
        source: new ol.source.Vector({
            features: (new ol.format.GeoJSON()).readFeatures(GeoJSON, {
                featureProjection: 'EPSG:3857'
            })
        }),
        style: (feature) => {
          if (areaGeometry &&
              areaGeometry.intersectsCoordinate(
                  feature.getGeometry().getCoordinates()
              )
          ) {
            return new ol.style.Style({
                image: new ol.style.Circle({
                    radius: 8,
                    fill: new ol.style.Fill({
                        color: feature.get("color")
                    }),
                    stroke: new ol.style.Stroke({
                        color: 'white',
                        width: 2
                    })
                })
            })
          }
        }
    })

    areal.getSource().on('featuresloadend', function(){
        areaGeometry = areal.getSource().getFeatures()[0].getGeometry();
        point.changed();
    });

// The map
var map = new ol.Map({
    target: 'map',
    view: new ol.View({
        zoom: 8,
        center: [255000, 6266791]
    }),
    layers: [
        osm,
        areal,
        point
    ]
});

    <link rel="stylesheet" href="https://openlayers.org/en/latest/css/ol.css">


Unable to save text config files in IIS7 on Windows 2008

Question: My experience has been (on older setups) that I can remote into a system, edit a text file (*.config, *.aspx, *.ashx, etc...) in Notepad and save it.
I am unable to do this on the new box.  I don't know whether it has to do with IIS7 or Windows 2008 or something entirely different.
How can I set things up to allow quick Notepad edits of files being served by IIS7?
(AFAIK, I have full permissions on the file.  It is not marked read-only.)
Using Notepad, when I try to save it says "Cannot create the C:\inetpub\wwwroot\myfile.config file.  Make sure that the path and name are correct."
Comment: What kind of error message are you seeing?
Answer: It's UAC kicking you down.  Non-elevated processes basically have no rights in the INETPub directory structure.
What we do on all our W2K8 boxes is install a folder on the desktop with 3 shortcuts in it - CMD (elevated), Explorer (Elevated) and ProcExplorer (Elevated).  Each admin then right clicks them and selects "Pin to Start Menu".
UAC is quite painful with access issues - the error messages are standard "Access Denied" errors rather than "UAC is preventing access" errors, which is confusing as all get out.  I don't know how many times I've logged on to a "broken" box where the admin has granted full rights to Everyone in an attempt to fix this w/o knowing it's UAC overriding the ACLs.
Notes: To get explorer to work as elevated, you need to edit the folder options and check "Launch folder windows in a separate process".  Or run this REG file:
<code>Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]
"DisableThumbnailCache"=dword:00000001
"DontPrettyPath"=dword:00000001
"EnableBalloonTips"=dword:00000001
"FriendlyTree"=dword:00000001
"Hidden"=dword:00000001
"HideFileExt"=dword:00000000
"SeparateProcess"=dword:00000001
"ShowAttribCol"=dword:00000001
"ShowSuperHidden"=dword:00000001
"SuperHidden"=dword:00000001
</code>
Answer: Try running Notepad as an elevated program ("Run as administrator").  This also applies to Vista and Win 7.


View to display nodes with a random term

Question: I have got a view that selects some images. Each image is tagged with a taxonomy term. I would like the view to display only images tagged with a common term that is chosen randomly at every use.
The view is used as a block.
Example:
term: a, images: img1, img2, img3;
term: b, images: img4;
term: c, images: img5, img6;
One user sees a sequence of img1, img2 and img3. Another one sees img4 only. A next one sees img4 too.
How should I do it?
Answer: I would set up an argument (D6) / contextual filter (D7) to filter the view results based upon a taxonomy term, and then for the argument/filter value, select the PHP option for providing the default, and in there randomly return one of your taxonomy terms.  Without actually testing the code, I would imagine using array_rand() would make this rather trivial, eg:
<code>$terms=array('foo','bar','baz');
return $terms[array_rand($terms)];
</code>
Comment: Thank you very much!
I added a condition to select only used terms. My final code is:
`
    $tids = array();
    $terms = taxonomy_get_tree(4);
    foreach ($terms as $term) {
     $tids[] = $term->tid;
    }
    $result = db_query('SELECT DISTINCT tid FROM taxonomy_index WHERE tid IN (:tids)', array(':tids' => $tids));
    $tids = $result->fetchCol();
    return $tids[array_rand($tids)];
`


How to parse out links and img src references from body copy?

Question: I need to modify links and img references in the body of nodes and comments. MPD already gave me good advice regarding using a script.
Is there an easy way in Drupal or PHP to parse out all the links in the body copy?
Answer: It's never easy to do something like this because parsing HTML is a bit hit-and-miss, depending on how well formatted the input is.
I've always found the best way to do it is to load the HTML into a DOMDocument object, loop through and change whatever element attributes/values I need to, then use the DOMDocument to give me the new output.
This is a very rough example but hopefully it'll give you the idea:
$html = '

Blah blah blah

Link Text

';

$doc = new DOMDocument;

// This is a reasonable use of the @ operator as malformed HTML will produce
// a lot of warnings. Please don't shoot me ;)
@$doc->loadHTML($html);

// Get the links.
$links = $doc->getElementsByTagName('a');
foreach ($links as $link) {
  // Change the value of an attribute based on the current value.
  if ($link->getAttribute('href') == '/some-path') {
    $link->setAttribute('href', '/some-other-path');
  }
}

// Get the images.
$images = $doc->getElementsByTagName('img');
foreach ($images as $image) {
  // Change the value of an attribute based on the current value.
  if ($image->getAttribute('src') == '/some-path.jpg') {
    $image->setAttribute('src', '/some-other-path.jpg');
  }
}

// Get the new HTML
$new_html = $doc->saveHTML();

// Strip out the tags that loadHTML() introduces to get the clean HTML.
$patterns = array("/^\<\!DOCTYPE.*?/si", "!$!si");
$body_text = preg_replace($patterns, '', $new_html);

// Update the node body.
$node->body[$node->language][0]['value'] = $body_text;

EDIT
I knew I'd seen a good question about this on SO; have a look at How to parse and process HTML with PHP? for a good discussion on the subject in general.
Comment: This answer was quite helpful though when using different language based site. In my case 'Malayalam' the end result was was not UTF-8 based but Latin based. I searched a little more to solve this and replaced some lines as: `$dom->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'));` and `$node->body[$node->language][0]['value'] = html_entity_decode($body_text);`. My purpose was to convert inner images to base64 code. Thank You @clive
Answer: As I answered in your other question, filters are the proper solution since they won't actually alter the data, but the output. This means that should you want to change it differently (or fix a conversion bug), data is still there.
Just check the documentation on hook_filter_info() and have a good time parsing HTML with PHP.
Answer: Maybe you are not looking at the good way.
Have you try to make a replace in the database?
update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, 'find this string', 'replace found string with this string');

update client_table set company_name = replace(company_name, 'Old Company', 'New Company')

I have use use them for some migrations. It's no easy—you must check and map all the replace—but it works.


Existe apenas display inline e block por padrão nos elementos ou outros?

Question: Eu vejo bastante pela Internet falarem tanto de apenas display: inline e display: block, mas nas tabelas, por exemplo, no elemento
 a exibição dele é display: table, eu gostaria de saber se:

Existem outras exibições padrões nos elementos além dos mencionados?
Porque apenas inline e block são relevantes?
Comment: Does this answer your question? [Como funciona a propriedade display?](https://pt.stackoverflow.com/questions/190005/como-funciona-a-propriedade-display)
Answer: Na verdade, basicamente os elementos padrão do HTML5 vem por default com os tipos:

block (h1, h2, h3..., p, div, header, section, article, etc...)
inline (span, strong, em, image, etc)
inline-block (input, select...)
list-item (li, ...)
table, table-row, table-cell, etc... (aplicados por default nos elementos de tabela)
none (head, title, meta)

Na lista acima podem existir mais alguns talvez que eu esteja esquecendo... mas acho que não.
A questão não é ser relevante... mas sim, são os que existem desde os primórdios do css e por isso são os essenciais..
Os valores mais recentes da propriedade display (flex, grid e os outros) não vem por padrão do browser em nenhum elemento html nativo. Mas você os pode usar para satisfazer sua necessidade.
Comment: Obrigado, amigo!
Answer: Existem muitos mais, cada um suprindo uma necessidade diferente. Por exemplo:
Content, grid, flex, flex-inline, entre outros.
São considerados mais relevantes por terem mais tempo de uso (mais antigos se preferir). Hoje em dia eu procuro fazer quase tudo com flex, pela adaptação a Grids.
Você pode acompanhar todos nesse site: w3schools/css-display
Comment: Por exemplo, o elemento `` ele tem a exibição padrão para `block`, mas esses que você citou quais utilizam por padrão essas exibições?


Style block based on configuration setting

Question: I'm writing a module for Drupal and a bespoke theme. The blocks of the modules either float to the left or the right of the region their in. Currently I do that by hard coding specific css styles, e.g.
#block-myModuleName-myBlockName {float:left; background: red;}
#block-myModuleName-anotherBlockName {float:right; background: blue;}

I want to be able to set left/right (and maybe something else like background colour). So I've created an admin form that saves a persistent variable, such as variable_get('myBlockName-left', 0).
I can use that in the block content. I can wrap the content in a div that is based on the var such as
, but that will not include the title, and it's a bit messy because it's deeper into the DOM of the block.
Do I need to create a template file for blocks? But that code will need to know what block it is displaying, so that it can check the right variable to know which class to add to the block div.
Answer: I'd probably just use the Block Class module and assign a classes like block-left and block-right.

Block Class allows users to add classes to any block through the
  block's configuration interface. By adding a very short snippet of PHP
  to a theme's block.tpl.php file, classes can be added to the parent

 element of a block. Hooray for more powerful
  block theming!
Answer: You should really do three things:

Instead of using an admin form and variable_set / variable_get, you should use a theme settings form.
You would then make a template_preprocess_block in your theme, which reads a theme variable with theme_get_setting and sets something in $variables.
In your block template, use the variable that you set.

If you can accomplish all of this with just CSS classes, then in your preprocess, you can just tack classes onto $variables['classes_array'][] and skip the third step.
Comment: That sounds like I would have one variable set for all blocks. Or will one of those steps add the variable to the configuration of every block?
e.g. I make the variable var_colour, and I can specify a value for block_1, block_2, etc.
Comment: @TheG, I outline the basic process.  You would need to adapt it for your particular situation.  In your case, I think you would need to be creative with the theme variables.  I suspect you could have one each for left and right, and then assign the IDs that get floated.  Off the top of my head, I am not sure how I would handle the color thing.


A matrix with duplicate rows over commutative ring always has zero determinant, is that true?

Question: Let $R=(R,+,\cdot)$ be a commutative ring and $A$ is a square matrix over $R.$ It is well known that if two rows (or columns) of $A$ are swapped, then its determinant is changed by sign. As a consequence, if $A$ has the same two rows, then swapping such same rows doesn't change the matrix but changes its sign of the determinant. Thus $|A|=-|A|,$ that is $|A|$ has its own inverse in the additive group $(R,+).$ I can not conclude that $|A|=0$ since there are rings with the property that $r=-r$ does not implies $r=0,$ for instance take $r=3$ in the ring $\Bbb Z_6.$ My question: is always true $|A|=0$ when it has duplicate rows? If so, how to prove it?\
Note, $|A|$ is defined as
$$|A| := \sum_{\pi\in S_n} \mbox{sign}(\pi)\ a_{1\pi(1)}\cdots a_{n\pi(n)}$$
where $S_n$ is the group of permutations on $\{1,\dots,n\}$.
Comment: If you are allowed to use row operations, subtract one of the equal rows from the other. That gives a row of zeroes, and you can show that has determinant zero using cofactor or from the definition.
Comment: What is the definition of determinant that you are working with?
Comment: I just edited what we mean by |A|. Thank for asking.
Answer: Yes, it is true. Suppose, say, that the first two columns are equal. Let $\sigma\in S_n$ and let $\iota$ be the element of $S_n$ such that

$\iota(1)=2$;
$\iota(2)=1$;
$\iota(j)=j$ if $j>2$.

Then $\operatorname{sgn}(\iota)=-1$, and therefore $\operatorname{sgn}(\sigma\iota)=-\operatorname{sgn}(\sigma)$. So$$\operatorname{sgn}(\sigma)a_{1\sigma(1)}a_{2\sigma(2)}\ldots a_{n\sigma(n)}+\operatorname{sgn}(\sigma\iota)a_{1(\sigma\iota)(1)}a_{2(\sigma\iota)(2)}\ldots a_{n(\sigma\iota)(n)}=0.$$It follows from this that $\det A=0$.
Comment: Did you mean as $\sigma$ runs in the entire $S_n$, so are $\sigma\iota$, hence your displayed equation above becomes $|A|+|A|=0.$ But how can $|A|=0$?
Comment: Split the sum into two sums: a sum where you run over permutations in $A_n$, and a sum where you run over permutations of the form $\sigma\iota$ where $\sigma\in A_n$. As you can easily conclude from the answer, the second sum is the negative of the first one.
Comment: If $\sigma\in A_n$, that is, if $\operatorname{sgn}(\sigma)=1$, then $\operatorname{sgn}(\sigma\iota)=-1$. So, as $\sigma$ runs in $A_n$, $\sigma\iota$ runs in $\{\sigma\in S_n\mid\operatorname{sgn}(\sigma)=-1\}$. And, for each pair consisting of $\sigma$ and $\sigma\iota$, the contributions of $\operatorname{sgn}(\sigma)a_{1\sigma(1)}a_{2\sigma(2)}\ldots a_{n\sigma(n)}$ and of $\operatorname{sgn}(\iota\sigma)a_{1(\sigma\iota)(1)}a_{2(\sigma\iota)(2)}\ldots a_{n(\iota\sigma)(n)}$ to the determinant of $A$ cancel each other.
Comment: I think the displayed equation is not true, take $\sigma=(123)\in A_3$ so that $\sigma(12)=(13)$. Then the left hand side is $+a_{12}a_{23}a_{31}-a_{13}a_{22}a_{31}$ may not equal to zero.
Comment: @erdos Yes, it's zero as $a_{12} = a_{22}$ and $a_{23} = a_{13}$ by the assumption on the rows.
Comment: @erdos Consider it like this: let $P_n = \{\sigma\in S_n : \operatorname{sgn}(\sigma)=1\}$, $N_n = \{\sigma\in S_n : \operatorname{sgn}(\sigma)=-1\}$, and $T(\sigma) = \iota\sigma$. Then $T$ maps $P_n$ bijectively to $N_n$, so$$\sum_{\sigma\in S_n}f(\sigma) = \sum_{\sigma\in P_n}f(\sigma) + \sum_{\sigma\in N_n}f(\sigma) = \sum_{\sigma\in P_n}f(\sigma) + \sum_{\sigma\in P_n}f(\sigma\iota) = 0.$$
Comment: Yes, I see it. Very elegant solution, direct from the definition without use of previous known theorems. Thank you Sir..
Comment: I'm glad I could help.


jQuery data() vs attr(data)

Question: I would like to know the difference between saving data to an element using $(element).data({'foo' : 'bar'}) vs $(element).attr({ 'data-foo' : 'bar' }). And which of the two method would be best to use when saving a large amount of data in to an element? Thanks
Answer: The $.data is used for storing information with respect to an element:
Docs:

Store arbitrary data associated with the specified element. Returns
  the value that was set.

On the other hand, attr is used to manipulate attributes of an element.
From your question, you seem to store the data, you should use $.data in that case.
data-* attributes are a feature of HTML5
Performance
.data() seems to be much more performance friendly according to this
I also find it cleaner since it's not visible for everyone in page source.
Comment: Im saving an object using JSON.stringify. The data() method can be used to fetch html5 data attributes saved using the .attr() as well. But i suppose using data() would be better.

When using `data`, where is it stored? It doesnt show up as a data attribute on the element
Comment: @Johan: With `$.data` attribs won't be added to element since it is not for attributes but data. As for storing, I believe jQuery stores it internally in some object.
Comment: Ok, thanks for the info. Do you know if IE7 has any problem with data()?
Comment: @Johan: I haven't worked using it with IE7 but you can try it out. I think since jQuery does work for browsers till IE6, it should work fine.
Answer: I would say data, because that is what it was meant to do.  It supports the exact type of functionality you are trying to implement.
http://api.jquery.com/jQuery.data/

jQuery data() vs attr(data)


Strings for my guitar - I'm supposed to tie a knot, but they have a loop

Question: I'm a new guitar player and found an old acoustic guitar in the attic which had rusty strings.
I bought some Elixir Phosphor bronze acoustic strings, but now that I have received them I'm kinda confused.
Pictures for visual aid
Above you will find some pictures.
I let one string stay for ease of clarification.
My understanding of my guitar is that I have to tie it with a knot just like the last string is right now as there are no pins, but the Elixir strings has this loop.
Can I use them anyway and how would I tie them with the loop? :)
To be honest I am also confused that it says 3/4 acoustic, concert and classical guitar on the label inside the guitar, I understand that 3/4 means size but can it be all three at the same time?
Comment: As John says, if you have put the strings on, take them off immediately! They're not the correct ones for that guitar! They will single-handedly wreck it in one go!
Comment: Just to avoid any further confusion, if you have any luthier or music store in your area, I recommend getting their help with picking out strings; they ought to be able to show you how to put them on, too.
Answer: The instrument in the photo is a classical guitar, not acoustic. It uses nylon strings: the three treble strings are from plain nylon (like the one remaining on the photo), and the three bass strings are nylon fibers with metal wound, unlike acoustic/electric guitar strings which have steel core.
Don't put metal (acoustic or electric) strings on a classical guitar. See e.g. Putting a steel string on a classical guitar? (classical guitar with truss rods)
Comment: Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackexchange.com/rooms/139996/discussion-on-answer-by-user1079505-strings-for-my-guitar-im-supposed-to-tie).
Answer: …and just to reinforce user1079505's answer, if you did manage to put them on remove them immediately. A classical guitar is designed for about 1/2 to 1/3 the string tension of a steel string acoustic so you can easily damage the neck or bridge or both with steel strings.


How to feel the music?

Question: I am a deeply technical/mathematical person. I do enjoy understanding stuff around me and this curiosity was one of the reasons I started playing guitar few years ago: I wanted to understand how it works. I'm that kind of guy who asks the teacher a lot of weird technicalities, starting from how instruments are made up to why music is the way it is.
Unfortunately, this made playing a never ending practice. Basically, I'd pick a song, get its tab/music sheet, practice it for ages (also, I'm a perfectionist; a little mistake means usually starting over), and after hours and hours of practice i'd make it. Then, while "performing", i'd add a hint of something of me. Not too much.
You can easily see my issue here. I basically managed to transform playing from an art to a mathematical routine, where each note is a number in an equation. Basically, I cannot speak music. This is also enhanced by the fact that I need some practice to feel the rhythm (e.g. while playing on a backing track), and huge issues with conveying it (for example, if I play fingerstyle, my accents are usually a finger convenience rather than something that convey a rhythm). Notes durations are basically a way of saying "this is kind of longer than this". As for my hearing skills, I can pick up disonances and consonances, I can tell some pitch differences, but I have no relative pitch or anything else.
Now, I'd love to start playing again, but I'd like to actually enjoy it, to be able to "speak" music and "talk" to others (currently, if you get me a backing track, I'll see that it's in Am, I know the notes in the scale, do my random stuff while the backing is playing). Do you have any tips for me?
Edit: (Just some small clarifications)
The perfectionism I mentioned above makes me waste a lot of time, but I do not think it is the real problem. The real problem I find it to be the fact that I am not able to "speak" music. For me, playing has become following a recipe, like a robot, unaware of the surroundings. This has happened because my native skills are not the best, and I guess it was easier for me.
I had some "clicks" during my practice period, when I started feeling the consonances and disonances, when I started feeling the harmony between my voice and the instrument and so on (you can easily see that my ear also needs some training). But I'm looking for a way to move from blindly following a music sheet into the ability to make the music mean something more then a bunch of notes on a score. And the best example is that when I try to play on some backing track meant for improvisation, I end up randomly picking notes rather than having some feel to what I'm playing.
Comment: Do you ever enjoy music when you are just listening, rather than playing? If so, when?
Comment: While there is some great info and advice in the current answers, to my mind topo's question is crucial and cuts to the heart of the issue. Understanding how to feel music while playing it begins with playing music that you feel strongly when you are merely listening to it. Through practice, you can transcend the mechanical processes of reproducing the music and become once again a listener who is also actively involved. Going through that process with music that speaks to you gives insight in how to connect with all kinds of music and find the feeling in it.
Comment: Switch to improvising to a backing track from time to time. Do not stop the backing track when you make a mistake (there are no mistakes in improvising), keep going and work on expressing a mood/sentiment instead of trying to perfectly reproduce a written line.
Comment: @topomorto  I do enjoy music quite often. Actually, I listen at least 8 hours of music per day (i work as a programmer)  while I'm working, and sometimes I get quite engaged into the music (gets to the point where my typing speed varies with the music). The problem is that, quite rarely I get the same feeling. Quite soon after I start playing I start noticing that I missed a lot of notes, that I need to practice more some part and it becomes more about following the music sheet rather than a feeling.
Answer: The first and foremost way to learn to feel the music is to play music.  Not "practice" not "perform," but "play."  The key difference between the former two and the latter is that the former two typically have a very directed purpose to them.  Playing around has less direct purpose, and more just seeing what happens.
The second most important part of learning to feel the music is to go out and listen to music of that genre.  I'm sure you already do, but it's worth pointing out how essential it is.  There's a famous piece of Russian music which sought to replicate the American Jazz movement (Edit: I'd forgotten the name, but margalo's most excelent sleuthing found it:  Jazz Suite No. 1 by Dmitri Shostakovic).  As it was explained, the Russian composer had never heard American Jazz, but got his hands on some jazz scores and made his best guess as to what American Jazz sounded like.  He wasn't even close!
Now if I may give an opinion, I feel that the imperfections are what give the piece a feel.  A skilled musician takes the imperfections in their performance and weaves them right back into the music so seamlessly that you have to ponder if they were indeed imperfections in the first place!  Many styles actually focus around specific imperfections so greatly that they start to become the character of the music.
So go ahead and let the instrument have a little say in the sound.  If a guitar string is slightly out of tune, instead of stopping and tuning it back up, maybe play around with the sound.  Maybe the instrument will suggest a pitch bend that you never thought to try your hand at.  Or maybe, due to sheer luck, that particular out of tune string lets you do a just intonation chord like the Barbershop Quartets use, and you can hear the angel's voice ring out above them (you'll never get that sound with a traditionally tuned fretted insturment).  Let the environment have some say.  If its rainy, see how your picking interplays with the tap-tap-tap on the window panes.  If there's thunder, you've got a free bass track to play against.  If one of your notes falls off the beat, don't stop... see if you can take that note and tell a story with it as you whirl it away on a musical adventure to rejoin the tempo.  When performing for others, don't play for them, play with them.  Watch their eyes.  Soon your fingers will start to realize that they can do things which impress the audience that you never thought they could do (and certainly things that were never written into the score!)
Your very mathematical training provides a solid scaffolding from which to weave feeling into the music.  Don't be afraid to stray very far from your comfort zone, and simply trust that when push comes to shove, your scaffolding will be there to catch you.
Comment: As Tim said above, the answer is very inspirational and insightful. I mentioned my perfectionism since this is one of the reasons why I progress really slow. As I said in my question, I pick a song, and practice until I can sing it. This is most of what I've done and, maybe inappropriate choices for my level combined with a very mathematical way of doing things slow the progress. About playing, sometimes I do try to play on a backing track, but ends up me mumbling some notes in the same key (and the only reason I do that is because I know the key of the bt, not because I feel it).
Comment: @Paul92 Your last example may be an excellent place to start.  If you can "mumble some notes" with sufficient sincerity to make them sound like they were part of the piece in the first place, you will have developed a genuine skill!  I got to watch one of my music teachers cope with a performance where her sheet music fell to the floor half way through.  The only people who could tell she was making things up were those who had been in the dress rehearsal and had really really good memory. What she played was not the right notes, but it was the right feel, and that was actually more important!
Comment: @cort Ammon I found it!  Jazz Suite No. 1 by Dmitri Shostakovich.  Here's a youtube link: https://www.youtube.com/watch?v=CDSeqqEN9Rg
Answer: I agree with the other answers and hope mine complements and enhances their words...
I would suggest defining two distinct types of practicing:

Drilling practice
Playing practice

In drilling practice, you focus on small details of execution and this is where you will stop and start-over a lot. But, in this type of practice you also narrow the scope of what you're playing. Often it's just a measure or a part of a measure, even a single note or chord. But it is uneconomical to play through the whole song in this mode.
Conversely, in playing practice, you try to prepare for an actual performance. Eventually, you want to run through several songs like a little concert. But for each song, you don't stop at mistakes, you try to get back on track and keep going. You do make a mental note of where you stumbled and that measure or phrase will become part of your drilling practice later. But in this mode, you don't stop and start. Get to the end of the song.
Now these two modes of practicing are of course different in the way they should be approached, but also in the results you get. Drilling can be draining, but playing your (current) favorite song start-to-fin should be energizing, even without an audience. So if you organize your guitar practice around balancing these two modes, it will mitigate or even reverse the "boringness" of (drilling) practice (only).
Note, this is not an exhaustive list of the ways of practicing, neglecting reading (and visualizing) practice, improvisation, and others.
Edit: Reading over this later, I think Improvisation is almost equally important as these other two. Particularly with respect to what happens when you make a mistake.
In the drilling practice, a mistake is wrong, and you do it over again or analyze what's going wrong.
And in the performance practice, you try to minimize
mistakes. Don't make a face. Don't swear. Quickly, pick it back up.
But Improvisation teaches you a third way to react to a "mistake": listen to it.
What does it sound like? Where does the melody want to go if that happens? In playing a solo in jazz, there's a "rule":

If you make a mistake, play it twice!

If it's too hard for you to let a mistake lie, and carry on with the song when you're trying to play through the song; then I recommend a strong dose of Improvisation to break up the automatic reaction to mistakes that your brain is doing.
Comment: No-one mentioned guitar, however, this is superb as a practice regime. Both sections are so important, and should be part of every routine. Yes, in the *playing practice*, keep on, warts an' all, just like a performance in front of an audience. It's an essential part of the practice regime! +1 at least!
Answer: Perfectionists are sometimes their own worst enemy! Please don't start right back at the beginning again when learning a piece. My analogy is, you've just cleaned a large window, and you notice a speck still on it. Would you clean the whole window again?
To your question. Music  is mathematical in many ways, but its execution is probably not. Wanting to get things perfect is laudable, but also unrealistic. In fact, often, after a gig, a band I've played in has said how perfect everything was, but the audience was tepid; another night, lots of silly little mistakes, and the audience loved the performance. Weird!
What I'm getting at is - we all make mistakes, and  part of being a good muso is to live with the one you've just made, and do something with it - certainly carry on playing, and do not stop! I usually blame the bass player - unless I am the bass player that gig... If you find one or two others to play with, yes, learn some things verbatim, but also just jam, and see (and hear!) what comes out. Listen, feel, enjoy.
Certainly not advocating it, but so many players have used substances, and I think one of the products of that is losing of inhibitions, so they just played. Not being self-concious while playing is not an easy state to achieve for some, but it's pretty important.
Comment: Take a sentence, or a phrase, and try to express it in different ways.'Man without her woman is a beast' comes to mind. This can be said to mean completely different things. It will depends how you decide to put in the pauses. Music is rather similar. have fun re-phrasing!
Comment: The problem is that my playing is reduced to mumbling some notes. I cannot express myself using music, so I went into an area where music has become a chase after the right formula, after the right amount of pressure to get a bend, rather than a message.
Comment: I like that your comment brought it back to phrasing and words. Improv is not ballet, it's a conversation at a party. Really good vocabulary and grammar can be useful, but are rarely the requirement to being the life of the party. While playing bass, I remember looking over and seeing the lead guitar player scrambling in the dark looking for his pick. The funny thing is, you can't really tell on the tape I have of the performance.
Answer: If you have ever studied poetry, you learned about meter and rhyme. You may have also learned about cadence.  These things create rhythm.  Music is poetry.  The lyrics can help create the mood and emotion.  The beat (tempo and rhythm) also constitute part of the "feel" of music.  The timbre (pronounced "tamber") of the instruments and voices likewise contribute.
Study these things and note the differences between songs.
Also, dancing (or imagining yourself dancing) to the music will help you get the "feel" of it.
Answer: I think you have answered your own question. You mention that perfectionism is not the issue. I agree. You also mention that your ear needs some training. There is your answer. Apply your perfectionism practice habits to training your ear. Once you can hear a sound in your head and then play it, you will be able to rely less on the music and add more expression. In order to practice aural skills think in terms of the hardware. You have eyes, fingers, ears, voice and brain. Eyes and ears are input and fingers and voice are output and brain is processing and creation. You need to practice input through the eyes (seeing music and knowing what it sounds like) output through the fingers (writing or playing music heard in your brain.) Hearing music and knowing it (if not the actual notes, know the functions) and finally singing music.
This actually adds a step in between your current process of seeing sheet music and associating it directly to finger position, but this is good. You want to be able to speak music so think of music as language. Your current process is equivalent to seeing a sentence on a page and know how to type it on a computer and having the computer say the sentence for you. You need to read the sentence, know what it means, say the sentence out loud, then play the sentence on a device. Once this is better you can start rewording sentences and creating your own sentences.
As far as perfectionism is concerned don't worry about it. Be as perfectionist as you want. Do consult with people or teachers or methods as well though, to make sure you are on a good path.  However, I would suggest not stopping if you make a mistake, when practicing playing through a piece. If you constantly do that then that is what you learn. You learn to stop at the drop of a hat. If you have a problem playing something isolate it and perfect it then incorporate it into the whole. But when you practice playing the whole piece practice playing it through to the end. People often will stop and start over in a performance situation if they make a mistake because that is what they practiced, rather than making the mistake and playing through it and finishing the piece, which is preferable.
Answer: I'm also a mathematician that plays guitar. I started playing in earnest late in life. I've felt what you feel, and then some more. There's a little book that changed my whole attitude towards guitar, music and life in general: "Zen Guitar", by Philip Toshio Sudo. Perhaps you'll find in it the way to the answer your looking for.
Answer: My recommendation is to put some music on and dance to it, but in a very particular way.
First, focus on the feet, try to have the feet respond and move to the sounds. After a couple of minutes of this, focus attention on the knees instead. Third, the hips. Fourth the chest and shoulders. Fifth the elbows, sixth the hands and fingers, lastly the head.
Maybe this sounds goofy, but here is the theory behind it.
1) Sounds and music have elements that suggest motion and moving objects. But moving objects differ in mass and momentum, so different sounds will suggest different objects in motion. By isolating body parts, you will naturally tend to match the different instruments whose "musical gestures" best fit the types of motions possible for the featured body part.
2) Motion and emotion are closely linked. By spending time raising awareness of the motions suggested by musical lines and parts, you will be one step closer to hearing the emotion that is suggested by those parts, and will be creating a physically felt repertoire to draw from.
For example, the cradling and rocking of a baby is both a particular motion and it has a certain connotation for emotion, of warmth and comfort. Contrast that with the angular, forcefulness in the melody of, say, Ride of the Valkyries.
I did this dance exercise weekly in a class for a couple months and it had a big, positive influence for me, especially since I was not one to show a lot of emotion generally, and not that well connected with my own body. I can't recall the teacher's name or if this method had a name. It was quite long ago. Certainly one could do it in the privacy of one's home and have it still be helpful.
Answer: If you are not emotionally connected to the music, the way to proceed is not to put feeling into the music, but to put music into the music.
There are phrases begging for an intensivation because of culminating in some pitch or harmonic resolution.  Such intensivation is a matter of subtle developments in speed, articulation, phrasing.
You have an analytical approach so record yourself and listen to the recording.  Where do you think the music would profit from giving it some more of some property?
Of course there are different music styles lending themselves differently to that approach.  Hard rock, trash metal, punk have quite more of an inherent want of expressiveness by the artist than Baroque music.
So if you cannot find music "that is you", it may make sense to focus on finding music "that is it".
Playing such music may not be emotional as much as it may be satisfying.
Improvising on a level where you are not playing random notes in a distribution suitable for matching the scale is not a low-level or rote-learning skill.  Classic music education complete skips over that angle, and it is particularly hard to systematize in a manner where you can use the same teaching material for a large set of students.
If that's where you want to go, you will not easily manage without some one-on-one work with a teacher specializing on it.
Answer: You're already a step ahead and you don't realize it. You know what sounds good and why it sounds good, now you just need to apply it. My recommendation is that you pick up some music that is just melody and chords and force yourself to figure out how to play it. It forces you to think about playing with feeling. You can get inspiration from other songs you know, but, ultimately, it is just you.
Answer:
I started playing guitar few years ago

So, you're basically still a beginner in music. You've learned a bit, and you've earned the right to take stock and ask yourself "what am I getting out of this?".
I'm sure you've got plenty of intellectual pleasure from learning what you have so far, but it sounds like you've noticed you're not getting "musical" pleasure from the exact activities you're doing.
Firstly, just to play devil's advocate, don't force yourself to continue in music unless you can find something that is fun. I prefer eating food to cooking it. Maybe you prefer listening to music to playing it. No problem in that at all.
If you have a vague feeling that you want to continue , but you're not sure with what, maybe that means you should do some different activities, rather than the ones you're doing now? Certainly I've rarely enjoyed playing music from a sheet - As soon as the thought occurred to me, I stopped doing that, started writing my own music, and pretty much never looked at a piece of sheet music again. That's not to say you should do the same, but you do have to be honest about what you like.
Just to pick up on a few random things...

I'm a perfectionist; a little mistake means usually starting over.

To steal a programming analogy, you should be able to play in both 'debug' and 'release' mode. in 'debug' mode, when you make a mistake, sure - back up, work out why you made the mistake, slow down, practice that bit a few times. But you also need to be able to 'ship it' (release mode) and perform - that means you need to handle those exceptions and keep going.

And the best example is that when I try to play on some backing track meant for improvisation, I end up randomly picking notes rather than having some feel to what I'm playing.

So, you've worked out that randomly picking notes from a scale doesn't really work as a way to make compelling music. Why not start looking at a few tunes you like and wok out what really does make them tick, musically? If the lessons you learn there are too hard to put into practice in real-time (improvisation), slow things down and do some composition.

This is also enhanced by the fact that I need some practice to feel the rhythm (e.g. while playing on a backing track), and huge issues with conveying it (for example, if I play fingerstyle, my accents are usually a finger convenience rather than something that convey a rhythm).

Hard for me to give advice on that one - my 'feeling it' skills have always been ahead of the ability of my fingers to actually lay it down! I think there's some good advice in other answers here (i like 'dance') and other questions on the site.
In many styles, the rhythm really is key. If you feel like you've neglected your rhythmic skills, why not put down the guitar and learn drums for a couple of years?

I basically managed to transform playing from an art to a mathematical routine, where each note is a number in an equation.

There's nothing wrong with that. A lot of musicians and other creatives strongly systematize their creativity. The thing is to always keep expanding your equations, so that you can keep creating new things. Also, be prepared to unlearn things if they don't give you the results you are looking for. For example, it looks like you somehow got the idea that the most important thing when playing is to stay in a certain scale. You've found that doesn't give good results? Good! You can now put that idea to one side.
Answer: Paul I read all the answers and I think I might speak something differently. I do suggest the same as JOMKI, as for the singing advise. You really need to sing in order to undersand and incorporate relative pitch. You have to sing out loud and in your head all day. Firstly you want to focus on major scales, and minor scale. And you should sing the melodies of the songs you are playing on the instrument. But that's is really not enough. You need to study basic harmonic progressions and sing and incorporate the sounds in the scale. Then you need to play you own little songs. They don't have to be 3 min long. Just play with some  progressions (maybe start with I-IV-VII-III7_VI_II-V  or  II-V-I) and sing different melodies with the same progressions. Just feel every note you are playing. Go slowly but aware. Then start doind more advanced harmonies like Secondary dominants and finally, what really will give you a whole lot of feelings library is modal interchange. And that's is also going to help you incorporate more other more basic things too. Just sing all these while playing the chords n your instrument. Incorporate each feeling's tone, each chord, each chord tone. Identify them when hearing, and hear it in your head before playing it.
Comment: I agree that being able to sing, both with the voice and in my head are crucial skills, that I unfortunately very much lack and do not practice (mostly because I don't know how to proceed). When I started playing/practicing, I was noticing mistakes by comparison with what I knew it should sound like. After some time, i had a click, when I started to feel disonances (i knew about them, i was hearing them, but I didn't knew what to look for). Also, I wasn't able to produce a note with my voice for a long time (haven't tried much though), until I managed to feel a consonance with a instrument.
Comment: (..continuing last comment) the point is...I know this is what I should aim for...to be able to play the melody in my head, understand how it mixes with everything else, but I don't really know how to approach this. Any tips are welcome :D
Comment: I think everything lies in the feelings. Every note in the major scale has a feeling. A feeling that is the same no matter what is the root note (Do, F#) You should try to incorporate that feeling. Maybe you are able to determine only the root note, and the general feeling of what scale you are in matching you instrument. But you should be able to feel every note of that scale separately. Also, every chord has a feeling too. If it's the second grade, the root chord, if it's the IV grade with a 9th. All this you can feel, and should try to incorporate the feelings in a kind of dictionary.
Comment: This great channel has amazing material, and he's uploading still more and more. There is no doubt you can learn lots of things from him. https://www.youtube.com/user/pegzch/videos
But ou should start slow maybe, just incorporating every note of the major scale. Understand the concept, then move on.
Answer: Don't use conventional instruments like guitar and piano unless you want to torture yourself with boring pedagogy of 12th century church music or enjoy memorizing ridiculous mnemonics like ' all cows eat grass' .
Use a synth, much more mathematical, you can even get into math behind Digital signal processing. There are many free software synths like this one http://tytel.org/helm/ . You said you are a programmer, maybe you can write your own software devices that produce new and fun sounds.
Again, throw that guitar away.
Comment: I did study DSP, but that's more about the sound of music rather than the art of music (even if you might have given me a good idea :D). I have fun playing guitar, don't get me wrong. But I want to get to the next level, in which i'm not simply following the recipe but actually engaging more with the song.

How to feel the music?


Please explain this inner product equation

Question: From Vladimir A. Zorich, Mathematical Analysis I, p. 431:
If a basis $\{e_1,\dotsc,e_m\}$ fixed in the space, then the inner product $\langle x,y \rangle$
of two vectors $x$ and $y$ can be expressed in terms of their coordinates $(x^1,\dotsc,x^m)$ and
 $(y^1,\dotsc,y^m)$ as the bilinear form
$$\langle x,y \rangle=g_{ij}x^{i}y^{j}\tag{8.19}$$
(where summation over $i$ and $j$ is understood), in which $g_{ij}=\langle e_i,e_j \rangle$.
Please explain the Eq.(8.19), thanks.
Answer: The author is using Einstein notation.
In conventional notation it is $$\sum_{i=1}^m \sum_{j=1}^m g_{i,j} x^i y^j.$$
For example if $m=2$ then it is
$$g_{1,1} x^1 y^1 + g_{1,2} x^1 y^2 + g_{2,1} x^2 y^1 + g_{2,2} x^2 y^2.$$
Comment: I got it. Thank you very much!
Answer: According to the given choice of basis, the proposed relation results from the sesquilinearity of the inner product:
\begin{align*}
\langle x,y\rangle & = \langle x_{1}e_{1} + x_{2}e_{2} + \ldots + x_{n}e_{n},y_{1}e_{1} + y_{2}e_{2} + \ldots + y_{n}e_{n}\rangle\\\\
& = \sum_{i=1}^{n}x_{i}\langle e_{i},y_{1}e_{1} + y_{2}e_{2} + \ldots + y_{n}e_{n}\rangle\\\\
& = \sum_{i=1}^{n}x_{i}\sum_{j=1}^{n}\overline{y}_{j}\langle e_{i},e_{j}\rangle = \sum_{i=1}^{n}\sum_{j=1}^{n}x_{i}\overline{y}_{j}\langle e_{i},e_{j}\rangle
\end{align*}
Hopefully this helps.
Comment: I got it. Thank you very much.
Answer: I was inspired by user1337 and angryavian's answer, and write the Eq. (8.19) in more detail:
By the properties
\begin{align}
\langle{}x,y\rangle&=\langle{}y,x\rangle,\\
\langle{}\lambda{}x,y\rangle&={\lambda}\langle{}x,y\rangle{\quad}\text{where }\lambda\in{}\mathbb{R},\\
\langle{}x+y,z\rangle&=\langle{}x,z\rangle+\langle{}y,z\rangle,\\
\end{align}
we have
\begin{align}
    x
&=x^{1}e_1+\dotsb+x^{m}e_m,{\ }y=y^{1}e_1+\dotsb+y^{m}e_m,\\
    \langle{}x,y\rangle
&=\langle{}x^{1}e_1+\dotsb+x^{m}e_m,{\ }y^{1}e_1+\dotsb+y^{m}e_m\rangle=\\
&=\langle{}x^{1}e_1,{\ }y^{1}e_1+\dotsb+y^{m}e_m\rangle+\dotsb+\\
&\phantom{={}}+\langle{}x^{m}e_m,{\ }y^{1}e_1+\dotsb+y^{m}e_m\rangle=\\
&=x^{1}\langle{}e_1,{\ }y^{1}e_1+\dotsb+y^{m}e_m\rangle+\dotsb+\\
&\phantom{={}}+x^{m}\langle{}e_m,{\ }y^{1}e_1+\dotsb+y^{m}e_m\rangle=\\
&=x^{1}\Big(y^{1}\langle{}e_1,{\ }e_1\rangle+\dotsb+y^{m}\langle{}e_1,{\ }e_m\rangle\Big)+\dotsb+\\
&\phantom{={}}+x^{m}\Big(y^{1}\langle{}e_m,{\ }e_1\rangle+\dotsb+y^{m}\langle{}e_m,{\ }e_m\rangle\Big)=\\
&=\Big(x^{1}y^{1}\langle{}e_1,{\ }e_1\rangle+\dotsb+x^{1}y^{m}\langle{}e_1,{\ }e_m\rangle\Big)+\dotsb+\\
&\phantom{={}}+\Big(x^{m}y^{1}\langle{}e_m,{\ }e_1\rangle+\dotsb+x^{m}y^{m}\langle{}e_m,{\ }e_m\rangle\Big)=\\
&=\sum_{i=1}^{m}\sum_{j=1}^{m}x^{i}y^{j}\langle{}e_i,{\ }e_j\rangle=g_{ij}x^{i}y^{j}.
\end{align}


How to remove decoration in  tag?

Question: How can I make the decoration text in the
 tag not to be overwritten by the  tag?

a {
  text-decoration: none !important
}

#paragraph {
  color: black;
}

this is a link

My problem is that I want the text color p is black, not blue.
I found this one but no useful
   How to remove the underline for anchors(links)?
Please guys explain this. All helps are appreciated.
Comment: The blue color is from the :link pseudo-class, not a text-decoration.
Comment: `#paragraph a { color: black; }`
Answer: The best way is to use inherit, so it will depend on the parents property.
a { color: inherit; text-decoration: inherit }

Answer: In the

How to remove decoration in  tag?


Macdonald's "Symmetric Functions and Hall Polynomials" Section 1.5 Example 9

Question: I'm trying to follow Example 9 in Section 1.5 of Macdonald's book "Symmetric Functions and Hall Polynomials". I have trouble with understanding some points.
Before stating my question, I will first explain the example briefly. If $R$ is a root system, then the Weyl denominator formula for $R$ is
$$\sum_{w\in W}\varepsilon(w)e^{w\rho}=\prod_{\alpha\in R^{+}}(e^{\alpha/2}-e^{-\alpha/2}),$$
where $W$ is the Weyl group of $R$, $R^{+}$ is the set of positive roots (relative to some base), $\rho$ is the half-sum of the positive roots and $\varepsilon(w)$ is the sign of $w\in W$. The goal of the example is to express the products
$$\prod_{i<j} (1-x_{i}x_{j}),\quad\prod_{i}(1-x_{i})\prod_{i<j}(1-x_{i}x_{j}),\quad\prod_{i}(1-x_{i}^{2})\prod_{i<j}(1-x_{i}x_{j})$$
as linear combinations of Schur functions using the Weyl denominator formula for root systems of types $D_{n}, B_{n}, C_{n}$, respectively. More precisely,
\begin{align*}
\prod_{i<j}(1-x_{i}x_{j})&=\sum_{\pi}(-1)^{|\pi|/2}s_{\pi}(x_{1},\ldots,x_{n})\\
\prod_{i}(1-x_{i}^{2})\prod_{i<j}(1-x_{i}x_{j})&=\sum_{\mu}(-1)^{|\mu|/2}s_{\mu}(x_{1},\ldots,x_{n})\\
\prod_{i}(1-x_{i})\prod_{i<j}(1-x_{i}x_{j})&=\sum_{\nu}(-1)^{(|\nu|+p(\nu))/2}s_{\nu}(x_{1},\ldots,x_{n}),
\end{align*}
where the first sum ranges over all partitions $\pi=(\alpha_{1}-1,\ldots,\alpha_{p}-1\mid\alpha_{1},\ldots,\alpha_{p})$ with $\alpha_{1}\leq n-1$, the second sum ranges over all partitions $\mu=(\alpha_{1}+1,\ldots,\alpha_{p}+1\mid\alpha_{1},\ldots,\alpha_{p})$ with $\alpha_{1}\leq n-1$, the third sum ranges over all self-conjugate partitions $\nu=(\alpha_{1},\ldots,\alpha_{p}\mid\alpha_{1},\ldots,\alpha_{p})$ with $\alpha_{1}\leq n-1$ and $p(\nu)=p$.
Now I'm ready to state my question. Here I will just consider the first product. Let $\epsilon_{1},\ldots,\epsilon_{n}$ be the standard basis for $\mathbb{R}^{n}$. The root system $R=D_{n}$ is given by
$$\{\pm(\epsilon_{i}\pm\epsilon_{j}):i\neq j\},$$
and the subset
$$\Delta=\{\epsilon_{1}-\epsilon_{2},\epsilon_{2}-\epsilon_{3},\ldots,\epsilon_{n-1}-\epsilon_{n},\epsilon_{n-1}+\epsilon_{n}\}$$
is a base. Then
\begin{align*}
R^{+}&=\{\epsilon_{i}\pm\epsilon_{j}:1\leq i<j\leq n\},\\
\rho&=(n-1)\epsilon_{1}+(n-2)\epsilon_{2}+\cdots+\epsilon_{n-1}.
\end{align*}
On the other hand, the reflection $\sigma_{\epsilon_{i}-\epsilon_{i+1}}$ in the orthogonal complement of $\epsilon_{i}-\epsilon_{i+1}$ switches $\epsilon_{i}$ with $\epsilon_{i+1}$, and $\sigma_{\epsilon_{i}+\epsilon_{i+1}}$ switches $\epsilon_{i}$ to $-\epsilon_{j}$ and $\epsilon_{j}$ to $-\epsilon_{i}$. Thus the Weyl group $W$ can be identified with the group of all elements that permute $n$ elements as well as switching an even number of their signs, hence isomorphic to $S_{n}\ltimes\mathbb{Z}_{2}^{n-1}$. If we replace $e^{-\epsilon_{i}}$ by $x_{i}$, the right-hand side of the denominator formula becomes:
\begin{align*}
\prod_{\alpha\in R^{+}}(e^{\alpha/2}-e^{-\alpha/2})&=e^{\rho}\prod_{\alpha\in R^{+}}(1-e^{-\alpha})\\
&=x_{1}^{-(n-1)}x_{2}^{-(n-2)}\cdots x_{n-1}^{-1}\prod_{i<j}(1-x_{i}x_{j})\left(1-\frac{x_{i}}{x_{j}}\right)\\
&=(x_{1}\cdots x_{n})^{-(n-1)}\prod_{i<j}(1-x_{i}x_{j})\left(x_{j}-x_{i}\right).
\end{align*}
The product $\prod_{i<j}(1-x_{i}x_{j})$ is the product we are interested in and the product $\prod_{i<j}(x_{j}-x_{i})$ is involved in the definition of Schur function. So it remains to relate the left-hand side of the denominator formula to the partitions $\pi=(\alpha_{1}-1,\ldots,\alpha_{p}-1\mid\alpha_{1},\ldots,\alpha_{p})$ with $\alpha_{1}\leq n-1$. But I have no idea. If someone has any idea, please let me know. Thank you for reading.
Comment: Obviously you must use description of the $s_\pi$ via [SSYT](https://en.wikipedia.org/wiki/Young_tableau#Tableaux)s: the latter are fillings of the [Young diagram](https://en.wikipedia.org/wiki/Young_tableau#Diagrams) for $\pi$ with numbers according to certain rules. When you look what $w\rho$ might be you must ensure that the possibilities are exactly described by these rules. I believe.
Comment: All this is (concisely) said in the Wikipedia article about [Schur polynomials](https://en.wikipedia.org/wiki/Schur_polynomial#Properties)
Comment: Thank you for the comment. I will try with SSYT.
Answer: First, we would like to fix some notations.
Instead of $\varepsilon_i$ (as in the OP's notation), we use $v_i$ (as in Macdonald) for the standard basis for $\mathbb R^n$.
We solve this problem in several steps:
(Step 1) Rewrite the equation into a sum over $\mathbb Z_2^{n-1}$;
(Step 2) Rewrite the summand as Schur functions indexed by a partition $\lambda(\epsilon)$ depending on $\epsilon\in\mathbb Z^2_{n-1}$;
(Step 3) Prove that $\epsilon\mapsto \lambda(\epsilon)$ gives a bijection between $\mathbb Z_2^{n-1}$ and the desired set of partitions;
(Step 4) Check the signs.
(Step 1)
Identify $\mathbb Z_2^{n-1}$ as $\epsilon=(\epsilon_1,\dots,\epsilon_n)\in\mathbb Z_2^n$, such that $\prod_i \epsilon_i=1$.
Let $w\in S_n$, then $w\epsilon :v_i\mapsto\epsilon_{i} v_{w(i)}$, and
\begin{align}
 w\epsilon\rho=w\sum \epsilon_i(n-i)v_i = \sum \epsilon_i(n-i)v_{w(i)},
\end{align}
where $\rho=\sum (n-i)v_i$.
Under the identification $e^{-v_i}=x_i$, we now need to show that
\begin{align}\tag{*}
 \frac1{a_\delta} \sum_{\epsilon\in\mathbb Z_2^{n-1}} \varepsilon(\epsilon) \sum_{w\in S_n} \varepsilon(w) \prod_i x_{w(i)}^{n-1-\epsilon_i(n-i)}
\end{align}
can be written as a sum over Schur functions.
(Step 2)
Fix $\epsilon\in\mathbb Z_2^{n-1}$,
define $\overline\lambda(\epsilon)=\delta-\mathbf1-\epsilon(n\mathbf1-\delta)\in\mathbb Z^n$, i.e.,
\begin{align}
 \overline\lambda(\epsilon)_i:=i-1-\epsilon_i(n-i), \quad 1\leq i\leq n,
\end{align}
and define $\lambda(\epsilon)$ by
\begin{align}
 \lambda(\epsilon) = (\overline\lambda(\epsilon)+\delta)^+-\delta,
\end{align}
where $\delta = (n-1,\dots,1,0)$ and $(\cdot)^+$ is sorting in descending order.
Then
\begin{align*}
 \mathrel{\phantom{=}} \sum_{w\in S_n} \varepsilon(w) \prod_i x_{w(i)}^{n-1-\epsilon_i(n-i)}
 &= \sum_{w\in S_n} \varepsilon(w) \prod_i x_{w(i)}^{\overline\lambda(\epsilon)_i+n-i} \\
 &= \sum_{w\in S_n} \varepsilon(w) w(x^{\overline\lambda(\epsilon)+\delta})
 = a_{\overline\lambda(\epsilon)+\delta} = s(\epsilon) a_{\lambda(\epsilon)+\delta},
\end{align*}
where $s(\epsilon)$ is some sign.
Now (*) is equal to
$$\sum_{\epsilon\in\mathbb Z_2^{n-1}} \varepsilon(\epsilon)s(\epsilon) s_{\lambda(\epsilon)}.$$
(Step 3)
Fix $\epsilon\in\mathbb Z_2^{n-1}$.
Let $I=I(\epsilon)=\{i_1<\dots<i_l\}$ denote the indices with negative sign in $\epsilon$ and $J=I^c=\{j_1<\dots<j_{n-l}\}$ its compliment.
By the definition of $\overline\lambda(\epsilon)$, we have
\begin{align}
 (\overline\lambda(\epsilon)+\delta)_i = n-1-\epsilon_i(n-i) =
 \begin{cases}
  2n-1-i,&\epsilon_i=- \\
  i-1,&\epsilon_i=+ \\
 \end{cases}.
\end{align}
From the formula above, the index of the entry of $\overline\lambda(\epsilon)+\delta$ in descending order is given by $i_1,\dots,i_l,j_{n-l},\dots,j_1$ (i.e., the $i_1$th entry is the greatest, then the $i_2$th entry, and so on...).
Hence $\lambda(\epsilon)$ is given by
\begin{align}
 \lambda(\epsilon)_m = \begin{cases}
  n+m-1-i_m, & 1\leq m\leq l; \\
  j_{n+1-m}-n-1+m, & l+1\leq m\leq  n,
 \end{cases}
\end{align}
which is indeed a partition and the sign $s(\epsilon)$ is given by moving the $i_k$th entry to the $k$th entry, i.e., $s(\epsilon)=(-1)^{\sum_{k=1}^l (i_k-k)}$.
Define \begin{align}
 \alpha(\epsilon) = \begin{cases}
  (n-i_k)_{1\leq k\leq l-1}, &\epsilon_n=-; \\
  (n-i_k)_{1\leq k\leq l}, &\epsilon_n=+. \\
 \end{cases}
\end{align}
Let $p=l-1$ or $l$ be the length of $\alpha$ depending on $\epsilon$.
It is clear that $\alpha$ is strictly decreasing and each entry in $\alpha$ is at least 1 and that $\alpha_1\leq n-1$.
We will show that the Frobenius notation for $\lambda(\epsilon)$ is exactly $\left(\alpha(\epsilon)-\mathbf1\mid\alpha(\epsilon)\right)$.
Firstly, we claim that the maximal square in $\lambda(\epsilon)$ has length $p$. In fact, the length is equal to $\#\{m:\lambda(\epsilon)_m-m\geq0\}$.
Note the following:
when $m\leq l-1$, $\lambda(\epsilon)_{l-1}\geq0$;
when $m=l$, $\lambda(\epsilon)_m-m = n-1-i_m\geq0$ if $\varepsilon_n=+$ and $\lambda(\epsilon)_m-m<0$ if $\varepsilon_n=-$.
when $m\geq l+1$, $\lambda(\epsilon)_m-m<0$.
Secondly, note that the first $p$ rows of $\left(\alpha(\epsilon)-\mathbf1\mid\alpha(\epsilon)\right)$ are equal to those of $\lambda(\epsilon)$ by definition.
Lastly, we need to show that the first $p$ columns of them are also equal.
For $1\leq k\leq p$, the $k$th column of $\left(\alpha(\epsilon)-\mathbf1\mid\alpha(\epsilon)\right)$ is $\alpha_k+k=n-i_k+k\geq l+1$, while the $k$th column for $\lambda(\epsilon)$ is $\#\{i: \lambda_i\geq k\}$.
To show that $n-i_k+k \leq \#\{i: \lambda_i\geq k\}$, we need $\lambda_{n-i_k+k}\geq k$, i.e.,
$$
j_{i_k-k+1}\geq i_k+1.
$$
This holds because $i_k-k$ is the number of +'s in $[1,i_k]$, and $j_{i_k-k+1}$ is the index of the $(i_k-k+1)$th $-$ sign which is at least $i_k+1$.
Similarly, to show that $1+n-i_k+k > \#\{i: \lambda_i\geq k\}$, we need $\lambda_{1+n-i_k+k} < k$, i.e.,
$$
j_{i_k-k}< i_k.
$$
This holds because $i_k-k$ is the number of +'s in $[1,i_k]$, and $j_{i_k-k}$ is the index of the $(i_k-k)$th $+$ sign which is strictly less than $i_k$.
This concludes the proof that $\lambda(\epsilon)=\left(\alpha(\epsilon)-\mathbf1\mid\alpha(\epsilon)\right)$.
Note that the following bijections:
\begin{align*}
 \mathbb Z_2^{n-1}
 &\leftrightarrow
 \{I(\epsilon)\subset[1,n]: \#I(\epsilon)\text{ is even}\} \\
 &\leftrightarrow \{I(\epsilon)\setminus\{n\}\subset[1,n-1]\}\\
 &\leftrightarrow \{\alpha(\epsilon): \alpha_1>\dots>\alpha_p\geq1, \alpha_1\geq n-1\}.
\end{align*}
(Step 4)
Now, it suffices to show that
\begin{align}
 \varepsilon(\epsilon) s(\epsilon) = (-1)^{|\lambda(\epsilon)|/2}.
\end{align}
Note that $$|\lambda(\epsilon)|/2 = |\alpha(\epsilon)| = \sum_{k=1}^p (n-i_k) = \sum_{k=1}^l (n-i_k)=\sum_{k=1}^l (k-i_k)+\sum_{k=1}^l (n-k)$$
since when $\epsilon_n=+$, $p=l$; when $\epsilon_n=-$, $p=l-1$ and the $l$th term is $n-i_l=0$.
Also, we have
$\varepsilon(\epsilon)s(\epsilon)  = (-1)^{l/2+\sum_{k=1}^l (i_k-k)}$.
Now, since $l$ is even, we have
$$\sum_{k=1}^l (k-i_k)+\sum_{k=1}^l (n-k) \equiv \sum_{k=1}^l (k-i_k)+\binom{l+1}{2} \equiv \sum_{k=1}^l (k-i_k)+\frac{l}{2}.$$
Comment: Credit: I would like to thank [user:746685](https://math.stackexchange.com/users/746685/likeeatingoctopus) for the discussion with me.


Azure Mobile App and Authentication

Question: I have a Mobile App I am writing, at present it is simply the To Do Item list quick start application with custom Authentication added.  I have the associated Xamarin Forms app.
From the App I am able to login using the LoginAsync method, my website returns a token and shows the username I am logging in as, but subsequent calls suggest I am not authorised.
After a bit of debugging, I can see that the request arrives at the web server with the X-ZUMO-AUTH header and the token in the value, but I can see that the User does not seem to be populated and the call to the GetAllTodoItems method is returned as 401:Unauthorized.
In the startup code for the website, the ConfigureMobileApp contains the following:
<code>    app.UseWebApi(config);

    if (string.IsNullOrEmpty(settings.HostName))
    {
        // This middleware is intended to be used locally for debugging. By default, HostName will
        // only have a value when running in an App Service application.
        app.UseAppServiceAuthentication(new AppServiceAuthenticationOptions
        {
            SigningKey = ConfigurationManager.AppSettings["SigningKey"],
            ValidAudiences = new[] { ConfigurationManager.AppSettings["ValidAudience"] },
            ValidIssuers = new[] { ConfigurationManager.AppSettings["ValidIssuer"] },
            TokenHandler = config.GetAppServiceTokenHandler()
        });
    }
</code>
I have an account controller class:
<code>[Route(".auth/login/custom")]
public class AccountController : ApiController
{
    private static string URL = "https://myapidev.azurewebsites.net/";
    private static string KEY = "FC31EB8CAAAAAA9D74EEE3613A7A08CA65CB1ACAA8CEFF82A5B5E915625B31D";

    public AccountController()
    {

    }
    [HttpPost]
    public IHttpActionResult Post([FromBody] LoginUser assertion)
    {
        if (isValidAssertion(assertion))
        {
            JwtSecurityToken token = AppServiceLoginHandler.CreateToken(new Claim[] { new Claim(JwtRegisteredClaimNames.Sub, assertion.username) },
                ConfigurationManager.AppSettings["SigningKey"],
                ConfigurationManager.AppSettings["ValidAudience"],
                ConfigurationManager.AppSettings["ValidIssuer"],
                TimeSpan.FromHours(24));

            return Ok(new LoginResult()
            {
                authenticationToken = token.RawData,
                user = new LoginResultUser() { userId = assertion.username }
            });
        }
        else // user assertion was not valid
        {
            return ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.Unauthorized, "Invalid Request"));
        }
    }

    private bool isValidAssertion(LoginUser assertion)
    {
        return assertion != null;
    }
}
</code>
The TodoItemController contains the following:
<code>[Authorize]
[MobileAppController]
public class TodoItemController : TableController<TodoItem>
{
    protected override void Initialize(HttpControllerContext controllerContext)
    {
        base.Initialize(controllerContext);
        EducaterAPIDevContext context = new EducaterAPIDevContext();
        DomainManager = new EntityDomainManager<TodoItem>(context, Request);

        //// Get the SID of the current user.
        //var claimsPrincipal = this.User as ClaimsPrincipal;
        //string sid = claimsPrincipal.FindFirst(ClaimTypes.NameIdentifier).Value;
    }

    // GET tables/TodoItem
    public IQueryable<TodoItem> GetAllTodoItems()
    {
        return Query();
    }
    ...
    ...
}
</code>
On calling the query method from the Xamarin App, it returns with 401 even though the X-ZUMO-AUTH is in the headers and contains the correct token issued by the login method.
Have I missed something or has anyone come across this issue before - any help would be appreciated?
Comment: Never used Azure for mobile but here is 2 articles which may point what is wrong. https://azure.microsoft.com/en-us/blog/announcing-app-service-authentication-authorization/ and https://www.newventuresoftware.com/blog/custom-authentication-with-azure-mobile-apps
Answer: Have you turned on Authentication/Authorization in your App Service?  Without it, the token will never be decoded.
This is the most common issue.
Comment: And check out the custom auth section of my book - http://aka.ms/zumobook
Comment: I have the "Authentication / Authorization" turned on in Azure with the Action set to Allow Request.  None of the services are configured as I am only looking to use the custom option at present.
Does the Azure setting have an influence on local debug?
Comment: The local debug settings are on active on local debug and you have to set the ValidAudience / ValidIssuer / SigningKey values in the Web.config when running locally.  When running within Azure, these are handled for you by the Authn/Authz feature (which is why you need it turned on).  Try turning on diagnostic logging at the verbose level, watch the Log Stream and re-submit - see if there are any issues there.
Comment: I have found that the app will work against Azure - I had an issue with configuration which I spotted via the logs thanks, but when run against a local debug version and add the Azure app as the AlternateLoginHost then the authentication is not working locally.  The trace logs do not show any errors processing the header or any attempt to look at the header.  I have looked at several of the local debugging guides and all appears to be correct so I assume I am still missing something
Comment: @AdrianHall  I'm having the same issue as Mike C was having.  The auth works when on Azure, but doesn't when on my local.  I've checked the SigningKey,ValidAudience & ValidIssuers value in the startup and web.config at least 5 times.  I've also verified that it  UseAppServiceAuthentication is being hit on startup.  I've turned on verbose tracing at the server, but i'm not seeing any activity.  The request seems to be rejected before displaying any information at the server.  The [authorize] attribute is rejecting the request before any token information is being displayed.  Any ideas?  Thanks
Answer: After digging I found the issue, initially there was a configuration issue - the above comments helped thanks.  The Audiences and Issuers must match your azure site including including the trailing slash.
The issue once the configuration had been corrected was that the token which is passed correctly from my App did not get processed at the server side so all Authorized areas where out-of-bounds.  This was because of the order of calls in the ConfigureMobileApp method.  I was calling the app.UseWebApi method before the app.UseAppServiceAuthentication method, changing the order suddenly had the token being tested again.
The dummy site I have working now has the following:
<code>    public static void ConfigureMobileApp(IAppBuilder app)
    {
        HttpConfiguration config = new HttpConfiguration();

        //For more information on Web API tracing, see http://go.microsoft.com/fwlink/?LinkId=620686
        SystemDiagnosticsTraceWriter traceWriter = config.EnableSystemDiagnosticsTracing();

        new MobileAppConfiguration()
            .UseDefaultConfiguration()
            .MapApiControllers()
            .ApplyTo(config);

        config.MapHttpAttributeRoutes();

        // Use Entity Framework Code First to create database tables based on your DbContext
        //Database.SetInitializer(new EducaterAPIDevInitializer());

        // To prevent Entity Framework from modifying your database schema, use a null database initializer
        // Database.SetInitializer<EducaterAPIDevContext>(null);

        MobileAppSettingsDictionary settings = config.GetMobileAppSettingsProvider().GetMobileAppSettings();
        if (string.IsNullOrEmpty(settings.HostName))
        {
            var options = new AppServiceAuthenticationOptions
            {
                SigningKey = ConfigurationManager.AppSettings["SigningKey"],
                ValidAudiences = new[] { ConfigurationManager.AppSettings["ValidAudience"] },
                ValidIssuers = new[] { ConfigurationManager.AppSettings["ValidIssuer"] },
                TokenHandler = config.GetAppServiceTokenHandler()
            };
            app.UseAppServiceAuthentication(options);
        }
        app.UseWebApi(config);
    }
</code>
Comment: You should definitely check out Adrian's book.  It is absolutely great.  Heads off almost all problems before you get to them and the writing style is excellent.  Highly recommended.

Azure Mobile App and Authentication


Install xenserver on iscsi target

Question: Is is know that Xen Server is based on CentOS, and it is fact that CentOS can be installed on an ISCSI target flawlessly, but I wanted to install Xen server on an ISCSI target I couldn't find a way.
I already tried the latest version of xen server 6.2, and there is no obvious way who to do the installation without a local disk.
Does anybody have an idea about the subject, or did someone know how to do it?
Please share your experience about this subject.
Answer: Edit: Updated the Answer to better include Xen server Specific information.
Installing to an ISCSI target is similar to installing to a local disk.
You should be able to set your iscsi target as "First HDD" in the iscsi initiator settings.
Additionally, make sure that you have a boot order of:
1) iscsi target (DO NOT ALLOW IT TO BOOT TO THIS TARGET DURING INSTALL)
(You should be able to set the target to mount but skip booting 1 time in the initiator settings)
2) CD-Rom drive.
The system should them mount the target, then boot to CD-ROM.
After booting the to the Xen Server Install Media

At Xenserver installer boot press F2 to go to Advanced Mode
Type 'shell' at the prompt
At the prompt type: (Where "iqn.2010-01.com.example:name" is your IQN name)
echo "InitiatorName=iqn.2010-01.com.example:name" > /etc/iscsi/initiatorname.iscsi
Initialize your target ("--mpath" if you have multipath setup to the iscsi LUN)
/opt/xensource/installer/init --use_ibft

Information lovingly borrowed from here:
https://supportforums.cisco.com/discussion/11517296/iscsi-boot-xenserver
Comment: You are talking about booting Xen Server from and iscsi target, which irrelevant with my question, my question is intalling Xen Server to an iscsi target instead of the local server, just consider that the server that I want to install is diskless.
Comment: @GhassenTelmoudi Maybe you could clean up your question a bit?  You state "Install Xen Server on an ISCSI Target".  The steps I gave you are a birds eye view of how to install Xen Server on that target (Assuming your install media in on the CD-Rom drive)
Comment: There is none of what you're talking about on the installation process of Xen Server at least for version 6.2.
Can you at least back it up with some screenshot, because it seems to me that we're not talking about the same thing @Dan.
Comment: @GhassenTelmoudi I've updated my answer to be more Xen specific. Good luck!
Comment: Any luck with this @GhassenTelmoudi ?
Comment: Thank you @Dan for you answer, but I have to try it first.

Install xenserver on iscsi target


Shot on target with deflection - a goal or an own goal

Question: It's generally accepted that if a shot was on target but then deflected from another team's player and went in, then the goal is not considered as an own goal. "Generally accepted", because there are no official rules regulating these scenarios.
But what about Sergio Ramos's 2nd goal in Napoli vs Real Madrid, Round of 16, 2nd leg, 2016/17 Champions League game (Europe video) (US video)? This goal was accounted by UEFA as Dris Mertens's own goal, although the shot was clearly on target.
The only guess I have is that as this shot was directed towards the goalkeeper Pepe Reina, the guys who define the authorship of the goals decided that if there hasn't been a deflection, Reina would have easily caught the ball. So, why this goal is counted as an own goal?
Comment: It's not broken. Probably you can't access the video from your location. If you know some legal international video highlight of this match, you are very welcome to edit the video link, I couldn't find. Are you sure it's referee who regulates the authorship of the goals? Cause I think it's some officials behind the scenes.
Comment: @gbianchi [Law 10](http://theifab.com/laws/determining-the-outcome-of-a-match/chapters/goal-scored) provides no information on how a scorer is decided. The referee isn't tasked with deciding which player has scored a goal - only which team. Competition rules might specify that the referee provides a player in their report, but it's not always the case. In the English league system, for example, the [dubious goals committee](http://www.efl.com/global/dubiousgoalscommittee.aspx) has the final say on who is the scorer.
Comment: I've also replaced the officiating tag with statistics, since deciding who the goalscorer is is a [statistical matter](http://www.asktheref.com/Soccer%20Rules/Question/30436/), not an [officiating matter](http://www.asktheref.com/Soccer%20Rules/Question/31228/).
Comment: A number of occasions where the shot would have been going in but easily stopped by the goalkeeper, then deflected by a defender and actually went in, marked as o.g. in the summary. Almost assuredly that this is the case.
Comment: Beginning to think there are people watching AFC Bournemouth games passionately every week like me, given all the pertinent questions.  That thought is amazing.  In today's game an obviously deflected shot was changed from a goal to an own goal after further reflection.  And seems that has happened A LOT recently.  I've seen quite a few of these changes made this year, at least in the Premier... so perhaps they're shifting towards OG being defacto (which is a bit of a pity?)
Comment: The video link is broken. Besides that, it's a good question, but I doubt we can get an answer with real support. Since the final desicion of who makes a goal, is in the hands of the referee, there is no rule about it. Usually if the attacker has the porpuose to shoot on target, then there is no own goal.
Comment: gdrt94, this goal is one that I believe has more stably been defined as an own goal, when a player attempts to head (or kick, etc) the ball away, and it ends up in the goal.  Though indeed the intent on that isn't absolutely clear given the quick progression.  The Bournemouth goal I mentioned ([US link](http://www.espnfc.us/video/premier-league-highlights/148/video/3085389/prem-mawsons-own-goal)) is less clear.
Comment: It's all down to the person keeping track of the game eventually. So very likely he just made a mistake. Human errors are possible, that's why there is a "dubious goals committee" in PL. UEFA might not have an equivalent.
Answer: In the Premier League, if the shot was clearly on target before the deflection, then it is given as a goal. If there is any doubt as to whether the original shot was on target, then it is passed on to the dubious goals committee, who decide who to award the goal to. Whether or not the goalkeeper would have saved it without the deflection is not taken into consideration.
In the Sergio Ramos case, it is possible UEFA have their own definition of a goal/og that differs from the Premier League. Alternatively, UEFA could've deemed the Ramos header to be going off target before the deflection.
Answer: Since I don't have referee's match report this is not a complete answer. Clearly Ramos shot was on target but was given as Merten's own goal, the most likely case was that referee interpreted that as an own goal.
This old FIFA article states:

That although it is not among his official duties, it is the referee who should decide whether a goal is an own goal or not.

And on other article FIFA Referees Committee chairman David Will states:

the referee should decide. Maybe he would need to check with the teams to ascertain exactly who got the decisive touch in some unclear situations, but the name that goes down on the referee's report is the one that should enter the record books.

But more importantly on this article former UEFA president Michel Platini states:

Referees would be told to award a goal to the player who intended to score, provided the ball was already heading towards the net when the deflection occurred.

Emphasize part explains that it is the referee who will award the goal. But on that specific case referee may have interpreted Ramos shot was not headed towards the net and gave an own goal to Mertens.
Comment: Even if it were not exactly the case, still it's more general answer that could be applied to other disputable situations as well. That's why I am accepting your answer. Nice research!
Comment: If the deflection happened by someone on the same team, who's goal is it?
Comment: Are there different rules determining goals from own-goals, such that the referee would need to get involve? Or is it just as a favour to the statisticians, and to who gets the (dubious) bragging rights?


scalar curvature on one - dimensional Riemannian Manifold

Question: How can i express the scalar curvature for a one - dimensional Riemannian manifold (M, g) in terms of the metric g ?
Answer: A one-dimensional Riemannian manifold does not have any intrinsic curvature at all. It is always locally isometric to a straight, "flat" line.
Formally, the Riemann curvature tensor has but a single component $R_{1111}$, but this element is required to be 0 due to (for example) the skew-symmetry of $R_{ijkl}$.
Comment: @Lor: Good question. I _think_ every Riemannian metric on $\mathbb R$ is isometric to an open subset of $\mathbb R$, but I cannot rattle off a proof.
Comment: Yes, the isometry is given by a unit speed geodesic.
Comment: Ah thanks a lot that's what I suspected.
Comment: Can this local isometry always be promoted to a global isometry (of course if there is no topological obstruction) ?
Comment: How can one compute the global curvature of a circle seen as a 1D manifold with a metric, without embedding it into $\mathbb{R}^2$?


How can I sort a view based on a date value in a multi-value paragraph reference field?

Question: I have a custom entity type that uses an entity reference revisions field that accepts multiple values. The referenced paragraphs contain a date field. I would like to sort the entities (descending) by the most recent date in a paragraph referenced from their fields. E.g.:

Entity 1

Paragraph 0

Date: 1/1/2016

Paragraph 1

Date: 1/1/2017

Paragraph 2

Date: 1/1/2018

Entity 2

Paragraph 0

Date: 2/1/2017

Paragraph 1

Date: 2/1/2018

Entity 3

Paragraph 0

Date: 3/1/2016

Paragraph 1

Date: 3/1/2017

...should sort to: Node 2, Node 1, Node 3.
Thanks!
Answer: Sounds like you need to do a relationship to the paragraph reference field on your node. Which will then open up the fields on the paragraph into views. Then you might need to turn the field aggregation on in your view and add a sort on your date field selecting the MAX value
Comment: I did try that. I can then add the date field to each row, but I get multiple rows, one for each paragraph value. Turning on aggregation throws errors: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'node__field_url.field_url_' in 'field list': SELECT DISTINCT node__field_url.field_url_ AS node__field_url_field_url_, (etc.) -- field_url does exist in the view, and displays as expected when aggregation is turned off.
Comment: Sounds like you're using a field called "Url" in the view and you need to change the aggragation type to one of the other options for that field as some of them for certain fields will cause that error. Or are you saying you have no field with the machine in "url" in your view? If so that's strange and not sure whats going on


How can I automatically let syncdb add a column (no full migration needed)

Question: When I make a change to my models (only to add a column during development!), Django won't issue any ALTER TABLE statements to update the database. Is there a way to get this implemented or worked around? - other then adding the columns manually?

Note I'm not really looking for a full-migration solution, just something that lets me keep coding as I add columns on the way.
Comment: possible duplicate of [What is your favorite solution for managing database migrations in django?](http://stackoverflow.com/questions/426378/what-is-your-favorite-solution-for-managing-database-migrations-in-django)
Comment: ... among many other questions on the same subject.
Comment: I've reworded it a bit. What I'm looking for is not a complete migration suite, but something to add columns quickly during development. E.g. `syncdb` sees a column is missing, and adds it automatically.
Answer: Use python manage.py sqlclear YOURAPP in conjunction with dumpdata and loaddata (simplified version of answer by fish2000, which also uses a specific app):
DB=/path/to/db.sqlite3
APP=YOURAPPNAME
tmpdate=$(date "+%Y%m%d-%H%M%S")

echo "+ Dumping django project database to fixture DUMP-${tmpdate}.json ..." &&\
python manage.py dumpdata $APP --format='json' --indent=4 --verbosity=1 > datadumps/DUMP-${tmpdate}.json &&\
echo '+ Backing up sqlite binary store...' &&\
cp $DB $DB.bk &&\
echo '+ Rebuilding database structure from model defs...' &&\
python manage.py sqlclear $APP &&\
echo "+ Reloading project data from fixture dump DUMP-${tmpdate}.json ..." &&\
python manage.py loaddata datadumps/DUMP-${tmpdate}.json

Comment: In newer versions of django (e.g. 1.5) the command to use is python manage.py sqlclear instead of reset
Comment: If a django model has a column and a database doesn't - I get an error. Has this worked for anyone else?
Answer: Use a migration tool such as South.
Comment: Migrations appear to be on their way in Django 1.7: https://docs.djangoproject.com/en/dev/topics/migrations/
Comment: @vbdoor: there is no native schema modification in the Django ORM.  It must be done manually or with a utility such as South.
Answer: Sorry, this is a little late but I thought I would post it here anyways in case anyone else is having this problem.  If you are still in development and all of your data is dummy data (meaning you don't want to keep any of it), then all you have to do is delete the database and run syncdb again.
Answer: Check out evolution http://code.google.com/p/django-evolution/
Answer: If you don't want to set up migrations – you may be able to use a trick like this:
export JANGY_PROJECT='/Users/fish/Dropbox/ost2/ost2'
export BPYTHON_INIT_SCRIPT='${JANGY_PROJECT}/utils/django_shell_imports.py'
export PYTHONPATH="${JANGY_PROJECT}:${PYTHONPATH}"

alias jangy="python manage.py"
alias bp="cd $JANGY_PROJECT && bpython --interactive $BPYTHON_INIT_SCRIPT"

function jangyfresh () {
    tmpdate=$(date "+%Y%m%d-%H%M%S") &&\
    cd $JANGY_PROJECT &&\
    echo "+ Dumping django project database to fixture DUMP-${tmpdate}.json ..." &&\
    python manage.py dumpdata --format='json' --indent=4 --verbosity=1 > datadumps/DUMP-${tmpdate}.json &&\
    echo '+ Backing up sqlite binary store and taking database offline...' &&\
    mv sqlite/data.db sqlite/data.db.bk &&\
    echo '+ Rebuilding database structure from model defs...' &&\
    python manage.py syncdb &&\
    echo '+ Graceful-restarting Apache...' &&\
    sudo apachectl graceful &&\
    echo '+ Enabling write access on new sqlite file...' &&\
    chmod a+rw sqlite/data.db &&\
    echo "+ Reloading project data from fixture dump DUMP-${tmpdate}.json ..." &&\
    python manage.py loaddata datadumps/DUMP-${tmpdate}.json &&\
    echo '+ Rebuilding project database structure...'
}

... which what that bash function does is:

Dumps the database out to a fixture,
named with a date/time stamp
Backs up and deletes
the binary database file (SQLite in this
case, which it's comparatively easy
to delete the file in question)
Resyncs the the DB from models (regenerating the binary DB file)
(optional) Fixes the DB files' perms (which dropbox can screw with, in my case here)
Repopulates the new DB from the last fixture
(optional) restarts apache

I use this during development to back things up and start from scratch – sometimes it works if you add a column, sometimes it'll complain about the newly defined model field not having a database column.
In these cases I run the command, edit the models.py file, delete the sqlite file and reload the last fixture.
Obviously, I don't do this on a production install, nor I would not recommend that.


Show that the expressions $\sin^{-1}(\frac{1}{\sqrt{x}})$ and $\frac{1}{\sqrt{x}}$ are the same for big values

Question: How can you show that the expressions $\sin^{-1}(\frac{1}{\sqrt{x}})$ and $\frac{1}{\sqrt{x}}$ for big values are the same?
The opposite side of a triangle is given with $1/\sqrt(x)$, the angle between the hypotenuse and the the opposite side can be calculated by $sin^{-1}(1/\sqrt(x))$. For large x that seems to be correct, as a review with some inserted values in the calculator has given. Can one also show this connection differently? Maybe graphically?
Comment: The wording is important - for large values they are approximately the same. Note that the Taylor expansion for arcsin involves a sum of odd powers, and for small values, those powers become negligible.
Comment: Hint: $\sin'(0)=1$.
Comment: @TheSimpliFire if I understand you right, you mean: $sin^{-1}(x)=x-\frac{1}{6}x^3+\frac{3}{40}x^5+...$. Then this means for $sin^{-1}(1/\sqrt{x})$ something like that: $1/\sqrt(x)+-\frac{1}{6}(1/\sqrt(x))^3+...$ right?
Comment: Yes, and when $x\to\infty$, $1/\sqrt x\to0$ so powers of three, five etc become extremely small.
Comment: If you agree with the approximation $\sin\theta\approx \theta$ when $\theta\to 0$, then the result you seek is just considering $\theta:=1/\sqrt x\to 0$ as $x\to\infty$ and applying $\arcsin$ on both sides.
Comment: I would like to continue to know what exactly is meant by this hint $sin'(0)=1$, can someone explain that?
Answer: Consider the limit of their ratios:
$$\lim_\limits{x\to +\infty} \frac{\arcsin \frac1{\sqrt{x}}}{\frac1{\sqrt{x}}}\stackrel{\frac1{\sqrt{x}}=t}{=}\lim_{t\to 0^+}\frac{\arcsin t}{t}\stackrel{L'H}=\lim_{t\to 0^+}\frac{\frac1{\sqrt{1-t^2}}}{1}=1.$$
Answer: If $x$ is large, then $\frac1{\sqrt x}$ is small and if $y$ is small, then $\arcsin(y)$ is approximately $y$ (because $\arcsin(0)=0$ and $\arcsin'(0)=1$). But they are never equal if $y\neq0$.
Answer: Not that: $\lim_{x\rightarrow\infty}(\frac{1}{\sqrt{x}})=0$
$\Rightarrow \lim_{x\rightarrow\infty}(\sin^{-1}(\frac{1}{\sqrt{x}}))=\sin^{-1}(0)=0$
Hence: $\lim_{x\rightarrow\infty}(\frac{1}{\sqrt{x}})=\lim_{x\rightarrow\infty}(\sin^{-1}(\frac{1}{\sqrt{x}}))=0$


Cover map of the figure eight

Question: During an exam I was supposed to find a connected (and non trivial) cover map of the figure eight. In particular, each point in the figure eight has to have infinite pre-image. I know that there is a 'standard' one in $R^2$ that is not hard at all but during the exam for some reason I forgot about it or I was not able to build it again. Since I had fun thinking about it, I am still curious to know if it works or not.
I came up with an alternative idea. Please let me know how you could formalize this idea in a better way or if there is any flaw in the reasoning :)

Start with a triangle (full line) and map each segment to the 'left circle'. Do you need an 'orientation' on the segments when you define this map?
For each of the vertices of the triangle in previous step, construct another triangle (dashed line) and map each of its segments to the 'right circle'.

Then, continue with the same pattern.
I think I missed the orientation but maybe the overall concept work. What do you think? From my reasoning it seems a covering space since it satisfies the required properties.
Answer: Yes, that looks like a correct idea.
Of course, whenever one says something like "continue with the same pattern", it raises the question of "What's the pattern?". To give a good answer to such a question, you must give a rigorous description of the pattern, and the best way to do that is to give a formal definition-by-mathematical-induction.

Cover map of the figure eight


Is it possible to somehow overcome type erasure in Java?

Question: Here's the thing.
We use a lot of Wicket Panels in our application, and for testing purposes they should ideally be generated generically. Part of this works, in theory: For every parameter type in a constructor I have only one possible argument to offer, so it is a matter of finding what these parameter types are - Reflection.
Problem being: Type Erasure. Many of the constructors use multiple versions of the Model< > class as parameters with various different type parameters to it. Type Erasure means that as far as I can find I have no way to differentiate between these at runtime.
So, in this situation, is there any way to overcome or circumvent type erasure?
Comment: Can you post the relevant code?  Type erasure is a part of the Java language specification, so there is no way to "turn it off," but there could be a workaround for your problem.
Answer: You have a problem long before you use reflection and if you fix this, you not longer need to worry.
As there is no way to tell the difference between Model and Model you cannot overload two methods or constructors with these types.  Instead you need to create one method which takes a Model<C> where C is the super class/interface of A and B.
You can't do this
interface A extends C { }
interface B extends C { }

class MyClass {
    MyClass<Model modelA) { }
    MyClass<Model modelB) { }

This won't compile as they have the same signature after erasure so instead you can do
class MyClass {
    MyClass<Model<? extends C> model) { }

Not only does this compile but there is no ambiguity at runtime.


Infering generic types in typescript

Question: I am trying to wrap my head around infering generics in Typescript, but I can't seem to get a hold on what am I doing wrong. My concrete example would be rather large to leave here, but I've made a small typescript playground link, which illustrates the problem I am facing completely.
Here's the link
Basically, I am trying to infer a generic parameter from a class hierarchy:
type payloadType = {
    [key:string]: string
}

type specificPayloadB = {
    a: string
}

type specificPayloadC = {
    a: string,
    b: string
}

class A<TPayload extends payloadType = any> {}
class B<TPayload extends specificPayloadB = specificPayloadB> extends A<TPayload> {}
class C extends B<specificPayloadC> {}

type InferKeys<TType> = TType extends A<infer Keys> ? Keys : never;
class extender<
   TType extends A,
   TKeys = InferKeys<TType>
> {}

function getClass<TClass extends A>(): extender<TClass> {
    return new extender<TClass>();
}

let testExtenderB = getClass();
let testExtenderC = getClass<C>();

The above example, gives no compilation error, but when inspecting the returned variable types with typescript, testExtenderB is identified as a extender<B<specificPayloadB>, payloadType> which is correct, but based on the information provided, it could be more correctly identified as a extender<B<specificPayloadB>, specificPayloadB>.
The same is true in my opinion for the testExtenderC variable, which is identified as extender<C, payloadType> instead of it being identified as extender<C, specificPayloadC>.
Am I doing something wrong here? Is it possible to achieve the correct identification of the variables, without explicitly providing the types to typescript?
Answer: Typescript has a structural type system. For object types this means the members of the type are important when determining type compatibility (see FAQ). This means that unused type parameters are a not very significant in the type system. Since you don't use TPayload in A the type parameter doesn't have any significance in the type system, so during inference it will end up with it's default value in some cases.
If you add a member, inference works as you expect it to:
class A<TPayload extends payloadType = any> { p!: TPayload }

Playground Link
Comment: Does this mean that I need to actually define that variable somewhere along the lines, or just plain and simply add it, and leave it undefined if I never intend to use it for anything else? I am unfammiliar with the `!` exclamation mark notation, could you please explain what it does?
Comment: You can leave it undefined It just need to be a member in the class. The `!` is there to tell the compiler not to complain that the value is not assigned in the initialization or in the constructor

Infering generic types in typescript