Ionic 3 combination tabspage and sidemenu not working

Question: i followed this article to combine sidemenu and Tabs pages.
the app.html has my menu. i have with #nav bind the ion-nav to [Content] of my ion-menu.
in my app.component.ts i have click Events. they set different Tabs pages as root and there is one normal page.
this looks like this:
@ViewChild('nav') nav: NavController;

    public OnInformationClicked(): void {
        this.nav.setRoot("InfoTabsPage");
    }

    public OnManagementClicked(): void {
        this.nav.setRoot("ManagementTabsPage");
    }

//some other Tabs pages

//the normal page
    public OnFaqClicked(): void {
        this.nav.setRoot("FaqPage");
    }

in my tabs pages i'm using [selectedIndex] like this:
<ion-header>
    <ion-navbar>
        <ion-buttons left>
            <button ion-button icon-only menuToggle>
                <ion-icon name="menu"></ion-icon>
            </button>
        </ion-buttons>
    </ion-navbar>
</ion-header>
<ion-tabs [selectedIndex]="0">
    <ion-tab [root]="contactPersonRoot" tabTitle="{{tabs1Name}}" tabIcon="information-circle"></ion-tab>
    <ion-tab [root]="contactSupportRoot" tabTitle="{{tabs2Name}}" tabIcon="information-circle"></ion-tab>
</ion-tabs>

but it is not working.
Problem:
when i open my menu and change the tabs pages, i can see, how the tabs changed and the right tab Icon is selected, but the Content over the tabs doesn't changed.
if i going to the normal page, this is displayed correctly. if i going to a Tabs page from the normal page, then the Tabs page is displayed correctly. if i'm trying to go back to another tabs page. it doesn't changed all content again.
i tried  .... MyTabs.select(0). same issue.
i'm currently tesing with ionic serve.
"ionic-angular": "3.9.2",
"ionicons": "4.1.2",
"@angular/animations": "6.0.3",
"@angular/common": "6.0.3",
"@angular/compiler": "6.0.3",
"@angular/compiler-cli": "6.0.3",
"@angular/core": "6.0.3",
"@angular/forms": "6.0.3",
"@angular/http": "6.0.3",
"@angular/platform-browser": "6.0.3",
"@angular/platform-browser-dynamic": "6.0.3",
"@ionic-native/app-version": "^4.10.0",
"@ionic-native/background-mode": "^4.10.0",
"@ionic-native/camera": "^4.10.0",
"@ionic-native/core": "4.7.0",
"@ionic-native/in-app-browser": "^4.9.1",
"@ionic-native/network": "^4.7.0",
"@ionic-native/splash-screen": "4.7.0",
"@ionic-native/status-bar": "4.7.0",
"@ionic/storage": "^2.1.3",

anyone an idea, what's going wrong?
UPDATE
after try and error coding, changed from [selectedIndex]="0" back to myTabs.select(0) in the .ts file of the tabs page like in the article. this not working.
but i made a  timeout around like so:
ionViewDidLoad() {

    let _self = this;
        setTimeout(function(){
            _self.tabRef.select(0);
        },100);
}

now i can see, the content over the tabs replaced correctly. but it looks not like a good workaround, because now i see that the old content is loading before the replacement by select.
if i open tabspage 2 now, i can see from tabspage 1 is the content behind tab 1 rendered (ionViewDidLoad, ionViewWillEnter... of tab 1 is executing). then after selecting is done, tab 1 of tabspage 2 is rendering.
UPDATE 2
app.html:
<ion-menu [content]="nav">
    <ion-header>
        <ion-toolbar>
            <ion-title>{{menuTitle}}</ion-title>
        </ion-toolbar>
    </ion-header>
    <ion-content>
        <ion-list>
            <button ion-item (click)="OnInformationClicked()">
                <ion-icon name="information" item-start color="primary"></ion-icon>
                <ion-label>Info</ion-label>
            </button>
            <button ion-item (click)="OnManagementClicked()">
                <ion-icon name="build" item-start color="primary"></ion-icon>
                <ion-label>Manage</ion-label>
            </button>
            <button ion-item (click)="OnRealisationClicked()">
                <ion-icon name="clipboard" item-start color="primary"></ion-icon>
                <ion-label>Real</ion-label>
            </button>
            <button ion-item (click)="OnContactClicked()">
                <ion-icon name="contact" item-start color="primary"></ion-icon>
                <ion-label>Contact</ion-label>
            </button>
            <button ion-item (click)="OnFaqClicked()">
                <ion-icon name="help" item-start color="primary"></ion-icon>
                <ion-label>FAQ</ion-label>
            </button>
            <button ion-item (click)="OnLogoutClicked()">
                <ion-icon name="log-out" item-start color="primary"></ion-icon>
                <ion-label>Logout</ion-label>
            </button>
        </ion-list>
    </ion-content>
</ion-menu>

<ion-nav [root]="rootPage" #nav [swipeBackEnabled]="false"></ion-nav>

app.component.ts
@Component({
    templateUrl: 'app.html'
})
export class MyApp {

    @ViewChild('nav') nav: NavController;

    public menuTitle: string = GlobalHelper.GetResources().Application.Menu.Menu;

    rootPage: any = HomePage;

    constructor(private _css: ClientServerProvider, platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen,
        private _backgroundMode: BackgroundMode, private _appProvider: AppProvider) {

        platform.ready().then(() => {
            // Okay, so the platform is ready and our plugins are available.
            // Here you can do any higher level native things you might need.
            statusBar.styleDefault();
            splashScreen.hide();

            _backgroundMode.enable();
        });
    }

    public OnInformationClicked(): void {
        this.nav.setRoot("InfoTabsPage");
    }

    public OnManagementClicked(): void {
        this.nav.setRoot("ManagementTabsPage");
    }

    public OnRealisationClicked(): void {
        this.nav.setRoot("RealisationTabsPage");
    }

    public OnContactClicked(): void {
        this.nav.setRoot("ContactTabsPage");
    }

    public OnFaqClicked(): void {
        this.nav.setRoot("FaqPage");
    }

    public OnLogoutClicked(): void {

        this._css.Logout().then(loggedOut => {
            if (loggedOut) {
                this._appProvider.InitApplication();
            }
        });
    }
}

for example one of the Tabs pages (the others are like this):
<ion-header>
    <ion-navbar>
        <ion-buttons left>
            <button ion-button icon-only menuToggle>
                <ion-icon name="menu"></ion-icon>
            </button>
        </ion-buttons>
    </ion-navbar>
</ion-header>
<ion-tabs #myTabs>
    <ion-tab [root]="preparationRoot" tabTitle="{{tabs1Name}}" tabIcon="browsers"></ion-tab>
    <ion-tab [root]="processRoot" tabTitle="{{tabs2Name}}" tabIcon="logo-buffer"></ion-tab>
    <ion-tab [root]="complaintRoot" tabTitle="{{tabs3Name}}" tabIcon="bulb"></ion-tab>
</ion-tabs>

import { Component, ViewChild } from '@angular/core';
import { IonicPage, NavController, MenuController, Tabs } from 'ionic-angular';
import { GlobalHelper } from '../../../../helper/globalHelper';

@IonicPage()
@Component({
    selector: 'page-realisation-tabs',
    templateUrl: 'realisation-tabs.html'
})
export class RealisationTabsPage {

    @ViewChild('myTabs') tabRef: Tabs;

    preparationRoot = 'PreparationPage';
    processRoot = 'ProcessPage';
    complaintRoot = 'ComplaintPage';

    tabs1Name = GlobalHelper.GetResources().Application.Features.Realization.Preperation_Page_Header;
    tabs2Name = GlobalHelper.GetResources().Application.Features.Realization.Process_Page_Header;
    tabs3Name = GlobalHelper.GetResources().Application.Features.Realization.Complaint_Page_Header;

    constructor(public menuCtrl: MenuController, public navCtrl: NavController) {

    }

    ionViewDidLoad() {

      // after OnRealisationClicked

       /*
        *
        * with this workaround, Tabs changed, content (subpage) changed, correct * tab is active, but before the subpage changed to correct one, the previous
* subpage is loading , nearly the result of the guide in the article

        let _self = this;
        setTimeout(function () {
            _self.tabRef.select(0);
        }, 100);*/

          // this is the variant of the article, without timeout
         //only Tabs are changed and the correct tab Icon is active and selected
         // but content (subpage) is not changed, it is still the first subpage
//of the previous tabspage
         this.tabRef.select(0);
    }
}

Workflow (without the timeout workaround):

after Login HomePage as  root is replaced with RealisationTabsPage, Tab 1 subpage (preparation) is loaded
open Menu Click on a menu Point, which open another Tabs page, for example contacttabspage
Tabs of the contacttabspage are loaded. tab 1 of this Tabs is selected and active. but the subpage behind tab 1 of contacttabspage is still the subpage from realisationtabspage (preparation).
now i'm open menu and going to a None Tabs page (FAQ). FAQ is correctly rendered.
open menu: i'm going to a Tabs page, never mind which Tabs page (Realization, contact, info, mangement...), Tabs page rendered correctly.
now i'm going from this tabspage to another tabspage , so there is the issue again. i'm see the previous subpage of the previous tabspage.

if i'm using  instead of using the select() function there is the same issue.
Comment: Remove 'ion header' from tabs page template...Move the menu toggle button from to contact and contacts pages
Comment: You can use ion footer and create buttons like tabs with ngfor and ngclass for active inactive
Comment: my first variant was that the Header with the menu toggle was in the subpages. this not worked. so i opened the article again, see where the author of the article has the Header on the tabspage. so i moved the menu toggle Header from the subpages to the tabpages. :/
Answer: Made this working example of sidemenu+tabs.Hope it helps you.
https://stackblitz.com/edit/ionic-hmkkwc
Comment: i updated my post, how the app component is and a example Tabs page. it is like the tutorial article described.
Comment: kindly take a look at the link i have posted
Answer: I had a similar problem. Assign the pages directly to the tab variables instead of the string representation (page names) AND give the tab container unique ids. That worked for me.


Asymptotics of a series involving cos integral functions

Question: I'm looking for the asymptotic expansion( or value ) of the following function
\begin{equation}
F[y,t] =  \sideset{}{'}\sum_{n \in \mathbb{Z}}\text{Ci}\big[\frac{n^2}{t}\big] - \text{Ci}\big[\frac{(n+y)^2}{t}\big], \quad t \in [0, \infty), \,\, y \in [0, 1]
\end{equation}
where the sum is performed for all nonzero integers and $\text{Ci}$ is the cos integral function
\begin{equation}
\text{Ci}(x) = -\int_x^{\infty} \frac{\cos t}{t} dt
\end{equation}
I plot the alternative form of the function at $y = \frac{1}{2}$
\begin{equation}
F[y = \frac{1}{2}, t] = \sum_{n=1}^{\infty} 2\text{Ci}\big[\frac{n^2}{t}\big] - \text{Ci}\big[\frac{(n+0.5)^2}{t}\big] - \text{Ci}\big[\frac{(n-0.5)^2}{t}\big]
\end{equation}
using Mathematica.

The general pattern of these figures is that the function goes up and then has a damping process and finally converge to a fixed value at large $t$. My truncation is performed for $n \gg t$; it seems that beyond $n \gg t $, extra terms only increase the fuzziness of the curve, not the asympototic value.
I tried to approximate it using Euler-Maclaurin formula.
Let $f(n ) = 2\text{Ci}\big[\frac{n^2}{t}\big] - \text{Ci}\big[\frac{(n+y)^2}{t}\big] - \text{Ci}\big[\frac{(n-y)^2}{t}\big]$
then
\begin{equation}
  F[y, t] = \lim_{N\rightarrow \infty} \int_1^{N} f(x) dx + \frac{1}{2}[ f(1) + f(N)] + \frac{1}{12}[f'(N) - f'(1)] \\- \frac{1}{720}[f^{(3)}(N) - f^{(3)}(1)] + \cdots
\end{equation}
Keeping up to the first derivative term, I have
\begin{equation}
  F[y, t] \sim - 2\text{Ci}[\frac{1}{t}] + (\frac{1}{2} + y ) \text{Ci}[\frac{(1+y)^2}{t}] + (\frac{1}{2} - y ) \text{Ci}[\frac{(1-y)^2}{t}] \\- 2 \Big( \int_1^{1+y} + \int_1^{1-y} \Big) \cos \frac{u^2}{t}du
\end{equation}
However this function is very smooth at large $t$. It seems that I have to keep all the corrections at $n=1$ to have a reasonable estimation.
There are several questions I want to ask about the asymptotic behavior

Does
\begin{equation}
\lim_{t\rightarrow \infty} F[y,t]
\end{equation}
exist?
If the asymptotic value does exist, then is there some sort of series expansion available for the large $t$?

Thanks.

Edit:
Let me fill in the gaps in user Jack D'Aurizio's solution of asymptotic value(credit belongs to him).
First make a simple change of variable from $u$ to $v$: $u = \frac{v^2}{t}$
\begin{equation}
  -\sum_{n\in\mathbb{Z}}'\int_{n^2/t}^{(n+y)^2/t}\frac{\cos u}{u}\,du = -2\sum_{n\in\mathbb{Z}}'\int_{n}^{n+y}\cos(\frac{v^2}{t})\frac{dv}{v}
\end{equation}
The integral becomes an integration on $\mathbb{R}$ with standard measure and the integrand function
\begin{equation}
-2\cos(\frac{x^2}{t})\big[\sum_{n\in\mathbb{Z}}' \chi_{[n,n+y]}(x) \big]
\end{equation}
where $\chi(x)$ is the characteristic function.
Take $t$ to be an integer sequence, since
\begin{equation}
\Big|2\cos(\frac{x^2}{t})\big[ \sum_{n\in\mathbb{Z}}' \chi_{[n,n+y]}(x)  \big]\Big| \le 2( \sum_{n\in\mathbb{Z}}' \chi_{[n,n+y]}(x)  )
\end{equation}
and the later is integrable( by using the  Weierstrass product for the sine function )
\begin{equation}
2\sum_{n\in\mathbb{Z}}'\int_{n}^{n+y}\frac{dv}{v}=2\sum_{n\in\mathbb{Z}}'\log\left(1+\frac{y}{n}\right)=2\log\prod_{n\geq 1}\left(1-\frac{y^2}{n^2}\right)=2\log\left(\frac{\sin(\pi y)}{\pi y}\right).
\end{equation}
the dominated convergence theorem claims that
\begin{equation}
\lim_{t\rightarrow \infty} F[y,t] = -\int_{\mathbb{R}} dx\, \lim_{t\rightarrow \infty} 2\cos(\frac{x^2}{t})\big[ \sum_{n\in\mathbb{Z}}' \chi_{[n,n+y]}(x)  \big] = -2\log\left(\frac{\sin(\pi y)}{\pi y}\right)
\end{equation}
Answer: So we want to study the behaviour for a large $t$ of:
$$ \sum_{n\in\mathbb{Z}}'\int_{n^2/t}^{(n+y)^2/t}\frac{\cos u}{u}\,du = 2\sum_{n\in\mathbb{Z}}'\int_{n}^{n+y}\cos(v^2/t)\frac{dv}{v}$$
that by the dominated convergence theorem and the Weierstrass product for the sine function approaches:
$$ 2\sum_{n\in\mathbb{Z}}'\int_{n}^{n+y}\frac{dv}{v}=2\sum_{n\in\mathbb{Z}}'\log\left(1+\frac{y}{n}\right)=2\log\prod_{n\geq 1}\left(1-\frac{y^2}{n^2}\right)=\color{red}{2\log\left(\frac{\sin(\pi y)}{\pi y}\right)}.$$
Comment: Thanks @Jack D'Aurizio, impressive solution! In the figure it is about 0.91 for $y = 1/2$, indeed very close to -$2 \ln \Big( \frac{\sin{\pi y }}{\pi y} \Big)$. The opposite sign is due to a missing minus sign in the definition of cos integral function(I have edited the post). Do you have idea in doing a systematic expansion in terms of $1/t$ or other relevant small variables in large time?
Comment: @anecdote: well, in principle the remaining part is given by $$2\sum_{n\in\mathbb{Z}}'\int_{n}^{n+y}\sin^2\left(\frac{v^2}{2t}\right)\frac{dv}{v}$$ that looks manageable through Fourier series. Interesting things happen for $y=1$. I will keep working on this problem.
Comment: Hi @Jack D'Aurizio, in reflection, I have questions about the use of dominated convergence theorem. What absolute convergent function do you use to control the $\cos(v^2/t) /v$? The function $1/|v|$ is not integrable. Or you use the measure $dv / v = \text{sgn}(v) d \ln v $? Is it a valid measure(it can be negative)?


Problem with adding content

Question: I allow my administators to add panels, articles, blog posts, forum topics, etc but it only shows the default set that regular users get which is blog posts and forum topics. Ive checked and all the people are set to admin. How do i fix this?
Answer: You need to go into People -> Permissions -> Roles.  Find the administrator role and click on 'Edit Permissions'.
Then, go down to the Node section, and check off the appropriate permissions for viewing, creating, editing, deleting, etc.. that particular content type.  The permissions actually look like this:
<code>Article: Create new content [ ]
Article: Edit own content   [ ]
Article: Edit any content   [ ]
Article: Delete own content [ ]
Article: Delete any content [ ]
</code>
You'll of course want to check off probably all of those if the role is an administrator, as typically they'll have absolutely power over your application.  That is, if it's what you intend.  The power of Drupal is yours :)
Comment: Still does not work.
Comment: Try clearing cache?

Problem with adding content


Pass multiple calling arguments to a formal argument in dplyr custom function without using "..."

Question: To make a custom function flexible to receiving one or more calling arguments per formal argument I currently rely on "...":
library(dplyr)

foo <- function(data, ..., dv){
  groups <- enquos(...)
  dv <- enquo(dv)
  data %>%
    group_by(!!!groups) %>%
    summarise(group_mean = mean(!!dv))
}

mtcars %>% foo(am, dv = mpg)
mtcars %>% foo(vs, am, dv = mpg)

But "..." obscures the logic of the function, and it could not be used in a custom function with 2 or more formal arguments requiring multiple calling arguments.
Is there a way to write the above function to utilize a formal argument (e.g., "groups") rather than "..." that can receive a single vector name or a vector of vector names as its argument(s)? Something like:
foo <- function(data, groups, dv){
  groups <- enquos(groups)
  dv <- enquo(dv)

  data %>%
    group_by(!!!groups) %>%
    summarise(group_mean = mean(!!dv))
}

# Failing code
mtcars %>% foo(groups = c(vs, am), dv = mpg)

Note that this code would work, but require user to remember to use quos() in function body:
foo <- function(data, groups, dv){
  dv <- enquo(dv)

  data %>%
    group_by(!!!groups) %>%
    summarise(group_mean = mean(!!dv))
}

mtcars %>% foo(groups = quos(vs, am), dv = mpg)

I'd love to rely on enquos() in body of function instead.
Answer: We could place the ... at the end
foo <- function(data,  dv, ...){
   groups <- enquos(...)
   dv <- enquo(dv)
   data %>%
     group_by(!!!groups) %>%
     summarise(group_mean = mean(!!dv))
  }

If we want to pass a vector of 'group', then one option is group_by_at
foo <- function(data, groups, dv){
  dv <- enquo(dv)

  data %>%
     group_by_at(vars(groups)) %>%
     summarise(group_mean = mean(!!dv))
  }

mtcars %>%
    foo(groups = c("vs", "am"), dv = mpg)
# A tibble: 4 x 3
# Groups:   vs [?]
#     vs    am group_mean
#  <dbl> <dbl>      <dbl>
#1     0     0       15.0
#2     0     1       19.8
#3     1     0       20.7
#4     1     1       28.4

One option if we want to pass unquoted expression with c would be to convert it to expression and then evaluate it
foo <- function(data, groups, dv){

 groups <- as.list(rlang::enexpr(groups))[-1]
 dv <- enquo(dv)
   data %>%
      group_by(!!! groups) %>%
      summarise(group_mean = mean(!!dv))
 }

mtcars %>%
      foo(groups = c(vs, am), dv = mpg)
# A tibble: 4 x 3
# Groups:   vs [?]
#     vs    am group_mean
#  <dbl> <dbl>      <dbl>
#1     0     0       15.0
#2     0     1       19.8
#3     1     0       20.7
#4     1     1       28.4

Or as @Joe mentioned in the comments, enquo should also work with group_by_at
foo <- function(data, groups, dv){
   dv <- enquo(dv)
   groups <- enquos(groups)
   data %>%
        group_by_at(vars(!!!groups)) %>%
        summarise(group_mean = mean(!!dv))
   }

mtcars %>%
     foo(groups = c(vs, am), dv = mpg)
# A tibble: 4 x 3
# Groups:   vs [?]
#     vs    am group_mean
#  <dbl> <dbl>      <dbl>
#1     0     0       15.0
#2     0     1       19.8
#3     1     0       20.7
#4     1     1       28.4

Comment: @Joe  I updated with another option to convert it to an expression
Comment: your use of group_by_at() seems key to making this work, but I found that enquos() will also work:

foo <- function(data, groups, dv){
  dv <- enquo(dv)
  groups <- enquos(groups)

  data %>%
    group_by_at(vars(!!!groups)) %>%
    summarise(group_mean = mean(!!dv))
}

mtcars %>% foo(groups = c(vs, am), dv = mpg)
Comment: Thank you, the function will work with a string vector and with quos(). Do you know if there is any reason it cannot work with enquos()? I can only find examples of enquos being used with "..."


Conversão de char para inteiro no C#

Question: Lendo um artigo de blog, me deparei com a seguinte sintaxe para conversão de char para inteiro:
string value = "123";
foreach (var c in value)
{
    if (char.IsDigit(c))
    {
        int digito = c - '0';
    }
}

Gostaria de saber por que essa conversão funciona.
Answer: Todo char é um inteiro correspondente da tabela ASCII, e o '0' é o valor base dessa tabela, ou seja, todos os caracteres tem um valor inteiro correspondente e em uma operação de subtração o resultado é o inteiro correspondente dessa tabela, por isso funciona.
Referencias

char (Referência de C#)
Método Convert.ToInt32 (Char)
How to convert char to int?
Char Struct
Char.GetNumericValue Method (Char)
Answer: Segundo a documentação do C#, o char pode ser convertido implicitamente para int

(... ) char pode ser convertida implicitamente para ushort, int, uint, long, ulong, float, double ou  `decimal.

No entanto, cuidado com resultados inesperados. A explicação do @VirgilioNovic justifica porque operações como essa:
char op1 = '3';
char op2 = '1';

Console.WriteLine("Resultado: " + (op1 + op2).ToString());

Não resulta em 4:
`Resultado: 100`

Porque (int)op1 é 51 e (int)op2 é 49.
Veja este exemplo no dotnetfiddle.;
Answer: você deve usar o ToString() para não usar o código ASC e depois o TryParse para verificar se é inteiro.
string value = "123";
foreach (var c in value)
        {
            short digito;
            if(Int16.TryParse(c.ToString(),out digito))
            {
                Console.WriteLine(digito);
            }
        }
        Console.ReadKey();

Conversão de char para inteiro no C#


What forms can a classical composition be?

Question: I'd like to learn the names of the different forms of classical musical compositions as compared to the literary work structure that has a beginning, the part where the plot thickens and the dramatic changes occur, then the part where mysteries get solved and the ending.
Comment: Please don't limit this question by a specific era of classical music -- that's *not* going to be useful because there are many similarities across eras *for a given form*. For example, Binary, Ternary, Sonata and Rondo forms are all used to some degree from about the Baroque and onward (or longer). What should be realized is that there are many different types of classical music forms, each possibly with their own structural terminology (though there may be some overlap). If you are not interested in any specific type (e.g. Symphony, Concerto, Opera), then this answer will become very long.
Comment: Your question is meaningful but you do not realize how vast the subject is. There are many different kinds of classical music pieces and they all have different structural elements. Answering your question would take many college textbooks. Google the term "form and analysis" (use the quote marks) with regard to music composition and music theory, and you will begin to see what we mean.
Comment: I think you'll have to define 'classic'. There is romantic, baroque, 20th century classic
Comment: Well, how different in structure are they? Maybe we could further narrow down the scope if it's still too broad :p
Comment: Agreed with Caleb here - there are many more questions the OP would need to answer before we could give a thoughtful response, and even then, the answer would be very long.  In this instance, it is likely to be more helpful to suggest a book or two.
Comment: I'm still interested in finding out how the music is designed (classical or modern), by learning the progression structures components and their purposes. Please help me make these questions acceptable and answerable on this SE site.
Answer: Okay... I'm going to take a stab at this. Note that while some of my answer will be from the perspective of Baroque music, much of it will still apply to some degree throughout the Classical and Romantic eras as well.
First of all lets differentiate between the type of composition, and the form of that composition. By type of composition (there may be a better word for this) I mean what kind of music is it, and what its texture and purpose is. By form, I mean the structural layout of its various developmental elements. Often, one will imply something about the other, but this is not a necessary or fixed correlation.
Some common types of classical compositions include (but this is not an exclusive list):

Vocal works

Opera: A long staged work of musical drama for choir & orchestra, usually of a secular theme.
Oratorio: Similar to an opera, but unstaged and usually on a sacred theme.
Cantata: Usually religious, similar to an oratorio, but much shorter. Suitable for inclusion in a church service.

Instrumental works

Sonata: A piece for a solo instrument (often with accompaniment)
Chamber music: Trios, quartets, etc... More instruments than a sonata, but not a full orchestra
Suite: A collection of shorter works, usually dances, or pieces with a dance-like quality.
Concerto: A piece that contrasts one (or more) soloists against an orchestra.
Symphony: A piece for the the full orchestral texture.

Structurally, the one thing that all of these types of classical music (generally) have in common is that they have multiple movements (but as with any "rule" there are always exceptions). A movement is a portion of a complete work which is able to stand on its own: it is (usually) separated from the other surrounding movements by a brief silence, (usually) ends with a satisfactory cadence, (usually) has its own distinct set of themes or motifs, has it's own tempo (or set of tempi), may possibly be in a different key from other movements, and, notably, has its own distinct structure. For the vocal works listed above, the movements will commonly consist of Recitatives (short declarative, narrative-like sections of almost sung-speech), Arias (lyrical songs with instrumental accompaniment), and Choruses. For the instrumental works, the movements will often be labeled for the mood that they are convey, which may be a tempo indication (Allegro, Adagio, etc...), some type of desired emotional effect (Maestoso), or another type of music with a similar mood (Minuet, Alla marcia). The important thing to realize is that each movement will have its own form or structure.
So now lets talk about form. Musical form is built around two contrasting techniques: Repetition and Contrast. That is, a piece's structure can often be defined in terms of which parts of it are repeated (and when) versus when new, contrasting parts are introduced. Repetition need not be exact -- Variation is an important element of music as well. Musical structures are often denoted with a series of capital letters, where a repeated theme is denoted with a repeated letter.

Free Form:
There is no repetition, just a sequence of unrelated ideas:
ABCD...
Theme & Variations:
There is a single musical idea, repeated, but varied each time (note: variations are sometimes denoted by one or more apostrophes after a letter): AA'A''A'''. Example: Mozart's Variations on "Ah, vous dirai-je, Maman". Note that in this example, the theme and each variation is individually in rounded binary form (described below). Granted, the Mozart example is somewhat broken up, with each variation as its own thing (which is often the case for this form). A better example of how a theme & variation can be used to unify the structure within a single piece might be Bach's Passacaglia in C minor. In this case, the theme is a bass line which gets constantly repeated throughout the work (which is not dissimilar to how some modern forms of electronic music get built), and the variations are usually in the upper voices.
Binary Form:
In Binary Form, there are two contrasting ideas: AB. Often, each segment will be repeated: AABB. A variation of this, called Rounded Binary Form, ends the B section with the material from the A section, so with repeats, it might look like: AABABA. This is similar to Ternary Form. Pretty much every dance form from the Renaissance, Baroque, and probably Classical Eras will have some type of binary or rounded binary layout, and there are very many types of dance forms (Allemandes, Sarabandes, Courantes, Bourees, Gavottes, Minuets, Gigues, etc...).
Ternary Form:
Ternary Form contains two contrasting ideas, but the initial idea returns at the end: ABA.
Da Capo Aria:
Initially very common in Baroque arias, but later in instrumental music as well. This is essentially an application of ternary form. The aria will have an initial section, then a second contrasting section (likely in a different key, and with a different mood), followed by the instruction "Da Capo al Fine", which means to go back to the beginning, and play through to the "Fine" ("fee-nay" = finish) which marks the end of the first section. This form gave rise to the wildly popular Sonata Form. Example: "The Trumpet Shall Sound" from Handel's Messiah.
Sonata Form:
This is a very widely used form, and there is a previous question here about it. It is used quite often in the first movement of symphonies, concerti, and (unsurprisingly) sonatas, and can be seen as an elaboration of Ternary form. The initial section is called the Exposition; it introduces a Primary Theme (A), as well as a contrasting Secondary Theme (B) in a different key. The Exposition is often repeated. The middle section is called the Development, and it typically breaks down the themes into individual elements, and recombines them in different ways. The final section is called the Recapitulation, and it restates the original two themes, but in the same final key. They may be followed by a closing Coda. A full Sonata Form may look something like this: (Intro)(AB)(AB)(C)(AB)'(Coda). Example: Beethoven's 5th Symphony (1st movement only).
Rondo Form:
There is one main theme that is repeated frequently, interleaved with multiple supporting ideas (which may or may not repeat): ABACADA... This is often used for another one of the movements in a sonata or symphony. Example: Beethoven Piano Sonata No. 8 "Pathetique", 3rd movement
Ritornello Form:
Often seen in Baroque concerti. This describes an alternation of textures between tutti (full orchestra) and solo. Each tutti section is called a ritornello and is usually based on the same initial set of musical ideas (or some variation of them), while the solo sections, sometimes called episodes, tend to be more independent. This can be seen as somewhat similar to a rondo, but ritornellos are typically allowed more variation or development between entries than the main theme of a rondo. Example: Bach Brandenburg Concerto No. 5, 1st movement.
Fugue:
A somewhat technical form involving specific contrapuntal techniques and textures. A fugue involves a main theme called a Subject which enters separately in different voices at different pitches. There may be a Countersubect as well. A fugue opens with an Exposition, during which time all voices initially enter with the subject. After this, there will usually be additional subject entries separated by Episodes of more free counterpoint, which may or may not be based off of the subject material. Usually, the subject will undergo various forms of contrapuntal transformations, such as inversion, augmentation, diminution, and stretto. In the Baroque, it would not be uncommon for an entire movement of a work to be written as a fugue, but later, the technique is often confined to just a portion of a movement. Example: Bach's "Little" Fugue.

Note that this list is by no means complete, but it should cover the basics. There could be whole books written about some of these forms (Sonata Form and Fugue can be especially involved). Also note that structures can be hierarchical, or nested. A movement may have an overall ternary form, but each of the subsections might itself be in binary form. Or there may be a concerto movement in a ritornello form, in which each ritornello is a fugal entry. Or in the case of the Mozart above, you have a series of variations, each in rounded binary form.
Answer: It depends what kind of type you aim, because classical music can be very different in its structure and form.
Caleb Hines already posted a very detailed list about the forms. My answer is only an introduction and might not be suited perfectly for your question, but should give you a basic understanding about classical music.

Sonata

Sonata form is characterized by tonal movement and consists of an
exposition, development and recapitulation section. Sonata form is
used in most first movements of sonatas and symphonies. It is
considered the most important principle of musical form.
In the "Classical" period, the title "sonata" is typically given to a
work composed of three or four movements. Often sonata form refers
just to the structure of an individual movement. Outline of sonata
form

Sonata-form, otherwise known with similar inaccuracy as first movement form or sonata-allegro form, developed during the second half of the 18th century as a principal form in instrumental music, from Haydn onwards.
Structure of the Sonata:

Introduction -In music, the introduction is a passage or section which opens a movement or a separate piece. In popular music this is often abbreviated as intro. The introduction establishes melodic, harmonic, and/or rhythmic material related to the main body of a piece.
Exposition - The exposition is "the very first major section, incorporating at least one important modulation to the dominant or other secondary key and presenting the principal thematic material."
Development - The development generally starts in the same key as the exposition ended, and may move through many different keys during its course. In this process, certain central ideas are repeated in different contexts or in altered form so that the mind of the listener consciously or unconsciously compares the various incarnations of these ideas. Listeners may apprehend a "tension between expected and real results", which is one "element of surprise" in music.
Recapitulation - The Recapitulation is an altered repeat of the exposition
Coda - Codas may be quite brief tailpieces, or they may be very long and elaborate. Main purpose of the Coda is to bring a piece to an end. A famous example for an extended coda is the one to the first movement of Beethoven's Eroica Symphony (no. 3 in E flat).

Sonata sample: Sonata No. 1 in F Minor, Op. 2 No. 1 - I. Allegro

Symphony

A symphony is a musical composition usually for orchestras. Many
symphonies are tonal works in four movements with the first in the
sonata form, and this is often described by music theorists as the
structure of a "classical" symphony.
The opera sinfonia, or Italian overture had, by the 18th century, a
standard structure of three contrasting movements: fast; slow; fast
and dance-like. It is this form that is often considered as the direct
forerunner of the orchestral symphony. The terms "overture",
"symphony" and "sinfonia" were widely regarded as interchangeable for
much of the 18th century.

The Italian overture opens with a fast movement, followed by a slow movement and a final fast dance-movement in triple metre. The function of the symphony as an overture continued into the second half of the 18th century, to be replaced more generally by its new function as an isolated orchestral form.
The classical symphony of Haydn and Mozart is generally in four movements, opening with a sonata-form allegro, followed by a slow movement, a minuet and trio and a rondo finale.
With Beethoven the symphony grew in size and ambition, an example followed later by Brahms, Bruckner and others. In the 19th century and into the 20th century the symphony, now much expanded, remained the most respected and demanding form that a composer might tackle. A symphony may loosely be defined as an orchestral composition generally in several movements.
Symphony sample: Symphony No. 8 in F Major, Op. 93 - I. Allegro vivace e con brio

Concerto

The term concerto usually refers to a musical work in which one solo
instrument is accompanied by an orchestra. The concerto arose in the
Baroque with the concerto grosso, which contrasted a small group of
instruments with the rest of the orchestra. While the concerto grosso
is confined to the Baroque period, the solo concerto has continued as
a vital musical force to this day.

The Baroque concerto

In the late 16th century there was often no clear distinction made
between a concerto and a sinfonia. Both of these terms were even used
throughout the 17th century, in Italy, to describe vocal music with
instrumental accompaniment; Giovanni Gabrieli published motets using
either of these terms indiscriminately.
Starting at about 1675, composers started to write works for divided
orchestra, often called concerto grosso. The smaller division, which
was effectively a group of soloists, was referred to in these works
as the concertino and the accompanying instruments were called the
ripieno, while tutti was used to indicate the two groups playing
simultaneously.

The Classical concerto

The concertos of Bach's sons are the best links between those of the
Baroque period and those of Mozart. Bach's keyboard concertos contain
some brilliant soloistic writing. Some of them have movements that
run into one another without a break, and there are frequent
cross-movement thematic references.

Mozart, as a boy, made arrangements for harpsichord and orchestra of
three sonata movements by Johann Christian Bach. By the time he was
twenty, he was able to write concerto ritornelli that gave the
orchestra admirable opportunity for asserting its character in an
exposition with some five or six sharply contrasted themes, before
the soloist enters to elaborate on the material. He wrote one
concerto each for flute, oboe (later rearranged for flute and known
as Flute Concerto No. 2), clarinet, and bassoon, four for horn, a
Concerto for Flute, Harp and Orchestra, and a Sinfonia Concertante
for Violin, Viola and Orchestra.

It is conventional to state that the first movements of concerti from the Classical period onwards follow the structure of sonata form. Final movements are often in rondo form, as in J.S. Bach's E Major Violin Concerto.
Concerto sample: Concerto in A Minor, Op. 102 'Double Concerto' - I. Allegro

Etude
An étude (a French word meaning study) is a short musical composition designed to provide practice in the performance of a solo instrument. For example, Frédéric Chopin's étude Op. 25 No. 1 trains pianists to play rapid parallel thirds.
The études that are most widely admired are those which transcend their practical function and come to be appreciated simply as music. For example, Chopin's études are considered not just technically difficult, but also musically very powerful and expressive.
Etude sample: Étude No. 1 in A Flat Major, WoO

Overture
An overture (from the French word, ouverture, meaning opening) in music is the instrumental introduction. It is frequently an opening to a larger dramatic work such as an opera. Earlier usage of the word also referred to collections of movements, known as suites. Later works, such as Beethoven's overture Leonora No 3 mark a transition between the concept of overture as introduction to a dramatic entertainment, and musical forms such as the symphonic poem, which are work .
Overture sample: The Marriage of Figaro - Overture
Answer: If by "classical music" you mean the music before the second half of 20th century then there's not an easy answer for your question...
While, if you mean music of classical period, I think you should give a look to the Sonata Form.


GPResult error The user does not have RSoP data fails as Domain Admin

Question: Is there a way to get gpresult to work without never logging in to computer as an actual user?
Lets say UserA is logging in to computer XYZ. You login via TeamViewer to it or are there locally as AdminA, you right click Run As Administrator, type in your administative credentials you type in the famous gpresult /R command to get computer GPO's and it's simply not there.
gpresult /R
INFO: The user adm.test does not have RSoP data.

You try to do it remotely and it fails as well...
gpresult /S DDD9D5 /SCOPE COMPUTER /R
INFO: The user does not have RSoP data.

How to force it so you can actually get that data as Domain Admin or Administrator on that computer (but not a user) and a user that has never actually logged in to that computer?
For years I thought this was just "working" but it seems I've always been logged in to the computer via RDP or other means and it always worked. Now it doesn't... and I need a way to debug this properly.
Is my only option actually to login as standard user and then do the commands?
Comment: Looks like the correct way to do this is to not even use `gpresult` at all, but to use powershell, including `Get-GPResultantSetOfPolicy`. See: https://social.technet.microsoft.com/Forums/ie/en-US/fcee40ef-85e9-4abe-b0a5-d9a0555c5a23/running-gpresult-remotely-only-for-computer-policies?forum=winserverGP
Answer: Yes, it can be done without doing a interactive login, although you need to know a user that has actually done an interactive login on that computer. In your case, UserA would do it. Then, from an elevated prompt:
gpresult /user UserA /scope computer /r

Also, from a remote computer:
gpresult /s RemoteComputer /user UserA /scope computer /r

I really don't get why you need to specify a user when using /scope computer, but this is how it works...
Comment: @curropar

I think the piece you're probably missing -- and I'm going on experience here -- is loopback policies. thus the reason for the need to specify a user. Sometimes the user policies are superseding the computer settings because of such a configuration of your group policy object(s). Remember the purpose of RSoP is to generate the resulting set of policy as it would be evaluated, rather than simply a list and show you the "winners".
Comment: It's the other way around: user policies override computer policies, except when there's a loopback policy. So RSoP of the computer makes sense in terms of getting the base configuration. Then of course, user policies will apply, and those policies will depend on the OU of the user, but that's a step further.
Comment: I always thought if you write /user UserA it would ask for user credentials. That's nice to know. Thanks
Comment: Me too; but you know, I was in the same position as you and trial error lead me to this ;-) Glad to help!


How can I remove a theme that is no longer in core?

Question: Drush/Drupal 8 is throwing errors because a theme is 'enabled' that is 'missing'. The theme is/was part of core (test_stable), and I'm having difficulty getting it to uninstall.
I understand that the theme code needs to be there in order to uninstall, but this being core makes that difficult. I can manually place the module there locally, but would need to create a patch to actually have it installed (and then uninstalled) on the remote environments via composer.
The "Module Missing Message Fixer" module addresses this scenario with modules, but not themes.
I'm pretty sure enabling this theme in the first place was an accident. I'm hoping someone can help me determine if there is a way to do this w/out creating a patch that installs this old theme.
Comment: Does this answer your question? [How to solve the "The following module is missing from the file system" error?](https://drupal.stackexchange.com/questions/245731/how-to-solve-the-the-following-module-is-missing-from-the-file-system-error)
Comment: It is helpful information.  Thanks.  Given the way things are deployed, the answer by @miststudent2011 was a good fit.
Comment: @MichaelBopp on a side not have you ran all the pending updates ?
It seems test_stable theme is removed after Drual 8.7.x as that file is not present in latest versions.
https://api.drupal.org/api/drupal/core%21modules%21system%21tests%21themes%21test_stable%21test_stable.theme/8.7.x
Before proceeding with m suggestion below run `drush updbst` and check for pending updates.
Answer: You can create a theme calling it test_stable. Then, you clear the cache with drush cr and uninstall the theme with drush theme:uninstall test_stable. It will solve your problem.
You don't need to create the whole theme; the test_stable.info.yml file is sufficient for Drupal to recognize the theme as present.
As the test_stable theme has been removed from Drupal after Drupal 8.7.x, and that file isn't present in latest versions, before proceeding with what I suggested, I would run drush updbst and check for pending updates.
Answer: I had this issue :

The base theme stable cannot be uninstalled, because theme classy
depends on it.

I solved it without install a fake theme. I simply executed these 2 Drush Commands :
drush theme-uninstall classy

drush theme-uninstall stable


Why is it that most piano students are taught to only play a piece in one key?

Question: Learning to play a tune/piece in only one key is a very popular piano method. People learn in different ways but I find that I get a lot of understanding when I practice it in other keys as well. Transposing is very important to me. I analyse and feel the music when I transpose it. Standard piano lessons never really works for me. I want to understand the music I play.
Why is it that most piano students are taught to only play a piece in one key?
Comment: Like others here, I don't really understand what's added to your understanding of a piece by transposing it.  All the pitch relationships are present in any one key, no information about the piece is added by playing in a different key. The facility of being able to play in more than one key, as Todd noted, is important for jazz and studio musicians, and many others, but no information about the structure or feeling of the piece is added, as far as I can see.
Comment: Interesting. Maybe not just confined to piano, but could encompass most, if not all instruments. Originally, years gone by, sheet music was only available in one key?
Comment: What new information do you actually get from transposing something though? Ultimately it should be pretty mechanical. If it works for you then obviously keep doing it, but you haven't really justified why it's worth spending lesson time on, especially when most students' aim will be to "play the piece".
Comment: Probably because the piece was written in that key and they want to play it in its "original form"?
Comment: I'm currently working on a piece by Ligeti where you couldn't transpose it down at all and only up  by a minor third at most because the range of the piece is from the lowest key in the piano to the highest A on the piano.
Comment: I don't exactly agree. When playing with a singer (art songs), transpositions are frequently needed, the transposed sheet music is even printed.
Answer: I think it depends on what you're going to do with the piece. Personally, if I had time to learn the piece in more than one key then I think I should have chosen a more difficult piece.
It might take me 3 - 18 months to learn a piece. After that, I'd rather learn something else than learn to play the same piece again in a key different from the composers original intent.
But, I mainly play classical piano. Accompanists for musical theatre, jazz pianists, and some other genres quite often are asked to sight read songs and transpose on the fly. Those professionals aren't exactly learning pieces in different keys, they are just playing them in a different key. If you would like to play like that then there's nothing wrong with learning the same piece in multiple keys and/or learning to transpose on the fly.
In the classical world, the key in which a piece is written is an important, intentional choice. I've never heard of a classical work being professionally performed in a key other than the one it was written in, although I expect it may have happened from time to time.
And now I'm reminded of a slight contradiction to my first paragraph, which is that I'm currently learning the jazz standard "Autumn Leaves" in a different key from what it was written in to make it easier for me to play the melody on clarinet (for which I'm only a beginner).
So in summary: in the classical world, transposing pieces is rare, probably because that would make it a different piece (in the classical mind). In the musical theatre and jazz genres; transposing is very common, but often the pieces are not learned in different keys, merely transposed on the fly (an important skill). In pop and rock transposing happens for covers and less commonly originals. For example, as Ozzy Osbourne has aged, he has lost his ability to hit some high notes, so some of his most popular songs, like "Crazy Train" have been played in a lower key in live shows.
Comment: "I've never heard of a classical work being professionally performed in a key other than the one it was written in, although I expect it may have happened from time to time."  It's not common for piano solo, but quite common for vocalists.  For example, lots of 19th century Lieder are often even published in different keys for different voice parts, and lots of classical singers perform transposed versions (obviously with the transposed piano accompaniment).
Comment: The classical side is an important mention - most pieces *are* played in their original key. 'Play Fur Elise in Bbm'... what? Which makes me wonder *why* certain pieces *were* written in certain keys, when other keys would have done the job - maybe better. But transposing jazz classics and others to help transposing instruments, or just for fun/challenge is fair game. Although you may fall into the trap of only being able to play Autumn Leaves in a key that most people aren't used to  playing it in! Enjoy it - I always do - and it's probably appropriate to play it at this time of year too...!
Comment: I think in classical music the key may change in arrangements.
Comment: @Tim During the baroque, classical, and romantic periods, because of keyboard temperaments not being equal, different keys sounded different. So that of course is a motivator for the composers to have chosen the keys they did. There's a recent question on this site about whether keys still sound different in ET, and one theory is they have attained cultural differences due to associations with works written in specific keys. Certainly most classical musicians and listeners find the key of a piece to be an important aspect that shouldn't be changed expect in special cases.
Comment: you learn how music works by transposing. I do but perhaps you don't.
Comment: @Tim - The piano is a fairly uniform instrument, but most orchestral instruments have subtly different tone colors in different keys, and also they have a more limited range which is used fully, so that transposing would require a note not playable on the instrument.  The most interesting use of tone color I know is the Mozart Sinfonia Concertante in E-flat, where everyone is tuned normally except for the solo viola being tuned up a half step, so that the solo viola is the only instrument playing on open strings and therefore has a slightly more resonant and prominent sound.
Comment: how do you learn a piece by only playing it in one key? I find it to be a difficult method for me. How does this method work? It is really interesting to read about people who can actually learn piano this way. I need to look at music from different prespective. Perhaps I am a very special person. Normally people are super good at just repeating note from a score.
Comment: @Hank I can't understand the question of how to learn a piece in "only" one key. Surely learning a piece in more than one key involves learning the piece in one key and then learning it in another key. So if you know how to learn a piece in multiple keys then you also know how to learn a piece in only one key.
Comment: @Hank - most of the pop type stuff - jazz standards, etc., I play in any key, on guitar, bass or keys. Not learning from the dots/charts, but by listening, and transcribing by ear - not on paper. That's maybe very different from what you are considering - the geography of a piece is 'in my head'. If you're considering transcribing note for note of written pieces into various keys, it's a rather different situation. Some will learn verbatim, and I agree it may not be the best. Like being able to quote in a foreign language, not knowing what it actually means, but it sounds (and is) correct.
Comment: @Tim I do find it very difficult to just "learn verbatim". for me understanding is the key. Sure I don't need to understand everything but at least some understanding. I seldom memorize poetry with understanding anything about it.
Comment: @Hank I think gaining understanding through transposition might be something that works better for you than for others. I have no issues understanding pieces without transposing them.
Comment: Little known fact: you also learn phone numbers by adding or subtracting the same number for each digit. Transposing is no different.
Comment: The first published edition of Schubert's Impromptu D899 no 3 was printed in G instead of G flat for some reason - perhaps the publisher had an aversion to flats? I don't know if this version was ever performed.
Comment: Some classical pieces do exists in multiple keys.  There's a Bach concerto for two violins which also exists in a version for violin and oboe.  They are in different keys.
Answer: To my knowledge, most piano lessons (at least ones given to children) are oriented around playing classical music. For classical music, playing according to the written score is important, and deviations from the score are treated as mistakes.
As Todd Wilcox mentions in his answer, keys of classical music pieces are chosen intentionally. The notion that a classical piece of music must have an overarching key is so important that they are often labelled with their single key each in their name (e.g. "Minuet in G Major", "Symphony No. 5 in C Minor, Op. 67"). Entire cycles of preludes and etudes have one piece in each of the major and minor keys - changing the key of any one of these pieces is seen as sacrilege.
Sheet music isn't cheap. As illegal as all my piano books said the practice was, all my piano teachers photocopied my repertoire and gave the photocopies to me. I strongly suspect my piano teachers were not alone. I don't think they're about to bust sheet music transposing my repertoire.
One more note: piano repertoire for young children is often in keys with few accidentals such as C Major, F Major, and G Major, probably for readability's sake. Good luck convincing piano teachers to change the keys of those.
Comment: @Tim As a Beethoven fan, I know Werkmeister III better than any other historical tuning. In WIII, it's not that some keys sound good and some sound bad, it's that they all sound different. D major sounds happier. C# minor is dark, dark, dark and disconcerting. Playing some Beethoven in the same tuning he wrote in is very enlightening.
Comment: You're right in all you say.What I don't understand is a composer writing in, say, a harpsichord, just intonated to play in a certain key, trying to write a piece in a different key. It would sound more odd than writing in the key tuned properly, surely? Unless, for instance, Mozart had his harpsichord or piano tuned in G (JI) for 'Minuet in G'. Were it tuned so Eb was JI, it would sound odd, wouldn't it?
Comment: @ToddWilcox - I'll check if one of the keyboards has WIII, and try it. Maybe Mozart et al didn't have the same luxury with harpsichords.
Comment: @Tim the problems of JI on keyboards was well known by the baroque era if not earlier. So very little if any of the keyboard music of the common practice period was written for JI. I believe in Bach's time 1/4 comma mean tone was a common temperament. I don't know if Mozart favored a tuning or what it was. I wonder if conductors asked for intonation adjustments from orchestras to try to get the sounds they had on their home keyboards or not.
Comment: mistake? that is just stupid.
Answer: Like you, I have a hard time getting something to work properly without a deep knowledge of exactly how it works. My driving teacher spent hours repeatedly explaining the sequence of steps required to drive a manual transmission and I just couldn't get it. Later, when I looked up the internal mechanics of exactly how a manual transmission works, it immediately clicked and I could suddenly drive a manual without issue.
So I too have an insatiable need to understand exactly what (and why) I am playing in order to play it properly. When I decide to learn a new piece, I carefully analyze each chord and passage, trying to internalize the technical structure and decipher the composers original intent. I also take time to gain an understanding of why exactly the composer chose the key that they did; oftentimes this also involves some study of why they didn't chose certain other keys.
This often comes down, largely, to fingering and technique. As you get into more advanced pieces, certain keys just don't make sense and may be nearly impossible to play. At the end of the day, classical composers had a very deep understanding of music and their choice of key was not arbitrary. Figuring out why a piece is in a particular key may well give you more insight and understanding than figuring out how to play it in other keys.

Now, to actually answer your question: why are piano students taught to only play songs in one key?
The main point of piano lessons is to learn proper playing technique, not music theory. Naturally, some theory must be taught, but it is usually secondary and supportive. If additional knowledge of theory is desired, one must seek out other sources, like online tutorials, music theory dictionaries, college courses, or this site (obviously).
(Alternatively, you can do what I did and try to find a teacher that loves theory as much as you do so you can lure them into spending the entire hour session in a deep theory dive! That is, until your parents find out that you have been spending most of your lessons chatting and not actually playing anything, so they get mad at your teacher who explains to them that you are "advancing" into jazz improvisation for which you need a solid foundation of music theory, after which your sessions are split between discussing theory and screwing around on the piano...yup, he was by far my favorite teacher!)
The ability to transpose, either in advance or on the fly, is a practical application of music theory, not a physical skill. A steady progression of the student's skill and ability is the closest thing a piano teacher has to a deliverable "product", and is therefor the easiest way to demonstrate to the student (or their parents) that they are getting their moneys worth.
Lastly, as alluded to before, most pieces, especially more advanced ones, are intentionally written in a key that provides a stable structure for proper technique. For example, pieces that require the thumb to frequently pass under the other fingers are often written in keys with lots of sharps/flats to make this motion easier and more fluid. Practicing it in a different key can make it more awkward to play, and can even result in picking up bad habits, negatively impacting the advancement of technical skill, thereby undermining the very reason for taking lessons in the first place.
Comment: Beyond keys of pieces in a multi-movement work being related to each other, keys with many accidentals in their key signature being avoided in earlier times due to the desire to not change keyboard tunings so often, and arrangements mirroring the key of the original, I actually get the impression that keys of single-movement absolute music works are chosen arbitrarily (a la "because that's what the composer thought of first"). Can you provide any examples where the keys of those were purposefully chosen?
Answer: To give a counter-example, The Russian School of Piano Playing encourages teachers and students to introduce transposition right from the beginning:

"From the outset of musical training it is important that the pupil be
taught to transpose. Such exercises promote the development of ear,
memory and keyboard orientation."

As a specific example, on piece number 20, a simple one-line melody piece, the instruction says:

"The pupil should play the exercise in different keys […]."

So I would conclude that there is at least one piano school which recognizes transposition as an important concept of piano lessons.
Comment: Suzuki method also includes transposition.
Answer: Your question seems to telegraph the expected answer: the teaching is focused on recitals and advancing through graded methods. That kind of teaching isn't concerned with understanding why things happen in music.

EDIT
I wasn't going to add this initially, but there seems to be a lot of interest (disagreement) on this topic of transposing.
Recently I started working on Bach's Two Part Invention in C Minor and I simply did not want to memorize it. I've done that before with other music, and eventually I forget the stuff.
I decided to take most of the expository material and break it up into two beat units which I then practiced by sequencing the stuff up and down by step. I also inverted the parts between the hands. I made myself a sort of shorthand score of what I was doing, like this...

...the double notes at the end of phrases are supposed to show the continuation by sequence up/down. Fingerings above/below are RH/LH depending on how the hands invert. I don't expect anyone else to read this, but I think the basic idea should be clear enough.
Now I've moved on to playing each hands separately, but I play it in various keys. The music itself modulated up a fifth so you can just repeat the exposition and keep going around the circle of fifths. After working through a few keys and getting used to the changing "topographical" feel it seems I can play it in any key comfortably without practice.
I'm not done with the piece yet, and certainly this take more time than just memorizing it in C, but I definitely feel like I'm learn much, much more this way. My hands move more freely and I better understand the actual tonal content of the music.
At the very least, you aren't the only person that thinks transposing is a useful study method.
Comment: @Hank I understand music just fine when looking at it in its original key. This isn't a good platform to try to convince us that we should be learning pieces in multiple keys just because that works well for you.
Comment: @Hank sounds like you might want to look at finding a piano teacher who suits you better.
Comment: @ToddWilcox - don't think OP is trying to convert anyone. Just looking for justification as to why (some, or most) piano teachers don't use that as one of their tools. Should a student of mine request it, I'd embrace the idea. It's just another piece in the armoury, isn't it? (For certain students).
Comment: I don't think the reason is that teaching isn't concerned about understanding the music. It's rather that it's often focused on performing, rather than creating, composing or improvising.
Comment: Transposing will present fingering challenges that _are_ applicable in other situations. The techniques used to solve the challenges apply principles to understand and reuse. And it's really the same issue as the OP, you don't just execute fingerings, you understand _why_ they are used. A good way to test whether you have that knowledge of principles is transposing. It may not make sense for every piece, like the "Minute" Waltz. But that's just recital memorization. There is a reason why people post questions here about being able to play recitals but can't improvise or sight read.
Comment: how do you learn to play music without understanding it? I can't do it so I would like to know how it works for people.
Comment: Why would anyone want to play without understanding?
Comment: piano teachers often want student to become like robots. This is the issue for me.
I guess there are tricks you use so that you never need to learn music by playing by ear.
Comment: You're probably correct here, sadly. It's the way a lot of piano teachers work - just learn the piece, play it for the exam, don't 'waste time' with trying to understand it.
Comment: @user1079505, that is just another way of describing the problem: train performances while neglecting other important musical skills. Can you imagine if art students were taught only to create reproductions? No sketching from life, no self portraits... just copy the Mona Lisa, etc.
Comment: It's true that it's useful to know about (say) ABA, rondo or sonata form before learning a piece in that form. However, I don't see how learning a transposition of the piece would help. You need to gain muscle memory for the *actual* notes you'll play when performing it in its *correct* key. Learning say Chopin's "Minute" Waltz in D instead of D flat entails fingering passages you'd never actually play, that is, solving problems whose solutions you'd never need.
Answer: I don't think that this depends so much of the education level of teachers or the education system like Stretto says. But theres some truth in it, there are actually teachers - generally - who are good in just one subject and transport their knowledge without seeing behind the horizon.
There would be great benefit in the task to transpose a piece in other keys. (But this shouldn't be done by just using the same fingersettings and moving the hand some intervals up or down.)
I'm convinced that a didactic of more experience in transposing would help a lot for better understanding a piece and playing music in general.
Why doesn't this happen?
Because any other method wouldn't fit with the expections of the students, their parents who probably pay the lessons and also the teachers themselves.
The goal of most people is to learn as many pieces as possible in a short time, and not the goal of seeing through and internalizing fully a piece.
And not every teacher would be able to control whether the student is playing correctly.
Of course there are other points like the key characteristics, the respect of the authority of the composer, the availability of sheet music in other keys, the lack of fantasy or insight of the benefit of transposing, improvising and transfer learning!
But the main problem seems to me that people want to reach a goal direttissima and don't see that there would be a short cut what looks like detour at first sight.
A good piano teacher should apply different approaches and use a large variety of methods: transposing, formal analysis, improvising, comparing pieces are just some. A lot of this happens unconsciously. What is unconscious should become aware.


Custom Link function works for GLM but not mgcv GAM

Question: Apologies if the answer is obvious but I've spent quite some time trying to use a custom link function in mgcv.gam
In short,

I want to use a modified probit link from package psyphy ( I want to use psyphy.probit_2asym, I call it custom_link )
I can create a {stats}family object with this link and use it in the 'family' argument of glm.
m <- glm(y~x, family=binomial(link=custom_link), ... )
It does not work when used as an argument for {mgcv}gam
m <- gam(y~s(x), family=binomial(link=custom_link), ... )
I get the error Error in fix.family.link.family(family) : link not recognised

I do not get the reason for this error, both glm and gam work if I specify the standard link=probit.
So my question can be summarized as:
what is missing in this custom link that works for glm but not for gam?
Thanks in advance if you can give me a hint on what I should do.

Link function
probit.2asym <- function(g, lam) {
    if ((g < 0 ) || (g > 1))
        stop("g must in (0, 1)")
    if ((lam < 0) || (lam > 1))
        stop("lam outside (0, 1)")
    linkfun <- function(mu) {
        mu <- pmin(mu, 1 - (lam + .Machine$double.eps))
        mu <- pmax(mu, g + .Machine$double.eps)
        qnorm((mu - g)/(1 - g - lam))
        }
    linkinv <- function(eta) {
        g + (1 - g - lam) *
         pnorm(eta)
        }
    mu.eta <- function(eta) {
        (1 - g - lam) * dnorm(eta)      }
    valideta <- function(eta) TRUE
    link <- paste("probit.2asym(", g, ", ", lam, ")", sep = "")
    structure(list(linkfun = linkfun, linkinv = linkinv,
    mu.eta = mu.eta, valideta = valideta, name = link),
    class = "link-glm")
}

Answer: As you may know, glm takes iteratively reweighted least squares fitting iterations. Early version of gam extends this by fitting an iteratively penalized reweighted least squares, which is done by the gam.fit function. This is known as performance iteration in some context.
Since 2008 (or maybe slightly even earlier), gam.fit3 based on what is called outer iteration has replaced gam.fit as gam default. Such change does require some extra information of the family, regarding which you can read about ?fix.family.link.
The major difference between two iterations is whether iteration of coefficients beta and iteration of smoothing parameters lambda are nested.

Performance iteration takes the nested way, where for each update of beta, a single iteration of lambda is performed;
Outer iteration completely separate those 2 iterations, where for each update of beta, iteration of lambda is carried to the end till convergence.

Obviously outer iteration is more stable and less likely to suffer from failure of convergence.
gam has an argument optimizer. By default it takes optimizer = c("outer", "newton"), that is the newton method of outer iteration; but if you set optimizer = "perf", it will take performance iteration.

So, after the above overview, we have two options:

still use outer iteration, but expand your customized link function;
use performance iteration to stay in line with glm.

I am being lazy so will demonstrate the second one (actually I am not feeling too confident to take the first approach).

Reproducible Example
You did not provide a reproducible example, so I prepare one as below.
set.seed(0)
x <- sort(runif(500, 0, 1))    ## covariates (sorted to make plotting easier)
eta <- -4 + 3 * x * exp(x) - 2 * log(x) * sqrt(x)   ## true linear predictor
p <- binomial(link = "logit")$linkinv(eta)    ## true probability (response)
y <- rbinom(500, 1, p)    ## binary observations

table(y)    ## a quick check that data are not skewed
#  0   1
#271 229

I will take g = 0.1 and lam = 0.1 of the function probit.2asym you intend to use:
probit2 <- probit.2asym(0.1, 0.1)

par(mfrow = c(1,3))

## fit a glm with logit link
glm_logit <- glm(y ~ x, family = binomial(link = "logit"))
plot(x, eta, type = "l", main = "glm with logit link")
lines(x, glm_logit$linear.predictors, col = 2)

## glm with probit.2asym
glm_probit2 <- glm(y ~ x, family = binomial(link = probit2))
plot(x, eta, type = "l", main = "glm with probit2")
lines(x, glm_probit2$linear.predictors, col = 2)

## gam with probit.2aysm
library(mgcv)
gam_probit2 <- gam(y ~ s(x, bs = 'cr', k = 3), family = binomial(link = probit2),
                   optimizer = "perf")
plot(x, eta, type = "l", main = "gam with probit2")
lines(x, gam_probit2$linear.predictors, col = 2)

I have used natural cubic spline basis cr for s(x), as for univariate smooth the default setting with thin-plate spline is unnecessary. I have also set a small basis dimension k = 3 (can't be smaller for a cubic spline) as my toy data is near linear and big basis dimension is not needed. More importantly, this seems to prevent convergence failure of performance iteration for my toy dataset.
Comment: Thanks a lot for your answer. Using the performance optimizer is the easy answer to the question. I will study this outer iteration that I did not know was the new standard (apparently skipped this section while reading the simon wood r book).
For now, I will empirically explore if this no longer default optimizer impairs the fitting performance and convergence for my problem and will report my findings here. I might extend and share the links to work with the outer iteration.


grep to IP address when IP address in parameter

Question: I need to grep to  IP address ( as the following example )
, I use ksh script ,
    #  ifconfig -a |  /usr/xpg4/bin/grep   "100\.106\.2\.120 "
    inet 22.214.171.124 netmask ffffff00 broadcast 18.104.22.168

but how to grep IP address from parameter  ( IP_ADDRESS ) ?

Remark - IP address could be any IP

how to add the back slash in this case
IP_ADDRESS=220.127.116.11 , or IP_ADDRESS=184.108.40.206 ... etc
    #  ifconfig -a |  /usr/xpg4/bin/grep   "$IP_ADDRESS "

Answer: If you are using the bash shell you can Use parameter expansion:
ifconfig -a | /usr/xpg4/bin/grep "${IP_ADDRESS//./\\.}"

If your shell doesn't support this type of parameter expansion, you could use shell expansion instead, e.g. with sed:
ifconfig -a | /usr/xpg4/bin/grep `echo $IP_ADDRESS | sed 's/\./\\./g'`

or perl:
ifconfig -a | /usr/xpg4/bin/grep `echo $IP_ADDRESS | perl -pne 's/\./\\./g'`

Comment: I use the ksh shell not the bash shell
Comment: @yael: many versions of ksh also support this type of parameter expansion.
Comment: my ksh not support it  - # ifconfig -a | /usr/xpg4/bin/grep "${IP_ADDRESS//./\\.}"
ksh: "${IP_ADDRESS//./\\.}": bad substitution
Comment: @yael: alternatively you could use shell expansion, see edit.


How to self teach myself sheet music reading (for piano)?

Question: I am a self taught pianist, I play mainly by ear and I look for tutorials or synthesia on YouTube. However, sometimes some pieces do not have a synthesia and are really subtle to play by ear (ex. Fides Tua by Tigran Hamasyan). This is why I want to learn how to read sheet music and I ask for your recommendations on how to do so.
My goal isn't to become a really fast sight reader or to understand every single detail on the sheet music, neither to be able to play a piece only by reading the sheet music (and not having listened to it prior to that). Instead I want to use my music reading skills to figure out how to play a piece after I have listened to it.
Also, I wish that you could also recommend me some techniques by which I can teach myself some good amount of music theory !
Comment: Does this answer your question? [How should I teach myself sight-reading?](https://music.stackexchange.com/questions/75646/how-should-i-teach-myself-sight-reading)
Comment: This will likely be closed, as asking for recommendations is not in the remit for this site. Obviously a teacher will be the best option, and there are loads of books on learning to sightread. Knowing where notes are, both on piano and stave is a good start.
Comment: I was going to say you're out of luck and need to learn how to learn music by ear if your main interest is Hamasyan's music, but apparently there *is* sheet music of "Fides Tua" out here (even if only on YouTube videos, and even if it's probably unofficially transcribed by ear by fans). Huh.
Comment: Let the Aaron vs Thompson method book argument begin :)
Comment: Thank you for signaling that Tim ! Could you name me a couple of books you think are good ? Thing is, I am a master student (outside my country)  and with a curriculum this dense I don't find it convenient to work with a teacher (plus it is expensive)
Comment: @Tim Not a request for resources; a request for practice techniques. (Charbel Abetian, please correct me if I'm wrong.)
Comment: @BrianTowers I came here thinking about that, to see if it's a duplicate, but IMO not: The other is "I know how to read music; how do I improve sight reading skill," and this really is "How do I learn how to read music." (Explicitly says "my goal isn't to become a really fast sight reader") And so have very different answers
Answer: Use pencil to write proper note literals (C, D... etc) in the score papers. Use software for sight reading, and stickers for keys. After you will mark a 1000 pages, recognize and mark with a pencil only the altered notes. When you will cope with another 1000 pages I am sure you will read any score better/faster than many conductors. Play guitar and violin scores on piano. Learn harmony/structure pattern recognition and rewrite favorite scores with a pencil and software. Train your ears to recognize sounds and their written appearance. Transpose music to different keys with software and in handwritten way. Hope it helps.
Comment: Thank you for your recommendations ! I want a book or a series of videos in my hand to help me with the learning process. Could you recommend some if possible ?
Answer: As like when you learned to read and write, you need a great deal of exposition to scores and sheet music to read it well after a time.
If you don't read a single note on staff, you can discover the mechanics even on wikipedia. There's plenty YouTube videos on this. It's is fairly easy and straightforward system - but can escalate rapidly to complexity on both rhythms (horizontal axis) and pitches/chords (vertical axis). A little sight-singing along reading training will do a greater good, by the way.
John Mortensen, on his channel, have lots of videos on sight-reading that may be very useful here, even it's not your wish to be an sight-reading beast. Check "cedarvillemusic",

, the second advice: "sight-reading at least 20 min. a day"
You can start with very very easy tunes with only one hand playing from children music books and improve to reach Mikrokosmos vol. 1 (Bartok) and church hymnals or choir books. In 60 days, you will be amazed by how much ability in reading you'll gain.
Answer: On a grand piano there are 88 notes. At first memorizing positions of notes around middle C can help. Later you can start to find relations between intervals. To memorize it you can use a software like Anki. There are lots of shared decks and some of them contain notes on score to memorize it.
Also personally I believe learning sight reading is not such a big effort. As I mentioned before, all you need is 88 positions on grand staff. So don't make it over complicated. Imagine it like learning letters when you were a kid. First they helped you to memorize them and then came the knowledge of "Why?"
Here you can find Anki.
Here are the flash cards
Comment: @Tim I agree. Memorizing note positions to learn sheet music reading is something like suggesting to memorize a dictionary in order to learn a language.
Comment: 88 positions on the grand staff? How (un)helpful is that?
Comment: There's also a significant range of notes that regularly appear in either staff (in principle "all of them" I guess, but in practice maybe an octave or so). So more than 88 things to memoryize
Comment: Alternatively, one could just memorize one position per clef and count from those. Or do something in between, like recognize scales and intervals instead of singular notes.


What is wrong with my custom Entity form validation?

Question: I add
public function validateForm(array &$form, FormStateInterface $form_state) {
}

to MymoduleMyentityForm.php which starts with
namespace Drupal\association\Form;
use Drupal\Core\Entity\ContentEntityForm;
use Drupal\Core\Form\FormStateInterface;

Then I run the form and when I submit it, I get this error: Uncaught PHP Exception Drupal\Core\Entity\EntityStorageException: "Entity validation was skipped." at /Applications/MAMP/htdocs/JdP8/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php line 770
Any idea why?
What am I doing wrong?
Answer: Documentation of ContentEntityForm::validateForm:

Button-level validation handlers are highly discouraged for entity
  forms, as they will prevent entity validation from running. If the
  entity is going to be saved during the form submission, this method
  should be manually invoked from the button-level validation handler,
  otherwise an exception will be thrown.

Even if you don't use button-level validation this should be the cause for the exception. Did you call the parent method?
parent::validateForm($form, $form_state);

If you don't run the entity field validation in some way the exception is thrown.


Como fazer uma operação de subtração entre duas colunas de um dataframe e depois somar o resultado com uma outra coluna?

Question: Tenho este código:
dados_train = pd.read_csv('arquivo.csv', delimiter=",")
y = ((dados_train.pop('col_name1') - dados_train.pop('col_name2')) + (dados_train.pop('col_name2')

Quando eu tento executar só assim:
y = (dados_train.pop('col_name1') - dados_train.pop('col_name2')

Dá certo!
Mas quando tento assim:
y = ((dados_train.pop('col_name1') - dados_train.pop('col_name2')) + (dados_train.pop('col_name2')

Dá erro!
Por que isso acontece? Alguém saberia uma solução?
Answer: Quando você utiliza o pop ele apaga o valor da variável, então na segunda vez que você usa na verdade não há valor nele
você pode fazer assim
y = (dados_train['col_name1'] - dados_train['col_name2']) + dados_train['col_name2']

caso utilize em dicionario, tem a opção do get, não sei se se o dados_train esta recebendo um dicionario, mas se estive pode utilizar assim
y = (dados_train.get('col_name1') - dados_train.get('col_name2')) + dados_train.get('col_name2')

Comment: Obrigado pela ajuda Guilherme! Deu certo!
Comment: Nada, qualquer duvida fique a vontade.
Answer: o método list.pop() remove um objeto da última posição da lista e a retorna ao usuário. Da forma como foi apresentada, acredito que a lista tenha dois elementos apenas.
tente acessar usando colchetes:
y = (dados_train['col_name1'] - dados_train['col_name2'] + dados_train['col_name2'])

Adendo: você se esqueceu de fechar um dos pares de parênteses. Eu o fechei no exemplo, mas esse pode ser o problema na sua aplicação.
Comment: Obrigado Arthur! Bem isto mesmo! Agora deu certo!
Comment: Se a resposta abaixo resolveu o seu problema e não restou nenhuma dúvida, marque-a como correta/aceita ao clicar no "✅" que está ao lado dela, o que também marca a sua pergunta como resolvida. Se ainda te resta alguma dúvida ou gostaria de maiores esclarecimentos, fique a vontade para comentar.
Comment: Você só pode marcar uma resposta como **aceita**, mas, se desejar, pode votar em todas as que achar que solucionaram o problema. Sinta-se à vontade


How to make Drupal 8 use only relative URLs?

Question: I'm trying to get my site to use only relative URLs, like in the question drupal.stackexchange.com/questions/105932
EDIT 3:
It seems like Drupal 8.0.3 and beyond will do this by default:
https://www.drupal.org/node/2650374
But I've changed the code for Drupal 8 to this by getting rid of the deprecated function:
function custom_file_url_alter(&$uri) {
  global $base_path;

  $scheme = file_uri_scheme($uri);

  if (!$scheme || $scheme == 'public') {
    if (!$scheme) {
      $path = $uri;
    }
    else {
      ////$wrapper = file_stream_wrapper_get_instance_by_scheme($scheme);
      $wrapper = \Drupal::service('stream_wrapper_manager')->getViaScheme($scheme);
      $path = $wrapper->getDirectoryPath() . '/' . file_uri_target($uri);
    }

    // Clean up Windows paths.
    $path = str_replace('\\', '/', $path);

    $uri = $base_path . ltrim($path, '/');
  }
}

The problem is, whenever I add even just an article with an image (or any content type with a file in it) I get an error like this: 'Uncaught PHP Exception InvalidArgumentException: "The URI '/sites/default/files/field/image/h.jpg' is invalid. You must use a valid URI scheme." at /srv/www/example/core/lib/Drupal/Core/Url.php line 301, referer: http://example.com/node/add/article. I'm also getting this error when visiting a page that links to certain uploaded files.
The documentation says that this hook is called whenever the file_create_url method is called, but I don't know enough about Drupal to understand what scenario this method is being called which is causing Url.php to get mad at me.  For what reasons does Drupal call file_create_url, and why are almost all scenarios working for me while some are freaking out about no scheme being used?
Any extra information or guidance about this will be appreciated.
EDIT:
Here are some examples of $uri as it comes into the function (1) and as it leaves (2) .
1: 'core/themes/stable/images/core/icons/5181c6/pencil.svg'
 2: '/core/themes/stable/images/core/icons/5181c6/pencil.svg'
 1: 'public://css/css_Ys2L0rGQLjkWZQC7f9g5LiLUni8xUQvB1HqJHn3TKK4.css'
 2: '/sites/default/files/css/css_Ys2L0rGQLjkWZQC7f9g5LiLUni8xUQvB1HqJHn3TKK4.css'
 1: 'public://field/image/h_0.jpg'
 2: '/sites/default/files/field/image/h_0.jpg'
The h_0 example is one that happened after I created an article with the h.jpg image, which crashed and prevented creation of the article.  I've noticed that when I upload the image using the form, the little ajax thing that happens and shows you the preview of the image doesn't work when I use this file_url_alter code.  So, something is trying to call file_create_url when saving the image in the first place, and then, since the image is not properly saved, it can't be added as a field of the node.
Also, I've printed a backtrace, and it seems the crash happens after ThemeManager.php's render function calls template_preprocess_file_link(), which, in file.module, tries to do this:
$variables['link'] = \Drupal::l($link_text, Url::fromUri($url, $options));
...which caused the error I mentioned in the first place.
EDIT 2:
I've made this work by modifying one line of core.  I changed the last line of template_preprocess_file_link() in file.module from $variables['link'] = \Drupal::l($link_text, Url::fromUri($url, $options)); to $variables['link'] = $url;. This makes all URLs relative without any noticeable issues.  Does anyone know how to achieve this without hacking core? Or, does anyone know what negative effects doing this might cause?
Comment: The resulting URI needs to be `public://field/image/h.jpg` if that helps
Comment: Thanks, Clive. Since your comment I've tried returning public:// for public files, and this allows me to create nodes with files, but it stops my URLs from being relative.  If I could just figure out which scenarios require public:// and which don't...  I'll keep experimenting.
Comment: You should handle that on the Form layer and convert the url to the drupal standard before validation/submission.
Comment: The form is already correct, actually. The uri that comes into my hook is already formatted correctly, but for absolute URLs.  When $uri is saved at the end of my function, it is in relative format, but for some reason this doesn't work in some situations.  I believe it's because file_create_url is called in too many unrelated scenarios.  I'll update my question with more info.
Answer: Maybe you can take a look at this function new to Drupal 8 :
file_url_transform_relative()
Once you pass an uri through file_create_url() you get an absolute url. You can then pass it to file_url_transform_relative() and you'll get the relative path if indeed it's pointed to a local file.
Comment: This is the suggested way to obtain it, yes. LinkIt module recently implemented this fix.


Text displaying beside the  element content instead of displaying in new line

Question: I am trying to design a simple ecommerce website, in that my footer tag text is displayed right beside the section tag. I have no idea where I am doing wrong.
HTML

        Categories

Staples

Oils

Vegetables

Fruits

        Bestsellers

                    Cabbage 1

$10

                    Add to Cart

This is footer text

CSS
   #content{
        width:  100% px;
        display: block;
    }

    .carousel_img{
        width: 1000px;
    }

    #headings{
        font-weight: bold;
    }

    #categories{
        float: left;
    }
    #bestsellers{
        float: left;
        margin-left: 25px;
        margin-right: 0 px;
        width: 80%;
        height: 100%;
        margin-bottom: 20 px;
    }

    .background_div{
        background: lightgreen;
    }

    .productarticle{
        float: left;
    }

    .align_text{
        text-align: center;
    }

Please help me. I want the content in section tag and the text in footer tag to be displayed in seperate lines.
JS-FIDDLE DEMO
Comment: Is [this](http://jsfiddle.net/lalu050/n1jjqyga/1/) what you want?
Comment: yes @Lal . Can you please provide the explanation as an anwer ?
Comment: Please see my answer for explanantion @Sai
Answer: See this fiddle
Since your #content contains of floated elements, you also need to float the #content div. Thus add a float:left; to #content.
Now to clear this float effect from the footer, you need to add clear:both; to your footer CSS. Thus the changed CSS would be like
#content{
    width:  100% px;
    display: block;
    float:left;
}
footer{
    clear:both;
}


Private declaration seems invalid

Question: class global_class extends Timemine
{

  private $DBPrefix = '';

  public function __construct()
  {
    global $DBPrefix;

    // Load settings
    self::loadsettings();

    $this->database = $db;
    $this->DBPrefix = $DBPrefix;
    .
    .

$DBPrefix is declared outside as a private but inside the function its redeclared? as global.
Is this correct?
Thank you.
Comment: Your answer is a few lines down.  `$this->DBPrefix = $DBPrefix;`  It is not "redeclared."  Members in php are never accessible without `$this`
Answer: $DBPrefix is actually not redeclared. There are two versions of the variable. The first one (private $DBPrefix = '';) is a member variable, the second one (global $DBPrefix) is a local scope variable of the constructor (which refers to a third global version of the variable, but let's leave this aside). See the PHP docs about variable scope for more information
The value of the member variable is then set to the same value as the local scope variable with this line: $this->DBPrefix = $DBPrefix; So after this line both versions have the same value. Technically, your code is correct.
However, using globalis usually bad. It is probably better to pass $DBPrefix in the constructor like:
public function __construct($DBPrefix) {

    // Load settings
    self::loadsettings();

    $this->database = $db;
    $this->DBPrefix = $DBPrefix;
}

Private declaration seems invalid


Meaning of natural action

Question: What is the meaning of the assertion :'the group $G$ acts in a natural way on the set $S$'?
I don't understand the meaning of 'natural'.
thanks!
Comment: It just means "natural" - it is an aesthetic term, not a mathematical one.
Comment: http://mathoverflow.net/questions/19644/what-is-the-definition-of-canonical
Comment: @Martin I think "canonical" is stronger than "natural". Although I cannot think of any easy examples...
Answer: It just means "natural" - it is an aesthetic term, not a mathematical one.
For example, $S_3$ acts on the set $\{1,2,3\}$ in a natural way, while if $N$ is a characteristic subgroup of a group $G$ then $\operatorname{Aut}(G)$ acts on $G/N$ in a natural way.
Comment: "The" action of $S_3$ on $\{1,2,3\}$ is natural (or canonical) because it is this action that is used as the very definition of the group. $SL(3,2)$ acts canonically (namely, by definition) on $\mathbb F_2^3$ and hence also on the projective plane; but without a natural/canonical way to enumerate the seven points of the projective plane we don't get a natural action on $\{1,\ldots,7\}$.
Comment: So $G$=SL(3,2) acts in a natural way on $\{1,...,7\}$ because there is a transitive action on the seven point of the proiective plane on ${F}_2$, is it right?  thanks!
Comment: Yeah - just label the seven points.
Comment: @HagenvonEitzen: Sometimes I wish I could upvote comments multiple times.
Comment: @Hagen I disagree that without the ordering we don't get a *natural* action. I agree that it isn't canonical, but I feel that this is the difference between *natural* and *canonical*. For example, $S_3$ acts on any set with three elements in a natural way, and this way is unique up to automorphism. But without further information, the action is not canonical. That said, that is based on the definition of "natural" which I use, which cannot be standard because it is a non-technical word but I believe that this definition is the most...natural...

Meaning of natural action


Extrair elementos de uma List

Question: Tenhos essa list:
a <- list()
  a[[1]] <- matrix(c(1,2),nrow = 2)

Como faço para selecionar o elemento 2 ?
Answer: Para acessar o elemento 2 da matriz na lista primeiramente você tem que acessar a matriz  -- a[[1]] pois é o primeiro elemento da lista -- e depois acessar o segundo elemento da matriz -- a[[1]]][[2]] ou a[[1]][2].
a[[1]][[2]]
[1] 2

Extrair elementos de uma List


Firefox ignoring format-detection on iPhone

Question: In the following HTML, Firefox on iPhone is rendering 30 thru 60 as a phone number, despite the meta tag asking it not to do so. Is this a known bug, or am I doing something wrong? Thanks.

            <meta name="format-detection" content="telephone=no" />

30

35

40

45

50

55

60

65

70

75

80

Answer: I got around this by adding characters to each
 element. My code example is an age filter, so I amended each
 like this:

30+

35+

etc. I tried wrapping the + signs in  tags and making them invisible, but Firefox was persisting in turning them into a phone number. So the next best option was to use a CSS font-size value of 1px as follows:

30+

35+

etc, and that seems to be enough to discourage Firefox.


Correctly configure the JavaScript tools

Question: I am trying to configure eslint for Drupal in PHPStorm, and it's really confusing.
For example, I have installed the node dependencies that comes in the web/core/package.json file. In PHPStorm, in the Eslint settings, I have configured web/core/node_modules/eslint, but with this module (eslint-config-drupal), I don't know if to configure it with node_modules/eslint which is in the root where I installed eslint-config-drupal. The same goes for prettier.
When I check the Drupal JavaScript coding standards using, for example, ./node_modules/.bin/eslint --no-ignore "../modules/custom/my_module/js/file.js" I had to pass the --no-ignore parameter in order to see the style errors.
The package.json used by Drupal core has some interesting commands that I am interested in using, such as transpiling ES6 to ES5. What the core does is transpile a file.es6.js file to file.js.
In the Drupal documentation I see that the command can apparently be used like npm run build:js -- --file ../modules/custom/my_module/js/file.es6.js, but when I do so, I notice That the Babel plugins don't process them and only show the same file. I only added a generic header text.
I understand that these commands are for the Drupal core, and if I temporarily copy a file.es6.js file to a location within the core, Babel transpiles it correctly.
The only way I have managed to transpile it is to copy the package.json file, the core JavaScript files, and use it in the root of the project. What I don't like is having everything duplicated.
I don't know if there is a way to use what comes with Drupal core in a transparent way.
Answer: Update:
Starting with Drupal 10, an ES6 build process will no longer be used, and several of the scripts related to these tasks are removed.
Now Js code will be written directly without an intermediate compilation process.


Differentiating the inverse of a function with respect to a parameter

Question: The derivative of a function's inverse is well understood, and it is explained in full detail here.
Say I have a function $\varphi_\varepsilon:\mathbb{R}\to\mathbb{R}$, where $\varepsilon$ is a parameter.  I also know that the function is smooth, invertible, and has smooth inverse.  This leads us to the question: do we have a representation for $\frac{\partial}{\partial\varepsilon}\varphi_\varepsilon^{-1}$ that is similar to the single variable case?
Here is a post that already addresses this question, but it is quite old and doesn't have any significant responses.  I'm also more interested in the theoretical case than a concrete example.
Comment: If $\epsilon$ is a real variable, then $\phi$ is really a function $\mathbb R\times\mathbb R\to\mathbb R$.  So you want to assume for each $\epsilon$ $\phi_\epsilon$ is smooth and invertible in which case the one dimensional theorem applies.  I'm not sure what you mean by "representation" here.
Comment: In saying "a representation," I'm referring to something like the formula
$$
(f^{-1})^\prime(x)=\frac{1}{f^\prime(f^{-1}(x))}.
$$
Is it really as simple here as replacing $f$ with $\varphi_\varepsilon$ and making the derivatives in terms of $\varepsilon$?
Comment: Yes I think in that generality it's just as simple as parameterizing $\phi$ by $\epsilon$ in the statement of the 1-dimensional formula.
Answer: After some further investigation, it appears we can't actually get away with what's stated in the comments.
Note that for a function $f$ of two variables $x$ and $y$, if $y$ is also a function of $x$, we have that
$$
\frac{df}{dx}(x,y(x))=\frac{\partial f}{\partial x}(x,y(x))+\frac{\partial f}{\partial y}(x,y(x))\frac{dy}{dx}(x).
$$
It is worth pointing out here that there is a significant difference between $\frac{df}{dx}$ and $\frac{\partial f}{\partial x}$.  The former is the total derivative of $f$ when we make $y$ dependent upon $x$, whereas the latter is the partial derivative of $f$ with respect to its "first" input variable.
Now say that $s$ and $t$ are the variables for the domain and codomain of $\varphi_\varepsilon$, respectively.  That is, $\varphi_\varepsilon(s)=t$.  As our function is invertible, we may write
$$
\varphi_\varepsilon(\varphi_\varepsilon^{-1}(t))=t.
$$
Differentiating both sides of this equation with respect to $\varepsilon$ then yields something similar to the above statement with $f$:
$$
\frac{\partial\varphi_\varepsilon}{\partial\varepsilon}(\varphi_\varepsilon^{-1}(t))+\frac{\partial\varphi_\varepsilon}{\partial s}(\varphi_\varepsilon^{-1}(t))\frac{\partial\varphi_\varepsilon^{-1}}{\partial\varepsilon}(t)=0.
$$
We can then solve this for $\frac{\partial\varphi_\varepsilon^{-1}}{\partial\varepsilon}(t)$, which yields
$$
\frac{\partial\varphi_\varepsilon^{-1}}{\partial\varepsilon}(t)=\frac{-\frac{\partial\varphi_\varepsilon}{\partial\varepsilon}(\varphi_\varepsilon^{-1}(t))}{\frac{\partial\varphi_\varepsilon}{\partial s}(\varphi_\varepsilon^{-1}(t))}.
$$