Original underlying melodies of Liszt's Hungarian Rhapsodies

Question: As we all know, Liszt's 19 Hungarian Rhapsodies contain and conserve some Hungarian and Gipsy tunes (although some of them are in a somewhat modified form). I'd like to know if there's any resource for knowing what exactly they are (I'd like to get information about as many of the Rhapsodies as possible, but my personal preferences include the 2nd, 6th, 9th, 12th and 15th one). In particular, I'm wondering:

if these tunes/melodies have a title at all (my sad first guess would be no because they're folkloric);
If so what the titles are;
And if not, where could I find them, either in written form (notes) or in some kind of digital media?
Answer: Bela Bartok was an Ethnomusicologist too.. he was known to have collected some gypsy songs, for example:
->

If you are searching for a book on this subject,
Bela Bartok's Studies in Ethnomusicology seems to be interesting:
http://books.google.co.uk/books?id=LKQuRowyjPcC&printsec=frontcover&dq=Bela+Bartok+Studies+in+Ethnomusicology&source=bl&ots=WXE3sYPfuf&sig=HNhTMq_f3tnUTre6k38FUkCFOyM&hl=de&sa=X&ei=A_N5UNeVJpDLsgapxoCQBw&ved=0CC0Q6AEwAA
The biggest  problem with the folk tunes is that they are not using the standard european tuning.  Bela Bartok has transposed some tunes for the piano.  If you are not using the well-known tuning, it is pretty hard to write the notes down for a tune.
Comment: Thanks! I'll have a look at Bartók's book. As for the transposition, I'm Hungarian and I'm pretty comfortable with writing down folk tunes.
Comment: YouTube link is dead.
Answer: In his article Hungarian Peasant Music, Béla Bartók writes:1

Among the melodies employed by Liszt in his Hungarian Rhapsodies, and by Brahms in his Hungarian Dances, there are scarcely four or five genuine peasant melodies, and
even these appear in a much distorted, "Gypsy-like" form. All the remainder are art-
melodies in folk-music style. For the programs of the Gypsy musicians are made up
chiefly of such melodies, sparsely interspersed with real peasant tunes; these musicians
adapt both sorts of melodies to their own taste. For instance, they imported the step
of an augmented second (with which we are familiar in the so-called "Hungarian scale,"
but which is never found in the Hungarian peasant melodies) from the melodies) from the Balkans, or still further away, into the Hungarian art-music in folk-music style.2

Further on, Bartók gives two examples.
<code>X:0
T:From "Hungarian Peasant Music" by Béla Bartók
T:Example 11
K:F
M:2/4
L:1/8
GGgg | ga g2 | f2 fg"//"x | aaag | de f2 | d2 dd"//"x | gccc | cd c2 | B2 Bc"//"x | dddc | GA B2 | G2 GG || &
T:Example 12
[K:Bb]
[M:2/4]
cBcd | e2 d2 | gg f2"//"x | cBcd | e2 d2 | cc B2"//"x | GAGF | G2 F2 | dc B2"//"x | GAGF | G2 c2 | GG G2 ||
</code>

These two airs were utilized in Liszt's Thirteenth Hungarian
Rhapsody; No. 11 is the first theme of the Allegro section, much
distorted by graces and figurations in Gypsy style. (On closer
scrutiny of these figurations it is evident that their origin can be
traced to the West-European art-music of the eighteenth century.)
No. 12 is the second theme of the Allegro section; in the Liszt
melody, the close, in particular, shows a deviation from the
original peasant form; it closes a third lower than our example.3

On the other hand, in "A study of Franz Liszt's Hungarian Rhapsodies"4, Dana Charlene Francey writes:

The second chapter of the thesis will describe the relationship of the Hungarian Rhapsodies with the original collections of Hungarian folk tunes on which they are based (Macwar Dallok and Macwar Rhapszodiák pieces), and subsequently will use the relationship with this pre-existing material as the foundation for grouping them into categories, e.g., Hungarian Rhapsody Nos. 1-2 (based on folk tunes not found in the Magyar collection); Hungarian Rhapsody Nos. 3-15 (based on folk tunes found in the Magyar collection); Hungarian Rhapsody Nos. 16-18 (not based on any pre—existing material —- all original works); and Hungarian Rhapsody No. 19 (based entirely on Csárdás nobles by Abrányi, an Hungarian composer).5

The dissertation gives an extensive analysis of the source material for the Hungarian Rhapsodies.

1Bartók, Béla (trans. Theodore Baker). "Hungarian Peasant Music." The Musical Quarterly 19, no. 3 (1933): 267-87. Accessed September 21, 2020. http://www.jstor.org/stable/739077.
2Ibid., 267
3Ibid., 277
4Francey, Dana Charlene. 1992. "A Study of Franz Liszt's Hungarian Rhapsodies." Retrospective Theses and Dissertations, 1919-2007. T, University of British Columbia. doi:http://dx.doi.org/10.14288/1.0086785.
5Ibid., ii


Convergence of random variables: sumXn/ sqrt(n sumXn^2)

Question: Let $\{X_n\}_{n\geq1}$ be a sequence of i.i.d. random variables such that $\mathbb{E}[X_1]=Var(X_1)=1$.
Show that:
$$\frac{\sum_{k=1}^{n} X_k }{\sqrt{n \sum_{k=1}^{n} X_k^2 }} \xrightarrow{\text{prob}} \frac{1}{\sqrt{2}}$$
I think we need to use the strong law of large numbers applied to the sequence $\{X^2_n\}_{n\geq1}$ to get that:
$$\frac{\sum_{k=1}^{n} X^2_k }{n} \xrightarrow{\text{a.s.}} \mathbb{E}[X_1^2]=Var(X_1)+\mathbb{E}[X_1]^2=2 $$ and then use some relation to get the result above.
Answer: Just divide numerator and denominator by $n$  and apply SLLN's to the sequence ${X_i}$ and $X_i^{2}$. In fact the convergence is almost sure.
Comment: Thanks! But don't you need $\mathbb{E}[|X_1|]$ also to be finite in order to apply the SLLN's?
Comment: A random variable $X$ has finite expectation  iff $E|X| <\infty$. In Lebesgue Theory there is no distinction between integrability of $X$ and integrability of $|X|$.  @Babado
Comment: In this case even the variance is given to be finite.
Comment: Yeah, I was thinking of the Lebesgue measure... but wrt the probability measure that's true


Fazer o batch dizer o nome do exe

Question: eu quero saber como que um batch, diga o nome do exe que eu quero.
Eu tentei, mas não deu muito certo
Meu Script:
where /r C:\Users\Usuario\ *.txt

Mas esse comando, diz o caminho completo. eu quero que diga só o nome
Exemplo:
Teste.exe
É só isso, eu sou médio em script de batch, Valeu!
Answer: faça dessa maneira se for dentro de um script:
for %%F in (teste.exe) do (echo.%%~nF)

o resultado será:
teste
e caso queira puxar junto com a extensão...
for %%F in (teste.exe) do (echo.%%~nxF)

o resultado será:
teste.exe
veja que eu acrescentei a letra x, que indica que quero buscar a extensão.
caso eu queira buscar o tamanho do arquivo, posso adicionar a letra z.
e eu terei o tamanho em bytes.
for %%F in (teste.exe) do (echo.%%~nxzF)

basicamente você adiciona uma letra no meio da variável do for %%'aqui'F
com o prefixo ~
veja outros exemplos retirados do prompt
%~I         - expande %I removendo quaisquer aspas em volta (")
%~fI        - expande %I para um nome de caminho totalmente qualificado
%~dI        - expande %I para somente uma letra de unidade
%~pI        - expande %I para somente um caminho
%~nI        - expande %I para somente um nome de arquivo
%~xI        - expande %I para somente uma extensão de arquivo
%~sI        - o caminho expandido contém somente nomes curtos
%~aI        - expande %I para atributos de arquivo do arquivo
%~tI        - expande %I para data/hora do arquivo
%~zI        - expande %I para o tamanho do arquivo

Comment: Não quero o echo, só quero os nomes do exe em um diretorio.
Comment: bom, nesse caso você pode usar o operador > ou >> caso não queira sobscrever. o echo. foi só pra exibir o resultado, eu mostrei para você uma maneira de exibir apenas o nome, aqui não podemos montar scripts, apenas tirar dúvidas
Answer: Você pode usar o where dentro de um for, ficaria algo assim:
for /f "Delims=" %%a in ('where /r "c:\users\usuario" *.txt') do @echo %%~nxa
Comment: Valeu!!! funcionou.

Fazer o batch dizer o nome do exe


why is epsilon uncorrelated with any function h(X)

Question: Im currently reading mostly harmless econometrics. The three relevant pages are here: http://econ.lse.ac.uk/staff/spischke/mhe/ex_ch3.pdf
My issue is the following. They claim that epsilon is uncorrelated with any function of $h(X)$ in theorem 3.1.1 and later they claim that it is uncorrelated with $E(Y | X)$ in theorem 3.1.3. So far I always thought that its just an assumption that epsilon is uncorrelated with $X$ in a data analysis. How am I to understand their proof?
Answer: by conditional expectation:
$$E(h(X)\varepsilon) = E(h(X) E(\varepsilon|X)) = E(h(X)0) = 0,$$
i.e. $h(X)$ and $\varepsilon$ are uncorrelated.

To shed some light on the first part of the theorem in the satement, note that one can always write $Y=E(Y|X) + \varepsilon$, where $\varepsilon = Y-E(Y|X)$ yielding  $E(\varepsilon|X)=0$, since $$E(Y|X) = E(Y|X) + E(\varepsilon|X) \quad \Rightarrow \quad E(\varepsilon|X)=0.$$

However, this is pretty boring since it doesn't give you any helpful information about the relationship of $Y$ and $X$. In order to model the relationship you will assume $Y=g(X) + \varepsilon$ for some specific $g(X)$. For this specific model to be meaningful (as in $g(X) = E(Y|X)$) you then need to assume $E(\varepsilon|X)=0$:
For a model of the form $Y=g(X)+\varepsilon$ we have $$E(\varepsilon|X) = 0  \Leftrightarrow g(X)=E(Y|X).$$
Indeed, If $E(\varepsilon|X)=0$ then $$E(Y|X)=E(g(X)|X)+E(\varepsilon|X)= g(X).$$
On the other hand, if $g(X)=E(Y|X)$ then  $Y=E(Y|X) + \varepsilon$ and we have $$E(Y|X) = E(Y|X) + E(\varepsilon|X) \quad \Rightarrow \quad E(\varepsilon|X)=0.$$
Comment: yes, that proof makes sense to me. but does that mean that E (Y I X) is also a function of X? and i thought that the indpedence of X and epsilon was a statistical assumption, not something you could prove
Comment: yes, the conditional expectation $E(Y|X) $ can be seen as a function of $X$. $E(\varepsilon|X)=0$ is indeed an assumption and quite a strong one in practice. while it may indeed be hard to check, ther are simple examples where you know that the assumption can not hold. for example, In a standard regression model this occurs whenever you omit relevant variables in the regression and the omited variable is correlated with $X$. it's easy to imagine that this happens quiet often in practice.
Comment: but they say they prove E(ε|X)=0 in theorem 3.1.1 i. so why is it an assumption?
Comment: i expanded my answer. they already modelled $Y$ in an equivalent way as assuming $E(\varepsilon|X)=0$.
Comment: thanks so much, this has made it clearer to me. So assuming the independence and choosing E(Y|X) as the function of X is equivalent. Thats why it remains an assumption. And then i suppose even the proof in theorem 3.1.1 ii (where they show the independence of epsilon from any function h(X)) rests on this assumption as it still uses E(ε|X)=0?


What does an arrow pointing up inside the staff mean?

Question:
This was in my audition music, and I can't ask the person I got it from. It was written by the director at my high school.
Edit: Here's the full music:

I'm not sure what style.
Also, I can ask my director, but not for about a week and a half, which is why I asked here.
Comment: If this was written by your director - a. I'd ask them. b. I'd be concerned
Comment: What instrument? What style? Can you post the full sheet?
Comment: Some thoughts building on Tim's comment. If I was a director and I was doing auditions I would not hold it against a player if they asked me about something in the piece they were auditioning with. If I explained it and they played it as I explained, all good. If they didn't ask and play it "wrong" I would maybe give the spot to the kid that asked and played it right. It's not like your asking what key the piece is in or what the time signature means. This doesn't seem like standard notation.
Comment: I agree with Richard. This is some sort of weird typo. Practice the rest of the piece. Play a half note there as a place holder for now and wait to get a good answer. Good luck on your audition.
Comment: The only thing I could find close to this was an arpeggio arrow, but the arrow is next to a chord. There is no chord next to this arrow, so it can't be that...Here's the link if you want to see it. https://ccrma.stanford.edu/software/cmn/cmn/cmn.html#arrow
Comment: I think you might be right, Richard. I know how horrible Musescore is at handling notation. I'll ask my director what it really is. Thanks!
Comment: @Richard - if that is indeed the case the director has some answering to do to retain any credence...
Comment: I agree - printing/ notation error.
Answer: I would say there's a strong possibility that this is a typeface error and this should just be a half-note G.
Notice that there is a note stem there, but there's no half-note note head. This arrow is not standard notation, so I'm wondering if the half-note note head got replaced by its closest symbol in another typeface.
Comment: I totally agree this is what happened.


R arbitrary ring, R/I is a field then I maximal

Question:
In Foote and Dummit Page 255. It states: Let $R$ be an arbitrary ring (not necessary has 1) if $R/I$ is a field then I is maximal.
I know the statement holds when $R$ has 1, but how to prove this if $R$ does not have 1.
Comment: What happened when you read through the proof in the case that $R$ has $1$, and tried to make the proof work in the case that $R$ does not have $1$?
Comment: For non-commutative rings we need to distinguish between left, right and bilateral ideals, same for maximal. A field has no non-trivial ideals (left or right or bilateral it is the same since commutative).
Answer: By definition, take $J$ an ideal of $R$ such that contains $I$. We want to show that either $J=I$ or $J=R$.
Since $J$ is an ideal of $R$ then $J/I$ is an ideal $R/I$ consequently $J/I=\lbrace I\rbrace$ or $J/I=R/M$ as a result of being $R/I$ a field.
In the first case implies $a+I=I~\forall a\in J$, therefore $J=I$.
On the other hand if $J/I=R/I$, for every $r\in R$ exists an $a\in J$ s.t. $r+I=a+I$, then $r-a\in I\subset J$ and $a$ lies in $J$ so $r\in J$ for each $r\in R$.
Hence $J=I$ or $J=R$.


Gaussian process regression - Matérn kernel gradient issue

Question: I'm trying to use a Matérn 5/2 kernel for GP regression, so my kernel function is
$ K(x,x')\triangleq\theta_0(1+\sqrt{5r(x,x')}+5/3r)\exp(-\sqrt{5r}), $
where $r(x,x')\triangleq\sum_{d=1}^D (x_d-x'_d)^2/\theta_d^2$
I want to optimize the marginal likelihood--the gradient of which involves calculating $\frac{\partial K}{\partial\theta_i}.$ The problem, though is for $x=x'$, i.e., the diagonal entries of $K$, $r(\cdot)=0$, making $\frac{\partial K}{\partial\theta_i}$ undefined at the diagonal, as $\sqrt{(\cdot)}$ doesn't have a defined derivative at 0.
This seems like a very obvious problem, but google hasn't revealed anything, so maybe I'm missing something.
Comment: The lack of differentiability of the square root is not relevant, because what matters is the differentiability of $K$ (*qua* function of $\theta_d$). Any plot of $K$ as a function of $\theta_d$  will show how beautifully smooth it is as $\theta_d$ approaches zero.
Answer: I think when the kernel matrix is differentiated, the kernel would be multiplied by differentiation of r(.) with respect to correlation length (θ) (i.e. K*dr(.)/dθ). At x=x', r(.) is zero, so the entries for the derivative matrix of the kernel wrt correlation length is zero.


How do I notate a staccato on a unison note?

Question: If there is a stem on either side of a note, or the stems are DOWN below ledger lines, where does the dot indicating staccato go?
Answer: On single-stem pitches, the rule is always the same: the staccato goes on the side of the notehead that is opposite the stem.
But when multiple voices are in play, the convention is typically to put the staccato pitch at the end of the stem, even if there's enough space to place it by the notehead. This means that, in multiple voices, the up-stem pitch will have a staccato above the pitch and the down-step pitch will have it below the pitch.
Note that in the first measure the staccato is centered with the notehead, but in the second measure the staccato is centered with the note stem.
Answer: The convention in these cases is to put the staccato dot above/below the stem of the note in question. I admit that it looks a little strange to have the dot so far away from the notehead, but that's how I've seen it done.


Cannot program application.onkey for alt+0 in Excel 2016

Question: In Excel 2016 it seems I cannot program alt + 0 anymore to run a VBA subroutine of mine, in other words
application.onkey "%0", "mysub"
. The default behaviour (to temporary show the ribbon, if hidden) cannot be changed, it seems. But now I also lose alt + shift + 0, in other words the following also does not work:
application.onkey "%+0", "mysub".
Is there any way to have application.onkey override the default action? Thanks
Comment: alt+shift 0 works for me (Excel 2016). WHere is your onkey line of code located precisely? What exactly happens when you run it?
Comment: Thanks I found the problem now .... see below
Answer: Thanks, I found the problem now: I had done the ctrl + shift + f1 toggle beforehand. This makes Excel fullscreen and totally hides the ribbon. While hidden, alt + 0 becomes the shortcut to temporarily show the ribbon, and application.onkey "%0", "mysub" won't work.
Apologies, it was not my intention to answer my own question from the start... But @jkpieterse motivated to me try harder.
Comment: Great you were able to solve the problem. Although it does surprise me because normally OnKey supersedes whatever the built-in function is a short-cut key triggers.


No data showing in tableselect

Question: This is a very weird one...
I am building a table using
'#type' => 'tableselect'

I have
$header = array('date', 'name', 'email', 'location', 'time');

and
$options[$result2[$i]['id']] = array(
    'date' => gmdate("d / m / Y", $result2[$i]['timestamp']),
    'name' => $result2[$i]['name'],
    'email' => $result2[$i]['email'],
    'location' => $str_location,
    'time' => $str_time,
);

then I am building the table like this...
    $form['table_' . $n] = array(
        '#type' => 'tableselect',
        '#header' => $header,
        '#options' => $options,
        '#prefix' => '

' . $record1->name . '
',
        '#suffix' => '
',
    );

The problem is this: The rows are showing.... but with no data in them!
I can output the $options array and it contains the data I want to see in the table.
I have cleared the cache as mentioned here
Any clues as to why there are the correct rows with the correct columns but with no data?
Answer: Ahhhh!
Just as I posted this I discovered that my $header was malformed!!
$header = array('date', 'name', 'email', 'location', 'time');

should have been
$header = array('date' => 'Date', 'name' => 'Name', 'email' => 'Email', 'location' => 'Location', 'time' => 'Time');

Phew!

No data showing in tableselect


Can I stop XCode from breaking on a fatalError/preconditionFailure?

Question: I've got some conditions where I need my frameworks to report a fatalError or a preconditionFailure and crash. I have set up some unit tests around these conditions to make sure they hit correctly.
It works really well if the unit tests are run without a Test Host application, but the moment a Test Host application is involved, any fatalError or preconditionFailure hits an automatic XCode break with the message Thread 1: Fatal error: <CUSTOM ERROR HERE>. and stops the execution of the rest of the tests until I press the Continue program execution button manually.
This is obviously an issue because I can't just let my tests run in the background and I need to be actively hitting the Continue button every time one of these tests hits which is quite annoying.
Is there any way to disable this XCode break?
Answer: Looks like this is fixed in Nimble 7.1.3, a library which I use to test these particular cases. I also found this specific issue in the Nimble library issue 478 which has a comment on a workaround you can use to disable the debug executable when running you tests. Hopefully this helps anyone else stuck with the same problem I had.
Comment: Don't you think your question/answer would be more useful if the question had _mentioned_ Nimble?
Comment: Fair point matt, but the question is not limited to Nimble. I only use this library to do the asserts, it would happen even if I didn't use the library and I had other ways of asserting that didn't include the workaround spoken about in the issue above, and/or the fix from this link https://github.com/mattgallagher/CwlPreconditionTesting/commit/ce96cb1d81644b92c66fd2b622260905526a7c5f


How do I debug/kint Simple XML Sitemap link array?

Question: I am trying to find how I can debug/kint a variable/array from the Simple XML Sitemap?
I worked through the documentation here: https://www.drupal.org/docs/8/modules/simple-xml-sitemap/api-and-extending-the-module#s-api-hooks to find the hook I need.
My goal is to unset any links that have node/ to remove published, but un-aliased nodes of included content types.
The array key ['path'] looks to be the unaliased URL and the below code removes all links except the home page. I am unsure how I can kint($link) in this function so I can see what other array keys are available to see what else I may use for comparison.
function HOOK_simple_sitemap_links_alter(array &$links, $sitemap_variant) {

  foreach ($links as $key => $link) {
    if (strpos($link['meta']['path'], 'node/') !== FALSE) {
      unset($links[$key]);
    }
  }
}

Is there a way to kint() these sitemap arrays? Or maybe some documentation that shows the structure of these arrays?
Comment: Assuming you have devel installed and kint selected for output, it should be as easy as `ksm($links);` to print the kint output to the message area
Comment: I had kint enabled but not devel. `kint()` throws errors while regenerating the sitemap links, but `ksm()` does not and displays what is needed.
Answer: As Clive said, you will need to make sure that both the devel and kint modules are enabled.  (NOTE: D8's Devel 4.0 now includes the kint module but requires 'composer require kint-php/kint' to be done to make it work) Then you can add your hook and just do a ksm($links); statement.
Make sure to clear cache so the hook will be found.  Then doing a regenerate of the sitemap(s) in the gui will product the kint output that you can examine for the structure.
Also, not totally sure, but I think this hook has to be in a module and will not work in the .theme file.
FYI - Here's a code snippet from a working hook that does what you want, including removing untranslated nodes.
/**
 * Implements hook_simple_sitemap_links_alter().
 */
function my_module_simple_sitemap_links_alter(&$links, $variant) {
  foreach($links as $key => $link) {
    // Filter out any node/### URLs
    if ( preg_match("!(/[a-z-]*)?/node/\d?!", $link['url']) ) {
      unset( $links[$key] );
      continue;
    }
}

Comment: `['url']` was the key I was looking for. I am using `if (strstr($link['url'], '/node/'))`, but this answers the need of my Q, and the above will remove `/node/` URL's. `ksm()` seemed to be the big difference in debugging.


How to prove $\sum_{i=1}^{k}2^{-d_i} \leq 1$

Question: The question is:
In a binary tree, the depths of leaf nodes are $d_1, d_2,... d_k.$ Prove that $\sum_{i=1}^{k}2^{-d_i} \leq 1$
Understand why this is true, in that:
If a tree has only 1 node, it has one leaf, and thus $\sum_{i=1}^{1} = 2^{-1} = 1 \leq 1$
If a tree has 3 nodes, the tree has two leaves, and: $2^{-1} + 2^{-2} = \frac{1}{2} + \frac{1}{2} \leq 1$
and so on...
I started this thinking that I could use induction to prove it.
So:
Base Case:
Let $n = 1$, which as shown above $\leq 1$.
What is the inductive step here? Should I use induction?
Comment: Use the fact that $2^{-(d_i + 1)}+2^{-(d_i + 1)}=2^{-d_i}$ for induction.
Answer: Take any arbitrary tree, and add a child leaf to any non-leaf node with only one child. This can only increase $\sum 2^{-d_i}$, because you're adding leaves without changing the degree of any existing leaf, or changing any existing leaf to a non-leaf.
Now find each node with two child leaf nodes. From each of these, remove both leaves. This gets rid of two leaf nodes with degree $d$ and creates a new leaf node with degree $d-1$, leaving $\sum 2^{-d_i}$ unchanged.
Repeat until all that's left is the trivial one-node tree, for which $\sum 2^{-d_i} = 1$.
Comment: Ok, thanks. Obviously I have a lot to learn...I don't know if this answer is better than the other but I understood this more.
Answer: Prove it by structural induction on the tree (or if you like, by induction on the depth of the tree).  Let $S(T)$ denote $\sum 2^{-d_i}$ for leaf nodes of the tree $T$.  If $T$ is a single leaf node, then $S(T) = 2^{-0} = 1$.  Otherwise, both the left and right subtrees, $T_l$ and $T_r$, satisfy $S(T_l) \le 1$ and $S(T_r) \le 1$ by inductive hypothesis.  However, the depth of each leaf node in the tree is one more than the depth of the leaf node in the corresponding child tree.  Therefore,
$$S(T) = \sum 2^{-d_i} = \sum_{i~\mathrm{for~left~subtree}} 2^{-d_i} + \sum_{i~\mathrm{for~right~subtree}} 2^{-d_i} = \frac{1}{2} (S(T_l) + S(T_r)) \le \frac{1}{2} (1 + 1) = 1.$$
(And in fact, it's easy to see by a very similar proof that for any full binary tree $T$, $S(T) = 1$.)


Is Aftersave() callback with $created parameter works on CakePHP 1.1?

Question: I am working on a CakePHP 1.1 project. I know it is a really old version of the framework but it is not my project.
I try to get the $created variable in my afterSave() callback :
function afterSave($created) {
      debug($created);
}

According to the 2.x documentation, $created should be true or false.
In my case, $created is not defined.

Notice: Undefined variable: created in /app/models/property.php on line 370

Am I missing something ?
I am having a lot of trouble for finding documentations/informations on the version 1.1 of the framework.
Is this even possible in CakePHP 1.1 ? If not, what alternative can I use ?
Thanks in advance.
Answer: According to the CakePHP 1.1 documentation there are no parameters for afterSave(). It looks like the $created parameter was introduced in CakePHP 1.2.
If your records have created and modified fields you could check if these match (i.e. is a new record):-
function afterSave($created) {
    if ($this->data[$this->alias]['created'] === $this->data[$this->alias]['modified']) {
        // created
    }
}

Not sure if my code example is a 100% correct as it is a very long time since I worked with CakePHP 1.x, but will hopefully put you on the right track. There may (probably) be better solutions than this.
Comment: Thanks! Indeed you are right, I arrived to the same conclusion and used a similar condition : `if(!isset($this->data[$this->name]['id']))` because when it is created no `id` is present in `$this->data`. Your solution is also perfectly working thank you very much!


Drupal shortcuts - link with question mark included

Question: When I add a link to shortcut set which looks like this:
admin/work?date_filter
shortcut module changes this question mark sign "?" into this "%3F" and this link doesn't work anymore. I believe I can't avoid it - looks like it's a bug, so my question is how to add link as a shortcut programically?
Comment: It's a browser rule to convert special characters. May I know why you need such character in your URL? It may help me to answer more accurate.
Comment: @DharaShah It's not browser rule. I've checked it. Chrome doesn't translate question mark into ASCII code. As for the link, it's a long story, but it must stay.
Answer: The shortcut module is more strict about valid URLs it can use compared to what the menu module will allow (e.g. no external URLs, no query param).
One way to circumvent this is to use hook_menu in a custom module to define a valid path that redirects where you want it to go and add that path to your shortcut set.
function MYMODULE_menu() {
  $items['MYMODULE/work'] = array(
    'access arguments' => array('access content'),
    'page callback' => 'drupal_goto',
    'page arguments' => array('admin/work', array('query' => array('date_filter' => 'XXX'))),
    'type' => MENU_CALLBACK
  );
  return $items;
}

This makes MYMODULE/work a valid path for your shortcut set.


In Postfix, Should SSL FQDN Matches with myhostname or mydomain field in /etc/postfix/main.cf?

Question: Quoted from the documentation:

myhostname
The internet hostname of this mail system. The default is to use the fully-qualified domain name (FQDN) from gethostname(), or to use the non-FQDN result from gethostname() and append ".$mydomain". $myhostname is used as a default value for many other configuration parameters.

mydomain
The internet domain name of this mail system. The default is to use $myhostname minus the first component, or "localdomain" (Postfix 2.3 and later). $mydomain is used as a default value for many other configuration parameters.

I'm confused that FQDN postfix should be equivalent as SSL FQDN or not. For now, let's assume /etc/postfix/main.cf configuration is
myhostname = mail.pelersapi.id
mydomain = pelersapi.id
myorigin = $mydomain

Now the question is: can I create a SSL certificate with domain mail.pelersapi.id while keep the firstname.lastname@example.com address valid?
Currently, I'm using Let's Encrypt to make the certificate
sudo certbot certonly                                                            \
    --dns-cloudflare                                                             \
    --dns-cloudflare-credentials /etc/letsencrypt/cloudflare/pelersapi.id.ini    \
    --dns-cloudflare-propagation-seconds 30                                      \
    -d mail.pelersapi.id                                                         \
    -m firstname.lastname@example.com

My previous attempt was keeping SSL FQDN and myhostname same as mydomain, then it's successfully authenticated. For the scenario explained above, I'm afraid misunderstanding the theory could causes spam score worsen.
Answer: If mail.pelersapi.id is defined in DNS as the MX for pelersapi.id, and if there is an A record that points mail.pelersapi.id at your Postfix server, then having a certificate for mail.pelersapi.id on that server will validate all mail addresses email@example.com. (If there is a second mailer mail2.pelersapi.id it will need a certificate for itself, of course.)
Comment: Yes. The only other tip is that you need to set a priority in your MX record; 10 is a good value for that. (Priority is used to allow for additional, failover mail servers; lower-numbered servers are used first, and higher-numbered ones if the low-numbered ones don't respond.)
Comment: Okay, then the DNS Server should be configured as `MX record of pelersapi.id to mail.pelersapi.id` and `A record of mail.pelersapi.id to 126.96.36.199` right? Thanks for the concisely helpful clue!
Answer: Yes, in simple cases like this, you want the SSL certificate to contain mail.pelersapi.id, just like myhostname. The fact that this happens to be a subdomain of your mail domain is just a bonus.
Remember this certificate is presented when you are receiving messages. People you are sending messages to do not see this (they use SPF/DKIM/DMARC to establish sender authority). Your cert presented on your MX only even starts to matter as they reply (or bounce).

Look for the separate manual page, or possibly a text document in /usr/share/doc/postfix/TLS_README referenced from that documentation, specifically for the TLS related discussions:

DNS names in the SubjectAlternativeName certificate extension are used
to verify the remote SMTP server name

If you read through that explanation you will see, it used to be and still is quite a bit more complicated than just that, but a configuration that covers most of the edge cases is not that complicated: MX record, $myhostname match and appear in SAN.DNSName of the certificate, which is signed by some Mozilla-trusted CA just like any website certificate, done.
Comment: So in a nutshell, SSL is just for receiving and SPF/DKIM/DMARC are for sending mail? Anyway, thanks for the additional information!


Why shouldn't you use your thumb on black notes (Harmonium / Keyboard)

Question: When I was younger I took a couple Harmonium classes and the teacher taught us how to play all of the scales.  We weren't allowed to place our thumbs on the black notes.
I haven't had any piano instructions, so I don't know if that requirement is there as well, but I've noticed at concerts, recitals, and on Youtube, people generally play freely.
Why would the teacher ingrain the "No thumb on black notes" rule?  Was there a purpose for this?
Answer: There's no hard rule to say that you shouldn't use your thumb on black notes - some pieces would be near-impossible to play without doing so!
However, there are some reasons why you might be better off by not doing so.
One is that the thumb is shorter than the rest of your digits, so it makes sense to reserve it for the easy-to-reach white keys. You specifically mention scales - so here, it does indeed make sense to reserve your thumb for the white notes, as you require fluid, step-by-step movement. Try crossing your thumb under a finger from a white to black key and see the awkward movement you make! The exception here is of course pieces in keys which make heavy use of the black keys, in which case you'll find using your thumb to be more convenient than not doing so.
Another situation is playing chords - you'll notice that using your thumb on a black key in many chords will cause you to twist your wrist slightly. Again, there are exceptions where using the thumb is more comfortable than not.
Another reason is historical - Prior to Bach and his contemporaries, conventional fingering avoided using thumbs altogether - black keys or otherwise! Again, there would be exceptions; e.g. for playing octaves or large intervals. If you wanted to be 'historically accurate' you might want to avoid your thumbs being used, but 'historically accurate' does not equal 'better'!
Comment: Good answer. Playing a scale is incredibly hard if you use your thumb for black keys, but can be perfectly appropriate when chording or what have you.
Answer: On the Indian harmonium, you are generally playing with one hand on a short keyboard (two or three octaves) and you are only playing one note at a time. So fingerings would not be so crucial. However, when you learn Western technique, the fingering patterns for piano are designed for two-handed playing across multiple octaves, and to facilitate rapid scales.
The main reason not to put your thumb on a black key is that when you do, it tends to be more difficult to move your fingers quickly to the next key or keys you need to strike. Experience will teach you this.
All the Western piano books provide exact fingering patterns for all twelve Western major and minor scales, in one hand and with both hands parallel, across two or more octaves. Due to the way that the keys are laid out on keyboard instruments, the fingering pattern for each of the traditional scales is distinctly different, and must be memorized.

Historical footnote (I'll leave it to you to look up a reference.) While the layout of the keyboard had been the same for centuries before, keyboard players rarely used their thumbs at all before J. S. Bach (1685-1750), who pioneered and popularized the technique of fingerings that involved the thumb.
Answer: Actually the rule applies only for your little finger and not thumb. The main reason why you are not allowed to use thumb is, you couldn't be able to generate speed while playing third or fourth kalas, as compared to index finger and others.
However in our school we follow the tradition of playing Harmonium with all fingers, what you need is only a good output and fingerings doesn't matter at all stage.


Is $\bf{u} \times\bf{(\nabla \times u)}$ $=0$ in the contex for deriving Bernoulli's theorem

Question: Is $\bf{u} \times\bf{(\nabla \times u)}$ $=0$
I am trying to derive the to Bernoulli's theorem for a a steady, inviscid, homogeneous, incompressible fluid.
Using mass conservation:

Using Euler's equation:

Now somehow we get that $\nabla H$ is zero, i don't understand how?
Answer: What is true is that $ u \cdot \nabla H = 0$. This is all that is required, as Bernoulli's principle says that the quantity $H$ is conserved along streamlines.

Is $\bf{u} \times\bf{(\nabla \times u)}$ $=0$ in the contex for deriving Bernoulli’s theorem


The command echo "users" | ssh myserv does not return anything.. Why?

Question: The command echo "hostname" | ssh myserv returns the hostname, but echo "users" | ssh myserv does not return anything?
When I ssh on the server then run the command users, it returns my user name (since I'm connected on it :-' ).
Answer: users only shows users who are logged into a terminal (as recorded in utmp). echo users | ssh myserv doesn't create a terminal (it's not an interactive session), so that session isn't listed. The more common ssh myserv users similarly executes the command without creating a terminal. On the other hand, ssh -t myserv users (where -t forces a terminal to be created) should show you.
Compare also ssh -t myserv 'tty; who' (shows you logged in on that tty) with ssh myserv 'tty; who' (not a tty).
Answer: Try it this way:
ssh myserv users

Answer: I get an error when I attempt this.  Some programs require a tty.  Also keep in mind that who, and users are a special case, they are looking specifically at login sessions.
# echo users | ssh host
stdin: is not a tty

See:
man sshd_config

UseLogin Specifies whether login(1) is used for interactive login sessions.  The default is "no".  Note that login(1) is never used for remote command execution.

man users

users  -  print the user names of users currently logged in


Promise rejects before finishing for loop

Question: this might be a easy fix, but I am running into a problem with using a loop with a Promise. I am using Angular and Typescript.
As a backstory, I am trying to implement a very simple user authentication login page. I have a Array of User objects, each object containing a username, password, etc. On the login page, when the user inputs their User/Pass, clicks a "Login" button, a promise function fires which loops through the Array to see if there is a match between the Array and the user input.
Here's some pseudocode that I have written, where usersList is the array of Users and users.username and users.password is the user input.
for (var i = 0; i < this.usersList.length; i++) {
    if (this.usersList[i].email === user.username && this.usersList[i].password === user.password) {
        resolve({
            /* code */
        })
    } else {
        reject({
            message: "User/Password not found"
        })
    }

However, this only works for the first object in the list, since the Promise rejects on the first iteration of the for loop. How would I go ahead and fix this so that it only rejects after the loop has gone through every object in the Array?
Comment: Besides moving the `reject` to outside the loop? You mainly need to keep track if you "found" something or not, then check that *after* the loop to know if you need to reject.
Comment: Your code in english is something like this
`Check first. If it matches, yay, resolve. Else, reject promise. End of lookup`
Answer: The obvious problem is you're calling reject as soon as one item has been checked and found to not match the input. The loop does continue, but by that point it's too late to resolve.
A better idea might be to filter your users list to see if the item exists, if it does, resolve else reject. Something like:
var foundItems = this.usersList.filter(u => u.username == user.username && u.password == user.password);
if(foundItems.length){
    resolve({
            /* code */
        });
}
else{
    reject({
            message: "User/Password not found"
        });
}

You could also use find with similar effect:
var user = this.usersList.find(u => u.username == user.username && u.password == user.password);
if(user){
    resolve({
            /* code */
        });
}
else{
    reject({
            message: "User/Password not found"
        });
}

Answer: You basically fix your code by moving the reject.
for (var i = 0; i < this.usersList.length; i++) {
    if (this.usersList[i].email === user.username && this.usersList[i].password === user.password) {
        resolve({
            /* code */
        })
        return
    }
}
reject({
    message: "User/Password not found"
})

You need to return to break the loop when found and also, if this code runs in a function, to stop the execution of function.
Answer: Promise reject at first iteration because it did not match the object at index(0) of Array and code inside the else loop executed. To resolve this problem you should write the code where the promise reject at last iteration if it not resolved in all iteration before the last one.
 for (var i = 0; i < this.usersList.length; i++) {
    if (this.usersList[i].email === user.username && this.usersList[i].password === user.password) {
        resolve({
            /* code */
        })
    } else if(i === this.usersList.length - 1) {
        reject({
            message: "User/Password not found"
        })
  }


Converter timestamp p/data no LUA?

Question: Como converter timestamp para data legível no LUA ?
tipo
1634521166 (2021-10-18T01:39:25)
Answer: Use os.date()
os.date('%Y-%m-%dT%X', 1634521166) -- retorna '2021-10-18T01:39:26'

ou ou troque o primeiro parâmetro para '*t' para retornar uma table
os.date('*t', 1634521166).year -- retorna '2021'

Comment: Mais informações sobre data no lua neste [link](https://www.lua.org/pil/22.1.html)

Converter timestamp p/data no LUA?


How to fix: "An object reference is required for the non-static field"

Question: I got the error Message:

CS0120 - An object reference is required for the non-static field,
  method, or property 'StageDBEntities.Aufgaben'

My Code:
public ActionResult AufgabenDetails(int id)
{
    var Aufgabe = StageDBEntities.Aufgaben.Find(id);

    return View(Aufgabe);

}

This Code is on my Main Controller. With this i try to create a Site per Task(Aufgabe) in my Database.  /AufgabenDetails/1 <-- one is the ID of my Task(Aufgabe)
Comment: whether StageDBEntities is a class ? and it is not a static class to use StageDBEntities.Aufgaben, you have to create object of StageDBEntities and need to access
Comment: Did you look at the related column on the right? There are at least 10 duplicates of this error. Why you don't search before asking?
Answer: You should creat an instance of StageDBEntities before trying to use it. Try

public ActionResult AufgabenDetails(int id)
{
    var Aufgabe = new StageDBEntities().Aufgaben.Find(id);

    return View(Aufgabe);

}
Answer: If StageDBEntities is your Entity Framework class, you need to instantiate a new db instance as a variable
public ActionResult AufgabenDetails(int id)
{

    StageDBEntities db = new StageDBEntitites();
    var Aufgabe = db.Aufgaben.Find(id)

    return View(Aufgabe);

}


How to get unique value from dynamically create divs by using JQuery?

Question: I am creating div inside div tag on button click, It is created and shown on UI , but
I am unable to get the unique value  inserted in dynamic created div. I always get
the first  value.
Code sample:

Dynamically adding code sample, This code runs on each click
 $("#row-list-outer").append(`

                       <input type="text" id="salesPersonName" placeholder="Name">

)

Now input element  is created on click, but If I enter a value  in 2nd row input, or 3rd row input etc. Then How  I get those values in the same order as they are inserted. For example if the user enters in first row input, then it should be stored on index 0 in array, similarly, if user enters in 1 row, 2nd row, then it should be inserted on array at index 1, 2 respectively
Comment: when do you want to insert the value into an array. While typing into the text field or after filling all the inputs then clicking another button?
Answer: You can try something like this:
function addRow() {
  $("#row-list-outer").append(`

                       <input type="text" id="salesPersonName${$("input[id^=salesPersonName]").length + 1}" placeholder="Name">

`)
}

$(document).on("change","input[id^=salesPersonName]",function() {
  var v = $("input[id^=salesPersonName]").map(function() {
    return $(this).val() || ""
  }).get();
  console.log(v)
})

Demo

function addRow() {
  $("#row-list-outer").append(`

                       <input type="text" id="salesPersonName${$("input[id^=salesPersonName]").length + 1}" placeholder="Name">

`)
}

$(document).on("change","input[id^=salesPersonName]",function() {
  var v = $("input[id^=salesPersonName]").map(function() {
    return $(this).val() || ""
  }).get();
  console.log(v)
})

<button onclick="addRow()">addRow</button>
Answer: You can try the following code:
HTML:

  <button>Change color</button>

Jquery:
$("button").click(function(e){
e.preventDefault();
 $("#row-list-outer").append(`

                       <input type="text" class="salesPersonName"
data-id="${$('.salesPersonName').length + 1}" placeholder="Name">

`);
})
let colors = [];
$(document).on("change","input",function(e){
    let i = +$(this).data('id') - 1
  colors[i] = $(this).val();
  console.log(colors)
});


Ruby regex without global flag

Question: I have a regex problem. I have this regex:
/(https|http):\/\/(kwagmire)\.(com)\/(embed)\/([a-zA-Z0-9]+)/i

and this captures correctly on https://regexr.com but on Ruby on Rails anything with
http://kwagmire.com/embed/1QgJVmCam

returns a truthy value, I think because it sets it with the global flag which I don't want.
I tried match and scan but still the same returns a truthy value if the link is seen. I just want it to be specific.
https://kwagmire.com/embed/1QgJVmCam < I want to return success this one is ok when testing on console

http://kwagmire.com/embed/1QgJVmCam < I want to return success also this on returns good

https.evil.com/http://jsitor.com/embed/1QgJVmCam < I want to return fail or nil, this one passes returns all match

facebook.com < I want to return fail or nil this one is good because it's failing

https://google.com < I want to return fail or nil also this good failed
www.twitter.com < I want to return fail or nil

http://kwagmire.com/embed/1QgJVmCam/?onload(alert('asdfadsf')) < I want to return fail or nil, this one also is failing, good

http://kwagmire.com/embed/1QgJVmCam/   onload(alert('asdfadsf')) < I want to return fail or nil, this one returns match too but should fail

http://kwagmire.com/embed/1QgJVmCam/?onload(alert('asdfadsf')) < I want to return fail or nil, this one returns match too, this should fail

basically I want this https://kwagmire.com/embed/1QgJVmCam all else should return nil or false. is there an easy way without looping? I think the solution on this one is remove the global flag or g but do you have that option? If so why if I do this?
see the i after /
/(https|http):\/\/(jsitor)\.(com)\/(embed)\/([a-zA-Z0-9]+)/i.match("http://jsitor.com/embed/1QgJVmCam/ onload(alert('asdfadsf'))")

and returns but this should fail
#<MatchData "http://jsitor.com/embed/1QgJVmCam" 1:"http" 2:"jsitor" 3:"com" 4:"embed" 5:"1QgJVmCam">

Comment: Can you be more specific on what you want to achieve? Can you provide some test links of what you want to match and what links shouldn't match?
Comment: You need to state your question in terms of what you want to achieve, *without reference to a regular expression*. That is, you have a number of strings you want to test. Only one passes the test. What is the test?  That's how you need to frame your question. After you have done so you can present the regular expression you tried, and explain why it doesn't work. Lastly, forget about speculating as to why the regular expression doesn't work.
Comment: @allenbrkn check text before `<` I edited it
Comment: For what it's worth, this is not a question about Rails. This is a question about pure Ruby.
Comment: Rather than try to write a regex, which for URI is complex, use Ruby's URI class which already has it written and it works, and which allows you to break a path into its components and then check them individually. In particular, look at [`split`](https://docs.ruby-lang.org/en/2.1.0/URI.html#method-c-split) and [`parse`](https://docs.ruby-lang.org/en/2.1.0/URI.html#method-c-parse).
Answer: I guess,
(?im)^https?:\/\/(?:w{3})?kwagmire\.com\/embed\/([a-zA-Z0-9]+)\/?$

might simply work OK.
Test
re = /^https?:\/\/(?:w{3})?kwagmire\.com\/embed\/([a-zA-Z0-9]+)\/?$/im
str = 'https://kwagmire.com/embed/1QgJVmCam
http://kwagmire.com/embed/1QgJVmCam
https.evil.com/http://jsitor.com/embed/1QgJVmCam
facebook.com
https://google.com
www.twitter.com
http://kwagmire.com/embed/1QgJVmCam/?onload(alert(\'asdfadsf\'))
http://kwagmire.com/embed/1QgJVmCam/   onload(alert(\'asdfadsf\'))'

str.scan(re) do |match|
    puts match.to_s
end

Output
["1QgJVmCam"]
["1QgJVmCam"]

RegEx Circuit
jex.im visualizes regular expressions:

If you wish to simplify/modify/explore the expression, it's been explained on the top right panel of regex101.com. If you'd like, you can also watch in this link, how it would match against some sample inputs.
Comment: With ruby, `^` and `$` match always the start and end of the line, and the m modifier allows the dot to match newlines.
Comment: sorry sir this doesn't work. I was thinking of like `regex_without_global.match('https://kwagmire.com/embed/1QgJVmCam')` return truthy

`regex_without_global.match('https://kwagmire.com/embed/1QgJVmCam/?evilevil')` return nil
Comment: @CasimiretHippolyte but it just give me an empty array when I tried his approach tho
Answer: Looks like you just need either ^ and $ at the beginning and end of your regex, or better yet \A and \Z to mark the beginning and end of the entire string (^ and $ work as long as it is a single line).
This is telling Ruby that it must match from beginning to end.  Also the 'i' at the end isn't necessary and may yield incorrect results.
The following modified regex will work.
/\A(https|http):\/\/(kwagmire)\.(com)\/(embed)\/([a-zA-Z0-9]+)\/?\Z/
Note that besides the \A and \Z I also added \/? which allows for an optional / at the end of the url. I also removed the i at the end because you don't actually want the entire regex to be case insensitive.  The last part ([a-zA-Z0-9]+) already is case insensitive by how it is declared with a-z and A-Z.
myregex.match("http://kwagmire.com/embed/1QgJVmCa/?onload(alert('asdfadsf'))")
 returns nil
myregex.match("http://kwagmire.com/embed/1QgJVmCam/")
 returns #<MatchData "http://kwagmire.com/embed/1QgJVmCam/" 1:"http" 2:"kwagmire" 3:"com" 4:"embed" 5:"1QgJVmCam">
Comment: also i added this \A and \Z but on https://regexr.com/ its saying that literal A thats why i didn't use it.
Comment: yow sir I think this is it. this is all I want. I knew there's a simple way without looping this because I know what the url is going to be. Ive used similar way in javascript before i just forgot. thank you!  @randall
Answer:
Some people, when confronted with a problem, think "I know, I'll use
  regular expressions." Now they have two problems.

Ruby has the URI module which actually parses URI's and understands them. It will beat the socks off almost any regular expression when it comes to actually working with URIs.
Input:
input = ["https://kwagmire.com/embed/1QgJVmCam", "http://kwagmire.com/embed/1QgJVmCam", "https.evil.com/http://jsitor.com/embed/1QgJVmCam", "facebook.com", "https://google.com", "www.twitter.com", "http://kwagmire.com/embed/1QgJVmCam/?onload(alert('asdfadsf'))", "http://kwagmire.com/embed/1QgJVmCam/   onload(alert('asdfadsf'))"]

require 'uri'

# This assumes that the id is 9 characters
re =  /\A\/embed\/[\d|a-zA-Z]{9}\/?\Z/.freeze
clean = input.map do |line|
  begin
    uri = URI(line)
    if uri.host == 'kwagmire.com' && uri.path =~ re && !uri.query
      uri.to_s
    end
  rescue URI::InvalidURIError
    nil
  end
end.compact

Output:
["https://kwagmire.com/embed/1QgJVmCam", "http://kwagmire.com/embed/1QgJVmCam"]

This lets you use a far simpler regular expression to verify the path, you could also just use uri.path.split('/') and forgo a regex completely. It also guarantees that you are dealing with a valid URI.

Ruby regex without global flag


Which set of books could I read to become an advanced conductor?

Question: I would like a list of three to ten books to learn all there is to know about conducting.
Please be concise, try to cover all the stages from a beginner conductor (but already an experienced adult instrumentalist or composer) to what an advanced conductor would need.
My dream is that the reader of this series could go out, grab a score, learn it and have an orchestra rehearse and rock it out.
I am more interested in chamber orchestra as opposed to a full symphony, but this is a general question. If there are books on conducting symphonic formations but it still applies to conducting in general, it should be on the list.
I would prefer books easy to find and purchase, not the kind you need an archeologist to excavate. I am ready to invest in valuable books if their content warrant it.
So, which set of books could I read to become an advanced conductor?
Comment: Related meta discussion: http://meta.music.stackexchange.com/questions/125/are-shopping-list-questions-on-topic
Comment: (Thanks commenters. It's apparent I'll have to reformulate my question. Unfortunately I have to go offline now. I'll address the issues you pointed out as soon as I can.)
Comment: You're making a number of assumptions here, and I'm not convinced the question is answerable as a result. 1) You're assuming that there is a "right way" to conduct. There are more schools of conducting than you can count, and while I certainly have an opinion of what the "right way" is, the book for that method actually hasn't been published yet, _and_ many people would disagree with me. 2) You're insisting that no one book is "complete," but in less than 10 it's possible to know all there is to know.
Comment: Calling a question "very straight-forward" does not make it so, especially when the question then lists four paragraphs of restrictions and provisos.
Comment: a) You are asking for complete immediate, all-purpose and multi-stage answers, but very good answers are progressive and grow out of comments and confrontation. b) If you do not rephrase your question to narrow it and make it answerable, it will likely be closed without any answers at all. c) If your way of asking this community for help is to tell it in advance that most things they are likely to do will be "bad", you are perhaps not very keen on having answers. d) You have not enough reputation to downvote any incorrect answer. :-)
Comment: @Allan by the way, I think your english is excellent.
Comment: Before we close, I'd like to give Allan a chance to reword the question to meet our (still evolving) guidelines. He's obviously acting in good faith and I think that should be rewarded, especially in a beta SE community.
Comment: @Allan : I have heavily edited your question in a form that seem to me more answerable, more humble and not looking like a scarecrow to all potential partial answerers. If you do not like it, just roll it back or do something else.
Comment: No point trying to reword it until someone makes things clear on the meta discussion. From where I stand now it seems it's impossible to ask anything.
Comment: @Allan : I have answered you on meta. Like Rein and Matthew, I believe it is worth you rewrite your questions.
Comment: I'm OK with this in its current form.  That said, it is quite specific.  Very few of the world's advanced conductors have signed up for this site, I assume, and no one else can answer it well.
Answer: There are many reference books about conducting, some of them still being read despite dating from the early 20th century but your dream is just a dream. Conducting is as much apprenticeship as theory. And as many here have remarked, conducting schools and styles abound. You have to make a choice or let life make the choice for you.
In the original version of your question you warned:

Please don't include books on peripheral subjects. For example "read this book about rhythm because you need to know rhythm to conduct" is bad. This question is about books specific to conducting.

That's twice a pity. First because what you assume to be peripheral, most good conducting books I could recommend would tell you to spend as much time as possible on them:

Understanding harmony and orchestration from a composer's point of view
Understanding the subtlety of the rythmic and dynamic hierarchy of instruments
Always go deeper in your analysis of the music notation.
Go on practicing chamber music as much as possible (you are probably doing it)
Go to concert as much as possible. Try to be allowed backstage.

Second, because one of the best book I could recommend to every budding conductor is on what you might term "a peripheral subject" and was published just six months ago (you won't need an archeologist) and I am fortunate to know one musician who was consulted for its content:

Elaine Gould, Behind Bars, Faber and Faber 2010 you can find reviews here

To build a progressive repertoire for a chamber music orchestra, you might be interested by this book from a violinist and conductor, starting at the beginning

Barbara Boscaino Tamburro, Great Music for String Orchestra, Meredith Publications

In general their orchestra conducting books are recent, innovative and not too expensive and cover from beginner to intermediate, both from a conducting point of view and from an orchestra member point of view.
Same publisher than Elaine Gould, for a conductor with already some field experience, wanting to try himself of some of the greatest works of the repertoire, I find this book very inspirational:

Pierre Boulez, Boulez on Conducting

to be read while listening to some of his recordings and some by other conductors with a very different style like L. Bernstein.
This is the kind of book that you would better loan from a library than buy yourself.


$f(x,y)$ in polar coordinates

Question: So, I have $ f(x,y) = (x^2-y^2, 2xy) $,
which is a local $\mathcal C^1$ isomorphism in  $\mathbb R^2 \setminus \{(0,0)\}$.
I have to write this function in polar coordinates:
$$f(x,y) = f(r\cos\phi, r\sin\phi).$$
My beginnings:
I know that
$$df(r, \phi) =
\cos\phi -r\sin\phi
\sin\phi r\cos\phi.$$
But I really have no clue how to work this one out. It is a single exercise of this kind in my book; so, I probably  don't need it for the test, but I would like to know.
Comment: Just plug in $r\cos \phi$ and $r\sin\phi$ for $x$ and $y$ respectively.  Note that trig identities will allow you to simplify your result.
Comment: As @Aaron suggested $f(r,\theta)$ can be obtained by replacing $x$ with $r\cos{\theta}$ and $y$ with $r\sin{\theta}$
Answer: In polar coordinates, we have $(x,y) =(r\cos\phi, r\sin\phi)$ as you said. Therefore,
$f(x,y) = (x^2-y^2, 2xy)$ can be rewritten as
$$f(x,y) =f(r\cos\phi, r\sin\phi)= \big((r\cos\phi)^2-(r\sin\phi)^2, 2(r\cos\phi)(r\sin\phi)\big)$$
$$=\big(r^2(\cos^2\phi-\sin^2\phi),r^2(2\sin\phi\cos\phi)\big)=\big(r^2\cos(2\phi),r^2\sin(2\phi)\big).$$
Comment: thanx much paul, i came to similar solution. Would that mean that the function is bijective only from (0,8)x(0, 2Pi) because of ϕ being periodic?

$f(x,y)$ in polar coordinates


tool to publish mail (from Exchange server) on the internal web site

Question: When we work on specific defects or features, many important discussions and decisions comes in via mail.   I would like to forward all mails to an email id and that publishes e-mails on a web. Is there a solution I can deploy an intranet server?
Our mail server is Microsoft Exchange.
Answer: Sharepoint (shudder) does this out of the box - you can give a Document Library an email address, and any messages sent to that address will get saved in the Document Library.


How does the system choose the right Page Table?

Question: Let's focus on uniprocessor computer systems. When a process gets created, as far as I know, the page table gets set up which maps the virtual addresses to the physical memory address space. Each process gets its own page table, stored in the kernel address space. But how does the MMU choose the right page table for the process since there is not only one process running and there will be many context switches happening?
Any help is appreciated!
Best,
Simon
Answer: Processors have a privileged register called the page table base register (PTBR), on x86 it is CR3.  On a context switch, the OS changes the value of the PTBR so that the processor now knows which page table to use.  In addition to the PTBR, many modern processors have a notion of an address space number (ASN).  Processes are given an address space number (from a limited pool) and this ASN is set in a register on a context switch as well.  This ASN is used as part of TLB matching and allows TLB entries from multiple address spaces to coexist.  Only when an ASN is reused is it necessary to flush the TLB, and then only for entries matching that ASN.  Most x86 implementations are more coarse grained than this and there is a notion of global pages (for shared libraries and shared data).
Answer: The MMU in this case is unaware completely of what a process is. The operating system, which keeps tracks of processes, generates a page table for each process, as you say, as they are created. The process for context switching is as follows:

The operating system tells the MMU to use page table located at physical address 0xFOO
The operating system programs the programmable interrupt timer (PIT) to cause a hardware interrupt after BAR milliseconds.
The operating system restores the process state (CPU registers, program counter, etc) and jumps to the correct address.
The process runs until the PIT triggers an interrupt.
The Operating System routine for handling the PIT interrupt then saves the program state (registers etc), uses a scheduling algorithm for determining the next process to run (in a simple case, a circular linked list), then starts over at step 1.

I hope that clears up any doubts you may have. The short answer: The MMU is process agnostic and doesn't know what a process is.
Comment: Thank you for your quick reply. So you say that the OS does flush & restore the page table on each context switch?
Comment: @user1435023 Essentially. The operating system tells the MMU where the table is located in physical memory as a pointer, then the MMU handles the flushing of the TTL and other hardware tasks. Depending on the MMU, the operating system may have more fine grained control of the low level details, but this is not strictly necessary. At the simplest level, all the OS cares about is telling the MMU which page table to use.
Comment: @user1435023 Correction: Meant TLB above, *not* TTL. Nathan Binkert answered more on the TLB aspect of things


DNS Scavenging - "This zone can be scavenged after" time stamp missing

Question: I am setting up DNS scavenging on a Windows 2003 server. When I go to set up scavenging on a zone the "This zone can be scavenged after" time stamp box is blank and not editable. Is this intended behavior? I thought this box should have todays date and time.
Thanks in advance for any advice
Answer: The box indeed should have a timestamp (not necessarily the current one) if you have you enabled both - dynamic updates and scavenging - for the zone in question. It should not be editable at any time.

When you first set scavenging on a zone the timestamp seen at the bottom (reload zone if you don't see it) will be set to the current time of day rounded down to the nearest hour plus the Refresh interval.  This also gets reset any time the zone is loaded or any time dynamic updates get enabled on the zone.

(From: http://blogs.technet.com/b/networking/archive/2008/03/19/don-t-be-afraid-of-dns-scavenging-just-be-patient.aspx)
Comment: I have both enabled
Comment: @BigJ so have you tried reloading the zone as suggested in the quoted passage?
Comment: I did and now it works. I'm a dumby. Thanks mucho!


Usar Bootstrap e Primefaces sem que um interfira no outro?

Question: Estou tentanto usar Bootstrap juntamente com primefaces em um projeto JSF, o problema é que na maioria dos componentes eu preciso usar tags do JSF ao invés do primefaces porque o primefaces faz algumas gambiarras com o html e com isso os css do bootstrap e do primefaces ficam se conflitando em alguns componentes, um pequeno código pra ficar melhor entendido:

        <h:selectOneMenu id="tipo-beneficio" styleClass="form-control" value="#{processomb.tipoBeneficio}" valueChangeListener="#{processomb.changeBeneficio}" >

            <f:selectItem itemLabel="Funeral" itemValue="funeral" />
            <f:selectItem itemLabel="Natalidade" itemValue="natalidade" />
            <f:selectItem itemLabel="Creche" itemValue="creche" />
            <f:selectItem itemLabel="Doença" itemValue="doenca" />
        </h:selectOneMenu>

Onde tem o h:selectOneMenu ele consegue exibir perfeitamente, mas se eu usar p:selectOneMenu ele desenha duas divs uma com o estilo do bootstrap e outra com o do primefaces para o mesmo componente.
O estilo do primefaces é alterado mesmo que eu tire a styleClass="form-control", haveria alguma forma de conviverem os dois em harmonia?
Comment: Tem um esquema de tirar o bootstrap das tags html por default e deixar só como classes, mas dai você teria que colocar as classes que deseja manualmente. Não se seria uma boa solução
Comment: Você tentou desabilitar o tema do primefaces e importar o do bootstrap na mão?
Comment: Até o momento, acho que ainda não tem como -- em parte porque os componentes do Primefaces são baseados no jQuery-UI.
Comment: Não @uaiHebert, o que estou fazendo para contornar esse problema é não importar nenhuma classe do bootstrap no componente do primefaces que vou utilizar, assim ele fica com o design do primefaces mesmo...
Comment: PESSOAL!!! ESSA PERGUNTA SE TORNOU BASTANTE POPULAR, ENTÃO APÓS TODO ESSE TEMPO ESTOU ADICIONANDO UMA SUGESTÃO DO QUE PODE SER A SOLUÇÃO ATUAL PARA O PROBLEMA: USAR BOOTFACES. PEÇO A QUEM INTERESSAR DAR UMA OLHADINHA EM WWW.BOOTSFACES.NET
Answer: A incompatibilidade do Bootstrap com o jQuery UI (no qual o PrimeFaces é baseado) é conhecida. Além disso, o tema baseado no Bootstrap do PrimeFaces é bem alterado em relação à versão original da biblioteca, o que não ajuda muito quando se deseja usar algumas funcionalidades dela.
Se o seu objetivo é usar o Grid system, crie uma versão personalizada apenas com esse componente. Isso vai evitar conflitos com outros componentes e scripts e, com um pouco de sorte, não vai afetar as funcionalidades que você está usando do PrimeFaces.
Em alguns casos, mesmo com a biblioteca completa é possível resolver conflitos com outros frameworks em componentes específicos usando a função noConflict(). Isso evita que tanto o Bootstrap quanto o outro framework (como o jQuery UI) tentam "melhorar" o mesmo elemento.
Answer: Se o que você quiser for apenas o sistema de colunas do bootstrap, você pode entrar no site do bootstrap e baixar um estilo apenas com este recurso, e com apenas algumas poucas modificações você consegue deixar ele 100% compatível com o primefaces. Segue o exemplo, esse bootstrap eu adaptei para meu projeto:

/*
  Bootstrap v3.3.1 (http://getbootstrap.com)
*/
/*
  NOTE:
  This file has Normalize.css removed.
  It still requires a "reset.css", so we're using this...
  https://github.com/nathansmith/unsemantic/blob/master/assets/stylesheets/reset.css
*/

{
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}

*:before,
*:after {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}
.container {
    margin-right: auto;
    margin-left: auto;
    padding-left: 15px;
    padding-right: 15px;
}
@media (min-width: 768px) {
    .container {
        width: 750px;
    }
}
@media (min-width: 992px) {
    .container {
        width: 970px;
    }
}
@media (min-width: 1200px) {
    .container {
        width: 1170px;
    }
}
.container-fluid {
    margin-right: auto;
    margin-left: auto;
}
.row {
    margin-left: -15px;
    margin-right: -15px;
}
.col-xs-1,
.col-sm-1,
.col-md-1,
.col-lg-1,
.col-xs-2,
.col-sm-2,
.col-md-2,
.col-lg-2,
.col-xs-3,
.col-sm-3,
.col-md-3,
.col-lg-3,
.col-xs-4,
.col-sm-4,
.col-md-4,
.col-lg-4,
.col-xs-5,
.col-sm-5,
.col-md-5,
.col-lg-5,
.col-xs-6,
.col-sm-6,
.col-md-6,
.col-lg-6,
.col-xs-7,
.col-sm-7,
.col-md-7,
.col-lg-7,
.col-xs-8,
.col-sm-8,
.col-md-8,
.col-lg-8,
.col-xs-9,
.col-sm-9,
.col-md-9,
.col-lg-9,
.col-xs-10,
.col-sm-10,
.col-md-10,
.col-lg-10,
.col-xs-11,
.col-sm-11,
.col-md-11,
.col-lg-11,
.col-xs-12,
.col-sm-12,
.col-md-12,
.col-lg-12 {
    position: relative;
    min-height: 1px;
    padding: 2px 4px 4px;
}
.col-xs-1,
.col-xs-2,
.col-xs-3,
.col-xs-4,
.col-xs-5,
.col-xs-6,
.col-xs-7,
.col-xs-8,
.col-xs-9,
.col-xs-10,
.col-xs-11,
.col-xs-12 {
    float: left;
}
.col-xs-12 {
    width: 100%;
}
.col-xs-11 {
    width: 91.66666667%;
}
.col-xs-10 {
    width: 83.33333333%;
}
.col-xs-9 {
    width: 75%;
}
.col-xs-8 {
    width: 66.66666667%;
}
.col-xs-7 {
    width: 58.33333333%;
}
.col-xs-6 {
    width: 50%;
}
.col-xs-5 {
    width: 41.66666667%;
}
.col-xs-4 {
    width: 33.33333333%;
}
.col-xs-3 {
    width: 25%;
}
.col-xs-2 {
    width: 16.66666667%;
}
.col-xs-1 {
    width: 8.33333333%;
}
.col-xs-pull-12 {
    right: 100%;
}
.col-xs-pull-11 {
    right: 91.66666667%;
}
.col-xs-pull-10 {
    right: 83.33333333%;
}
.col-xs-pull-9 {
    right: 75%;
}
.col-xs-pull-8 {
    right: 66.66666667%;
}
.col-xs-pull-7 {
    right: 58.33333333%;
}
.col-xs-pull-6 {
    right: 50%;
}
.col-xs-pull-5 {
    right: 41.66666667%;
}
.col-xs-pull-4 {
    right: 33.33333333%;
}
.col-xs-pull-3 {
    right: 25%;
}
.col-xs-pull-2 {
    right: 16.66666667%;
}
.col-xs-pull-1 {
    right: 8.33333333%;
}
.col-xs-pull-0 {
    right: auto;
}
.col-xs-push-12 {
    left: 100%;
}
.col-xs-push-11 {
    left: 91.66666667%;
}
.col-xs-push-10 {
    left: 83.33333333%;
}
.col-xs-push-9 {
    left: 75%;
}
.col-xs-push-8 {
    left: 66.66666667%;
}
.col-xs-push-7 {
    left: 58.33333333%;
}
.col-xs-push-6 {
    left: 50%;
}
.col-xs-push-5 {
    left: 41.66666667%;
}
.col-xs-push-4 {
    left: 33.33333333%;
}
.col-xs-push-3 {
    left: 25%;
}
.col-xs-push-2 {
    left: 16.66666667%;
}
.col-xs-push-1 {
    left: 8.33333333%;
}
.col-xs-push-0 {
    left: auto;
}
.col-xs-offset-12 {
    margin-left: 100%;
}
.col-xs-offset-11 {
    margin-left: 91.66666667%;
}
.col-xs-offset-10 {
    margin-left: 83.33333333%;
}
.col-xs-offset-9 {
    margin-left: 75%;
}
.col-xs-offset-8 {
    margin-left: 66.66666667%;
}
.col-xs-offset-7 {
    margin-left: 58.33333333%;
}
.col-xs-offset-6 {
    margin-left: 50%;
}
.col-xs-offset-5 {
    margin-left: 41.66666667%;
}
.col-xs-offset-4 {
    margin-left: 33.33333333%;
}
.col-xs-offset-3 {
    margin-left: 25%;
}
.col-xs-offset-2 {
    margin-left: 16.66666667%;
}
.col-xs-offset-1 {
    margin-left: 8.33333333%;
}
.col-xs-offset-0 {
    margin-left: 0%;
}
@media (min-width: 768px) {
    .col-sm-1,
    .col-sm-2,
    .col-sm-3,
    .col-sm-4,
    .col-sm-5,
    .col-sm-6,
    .col-sm-7,
    .col-sm-8,
    .col-sm-9,
    .col-sm-10,
    .col-sm-11,
    .col-sm-12 {
        float: left;
    }
.col-sm-12 {
    width: 100%;
}

.col-sm-11 {
    width: 91.66666667%;
}

.col-sm-10 {
    width: 83.33333333%;
}

.col-sm-9 {
    width: 75%;
}

.col-sm-8 {
    width: 66.66666667%;
}

.col-sm-7 {
    width: 58.33333333%;
}

.col-sm-6 {
    width: 50%;
}

.col-sm-5 {
    width: 41.66666667%;
}

.col-sm-4 {
    width: 33.33333333%;
}

.col-sm-3 {
    width: 25%;
}

.col-sm-2 {
    width: 16.66666667%;
}

.col-sm-1 {
    width: 8.33333333%;
}

.col-sm-pull-12 {
    right: 100%;
}

.col-sm-pull-11 {
    right: 91.66666667%;
}

.col-sm-pull-10 {
    right: 83.33333333%;
}

.col-sm-pull-9 {
    right: 75%;
}

.col-sm-pull-8 {
    right: 66.66666667%;
}

.col-sm-pull-7 {
    right: 58.33333333%;
}

.col-sm-pull-6 {
    right: 50%;
}

.col-sm-pull-5 {
    right: 41.66666667%;
}

.col-sm-pull-4 {
    right: 33.33333333%;
}

.col-sm-pull-3 {
    right: 25%;
}

.col-sm-pull-2 {
    right: 16.66666667%;
}

.col-sm-pull-1 {
    right: 8.33333333%;
}

.col-sm-pull-0 {
    right: auto;
}

.col-sm-push-12 {
    left: 100%;
}

.col-sm-push-11 {
    left: 91.66666667%;
}

.col-sm-push-10 {
    left: 83.33333333%;
}

.col-sm-push-9 {
    left: 75%;
}

.col-sm-push-8 {
    left: 66.66666667%;
}

.col-sm-push-7 {
    left: 58.33333333%;
}

.col-sm-push-6 {
    left: 50%;
}

.col-sm-push-5 {
    left: 41.66666667%;
}

.col-sm-push-4 {
    left: 33.33333333%;
}

.col-sm-push-3 {
    left: 25%;
}

.col-sm-push-2 {
    left: 16.66666667%;
}

.col-sm-push-1 {
    left: 8.33333333%;
}

.col-sm-push-0 {
    left: auto;
}

.col-sm-offset-12 {
    margin-left: 100%;
}

.col-sm-offset-11 {
    margin-left: 91.66666667%;
}

.col-sm-offset-10 {
    margin-left: 83.33333333%;
}

.col-sm-offset-9 {
    margin-left: 75%;
}

.col-sm-offset-8 {
    margin-left: 66.66666667%;
}

.col-sm-offset-7 {
    margin-left: 58.33333333%;
}

.col-sm-offset-6 {
    margin-left: 50%;
}

.col-sm-offset-5 {
    margin-left: 41.66666667%;
}

.col-sm-offset-4 {
    margin-left: 33.33333333%;
}

.col-sm-offset-3 {
    margin-left: 25%;
}

.col-sm-offset-2 {
    margin-left: 16.66666667%;
}

.col-sm-offset-1 {
    margin-left: 8.33333333%;
}

.col-sm-offset-0 {
    margin-left: 0%;
}

}
@media (min-width: 992px) {
    .col-md-1,
    .col-md-2,
    .col-md-3,
    .col-md-4,
    .col-md-5,
    .col-md-6,
    .col-md-7,
    .col-md-8,
    .col-md-9,
    .col-md-10,
    .col-md-11,
    .col-md-12 {
        float: left;
    }
.col-md-12 {
    width: 100%;
}

.col-md-11 {
    width: 91.66666667%;
}

.col-md-10 {
    width: 83.33333333%;
}

.col-md-9 {
    width: 75%;
}

.col-md-8 {
    width: 66.66666667%;
}

.col-md-7 {
    width: 58.33333333%;
}

.col-md-6 {
    width: 50%;
}

.col-md-5 {
    width: 41.66666667%;
}

.col-md-4 {
    width: 33.33333333%;
}

.col-md-3 {
    width: 25%;
}

.col-md-2 {
    width: 16.66666667%;
}

.col-md-1 {
    width: 8.33333333%;
}

.col-md-pull-12 {
    right: 100%;
}

.col-md-pull-11 {
    right: 91.66666667%;
}

.col-md-pull-10 {
    right: 83.33333333%;
}

.col-md-pull-9 {
    right: 75%;
}

.col-md-pull-8 {
    right: 66.66666667%;
}

.col-md-pull-7 {
    right: 58.33333333%;
}

.col-md-pull-6 {
    right: 50%;
}

.col-md-pull-5 {
    right: 41.66666667%;
}

.col-md-pull-4 {
    right: 33.33333333%;
}

.col-md-pull-3 {
    right: 25%;
}

.col-md-pull-2 {
    right: 16.66666667%;
}

.col-md-pull-1 {
    right: 8.33333333%;
}

.col-md-pull-0 {
    right: auto;
}

.col-md-push-12 {
    left: 100%;
}

.col-md-push-11 {
    left: 91.66666667%;
}

.col-md-push-10 {
    left: 83.33333333%;
}

.col-md-push-9 {
    left: 75%;
}

.col-md-push-8 {
    left: 66.66666667%;
}

.col-md-push-7 {
    left: 58.33333333%;
}

.col-md-push-6 {
    left: 50%;
}

.col-md-push-5 {
    left: 41.66666667%;
}

.col-md-push-4 {
    left: 33.33333333%;
}

.col-md-push-3 {
    left: 25%;
}

.col-md-push-2 {
    left: 16.66666667%;
}

.col-md-push-1 {
    left: 8.33333333%;
}

.col-md-push-0 {
    left: auto;
}

.col-md-offset-12 {
    margin-left: 100%;
}

.col-md-offset-11 {
    margin-left: 91.66666667%;
}

.col-md-offset-10 {
    margin-left: 83.33333333%;
}

.col-md-offset-9 {
    margin-left: 75%;
}

.col-md-offset-8 {
    margin-left: 66.66666667%;
}

.col-md-offset-7 {
    margin-left: 58.33333333%;
}

.col-md-offset-6 {
    margin-left: 50%;
}

.col-md-offset-5 {
    margin-left: 41.66666667%;
}

.col-md-offset-4 {
    margin-left: 33.33333333%;
}

.col-md-offset-3 {
    margin-left: 25%;
}

.col-md-offset-2 {
    margin-left: 16.66666667%;
}

.col-md-offset-1 {
    margin-left: 8.33333333%;
}

.col-md-offset-0 {
    margin-left: 0%;
}

}
@media (min-width: 1200px) {
    .col-lg-1,
    .col-lg-2,
    .col-lg-3,
    .col-lg-4,
    .col-lg-5,
    .col-lg-6,
    .col-lg-7,
    .col-lg-8,
    .col-lg-9,
    .col-lg-10,
    .col-lg-11,
    .col-lg-12 {
        float: left;
    }
.col-lg-12 {
    width: 100%;
}

.col-lg-11 {
    width: 91.66666667%;
}

.col-lg-10 {
    width: 83.33333333%;
}

.col-lg-9 {
    width: 75%;
}

.col-lg-8 {
    width: 66.66666667%;
}

.col-lg-7 {
    width: 58.33333333%;
}

.col-lg-6 {
    width: 50%;
}

.col-lg-5 {
    width: 41.66666667%;
}

.col-lg-4 {
    width: 33.33333333%;
}

.col-lg-3 {
    width: 25%;
}

.col-lg-2 {
    width: 16.66666667%;
}

.col-lg-1 {
    width: 8.33333333%;
}

.col-lg-pull-12 {
    right: 100%;
}

.col-lg-pull-11 {
    right: 91.66666667%;
}

.col-lg-pull-10 {
    right: 83.33333333%;
}

.col-lg-pull-9 {
    right: 75%;
}

.col-lg-pull-8 {
    right: 66.66666667%;
}

.col-lg-pull-7 {
    right: 58.33333333%;
}

.col-lg-pull-6 {
    right: 50%;
}

.col-lg-pull-5 {
    right: 41.66666667%;
}

.col-lg-pull-4 {
    right: 33.33333333%;
}

.col-lg-pull-3 {
    right: 25%;
}

.col-lg-pull-2 {
    right: 16.66666667%;
}

.col-lg-pull-1 {
    right: 8.33333333%;
}

.col-lg-pull-0 {
    right: auto;
}

.col-lg-push-12 {
    left: 100%;
}

.col-lg-push-11 {
    left: 91.66666667%;
}

.col-lg-push-10 {
    left: 83.33333333%;
}

.col-lg-push-9 {
    left: 75%;
}

.col-lg-push-8 {
    left: 66.66666667%;
}

.col-lg-push-7 {
    left: 58.33333333%;
}

.col-lg-push-6 {
    left: 50%;
}

.col-lg-push-5 {
    left: 41.66666667%;
}

.col-lg-push-4 {
    left: 33.33333333%;
}

.col-lg-push-3 {
    left: 25%;
}

.col-lg-push-2 {
    left: 16.66666667%;
}

.col-lg-push-1 {
    left: 8.33333333%;
}

.col-lg-push-0 {
    left: auto;
}

.col-lg-offset-12 {
    margin-left: 100%;
}

.col-lg-offset-11 {
    margin-left: 91.66666667%;
}

.col-lg-offset-10 {
    margin-left: 83.33333333%;
}

.col-lg-offset-9 {
    margin-left: 75%;
}

.col-lg-offset-8 {
    margin-left: 66.66666667%;
}

.col-lg-offset-7 {
    margin-left: 58.33333333%;
}

.col-lg-offset-6 {
    margin-left: 50%;
}

.col-lg-offset-5 {
    margin-left: 41.66666667%;
}

.col-lg-offset-4 {
    margin-left: 33.33333333%;
}

.col-lg-offset-3 {
    margin-left: 25%;
}

.col-lg-offset-2 {
    margin-left: 16.66666667%;
}

.col-lg-offset-1 {
    margin-left: 8.33333333%;
}

.col-lg-offset-0 {
    margin-left: 0%;
}

}
.clearfix:before,
.clearfix:after,
.container:before,
.container:after,
.container-fluid:before,
.container-fluid:after,
.row:before,
.row:after {
    content: " ";
    display: table;
}
.clearfix:after,
.container:after,
.container-fluid:after,
.row:after {
    clear: both;
}

O trecho abaixo é opcional, mas aqui tive que usar para deixar alguns componentes do primefaces renderizados corretamente:
[class*="col"] .ui-selectonemenu-label{
    width:100% !important;
}
[class*="col"] .ui-selectonemenu{
    width:100% !important;
}
[class*="col"] input {
    width: 100%;
}
[class*="col"] button {
    width: 100%;
}
[class*="col"] .ui-autocomplete {
    width: 100%;
}
[class*="col"] textarea {
    width: 100%;
}
[class*="col"] .ui-autocomplete-input {
    width: calc(100% - 20px);
}
[class*="col"] .ui-autocomplete-dropdown {
    width: 20px;
}

Answer: Essa pergunta se tornou bastante popular, então após todo esse tempo estou adicionando uma sugestão a qual é a solução atual para o problema. A não ser que você queira fazer no braço mediante as várias tentativas aqui propostas (desde já agradeço a todos) o mais sensato seria USAR BOOTSFACES , esse framework se propõe a fazer exatamente isso, permitir o uso harmonioso de Bootstrap e Primefaces, extraindo as potencialidades específicas de cada um. Peço a quem interessar dar uma olhadinha em WWW.BOOTSFACES.NET
Comment: Então essa biblioteca substitui o bootstrap e o primefaces ou apenas o bootstrap?
Answer: Se você está usando o Bootstrap somente pelo visual, você pode usar o tema Bootstrap do PrimeFaces: http://blog.primefaces.org/?p=2139
Para ativar o tema Bootstrap, modifique os seguintes arquivos (supondo que você está usando Maven):
pom.xml:
<dependency>
  <groupId>org.primefaces.themes</groupId>
  <artifactId>bootstrap</artifactId>
  <version>1.0.9</version>
</dependency>

web.xml:
<context-param>
  <param-name>primefaces.THEME</param-name>
  <param-value>bootstrap</param-value>
</context-param>

Comment: Eu sei @rodrigorgs, repare que já estou usando o tema do bootstrap no primefaces na figura, estou usando o bootstrap mais por causa do Grid System porém quero usar os componentes do primefaces também sem que haja essa interferência ou que ele se comporte como um componente do primefaces normal só que seguindo o grid system...
Comment: Ok, achei que você tivesse integrado o Bootstrap por fora.
Answer: Você esta utilizando as classes do bootstrap 3 para definir as colunas. Se não me engano a versão do bootstrap utilizado pelo Primefaces é a versão 2. Nesse caso, você deve utilizar as classes span3, span4, span12 para definir as colunas.
Answer: O ideal nesse caso é desativar o theme do Primefaces no web.xml:
  <context-param>
    <param-name>primefaces.THEME</param-name>
    <param-value>none</param-value>
  </context-param>

A partir daí você cria um novo theme customizado seguindo os passos deste link:
http://www.mkyong.com/jsf2/primefaces/create-a-custom-theme-in-primefaces/
Answer: Tente isto no css. Funcionou comigo.
/* Primefaces utiliza content-box, e o bootstrap modifica para border-box */

[class^="ui-"] {
       box-sizing: content-box !important;
}

Answer: Tente isso:

Comment: Bem-vindo ao Stack Overflow em Português! A comunidade está sempre receptiva a novos usuários que queriam contribuir com perguntas e respostas. Porém, não se assuste com os votos negativos que sua pergunta recebeu. O problema é que ela não responde adequadamente à pergunta, nem ajuda o autor. Você é livre para remover sua resposta ou mesmo tentar melhorá-la. E fique à vontade para responder outras perguntas, apenas observando se você está realmente respondendo o que está sendo perguntado.


Questions on bag of features methods

Question: I've been studying the bag of features (BoF) methods. I understand the basics and how it's done but I think I still am not good at the details. So here's my understanding of such methods:
Suppose you have a data base of images and you need to classify them. OK, then you must select local features in the first place. I read that there's no general rule on how they're selected, it highly depends on the application. Then, considering each of these local features is called "visual vocabulary",  the same steps as bag of words is applied here, too. In bag of words, we count the important words of a document using a histogram.
Here are my questions:

When your data base of image is relatively large and you have no information of the images individually, how are those local features selected? How do you know which parts of the image contains information and are thus important to us?
I read that these methods are simple because spatial features are ignored. Don't we lose information this way, or even, do we have enough information?

If you could suggest some good reads on the topic, I'd really appreciate it but please don't publish Google results, I've read most of them (if not all of them!).
In case someone is interested to know why is the word "bag" used; that's because they're unordered collections.
Comment: It seems to me this question is more suitable for [stats.se].
Comment: I agree with @Kaveh, if you'd like your question migrated then just flag it as such or comment here and I will take care of it.
Comment: @ArtemKaznatcheev: I think it's CS specific but still what choice do I have? please move it to CV if you think it'll be answered there.
Answer: First of all, you should distinguish between keypoints (feature points) and their descriptors (feature vectors constructed on the base of an image patch taken around corresponding keypoints). In theory, optimal detection and description of keypoints should be deeply connected. However, in practice, one can detect keypoints and construct their descriptors using almost unrelated methods.
Keypoints are the most unique (or informative) points and most stably detectable points on images. Of course, informativeness of points depends on image type under consideration. For ordinary images, informative and stable points lie on borders of uniform regions (since our visual world approximately consists of a set of smooth surfaces). Consequently, most detectors of keypoints are based on maxima of partial derivatives (gradient, Laplace operator, etc.). Of course, this is a simplification, so there are many different implementations of these detectors, which have somewhat different performance (and speed) on different images. If you don't want (or cannot) to select more suitable detector, the simplest way is to take any general detector, e.g. on the base of difference of Gaussians.
If your images are very specific (very unnatural), the only way is to automatically construct a good detector using the criterion of its informativeness. Different approaches to this problem exist originating from statistics and information theory. Or one can try adopting something like convolution autoencoders with pooling.
The same is true for descriptors, but their influence on performance more significant, and methods for constructing features are even more diverse. However, considerable part of hand-crafted feature transforms is very similar to features that can be obtained automatically by PCA, ICA, autoencoders, etc. Hand-crafted features can be calculated faster (due to code optimization), and don't require off-line learning. But if your images are of really unknown nature, then it is better to learn feature transforms from some training set of images. However, there is a questing concerning their invariance. Most methods with hand-crafted feature transforms perform affine (or rotation and scale) normalization of image patches before calculating features in order to achieve invariance to spatial transformations. Right now, no methods exist, which can learn arbitrary invariants.
Indeed, in bags of visual words spatial arrangement of keypoints is ignored. This makes comparison of images very fast. And, indeed, we lose valuable information this way, and in some cases remain information could not be enough for good recognitions. However, an alternative solution is to perform keypoint matching, which is much slower. Well, there are also intermediate solutions, in which some spatial information is incorporated, but full point-to-point matching is not needed.

Questions on bag of features methods


Have to do FreeLibrary 2 times although I have done LoadLibrary only 1 time. Also, after unloading DLL, when trying to load it again, error happens

Question: Have the following C# code for loading and unloading a C++ DLL.
I load DLL only once, but code has to unload DLL 2 times. Also after unloading DLL, when I load it again, and I call DLL's exported function, I get the following error message:

Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

DLL depends on other DLLs.
    /// //////////////handle of FDD DLL:
    System.IntPtr SystemIntPtr_handle_of_DLL=System.IntPtr.Zero;

    private void button4_Click(object sender, EventArgs e)
    {
        try
        {
            string string_Dependency_path = ".\\DLL_Dependencies\\";
            Call_DLL.SetDllDirectory(string_Dependency_path);
            SystemIntPtr_handle_of_DLL = Call_DLL.LoadLibrary("DLL.dll");
            if (SystemIntPtr_handle_of_DLL == System.IntPtr.Zero) { throw new Exception("DLL did not load"); }

        }
        catch (Exception Exception_Object) { MessageBox.Show(Exception_Object.Message); }
    }

    private void button5_Click(object sender, EventArgs e)
    {
        try
        {
            int int_FreeLibrary_counter = 0;
            while (Call_DLL.FreeLibrary(SystemIntPtr_handle_of_DLL))
            {
                int_FreeLibrary_counter++;
            }
            MessageBox.Show("DLL unloaded. You will have to load it again. (Unloaded" + int_FreeLibrary_counter + " times)");
        }
        catch (Exception Exception_Object) { MessageBox.Show(Exception_Object.Message); }
    }

The invoke method:
class Call_DLL
{
    [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
    [return: MarshalAs(UnmanagedType.Bool)]
    public static extern bool SetDllDirectory(string string_Dependency_path);
    [DllImport("kernel32.dll")]
    public static extern IntPtr LoadLibrary(string string_DLL_name);
    [DllImport("kernel32.dll", SetLastError = true)]
    [return: MarshalAs(UnmanagedType.Bool)]
    public static extern bool FreeLibrary(IntPtr IntPtr_handle_of_DLL);
}

EDIT
I forgot to include the following which call DLL exported functions, after loading DLL and before unloading DLL. It makes sense to think that something else is going on inside these exported functions which is causing strange behavior (i.e. loading 1 time, having to unload 2 times):
    [DllImport(@"DLL.dll", EntryPoint = "getFreq")]
    public static extern System.IntPtr getFreq([In, Out, MarshalAs(UnmanagedType.LPStr)] string char_Address, [In, Out, MarshalAs(UnmanagedType.I4)]int int_Num, [In, Out, MarshalAs(UnmanagedType.I4)]int int_Samp);
    [DllImport(@"DLL.dll", EntryPoint = "setNat")]
    public static extern System.IntPtr setNat([In, Out, MarshalAs(UnmanagedType.LPStr)]string char_Address_File_nat);
    [DllImport(@"DLL.dll", EntryPoint = "getMode")]
    public static extern System.IntPtr getMode();

Comment: It's pretty certain that freeing the library twice is why it fails on subsequent reload. Why do you feel you need to free it twice?
Comment: My psychic debugger says that you forgot to post your [DllImport] declaration that *also* uses this DLL.  You cannot do it both ways.
Comment: That behaviour cannot readily be re-produced. So until you can show us how to reproduce this, there's nothing to answer.
Comment: Not until you explain why you think you need to do this.  Up until now it looks completely pointless to use LoadLibrary.
Comment: Hmm, hardly.  But given how confused you are about SetDllDirectory(), you'll certainly have better luck with that.
Comment: SetDllDirectory is fine. You have to stop calling LoadLibrary. Then it's all good. Or follow the rules and call FreeLibrary as many times as you called LoadLibrary.
Comment: @DavidHeffernan You're right. I should think about how to provide information to be able to reproduce this behavior.
Comment: @HansPassant Right, I added now.
Comment: You still cannot do it both ways.
Comment: @HansPassant I didn't understand what you meant. Can you explain.
Comment: @HansPassant I was using `LoadLibrary` to be able to use `SetDllDirectory`, but I think you mean it is a better idea to use [this](http://stackoverflow.com/a/11418341/3405291) procedure. Right?
Comment: @HansPassant I'm going to test with [that](http://stackoverflow.com/a/11418341/3405291) procedure.
Comment: @HansPassant btw, please let me know if I'm not aware of any better procedure to use instead of `SetDllDirectory`.
Comment: Down-vote is not fair!
Answer: The update to your question provides enough information to explain the behaviour.

You call LoadLibrary to load your DLL which accounts for one of the references.
You call DllImport p/invoke functions which in turn lead to a call to LoadLibrary. That's the other reference to the library.
Then when you call FreeLibrary, this succeeds twice since there were two calls to LoadLibrary.

But now you are in trouble because you've gone behind the back of the p/invoke system and it still believes that it owns one of the references to the DLL. A reference that you stole from it with your second call to FreeLibrary.
I guess that the information you are missing is how the DllImport p/invokes bind to the function. You are hoping that they will obtain a module handle by calling GetModuleHandle. They don't. They call LoadLibrary. They do this the first time they are called and the module they load stays loaded until the assembly itself unloads.
What you have to do, above all else, is follow the rules. The rules state that each call to LoadLibrary is to be matched by a call to FreeLibrary. You call LoadLibrary once. So you must call FreeLibrary exactly once also. Stop calling it twice and all is well.
I suspect that you are actually trying to arrange a system whereby you can load and unload DLLs. This prevents you from using p/invoke via DllImport. You'll have to do it all with LoadLibrary and GetProcAddress.
Your usage of SetDllDirectory looks somewhat messed up. What do you expect ".\\DLL_Dependencies\\" to be relative to? Supply a full path.
Comment: In a comment of [this](http://stackoverflow.com/a/11418341/3405291) post, it is mentioned that _Path set via SetDllDirectory function will not be used when you're loading dlls via .NET interop (DllImport)_. My observation implies that that comment looks misleading.
Answer: If you only call LoadLibrary once then you only need to call FreeLibrary once as well. Calling it a second time is moving into undefined behavior.
If you look at the MSDN docs https://msdn.microsoft.com/en-us/library/windows/desktop/ms683152%28v=vs.85%29.aspx the function returns a non zero value if it succeeds, or 0 if there is an error.
If you want to be sure that its unloaded then you can call GetModuleHandle on it after the call to FreeLibrary and it should return null.
https://msdn.microsoft.com/en-us/library/windows/desktop/ms683199(v=vs.85).aspx
Updated your invoke method class to include:
[DllImport("kernel32.dll", CharSet=CharSet.Auto, SetLastError=true)]
public static extern IntPtr GetModuleHandle(string lpModuleName);

Then change your button5 click handler to the following:
private void button5_Click(object sender, EventArgs e)
{
    try
    {
        int freeCount = 0;
        while(Call_DLL.GetModuleHandle("DLL.dll") != System.IntPtr.Zero)
        {
             Call_DLL.FreeLibrary(SystemIntPtr_handle_of_DLL);
             freeCount++;
        }

        MessageBox.Show("DLL unloaded. You will have to load it again. (Unloaded" + int_FreeLibrary_counter + " times)");
     }
     catch(Exception Exception_Object)
     {
        MessageBox.Show(Exception_Object.Message);
     }
}

Comment: The question is asking why that second call succeeds. Can you explain why that happens?
Comment: The second call succeeds which is why it enters the loop body a second time
Comment: @user Why did you think anything would change. rgoble hasn't attempted to explain where the extra ref count comes from.
Comment: The second call doesn't succeed, it fails. The docs clearly state that it returns 0 if there is an error, which is why it exits the loop after the second call.
Comment: @rgoble I implemented your procedure with `GetModuleHandle` and behavior is the same: I load DLL 1 time, and `int_FreeLibrary_counter++` shows that it has to be unloaded 2 times.
Comment: @DavidHeffernan You're right. Code of rgoble was basically doing the same thing, no change expected.
Comment: @DavidHeffernan You were correct that it was unloading it twice. I was mistaken and thought FreeLibrary was only being called twice, but it was actually called 3 times.
Answer: I know that this question come to completion, but working on a similar problem I have found a way to load and unload library dynamically using DllImport and without exceptions.
The approach is based on these stakeholders:
- the DllImport load the library on the first call to a method wrapped.
- if a library is alredy loaded on the stack the call to a method will use this instance of the library instead load another one
based on these considerations you can manage your module in this way:

implement your class which wrap the library

    public class MyWrapper
    {
        int _libraryHandle = 0;

        [DllImport("mylibrary.dll")]
        public external static void MyMethod();
    }

in the constructor load the library using LoadLibrary:

    public MyWrapper()
    {
        _libraryHandle = LoadLibrary("mylibrary.dll");
    }

in the dispose method unload the library using FreeLibrary:

    public Dispose()
    {
        FreeLibrary(_libraryHandle);
    }

in this way everytime you'll instance your wrapper a new occurrence of the library will be loaded on the stack without any exception.
Answer: According to https://msdn.microsoft.com/en-us/library/windows/desktop/ms683152%28v=vs.85%29.aspx (the first google hit) If the function succeeds, the return value is nonzero. Your unload loop basically says "as long as freeing the library worked, free it again, until the unload fails".
Comment: I think that the asker knows this but can't understand why the number of calls to `LoadLibrary` doesn't match the number made to `FreeLibrary`. Do you know why?


I'm getting object data output from sqlite instead of the data I need

Question: I'm getting object data returned from my code here, but I don't see how I can be doing that.
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_manage);

    Log.d(TAG, "onCreate");

    datasource = new DataSource(this);
    datasource.open();

    List<Encouragement> values = datasource.getAllEncouragements();

    Log.d(TAG, "values");

    ArrayAdapter<Encouragement> adapter = new ArrayAdapter<Encouragement>(this,
        android.R.layout.simple_list_item_1, values);

    setListAdapter(adapter);
    Log.d(TAG, "end of onCreate");
}

and
public List<Encouragement> getAllEncouragements() {

    List<Encouragement> encouragements = new ArrayList<Encouragement>();

    Cursor cursor = database.query(DatabaseHelper.TABLE_ENCOURAGEMENTS,
            allColumns, null, null, null, null, null);

    cursor.moveToFirst();

    while (!cursor.isAfterLast()) {
        Encouragement encouragement = cursorToEncouragement(cursor);
        encouragements.add(encouragement);
        cursor.moveToNext();
    }

    cursor.close();
    return encouragements;
}

is producing com.example.myActivity.myObject@34563475 in the list item.
Answer: The listview is calling toString() to represent myObject.  You have not overridden the toString() method hence the default Object.toString() method is called.
@Override
public String toString(){
   return this.name; // whatever you need to represent this instance of myObject.
}