What is the symbol for "is the enharmonic equivalent of"?

Question: Say I want to write a statement like this, but in a more compact form:

E♯ is the enharmonic equivalent of  F♮

What symbol could I use instead of "is the enharmonic equivalent of"?
It doesn't seem right to me to use the equals sign = because the left and right hand sides aren't equal. The symbol should represent a qualified equivalence.
Or is the convention to "just hold your nose and use =" even though it's not actually true in the mathematical sense?
Edit 1
It occurs to me that we already use the equal sign in non-mathematical ways in music notation. For instance, the tempo indication:

♩ = 120

or the metric modulation:

♩. =

Perhaps it's OK after all to use a plain equals sign to denote enharmonic equivalence. The tacit assumption is that the human reader of the notation will know how to expand the compact notation back into an English sentence.
Edit 2
I came across the decorated equals sign: ≑ which (to me anyway) conveys the idea that the terms on its left and right are sort-of equal.
Thinking about it, E♯ and F♮ are two different notations for the same physical property i.e. pitch. In the same way you could say:

"one two three" ≑ "un deux trois"

Edit 3
The reason I asked the question originally was that I was experimenting with the notation of Theoretical Keys. We'd most of us be comfortable with the idea that

F♯ is the enharmonic equivalent of  G♭
F♯ ≑  G♭

and so:

6 sharps ≑ 6 flats

But what follows from this is this sort of thing:

10 sharps ≑ 2 flats

and

12 sharps ≑ 0 flats

The use of an equal sign in these statements looked plain wrong to me.
Comment: Well, there is a "congruent" symbol in math,  $\cong$  (oops no markdown at this site). It's an "=" sign with a tilde over it.
Comment: Relevant anecdote: a friend of mine (musician) spent a year on a fellowship at Princeton's Institute of Advanced Study.  As Albert Einstein used to hang out there years ago, I suggested she put a sign on her door proclaiming: "E = F♭".  Which she did.  It apparently was quite the conversation piece.  Anyhow -- yeah, the equals sign is commonly used for this.
Comment: Well, so long as you are in a well-tempered system, from a wavelength point of view, these two **are** equal.   So it sort of depends on your intended usage.
Comment: An observation - the two usages you bring up in the edit are more like assignment (like in programming) than equality, while enharmonic equivalence is a similarity relationship. I don't think that invalidates the point you make about conversion to English, but it does bring up an argument for introducing a different symbol for enharmonic equivalence since it has different semantics than the current usages.
Comment: @CarlWitthoft Sometimes when you cannot have LaTeX, you can input the symbols directly (Unicode): `≅`, `≃`, `∼`, `≈` (let us see if it works).
Comment: I use parenthesis like @dissemin8or. Usually the context is key signatures on the circle of fifths or tritone substitutions. In what context do you want to write it?
Comment: @CarlWitthoft it doesn't matter whether the system is well tempered, only that the systems uses the same pitch for both notes.  Stated differently: E♯ is the enharmonic equivalent of F♮ in *every* 12-tone system, regardless of the temperament used.  More broadly, it is true of every temperament based on a keyboard that does not have a distinct E♯ key.
Comment: Brian: are you looking for something to use when writing music notation, or are you looking for something to use for writing a proposition as one might in a formal logical proof?  I would argue that the equals signs in metronome markings and metric modulation are in fact mathematical (and precise), but the things that they are equating are abbreviated to some degree or another.
Comment: @phoog  I see your point.   My (personal, not standard) view is that a non-tempered scale on a 12-tone keyboard will not produce both an E# and and F-natural because they are different pitches.
Comment: @CarlWitthoft what then is your definition of *temperament?*  As I understand it, it is a system for assigning frequencies to the keys of a keyboard.  Quarter-comma meantone is a temperament, albeit a very unequal one.  To use a more realistic example than E♯ and F, you have to decide whether to use the G♯ or A♭ pitch for the key between G and A, but once you've done that, that pitch is *by definition* both G♯ and A♭ for the purpose of that temperament.
Comment: @crass_sandwich that is a truly excellent point.  The distinction between assignment and comparison is a useful one.  But it's also worth noting that many programming languages manage to use the same symbol for both.  It can cause confusion, of course, but it's not unworkable.
Comment: Delphi uses = for comparison, := for assignment, C#/C++ use = for assignment, == for comparison. But I don't think == would be suitable notation here either.
Answer: Use Parentheses?

E♯ is the enharmonic equivalent of F♮

I've seen the following in scores but written on the staff instead of using letters: E♯ (F♮)
Comment: This is what I have seen in the wild, and what I have used myself in writing my scores when I used an equivalence like this to change keys. It helps the singer's ear to see what the note is in the new key for reference.
Comment: This approach is used commonly in staff notation, at least for singers.  For example, if there's an E♯ before a key signature change followed by an A♭ after the change, the E♯ may be followed by an F♮ in parentheses to warn the singer that the interval is enharmonically a minor third.  The F♮ will often be smaller, and it will typically be a solid notehead without a stem, to reduce the likelihood of rhythmic confusion.
Answer: I think the equals sign actually works perfectly well for this purpose. For starters, "enharmonic" itself is really a short way to say "enharmonically equivalent", so from a language perspective, = makes a lot of sense. In any context where it is important to note that two things are enharmonically equivalent, it will be obvious that the normal distinctions about enharmonicity not being entirely the same are implied. Plus, = is such a commonly understood shorthand that its meaning is immediately obvious to even beginners.
As an alternative, I think the similar (~) sign from geometry could also work really well, and it probably comes closer to the exact meaning of enharmonic. The congruent symbol takes this even further, but isn't localised on many keyboards.
The main argument I have against other symbols, like the ones mentioned in other answers from mathematics or logic, is that they aren't nearly as accessible as an equals sign. Just about everyone in the world knows what an equals sign generally represents, but lamentably the same cannot be said about the congruent symbol, for example.
I've seen scores sneak their way from C major to D♭ major, and when their G♯ note gets tied to A♭, the composers (or editors) sometimes write "G♯=A♭" above the notes.
If you're okay with shorthanding the enharmonic relationship with a symbol, you have to be okay with letting the technicalities of enharmonic relationships be implicit. Otherwise, you may as well just write it out.
Comment: I've frequently seen ~ for a generic equivalence relation. https://en.m.wikipedia.org/wiki/Equivalence_relation
Answer: Several mathematical symbols come to mind, as I don't think there is an official musical symbol.
≡ Triple bar means "identical to"
≈ Approximately means "almost equal to"
~ Tilde means "similar"
Comment: Please don't try to do this as there other terms and symbols that overlap with mathematics. For example, musical set theory doesn't really overlap well with mathematical set theory and symbols like '+' are used to indicate augmented triads not add notes together.
Comment: Each symbol actually seems _inappropriate_. Not identical, respelling changes scale degree. Not approximate, at least on a fix pitch instrument like a piano the pitch will be exactly the same. Similar is just too vague, C1~C2 is also a similarity.
Comment: @MichaelCurtis I think you're interpreting too literally the definitions that MeanGreen gave. In math, "identical", "almost equal" and "similar" have specific definitions, and the symbols themselves can be used in many fields for other particular definitions. For example, one could say that two numbers are equivalent under modular arithmetic with the triple bar, despite the numbers being written differently, so to say "identical" I think is a bit of a misnomer. I don't see why musical notes can't be talked about similarly, i.e. enharmonic spellings are identical under a certain system.
Comment: Or per my comment, maybe "congruent" ?   OTOH,  there is no musical symbol for "is NOT the same as" either :-)
Comment: @Dom I think the triple bar symbol is actually suitable if the purpose is to indicate a certain tuning system, though saying "let E# = F" is probably simpler.
Comment: @awelotta the problem is if you stat using it, it's only going to confuse more people since there's not an official source.
Comment: @Dom Are you proposing: "We should not use math symbols as musical symbols"? If that is indeed what you're saying, I don't think it's possible to avoid overlap, since different areas of math use so many different symbols; though I suppose there is some value in trying to use rarer notation so that common math can coexist with musical notation. Also, I just realized I meant to respond to Michael Curtis sorry. One could clarify the usage the first time it's written, and then leave it unexplained every time after; though some other answers have mentioned, e.g. "=" used in authoritative texts.
Answer: As far as I know, there is no sign. Why should there be? That statement and other similar ones aren't commonplace, and whenever there's a need to use it, simply write the fact down.
There are, as Dom rightly states, many mathematical signs and symbols which actually mean completely different things musically. + and - and o come to mind. And = isn't going to be a true statement anyway. B♯ = C ? Not true!
Comment: I understood the expression `B♯ = C` to be shorthand for the statement "the pitch of B♯ is the same as the pitch of C," which certainly is true in the 12-tone system (and a good number of systems with more tones besides).  That B♯ and C are not written the same is question begging (1.5 and 3/2 aren't written the same, but that doesn't stop them from being equal).  I also do not see the relevance of whether the pitch is part of an interval or not.
Comment: @phoog - it's not *completely * true. It sounds the same in 12tet, but it doesn't look anything like when it's written, does it? And when it's part of an interval, it's different too. It is enharmonic, but that's as far as it goes. Yes, I'm pedantic!
Comment: B♯ = C is completely true in the 12-tone musical system.  (On the other hand, if you're considering that the pitch required from an instrument with variable pitch might be different because of a different harmonic context, then C = C is also not true.)
Answer: In Kostka and Payne, Tonal Harmony the equal sign is used...

...or...

...or...
Answer: F# - Gb or F#/Gb
(I know you use the slash to indicate a secondary dominant or any other degree of another degree).
https://www.theorie-musik.de/grundlagen/enharmonische-verwechslung/
Edit:
I agree that / is used to assign F/G = F chord above G. So how about back slash: F#\Gb
After reading the other answers here I think a good and clear solution will be euqal in parentheses: F# (=Gb)
Comment: I typically see slashes in guitar chords, indicating that the bass note is different than the indicated chord. In that sense, `/` means "different" to me.


Trying to understand what is requested in this task and its solution

Question:
A student wishes to travel to the USA and changes amounts of Euro and
  Swiss Franc in Dollar (in whole numbers!). The exchange rates are \$ 1.35 = € 1.00 and \$
  1.12 = CHF 1.00. If the student receives \$ 66.49 in total, then how much money of each currency has been changed?

So I don't really understand this task. The student has got \$ 66.49.
This seems problematic "how much money of each currency has been changed?".
Am I asked to convert \$ 66.49 into € and CHF?
If so then: $$\frac{\$66.49}{\$1.35}=€49.25$$
and
$$\frac{\$66.49}{\$1.12}=50.37 \text{ CHF}$$
But wait, it was mentioned "in whole numbers"... So what to do? Or the task is just bad? I think it cannot be as easily done as I tried here, no way : /
Edit: I heard there is a recommendation using extended euclidean algorithm but I don't see the use of it here at all.
Comment: Assume that $e$ Euros and $f$ Francs were exchanged. Then $$1.35e + 1.12f = 66.49$$ Multiply throughout by 100 and solve to get the integral answers to your equation.
Comment: You are not asked to convert $ 66.49 into € and CHF. You are told that the amount of currency of each type (Euros and Francs) exchanged is a whole number. I suspect that this is going to lead towards a diophantine equation.
Comment: @nbro integers.
Comment: Something's amiss. I followed the interpretation I mentioned in my first comment, but the resulting diophantine equation does not have a solution. @cnmesr - As to your recent edit, diophantine equations are solved using Extended Euclidean Algorithm.
Comment: Maybe you can tell me how the equations would look then I'd like to see if solvable or not, assuming I get that far.. ^.^
Comment: Thanks a lot I will do that :-) But still, I would never get the idea of doing it if this was an exam.. : /
Answer: Scaling by $\,100\,$ we need to solve $\ 112x + 135 y = 6649\ $ for $\,x,y\in\Bbb N.\,$ Using Gauss's algorithm
$\quad {\rm mod}\ 112\!:\,\ y \equiv \dfrac{6649}{135}\equiv \dfrac{41}{23}\,\overset{\times 5}\equiv\, \dfrac{205}{115}\equiv \dfrac{93}3\equiv 31,\ $ so $\,\  x = \dfrac{6649-135\cdot 31}{112} = 22$

Beware $ $ Modular fraction arithmetic is well-defined only for fractions with denominator coprime to the modulus. See here for further discussion.
Answer: The problem is asking you to find an integer amount of Euros and an integer amount of Swiss Franc which when converted gives you USD 66.49, so you need to solve
$1.35e + 1.12f = 66.49$
where $e$ and $f$ are integers, which, as someone else has already said in the comments, is a diophantine equation.
Now, I don't know how to properly solve a diophantine equation, but I have found a solution.
You know that the final digit is 9, and since multiplying 1.35 will only ever get you final digits 0 or 5 and multiplying 1.12 will never get you final digit 9, it must be that $e$ is odd and $f$ will get you a 4.
So, first I tried to find an odd integer $a$ such that
$1.35 a + 2.24 = n + 0.49$
where n in any integer. I literally got a calculator and attempted values and found $a = 15$ and $n = 22$. So now we have 22.49 and we need 44 still.
Since 44 is an integer you know you have to multiply 1.12 by a multiple of 5 and 1.35 by an even number. $1.12 \times 5 = 5.6$ and $1.35 \times 4 = 5.4 $ so that
$1.12 \times 5 + 1.35 \times 4 = 11$
If you multiply that by 4 you have the missing 44 and finally
$ 1.35 \times 15 + 1.12 \times 2 + 4 \times (1.12 \times 5 + 1.35 \times 4) = 31 \times 1.35 + 22 \times 1.12 = 66.49$
Thus,
$e = 31$
$f = 22$


Como retornar uma variável vinda de um formulário com anexo?

Question: '''
Quero que meu código retorne um valor/string a partir desse formulário:
<form action="/dashboard/busca_inserir" method="POST" enctype="multipart/form-data">

  Insira um documento, caso exista

  <input type="file" name="empresas_file" />

  <input type="submit" id="empresas_file" value="Submeter Arquivo" />

A função de retorno se encontra a baixo:
router.post('/busca_inserir', (req,res) => {

const empresas_file  = req.body.empresas_file;
console.log(empresas_file);
res.redirect('/dashboard/busca_inserir');});

Desse modo, o console log está sempre retornando "undefined" queria saber como consigo um valor para esse retorno.
Answer: Pelo fato de estar passando um arquivo na requisição, por causa do enctype, é necessário algum pacote npm que faça a leitura (pelo menos é uma das alternativas), talvez o Multer ou connect-multiparty.
Por exemplo:
npm install --save connect-multiparty

agora, como middleware (O app é o objeto do express)
const multiparty = require("connect-multiparty");
app.use(multiparty());

Mais um detalhe: use 'req.files'
router.post('/busca_inserir', (req,res) => {

const empresas_file  = req.files.empresas_file;
console.log(empresas_file);
res.redirect('/dashboard/busca_inserir');});


Call Parameter as Reference to Array of Unknown Bound in C++

Question: I am trying to understand whether references to array of unknown bound can be used as call parameter in functions in C++. Below is the example that i have:
EXAMPLE 1
void func(int (&a)[])
{
}
int main()
{
   cout << "Hello World" << endl;
   int k[] = {1,2,3};
  // k[0] = 3;
   func(k);
   return 0;
}

To my surprise this example 1 above works when compiled with GCC 10.1.0 and C++11 but doesn't work with GCC version lower that 10.x. I don't think that we can have references to arrays of unknown size in C++. But then how does this code compile at the following link: successfully compiled
My second question is that can we do this for a function template? For example,
EXAMPLE 2
template<typename T1>
void foo(int (&x0)[])
{
}

Is example 2 valid C++ code in any version like C++17 etc. I saw usage of example 2 in a book where they have int (&x0)[] as a function parameter of a template function.
Comment: Not sure what your template adds... Did you mean `templatevoid foo(T(&a)[])` or `template void foo(int (&a)[N])`?
Comment: Using `typeid(a)` I can see that `a` is just that, an array of unknown bound. Not a pointer, nor a fancy auto-makes-template thing. Interesting... but hardly useful.
Comment: @Jarod42 It doesn't add anything. Instead the user will explicitly provide the template argument. The point being that is the usage of reference to array of unknown bound legal in C++ whether in nontemplate or template functions. It is just an example. You can remove the type parameter if you like.
Comment: gcc is rather lax with default settings. Try `-pedantic-errors`: https://wandbox.org/permlink/RVCutmkxYc18Mvyd
Comment: @463035818_is_not_a_number But the program you sent the link to works with C++2a.
Comment: I see no reasons template version should behave differently than the non-template version. (Notice than detecting error with template is generally harder for compiler).
Comment: It was perhaps that paper implemented: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0388r4.html so it obviously can't be in C++11
Comment: BTW, I think the line `int k[] = {1,2,3};` declares k of *known* size (3). It is the same as `int k[3] = {1, 2, 3};`. In any case, good catch.
Answer:
I don't think that we can have references to arrays of unknown size in C++.

That used to be the case, although it was considered to be a language defect. It has been allowed since C++17.
Note that implicit conversion from array of known bound to array of unknown bound - which is what you do in main of example 1 - wasn't allowed until C++20.

Is example 2 valid C++ code in any version like C++17

Yes; the template has no effect on whether you can have a reference to array of unknown bound.
Comment: When you said that "implicit conversion from array of know bound to array of unknow bound", are you talking about the statement `int k[] = {1,2,3};` or the statement ` func(k);`? I think that you mean the latter but i want to confirm.
Comment: @AanchalSharma I mean the latter. In the former, the type is *adjusted* to array of *known* bound.


C# - Make faster MySql queries?

Question: what is the best way to insert a lot of data to mysql database?
Comment: Please, have a look at `BULK INSERT`.
Comment: @willie - No, do not run "lots of inserts in a single string".  On the other hand, you can have lots of rows in _one_ `INSERT`; that _does_ run faster (like 10x).
Comment: `INSERT ...; INSERT ...;` is essentially no faster than `INSERT ...;`, then `INSERT ...;`.  This _is_ faster:  `INSERT INTO t (a,b) VALUES (1,2), (5,6), ...;`
Comment: Hi , you can make a stringbuild and execute it one time, because you have too much IO, for example , "insert ..... ;" + "insert ......" to one string
Comment: I think I looked at some examples about strinbuild last night. is that when I loop through all my Players, and make a gigantic query, and then some `append` at the end and close it off with semi-colons? If so, then I had a lot of trouble with it. Because I couldn't insert my variables like @level, they are assigned later on at the bottom as you can see in my code. So I dont know how to do this. I find it extremely difficult with these sql queries. I sat with stirngbuild until 5am this morning, no kidding. And I just went to bed cus I was so dead tired about it. it's driving me insane
Comment: I updated my question and added my stringbuild. Please check. I dont know what I did wrong.
Comment: @RickJames thanks very much for your comment , could you do me a favor to give me a small sample , how to do , thanks a lot
Answer: You are not just doing an insert, but also using on duplicate key update.
I would suggest that you take a bulk-load approach:

Put the 18-25,000 things into a file, appropriately delimited.
Load the data from the file using load data infile into a staging table.
Use the insert . . . on duplicate key update on the staging table.

The final step looks similar to your query:
INSERT INTO players (name, online, world, level, vocation, month, week, today)
    SELECT name, online, world, level, vocation, time, time, time
    FROM players_staging
     ON DUPLICATE KEY UPDATE
         online = values(online), world = values(world), level = values(level),
         vocation = values(vocation), month = month + values(time),
         week = week + values(time), today = today + values(time);

Bulk operations are faster for two reasons.  First, they requires fewer calls into the databases -- setting up queries, returning results, and other overhead going back and forth.  Second, they reduce the amount of logging and locking required for the operations.
Comment: I have no idea how to do that type of stuff. how do i output it to a file? is it some special format? like xml? or what? i am a newbie at this, so bare in mind.
Comment: still cannot figure this out, @gordon linoff
Comment: @TibiaRook - research the term "CSV" or "Comma Separated Values" or "Tab Separated Values".  Then look for `LOAD DATA INFILE` in MySQL.  Put those two together to get high speed ingestion.  Oh, also, you need to know how to create and write a file from C#.

C# - Make faster MySql queries?


How to measure CPU usage per site in a nginx + apache + php-fpm setup

Question: If I have a server with nginx as reverse proxy and Apache + php-fpm as server. I also have a ton of websites on this server, say 200+. I want to write a script which can tell me how much CPU is used by each site at any given time.
This is important because I want to delete/disable sites overusing my server resources.
Note: every process is run by a different user.
Comment: Are your php-fpm processes splitted by different users? If yes you can do some nice things like monitoring their CPU %. Maybe this information can be added in the question.
Comment: @ValerioBozzolan yes, every process is run by a different user. Can you give me a command for that?
Answer: If every process is executed by a different user, well done! You've made your life easier!
Your question now is: how to monitor CPU usage by user?
Some starting points:

https://superuser.com/questions/920007/how-to-view-total-cpu-and-memory-usage-of-per-system-user-in-linux
https://unix.stackexchange.com/questions/120570/how-can-i-monitor-cpu-usage-by-user


Php function to clear cache for regions

Question: I made a custom module, in which I dynamically add regions. The thing is, I want to make just the region part of the cache to refresh after. So drupal_flush_all_caches(); isn't the solution, since this takes too long, as well as it sometimes crashes the site.
Could anyone tell me which function I need to specifically clear the region/blocks cache? I tried all logical functions from the drupal_flush_all_caches(); function. I also couldn't find the right call from cache_clear_all();.
Any help would be appreciated.
Answer: You are looking for cache_clear_all. You want to set first argument $cid to NULL, as you want expire all your objects. Now you only need to figure second argument, $bin. For sure you have to clear cache_page bin. If it's not enough, look inside your database for cache_% tables (where % means any string, per SQL standard) to know what bins are available to you.
Last but not least, dynamic regions may be huge performance hit. Think twice if that's what you really need.
Comment: Any idea which cache table governs the regions? None of the cache names really give away anything about the possibility of having the regions cached inside. And it's not the page cache. Because I got about as far as you've told me already, just couldn't find out which cache contains the region information.
Comment: @SanderKoedood It's in the `cache_bootstrap` table with a cid of `system_list`

Php function to clear cache for regions


Closed form for $c_m = \sum_{n=|m|}^{\infty} \left(\dfrac{1}{2}\right)^{2n} (-1)^{m+n}{2n \choose m+n}$, $m$ integer

Question: What is a closed form for
$c_m = \sum_{n=|m|}^{\infty} \left(\dfrac{1}{2}\right)^{2n} (-1)^{m+n}{2n \choose m+n}$
with $m$ an integer?  (N.B. the starting index is an absolute value.)
I already know a form in terms of a hypergeometric function, but that's really just rewriting the sum as another sum.
This series arose near the end of this answer: https://math.stackexchange.com/a/2984718/441161
For any particular $m$, this sum is scaling and summing the terms down a vertical column of the Pascal's triangle that has alternating signs, and is only operating on columns that have elements in the even rows of Pascal's triangle -- rows with coefficients for $(a-b)^{2n}$.
$m = 0$ corresponds to the center column of Pascal's triangle.  $m = 1$ corresponds to the first relevant column to the right of the center column of Pascal's triangle.    $m = -1$ corresponds to the first relevant column to the left of the center column of Pascal's triangle.  And so on...
Answer: If $m \ge 0$ I get $$ \frac{(3-2\sqrt{2})^m}{\sqrt{2}}$$
and if $m < 0$,
$$ \frac{(3+2\sqrt{2})^m}{\sqrt{2}}$$
Comment: Thanks. I was under the impression that $c_{m} = c_{-m}$.  Maybe that's the case with your answer, but I'm not at a place I can easily check that at the moment.  Or maybe I'm mistaken.
Comment: The sum from $m$ to $\infty$ is $(3-2\sqrt{2})^m/\sqrt{2}$, the sum from $-m$ to $\infty$ is $(3+2\sqrt{2})^m/\sqrt{2}$
Comment: There are absolute value bars there in the lower limit (intentionally): $n=|m|$, if that is the discrepancy.  I only need the sum from $|m|$ to $\infty$. BTW, what techniques did you use to get the sum? I'm genuinely interested.  I'm only an engineer and not a mathematician, so I don't know all the tools that can be brought to bear for summations
Comment: @RobertIsrael $c_m = c_{-m}$ indeed holds, since the sum arises as the $m$th Fourier series coefficient of $1/(1 - a \cos x)$.


What does the following code do?

Question: i = i + j ;
j = i - j ;
i = i - j ;

What the above code do ? Can someone write the same operation with other code ?
thnx.
Comment: appears to reverse the two numbers. (Try [for yourself](http://jsfiddle.net/bradchristie/jjcCG/))
Comment: standard answer to the question, _"swap two integers without using intermediate temporary variable._
Comment: above code does mathematical operations - namely addition, subtraction and assignment ;-) - writing same with other code may look like this - `int temp = i; i = j; j = temp`
Comment: before asking Qs like this, try running this code a few times with sample values and learn the pattern.
Answer: It's a technique to swap the values of i and j without creating a temporary variable. It's a form of memory optimization
If you're interested in learning about some of these things, I found a site about swapping values:
http://booleandreams.wordpress.com/2008/07/30/how-to-swap-values-of-two-variables-without-using-a-third-variable/
Another way to swap values is with the bitwise operator Exclusive Or (XOR)
a = a ^ b
b = a ^ b
a = a ^ b
This way is my favorite personally because it's more fun to think about conceptually. Integers are sets of bits, (ones and zeros)
a 64 bit integer has 64 "ones and zeros"
The ones and zeros are binary.
1 = 1
10 = 2
11 = 3
100 = 4
101 = 5
111 = 6
That's an example of binary to decimal. Now the bitwise operator XOR works like flipping a switch. So:
2 ^ 1 = 3 :binary: 10 ^ 01 = 11
and
3 ^ 2 = 1 :binary: 11 ^ 10 = 01 = 1
Now now that you understand that, you can see how swapping variables with it might work out.
Let's set a = 3 and b = 2 (in binary) and try it
a = 100
b = 10
a = a ^ b :: a = 100 ^ 10 = 110
b = a ^ b :: b = 110 ^ 10 = 100
a = a ^ b :: a = 110 ^ 100 = 10
now a = 10 and b = 100 or a = 2 and b = 3
Welcome to bits!
Comment: As I thought...
And can you give an example of other code that do the same (of course not only change parameter's names)?

Thanks !
Comment: @Mosh Sure, you mean another technique for swapping variables?
Answer: It swaps i and j.  Assuming they have initial values of a and b, the lines evaluate to:
i = a + b;
j = (a + b) - b; // = a
i = (a + b) - a; // = b

To answer the second part of your question, an alternative (and more than likely, the approach that would be taken in real life, non-interview situations) would look something like the following:
int tmp = i;
i = j;
j = tmp;

Comment: To be pernickity, it swaps i and j assuming that they are integers and that either overflow does not occur or is handled appropriately by the language. If they are not integers then loss of precision can occur.
Comment: What do you mean by "handled appropriately"? Simply ignoring the overflow works fine.
Comment: One of the 'appropriate' handlings (what you call 'ignoring') is to return the correct result missing any high level bits that cannot be represented. Most languages do that. However a language that returned the highest representable integer when overflow occurred, or one that threw an exception, would be an example of 'inappropriate' handling and would result in this code not working.
Answer: Temporary variable swap
And most used swap method involves using a temporary variable:
T swap = i;
i = j;
j = swap;
swap = null; // or let it fell out of scope

Aritmetical swap
i = i + j ;
j = i - j ; // i + j - j = i
i = i - j ; // i + j - (i + j - j) = j

This hack only works if:

i and j are integers and their sum is between 2147483647 and -2147483648.
i and j are longs and their sum is between 9223372036854775807 and -9223372036854775808.

xor swap
There is a similar xor swap hack
i = i ^ j;
j = i ^ j; // i ^ j ^ j = i
i = i ^ j; // i ^ j ^ i ^ j ^ j = j

And it's slight variation of:
a[i] = a[i] ^ a[j];
a[j] = a[i] ^ a[j];
a[i] = a[i] ^ a[j];

This hack only works if:

i != j, two indexes refer to the same element and thy cancel each-other out.
Comment: Don't think the bit about them being equal is right.  if this was the case then since all the bits are independent it wouldnt work for any number which had coincident 1 or 0 bits.  pretty sure it does work if i = j
Answer: The obvious way to do this with other code would be:
const int tmp = i;
i = j;
j = tmp;

This assumes that the type is int. Note that this swap trick is not safe if there is integer overflow/underflow risks in the computations. It's also not very clear, people who read it need to think pretty hard to understand what's going on (or ask someone).
Comment: Over/underflow isn't a problem here, it'll work independent of that (at least as long as you use 2s complement).
Answer: It swaps them - but it's easier to tell this if you use different variable names to keep things clear:
int originalI = ...;
int originalJ = ...;

int tmp = originalI + originalJ;
int newJ = tmp - originalJ;
int newI = tmp - newJ;

Now perform substitutions:
int originalI = ...;
int originalJ = ...;

int tmp = originalI + originalJ;
int newJ = originalI + originalJ - originalJ;
int newI = originalI + originalJ - (originalI + originalJ - originalJ);

... and simplify:
int originalI = ...;
int originalJ = ...;

int tmp = originalI + originalJ;
int newJ = originalI;
int newI = originalJ;

... and remove the temporary variable:
int originalI = ...;
int originalJ = ...;

int newJ = originalI;
int newI = originalJ;

Answer: It looks like its swapping i and j.
Answer: It swaps the variables.
Another way:
i ^= j;
j ^= i;
i ^= j;

Answer: Assuming i and j are numeric primitives, assuming the operators operate like they do in Java, C++, or the like, and assuming the operators have not be redefined, then we can look at this line of code like this:

i = i + j;

j = i - j;

i = i - j;

Here, i becomes the sum of the two variables. In the second line of code though, we remove j from that sum and assign it to j. We can therefore reduce the first two lines to the following:
j = i;
Variable j now equals our original i. But currently, i doesn't have the same value it started with. Right now, i is equivalent to the sum of the original two values. In the next line of code, we say:  i = i - j, which in pseudocode is equivalent to:  i = originalSum - originalValueOf_i; //The original j.
So, basically, all of the original code is equivalent to a swapping routine, i.e.:
tempVal = i;
i = j;
j = tempVal;

We can even try an example involving positive and negative values to see that this is true:
i = -24.3;
j = 10.4;
//Original code:
i = i + j; //i now equals -13.9
j = i - j; //j now equals -13.9 - 10.4, which is -24.3 (our original i value).
i = i - j; //i now equals -13.9 - (-24.3), which is 10.4 (our original j).

Someone may have written the swap you posted in the way he/she did to avoid method call overhead, declaring new variables, etc., but if you're going to be swapping values a lot, using the code you posted over and over could get icky. A swap routine like the one shown above is fairly common.
Answer: i gets j's value. And j keeps it's value.
Comment: but ofcourse, one of the operators he gave there is wrong, I had this question once.
Answer: It switches the values of i and j:
i = i+j;
j = (original_i + j) - j = original_i;
i = original_i + original_j - original_i = original_j;

Yes, there are other ways to do this operation.

What does the following code do?


.htaccess file showing 500 Internal Server Error

Question: I have this in my htaccess file:
RewriteCond %{HTTP_HOST} ^my\.domain\-uk\.net$ [OR]
RewriteCond %{HTTP_HOST} ^www\.my\.domain\-uk\.net$
RewriteRule ^/?$ "http\:\/\/www\.domain\-uk\.net\/my\-integra" [R=301,L]

RewriteCond %{HTTP_HOST} ^status\.domain\-uk\.net$ [OR]
RewriteCond %{HTTP_HOST} ^www\.status\.domain\-uk\.net$
RewriteRule ^/?$ "http\:\/\/www\.domain\-uk\.net\/service\-status" [R=301,L]

RewriteCond %{HTTP_HOST} ^dd\.domain\-uk\.net$ [OR]
RewriteCond %{HTTP_HOST} ^www\.dd\.domain\-uk\.net$
RewriteRule ^/?$ "https\:\/\/sub\.domain\.co\.uk\/preauth\/0J9A7MT35N" [R=301,L]

the status. redirects but the two after are showing 500 Internal Server Error
above this i have the standard Wordpress code:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Comment: Check your error log plus remove the quotes from your target url
Comment: check htaccess here http://htaccess.madewithlove.be/
Comment: i removed the quotes but im just getting 404 errors now
Answer: The first rules that you want in your htaccess file are the ones the redirect the browser, the order is important, you don't want to redirect the browser after wordpress's internal rewriting. So first, you can clean up your redirect rules:
RewriteCond %{HTTP_HOST} ^(www\.)?my\.domain\-uk\.net$ [NC]
RewriteRule ^/?$ http://www.domain-uk.net/my-integra [R=301,L]

RewriteCond %{HTTP_HOST} ^(www\.)?status\.domain\-uk\.net$ [NC]
RewriteRule ^/?$ http://www.domain-uk.net/service-status [R=301,L]

RewriteCond %{HTTP_HOST} ^(www\.)?dd\.domain\-uk\.net$ [NC]
RewriteRule ^/?$ https://sub.domain.co.uk/preauth/0J9A7MT35N [R=301,L]

The ? makes the grouping optional, and the NC ignored the case. So after these rules, you can put your wordpress rules.
Comment: ok, ive just tired this code above my wordpress code and im still getting 500 error
Comment: Are you sure you have MOD_rewrite loaded?


Why are modern string bows concave instead of convex?

Question: Every bow that I have seen used to play an orchestral stringed instrument, regardless of the style of music being played, has the same concave design.  By concave I mean that there is a slight curve of the wood towards the bow hair (which is pronounced by loosening the bow).
As best I can tell, bows of the 17th century were convex.  Why are convex bows virtually never seen in use now?
Comment: Then there are some off-the-wall bows, such as a super-slack hair kind that allows genuine quadruple-stops!   or worse,   https://www.classicfm.com/discover-music/instruments/violin/features/backwards-violin-bow/
Comment: @CarlWitthoft – That is truly cool: like a poor man's [hurdy-gurdy](https://en.wikipedia.org/wiki/Hurdy-gurdy)!
Answer: It's a fun experience to play with a convex Baroque bow, but if you've ever tried to use it for anything romantic or later, you'll quickly want to get back to the concave Tourte design that everybody has nowadays.
The thing with convex bows is that they bounce around like mad. This can work quite well for the elegant-rhythmic dance feel of Baroque and early Classical music. But it works completely against you if you need biting attack and/or dramatic long tenuto notes. With such a playing style, a baroque bow feels like immersing styrofoam in water: the string seems to outright repel the bow. Whereas a Tourte bow can pretty easily be forced to "sink into he string" for straight sustained notes.
Some "historically informed" performers do use convex bows for Baroque music, but it's not like a Tourte bow doesn't still have some bounce and can convey that gracious character, especially when held in "Baroque position" (i.e. closer to the center of gravity, rather than right at the frog).
Comment: @KamiKaze yes. Arguably, CM is the better term here, since inertial forces are more important than weight. That post was anyways not one of my most _scientifically rigorous_ ones... I think I'd had a bit of alcohol when I wrote it. Does seem to be popular though...
Comment: This was in no means a criticism on your answer, just a little suggestion for improvement.
Comment: center of gravity = center of mass?
Answer: If you trace the development of the orchestra, you'll see that there has been a shift toward larger groups in larger spaces between the baroque period and now. A natural consequence of this is that instruments had to adapt to project more sound to fill those spaces up. The modern bow is just one of those adaptations. The concave design can hold significantly more tension in the bow hair than a convex design. This allows for more pressure to be applied to the strings when playing which increases the volume of the sound. It's not the only adaptation to string instruments over that time either. The angle of the neck and fingerboard used to be much flatter than it is today and the bridge is higher. All of this allows more tension on the strings to make the instruments project more into larger performance spaces.
Comment: Hi Christopher, welcome to [music.se]! Feel free to [contact the mods](https://music.stackexchange.com/contact) if you'd like to merge your different accounts.
Comment: @Richard Aw, all that detective work I just did, and you beat me to it!
Answer: Late in the day, but:
The concave bow allows a lighter bow to be used for the same level of tension in the hair, because it reduces the torque over the majority of the stick's length (and particularly at the centre where the effect of a bend is greatest).  Greater tension means that, for a given change in force, you have to move the bow less far, which is useful in loud-and-fast passages – less-weight-and-more-tension is a double-whammy for high-speed changes of bow pressure.
There are costs, of course: for example, you cannot afford to reduce the tension to play multiple strings simultaneously (the technique of tightening the bow with thumb or forefinger is no longer relevant).
BTW, I don't think the reduction of rotational inertia around the length of the stick is an advantage – as you really don't want to rotate the stick in that direction in the first instance.
N.B.1: that the improved stiffness was already well understood and implemented before Tourte.  Indeed, late baroque  and very early classical bows included sticks where, before tightening, the stick was almost touching the hair in the upper half if the bow.  I believe that the advantage of the Tourte is supposed to be increased flexibility when playing at the tip, but I could be entirely wrong on this.
N.B.2: I personally prefer a slightly short, stiff concave snakewood bow for most 17th-century and earlier music.  Indeed, even for late romantic and modern works, I find it preferable to some brazilwood bows supposedly built to Tourte's design, but I'm probably somewhat atypical in this.


Como fazer uma tabela que só aceite número de 1 a 100?

Question: Iniciei agora na programação e estou com problema. Eu estou tentando fazer uma tabela que só aceite números de 1 a 100, mas esta dando erros

var num = document.getElementById("caixaNum")
var tab = document.getElementById("tab")
var res = document.getElementById("res")

function clique() {
  if (Number(num) >= 1 && Number(num) <= 100) {
    window.alert('ok')
  } else {
    window.alert('error')
  }
}

Numeros

 Numeros Para Tab (entre 1 - 100):
    <input type="number" name="caixa" id="caixaNum"><input type="button" value="numeros" onclick="clique()">

    <select name="tabnu" id="tab"></select>

    <input id='fina' type="button" value="Finalizar">

©CursoemVideo

Comment: Você está passando um elemento para a função `Number`. O correto é passar apenas o valor: `Number(num.value)`.
Comment: não , da erro tbm, acho que é no html
Comment: https://codepen.io/valdeir2000/pen/YzGYVLb
Comment: n tá indo tá dando erro no input, mas vi q o seu codigo esta certo . deve ser algo nas configurações do meu pc, vlw msm assim
Comment: Uncaught ReferenceError: clique is not defined ta dando isso no depois do clique
Comment: Isso quer dizer que você precisa implementar a função `clique`. Poste seu código no pastebin
Answer: acredito que seu erro foi no operador de &&(E) ao invés de ||(OU). Fiz um exemplo prático para lhe mostrar melhor.
Eu separei os arquivos então os elementos estão em um arquivo html e o JS está em outro arquivo que eu importei como pode ver no .
HTML

Número

      <form id="calculo" novalidate>
        <input
          type="number"
          id="numberId"
          placeholder="Coloque um número entre 1 e 100."
        />
        <button type="submit">Verificar</button>
      </form>

Arquivo JS onde a mágica rola, aqui eu peguei os ids dos elementos e atribui a uma constante com o mesmo nome para facilitar e então quando você clicar no botão "verificar" ele irá executar está função.
// Pegand o id dos elementos
const calculo = document.getElementById("calculo");
const numberId = document.getElementById("numberId");

// Uma função de submit para validar se o número é menor que 1 ou maior que 100
calculo.onsubmit = (event) => {
  event.preventDefault();

  if (numberId.value < 1 || numberId.value > 100) {
    alert("Número invalido!");
    // Se o número não corresponder com o valor posto ele retorna false
    return false;
  }

  // Depois do número validado ele limpa o value do input
  numberId.value = "";
};

Coloquei o código aqui para que você possa ver em tempo real ele executando, só basta clicar em executar.

// Pegand o id dos elementos
const calculo = document.getElementById("calculo");
const numberId = document.getElementById("numberId");

// Uma função de submit para validar se o número é menor que 1 ou maior que 100
calculo.onsubmit = (event) => {
  event.preventDefault();

  if (numberId.value < 1 || numberId.value > 100) {
    alert("Número invalido!");
    // Se o número não corresponder com o valor posto ele retorna false
    return false;
  }

  // Depois do número validado ele limpa o value do input
  numberId.value = "";
};
<!DOCTYPE html>

    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Número</title>

Número

      <form id="calculo" novalidate>
        <input
          type="number"
          id="numberId"
          placeholder="Coloque um número entre 1 e 100."
        />
        <button type="submit">Verificar</button>
      </form>

Comment: o input tipo number retorna um string ?? por isso temos q usa number?
Comment: Como se tratava de um input que pegasse **número** de 1 a 100 então eu pré-defini o input com `type="number"`, pois assim ele só aceitará número e não string.
  Se preferir você pode mudar o input para aceitar String, Number, Date e etc..
  Neste link que irá para a MDN mostra os types que o input aceita: [link](https://developer.mozilla.org/pt-BR/docs/Web/HTML/Element/input)

@VitorSantos
Answer: Como alternativa ao invés de usar um alerta para o usuário, acredito que a melhor solução, inclusive para o design, seria bloquear essa função.
Você pode utilizar as propriedades 'min' e 'max' do input type number. Veja o exemplo abaixo:
<input type='number' id='quantity' name='quantity' min='1' max='5'>

Depois de uma olhada na documentação da Mozilla lá mostra todas as propriedades de todas as tags HTML, sempre vejo se tem algo lá antes de fazer as funções em JS
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number


Wordpress theme for normal website

Question: I have bought a wordpress theme. But i dont want to develop a website using wordpress. How can i use it for developing it normally with php? Any help would be appreciated. Thanks
Comment: `"But i dont want to develop a website using wordpress."` - then why did you buy a WordPress theme?
Comment: http://stackoverflow.com/questions/4420527/can-i-use-wordpress-templates-on-my-own-non-wordpress-website
Comment: the client bought it for me.. anyways thanks a lot for the link
Answer: You can surely reuse the CSS depending how well the theme was crafted, the main part should be in the styling. The XHTML should not be a problem because it's usually short and with many placeholder. Just replace the WP placeholder with yours own or write an adapter. Yes, if you have time, definitely write an adapter. You could even reuse it or sell it.

Wordpress theme for normal website


Does Schoenberg or Glenn Gould have a point? Does a great deal of music remain to be written in C major?

Question: There's a great interview online where Glenn Gould talks about Stravinsky and Schoenberg (circa 1960). His comments about Stravinsky certainly haven't aged well but nonetheless, he does make some rather good points. And on Schoenberg too. All of these aside, he does make one remark (see below) that confuses me tremendously.

He says Schoenberg once said to him:

A great deal of music remains to be written in the key of C major

What he goes onto say next (his two things regarding the above) go straight over my head.
I must confess a lot of this will be down to the system where Schoenberg spent a majority of his time constructing and Richard did do his best to explain this to me some time ago but I find the two comments Glenn Gould makes rather verbose.
Would someone be able to translate his points? Does Schoenberg have a point? Is there still a lot of music to be written in C?

I did have a small pause before composing this as to whether or not this is likely to be closed for being too opinionated. Professionals would be able to agree (or disagree) as a consensus what Glenn Gould is saying here so it is not just down to opinion. Had the interview not been provided above, quite possibly, yes. I am merely asking for someone with a much better sense of the history and terminology to translate his two points he goes forward to explain.
Comment: Seems to me that he meant 'diatonic' - or if you like 'non-serial' music still had plenty of mileage to go - C major being a blanket term for it. Only surmising!
Comment: Historically, Schoenberg has of course proven to be correct - since he made that statement, a great deal of music has indeed since been and continues to be written in C major.  In fact the vast majority of music written since then has been tonal (and C major is still the most commonly used key at least in western music, though that's kind of beside the point).
Comment: Michael Curtis and I wrote very similar answers, and I feel like his is the clearer one. Hopefully between the two of us you can better. understand Gould's comments and also some more about Schoenberg's context and the larger point about whether C major is exhausted or not.
Comment: Sounds like hero-worshipping.
Comment: There is no substitute for spending 5 or 10 hours (not all at once!) listening to major serial compositions, both works that are more diatonically oriented and less diatonically oriented.
Comment: I don't think there can be a definitive answer to your question. We can only discuss it. But that applies to a lot of questions about any art form such as music! It says something about Gould that he found Schoenberg's tolerance for musical paths other than Schoenberg's own remarkable. Textbooks often speak of the 'rejection' of tonality by the '12-tone' composers. This doesn't mean they were disgusted by tonal music! Just that they chose to explore a different path. I haven't a clue what Gould means by 'quasi-mathematical'.
Answer: The two points I heard him make were:

the 12 tone system was not a refutation of tonality or diatonicism.

serial composition techniques need not be restricted to atonal music.

The first point is about the development of art styles up until post-modernism. In a nutshell new artistic styles were championed as superior to older styles. The attitude is one of artistic evolution from primitive to sophistication. That attitude is particularly true of various types of modernism. Those folks liked to write manifestos rejecting the old and outdated and championing whatever the new style was.
This was true about atonal music. Some felt tonal music had progressed along lines of increasing chromaticism to the inevitable conclusion that all 12 tones were equal and the tonal style had exhausted itself. Tonality must be abandoned so music could be progressed via the 12 tone style. Schoenberg's comment "a great deal of music remains to be written in the key of C major" was explained by Gould to mean Schoenberg actual felt tonal music had not exhausted itself.
The second point about serial technique is a bit harder to explain. I think it starts with the idea of a hierarchy of tones in tonal music. Not all tones are equal, the tonic is most important. Not all combinations are equal, tertian harmony is preferred. In that sense not all options of rhythm and pitch are equally available in tonal music. Choices are limited to give prominence to the tonic.
Serial music takes a palette of musical elements - at the very least pitch in 12 tone music - and treats any series of those elements as available options. There are various procedures for creating series - this is the aspect which I think Gould calls "quasi-mathematical" - but an important aspect was to give equal important to all 12 tones. With equal importance of all tones, no tonic can be defined, hence the music is atonal, without a tonal center.
Equal treatment of all 12 tones means no preferential treatment of select tones. Any series of tones melodically or harmonically can be combined. When you do that will all 12 tones you can get a lot of "chords" which are dissonant by tonal standards. Remember, tonality gives preference to certain combinations, like major and minor triads. 12 tone music actively avoided such preferences and the result is a lot of "chords" with seconds, sevenths, and diminished or augmented sounds.
In tonal terms those 12 tone chords are very dissonant. But, 12 tone music was supposed to be the natural conclusion of the increasing chromaticism of the tonal style. Remember too the attitude of refuting the old when championing the new style. 12 tone music was supposed to emancipate music from the restricted old attitudes about consonance and dissonance. But that didn't happen. Most people feel 12 tone music is very dissonant.
One of the main reasons 12 tone music is dissonant is because it uses a palette of all 12 chromatic tones. Mathematically speaking there are many, many combinations which will be dissonant. If you reduce the number of tones, and especially if you limit the specific relationship between the tones of the palette, you will reduce the number of dissonant combinations.
If you reduced the palette to just C major (surely meant to mean any set of 7 diatonic tones,) you eliminate a great deal of dissonance. In fact if you play the whole set, all 7 diatonic tones, you get a thirteenth chord which while certainly sounding modern, it can also sound consonant.
Let's get back to Gould and Schoenberg. Gould is explaining Schoenberg's comment "a great deal of music remains to be written in the key of C major" to mean serial technique could be applied to a diatonic tone set. I don't know exactly what Schoenberg envisioned, but based on Gould's comment I imagine the idea was music without a strong tonal center - atonal in that sense - but much less dissonant that 12 tone music, because the number of dissonant combinations and types of dissonance would be greatly reduced.
I don't know how much of this is actually Schoenberg's ideas or Gould's ideas about Schoenberg. But what I've written is how I understood Gould's comments.
Answer:
Would someone be able to translate [Gould's] points?

Gould is assuming familiarity with Schoenberg's compositions and composition techniques on the part of his audience. Hopefully you have at least some understanding of those. The important thing to know about Schoenberg with respect to Gould's comments here is that Schoenberg's music would not generally be considered to be in any key, in the traditional sense of the word. In other words, Schoenberg himself was not striving to write music in C major, which could make one think that Schoenberg disdained or at least did not value music written in traditional keys like C major.
So Gould's first comment about Schoenberg's tastes being "catholic" (small c) despite his compositions is really saying that Schoenberg valued all kinds of music that was different from the kinds of music that he composed. Just because Schoenberg was into 12-tone as composer doesn't mean tonal music is dead to him.
Gould's second point is a little more involved. The word "quasi-mathematical" almost certainly refers to the way that 12 tone composition is somewhat formulaic in a way. There are rules for how it is done. I think Gould's use of the word "dissonance" might be a bit confusing, especially from any point of view that consonance and dissonance only exist in the context of a theoretic and aesthetic framework for music. Let me try to put that more simply: Some people would say that consonance and dissonance are completely subjective, so one listener might be trained find 12-tone music consonant and C major music dissonant, while most listeners in the world today would say that C major music has more often consonant intervals and 12-tone music sound more dissonant.
I think Gould is at least partly in the other camp, that believes consonance and dissonance have at least some objective basis. Usually the acoustic and psychoacoustic basis for the objectivity of consonance and dissonance is the harmonic series and how different intervals evoke or conflict with the harmonic series. Generally 12 tone music is written with no regard to the harmonic series, so from the objective view of consonance and dissonance, it is somewhat "randomly" consonant or dissonant, which leads to sense of general dissonance on the part of listeners. Either way, since the vast majority of listeners in Gould's world were "trained" on tonal music, some of which was written in C major, they would find 12 tone music dissonant, and we can suppose that at the very least, Gould found 12 tone music to be dissonant.
So with that in mind (12-tone = dissonant), we can unpack what his second point is about. What he's suggesting is that perhaps Schoenberg saw ways to bring some of the influence of 12-tone composition into a tonal compositional framework, and allow for new and/or different patterns of consonance and dissonance than had been explored in the key of C major up to that time. We could easily suppose that a composer could develop a 7-tone system based on the 12-tone system and start with the 7 tones of the C major scale and otherwise compose with a serialist approach, which has in fact been done in some ways. Serialism (a broader concept than 12-tone music) has definitely influenced modern composition, even compositions that are otherwise very tonal (e.g., definitely written in a key).
So it seems clear that Gould has a positive view of Schoenberg's view of music, and I want to note that he doesn't call Schoenberg's comment "surprising", he calls it "revealing". As in it's something that many people wouldn't know or think about Schoenberg but is nonetheless true.
For the larger question about "Is there more music to be written in C major?" we can turn it around and ask "Has all the C major music possible already been written?". History tells us that the answer to that question is always "No". That question has been asked and/or discussed over the last two millennia and any answer of "yes" has always been very quickly disproved. That said, there are always people who are ready to believe that all music has been written or that all music will soon be written or that all music in a certain category or with certain restrictions has been or will soon be written. That they have always been proved wrong in the past doesn't seem to deter these people, and I expect some may comment on this very answer that we can't say for certain whether it's possible to write all the music that could be written in C major. History strongly supports the assertion that all the music will never be written, and that there is no category of restriction we might place on music such that all the music that fits that category will ever be written.
Comment: Thanks for the very nice answer---I'm intrigued by your hint that Schoenberg's suggestion (or Gould's Schoenberg's suggestion) about using serial techniques in a diatonic context has indeed been taken up by contemporary composers. Could you give some examples? I'd be very keen to listen to them.
Comment: @stefano I can't speak for Todd directly, but serialism has been such a major movement in modern "classical" music that it's had an influence on just about everyone's thought in one way or another. As far as specifically diatonic serial music goes, Ligeti's ["White on White"](https://www.youtube.com/watch?v=Ra7QdAWaBfE) piano etude is not truly serial as far as I can tell but has kind of a similar attitude. Although some may well be out there, I don't know of any strictly serial diatonic music, so I'll go write some and get back to you. :P
Comment: @stefano One aspect of serialism that has penetrated deeply in several forms of music is the extension of serialism to rhythms. Rhythm serialism can be as simple as taking a set of rhythms and using them in a predetermined order. But I argue that rhythmic serialism has been somewhat deconstructed and has influenced hip hop and EDM in the form of evolving hi hat rhythms that are ubiquitous in those genres, to say nothing of the clear influence of serialism on 20th century classical and soundtrack music.
Answer:
...in the last years of his life he said what to me is a very
revealing statement: he said that a great deal of music remains
to be written in the key of C major. But that means to me two
things: first of all it means that he was a man of some
catholicity of taste—he didn't automatically assume that
because he had espoused a certain system of composing music
which came to be called, not too accurately, the twelve-tone
technique, that all music not composed in that system or not
harmonious with it or not in some way acquiescent to it was
false or wrong...That's one thing it represents.

I think this is probably pretty easy to understand. Basically, Schoenberg and others had put forward a new strategy for composing music. Some composers who had come up with a system like that would be very dogmatic about it and insist that everyone who didn't follow them was on the wrong track (which was an attitude that some later serialists did take). Gould is suggesting that Schoenberg himself wasn't so dogmatic as that, but rather that he saw his approach as one reasonable possibility among many.
EDIT 2: If you're wondering what his "not too accurately" comment is about, my guess is it's because serialism came to be understood as a much more general idea than simply relating to the 12 tones of the traditional chromatic scale—so general that you could even apply it to other art forms aside from music. Read on for more. :P

The other thing that it represents, I think, is the feeling
that comes very strongly from Schoenberg's compositions and
from his writing about those compositions in his last years,
and that is that he begins to see that the very highly
dissonant forms of twelve-tone music, of serial music...aren't
necessarily a concomitant of this music. That one could apply
some of the quasi-mathematical (never more than
quasi-mathematical) formulas that he worked out and apply these
to sound formations that were really quite consonant, that were
triadic, that were in fact precisely the sound formations that
every composer from the Renaissance onward had worked with. So
that what you find in the late years of Schoenberg is this
extraordinary coalescence of ideas that were extremely radical,
in the sense that he was saying, "I do not believe the
arithmetical components of music as it's been practiced in the
generation or two before my own. I do not believe that these
are any longer serviceable," and at the same time extremely
conciliatory in that he was saying, "Look, there is a way to
take very old sound formations, very consonant ones, totaly
undissonant ones if you like, and organize them in a
mathematical relationship that gives them maximum expressivity
and minimum debate against each other," which was the formation
of tonality. So I see Schoenberg more as a man affecting a
conciliation than as a man overturning things.

Obviously this is a little more technical and I wouldn't be surprised if this is more of a sticking point for you, so I'll get into this in more detail.
First: serial music is really not so complicated, essentially speaking. The basic idea is that you take a set of possible musical actions and arrange all of them in some order. Then when you're composing, you use those actions in that order. So, if the musical actions are the 12 tones of the traditional Western chromatic scale, you would arrange all 12 of them in some order (called a "series"), and then every time you wrote a note you would follow it with the next note from the series. Like, if A was followed by C#, then whenever you wrote an A in a certain voice, you would make sure C# came next in that voice. They don't have to have the same note value and they can even be in different octaves and such, but just in terms of pitch class, they should follow the series.
The idea behind this is to make sure that you use all 12 tones equally much, instead of giving prominence to any one of them. Before Schoenberg devised this technique, he was writing "freely atonal" music, which had no key signature but also no overarching formal principle akin to tonality or the like (this was his first piece in that idiom, specifically the fourth movement). Music written in this manner can still end up kind of tonal in one way or another, so the 12-tone technique is a more rigorous approach to atonality.
However, that technique, in and of itself, says nothing about consonance or dissonance, or even passing moments of tonality. Note that I never said, "Make sure you can't form a major triad by lining your series up against itself a certain way," or something like that. However, many following serialist composers became very adamant about avoiding even the faintest whisper of tonality in their music, and even moved to serialize other aspects of music like rhythm and dynamics (see Boulez's Polyphonie X for an extreme example of this). The result was music that was very suspicious of consonance, rhythmic pulse, repetition of any idea smaller in scope that the series, etc.—a much more extreme break with the musical past than plainly-stated serialism requires. These composers generally felt that they were being true to the spirit of serialism, but of course that's a matter of perspective.
Schoenberg himself did not really share that perspective, and in fact he became rather unfashionable in mid-late-century serialist circles in favor of his pupil Webern, who pioneered this more "pure" or "severe" (depending on your outlook) approach to serialism. This isn't surprising considering how Schoenberg arrived at atonality to begin with: he started out as a well-regarded late Romantic composer, and said he moved to atonality because total chromaticism was the only place left to go after composers like Wagner and Mahler pushed the boundaries of tonality so far. He wasn't necessarily trying to be an iconoclast, nor was he driven by some sort of all-encompassing abstract ideology about music.
Gould is making the case that he was even more like this in his later years than in the decades prior. As an example of the sort of music of his Gould might be referring to, you could check out Ode to Napoleon Buonaparte, which has a pronounced tonal character despite its serialism, even ending on an Eb major chord that's approached in a manner recalling his late Romantic period. There's a lot of classicism in it, not just in terms of its harmony but also some of its rhythmic figures and so on. That might be the sort of thing Gould is getting at, that he found ways to use this novel and math-ish (lots of terminology from set theory in serialism) composing strategy to get at very traditional ideas in Western music.
In terms of his general attitude around that time, he even returned to that late Romantic style with stuff like his Chamber Symphony No. 2, which he had started writing a couple years before his first atonal pieces. Also, he was a music professor in his later life and wrote some very good textbooks covering the styles of the common practice period—at least of what I've read of his output, he spent far more words discussing the techniques of composers like Mozart and Beethoven than he did describing how to write serial music.
So, in a way, he's not such an enfant terrible as he's made out to be. That reputation might be more reasonable to confer on some of his successors, like Babbit, Boulez, Stockhausen, and so on, who were more determined to totally upset the Romantic apple cart.
EDIT: As a postscript, I figure Gould says "quasi-mathematical" because serialism is not truly mathematical, in the sense that it lacks axioms and proofs and what have you. It has quantitative procedures for constructing and manipulating series, but there's nothing unusual about Western music theory having a quantitative flavor even going back hundreds of years. what maybe distinguishes serialism is that it also lifted a fair amount of terminology and a handful of ideas from set theory, since the elements used to construct a series (like the steps of the chromatic scale) can be thought of as a set, and a series as an ordering of the set. That still doesn't make it math, though, just "math-inspired". :P


How does varimax work

Question: I have some questions regarding how varimax works. I read that given an n by k matrix A, the k by k orthogonal matrix B maximises the varimax criterion, which measures the difference of these 2 terms:
$$\frac{1}{n}\sum_{i,j}[AB]_{ij}^4$$
$$(\frac{1}{n}\sum_{i,j}{[AB]_{ij}^2})^2$$

The varimax criterion maximises high and low value factor loadings and minimises mid-value factor loadings. How does doing this ensure that the varimax criterion is maximised?

In the varimax criterion, the first term is raised to the fourth power while the second term is squared. Why can't the powers of these two terms be 2 and 1 respectively? In other words, why do we have to find the sum of variance of squared loadings, rather than simply the sum of variance of loadings?

Any help is much appreciated, thanks!
Comment: [*It is said that...*](https://en.wikipedia.org/wiki/Weasel_word).
Answer: Varimax seeks to maximize the variance of the squared factor loadings across variables for each factor. It does this by rotating the original factors to a new position. The objective is to make the loadings within a factor either very high or very low, thus making it easier to interpret which variables are strongly associated with which factors.
In the first term, increasing to the fourth power increases the significance of larger loadings, since the effect of re-squaring a number greater than one is amplified. In order to maintain a variance as the objective, the second element is squared, as variance inherently entails squaring. Using powers of 2 and 1 would not adequately amplify the distinction between large and small loadings and might not provide the desired contrast for interpretability.

How does varimax work


Why is ping not returning local DNS cache result? (Using DNS caching server on an internal network.)

Question: Yet another post about this nslookup works but ping does not. I've read a handful of forum posts but could not find anything relevant to my setup and problem, of resolving external domain names on an internal only network.
My Lab:

VMWare Workstation 11
Windows 2012 R2 Datacenter Edition servers

DC1.ad.example.com - AD and DNS, INT NIC
DC2.ad.example.com - AD and DNS, INT NIC
DNS1.ad.axample.com - DNS only, not a member of AD. INT, EXT NICs.

The network is internal only for AD members. Server DNS1 is not a member of AD and contains two NICs, one internal to the AD network and the other external to the internet. DNS1 only serves as a DNS caching server, for the purpose of allowing the internal network (AD) computers to be able to resolve external IP's. Purpose of the lab relating to this question is to learn best practices in AD deployment which includes network design, and DNS.
DNS configuration:
DC1 and DC2 both have a forwarder setup to DNS1. Queries outside of AD go there and get cached upon request from internal network computers. Nslookup confirms that using these two name servers, DC1 and DC2, we can resolve external domain names (I can see them being cached on DNS1 after requests from DC1/2).
Problem:
However, when I ping, it fails without showing the IP. Why is that? I would expect at least an IP printed and failure to reach host or some similar error. The domain name is visible in the local cache on DC1/2, but ping won't resolve or show it.
I ended up adding an external NIC to DC2 and was able to ping no problem. Which also led me to wonder [why I'm actually trying to accomplish this external name resolution.]
I would expect that there would be a "no route", or some other error from ping, but I also would expect it to resolve (or show the resolved IP) and then choke trying to find the host. However, it just fails. Can anyone explain why? Does ping just give up if it can't reach the network?
Below is a series of commands demonstrating all of this:

PS C:\Users\Administrator> ipconfig /flushdns

Windows IP Configuration

Successfully flushed the DNS Resolver Cache.
PS C:\Users\Administrator> ipconfig /displaydns

Windows IP Configuration

    dc1.ad.polishpaul.net
    ----------------------------------------
    Record Name . . . . . : dc1.ad.polishpaul.net
    Record Type . . . . . : 1
    Time To Live  . . . . : 1197
    Data Length . . . . . : 4
    Section . . . . . . . : Answer
    A (Host) Record . . . : 192.168.55.11

PS C:\Users\Administrator> ping google.com
Ping request could not find host google.com. Please check the name and try again.
PS C:\Users\Administrator> ipconfig /displaydns

Windows IP Configuration

    dc1.ad.polishpaul.net
    ----------------------------------------
    Record Name . . . . . : dc1.ad.polishpaul.net
    Record Type . . . . . : 1
    Time To Live  . . . . : 1186
    Data Length . . . . . : 4
    Section . . . . . . . : Answer
    A (Host) Record . . . : 192.168.55.11

    google.com
    ----------------------------------------
    Record Name . . . . . : google.com
    Record Type . . . . . : 1
    Time To Live  . . . . : 293
    Data Length . . . . . : 4
    Section . . . . . . . : Answer
    A (Host) Record . . . : 18.104.22.168

PS C:\Users\Administrator> nslookup
Default Server:  dc1.ad.polishpaul.net
Address:  192.168.55.11

> google.com
Server:  dc1.ad.polishpaul.net
Address:  192.168.55.11

Non-authoritative answer:
Name:    google.com
Addresses:  2607:f8b0:4006:806::1005
          188.8.131.52

PS C:\Users\Administrator>
PS C:\Users\Administrator> # external NIC now added
PS C:\Users\Administrator> ping google.com
Pinging google.com [188.8.131.52] with 32 bytes of data:
Reply from 184.108.40.206: bytes=32 time=11ms TTL=128

Thanks,
Paul
Comment: `Purpose of the lab relating to this question is to learn best practices in AD deployment which includes network design, and DNS` - Nobody does this the way you're trying to do it, so you're definitely not following `best practice` in your design.
Comment: While may organizations may use a dedicated DNS resolver for resolving external domains in order to "shield" their AD DNS servers from direct internet access, they don't use a multi-homed DNS server to do so. Remove the multi-homing from the equation and see what you get.
Comment: If could you elaborate, it will be a lesson learned :) I'm exploring what's possible and attempting to run AD on an isolated internal network. As I read through books and guides I'm trying things out.
Comment: Since the primary purposes of being connected to the Internet are to use smtp and http, I would test those instead of ping.  As for why ping doesn't use cached records, I don't know, but it makes sense if you think about it.
Comment: And I think this may have bee the root question I'm not sure how to ask yet. So how would i do this? Is the answer simply to route the traffic instead of relying on two NIC's? I think i've been over engineering here...
Comment: @joeqwerty, I changed my setup based on your hints. Now I have a router/firewall (pfSense on VM) for the network and the DNS caching server is outside of it. Thanks! :)
Answer: I have found that although the name resolution works with nslookup or the domain name resolution is cached locally, if one does not have a route to the destination ping will fail and never show the IP.
I encountered this issue in another lab without multi-homing. Removing the default gateway would cause ping to fail with "cauld not find host" when pinging a domain name and when pinging the IP, it would show a "transmit failed" error:
<code>C:\Users\pawel>ping google.com
Ping request could not find host google.com. Please check the name and try again

C:\Users\pawel>ping 18.104.22.168

Pinging 18.104.22.168 with 32 bytes of data:
PING: transmit failed. General failure.
</code>
Comment: This is absolutely strange! Ping does two *distinct* things: resolves the name to IP address and then sends ICMP packets. Name resolution and actual "pinging" are not connected in any way. You don't show your DNS client configuration?


Enviar email com PHPMailer sem autenticação?

Question: Estou usando o seguinte código para enviar email:
<?php
require 'libs/PHPMailerAutoload.php';

$mailer = new PHPMailer();

$mailer ->isSMTP();
$mailer ->isHTML(true);
$mailer->CharSet = "UTF-8";

$mailer->SMTPAuth = true;
$mailer->SMTPSecure = "tls";
$mailer->Host = "smtp.live.com";
$mailer->Port = 587;
$mailer->Username = "email@example.com";
$mailer->Password = "*********";

$mailer->From = "email@example.com";
$mailer->FromName = "leonardo vialrinho";

$mailer->Subject = "TESTE DE EMAIL";
$mailer->Body = "body HTML";
$mailer->AltBody = "body texto";

$mailer->addAddress("firstname.lastname@example.com");

if($mailer -> send()) {
    echo "Enviado";
} else {
    echo "Erro: ".$mailer->ErrorInfo;
}
?>

Até aí sem problema, mas como seria em um formulário de contato? Onde o usuário não vai informar a senha do email dele. E também não acho legal nem pra mim mesmo colocar a senha do meu email no código (em caso que fosse enviar uma confirmação de registro, etc)
Answer: Formulário de contato é você enviando uma mensagem para você mesmo, não é a pessoa enviando a mensagem para você. Não precisa contatar o servidor dela para fazer isto, precisa da sua senha.
É assim mesmo que funciona, ou coloca no código ou coloca em arquivo de configuração, o que acaba dando na mesma. O que dá para fazer é criptografar a informação, quase ninguém faz isto em PHP.
Tem soluções para evitar colocar a senha na aplicação, mas é complexa e não costuma compensar o trabalho, então todo mundo faz assim. De qualquer forma teria alguma proteção em algum lugar.
Formulário de confirmação é outra coisa, mas o processo é o mesmo. É você enviando a mensagem para outra pessoa, precisa da sua senha.
Sempre que abre um formulário na web está abrindo a possibilidade de ataques e existem técnicas sofisticadas para prevenir isto. Como esses ataques não costumam trazer vantagens é raro alguém fazer o ataque. E por isso é mais raro ainda alguém se prevenir contra isto.
Só tome o cuidado para não dar a chance de um formulário poder ao mesmo tempo permitir para a pessoa escolher a mensagem que será enviada e para quem a mensagem será enviada. Isso permite o envio de spam pela sua conta. Este é um ataque que traz vantagens.
O que não pode fazer em hipótese alguma é usar um servidor de e-mail que não precisa de autenticação para envio de mensagens.
Coloquei no GitHub para referência futura.


Getting a better handle on APC Cache Bins / code for settings.php

Question: I've got APC up and running on my VPS and have installed the APC module on my Drupal 7 site. I followed the documentation here and added this code to my settings.php file:
$conf['cache_backends'] = array('sites/all/modules/apc/drupal_apc_cache.inc');
$conf['cache_default_class'] = 'DrupalAPCCache';
//$conf['apc_show_debug'] = TRUE;  // Remove the slashes to use debug mode.

However, on my site's status page under APC, it says:
APC has been running for 3 min 54 sec. Currently caching 0 entries (0 bytes).

To me the "0 entries" indicated that there was no cache being created / used. I did some digging around and it looks like there might be additional code I need to add but cannot find documentation anywhere.
I found this snippet but not really sure if I need it or what part it I am supposed to use and what it does, I could not find any documentation for this. I suspect this is what makes the cache work.
'page_cache_without_database' => TRUE,
        'page_cache_invoke_hooks'     => FALSE,
        'page_cache_maximum_age'      => 3600,
        'cache_lifetime'              => 0,
        /* my note -- noticed "cacherouter" in the path below
         so I am guessing this needs to be adapeted to the path for APC?? */
        'session_inc'      => './sites/all/modules/cacherouter/session.inc',
            'cache_default_class'               => 'DrupalAPCCache',
            'cache_class_cache'                 => 'DrupalAPCCache',
            'cache_class_cache_block'           => 'DrupalAPCCache',
            'cache_class_cache_bootstrap'       => 'DrupalAPCCache',
            'cache_class_cache_content'         => 'DrupalAPCCache',
            'cache_class_cache_filter'          => 'DrupalAPCCache',
            'cache_class_cache_form'            => 'DrupalAPCCache',
            'cache_class_cache_menu'            => 'DrupalAPCCache',
            'cache_class_cache_page'            => 'DrupalAPCCache',
            'cache_class_cache_pathdst'         => 'DrupalAPCCache',
            'cache_class_cache_pathsrc'         => 'DrupalAPCCache',
            'cache_class_cache_session'         => 'DrupalAPCCache',
            'cache_class_cache_session_user'    => 'DrupalAPCCache',
            'cache_class_cache_update'          => 'DrupalAPCCache',
            'cache_class_cache_users'           => 'DrupalAPCCache',
            'cache_class_cache_views'           => 'DrupalAPCCache',
            'cache_class_cache_views_data'      => 'DrupalAPCCache',
      );

Any help on this matter would be appreciated.
The information about the APC extension returned from phpinfo() are the following ones.
Comment: Is this on linux ? What is in your php info in the "apc" section? Do you run php-fpm master process ?
Comment: Note: I've had quite some issues with using APC as cache backend, APC tends to become instable when you have large amounts of caches. I'd recommend using an external (=outside of PHP) service as cache provider, for example Memcache or Redis.
Comment: It's on linux / Cent OS.  Here is a screen capture of the APC section: http://twitpic.com/94re56/full I am not familiar with php-fpm so not sure about that...
Answer:
"APC has been running for 3 min 54 sec. Currently caching 0 entries (0
  bytes)."

This message suggests that your APC is running for each php request separately ultimately not caching anything at all.
I had a similar issue and it required to set up PHP once again but in a different mode.
APC works fine for multiple processes with apache/2 + php 5.3.x + php-fpm + fcgi in FPM/FastCGI mode.
PHP 5.3.x is configured with following options --enable-force-cgi-redirect --enable-fastcgi --enable-fpm
In APC section of my php info I can see:
APC Support = enabled
Serialization Support = php
MMAP File Mask = /tmp/apc.something  | where something is a random 6-character string
Please check your phpinfo
In PHP Configure Command you should have:
'--enable-fastcgi'
and
'--enable-fpm'
In Server API :
 FPM/FastCGI
Check if you have cgi-fcgi section and if you can find
php-fpm set to "active"
NOTE: There might be another solution if you use php 5.2.x or older.
Comment: Thanks that's all very interesting info but it does not address the crux of my basic question, "what about the additional code required for settings.php"...
Comment: Sorry, I can only tell you that manipulation of settings.php was not enough in my case and I needed to ask to recompile php and install php-fpm together with it.
Answer: APC should only be used for smaller parts of the cache, that dont change frequently. So probably not pages for example. (the actual bins where it is wise to use APC may vary depending on the site ... for example vars or menu).
Indeed, before you start caching data, first fine-tune your settings for caching scripts (so turn of that module).
You should use the script apc.php to see how much memory was used to cache the scripts and make sure you give APC enough memory (the default setting - 32M in your case is not necessarily enough) - otherwise the cache can be even worse - slowing the site down by trying to cache again and again. If you are limited on resources, dont be afraid to give it a fair share - it pays off (a tuned apc can get you lower amount of RAM per pageview).
I was also playing with not caching some directories (a crazy module with a lot files or the admin parts of views for example). Also, remember that in the default setting it is trying to cache ANY php file on the VPS ... even running two drupals side by side can be problematic (newly visited code is pushing the older out of the cache) - so i suggest limiting it to one drupal.
this is a useful resource to see http://php.net/manual/en/apc.configuration.php
and one with relation to drupal : http://xerosphere.net/optimizing-apc-for-drupal


Error:String types not allowed

Question: I am new to android.
I am facing the following error:
String types not allowed

EDIT: I have kept the image.jpg in Resources -> drawwble- hdpi

Refer the code below:
Strings.xml
 <drawable name="test_image">image.jpg</drawable>

Activity_main.xml
<ImageView android:id="@+id/imageDisplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/desc"
android:src="@drawable/test_image" />

Android_manifest
<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />

Comment: When you use @drawable/, it refers to the file  with extension jpg or png or gif that you placed in the drawable folder. So, if your image is called image.jpg, you should use @drawable/image, or you should rename your image to test_image.jpg.
Comment: to know about string resources check this http://developer.android.com/guide/topics/resources/string-resource.html. To just set image to a imageview follow the answer by Ahmad
Comment: you need to provide access permission in `manifest.xml`. try googling out for that.
Comment: Its a compile time bug. Has it anything to do with `target SDK` ?
Comment: please would you check again if the name of the image includes any capital letter
Comment: @WilliamKinaan: No Caps. the name is `image.jpg`
Comment: refresh your project, put `android:src="@drawable/image"` instead of `android:src="@drawable/test_image"`then save your layout
Comment: SOlved !!! You should not put  into the file String.xml. You should put your image file (which should be a jpg or a gif or a png) into the subdirectory res/drawable of your project. Then you reference that image in the xml file with @drawable/, where  is the name of the image you placed in the drawable folder, without extension
Answer: You can just do this:
<ImageView android:id="@+id/imageDisplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/desc"
android:src="@drawable/image" />

@drawable/image represents your drawable named "image".
Comment: Whats the difference between `android:src="@drawable/image"` AND `android:src="@drawable/test_image"` when both `image` & `test_image` refer to the same resource ?
Comment: SOlved !!! **You should not put  into the file String.xml.** You should put your image file (which should be a jpg or a gif or a png) into the subdirectory res/drawable of your project. Then you reference that image in the xml file with @drawable/, where  is the name of the image you placed in the drawable folder, without extension
Answer:
Place your image in res/drawable folder.
also remove the file extension.

I hope that helps.
Answer: The value of the attribute android:src should be a drawable object. So you should put the file 'image.jpg' into the folder res/drawable/ of your Android project, and then replace the line:
android:src="@drawable/test_image"

with
android:src="@drawable/image"

that will reference the file 'image.jpg' that you placed in the drawable folder.
Comment: You should not put  into the file String.xml. You should put your image file (which should be a jpg or a gif or a png) into the subdirectory res/drawable of your project. Then you reference that image in the xml file with @drawable/, where  is the name of the image you placed in the drawable folder, without extension.
Comment: Tried that. But still the error is same. Are you sure we write like this only in String.xml : `image.jpg` OR `image`

But the error states: **String types not allowed**

Error:String types not allowed


If all diagonals are drawn in a regular polygon from a vertex, the angles formed in that vertex are equal

Question: How can I prove this statement? I tried with a pentagon, but I have not achieved anything
Restriction: I can not use the circumference to prove it, and by this I mean to inscribe the polygon in the circumference. The idea is prove it with properties of congruence of triangles or properties of parallelogram or properties of quadrilateral, trapezium or trapezoid.

If all the possible diagonals are drawn in a regular polygon from a
  vertex, the angles formed in that vertex are equal each.
Comment: You should clarify what is "allowed". E.g. Can I use vector / complex number geometry (which I'd consider an overkill)? Which properties of regular polygons can I use, especially those about symmetry?
Comment: Is there a specific path you would like? E.g. Trigonometry, Coordinate geometry, etc.
Comment: The contents that have taught me are: Congruence of triangles, Properties of triangles (median, height, etc), properties of parallelograms, trapezoids and trapezoids. External and internal angles of quadrilaterals and regular polygons. With this I must solve it.
Comment: You have to somehow use the fact that all the interior angles from the center to adjacent vertices are equal. That is the definition of regular.
Comment: Mattiu, is Marty's claim allowed? IE Can I assume that a regular polygon has a center, which angle to any given side is equal?
Comment: I assume that you mean by a "regular polygon" one in which all sides and vertex angles are equal. Yes? We are not allowed to use the "center" in any way.
Answer: Pick a vertex $P_i$ and an adjacent side $P_iP_{i+1}$, and consider the angle bisector of $\angle P_i$ and the perpendicular bisector of $P_iP_{i+1}$.
For each bisector, join opposite vertices that are reflections to each other.

Do you agree that by symmetry there is a family of parallel lines for each bisector? Then the marked angles are all equal for being alternate angles of parallel lines.
As these parallel lines partition the regular polygon, they form triangles that are congruent to triangles formed by diagonals from a vertex.
e.g. $\triangle P_3P_0P_8 \cong P_0P_3P_4$ by counting the number of vertices between the long edge $P_3P_0$.
Comment: This is very slick. The only proof I could come up with was the one gotten by setting the polygon into a circle, as OP forbade.
Answer: How about this? But, as you can see, it's skirting about the "construct circle". In particular, the claim can be a step in proving "Angle at the center is twice angle at circumference".
Assumption: A regular polygon has a center $O$, where for any consecutive vertices $B, C$, $\angle BOC$ is a constant $ \frac{360^\circ}{n }$.
Claim: In triangle ABC, if $OA=OB=OC$, then $\angle BAC =  \frac{1}{2} \angle BOC$.
This is easily proven using isosceles triangles and angle chasing.
Hence, the result follows.

I hope this approach doesn't "use circumference"
Hint: A regular polygon can be inscribed in a circle.
Hint: Angle at the center is twice angle at circumference. Clearly, the angles at center are all the same.

I'm guessing this approach is "using circumference"?
Hint: A regular polygon can be inscribed in a circle.
Hint: If $A, B, C$ are 3 points on a circle, then $\angle ABC $ is dependent only on the length $AC$.
Comment: You are solving it with the circumference and its angles, I can not do that.
Comment: I think you're using the circumscribed polygon concept and $ OA = OB = OC $ are the radius of the circle and therefore are equal, but I can not use that, the idea is to solve it with the concepts I mentioned, without any circumference concept.
Comment: While I understand your frustration of "I cannot use X", you need to be much clearer in specifying what is allowed or not allowed. Am I allowed to assume that a regular polygon has a center which satisfies OA=OB=OC? If no, then 1) What is your definition of a regular polygon, and 2) Why can't I use that definition to show that such an O exists?
Comment: Thanks for your good help, I did not know that by DEFINITION that was true?
Comment: So the definition of regular polygon, is given by the circumference?
Comment: No, I didn't say that the definition includes the center. I am asking you for your definition, esp since it seems like this is from a class / homework where a specific path is not allowed. The typical definition is "equal angles and side lengths", from which rotational symmetry implies that the perpendicular bisectors of the sides intersect at 1 point (which we then denote as the center). The fact of perpendicular bisectors gives us $OA=OB=OC$, and rotational symmetry gives us that the angles $BOC$ are equal.
Once again, I'm skirting about the "not allowed to use circles" restriction.
Comment: Yes i have that definition "All angles and sides are equal", but i don't know about rotational simmetry or something similar
Answer: Let the regular polygon be $P_0P_1P_2\cdots P_{n-1}$ where $P_i$'s are vertices in order. The polygon has $n$ sides where $n\ge 4$ to be interesting.
Let each interior angle be $\theta$:
$$\theta = 180^\circ-\frac{180^\circ\cdot2}{n}$$
Pick $P_0$ as the vertex to draw diagonals from.
Consider the diagonal $P_0P_2$. The triangle cut off $\triangle P_0P_1P_2$ is isosceles with $P_0P_1 = P_1P_2$. The base angles are
$$\angle P_1P_0P_2 = \angle P_1P_2P_0 = \frac{180^\circ - \theta}2 = \frac{180^\circ}{n}$$

Now here's an inductive assumption: The $i$th triangle formed by $\triangle P_0P_iP_{i+1}$ has the following angles:
$$\begin{align*}
\angle P_iP_0P_{i+1} &= \frac{180^\circ}n\\
\angle P_iP_{i+1}P_0 &= \frac{180^\circ \cdot i}n
\end{align*}$$

For the next (i.e. the $(i+1)$th) triangle $\triangle P_0P_{i+1}P_{i+2}$, reflect $P_{i}$ by diagonal $P_0P_{i+1}$ to obtain $P_{i}'$. $P_{i}'$ may be outside or inside or on the edge of the polygon, but the cases are similar.
Examples of $i=1$ and $i=5$ in a regular nonagon:

In both cases, the proof strategy is to:

Consider the polygon interior angle $\angle P_iP_{i+1}P_{i+2}$ and three angles sharing the same vertex: $\angle P_iP_{i+1}P_0$, $\angle P_0P_{i+1}P_i'$ and $\angle P_i'P_{i+1}P_{i+2}$;
Use the inductive assumption to solve $\angle P_i'P_{i+1}P_{i+2}$;
Consider the isosceles triangle $\triangle P_i'P_{i+1}P_{i+2}$, and solve its base angles $\angle P_{i+1}P_i'P_{i+2}$ and $\angle P_i'P_{i+2}P_{i+1}$;
Show that $P_0$, $P_i'$ and $P_{i+2}$ are collinear using the first base angle;
Prove the induction statement for $i+1$.

If $P_{i}'$ is inside the polygon, e.g. $i=1$ above, consider the triangles at $P_{i+1}$: $\triangle P_0P_iP_{i+1}$, $\triangle P_0P_i'P_{i+1}$ and $\triangle P_i'P_{i+1}P_{i+2}$.
$$\begin{align*}
\angle P_iP_{i+1}P_{i+2} &= \angle P_iP_{i+1}P_0 + \angle P_0P_{i+1}P_i' + \angle P_i'P_{i+1}P_{i+2}\\
180^\circ - \frac{180^\circ\cdot2}{n} &= \frac{180^\circ \cdot i}n + \frac{180^\circ \cdot i}n + \angle P_i'P_{i+1}P_{i+2}\\
\angle P_i'P_{i+1}P_{i+2} &= 180^\circ - \frac{180^\circ (2i+2)}{n}
\end{align*}$$
$P_{i+1}P_{i+2} = P_{i+1}P_i'$ for being the sides of the regular polygon, so $\triangle P_i'P_{i+1}P_{i+2}$ is isosceles. Consider its base angles:
$$\begin{align*}
\angle P_{i+1}P_i'P_{i+2} &= \frac{180^\circ - \angle P_i'P_{i+1}P_{i+2}}{2}\\
&= \frac{180^\circ(i+1)}n\\
&= \angle P_i'P_{i+1}P_0 + \angle P_i'P_0P_{i+1}
\end{align*}$$
And so $P_0P_i'P_{i+2}$ is a straight line, so
$$\begin{align*}
\angle P_{i+1}P_0P_{i+2} &= \angle P_{i+1}P_0P_i'\\
&= \frac{180^\circ}n\\
\angle P_{i+1}P_{i+2}P_0 &= \angle P_{i+1}P_{i+2}P_i'\\
&= \frac{180^\circ(i+1)}n
\end{align*}$$

If $P_i'$ is outside the polygon, e.g. $i=5$ above, consider at $P_{i+1}$,
$$\begin{align*}
\angle P_iP_{i+1}P_{i+2} &= \angle P_i P_{i+1} P_0 + \angle P_0 P_{i+1} P_i' - \angle P_i'P_{i+1}P_{i+2}\\
180^\circ - \frac{180^\circ\cdot2}{n} &= \frac{180^\circ \cdot i}n + \frac{180^\circ \cdot i}n - \angle P_i'P_{i+1}P_{i+2}\\
\angle P_i'P_{i+1}P_{i+2} &= -\left[180^\circ - \frac{180^\circ (2i+2)}{n}\right]
\end{align*}$$
$\triangle P_i'P_{i+1}P_{i+2}$ is again isosceles with $P_{i+1}P_{i+2} = P_{i+1}P_i'$. Consider its base angles:
$$\begin{align*}
\angle P_{i+1}P_i'P_{i+2} &= \frac{180^\circ - \angle P_i'P_{i+1}P_{i+2}}2\\
&= 180^\circ - \frac{180^\circ(i+1)}n\\
&= \angle P_0P_i'P_{i+1}
\end{align*}$$
So in this case $P_0P_{i+2}P_i'$ is a straight line, and so
$$\begin{align*}
\angle P_{i+1}P_0P_{i+2} &= P_{i+1}P_0P_i'\\
&= \frac{180^\circ}n\\
\angle P_{i+1}P_{i+2}P_0 &= 180^\circ - P_{i+1}P_{i+2}P_i'\\
&= \frac{180^\circ(i+1)}n\\
\end{align*}$$

By induction, all $\angle P_iP_0P_{i+1}$ are equal to $\frac{180^\circ}n$ for $i = 1, 2, \ldots , n-2$.
Answer: Since the polygon is regular, it means that all the angles of interest (made up by the lines drawn from a single point) lie on a same-length segment of the circumscribed circle (equal sides of the regular polygon) and hence must be the same. However, I'm not sure if this answer doesn't satisfy your 'circumference' requirement (please clarify if it doesn't).
Comment: I cant inscribe the polygon in a circumference to prove it


Securing website assemblies with new code security model

Question: I'm currently on a project where we are creating a MVC site. The site needs to use code access security, due to the fact that third party dll's needs to be plugged in, to provide custom functionality. Now we don't want these assemblies to have full trust, and therefore utilizing the new security model in .NET 4.0
Because of these requirements, we are stong naming all of our own assemblies, and installing them in the gac. Some of these assemblies are SecurityTransparent mixed with SecuritySafeCritical and SecurityCritical types and members.
The securityTransparent and SecurityCritical assemblies, types and members can be used by the third party assembly developers just as we are intending.
I now have this problem with the Global.asax file, which inherits from a class residing in a assembly marked with the AllowPartiallyTrustedCallers attribute.
This class in turn inherits from HttpApplication.
In my web.config the trustlevel is currently set to High.
I'm getting the following error:

Inheritance security rules violated by type: 'ASP.global_asax'.
  Derived types must either match the security accessibility of the base
  type or be less accessible

I guess that's because of the inheritance rules when using the security model, and that the HttpApplication class must have a stricter rule than SecurityTransparent.
I tried marking my custom class with the SecuritySafeCritical attribute, but with no luck.
I hope some of you have a solution to this problem.
Answer: If you are trying to secure the access to the HttpApplication subtype I would reccomend abstracting it to a custom interface that you know is secure and allowing the third party developers access to that instead of trying to bootstrap security on to existing .NET types.