Does there exist a way of notating ones own harmonic language?

Question: It's quite clear to most that certain artists have a distinct sound. While a lot of it may be down to production elements and instrument choice, there can really be no denying that their personal harmonic language plays a role.
While music theory gives a good framework for describing and analyzing their choice of notes/chords, I find that it often stifles an inexperienced players creativity by imposing itself as a set of rules that must be followed. Eventually they may reach a point where they constantly come across caveats such as: "This works here but not there", or "That's modal interchange to the artist's taste, but it probably works because XYZ". With an almost certainty being that the artists themselves were unconcerned with these explanations of why their material "works".
Not to hate on music theory of course - It certainly is a pure way of analyzing many things, but I just wonder if there isn't a lower level way of describing a complete picture of an individuals harmonic language without caveats. Perhaps using set theory or mathematics?
For example, we are able to accurately determine if a painting was done by someone like Da Vinci, or if it is simply a good fake. Might there be a way of completely defining the sound of an artist? A method of extracting and preserving their harmonic language - their musical 'soul'?
Edit 1: Just to clarify, I understand that music theory is used as a way of describing what is happening rather than a set of rules - however as someone who has seen young musicians over and again try to improvise over a piece and essentially walk the major scale or modes up and down, I just wonder if there isn't  another way of imparting the sound they WANT to play quicker than years of listening, transcribing, then deriving. Specifically, I was curious if there has ever been a way of or an attempt at summarizing a signature sound in some form of notation, rather than simply getting a feel for it, or recognizing licks after years of practice? A packet of information that contains constantly recurring ideas that are a signature of the artist written in a standardized way - that would also include rhythmic, compositional, and other elements.
Comment: Current descriptions of music do not stifle creativity any more than words stifle creativity.  Would you propose asking a question here by jumbling up letter, words, and symbols in a way that is completely random to the rest of us but look pretty to you?  Music, like any other language or artistic medium, is about communicating with others.  What's wrong with learning things like pp, mp, ff, crescendo (which is just Italian for get louder), etc.  And then using them? If your "language" is for you then it doesn't matter if it uses existing notation or not.
Comment: Do you mean something like a "design language" for music, like the Snow White design language https://en.wikipedia.org/wiki/Snow_White_design_language   So, how was the design language written down? I guess it must have been some kind of a set of books containing descriptions of how to do different kinds of things. So, "how to do harmony the way I like it" book. What would you write in it? I think it would be just any sort of text, descriptions, maybe notation. Something you could give to other musicians in order to make "your" music. "Never play a maj7 chord in a bar full of rednecks" etc.
Comment: what is a harmonic language?
Comment: @ggcg There are plenty of areas of life in which we come up with terminology to represent specific concepts. Often such technical jargon is a bit opaque to those who are not familiar with it, but that doesn't mean it solely hinders communication - it makes up for its lack of 'common currency' by allowing more precise communication about a certain domain. I think OP is asking whether there's any terminology that could be used for the specific technical task of capturing an artist's "style".
Comment: Numpy - I am a bit confused though as to why you seem to equate 'signature sound' or musical 'soul' with harmonic language? For many artists, their 'signature' may be in their timbre or rhythm, rather in aspects of music that would (*traditionally*) be seen as 'harmony'...
Comment: @topoReinstateMonica, that was not at all clear in the OP.
Comment: @topoReinstateMonica Apologies, for me the term harmonic language takes precedence because my main interests lie in non-functional harmony, set-theory, why certain things work together, and how to define new harmonic concepts. While I think rhythm, etc. play an equally important part, I'd rather read answers with a bias towards thinking about harmony.
Answer: Hmm... this is an interesting question.  I'll mostly stick to the harmonic idea, as that was the original focus of the question (even though, as other answers have pointed out, musical style involves a lot more than harmony).
What you're really getting after is a notion of style analysis.  Specifically, you seem to want a kind of notation or "language" for compactly notating some composer's style.  I suppose the classic work on this idea is Jan LaRue's Guidelines for Style Analysis, which proposed a methodology for classifying various aspects of compositional style.  I wouldn't say it created any sort of compact language, but it's still a useful read for laying out some of the problems and the various parameters one might begin to think about.
But to harmony in particular, if you want to quantify the harmonic language of a composer, the first thing you might begin to do is create a sort of table of potential harmonic motions, with probability of movement from harmony X to harmony Y.  You might then incorporate some Bayesian concepts or Markov chain models to predict the likelihood of harmonic paths within a given context.
The early 2000s saw the development of a lot of potential models for harmony in this direction.  Some of these early attempts include things like David Temperley's The Cognition of Basic Musical Structures (2001) and Music and Probability (2007), Fred Lerdahl's Tonal Pitch Space (2001), and David Huron's Sweet Anticipation: Music and the Psychology of Expectation (2006).  Since these books, there have been lots of literature and articles attempting all sorts of methods of quantifying harmonic patterns.
Most of these early attempts focused on single harmonic motions between two chords.  But the next level of stylistic analysis would have to consider context (e.g., the effect of rhythm and accent on harmonic placement and progression).  One might then move on to building up a database of chains of three-chord, four-chord, etc. patterns, as corpus analysis in linguistics focuses on bigrams, trigrams, etc. to see patterns of word usage.  Some early attempts at this sort of corpus analysis can be found, for example, in Dmitri Tymoczko's A Geometry of Music (2011), where he showed the relative frequency of harmonic cycles in composers like Bach and Mozart (i.e., patterns that begin and end on tonic), though he's done a lot more work since then.
A lot of this type of corpus analysis has been facilitated in recent years by Michael Cuthbert (an occasional contributor here) and his work on the analysis package music21.
So far, there are lots of academic papers attempting to quantify style, but it's quite a challenge.  Even for a well-understood circumscribed collection like the Bach chorales, harmony can be very difficult to quantify.  In fact, one might say that recent attempts at corpus analysis have shown that our models (like tonal functions -- tonic, predominant, dominant) are overly simplistic and not up to the task of explaining how harmony works.  (See, for example, Chris White and Ian Quinn's recent article "Chord Context and Harmonic Function in Tonal Music.")
So, where does this leave us?  The basic answer to the question is that we can quantify harmonic patterns, perhaps for a particular composer and maybe even in an particular genre.  But since we're dealing with works of art, any classification system is going to be complex.  Would it be possible to identify stereotypical "signature" harmonic patterns of a particular composer?  Possibly.  Music theorists have been attempting this for at least a century, particularly because it might be relevant for adjudicating cases of questionable attribution of a historical work.  But, as noted above, patterns of harmony can't really be considered in isolation.  Rhythmic and phrase context, the question of harmonic function in ambiguous key situations, not to mention genre expectations, could be relevant.
Bottom line is that most such attempts at quantification are bound to be rather complex, consisting of long tables of numbers and probabilities, rather than the compact language the question hopes for.  Even in cases where we could summarize the data into "signature harmonic patterns," those will likely be rather unique to each composer, thereby making it difficult to come up with an effective and concise classification system.
But music theorists are working on it.  :)
Comment: This is an extremely informative answer, you have given me much to read and learn about! I'm going to be attempting such an analysis at some point in the coming years, and I'm certain all of these sources will come in handy. Thank you!
Answer: I guess there are two ways of looking at music theory.

As a set of rules that you must abide by in order to make music, or
A set of concepts which have have been developed to describe, in words and symbols, what a combination of different sounds are.

So to answer your question, yes and no. Yes, in that if you analyse enough of a person's music you will find a set of musical "ideas" that are repeated enough to be considered someones "harmonic language" as you put it. No, in that almost all music can be broken down into its individual parts and described with conventional analysis and so creating a new "harmonic language" for a single musician/composer seems a little like a waste of time in that we already have a fairly robust set of analysis tools to do such a thing.
I will give you an example that may or may not help. When I was studying Miles Davis, I spent many hours transcribing his solo's from many different era's where he played different styles and with different people. Throughout his entire career, I was able to find ideas he would repeat again and again and again. Licks he would play over early bebop would reappear over his fusion era. Sure if you weren't transcribing the amount that I was at the time, you may not even realise these licks were the same. But sure enough, through conventional musical analysis, I was able to discern patterns and in a way, form somewhat of a basis for harmonic, melodic and rhythmic ideas that you might be able to call his "harmonic language". Although I didn't think of it this way, I thought of it through the lens of conventional analysis.
So I guess, it comes down to definition and if you are willing to forget the idea that music theory is a set of rules and accept that it is just a set of tools.
Comment: Thanks for posting! I've edited the question for hopefully some more clarity
Comment: I thought for a second there you said "when I was studying _with_ Miles Davis" -
Comment: I would say #1 would be _composition methods_ and #2 is music theory. Yes, there is overlap, especially historically. But, I think the modern view of theory is #2.
Answer: You propose there is some unique harmonic language which cannot be described with music theory terminology, but then say nothing about what that unique harmonic language is. Whose style are you asking about?
There isn't much to say except there have been many harmonic styles that music theory provides the means to describe. Although, I suspect in many cases purely harmonic descriptions aren't going to tell the whole picture. Rhythm, melody, timbre, and other factors will contribute hugely to a musician's style. If music theory is thought of as common practice harmony/voice leading rules only, it is a short sighted view, and will be inadequate to describe a musician's style.
One area I think poses an obvious problem is non-western music and tuning systems. The problem isn't about such music not fitting into the western system - it doesn't make much sense to trying doing that in the first place - but the immediate barrier for a foreigner. If you cannot speak the language, or read the notation, you cannot discuss the music on its own terms.
If a musician's unique style involved a lot of "foreign" elements, it could be a problem for western theory to describe. One case that comes to mind is Debussy and Javanese music. The story goes that Debussy heard a gamelan at the Paris world fair and then tried to imitate the sound using the whole tone scale. The end result was music neither Javanese nor western common practice. Western theory has little to say about it harmonically other than it's functionally static. So you describe other aspects: rhythm, tempo, dynamics, timbre, melody, etc. That isn't a failure or abandonment of music theory. It's just using everything else except chord progression and voice leading.
Comment: Thanks for posting! I've edited the question for hopefully some more clarity
Comment: @Numpy, your edit really brings up something else: how to improvise, specifically how to not improvise badly. That's a lifetime journey! I'm also not the best to answer, because I'm still learning the basics of improvisation. IMO things work better musically when you dump the "chord/scale" system and focus on embellishing chord tones as the jazz greats of the first part of the 20th century did. Modal jazz is different, but I don't see how "chord/scale" helps with that beyond the obvious choice of scales.
Comment: Yeah I agree it reads as focused on improvisation, but what I am more concerned with is creation in general. While it sounds counter-intuitive that standardized information on how to replicate a musicians signature sound should encourage creativity, I think it may just have the opposite effect if introduced early. It could give rise to the idea that one can also define their own sound, and make their own 'rules'. Something that is sorely lacking in the currently musical pedagogy. Most wouldn't come across the chord tone/arpeggio approach you mentioned for several years for example.
Comment: I like the idea of learning by imitation, but that isn't what theory/harmony texts are about. Look for composition/improvisation methods instead of theory texts. You can find online tutorial to "fake" various general styles or particular musician's styles, but caveat emptor! Personally, I think the burden is on the imitator to develop a deep knowledge of the imitated musician. Even if you start with some tips about how to imitate someone you need to take a deep dive into that musician's work and see the actual origin of such tips.
Comment: For example, if one claims to imitate Mozart, can that person really distinguish Mozart from Haydn, or are they just generically doing classical style? That difference won't come from a quick list of easy rules.
Answer: First of all anyone can make up their own language people do it all the time.  I've done it too.  It's fun.  You can pick up a book on creating languages and have at it.  Your post seems very confusing to me as I think you are inadvertently describing multiple things.  On the one hand there is the matter of how we as musicians describe what to play and how to play it.  This basically uses directions given in Italian like accelerando, crescendo, piano, forte, Allegro, some of which have been turned into symbols, pp, ff, m, D.S. al coda.  These are instructions related to style, tempo, etc.  So in fact learning how to use the language we already use has nothing to do with creativity at all.  It also uses set divisions of time, and notation for what notes to play and when. It has to do with communication.  If you don't want to communicate your ideas to people then create your own language and keep notes in it.  I read somewhere that Steve Vai created his own language when he was young to prevent people from reading his ideas, not sure it was "musical" or to keep a personal diary personal.
On the other hand you seem to be talking about music theory in the context of harmony, chord progression, etc.  You are mistaking what theory is, which is a very common mistake.  Western music theory evolved as a set of best practices in our culture, the culture of Western Europe.  It is NOT a set of rules that dictate what you are allowed or not allowed to do.  Music existed for 1000s of years before anyone ever wrote down these "rules".  So in realty if you take them too seriously or become influenced by a bad teacher or method you might get stifled.  But that shouldn't happen if you have a good teacher, either private lessons or in school.  Of course, to pass a class on multi voice homophoinc harmony you will have to demonstrate that you know the "rules" they are teaching.  But every one of them has been broken without consequence (perhaps I should say with GOOD consequences in some cases).  The rules of music theory are common best practices of Western European cultures and should not ever be interpreted as rules.  At the very least that is ethnocentric as Indian and other forms of Eastern and Middle Eastern music sound wonderful and do NOT follow these "rules".
That all being said there is nothing wrong with learning the patterns of music as we know them today in a language we've been using for 100s of years.  This is not to force an opinion on you, the young musician, but a means to allow you to communicate your ideas to a wide audience.  Again, if you are the only person how will read your notes then it doesn't matter what you write and how.  But if you want to share these ideas or have an orchestra play them under your direction it would not hurt to learn how we write ideas down and explain them.  Don't worry about theory, it's there to enhance your understanding of culture, not to bind you to a set of chains (although cultures are good at doing this to people).  There is some natural curiosity and validity to wanting to understand WHY certain ideas become best practices and others not.  Is it really just opinion?  Or is there a real underlying physics based reason why we should NOT harmonize in parallel 5ths or octaves (even though we do all the time)?  There have been attempts to use physics and other scientific means to explain the "rules" of Western Music and why some ideas sound good and others don't.  At the end of the day there really are mathematical relationships in music and some of those may be hard wired into our brains through evolution but they are different in different parts of the world so it must be true that "music theory" is just a small part of a bigger picture.  I'd say it's a tool like any other tool.  Learn it and use it as you see fit.  But there is nothing wrong with making up your own set of rules that express your unique ideas.
Comment: Thanks for posting! I've edited the question for hopefully some more clarity
Comment: @Numpy, you edit, for me, makes it less clear.  Improv is variation in a theme and one can't improv w/o KNOWING the thing they are improving with.  You seem to want to circumvent the process of learning with a quick a dirty rule that removes the need for practice.  That is not how we learn language.  On the other hand I feel like you are now contradicting yourself.  First you stated that rules stifle creativity and now you seem to want a rule that makes on creative w/o effort.  At least that's how I read it.  Please discuss.
Comment: Sure, so what I actually said was that theory stifles creativity by imposing itself as a set of rules - not that it is responsible for imposing itself as such, nor that rules necessarily stifle creativity either. This is just an observation I've made from watching young musicians learn theory and struggle to break out of the rudimentary ideas. It seems to be a product of the current musical pedagogy. I was, and am, asking if anyone has come across a way of helping anyone caught in this loop break out by giving them structured information on how to achieve the sound they're after.
Comment: I find theory very helpful in boosting creativity. FIrst, there are lots new ideas that I may not have seen. Second, If I want to get a certain effect, I can use theory (and history even more) to see how other people got that effect (if they did) and adapt (steal) various ideas which I combine differently from previous use. Third, (actually 2.5) I can see what other people did that I wish to avoid. (Cannot avoid what one doesn't know; most non-theory musicians I know have trouble breaking out of their ruts too.) There's more, but not in a comment.
Answer: There is an approach I didn't see in the answers (or I missed). One could select a set of musical elements: rhythmic patterns, harmonic progressions, melodic patterns, timbre, etc., which one thinks are useful (or which work in the experiments proposed below.) Then one makes a "signature" from a piece of work like the number of ii-V-I or ii6-V-I or eighth-quarter-eighth-quarter-quarter, or modulation up a third minor to minor, etc. A simple statistical classifier (linear or quadratic discriminant analysis would be my first choice but others may prefer something yet.) Then one can see if any combination has discriminatory power.
We read in the literature things like, "Handel was fond of V42 chords" or "Mahler liked certain melodic patterns,".... This would indicate that there are some patterns of use.
Comment: The Bayesian concepts / Markov chain models in Athanasius' answer are related to this idea~


Access Popover Controller on iPad UISearchDisplayController?

Question: So I have a view with a UISearchDisplayController linked to a UISearchBar that is not contained within the navigation bar, but is positioned within the main view controller. It's all configured correctly to show a popover controller with results, however I need to obtain a reference to this popover controller.

Firstly, I need to be able to style the navigation bar, as you can see in the above screenshot, it is not styled properly.
Secondly, I need to dismiss this popover when the user selects a result, the following code is not working:
[self.searchDisplayController setActive:NO animated:YES];
[self.searchToolbar becomeFirstResponder];

I have even tried completely scrapping this popover and rolling my own, but I can't find a way to prevent this popover from being shown on the iPad. I need to use a UISearchDisplayController for the behavior on the iPhone, so i'd rather not get rid of it and roll my own search function entirely, has anyone got any ideas?
Answer: Resolved the problem I was having regarding the dismissal of the popover view. It turns out that the following lines do dismiss the popover controller...
[self.searchDisplayController setActive:NO animated:YES];
[self.searchToolbar becomeFirstResponder];

However, What I was doing immediately after that was populating the search string in the search field programatically (So the user retains a reference to what they actually searched for) In doing that, my search bar's delegate method performed another 'search' thus displaying the popover controller again...
In the words of a famous cartoon character... Doh!


ElasticSearch: How to set a default mapping to a template

Question: I'm running ElasticSearch version 1.4
I want to create a template that named:
listener*
with the following mapping:
Every string field will be defined as not_analyzed.
Meaning
analyzer:not_analyzed
The main reason for this is my intent to save the data AS IS. (e.g Person ID)
This can be done, but only when I specifically specify the field in its exact JSon structure.
When you have a large JSON structure it is very difficult to maintain.
Is there any way to specify to the mapping that every string field will be not_analyzed ?
Answer: This should do it. After you run it you'll have to delete and rebuild your index, but it will work for all new indices.
PUT _template/not_analyzed_template
{
    "template": "*",
    "mappings": {
        "_default_": {
            "dynamic_templates": [
                {
                    "template_1": {
                        "mapping": {
                            "index": "not_analyzed",
                            "type": "string"
                        },
                        "match_mapping_type": "string",
                        "match": "*"
                    }
                }
            ]
        }
    }
}

Here's some toy code I used to test it:
http://sense.qbox.io/gist/398aab275d48a7a2aac6ba725d5691e1e159496c
Comment: great. I've tried it and it works. BTW, when I've asked this question and got the same answer: use the analyzer "keyword". When I did that, it wasn't like the "not_analyzed", e.g. DATA: "This-Is-My-Data", keyword ANALYZER: word1:"this", word2:"is", word3:"my", word4:"data" which is nothing like "This-Is-My-Data". So my question here is, Is it the only way to achieve what I want? Or is there any other answer to my question above?


Reflection and rotation of a vector.

Question: Considerer a vector $(x,y)$ in the cartesian plane. The matrix that represents, first, a reflection of this vector in relation to a line passing through the origin and forming an angle $\alpha$ with  the axis $x$ positive and, after, a rotation around the origin by an angle $\beta$ is?
Comments
I considered a rotation of the system by an angle $\alpha$. Then we obtain the matrix
\begin{bmatrix} \cos\alpha & \sin\alpha \\ -\sin\alpha & \cos\alpha \end{bmatrix}
In the sequence, in this system I reflected on the axis $x$ multiplying by the matrix
\begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}
and so I got the matrix
\begin{bmatrix} \cos\alpha & \sin\alpha \\ \sin\alpha & -\cos\alpha \end{bmatrix}.
I don't know if this reasoning is correct and I don't know what it means "a rotation around the origin by an angle $\beta$".
I thank you for your help.
Comment: Did you mean the Cartesian *plane*?
Comment: Yes. Sorry by my English.
Comment: In fact, on second thought, I think the matrix with the 1 and -1 is not in the correct base
Comment: Unless your matrices are multiplying by row vectors on the right, your original rotation matrix is the transpose of what you want. Or it's a clockwise rotation through $\alpha$, rather than the usual counterclockwise.
Answer: Reading this, it seems like you were trying to get the reflection by rotating the plane and reflecting across the x-axis.  That's a valid strategy... as long as you reverse the rotation afterwards!
I'm assuming you're using transformation matrices multiplied on the right of row vectors, since that matches your rotation matrix format.
The angle $\alpha$ is used to specify the angle of the diagonal in this picture:

You'd need to work out what matrix reflects the plane over that line.  I suppose there are a lot of ways to do it.
Following your idea, we could rotate by $-\alpha$, reflect across the $x$-axis, then rotate back $\alpha$ to achieve the reflection.
If you do those transformations in that order:
$$
\begin{bmatrix} \cos\alpha & -\sin\alpha \\ \sin\alpha & \cos\alpha \end{bmatrix}\begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}\begin{bmatrix} \cos\alpha & \sin\alpha \\ -\sin\alpha & \cos\alpha \end{bmatrix}=\begin{bmatrix} \cos2\alpha & \sin2\alpha \\ \sin2\alpha & -\cos2\alpha \end{bmatrix}
$$
Another one I remember is to first figure out the unit normal and then compute its Householder reflection.
It's not hard to work out that the unit normal is $(-\sin\alpha, \cos\alpha)$, and then its reflection is
$$
I_2-2\begin{bmatrix}-\sin \alpha \\ \cos\alpha\end{bmatrix}\begin{bmatrix}-\sin \alpha & \cos\alpha\end{bmatrix}=\begin{bmatrix}1-2\sin^2\alpha & 2\sin\alpha\cos\alpha \\ 2\sin\alpha\cos\alpha &1-2\sin^2\alpha\end{bmatrix}
$$
Considering the half-angle identities, this matches the first matrix!
It's odd you say you don't understand "a rotation around the origin by an angle " because you were apparently comfortable writing the matrix for a rotation around the origin by an angle $\alpha$.
In the notation we're using, that matrix would be $\begin{bmatrix} \cos\beta & \sin\beta \\ -\sin\beta & \cos\beta \end{bmatrix}$. Applying this transformation after the previous one would achieve the matrix that's the goal of the problem.
Comment: Thank you for your help! I managed to solve it with the tip of the other answer and then I marked it as correct.
Answer: you just use the fact that this is the composition of linear transformations: Denoting by $R(x,y)$ the reflection, and $T(x,y)$ the rotation, the transformation of your exercise is $(T \circ R)(x ,y)$. It is a known fact of linear algebra that the matrix of the composition of linear transformations is the product of the matrices, i.e. $[T \circ R] = [T][R]$ (assuming to use the canonical basis of $\mathbb{R}^2$) so just do the multiplication of the rotation and reflection matrices.
Comment: But what you mean "a rotation around the origin by an angle $\beta$"? What is the matrix of linear tranformation?
Comment: Here you can find the definition of rotation matrix https://en.wikipedia.org/wiki/Rotation_matrix
Comment: Saying rotation around the origin simply means rotating the vector counterclockwise. That I wasn't understanding what it was. It is not necessary to change system or basis, just use the rotation and reflection matrices around a straight line.
Comment: Thank you for your help.
Comment: You're welcome!

Reflection and rotation of a vector.


Test of significance between autocorrelation coefficients for two time series

Question: I have a time series measured at monthly intervals, and I want to determine if the first half of the series is less persistent than the second half of the series. My initial thinking was to the estimate coefficients for the autocorrelation function using each half of the initial time series.
For each series I have estimated coefficient for lags 1-25. As I initially imagined, the coefficient on each lag is higher in the second series and this difference between the estimates increases with the lag. What I want to know is whether the difference is statistically significant.
I imagine there is a straightforward way to do this, but I am new to statistics and none of the methods I understand well seem to fit. I am also using R if that matters.
Answer: Form a useful ARIMA model . Estimate separate coefficients for each each time interval (two groups). Estimate the coefficients globally ( using all the data ). Perform the CHOW TEST for purposes of testing the equality of coefficients over the two groups .
Comment: I wonder, does this approach properly address the aspect of interest, i.e. persistence? Is it possible to deduce statistical significance of difference in persistence from the Chow test suggested above?
Comment: Thanks for your response. I have tried to do some reading on ARIMA models, but I don't fully understand the motivation for them. If it is possibly to briefly summarize the beneficial properties or direct to me a thorough introduction to the subject I would greatly appreciate it.
Comment: Persistence ( a.k.a.) is reflected in the coeficients. Two or more sets of coefficients can be be tested for commonality of persistence via The CHOW test .
Comment: ARIMA models are based on the ACF/PACF and reflect the way the past relates to future values. An arima model is simply a weighted sum of the past. For example a twevce period average of the past is a simple ARIMA model where the lenght of memory is 12 and the weights are equal to 1/12th .The form of the ARIMA model will tell you how to optimize these two specifications ( i.e. the length and the actual weights.
Comment: ARIMA models based on the ACF/PACF reflect the way the past relates to future values. arima model is simply a weighted sum of the past.For example a 12 period average of the past is an ARIMA  where the lengtht of memory is 12 and the weights are = 1/12 .The form of the ARIMA model will tell you how to optimize these two specifications ( i.e. the length and the actual weights.You can pursue ARIMA model educational info at http://www.autobox.com/cms/index.php/blog or here http://www.autobox.com/cms/index.php/afs-university/intro-to-forecasting or here http://people.duke.edu/~rnau/411arim.htm


Why is "File.expand_path(...)" resolving to something different from what I expect?

Question: I'm currently stepping through the code of the gitlab_development_kit gem to see how it works.
I'm currently at this line of code, and I've placed a debugger point above and below the line.
    3: require 'byebug'
    4: byebug
    5:
=>  6: $LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
    7: byebug
    8: require 'gitlab_development_kit'

I inspect the values of $LOAD_PATH and File.expand_path('../../lib', __FILE__):
(byebug) $LOAD_PATH
["/usr/local/Cellar/rbenv/1.1.2/rbenv.d/exec/gem-rehash", ...]

(byebug) File.expand_path('../../lib', __FILE__)
"/Users/richiethomas/Workspace/ThreeEasyPieces/lib"

I type next to advance the debugger, and then re-check the above values:
(byebug) next

[2, 11] in /Users/richiethomas/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/gitlab-development-kit-0.2.5/bin/gdk
    2: require 'yaml'
    3: require 'byebug'
    4: byebug
    5:
    6: $LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
=>  7: byebug
    8: require 'gitlab_development_kit'
    9:
   10:
   11:

(byebug) File.expand_path('../../lib', __FILE__)
"/Users/richiethomas/Workspace/ThreeEasyPieces/lib"

(byebug) $LOAD_PATH
["/Users/richiethomas/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/gitlab-development-kit-0.2.5/lib", "/usr/local/Cellar/rbenv/1.1.2/rbenv.d/exec/gem-rehash", ...]

If the value of File.expand_path('../../lib', __FILE__) really was "/Users/richiethomas/Workspace/ThreeEasyPieces/lib", then that's what I would expect to be pre-pended to $LOAD_PATH.  But instead, it looks like the lib dir from the version of the gem managed by RBENV was pre-pended instead.  What kind of devil's magic is this? :-)
Answer: __FILE__ at the prompt does not evaluate to the same value as __FILE__ in the file. In fact, __FILE__ is the currently executing file, but at the interactive prompt, there is no currently executing file, ergo, __FILE__ is just a placeholder.
Within IRb, __FILE__ evaluates to '(irb)', within Pry, it evaluates to '(pry)', and within Byebug, it evaluates to '(byebug)':
(byebug) __FILE__
"(byebug)"

Since (byebug) is a perfectly legal filename, File.expand_path will expand it using whatever the current working directory is. E.g. if the current working directory is /a/b/c, File.expand_path(__FILE__) will evaluate to /a/b/c/(byebug). Ergo,
File.expand_path('../../lib', __FILE__)

will then expand to
'/a/b/lib'


Ubuntu IPv6 setup for LAMP and Mail Server

Question: I noticed my ip6tables are not configured on my newish server, but well supported by my VPS and I have some idea about how to implement ipv4 rules, but know nothing about ipv6, I've tried looking through various Google and serverfault examples, but get somewhat conflicting arguments about best practices. So my question is, given the practices in my iptables.firewall.rules file below, what would an ipv6tables.firewall.rules file look like for me to start-up with the server?
<code>*filter

#  Allow all loopback (lo0) traffic and drop all traffic to 127/8 that doesn't use lo0
-A INPUT -i lo -j ACCEPT
-A INPUT ! -i lo -d 127.0.0.0/8 -j REJECT

#  Accept all established inbound connections
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

#  Allow all outbound traffic - you can modify this to only allow certain traffic
-A OUTPUT -j ACCEPT

#  Allow HTTP and HTTPS connections from anywhere (the normal ports for websites and SSL).
-A INPUT -p tcp --dport 80 -j ACCEPT
-A INPUT -p tcp --dport 443 -j ACCEPT

#  Allow ports for testing
-A INPUT -p tcp --dport 8080:8090 -j ACCEPT

# Allows SMTP access
-A INPUT -p tcp --dport 25 -j ACCEPT

# Allows pop and pops connections
-A INPUT -p tcp --dport 110 -j ACCEPT
-A INPUT -p tcp --dport 995 -j ACCEPT

# Allows imap and imaps connections
-A INPUT -p tcp --dport 143 -j ACCEPT
-A INPUT -p tcp --dport 993 -j ACCEPT

#  Allow ports for MOSH (mobile shell)
-A INPUT -p udp --dport 60000:61000 -j ACCEPT

#  Allow SSH connections
#  The -dport number should be the same port number you set in sshd_config
-A INPUT -p tcp -m state --state NEW --dport 1022 -j ACCEPT

#  Allow ping
-A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT

#  Log iptables denied calls
-A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7

#  Reject all other inbound - default deny unless explicitly allowed policy
-A INPUT -j REJECT
-A FORWARD -j REJECT

COMMIT
</code>
Comment: http://serverfault.com/a/410327/126632
Answer: ip6tables is pretty much the same as iptables. IPv6 depends heavily on ICMP so I suggest not filtering it unless you have a very good reason.
I would start with removing this line (IPv4 addresses don't make sense in ip6tables):
<code>-A INPUT ! -i lo -d 127.0.0.0/8 -j REJECT
</code>
And changing the ICMP line to:
<code>-A INPUT -p icmpv6 -j ACCEPT
</code>
Everything else looks to be IP version independent and should work for both iptables and ip6tables.


Slice a specific row out of pandas groupby dataframe

Question: I need to slice a particular row out of a groupby dataframe using 2 columns titles (The image is provided).I need the output of "Age" for a given Gender and Country.
Output of the groupby dataframe
Comment: Please put code and data in the body of your post rather than putting up a screenshot https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-on-so-when-asking-a-question
Comment: Does my attempt help. If it doesnt, post your data not the image and we will help
Comment: Did it work or you need more help?
Answer: Now that you didnt give data. Lets use free data from seaborn
Data
import pandas as pd
import seaborn as sns
sns.set()
tips = sns.load_dataset("tips")
tips

Groupby to get similar result to yours
df=tips.groupby(['sex','time'])['tip'].sum().to_frame()
df

Several ways to slice multi index for row;
##Silce Male Dinner
df.loc['Male','Dinner',:]

##Silce Female Dinner and Lunch
df.loc['Female',:]

#slice(None) to select all the contents of that level.
df.loc[(slice(None),'Lunch'),:]

Comment: df_GC = df.groupby(['GenderSelect', 'Country'])
df_GC.describe()
df_GC.loc['Male','United States',:].     but the error I get this time is Cannot access callable attribute 'loc' of 'DataFrameGroupBy' objects, try using the 'apply' method
Comment: Please provide me with a sample of your data. I worked of a generic dataset and cant figure out how to relate what you are doing to the answer I provided. Happy to help


Powershell Array search for keys

Question: I Have an array called $a
echo $a gives:
url                                                               load
---                                                               ----
win-coll2.astest.org                                              9
win-coll.astest.org                                               110
win-coll4.astest.org                                              110
win-coll5.astest.org                                              140
win-coll3.astest.org                                              410

now i want to know, if the array contains a sting
eg:
win-coll2.astest.org should lead to true
and win-coll7.astest.org should lead to false
is there a proper way to do this without a foreach?
with foreach:
$IsInArray = false
$ProofString = "win-coll2.astest.org"
foreach( $item in $a){
  if($item.url -eq $ProofString){
    $IsInArray = true
  }
}

Answer: In powershell v4 (and possibly v3) you can do the following:
[PS] > $a.url -contains 'win-coll2.astest.org'
True
[PS] > $a.url -contains 'win-coll7.astest.org'
False

Otherwise, I think the easiest, least painful way is either do a foreach or a foreach-object...
Comment: @Joel PoSh v4, through the Windows Management Framework v4 is available on Server 2008 R2, but not Server 2008.
Comment: since which WinServ is PS v4 supported? Is it available on 2008?
Comment: I think you need R2, take a look at http://www.microsoft.com/en-us/download/details.aspx?id=40855 for more info about it.

Powershell Array search for keys


SimpleCursorTreeAdapter causing an error

Question: Below is the code from my actvity along with a inner class that is a sub-class of Simple Cursor Tree Adapter. The problem is when i click child elements of the There is an error
protected void onStart() {
    super.onStart();
    SQLiteDatabase db = new ToDoDatabase(getApplicationContext())
            .getWritableDatabase();
    Cursor cursor = db.query(true, ToDoDatabase.TABLE_NAME, null, null,
            null, null, null, null, null);
    CustomCursorTreeAdapter cursorTreeAdapter = new CustomCursorTreeAdapter(
            getApplicationContext(), cursor, R.layout.group_item_layout,
            new String[] { ToDoDatabase.TASK_NAME_FORMAT_DATE },
            new int[] { R.id.groupItem }, R.layout.child_item_layout,
            new String[] { ToDoDatabase.TASK_TIME },
            new int[] { R.id.childItem });
    drawerList.setAdapter(cursorTreeAdapter);
}

public class CustomCursorTreeAdapter extends SimpleCursorTreeAdapter {

    public CustomCursorTreeAdapter(Context context, Cursor cursor,
            int groupLayout, String[] groupFrom, int[] groupTo,
            int childLayout, String[] childFrom, int[] childTo) {
        super(context, cursor, groupLayout, groupFrom, groupTo,
                childLayout, childFrom, childTo);
    }

    @Override
    protected Cursor getChildrenCursor(Cursor group) {
        SQLiteDatabase db = new ToDoDatabase(getApplicationContext())
                .getWritableDatabase();
        return db
                .query(
                        ToDoDatabase.TABLE_NAME,
                        new String[] { ToDoDatabase.TASK_TIME },
                        ToDoDatabase.TASK_NAME_FORMAT_DATE + " = ? ",
                        new String[] { group.getString(group
                                .getColumnIndex(ToDoDatabase.TASK_NAME_FORMAT_DATE)) },
                        null, null, null, null);
    }

    @Override
    public boolean isChildSelectable(int groupPosition, int childPosition) {
        return true;
    }
}

The output from my logcat is as below. More over I am getting same value for expendableList groupitem. Example if i there are tWo "A" then i am getting 2 "A" with same childitems.And i am a android beginner
     10-14 23:52:11.908: E/AndroidRuntime(28080): java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow.  Make sure the Cursor is initialized correctly before accessing data from it.
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at android.database.CursorWindow.nativeGetLong(Native Method)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at android.database.CursorWindow.getLong(CursorWindow.java:515)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at android.database.AbstractWindowedCursor.getLong(AbstractWindowedCursor.java:75)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at android.widget.CursorTreeAdapter$MyCursorHelper.getId(CursorTreeAdapter.java:436)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at android.widget.CursorTreeAdapter.getChildId(CursorTreeAdapter.java:173)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at android.widget.ExpandableListConnector.getItemId(ExpandableListConnector.java:427)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at android.widget.AdapterView.getItemIdAtPosition(AdapterView.java:756)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at android.widget.AdapterView.setSelectedPositionInt(AdapterView.java:1128)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at android.widget.AbsListView.onTouchEvent(AbsListView.java:3165)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at android.view.View.dispatchTouchEvent(View.java:5604)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2054)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1815)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2060)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1829)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2060)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1829)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2060)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1829)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2060)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1829)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1917)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1376)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at android.app.Activity.dispatchTouchEvent(Activity.java:2364)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at android.support.v7.app.ActionBarActivityDelegateICS$WindowCallbackWrapper.dispatchTouchEvent(ActionBarActivityDelegateICS.java:255)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1865)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at android.view.View.dispatchPointerEvent(View.java:5784)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:2890)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2466)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at android.view.ViewRootImpl.processInputEvents(ViewRootImpl.java:845)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2475)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at android.os.Handler.dispatchMessage(Handler.java:99)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at android.os.Looper.loop(Looper.java:137)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at android.app.ActivityThread.main(ActivityThread.java:4448)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at java.lang.reflect.Method.invokeNative(Native Method)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at java.lang.reflect.Method.invoke(Method.java:511)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:823)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at          com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590)
     10-14 23:52:11.908: E/AndroidRuntime(28080):   at dalvik.system.NativeStart.main(Native Method)

Comment: `getChildrenCursor` does not return `Cursor` with column called `_id`
Comment: Yes this was the problem thank you. Can u help me with the second problem i mentioned about multiple same groupItems
Answer: As @Selvin says, it appears you have an invalid return on your getChildrenCursor() method.
Refer to the documentation on the method.

The Cursors must include a column named "_id" or this class will not work.

http://developer.android.com/reference/android/widget/CursorTreeAdapter.html
Comment: Yes this was the problem thank you. Can u help me with the second problem i mentioned about multiple same groupItems @Demonslay
Comment: I'm afraid I don't quite understand your question. Are you getting duplicate results when there are not supposed to be? I see you are using the `distinct` variant of the `query` method; the `distinct` only works if you pass a column to the `groupBy` argument so that it can compare to.
Comment: What i need to pass in groupBy? The case is that I want unique dates. i am not able to achieve that @Demonslay335
Comment: I'm not completely sure on which of your columns is the date you are wanting to group by, but I'd assume it to be `TASK_TIME` or `TASK_NAME_FORMAT_DATE`. You'd pass it as a string array as the other arguments:
`new String[] { ToDoDatabase.TASK_TIME }`
Comment: Whoops, my mistake, `groupBy` is a singular String, not an array. Simply pass the `TASK_NAME_FORMATE_DATE` constant and you should be good. You may need to define the `columns` argument if that alone does nothing.
Comment: No it didnt solved the problem. I am still getting multiple columns and this time i am getting only one `TASK_TIME` associated with `TASK_NAME_FORMAT_DATE`
Comment: thank you! clear info and solve the problem with the exception:
i've got the same exception. and stubmled over "at android.widget.CursorTreeAdapter$MyCursorHelper.getId(CursorTreeAdapter.java:436)" in the stacktrace. so the answer with missed "_id" was right and helpful!


How keep column names when merge/concat in Pandas Dataframe

Question: i have a dataframe created in pandas which is looks like this:
<code>        A           B           C
        X   Y   Z   X   Y   Z   X   Y   Z
Y   K   2   5   12  11  9   8   4   5   12
    K   4   4   13  15  5   4   6   7   2
    K   6   7   14  0   2   3   0   6   8
C   M   4   5   12  5   2   2   1   14  0
    M   6   7   2   3   1   6   7   12  5
    M   0   6   8   7   3   9   6   8   4
D   N   7   1   13  15  9   8   1   13  5
    N   9   0   14  0   5   4   0   14  6
    N   3   2   12  5   2   3   1   2   2
</code>
I want to make it looks like this:
<code>        A           B           C
        X   Y   Z   X   Y   Z   X   Y   Z
Y   K   2   5   12  11  9   8   4   5   12
    K   4   4   13  15  5   4   6   7   2
    K   6   7   14  0   2   3   0   6   8
        A           B           C
        X   Y   Z   X   Y   Z   X   Y   Z
C   M   4   5   12  5   2   2   1   14  0
    M   6   7   2   3   1   6   7   12  5
    M   0   6   8   7   3   9   6   8   4
        A           B           C
        X   Y   Z   X   Y   Z   X   Y   Z
D   N   7   1   13  15  9   8   1   13  5
    N   9   0   14  0   5   4   0   14  6
    N   3   2   12  5   2   3   1   2   2
</code>
Is there is any way i can do that? I have tried several ways with concat/merge/join, but i didn't find a way how i can keep column names for "Y,C,D"
Comment: The structure in your desired output is not exactly a dataframe structure
Comment: Out of curiousity, why would you want your dataframe like this? Or is your question: "how to export a pandas dataframe to excel in the following format?"
Comment: I need to export it to google sheet in this format
Answer: No it is not possible using the standard DataFrame string output/display functions.  If there were a way to do that it might be a "display option" but those are all listed here and I don't see a relevant one for you: https://pandas.pydata.org/pandas-docs/stable/user_guide/options.html#available-options
Comment: may be there is another way? Like create separate data frames from Y,C,D
I want to export data in google sheet in this format.
Comment: Sure, you can create separate DataFrames and print them one after the other.


Center of $\mathfrak{gl}(n,\Bbb F)$ using the adjoint representation

Question: I'm quite new to Lie Algebras, and so there's a lot of easy stuff that I'm probably missing. Anyway following Kac notes I'm asked to compute the center of $\mathfrak{gl}(n,\Bbb K)$, and I've done it in the usual way (defining a bases for two matrices and working it out with brute force).
Anyway I was wondering: since the kernel of the adjoint representation is the center of the group, i.e. $ker(ad)=Z(\mathfrak{gl}(n,\Bbb K))$, is there any more elegant way to arrive to the result, i.e. $Z(\mathfrak{gl}(n,\Bbb K))= \lambda I$, starting from some proprieties of the adojoint representation?
Comment: I don't think there is going to be any very nice proof along these lines that does not essentially replicate your arguments anyway. The reason is that we obviously need to know something about the specific Lie algebra we have to know the center.
Comment: you men you need to know the field K?
Comment: No, I mean we need to use something about the specific Lie algebra (I mean, we cannot make any sort of general conclusion about the size of the center of a Lie algebra without further assumptions anyway).
Comment: well the Lie algebra in question is $\mathfrak{gl}(n,\Bbb K)$ with the canonical brackets... should I specify something I'm missing?
Answer: I also think that the adjoint representation will not give a "more elegant proof".
The computation of the kernel amounts again to the problem to show that $[A,B]=AB-BA=0$ for all $B$ implies that $A=\lambda I$. I do not agree that the proof here necessarily needs to be "brute force". There are several proofs given, among them such which try to avoid matrix computations, see
these answers. Also, the usual proof is not so bad.
Comment: I believe that Dac0 understands that the center is the kernel of $ad$. I think the question is whether one can use the adjoint representation to find the center without resorting to computations.
Comment: I also think that Dac0 understands that the center is $ker(ad)$. The question is perhaps more about the proof in general concerning the center of $\mathfrak{gl}_n(K)$. Here I think $ker(ad)$ is just a reformulation, and does not help.


Stop caching images in views, force reload of jquery image slideshow when images are externally updated

Question: In D7, I have a panel that contains a view that contains a jquery image slideshow.
Every day, the images that compose the slideshow are updated by a cron job---ie, every day's new images override the old ones (they are given the same names).  So, say I have image1.png, image2.png and image3.png---every day these files are overwritten with new pictures.
I have added the following anti-cache protections in my meta section to both the page/panel and the view itself:
<meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">
<meta http-equiv="refresh" content="300">

I have also turned off all caching on the server of any duration, and of javascript/css.  I also run the external cron with the cron-key after the image overwrite occurs.
Yet it seems that the only way my slideshow ever updates to reflect the new content of the image files is when I do an F5 or ctrl+r hard reload.
I don't want to ask my users to do this, so how can I force a reload and cache-clearing beyond the measures I've already taken above to get the browser to recognize that the images in the slideshow have changed on the server?
(I saw this recent similar post, How to tell if an image was updated, but it seems to apply to images created by Drupal, rather than created externally and pumped in.)
Update:
I have also added, in light of @mikeytown2's comment below, the following to my .htaccess file:
 # Requires mod_expires to be enabled.
<IfModule mod_expires.c>
  # Enable expirations.
  ExpiresActive On

  # Cache all files for 2 weeks after access (A).
  # ExpiresDefault A1209600
  ExpiresDefault A600 #NOTE, this means ALL sites expire in 5 minutes by default!

  <FilesMatch \.php$>
    ExpiresActive Off
  </FilesMatch>

</IfModule>

The .htaccess is in my public folder.
Even with this, which should be telling Drupal that all caches from my page expire at 5 minutes, I am still not seeing an update when new images replace old ones of the same name in my slideshow.
I have made sure to completely clear my cache and await an external cron, and the old images remain cached in the browser and/or server.
Answer: with firebugs net panel click on image1.png, select cache and get this information
Last Modified
Last Fetched
Expires

Your currently setting the html page to not be cached in the browser (which is already the case by default). If the images are hosted on your server, you need to adjust your apache .htaccess rules and have these images not be cached. Drupal's default htaccess uses a 2 week cache for everything other than php scripts. You need to make an exception for your images with filesmatch. Example:
# Requires mod_expires to be enabled.
<IfModule mod_expires.c>
  # Match image1.png, image2.png, etc...
  <FilesMatch ^image\d+\.png$>
    # Disable browser caching.
    ExpiresActive Off
  </FilesMatch>
</IfModule>

If the images are not hosted on your server simply append a question mark with the current unix time to the end of the image src. Example:
image1.png?1317717247

Comment: Awesome, thanks, that's very thorough.  Can I ask for one other pointer though? I'm not very good with regular expressions, so if my images were instead named image_ABC.png, image_BBB.png, etc...  would the following replacement be right?  ``
Comment: In full context, the .htaccess in my public directory now looks like this: `
  ExpiresActive On

  ExpiresDefault A1209600

    ExpiresActive Off

    ExpiresActive Off

` And this is not working yet
Comment: Did a little tinkering: it turns out even when I change A1209600 to A600, so it should release ALL caches within 5 minutes, it still isn't reflecting the new png files.  So, there might be something beyond .htaccess at work here?
Comment: mod_expires could be disabled on your server. What does firebug say the cache lifetimes of the files are?
Comment: As for regex, I use http://txt2re.com/ to help with creating regex given a string. This is a good start: http://txt2re.com/index-vb.php3?s=image_ABC.png&-22&4&-18&-6&-5&-3 Putting this all together you can test regex @ http://regexio.com/prototype.html (all back slashes here need to be double escaped \\; apache only needs one \) image_[A-Z]+.png should be image_[A-Z]+\.png
Answer: None of these internal-to-drupal settings worked.  It turned out I had to curl my cron.php remotely to actually reset the caching.


Find all incongruent solutions to this equation

Question: Find all incongruent solutions to $$11x^{33} \equiv 2 \pmod{17} $$
Comment: Your Question would be improved by explaining what you mean by "incongruent" solutions.
Answer: $x^{16}\equiv1 \pmod {17}$ by Fermat's little theorem. (unless $x$ is a multiple of $17$, but this case obviously doesn't generate solutions to the problem at hand).
So
$11x^{33}\equiv11x \equiv2\pmod {17}$
$x\equiv\frac{2}{11}\equiv\frac{2}{-6}\equiv-\frac 13 \equiv \frac{33}{3}\equiv11 \pmod {17}$
So the solutions are $x=11+17k$
Comment: Please don't provide complete solutions for people who have shown zero work/effort of their own.
Answer: Observe
\begin{align}
11a\equiv 1 \mod 17 \ \ \Rightarrow \ \ a \equiv 14 \mod 17
\end{align}
which means
\begin{align}
x^{33}\equiv 11 \mod 17.
\end{align}
Using Euler's theorem, we have that
\begin{align}
x^{33}\equiv  x \equiv 11 \mod 17.
\end{align}


Self adjoint inverse

Question: I'm reading some functional analysis and it's after lunch so I can't think. Can someone please help with this quick question. I have the following:
Let $T\in B(H)$ be a self adjoint operator and $\varepsilon>0$. Let $p$ be the spectral projection of $T$ corresponding to the Borel subset $[-\varepsilon,\varepsilon]$ (that is, the indicator function of $[-\varepsilon,\varepsilon]$ applied to $T$ by Borel functional calculus). Then the following operator $$S = (1-p)T+\varepsilon p$$ has a self adjoint bounded inverse.
Why? Is there an obvious inverse I am missing, or is this some bounded inverse theorem (or one of the other functional analysis theorems) business.
Comment: $S$ corresponds to the function equal $1$ on the interval $x\in [-\varepsilon,\varepsilon]$ and $x$ for |x|>\varepsilon. Such function has a bounded inverse. The inverse operator is equal {1\over \varepsilon}P$ on the range of $P.$ But on the range of $I-P$, i.e. on $\ker P$ according to me there is no explicit formula, which does not make use of the  spectral integral.
Answer: I was about to post an answer, when I saw that what I had to say had been said in a comment. Some readers may wonder what it means for an operator to "correspond to" a function. That's a medium-long story - my favorite version is not the most popular one, decided to mark this community-wiki and post a complete answer for readers who don't know that stuff.
Note again that the proof is contained in a comment above, of which this is just an exegesis.
A suitable version of the Spectral Theorem says that wlog $H=L^2(\mu)$ and $T$ is given by pointwise multiplication by $m\in L^\infty(\mu)$: $$(Tf)(x)=m(x)f(x).$$In this context $p$ is given by multiplcation by $$k_\epsilon=\chi_{[-\epsilon,\epsilon]}\circ m,$$and $S$ is multiplication by $$M=(1-k_\epsilon)m+\epsilon k_\epsilon.$$Considering a total of two cases shows that $1/M$ is bounded. (Also $1/M$ is real-valued since $m$ is; that's the "self-adjoint" part.)
Comment: Good that you have posted the answer, as my comment is edited poorly (typed on my mobile phone). Besides on function space the explanation is clearer.
Comment: Thanks to both of you for your help

Self adjoint inverse


Deleting resources

Question: I'm a beginner in C. I currently have a task to create a program having multiple queues. How should i correct this? From my understanding, is supposed to clear all of the queues that where created. As currently i think i have memory leaks.
#include <stdio.h> //printf etc
#include <stdlib.h> //malloc calloc realloc free
#include <stdint.h>

/* number of message queues */
#define MSGQS_LEN 5

/* number of nodes in the message queue */
#define CAPACITY 5

typedef struct _node {
    const char* message;
    struct _node* next;
} node_t;

typedef struct {
    char qName;
    node_t *front, *rear;
} msg_queue_t;

typedef struct {
    msg_queue_t **queues;
} MsgQs_t;

Comment: Please don't make more work for others by vandalizing your posts. By posting on the Stack Exchange (SE) network, you've granted a non-revocable right, under a [CC BY-SA license](//creativecommons.org/licenses/by-sa/4.0), for SE to distribute the content (i.e. regardless of your future choices). By SE policy, the non-vandalized version is distributed. Thus, any vandalism will be reverted. Please see: [How does deleting work? …](//meta.stackexchange.com/q/5221). If permitted to delete, there's a "delete" button below the post, on the left, but it's only in browsers, not the mobile app.
Comment: This thread might help. https://stackoverflow.com/questions/1957099/how-do-free-and-malloc-work-in-c. Basically you should `free` the memory you allocate with `malloc` (and variants).
Comment: *"As currently i think i have memory leaks."* - Why?
Answer: Your code has several problems.
if(msg_queues < 0)
        exit(EXIT_FAILURE);

This test is not correct, msg_queues will be NULL if malloc failed for some reason, the test should read.
if(msg_queues == NULL)
        exit(EXIT_FAILURE);

/* Relinquishes all resources currently held by a MsgQs_t.
   The pointer to the MsgQs_t in question is set to NULL. */
MsgQs_t* unloadMsgQs(){
    MsgQs_t *msg_queues;
    msg_queues = NULL;

    return(msg_queues);
}

You allocate a variable on the stack, initialize it to NULL and return NULL from this function.
What you actually want to do is pass a MsqQs_t* to unloadMsgQs and use this pointer as an argument to free, something like this
void unloadMsgQs(MsgQs_t *msg_q) {
    if(msg_q) {
        free(msg_q);
    }
}

If you want to set the msg_q pointer to NULL so that it can't be reused anymore, you should probably do something like.
void unloadMsgQs(MsgQs_t **msg_q) {
    if(msg_q && *msg_q) {
        free(*msg_q);
        *msg_q = NULL;
    }
}

From what I see, my advice would be to read some more books / tutorials on programming with C and pointers in general, because it seems you don't quite grasp the basics yet (which is nothing to be ashamed of of course!)
Answer: You have to call free with the pointer value returned from malloc. For this you have to pass the pointer to unloadMsgQs as an argument.
If this function is supposed to set the pointer to NULL in the caller, you have to pass the address of the pointer.
Note that malloc's return value to indicate an error is NULL not a value < 0.
/* Returns a pointer to MsgQs_t structure and through which multiple message queues can be subsequently created.
   Each individual message queue is to be identified by a unique identifier. */
MsgQs_t* initializeMsgQs(){
    MsgQs_t* msg_queues;
    msg_queues = malloc(sizeof(MsgQs_t));

    if(msg_queues == NULL)
        exit(EXIT_FAILURE);

    return(msg_queues);
}

/* Relinquishes all resources currently held by a MsgQs_t.
   The pointer to the MsgQs_t in question is set to NULL. */
void unloadMsgQs(MsgQs_t **msg_queues){

    if(msg_queues != NULL)
    {
        free(*msg_queues);
        *msg_queues = NULL;
    }
}

/* sample use in main() */
int main(int argc, char **argv)
{
    MsgQs_t* msg_queues;

    msg_queues = initializeMsgQs();
    /* ... */
    unloadMsgQs(&msg_queues);

    return 0;
}

Deleting resources


How do you define this odd chord?

Question: I was experimenting and transcribing chords from different kinds of jazz pieces and I stumbled on a weird-sounding one. It had the notes of [Db - E - G - Bb - B - F - Bb] in this exact order on the keyboard.
I assume without the "natural B note" it would've been a Db°7(add b11). But with that "natural B note" added in there, I'm not sure how to define it. Is there a way to describe such a chord?
Comment: It does sound like some sort of variant of a diminished .seventh chord. I think it's important to note that these notes fit in perfectly to the half-whole octatonic scale. https://en.wikipedia.org/wiki/Octatonic_scale
Comment: I agree, that B natural really sticks out. In the music, is the B natural actually a half step above the lower Bb, or is it an octave and half step above? I'm no jazz-head so to me, a chord with this much going on just passes into the realm of "I have no idea how to analyze it, I just know it sounds cool", and I would also look at it melodically instead of functionally. As in, it fits with other chords in terms of how each of several notes moves to and from the closest notes in the chords before and after it.
Comment: The B natural note was a half step above the lower Bb in this one.
Comment: What are the chords before and after this one? This may shed some light on its function.
Comment: @MartinDrautzburg The chord that came BEFORE that chord was a D°7 (add b13). Then AFTER the chord was a Cmin7. **Edit:** The chord progression went something like this: Eb6 // Ebm6 // D°7 (add b13) // **the odd chord** // Cmin7.
Comment: More than that, can you provide a musical example of the five bars or so around this, including melodic line? It's possible that one of these pitches is an extended non-chord tone. Indeed, Dexter Gordon's famous solo in Watermelon Man has one such non-chord tone--an extended *B-natural* held over a B-flat chord!
Comment: @Eric For instance, the fact that the chord roots move E-flat, D, **odd chord**, C tells me that the chord can likely be considered as a D-flat chord (as you've suggested) on accounting of the chromatically descending bass. But more information will shed some light on the other voices as well.
Comment: @Richard The chord progression was transcribed from the beginning of Art Tatum's piano solo of Moonglow here: [link](https://www.youtube.com/watch?v=1TJ8MT0tBgU) (you'll hear it from 0:05 to 0:08). At first, I don't know whether to just describe it as **Db°7 (add b11 + "add 7th")** or assume he's playing an "off-note" in that chord progression.
Comment: Maybe it is taking two simultaneous routes to get from D to C, namely D->Db->C and D->G->C. Though the Bb is strange. It could just be an anticipation of the 7 of the Cmin7.  Also this doesn't answer the question how to name it.
Answer: From a not very modern point of view, I'd analyze it as a Bb minor and E minor superimposed on top of each other. They are a triton apart and thus generate a sense of movement or tension (it's very dissonant though not bad-sounding.) The justification would be the sound as the chord is resolved. In a more classical analysis, chords need not be Functional (as in marking something using functional harmony) but merely happen as the confluence of various lines (bass, melody, counter melodies, etc.)

How do you define this odd chord?


NUMEROS ALEATÓRIOS EM PHP EXCLUINDO UM NUMERO DA LISTA

Question: Boa tarde, preciso pra um trabalho da escola fazer uma busca de 7 numeros de 1 a 20, excluindo um numero da lista.
Exemplo: 7 Numeros aleatorios de 1 a 20, excluindo o numero 5 da lista. Que me retorne 7 numeros todos diferente de 5.
function random($nNumeros, $nQuant)
{
    $aRand = array();
    for ($i=1; $i<=$nQuant; $i++) {
        $aRand[$i] = $rand = rand(1, 20) ;
        while (count($aRand) < $nNumeros)
            if (!in_array($rand, $aRand))
                $aRand[] = $rand;
            else
                $rand = rand(1, 20);
    }
    return $aRand;
}
echo "
";
print_r(random(7,1)); //1
?>```

Comment: O que exatamente é `$nQuant`? Poderia descrever em texto o que seu código está fazendo?
Answer: Existem várias formas de fazer isso, uma seria construindo um dicionário que ignore os inválidos e outro seria fazendo um loop, descartando os inválidos.

Irei fazer o primeiro, que segue a lógica um pouco contrária do seu código atual. Então, para isso você precisa usar o range para criar o dicionário inicial:
$dicionario = range(1, 20);

Isso criará um array com valores de 1 até 20.

Depois, precisará eliminar os valores inválidos. Então, podemos assumir que o $excluidos é algo como array(1, 2, 3) (ou seja: 1, 2 e 3 não podemo ser escolhidos). Para isso pode usar o array_diff:
$dicionario = array_values(array_diff($dicionario, $excluidos));

O array_values é utilizado para evitar "intervalos" no array.

Então, depois, pode gerar um número de 0 até o máximo que existe no $dicionario, utilizando random_int.

Então, no final terá algo como:
function Gerar(int $Quantidade, int $Maximo, array $Excluidos) : array {

    // Cria o array inicial
    $dicionario = range(1, $Maximo);

    // Exclui os inválidos
    $dicionario = array_values(array_diff($dicionario, $Excluidos));

    $resultado = [];

    // Gera a quantidade de número definidas
    for ($i = 0; $i < $Quantidade; $i++) {

        // Gera um número aletorio de 0 até a quantidade existente no dicionario.
        $id = random_int(0, count($dicionario) - 1);

        // Salva no "resultado"
        $resultado[] = $dicionario[$id];

        // Remove o número gerado da lista, afim de não gerar novamente o mesmo número
        unset($dicionario[$id]);
        $dicionario = array_values($dicionario);

    }

    return $resultado;
}

Que pode ser utilizado como:
// Gerar *7* numeros, de 1 até *20* e excluindo o *5*:
echo implode(",", Gerar(7, 20, [5]));

Resultado:
20,9,19,6,13,18,14

São 7 número de 1 à 20, sem repetição e sem o 5.

Observe que não foi adicionado qualquer verificação na função, então gerar mais do que a quantidade existente ou excluir mais do que possível não retornará erros claros, apenas o Warning do próprio PHP.


Annoying hot humbucker pick harmonics

Question: I have a weird "problem" I recently bought an ESP ltd les paul style guitar with a Duncan JB pickup on bridge. Yesterday while i was practising with my headphones and with full hi gain distortion i noticed that especially on high strings the moment my pick "touchs" the string to make an attack i get a quite loud pick "harmonic" kind of sound. SO loud and melodic that it feels like a note in advance added to my actual notes! Actually thats NOT an annoying sound or noise, its a bright sweet harmonic, but eventually that does not belong to my solo!!
I dont get this on my neck pickup(Duncan 59) and this is less noticable when doing alternate picking on same string, but it becomes quite annoying if thats sweep picking since there is single note on every string and when I am starting an upward sweep from high E, my arpeggio starts with the "harmonic" of my pick touching the string before I make any attack on the string. This is not about my technique cause when I simply and very lightly touch the string with my pick I can still get this harmonic as if I made an artifical harmonic.
Is this a known issue for all hot hummbuckers? some people say bridge pickups are naturally pick lots of harmonics and its normal. I tried changing height of pickups but no luck, something wrong with my guitar, or my digital effect pedals distortion is very crappy(thats 50 dollar Vamp with amp simulation ) ?
Answer: I would just like to point out something that has not been mentioned.
Using a finger from your right hand (and no amplification on the guitar), hammer on to a note on the fretboard. Listen closely, and you will hear two distinct notes ringing out. One is the note you would expect to hear -- the fretted note. The other note is the portion of the string between your finger and the NUT. That is the natural consequence of striking a string: you essentially divide the string into two strings, both vibrating and emitting a sound.
What does this have to do with the issue at hand? When you touch the pick to the string, it is doing the same thing as your finger: dividing the string in two. Eventually the pick completes its stroke and you only hear the fretted note, but in the moment the pick strikes the string, that action causes two separate notes to be created. Most people pick between the bridge and neck pickup, so the portion of the string over the bridge pickup is short and therefore high-pitched. This is the sound you are hearing. Lowering volume, lowering gain, lowering treble, and switching to the neck pickup all serve to reduce the problem, but technically the sound produced by the string is still there. (The neck pickup also has its own note being produced, but it will almost always be lower in pitch, and the harmonics over that pickup aren't as high anyway.)
All that is to say, despite what others have said, this IS a normal phenomenon in the sense that it is a natural result of playing a stringed musical instrument. Reducing it to the point that it is not noticeable is a separate issue. Technique, pick material, pickup construction, etc. may have some role in how much you can hear it, but the sound will always be there on some level.
[Edit] As I've grown more experienced in my guitar usage, I've discovered that oftentimes this issue is related to the pickup height. That is, if your pickups are overly chirpy, lower them (down toward the body and away from the strings --
 your pickups should have a couple of screws that allow you to do this), which will reduce the treble, and so the chirpiness should be reduced along with it. Of course, you probably still want some treble in your tone, so it may take some experimentation to find the correct balance.
Answer: Very strange - I generally find my humbucking pickups deliver a more muted pick sound than the single coils.
The only thing I can think is that you may have the pickups wired out of phase - I have a guitar I use for experimenting with new electronics, and when I ran my bridge humbucker with the coils out of phase I reduced the overall gain a fair bit, but got some accentuated noises from finger slides, pick and knocks.
This should be very easy to check if you can get a look at the wires to the back of the pickup.
Update for clarification
When the coils are in phase, the signal from the pickups is boosted, hum is removed (hence the term humbucker) and you tend to get a fat sound, but with some of the higher harmonics removed when compared to a single coil pickup.
When out of phase, the signals from the coils interfere, and the harmonics which are accentuated are those which have opposite nodes at the two coils, leading to a lot of treble and some high jangly tones.
This picture from Deaf-Eddie.net shows some of the ways the wiring can be connected. The Gibson combination shows coils in series and in-phase. To take them out of phase you would connect the black and white leads together, take the green to ground and the red to the output.

But in any case, check that all connections are secure, soldered well, and that no stray bits of wire are shorting any components.
Comment: The neck pickup certainly picks up more higher frequencies - this is because once you get close to the bridge lower harmonics are pretty much at a minimum. This is why you have neck and bridge pickups, so you can select for the fuller, lower harmonics at the neck or the higher harmonics, more trebly tone at the bridge.
Answer: Sounds like a grounding issue with the JB. Maybe check the wiring?
I've used a JB/59 set almost exclusively on my LP style guitars for over a decade and never had this issue.
Comment: @Spring The Seymour Duncan website [link](http://www.seymourduncan.com/support/wiring-diagrams/) has extensive support documents regarding wiring. It's very simple really. Just check to see the connections match the diagram for your configuration. It will all be more clear once you find the right diagram.
Comment: @Spring Also, this is going to sound weird but, check that the bridge is grounded. There will be a wire from the bridge to something like the tone pot or cable jack. I can't remember exactly. Still, this is a potential source of noise.
Comment: thanks, some folks says bridge pickups are naturally pick more harmonics than neck pickups thats normal, you agree? how can I check the wiring and fix it?
Comment: @Spring - you can't "fix" the bridge pickup getting more harmonics. There are more vibrations from higher harmonics near the bridge than lower ones.
Answer: Looks like its a combination of everything including; Pickup height, Pick material, Pick gauge, angel of the pick..But mostly its about pick.
Comment: What do you mean? What kind of pick were you using? Metal?
Comment: Unbuffed 4.2 milimeter, but as I said its a combination of everything.

Annoying hot humbucker pick harmonics


Saving node with a text format another user doesn't have permission for renders it inaccessible

Question: I have an editor role which has access to an editor Text format.
I have an admin role which uses the Full HTML format.
When the admin edits a node and saves the body (or any other full text field) with their default text format, Full HTML, then the editor gets:
"This field has been disabled because you do not have sufficient permissions to edit it."
How can I allow the editors to simply have permission to edit this locked field with their own editor text format?
Answer: You can't I'm afraid.
Think about it like this: When rendering the text to screen, Drupal has to decide which text format to use to filter it. This means that per field, there must only be one text format, regardless of which users have edited it.
If this wasn't the case, Drupal would have no idea which format to use to render the text. It would have to guess, which is something you don't want a computer doing!
If you want users to be able to edit textarea fields, your admins will simply have to save them in a format that those users have permissions to use. Otherwise the whole point of having different filters available for different roles is kind of lost.
But the main point is that conceptually, if different users edit the same field, with different text formats, then Drupal has no idea which one to use when outputting the field value. This is why you cannot do it.
Comment: Maybe that's an idea for a new contrib module.
Comment: That makes sense, glad to just have a definitive answer. Thanks.
Comment: This problem could be solved if Drupal would simply save the field in the new text format, and forget the old format. E.g. user A saves as "Full HTML", user says "break text format" and saves as "Filtered HTML". Maybe an additional affirmative action would be required, because user B cannot undo this.
Comment: And there could be a permission "break text formats".
Answer: Now 10 years later, there is also https://www.drupal.org/project/allowed_formats, which allows to limit text formats for a field to those, that everybody can use.


Continuity of infimum argument

Question: Suppose $f: [0,1]^2 \mapsto \mathbb R$ is continuous. Let
$$
\underline{y}(x)\equiv \inf \{y\in [0,1]: f(x,y)\geq 0\}.
$$
There is $y_0\in(0,1)$ such that
$$f(0,y_0)= 0,$$
$$f(0,y)< 0 \quad \forall y\neq y_0.$$
Moreover,
$$
f(x,y_0) > 0 \quad \forall x\in (0,1].
$$
I hope to find out: is it true that $\underline{y}(x)$ is continuous at $x=0$?
If not, what extra conditions may imply this?
Thank you.

I am tempted to answer yes, and I imagine a proof may work along this line:
By the definition of $\underline{y}(x)$, as long as $\underline{y}(x)\in(0,1)$,
$$
f(x,\underline{y}(x))=0.
$$
Then I want to use some version of the Implicit Function Theorem to argue the continuity of $\underline{y}(x)$.
Two difficulties I encounter are:

How to argue $y(x)\in (0,1)$ for $x$ in a neighbourhood of $0$?
To use the Implicit Function Theorem (without differentiability) to argue the continuity of $\underline{y}(x)$ at $x=0$, it seems I need $f(x,\cdot)$ to be a one-to-one mapping for $(x,y)$ in a neighbourhood of $(0,y_0)$, which I do not have.
Answer: The key idea is to use the compactness of the domain $[0,1]^2$ (which is necessary for the claim to work). From what you stated, we have $\underline{y}(0)=y_0$ and $\underline{y}(x) < y_0$ for $x \in (0,1]$.
What we will show is that, given some $\epsilon > 0$, there is a $\delta > 0$ such that
$$f(x,y) < 0\; \forall x \in [0,\delta], \forall y \in [0, y_0-\epsilon]. \label{eq1} \tag{1}$$
This means $\forall x \in [0,\delta]: \underline{y}(x) \ge y_0 - \epsilon$ and with the above $\underline{y}(x) < y_0$ for $x \in (0,1]$ that means $\underline{y}(x)$ is continuous at $x=0$.
So let's fix some $\epsilon > 0$ now. We know that $f(0,y) < 0$ for $y \in [0,y_0-\epsilon]$. Since $y$ varies over a compact interval and $f(0,y)$ is continuous, it takes a maximum value $M < 0$ there. So we actually have $f(0,y) \le M < 0\; \forall y \in [0,y_0-\epsilon]$.
Since $f(x,y)$ is continuous, for each $y \in [0,y_0-\epsilon]$ we can find a small $\delta_y > 0$ such that in the rectangular neighborhood $[0, \delta_y] \times [y-\delta_y, y +\delta_y]$ of $(0,y)$ we still have $f(x,y) < 0$.
That's a $\delta_y$ for each $y \in [0,y_0-\epsilon]$, so uncountably many and the infimum of the $\delta_y$ is likely $0$. But note that the set of open intervals $(y-\delta_y, y +\delta_y)$ completely covers the compact interval $[0,y_0-\epsilon]$ (because each number in the latter is the center point of a former one).
By using compactness, we know we can pick a finite set of those intervals, centered around $y_1,y_2,\ldots,y_n$ that still covers the complete interval $[0,y_0-\epsilon]$, with corresponding $\delta_{y_1},\ldots,\delta_{y_n}$.
Now we can choose our $\delta$ from \eqref{eq1} as
$$\delta = \min\{\delta_{y_1},\ldots,\delta_{y_n}\} > 0.$$
As a minimum of a finite number of positve values it is also positive! To check that \eqref{eq1} holds, lets select any $x \in [0,\delta], y \in [0, y_0-\epsilon]$. Then $y$ lies in one of the above constructed intervals, say the one centered around $y_k$. By construction, we know that for any $(a,b)$ inside $[0, \delta_{y_k}] \times [y_k-\delta_{y_k}, y_k +\delta_{y_k}]$ we have $f(a,b) < 0$.
We know that $y \in [y_k-\delta_{y_k}, y_k +\delta_{y_k}]$, because we chose $k$ such that this is true. $x \in [0,\delta]$ implies $0 \le x \le \delta \le \delta_k$ (by definition of $\delta$), hence $x \in [0, \delta_k]$. That means we have $(x,y) \in [0, \delta_{y_k}] \times [y_k-\delta_{y_k}, y_k +\delta_{y_k}]$ and so $f(x,y) < 0$, which is \eqref{eq1}.
This concludes the proof.
To summarize, "a little bit below" the point $y_0$ starts a compact interval  with all negative $f(0,y)$ values. Since the interval is compact and $f$ continuous, $f(0,y)$ cannot get "arbitrarily close" to $0$ there, so there is a "gap to 0". Again due to contuinuity of $f$, that "gap" can be extended a little bit into $x \in [0, \delta_y]$. Due to compactness of $[0, y_0-\epsilon]$, there is a finite list of intervals covering the whole $[0, y_0-\epsilon]$, and we can finally extend the "gap to 0" towards all $x$ in a small neighborhood of $0$, namely $[0,\delta]$, where the $\delta$ is now independent of $y$.

Continuity of infimum argument