Going "backwards" in my guitar practice

Question: I used to be a good player, as a self-taught alternative musician. Then I saw a lot of youtube videos and realised I was doing everything "wrong", from a technical point of view. I never learned any theory, I never used my fourth finger, I never learned alternate picking.
So I tried to learn "properly". And now I can't even play in my old style. I would like to rehabilitate my old punk-rock technique, are there any good ways to do this?
Not sure how to word this. It's more of a statement than a question, I suppose. Perhaps if I learned some piano it would help with the theory?
Comment: You have at least a couple questions here leaving us unsure which to answer. I'd suggest editing your question to make it more specific. For instance maybe just focus on the technique aspect and going "backwards" when changing up your technique because I think that's actually a very good question. As for theory, maybe search through some previous questions first because it's a [common topic](https://music.stackexchange.com/questions/tagged/theory+guitar) here. If you're still unsure after that, then maybe start a new question adding more details about what specific theory issues you're having.
Answer:
I was doing everything "wrong", from a technical point of view. I never learned any theory, I never used my fourth finger, I never learned alternate picking... Perhaps if I learned some piano it would help with the theory?

OK - first off: You seem to be conflating the study of theory with the study of technique, which we generally call method.  They are too different disciplines.  Method means the mechanics of how to play an instrument, and each instrument has its own method for mastering it. Theory is not really specific to any instrument at all, and you don't even have to be a musician to know musical theory: Theory means the guidelines and vocabulary we use to describe our music in the abstract: Chords, scales, keys, intervals, etc. etc.
Great theoreticians don't have to be great musicians, and great technicians - masters of technique on an instrument - don't have to be great theoreticians, although each area of expertise certainly compliments the other.
I never used my fourth finger, I never learned alternate picking. These are not questions of theory, but of method.
So again:

Perhaps if I learned some piano it would help with the theory?

As far as the study of theory goes, piano is essential. Every serious musician should know at least basic piano, to facilitate the study of theory. The visual nature and the keyboard layout of the piano make it ideal for studying theory, however studying piano will not help much when it comes to using your fourth finger on the guitar.
Today, basic theory is arguably mandatory for any musician with aspirations of advancing beyond the level of a stay-at-home hobbiest.
The question of theory stifling creatity has been bandied about endlessly by untrained musicians, and comes up on this site from time to time. Here's recent question dealing with it:
can music theory sabotage creativity

Having said that, your question actually seems to focus more on method/guitar technique than on theory, so let's address that:
Making music is about expressing yourself. Formal technique methodologies are tools to help musicians express themselves - they are not iron-clad rules.
Similar to musical theory, no matter how many youtube videos and books and teachers preach their methodologies, there is no absolute "right" or "wrong" when it comes to technique. The issue is simply what techniques - which method - help you to express yourself on your instrument in the most fluent way possible.
Formal methodologies for various instruments - such as using the fourth finger - were developed as knowledge accumulated about what allowed musicians to create better, more expressive music more efficiently and adroitly. Nobody handed down any divinely inspired laws about how to play music.
In addition, not everyone's body/hands are the same. There may be certain recommended techniques in books that are very difficult for some people to execute. Would it be worth it to spend years trying to perfect such a technique when doing so precludes you from expressing yourself and enjoying music the way you would like to? In the vast majority of cases, the answer is a resounding No.

It is true that if you are just starting out, learning the accepted rules of formal technique is a good idea - one learns things that help you play more efficiently and effectively and can be leveraged as you develop into a mature musician. But invariably, even those with a lots of formal training in technique will develop their own approach to technique (although it will incorporate much of their formal training) as they mature: the approach that best suits them for expressing themselves with their music.
There have been many good, even great musicians, who, just as they knew little or nothing about formal musical theory, also knew little or nothing about proper technique. They were self taught and figured out how to play the way they needed to in order to express themselves through their music. People like Jimi Hendrix, Wes Montgomery, Paul McCartney... the list goes on and on...
He did not learn this in music school:

Thelonious Monk did take formal piano lessons as youngster, but discarded virtually everything he learned as he developed his own extraordinarily unique style that required something else entirely:
Monk:

Nonetheless, they were great musicians because regardless of their technique, they were able to express themselves in eloquent, unique and appealing ways through their music, which is what ultimately makes for a great musician.

Bottom Line:
You are in a situation where putting aside what you did before and trying to learn formal technique is preventing you from expressing yourself musically the way you want to. In your case, formal technique is not serving its proper role. So: IMO forget about formal technique and play in the way that facilitates your own ability to express yourself musically - the goal of every musician worthy of the title. Go and play your old punk-rock technique for all its worth - enjoy yourself and let it all hang out.
BUT: That does not mean that you should ignore and forget what you've learned about formal technique. Continue to pursue that study - "book learning" never hurt any musician, when it's applied properly. They key is not to force yourself to incorporate it into your personal playing style. It should work organically: Don't change your musical identity because of what it says in a book.
What will happen over time is this: As you are doing your thing, certain aspects of what you've learned about formal technique will find their way into your personal style, in ways that will help you. You will integrate them into your style because once you know them, you'll find ways to use them to help you play your own music.
Comment: I generally try to describe theory as not a set of rules but an explanation for why things sound good and a language used to describe it, only really being rules if you are trying to emulate a specific style or genre.  I mostly do this to prevent people from developing the thought process that theory can detract from creativity.
Comment: @Basstickler - I changed _rule_ to "guidelines".
Comment: Yeah, your description was perfect, with my only criticism being the use of the word rule.
Comment: @Basstickler - no argument. I said : _to describe music in the abstract_ meaning that music dictates theory, not vice-versa.  I'm going to eliminate the term rule and subsitute _vocabulary_.  One the esteemed member around here Laurence Payne, likes to say _Theory describes, it does not command_.
Answer: "Then I saw a lot of youtube videos and realised I was doing everything "wrong", from a technical point of view. I never learned any theory, I never used my fourth finger, I never learned alternate picking."
It's easy to become overwhelmed with information when so much content is readily available. I have to keep a balance between challenging my skill/knowledge/etc. and actually enjoying playing. You may find that that you are doing less "wrong" and more so "what works" for you. I went back to using my thumb to fret the F# on the low E when making D/F#, lol. Keep playing!
Answer: Okay, let's address all of this in sections because you have a few things going on.
#1 - Are you sure you've gotten worse?
When I taught guitar lessons, I would occasionally hear this from students. 99% of the time this statement was false. I also insisted that students record the audio from their playing. Why? Because as you listen to it over time, you can hear the improvements. Do you have recordings from the past? If so, can you hear an actual decline in playing?
#2 - "Then I saw a lot of YouTube videos and realised I was doing everything "wrong", from a technical point of view. I never learned any theory, I never used my fourth finger, I never learned alternate picking."
You have to define what is "wrong" about your playing technique. You mention alternative picking - there are three main picking styles (alternative, economy and hybrid). None of them are "wrong" and only using one of them is just fine.
Django (the godfather of Gypsy Jazz) mostly used downstrokes when playing. There isn't even a name for that style, it's just what he did.
Wes Montgomery (the godfather of jazz guitar) used only his thumb to play strings - for everything. Again, not a named or official playing style.
I know plenty of guitar players that don't use their 4th finger. It's just their style and they've done things (without knowing) to compensate. There is a different sound between fretting with your ring finger and your pinky.
Theory is separate from technique. I have a music degree and took everything I learned from class on theory and applied it to the guitar. The piano is the easiest instrument to see theory on, but guitar is a darn close 2nd. If you want to learn more theory, buy the Hal Leonard Guitar Theory book - it's awesome.
#3 - The Problem With YouTube
If you want to learn things here and there, YouTube is fine. If you want to have an actual taught course (that's well thought out) go with some online lessons like at Udemy, TrueFire, etc. YouTube is scattered, not structured and can cause problems for those reasons.
#4 - "So I tried to learn "properly". And now I can't even play in my old style."
Just like you need to define what was "wrong" with your playing, you need to define what "properly" is. Without knowing that, we can't help you.
Comment: Django Reinhardt had also lost the use of his ring and pinky fingers of his left hand. That affected his guitar playing, no doubt.

Going "backwards" in my guitar practice


VMware Converter MAC Adress

Question: I want to convert a running machine to VMware ESXi with VMware Converter, but it assigns a random MAC address to destination virtual machine. However, in our network, port security and static arp tables are used, so there is no chance for assigning an IP address to an unknown MAC.
Is there a way of defining the MAC address of the destination virtual machine?
Thanks.
Answer: Yes, in the VM's settings under each Ethernet adapter's settings menu.

VMware Converter MAC Adress


Sending parameter with POST requests ,when content-type is multipart/form-data

Question: I am new to JMeter. I am trying to create a test plan ,one of the requests is a POST request containing some parameter, the content type in the request header is  Multipart/Form-data.
I am copying the headers/parameters from fiddler because the HTTP proxy recorder is not working.
Please see the image for the current settings I have.I am not able to get the required response using it.
Answer: As per HTTP Request Sampler Documentation

Use multipart/form-data for HTTP POST
Use a multipart/form-data or application/x-www-form-urlencoded post request

So all you need to do is:

Tick "Use multipart/form-data for POST" box
Remove all `Content-Disposition" lines

In regards to "proxy recorder not working", I have never experienced any problems with it so it might be misconfiguration or something like this. Some people find JMeter Chrome Extension easier to use.
Comment: Hi , I removed all content disposition lines from the parameter list . But stillwhen I see it in the result tree ,there is just one single row called form ,the value for which is buy-now
--mJ4HlsETQ6hR_VBYfkXo-xnY5nZAgA
Content-Disposition: form-data; name="prod_id"
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
and it continues like this for other fields,but they are all in the same row
Answer: Instead of copying the content-disposition etc, just send the parameters with name and you should be good. You are expected to send form data and it's value.
ideally it should look like, name should be just 'form' and it's value as 'buy-now'.
I would suggest you compare the requests that you are sending using developer tools and the request you are sending using JMeter, it will help you debug this quicker.
I hope it helps.
Comment: It didnt work,in the result tree ,all the parameter are coming in one line instead of a tabular format [the way they come without multipart on]


In mySQL how does AddwithValue() handle variable types width C#

Question: I wonder how does AddwithValue() in mySQL
Handles variables, width commands like INSERT, should i put in text valeus matching exactly a value kind in mysql.
To input a number in a table:
should i use myvalue="123.33"
or
myvalue = (double)123.33333333
myvaleu = (decimal)123.333
string connString = ConfigurationManager.ConnectionStrings["default"].ConnectionString;
MySqlConnection conn = new MySqlConnection(connString);
conn.Open();
MySqlCommand comm = conn.CreateCommand();
comm.CommandText = "INSERT INTO temperature(sample1,sample2) VALUES(@sample1, @sample2)";
comm.Parameters.Add("@sample1", "123.33");
double sample2 = 123.0 + 1/3;
comm.Parameters.Add("@sample2", sample2);   //is that ok?
comm.ExecuteNonQuery();
conn.Close();

I'm wondering this because, often its configured in mySQL how many decimals a variable has.
Currentl my C# application reads:
Doubles
Decimals
Dates (full date+time)
Comment: adjusted question, indeed it wasnt that clear
Answer: You shouldn't use AddWithValue. See Can we stop to use AddWithValue already.
While it has the advantage of the simplicity you couldn't trust it with precision because everything is inferred for you by your database engine that need to convert the received values to the expected structure of your database fields. (And I don't even start with the pitfalls caused by dates values passed as strings)
Even passing strings for text fields is not a good choiche because the parameter will have the same size of your string and this could interfere with the optimization technique employed by the database to parse your command
For example, this article on MSDN, while focused on Sql Server, contains a lot of informations about the adverse effects that AddWithValue could cause to your database engine.
So just use the Add method like this. (Still one code line)
cmd.Parameters.Add("@myParam", MySqlDbType.VarChar, 100, "myTextField").Value = "Test";

Comment: if i type it like that, i get a warning that its deprecated and that i should use AddWithValue. I red the article though but i'm  using quite common regular variable types, not custom types. So I should be fine width AddWithValue's. Maybe its because i'm using the current version of mySql and its connector.
Comment: No, you are reading [this overload of Add](https://msdn.microsoft.com/en-us/library/9dd8zze1(v=vs.110).aspx). The Add that takes only the parameter name and an object for the value is deprecated. And the reason is because when you pass an object there is a possible conflict with the overload that takes a DbType instead. There is no deprecation on the method explained above
Comment: not feeling so sure about this, i'd supose that database engines would implement this properly (or get fixed); as long as i dont put in types the connector isnt awaware off i shouldnt violate Addwidth value. As the types in use are pretty common ea Double Int long Decimal.


Save RAM when using dante proxy

Question: I have a small server that I run dante socks proxy on to route torrent traffic through it.
Now the problem is, that for each connection dante seems to create a new program/thread and it uses nearly my whole 256MB of RAM.
Is there any way to make the memory footprint smaller?
Thank you
Comment: Welcome to ServerFault, this Q&A site is intended for System Admins who work in a professional setting.  Your question seems to indicate a setup not used in a professional setting, therefore it is off-topic.  Please read the FAQ before posting again.
Answer: why don't you try openvpn instead.
Comment: @rnxrx - it's a tool. openvpn comes with excellent how to. use case varies, i think it would be pointless to provide sample configuration not knowing detailed needs of the author of the original question. would you copy&paste Apache documentation if someone was asking how to host few static files on a home server?
Comment: While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference.  Link-only answers can become invalid if the linked page changes.

Save RAM when using dante proxy


If I want to delete some ascending files in a folder while leaving others in ansible, what would that look like?

Question: The example is you have a folder with files numbered files_0.jpg to files_10.jpg in a folder /tmp/folder.
I'm trying to figure out how to delete files_0.jpg to files_4.jpg while leaving files files_5.jpg to files_10.jpg.
For extra points, same scenario, but, I want to delete files_0.jpg to files_4.jpg and files_8.jpg to files_10.jpg leaving files_5.jpg, files_6.jpg and files_7.jpg.
I'm trying to figure out how to do this in Ansible and I am stuck at trying to use a regex.
Answer: Use the range() function in order to loop over the file sequence you want to delete.
To delete files_{0..4}.jpg:
- file:
    state: absent
    path: "/tmp/folder/file_{{ item }}.jpg"
  loop: "{{ range(0, 5) }}"

To delete files_{0..4}.jpg and files_{8..10}.jpg:
- file:
    state: absent
    path: "/tmp/folder/file_{{ item }}.jpg"
  loop: "{{ range(0, 5) | list + range(8, 11) | list  }}"

Given the playbook:
- hosts: localhost
  gather_facts: no

  tasks:
    - file:
        state: absent
        path: "/tmp/folder/file_{{ item }}.jpg"
      loop: "{{ range(0, 5) | list + range(8, 11) | list }}"

This would yield:
TASK [file] *******************************************************************
changed: [localhost] => (item=0)
changed: [localhost] => (item=1)
changed: [localhost] => (item=2)
changed: [localhost] => (item=3)
changed: [localhost] => (item=4)
changed: [localhost] => (item=8)
changed: [localhost] => (item=9)
changed: [localhost] => (item=10)


Return string within a string based on expression 'x={(.*)}'

Question: I have a string that can vary but will always contain x={stuffNeeded}.
For example: n=1,x={y,z,w},erore={3,4,5} or x={y,z,w} or erore={3,4,5},x={y,z,w} etc.
I am having a devil of a time figuring out how to get y,z,w. The closest I got to finding the answer was based off of Yatharth's answer on this other post Regular expression to return all characters between two special characters.
It my searching I've so far come across something that almost worked. Testing was done here http://rubular.com/r/bgixv2J6yF and in python.
This was tested in python using:
i='n=1,x={y,z,w},erore={3,4,5}'
j='n=1,x={y,z,w}'
print re.search('x={(.*)}',i).group(1)
print re.search('x={(.*)}',j).group(1)
print re.search('x={(.*)}.',i).group(1)
print re.search('x={(.*)}.',j).group(1)

Result for the four different print:
'y,z,w'
'y,z,w},erore={3,4,5'
AttributeError: 'NoneType' object has no attribute 'group'
'y,z,w'

Needed result is 'y,z,w' for all cases and then if x={*} really isn't found I would put an error catch.
Thank you in advance.
Comment: is `x={yz,w}` a typo?
Comment: Upvoted for the phrase "a devil of a time" :D
Comment: @Ev.Kounis: it sure was a typo. Thanks
Answer: This regex does what you're trying to do :
regex = r'x={([^\}]*)}'

Live demo here
Explanation

{([^\}]*) : look for an opening bracket, then look for (and capture) any number of non } characters. So, your group 1 will contain the captured values for x.
}: look for a closing bracket
Answer: The main problem is that {(.*)} matches the longest string starting by { and ending by }, which in some cases is y,z,w},erore={3,4,5
You could use non-greedy matching by adding ?. You don't need any other case.
import re

i='n=1,x={y,z,w},erore={3,4,5}'
j='n=1,x={y,z,w}'
expr = 'x={(.*?)}'
print (re.search(expr,i).group(1))
print (re.search(expr,j).group(1))

result:
y,z,w
y,z,w

Answer: Using re.findall :
>>> import re
>>> re.findall('x={[^\}]*}', s)

#driver values :
IN : s = 'n=1,x={y,z,w},erore={3,4,5}'
OUT : ['x={y,z,w}']

IN : s = 'n=1,x={y,z,w}'
OUT : ['x={y,z,w}']

IN : s = 'x={y,z,w}'
OUT : ['x={y,z,w}']

Now to get the value of x, y, z , use split and strip :
>>> l = re.findall('x={[^\}]*}', s)

#if `l` is not empty
>>> out = l[0]
=> 'x={y,z,w}'

>>> y, z, x = out.strip('x={}').split(',')
>>> y, z, x
=> ('y', 'z', 'w')

Answer: You can try this:
import re
s = 'n=1,x={y,z,w},erore={3,4,5}'
final_data = re.findall('=\{(.*?)\}', s)

Output:
['y,z,w', '3,4,5']


Rotman's Homological Algebra Text, Def of Adjoint Functors

Question: I've been going thru Rotman's text Homological Algebra and one detail of his proof bothers me.  The proof is

The thing that bothers me is that in his definition of adjoint pair before this

the downward maps are only assumed to be a bijection of Hom-set, but he claims that it is an isomorphism in the proof??  Did he mean to say that the map is an isomorphism, not just bijection, in the definition of adjoint pair instead?
Thank you all.
Comment: One can say that it is implicit, but it actually follows from the adjunction !
Comment: Functors between categories of modules are implicitly considered as enriched functors; in particular, each $F_{AB} : [A,B]\to [FA,FB]$ is a group homomorphism (in this particular case, functors also preserve direct sums). If such $F_{AB}$ is bijective, it is an isomorphism.
Comment: I see it that way, maybe it's too simplistic but it never failed me: in the same way a function between abelian groups is of little interest if it is not a homomorphism, a functor between Ab-enriched categories is of little interest if it is not enriched. :)
Comment: Sorry it took me so long, but I had a busy couple of months. I wrote an answer now, hope it helps !
Comment: @Fosco Thank you for the reply, I just want to verify so what you are saying is that when we are working in the category of modules, his map $\tau$ in the definition of adjoint pair are implicitly assumed to be group homo, is that correct??
Comment: @Max Thank you for the reply, Max.  Do you mind showing me how $\tau$ is a group homo from the definition above since I tried to show it before and I get stuck? I don't know what I'm missing,  thank you so much
Comment: It's not trivial, it follows from the fact that addition on $\hom(A,B)$ can be defined categorically : it coincides with $\hom(A,B)\times \hom(A,B) \to \hom(A\oplus A, B) \to \hom(A,B)$, where the first arrow is the isomorphism that follows from the universal property of $\oplus$, and the second arrow is induced by $A\to A\oplus A$ defined by $id_A$ on both coordinates. From this you can show that $\tau$ is a morphism. Do you want me to write that as an answer ?
Comment: @Max yeah, if you don't mind.  Thank you!
Answer: In the category of modules over a ring $R$ (in fact, in an abelian category in general), addition in $\hom(A,B)$ can be defined as follows :
$\hom(A,B)\times \hom(A,B)\to \hom(A\oplus A, B) \to \hom(A,B)$
where the first map is obtained by the universal property of the direct sum, and the second map is obtained by the diagonal $A\to A\times A = A\oplus A$ (this can be alternatively described as the sum of the two inclusions $A\to A\oplus A$).
In $_R\mathfrak M$ you can check that by hand, and in an abelian category you can simply use the alternative description and the bilinearity of composition; but you have to check that the two descriptions I gave actually coincide.
The main point being that this description of addition in $\hom(A,B)$ is "categorical". In fact this suffices to check that $\hom(F(A),B)\to \hom(A,G(B))$ is a group morphism whenever $F\dashv G$ is an adunction.
Indeed we want to check that
$\require{AMScd}\begin{CD} \hom(F(A),B)\times \hom(F(A),B) @>>> \hom(A,G(B))\times \hom(A,G(B)) \\
@VVV @VVV \\
\hom(F(A),B) @>>> \hom(A,G(B))\end{CD}$
commutes, so we decompose it as follows
$\require{AMScd}\begin{CD} \hom(F(A),B)\times \hom(F(A),B) @>>> \hom(A,G(B))\times \hom(A,G(B)) \\
@VVV @VVV \\
\hom(F(A)\oplus F(A), B) @>>> \hom(A\oplus A, G(B)) \\
@VVV @VVV \\
\hom(F(A),B) @>>> \hom(A,G(B))\end{CD}$
and we treat both squares independently :

note that in the top squares, since the vertical arrows are obtained by universal properties, they are isomorphisms, so we may turn them around and check the new commutativity :

$\require{AMScd}\begin{CD} \hom(F(A),B)\times \hom(F(A),B) @>>> \hom(A,G(B))\times \hom(A,G(B)) \\
@AAA @AAA \\
\hom(F(A)\oplus F(A), B) @>>> \hom(A\oplus A, G(B))\end{CD}$
now we want to check that two maps into a product are the same, so we can treat each coordinate separately :
$\require{AMScd}\begin{CD} \hom(F(A),B) @>>>  \hom(A,G(B)) \\
@AAA @AAA \\
\hom(F(A)\oplus F(A), B) @>>> \hom(A\oplus A, G(B))\end{CD}$
Now note that $F$ commutes with direct sums, which means we can choose $F(A\oplus A)$ as a model for $F(A)\oplus F(A)$, with the inclusions $F(A)\to F(A\oplus A)$ being given by $F$ of the inclusions $A\to A\oplus A$. It follows that for the top square we only need to show that
$\require{AMScd}\begin{CD} \hom(F(A),B) @>>>  \hom(A,G(B)) \\
@AAA @AAA \\
\hom(F(A\oplus A), B) @>>> \hom(A\oplus A, G(B))\end{CD}$
commutes. But now this is true because the adjunction isomorphism $\hom(F(X),Y)\cong \hom(X,G(Y))$ is natural in $X$, and this square is nothing but a naturality square.
So the top square commutes.

The bottom square is treated in exactly the same way : consider $F(A\oplus A)$ as a model for $F(A)\oplus F(A)$, and prove that the diagonal $F(A)\to F(A\oplus A)$ is just $F$ of the diagonal $A\to A\oplus A$ (this follows from the fact that $F$ preserves finite products, because they are just finite coproducts in $_R\mathfrak{M}$)

So both squares commute, so the whole outer rectangle commutes, and this is precisely the definition of being a group morphism


Composing a song in Cm with major chord substitutes

Question: I am composing a song in Cm with a very basic chord progression of I-IV-I. So, normally, in Cm, that would be Cm7-Fm7-Cm7, but I am actually playing Cm7-F7-Cm7.
First of all, why does this work? This mix & match of Major and Minor chords in a minor key. Secondly, the obvious transition from IV is to V (G7), and it's ok...but what other transitions could I go for? Maybe modulation to another key?
Comment: Can you give us the set of notes you're playing for both chords? My first suspicion is that you're not quite playing what you think.
Answer: Firstly, you do not need to stay in a key for a chord sequence to 'work'. There is only one real rule in music and that is "If it sounds good, it is good." Many composers do not think in roman numerals, or about keys and come up with great music as a result.
However, this is not to say that you shouldn't. If thinking in keys works for you, then great. Just don't let it stifle what you do. I have no idea what you listen to, so it's hard to give a reference of a song that breaks the 'rules' and is still great but I'll go with Creep by Radiohead as an easy example. The sequence actually goes from a Bmaj to Bmin. Obviously these chords are not in the same key but it still works in the context they play it in. It's all about context.
I should also add if you do want to think of this sequence in terms of keys, you could say that the song is not in fact in Cm at all. It all depends on the "implied harmony" of the piece, which is to do with everything else that is going on, including rhythm, but I would say the piece is probably either in Bb Major (making Cm a II and F7 a V), or possibly Bb's relative minor, D Minor (making Cm a VII and F7 a III).
Hope this helps.
Comment: slight correction - the relative minor to `Bb` is `Gm`, not `Dm`.
Comment: Woops, slightly silly moment there! Yup, the sequence would be a IV - VII - IV if it's in Gm.
Answer: F7 Cm7 forms a weak cadence similar to that of F7 CM7: its guide tones resolve from a tritone to a perfect fourth and its root movement is a perfect fourth.
Depending on other factors, this song is likely to end up in Bb Major (where Cm7 and F7 form the II and V) or C Dorian (the related mode, somewhat less likely given the resolving tendencies of F7). Chords from these or related keys such as G Minor (relative minor) or Bb Minor (parallel minor) might be borrowed to good effect.
Answer: In the key of C minor, the chord built on the fourth degree would typically be an F minor chord.  In the key of C major the chord built on the fourth scale degree would typically be F major.  If one uses the F major chord in the key of C minor, this could be considered a "borrowed chord."  Borrowed chords are taken from related keys and used in the tonic key (related keys to C minor would be C major, the parallel major; F minor, the subdominant; G major or minor, the dominant key; etc.)
Another solution for "why this works" is the potential use of a melodic minor scale.  The melodic minor scale, going up, raise both the 6th and 7th scale degrees by half step (descending these scale degrees are played as in a natural minor scale).  With these raised pitches, F and G would be major.
As far as the latter part of your question is concerned, there are almost limitless answers.  If you are interested in different types of chords and progressions, I would suggest buying a music theory guide (I use Peter Spencer's Practice of Harmony).
Answer: That's a pretty common vamp. It's a Dorian "progression" or vamp, since what you've implied is static.  |Cmin7 | F7 | is a kind of IImin/V7 vamp.  In Dorian the IImin of Ionian becomes the "new" I chord
Dorian chords:

Imin7.......Cmin7
IImin7......Dmin7
bIIImaj7....EbMaj7
IV7.........F7
Vmin7.......Gmin7
bVImin7b5...Amin7b5
bVIImaj7....Bbmaj7

===================================
Also though, you are playing in a minor key, and in that case you still use V7 of the I chord, ie,--> G7.  Not the Vmin7 chord as written above.  Also, in minor key the IImin7b5 is often used as a II chord,
Nice little progression:
||:Cmin7 |F7  |Cmin7 |G7(#9)|
|Cmin7 |F7  |Cmin7 |Dmin7b5 / G7(b13) / |
|Cmin7-Eb7(9)-Abmaj7-G7(b13) :||


How is standard error calculated

Question:
The formulae doesn't pass the common sense test. If the sample size n is as large as population size N, then obviously standard error would be zero, as every sample mean would equal exactly the population mean. (Assuming my understanding of standard error is correct: it is the standard deviation of the distribution of the sample mean)But the formula quoted above  obviously does not equal 0 when sample size equals population size.
I would really appreciate if some one can help a poor guy who is trying to teach himself statistics with no one to turn to for help!
Comment: You need to consider that a finite population, completely sampled, is not the same as an infinite population.
Answer: Your formula is true only for infinite populations. For finite populations, there exist correction factors that tend to 0 if $n$ approaches $N$, see e.g. Wikipedia.

How is standard error calculated


Remove string with regexp leaving only ones with img tag inside - PHP

Question: I have a string that contains content previously formatted by WP and it contains few types of [caption] tags. Examples:

[caption (attributes here)]some text[/caption]
[caption (attributes here)]©name and surname[/caption]
[caption id="attachment_49532" align="aligncenter" width="530"][/caption]

I need to remove only the ones that contain © followed by the name of the person.
I tried:
preg_replace("/\[caption(.*?)\]©(.*?)\[\/caption\]/","",$string);

but it does the job only if as input string I have only one [caption] tag like
$string = "[caption (parameters here)]©name and surname[/caption]";

and not the string with more elements inside.
What am I doing wrong?
Comment: Can you provide an example of `the string with more elements inside`? Do you mean `[caption (attributes here)][bold]test[/bold]©name and surname[/caption]`?
Comment: http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454
Comment: There is regex for you https://www.regex101.com/r/oJ5nX6/1
Comment: What if `]©` is in one of the attribute values?
Answer: Enable DOTALL modifier, so that it would make dot in your regex to match also the line breaks.
preg_replace('/\[caption\b.*?\]©.*?\[\/caption\]/su',"",$string);


Can I call a python function from a Node.js Google cloud function

Question: I'd like to call a python function from within a Google cloud function like so:
<code>  `shell.exec(`${PYTHON_FUNCTION} parameters`, function(code, stdout, stderr) {`
</code>
Is this possible? And if so how would I do it?
Thank you very much
Comment: Cloud Functions run in a container and not directly within the host Ubuntu operating system. Functions are isolated. The node.js environment does not include Python.
Comment: 1) What research have you done? Did you try your example? What was the result? 2) Cloud Functions is a lightweight serverless platform for event-driven code. It is not an operating system and does not provide most features of an OS. 3) The function `shell.exec` would require the Python program, libraries, and environment to run a Python function. The Cloud Functions node.js environment does not include Python.
Comment: Thanks for your reply. From my research, the function runs on ubuntu-18-04 which does have Python installed so I was thinking I can call Python from the function. Basically, I think I'm missing the correct location of the Python binary.
Comment: Thanks, I guess that isn't going to work then :(
Comment: @JohnHanley your comment is very helpful. Please post it as an answer.
Answer: Cloud Functions code runs inside a container that is set up for specific environments. For example, in your question, you are using the Node.js execution environment.
Your goal is to call a Python function (script) from Node.js. This would require the Python interpreter, libraries, and a correctly set up environment.
The Cloud Functions Node.js execution environment does not include the Python execution environment. Therefore the answer is not possible using Google provided execution environments.
If you would like to combine Node.js and Python, I recommend creating a custom Cloud Run container and deploying to Cloud Run, which is the big brother to Cloud Functions.


Given a file directory, any short cut to open the file in IntelliJ?

Question: If you're given a full path to a file, say "blah/yadayada/file1.java", does IntelliJ offer any keyboard shortcut to open that file directly in the IDE?
Comment: https://www.jetbrains.com/help/idea/2017.1/navigating-to-class-file-or-symbol-by-name.html
Answer: IFAIK The closest you get cut and pasting the full path in IntelliJ and searching for a type (class/interface/enum) replacing / by . or searching for a resource file.


Is there a term for this compositional technique?

Question: There are many examples of a particular compositional technique, so I was wondering if it had a name. The example closest to me right now is Beethoven piano sonatina in F, 2nd movement (Anhang 5), starting around measure 27.  We see a chromatic scale that leads perfectly into the intro theme.  I love when I see it - a seemingly unrelated musical idea that just so naturally leads back to something we've heard before. Is it just good composition or is there a term for it?
Comment: Well, such moments in musical pieces are in general called _transisions_, or in this case also possibly _tensions_ -- the musical density (fast notes, solo, chromatics) builds a tension in the listeners, you know that _something has to happen here and now_. There are many tricks/technics how to achieve this. Is this what you are looking for?
Comment: Perhaps. I was particularly focused on how smoothly the transition lead into the main theme without at first seeming like it was going to.
Answer: If anyone is curious, here's the section OP mentions:

I can't think of any name for this particular technique, other than "chromatic scale that fills in the four-measure phrase and leads back to the theme," but that doesn't roll off the tongue all that well.
There is a branch of music theory called Sonata Theory, and one of their big points is the role of particular types of punctuations in the sonata form. One of these is called the Medial Caesura, and affiliated with that concept is the notion of the "caesura fill," where some musical element "fills" in what would otherwise be a complete rest in the music. So although the section you mention isn't a Medial Caesura, we do nevertheless see a punctuation and rest in the left hand starting in m. 3 and a "caesura fill" chromatic scale in the right hand. You may find that term helpful, but be careful when using it somewhere that isn't a Medial Caesura!


TypeORM make COUNT query on table which maps two tables together

Question: I have two entities Model and Video where Video basically store information about videos and Model store information about model. Because each video can have multiple models and each model can have multiple video entities looks like this:
How my entites and tables looks like:
// Video Entity
@Entity()
export class Video {
  @PrimaryGeneratedColumn()
  id?: number;

  @Column({ charset: 'utf8mb4', collation: 'utf8mb4_unicode_ci' })
  name: string;

  @Column({ type: 'text', charset: 'utf8mb4', collation: 'utf8mb4_unicode_ci' })
  description: string;

  @ManyToMany((type) => Model)
  @JoinTable()
  models: Model[];
}

// Model Entity
@Entity()
export class Model {

  @PrimaryGeneratedColumn()
  id?: number;

  @Column()
  name: string;

  @Column()
  code: string;
}

Because there is relation @ManyToMany between model and video TypeORM also created one extra table for connecting this two. Table name is video_models_model and it looks like this:
+-----------+---------+
| videoId   | modelId |
+===========+=========+
| 1         | 107     |
+-----------+---------+
| 2         | 142     |
+-----------+---------+
| 3         | 91      |
+-----------+---------+

What I need:
Based on modelId I need to find out COUNT() of videos.
In regular query language it  would be something like:
SELECT model.*, COUNT(model_videos.videoId) as totalVideos FROM model as model
LEFT JOIN `video_models_model` `model_videos` ON `model_videos`.`modelId`=`model`.`id`
WHERE model.id = 1;

What I tried:
This is how regular query would looks like:
this.modelRepository
  .createQueryBuilder('model')
  .where('model.id = :id', { id: id })
  .getOne();

so what I did was added to Model entity
  @ManyToMany(type => Video)
  @JoinTable()
  videos: Video[];

and after that I tried
this.modelRepository
  .createQueryBuilder('model')
  .leftJoin('model.videos', 'videos')
  .select('COUNT(videos)', 'totalVideos')
  .where('model.id = :id', { id: id })
  .getOne();

But it didn't work for me at all pluis it created one additional table named model_videos_video with modelId and videoId columns. So basically duplicate video_models_model table.
Is there any way how to make that easy query with TypeORM?
Answer: I found out that I have to change my entities to make them bi-directional so:
Video Entity:
@Entity()
export class Video {
  @PrimaryGeneratedColumn()
  id?: number;

  @Column({ charset: 'utf8mb4', collation: 'utf8mb4_unicode_ci' })
  name: string;

  @Column({ type: 'text', charset: 'utf8mb4', collation: 'utf8mb4_unicode_ci' })
  description: string;

  @ManyToMany(type => Model, model => model.videos)
  @JoinTable()
  models: Model[];
}

Model Entity:
@Entity()
export class Model {

  @PrimaryGeneratedColumn()
  id?: number;

  @Column()
  name: string;

  @Column()
  code: string;

  @ManyToMany(type => Video, video => video.models)
  videos: Video[];
}

And after that I make query like this:
this.modelRepository
  .createQueryBuilder('model')
  .loadRelationCountAndMap('model.videoCount', 'model.videos')
  .where('model.id = :id', { id: id })
  .getOne();


How to remove or uninstall an orphaned service?

Question: There are times when Windows Services are installed and for various reasons, that hopefully are not important to the answer, the service no longer has the installer attached to it. Therefore, this particular service shows up in the list of Services, but cannot be uninstalled through normal practices.
In situations like this, how does one go about manually removing the orphaned service?
Answer: Using sc.exe from system32 dir:
<code>sc delete <service_name>
</code>
(be sure to stop the service first)
Comment: One comment, if your service has a space in the name, you should use: sc delete ""
Comment: And then (and only then) remove files (executable or otherwise).
Comment: Never mind - It seems to work. BTW, the Service Name is not the same as the display name. You have to right click the service and select properties to see the actual name.
Comment: What if there was an uninstaller and it removed the files, but did not remove the service?


Firebase sorting data in desc using negative timestamp

Question: I am trying to retrieve data in descending order at server side, which I am doing using negative timestamps. In my client side code, I am ordering data using timestamp for first few items, using this query:
Query queryRef = databaseReference.child("wallpapers").orderByChild("timeStamp").limitToFirst(6)

I am maintaining a variable (oldestPostId) which keeps hold of last key added to list.
Then I am using onScrollListener to retrieve more data using this query:-
Query queryRef = databaseReference.child("wallpapers").orderByChild("timeStamp").startAt(oldestPostId).limitToFirst(6);

First 6 items are correctly retrieved but my onScrollListener query i.e. second query not working.
According to me, If there are 4 items lets say 1,2,3,4 which if ordered are 1,4,3,2. Let's suppose if I am retrieving 3 items at once, then first I will get 1,4,3 and in another query, I should get 3,2.
Answer: From your description, oldestPostId is the last key you added to list. I assume it will be the random generated key Firebase assigned to your wallpaper object when you push it to the database.
It means that, the oldestPostId is not the timeStamp.
Your second query is trying to extract the first 6 item with timeStamp>=oldestPostId, which is not comparing apple to apple. Ofcourse it is not working. You should use oldestPostTimestamp inside your query instead of olderstPostId.
Answer: This is happening because you are trying to order by the timeStamp child and you are passing to the startAt() method an id and not a timeStamp value. In order to solve this, please change the following line of code:
Query queryRef = databaseReference.child("wallpapers").orderByChild("timeStamp").startAt(oldestPostId).limitToFirst(6);

with
Query queryRef = databaseReference.child("wallpapers")
    .orderByChild("timeStamp")
    .startAt(1523346011) //We pass a timeStamp
    .limitToFirst(6);

As you can see, I have passed to startAt() a timeStamp which is of type long.


How to analyse several types of geo data together?

Question: I have some data gathered from a survey conducted within my city. All responses include an approximate geo location of where they were gathered (accurate to probably a couple of hundred yards which is relatively small), and things like the respondents age, sex, income range, number of dependents, etc. There are approx. 4000 responses.
What I would like to is to be able to generate what I guess you would call a model, so that given a geo point (or box) I could characterize the typical respondent from there (it doesn't really have to be really rigorous, although some kind of formal confidence measurement would be nice).
So, is the right thing to do to simply treat all the gathered attributes separately and say "Well the age of your typical respondent in that area is m with stdev s, and their income range is ..., etc."
Or is there some better way to analyse the data together to get a better profile of the respondents.
Some key phrases to google would even help at this stage, because I'm a bit lost. I thought this might be "data fusion" but I don't think it is.
Comment: Obligatory RA Fisher quote required here: "To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of"
Comment: I've added the spatial and survey tags. Feel free to remove them if you feel they are inappropriate.
Answer: The short answer is the "usual" way in the social sciences is to have pre-defined discrete areas and provide summary statistics for samples within those areas aggregated up. Examples of pre-defined areas may be census geographies, zip-codes, or any other neighborhood unit you can dream up.
This is the usual because it is fairly rare to have surveys geocoded to the exact location or be able to utilize that information due to privacy reasons, so typically surveys can't be geolocated besides within a general area anyway. Even if you don't have pre-defined areas you could always create a uniform grid (i.e. quadrats) and provide summary statistics. If your sampling over the city diverges from uniform though this approach will not work as well, as you could have some quadrats with few (or zero) samples and some with many samples (in fact some people justify aggregation to larger units because of such concerns).
More novel is to utilize what van Ham & Manley (2012) refer to as bespoke neighborhoods. One essentially picks a point, and then some arbitrary buffer around that point, and then estimates whatever summary statistic one is interested in based on samples around that point. Related examples can be found in Lee et al. (2008), Li & Radke (2012) and Ratcliffe & Taniguchi (2008).
If you want more continuous measurements over the entire study space, you can utilize geo-statistical kriging to estimate a continuous surface (although this is also pretty novel for social science). Similar examples can be found in the social science literature under area-to-point kriging (which is a slightly different context). See this other answer of mine for a list of scholarly examples.

Citations

Lee, B. A., Reardon, S. F., Firebaugh, G., Farrell, C. R., Matthews, S. A., and O'Sullivan, D. (2008). Beyond the census tract: Patterns and determinants of racial segregation at multiple geographic scales. American Sociological Review, 73(5):766-791. PDF Here.
Li, W. and Radke, J. D. (2012). Geospatial data integration and modeling for the investigation of urban neighborhood crime. Annals of GIS, 18(3):185-205.
Ratcliffe, J. H. and Taniguchi, T. A. (2008). Is crime high around drug-gang street corners?: Two spatial approaches to the relationship between gang set spaces and local crime levels. Crime Patterns and Analysis, 1(1):23-46. PDF at link
van Ham, M. and Manley, D. (2012). Neighbourhood effects research at a crossroads: Ten challenges for future research. Environment and Planning A, 44(12):2787-2793.
Answer: What about an estimator which is an average over its closest  k neighbors with the weights given to the neighbors decreasing with distance from the target point.
The right taper for the weights could be fit beforehand using some sort of error minimization training scheme?
Alternatively, I was thinking of a Voronoi tessalation. For a point of interest find its Voronoi cell and add in the effect of next-neighbor cells with a reduced weight and so on?
Too simplistic?
PS. Would there be a chance that the Income (say) at a location is better predicted by $fn(income, age, sex)$ of its neighbors than by merely $fn(income)$ of its neighbors?
In essence, can mixing predictors get a better predictive model than keeping them separate?
In the extreme could one ever have a situation where neighbor age alone was a better predictor of a points income than neighbor income? Just wondering.
Comment: `What about an estimator which is an average over its closest k neighbors with the weights given to the neighbors decreasing with distance from the target point.` This is essentially inverse distance weighting, which could be viewed as the simplest type of kriging model. A very similar context for estimating correlations between variables is geographically weighted regression.


Being Prevented From Closing File in Python

Question: I am trying to place scores from a 2D Array in to a file and I have arranged them in to descending order and the top highest scores will be put in to a text file for it to be read.
def highScoresList(player,score):
    length = len(winners)
    winners.append("")
    winners.insert(length, player)
    winners.insert(length, score)
    if length == 0:
        length = length
    else:
        for x in range (0,length):
            if winners[[x][1]] < winners[[x+1][1]]:
                temp = winners[x]
                winners[x] = winners[x+1]
                winners[x+1] = temp
                length += 1
if length <= 5:
    count = len(winners)
    if count < 5:
        for x in winners:
            high_scores = open("diceScores.txt","w")
            high_scores.write("",winners[[x][0]," - ",winners[[x][1]],""]
            **high_scores.close()** # Invalid Syntax
        high_scores = open("diceScores.txt","r")
        print(high_scores.read())
        high_scores.close()
    else:
        high_scores = open("diceScores.txt","a")
        for x in range (0,4):
            high_scores.write("",winners[[x][0]," - ",winners[[x][1]],""]
            high_scores.close()
        high_scores = open("diceScores.txt","r")
        print(high_scores.read())
        high_scores.close()

When I run the code, there is a syntax error on high_scores.close()> on the 7th line. What can I do to fix it?
Comment: Showing the actual error with surrounding lines would be very helpful.
Answer: The problem is a missing close parenthesis on the line before close.  It should be:
high_scores.write("",winners[[x][0]," - ",winners[[x][1]],""])


Created file access using USB in Titanium

Question: I'd like to know how can I access the photos that I saved with my Titanium Android app using the USB cable to copy for my PC.
I tried using the Ti.Filesystem.externalStorageDirectory and the Ti.Filesystem.applicationDataDirectory but both saved the file in the device (I could see using the ES File Explorer app) but when the device is connected to computer the same folder is not visible to copy.
Answer: AFAIK Ti.Filesystem.applicationDataDirectory will be only limited to your application, so you cannot access it outside the app. But by using Ti.Filesystem.externalStorageDirectory you can save the file to external storage and access it.
Also to make it visible to gallery you have to use scanMediaFiles.
Hope it helps.
Comment: Hello. But if I have another kind of files, like .txt or another extension?
Comment: are you checking in windows or linux?  Also what type of photos are in txt?? :/
Comment: I'm using Mac... But Windows happen the same. I have photos files (jpg) and some txt file with informations.


Automatically creating tables in BigQuery

Question: I created a transfer that loads data from an Amazon S3 bucket to my Google Cloud daily. The Google Cloud bucket contains a folder with more subfolders that contain application/octet-stream "files". I can manually create tables (in json) using them in BigQuery.
However, there is lots of them and I was wondering if it is possible to automatically create them. I always use the automatic schema and they are in json. I don't change any other settings. Is it possible to do this in the UI, and if not, how do I do this in the console?
Comment: You should probably clarify your question: do you want to automatically load your JSON files into BQ as soon as they reach GCS, or do you want a shell command to load them at once ? ("do this in the UI or the console": that sounds manual + the console and the UI is actually the same, you probably meant Cloud Shell)
Comment: As soon as the file is loaded into GC, I want a table in BQ based on it. The format should be in json and the schema should be automatically detected.
Answer: You can create a Cloud Function which will be triggered by file upload. Such cloud function can process uploaded file and create a table in BigQuery.


Realizar a Média de coluna valor dentro de uma tabela com R

Question: Estou precisando gerar a média em uma coluna de valor de uma tabela no R, porem não estou conseguindo. Eu já fiz assim criando um vetor:
x <- c(15,12,8,9,5,6,1,2)
mean(x)

Ele funciona, porém quando aponto para a tabela que gerei dentro do R não consigo:
x <- (receitas_vs_depesas_contratadas_tidy %>%
  select.list(VR_TOTAL_RECEITA))%>%

mean(x)

erro:Error in (receitas_vs_depesas_contratadas_tidy %>% select.list(VR_TOTAL_RECEITA)) %>%  :
  could not find function "%>%"

Comment: Carregue o pacote `dplyr` ou `tidyverse` para ter acesso ao comando `%>%`. Depois disso, o comando `(receitas_vs_depesas_contratadas_tidy %>% select.list(VR_TOTAL_RECEITA))%>%` vai continuar dando erro. Por favor, [dê uma olhada neste link](https://pt.meta.stackoverflow.com/questions/6700/como-fazer-uma-pergunta-reproduz%C3%ADvel-em-r/6701#6701) e veja como fazer uma pergunta reproduzível em R. Edite a sua pergunta com os detalhes necessários para que possamos te ajudar da melhor maneira possível.
Comment: importei o pacote e mudei o código:
Comment: media<-c(receitas_vs_depesas_contratadas_tidy %>%
  select(VR_TOTAL_DESPESA)%>%
  mutate(media=mean(VR_TOTAL_DESPESA)))
Comment: mas ainda não resolveu
Comment: Por isso postei o link acima. Se não tivermos uma parte que seja do teu conjunto de dados, vamos ficar aqui tateando no escuro sem chegar a conclusão alguma. Edite a sua pergunta para deixá-la reproduzível. Vai ser mais trabalhoso no começo, mas todos que estão aqui vão poupar seu tempo, inclusive tu mesmo.
Comment: Se quer só a média da coluna com o pacote `dplyr` nem é preciso o `select`. Veja este exemplo com o conjunto de dados `iris` que vem com o R base. `iris %>% summarise(media = mean(Sepal.Length))`. Note que é `summarise`, não é `mutate`.
Answer: Utilizando o summarise_all do pacote dplyr.
library(dplyr)
set.seed(1)
x <- c(15,12,8,9,5,6,1,2)

df <- data.frame(x,
                 y = rnorm(length(x)),
                 w = rnorm(length(x)))

df %>%
  dplyr::summarise_all(mean)

> df %>%
+   dplyr::summarise_all(mean)
     x         y          w
1 7.25 0.1314544 0.05200928

Perceba que a resposta das médias é igual a média de cada coluna, quando utilizado o $.
mean(df$x)
#
> mean(df$x)
[1] 7.25

mean(df$y)
#
> mean(df$y)
[1] 0.1314544

mean(df$w)
#
> mean(df$w)
[1] 0.05200928


How to customize the existing image component (map/area functionality) in Adobe Cq5?

Question: There is an image, when I hover on the specific area of a image. I want to show another image in CQ5. Right now I have achieved this using map,area,co-ordinates concept, onmouseover() function I have changed the images. I have got the following things from the dialog from the user.
1)image which needs to appear when hovered
2)co-ordinates of the area.
My question is, I want to  avoid getting the co-ordinates from the user. The same map functionality is present in default image component, where should I go and customize the component, so that I can add an extra textfield in the component to just get the image path which needs to change on hover,and I want to add the mouseover functionality as well.
Can someone please help?
Thanks in advance.
Comment: You want to know how to edit a dialog to add a text field? What have you tried so far?
Comment: @anotherdave : in the existing image component, there is map functionality available. i want to add a textfield in that map functionality tab . where is the jsp file to customize the map functinality ?
Comment: @anotherdave: right now the map fucntionality allows me to only add an href link for the area.i want to add an extra field where i can add, images path , which has to be showed when i hover on the each specific area.
Answer: When I add an image map to an image dialog, I get the following outputted in Author mode:

    <map name="map_X" id="cq-gen117">
        <area shape="rect" coords="25,34,209,151" href="/path.html">
    </map>

Going by /libs/foundation/components/image/image.jsp, the <map> and the <image> are all rendered out by the drawOut() method of com.day.cq.wcm.foundation.Image.
If you want to change how the map is outputted, you would need to replace this method with your own code. The details of the map itself though are saved on the image node as a regular property called imageMap, so there's it's quite possible to:

Overlay the image component
Modify your version of the JSP (apps/foundation/components/image/image.jsp) to output the map, the href and the image as you need it (using ${properties.imageMap} for the map/link and ${properties.fileReference} for the image reference)
Write some CSS/JS to overlay your image from the href on hover.


R group_by one variable or (not and) another

Question: I have a dataset with two variables. As a simple example:
df <- rbind(c("A",1),c("B",2),c("C",2),c("C",3),c("D",4),c("D",5),c("E",1))

I would like to group them by the first component or the second, the desired output would be a third column with the following values:
c(1,2,2,2,3,3,1)

If I use dplyr and group_by and cur_group_id(), I would get groups by the first and second component, obtaining therefore
c(1,2,3,4,5,6,7)

Can anyone help me in an easy way, it could be either base R, dplyr or data.table, to obtain the desired group?
Thank you
Answer: Perhaps igraph could be a helpful tool for you
library(igraph)
df$grp <- membership(components(graph_from_data_frame(df, directed = FALSE)))[df$X1]

which gives
> df
  X1 X2 grp
1  A  1   1
2  B  2   2
3  C  2   2
4  C  3   2
5  D  4   3
6  D  5   3
7  E  1   1

Data
> dput(df)
structure(list(X1 = c("A", "B", "C", "C", "D", "D", "E"), X2 = c(1L,
2L, 2L, 3L, 4L, 5L, 1L)), row.names = c(NA, -7L), class = "data.frame")


How to add large self hosted videos to Drual 7?

Question: The Video module for Drupal 6 has an option to use videos uploaded through FTP. The Drupal 7 version does not have that option. How can I embed large self hosted Video files?
Comment: You are using the "File attach from server directory" option for a CCK filefield in Drupal 6?
Comment: Can you clarify exactly which module? `"D6 video module"` is a bit vague.
Comment: I am currently using Drupal 7.  In D6 I used http://drupal.org/project/video, which had the ftp option.
Comment: Drupal 6 Sample: http://viyooham.com/node/54
Answer: To answer your question: Use the contributed Drupal 7 Video module.
You will likely need to configure your server to allow for large file/video uploads.
I currently allowing video uploads that are up to 1GB using only the Video module, FFMPEG and a few helper modules to manage the 'video processing' workflow.
Most likely you will need to modify your PHP.INI file to allow large uploads.  Specifically max post size and max upload size.

As for a widget that allows you to select a file uploaded via FTP, I see several issues in the Video modules issue queue that look relevant, but no solutions seem to be offered.

This question was also un-answered months ago.  If FTP is a requirement you may need to write a custom module or contact the Video modules maintainers for a status update.
Answer: This is old question but nowadays there is solution for adding videos which are uploaded with FTP to server.
Solution is to use FileField Sources module. After this module is enabled then go to Manage fields in your Content type which has Video-field. Edit Video-field settings and you can find File Sources from there. Choose desired ways to add video for example File attach from server directory.


How to select a dynamic number link using WebDriver for Java

Question: I'm trying to select a dynamic number link in Webdriver. The problem is this:
The xpath and href are both dependent on the order ID which changes per order. In this particular case:
XPath = "//*[@id='transSummaryRow_1195908']/td[1]/a"
href ="ftransDetails.aspx?FTID=1195908&OID=904096">1195908"

Here's what I tried, but it's not working.
public static WebElement lnk_TransHistPayId(WebDriver driver){
    element = driver.findElement(By.linkText("ftransDetails.aspx?FTID="+"\\d+"+"&OID"+"="+"\\d+"));
    return element;
}

Answer: Try this:
//or this can be done also: By css = By.cssSelector("[id^='transSummaryRow_']/td[1]/a");
By css = By.cssSelector("[href^='ftransDetails.aspx?FTID=']");

public static WebElement lnk_TransHistPayId(WebDriver driver){
    element = driver.findElement(css);
    return element;
}


Generating Rust executable or library, depending on the target platform

Question: I am targeting my Rust project for Windows and Linux.
On Windows, the code needs to be linked to an executable, whereas on Linux - as a shared library.
To link the project as a Linux shared library, I added the following section to Cargo.toml:
[lib]
name = "my_project_name"
crate-type = ["cdylib"]

However that results in shared library generated on Windows, too.
Is there a way to tell Rust compiler to link the project as executable on Windows and as a library on Linux?
Comment: I think it not possible, but you may try to build the binary and the library for both platforms, then using the required ones
Answer: As far as I can see it's not possible to do so right now. Closest information I could find was this for a similar use case.


CKEditor com MVC5 e EF6

Question: Eu coloquei o CKEditor no meu projeto. Ele funciona tudo belezinha, porém quando clico no botão Save ele retorna essee erro:

Um valor possivelmente perigoso Request.Form foi detectado no cliente (Conteudo="

  <span style="f...").

PS: Já desabilitei o RequestValidation no Web.Config
Comment: Tente decorar a sua Action que recebe o post com o seguinte código: [ValidateInput(false)]
Answer: Coloque ValidateInput(false) no método do seu Controller, exemplo:
[ValidateInput(false)]
[HttpPost]
public ActionResult CreateOrEdit(Noticia model)
{

}

Com isso ele não vai validar os seus input que enviaram ao seu model um html, que por padrão do MVC não pode.
Ou
Utilize AllowHtml como atributo da propriedade da sua classe, exemplo:
public class Noticia
{
    [AllowHtml]
    public string Texto { get; set; }
}

Referências:

Validate Input in ASP.NET MVC
ValidateInputAttribute Class
AllowHtmlAttribute Class

CKEditor com MVC5 e EF6


Consumindo API com Refit C#

Question: Boa pessoal, eu estou com um pequeno problema para consumir uma API.
Estou com uma aplicação web AspNetMVC e preciso consumir uma API.
Primeiramente com uma seleção do usuário eu executo este método abaixo no controller:
<code>[HttpPost]
    public JsonResult ChamadaTrade(String valor)
    {
        if (valor != null)
        {
            var saida = APICalling.Call();
            return Json(saida);
        }
        else
        {
            var saida = "falha";
            return Json(saida);
        }
    }
</code>
A intereface para implementação da chamada:
<code> public interface IApiService
{
    [Get("")]
    Task<Data> GetDataAssync();
}
</code>
E o método que a implementa:
<code>[HttpGet("")]
    public static async Task<string> Call()
    {
        try
        {
            IApiService ExchangeClient = RestService.For<IApiService>("https://api.coinlore.net/api/tickers/");
            var dataExchange = await ExchangeClient.GetDataAssync();
            return dataExchange.Name.ToString();
        }
        catch (Exception e)
        {
            return $"Erro na consulta dos dados " + e.Message;
        }
    }
</code>
No entanto estou recebendo JSONException "jsonexception a possible object cycle was detected which is not supported"
Só queria saber se meu código tem alguma implementação errada ou se preciso fazer alguma conversão do JSON que não estou fazendo.
Comment: Olá, é uma configuração no JSON. Teu objeto, provavelmente, está com referencia circular Ex.: class Pai { public List filhos {get;set; } e class Filho { public Pai pai {get;set; }; Quando o programa vai transformar o objeto em JSON string, vai ficar em um loop entre as referencias dos dois objetos. Vai precisar ignorar o erro no serialize do objeto para evitar esse tipo de referencia circular.
Answer: Como o Anderson Koester já falou, possivelmente sua classe Data está com referencia circular. Deveria ser algo parecido com esse exemplo:
<code>public class Data {
    public string id { get; set; }
    public string symbol { get; set; }
    public string name { get; set; }
    public string nameid { get; set; }
    public int rank { get; set; }
    public string price_usd { get; set; }
    public string percent_change_24h { get; set; }
    public string percent_change_1h { get; set; }
    public string percent_change_7d { get; set; }
    public string price_btc { get; set; }
    public string market_cap_usd { get; set; }
    public double volume24 { get; set; }
    public double volume24a { get; set; }
    public string csupply { get; set; }
    public string tsupply { get; set; }
    public string msupply { get; set; }
}

public class DataResponse    {
    public List<Data> data { get; set; }
}
</code>

Consumindo API com Refit C#


countinuty & differentibility

Question: Show that if $F :\Bbb R\to \Bbb R^n$ is continuous on $[a,b]$ and differentiable on $(a,b)$, then there is a $c\in(a,b)$ such that $||F(b)−F(a)|| \le||F'(c)||(b−a)$.
I am not sure whether I should use mean value theorem or not.
Comment: use the main theorem of differential and integral calculus for $F$, then apply norms and estimate.
Answer: You cannot use the mean value theorem for vector valued functions.
But you can argue as follows: Let $v = F (b)-F (a) $. Then consider the function
$$
f (x) := \langle  F (x), v \rangle
$$
for which you can apply the mean value theorem.
For the resulting bound,  apply the Cauchy-Schwarz  inequality.
Note though that the above assumes that you use the usual euclidean norm on $\Bbb {R}^n $. For other norms, you will have to use a (finite dimensional) variant of the Hahn-Banach theorem to obtain a functional $\phi $ on $\Bbb {R}^n $ with norm $\Vert \phi \Vert  \leq 1$ and $\phi (v)= \Vert v\Vert $.
Comment: sorry that I do not know Hahn-Banach theorem...
And I have inspired by you and then I try to answer my question below, hope you can help me to check. Thank you very much!!
Answer: I want to know are there any problems in my answer. Thank you!
Let ϕ(t)=(F(b)-F(a))⋅F(t) for t∈[a,b]
When t=a, ϕ(a)= (F(b)-F(a))⋅F(a) =F(b)⋅F(a)-||F(a)||^2
When t=b, ϕ(b)= (F(b)-F(a))⋅F(b) =||F(b)||^2-F(b)⋅F(a)
as F is continuous on [a,b] and differentiable on (a,b)
ϕ is continuous on [a,b] and differentiable on (a,b)
By mean value theorem, there exist c∈(a,b) such that
ϕ(b)-ϕ(a) = (ϕ'(c))(b-a)
Because ϕ(b)-ϕ(a) = ||F(a)||^2+||F(b)||^2 - 2F(a)⋅F(b)=(F(b)-(F(a))⋅(F(b)-(F(a))
=||F(b)-F(a)||^2
and
(ϕ'(c))(b-a)=(F(b)-F(a))⋅F'(c)(b-a)
So||F(b)-F(a)||^2 =(F(b)-F(a))⋅F'(c)(b-a)
||F(b)-F(a)||^2 =||(F(b)-F(a))||||F'(c)||(cosθ)(b-a) where θ is the angle between F(b)-F(a) and F'(c)
Hence, ||F(b)-F(a)||=||F'(c)||(cosθ)(b-a)
and as -1≤cosθ≤1, (b-a)>0
||F(b)-F(a)||≤||F'(c)||(b-a).

countinuty & differentibility


Winning strategy in a pigeonhole principle related game

Question: Let us have the following game. The player $F$ claims that the usual pigeonhole principle is not true and, moreover, they have a counterexample, i.e. a function which maps $n + 1$ pigeons injectively into $n$ holes for some finite $n$. The player $T$ does not agree with such a claim and wants to prove $F$ wrong. To achieve this, they ask $F$ questions of the following form: given a pigeon $a$, where should $a$ be mapped according to $F$. The player $T$ wins as soon as the $F$'s answer contradicts some information $T$ already has, i.e. $F$ claims that the pigeon $a$ should be mapped to the hole $b$, while $T$ already knows that $a$ is mapped to the hole $b' \neq b$. The problem is that $T$ has really small memory, in particular, they can store information about $2$ pigeons at the same time, and so before asking any new question, they must erase the oldest piece of information (and so immediately prior to asking such a question $T$ effectively has information about $1$ pigeon only).
It is not hard to show that that in this game $F$ can play in a way that $T$ will never catch them off guard and so $T$ can't possibly win. But there is one more rule. At some point $T$ can ask the last question, after which they will take the final piece of information and compare it with all the data they have gathered through the whole game (the data which has been erased). Note that they can compare the answers gathered through the whole game with the last answer only and not with each other. If they can find some contradiction with the $F$'s claim, they win.
Assume $T$ has some fixed strategy (i.e. each new question depends only on information which is in $T$'s memory and on the question's index) and assume the index of the final question is fixed as a part of the strategy. I would like to find an (elementary) proof that $F$ can still play in such a way that $T$ will not win in the end.
Comment: When you say "they can compare the answers gathered through the whole game with the last answer only", can you clarify what that means? EG If F said "pigeon A is in hole 1", can we compare against all questions about pigeon A AND all answers about hole 1? Or just the former/latter?
Comment: We can compare against both of these, e.g. for T to win it is enough that there has been an answer of the form A is somewhere besides 1 or there is some other pigeon besides A mapped to 1.
Comment: Does F know T's strategy ?
Comment: @WW1: Technically, it doesn't matter, since the question asks whether $F$ **can** still play in such way, which is independent of whether they know they're doing it or not. If the question was whether $F$ can know how to win, the assumption would have to be that $F$ knows $T$'s strategy, because otherwise it would be trivially impossible – $T$ could just fix a strategy of asking about each pigeon once and then asking the final question about some pigeon, and $F$ would have no way of making sure that that last pigeon wasn't assigned the same hole as another.
Comment: @WW1,  yes, $F$ knows a priori $T$'s strategy.
Comment: This isn't true for $n=1$ or $n=2$. $T$ can just ask about each pigeon in turn; you have to give different answers to successive questions; and then ending on the $n+1$-th question will reveal an inconsistency. Are you assuming $n\gt2$?
Comment: @joriki yes yes, sorry, we may assume $n$ is large enough.
Answer: If F knows which pigeon (call it X) will be asked about in the final question, they can fool T into thinking that they can fit any number of pigeons into just 3 holes.

If T asks about X, F answers hole #1
Otherwise F answers either 2 or 3, depending on whether or not T is asking about the same pigeon they asked about in the previous question.


How to hide webform label from email only?

Question: I'm currently using the Webform module to build a warranty support form for Drupal 7.
Here is a screen shot of the webform:

Below is the email output I receive when the form is submitted:

James Blunte.g. Joe Smith (firstname.lastname@example.com) has submitted a warranty request.
Order Number: 39840e.g. 1248

I've used the right label to show examples of what to enter in the field on the webform. My question is how do I hide the label from showing on the email template? As you can see the label follows right after the value.
Here is a screenshot of my 'Edit Components' page:

I can see how it's useful for the label to appear, but in my case I don't need it in the email.
Thanks for your time!
Answer: It would take quite a bit to edit the email templates. The truth is that this is design behavior, because labels
The better way to do what you want is to put that text in the help/description field of the component and then style it with CSS. That text is not included in the email.
Comment: Genius!! I completely let that one fly over my head. Thanks for the help.


Excessive memory usage in Matplotlib imshow

Question: I've got a PyQT4 application that displays medium size images in a Matplotlib figure.  The test image that I'm displaying is about 5Mb (2809 x 1241 pixels).  I read in the data using GDAL by the way. The image is read into an array with nodata values masked out.  This is then displayed with normalized values and a specified colormap
It seems to use an inordinate amount of memory to display a 5mb file. What I'm seeing is that it takes a 140mb of memory to display this image read in at full resolution. (application with imshow commented out used 60mb of memory, vs 206 with it)  The problem gets worse as images are displayed in multiple figures as each one uses an additional 200m of memory. At about 3 or 4 figures displayed the applications starts bogging down as the memory usage gets into the 700-900 mb range.
I understand about matplotlib having to store all the pixels even though it's displaying only a downsampled subset to match the screen resolution.  I'll probably end up writing routines to only read in an amount of pixels to match the figure size.  But since this application will be displaying up to 8 maps on 8 separate screens I'm concerned about it still using excessive memory.
So my questions are:
1) Does this seem like an inordinate amount of memory to be using for displaying a simple colormapped image?  It does to me.
2) Is there something I could be doing to decrease this memory usage?  For example using integer datatypes, releasing memory, etc.
3) What other strategies should I be using to deal with this memory usage?  For example downsampling (might not be very effective at full screen resolution 1900x1200), switching to 64bit architecture, etc
Thanks,
Code below
import sys, os, random
from PyQt4.QtCore import *
from PyQt4.QtGui import *

import matplotlib
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg as NavigationToolbar
from matplotlib.figure import Figure
import matplotlib.colors as colors

import numpy as np
from osgeo import gdal, gdalconst

gridfile = r"i:\vistrails\workingfiles\secondseason\secondseason_workfile_2012_02_28b\brt_1\brt_prob_map.tif"

class AppForm(QMainWindow):
    def __init__(self, parent=None):
        QMainWindow.__init__(self, parent)

        self.create_main_frame()

        ds = gdal.Open(gridfile, gdal.GA_ReadOnly)
        ary = ds.GetRasterBand(1).ReadAsArray(buf_ysize=500, buf_xsize=300)
        ndval = ds.GetRasterBand(1).GetNoDataValue()

        rasterdata = np.ma.masked_array(ary, mask=(ary==ndval))
        del ary

        self.axes.imshow(rasterdataint, cmap=matplotlib.cm.jet)

        del rasterdata

    def create_main_frame(self):
        self.main_frame = QWidget()

        # Create the mpl Figure and FigCanvas objects.
        # 5x4 inches, 100 dots-per-inch
        #
        self.dpi = 100
        self.fig = Figure((5.0, 4.0), dpi=self.dpi)
        self.canvas = FigureCanvas(self.fig)
        self.canvas.setParent(self.main_frame)

        self.axes = self.fig.add_subplot(111)

        self.mpl_toolbar = NavigationToolbar(self.canvas, self.main_frame)

        vbox = QVBoxLayout()
        vbox.addWidget(self.canvas)
        vbox.addWidget(self.mpl_toolbar)

        self.main_frame.setLayout(vbox)
        self.setCentralWidget(self.main_frame)

def main():
    app = QApplication(sys.argv)
    form = AppForm()
    form.show()
    app.exec_()

if __name__ == "__main__":
    main()

Comment: I had a slightly similar problem and I solved it by using `draw()` instead of `show()` and deleting the imshow object. For example: `self.im=imshow(your_data)`,`draw()`,`del self.im`. I don't know if this is your case
Answer: Memory issue with use of imshow() have been noticed, as here.
1/ Upgrade
As mentionned here, upgrading to latest vesion of mpl may fix the problem.
2/ PIL
As an alternative, you may make you of the PIL library.
When it goes to jpg files, imshow() is using PIL if installed. You can use PIL module directly, as documented here.


A list of Windows rootkit detection and removal tools

Question: A list of rootkit detection and/or removal tools from publicly trusted sources:

Name, Vendor, Latest release
RootkitRevealer, Sysinternals,
November 1 2006
Rootkit Unhooker, ep_x0ff (now working at Microsoft according to Rootkit.com), December 2007
F-Secure Blacklight, F-Secure, Unknown
GMER, GMER, March 2009
Microsoft Malicious Software Removal
Tool, Microsoft, April 2009
IceSword, Unknown, September 2005

Please add any trusted tools that you know of to the list.
Answer: RootkitRevealer

RootkitRevealer is an advanced rootkit
  detection utility. It runs on Windows
  NT 4 and higher and its output lists
  Registry and file system API
  discrepancies that may indicate the
  presence of a user-mode or kernel-mode
  rootkit. RootkitRevealer successfully
  detects many persistent rootkits
  including AFX, Vanquish and
  HackerDefender (note: RootkitRevealer
  is not intended to detect rootkits
  like Fu that don't attempt to hide
  their files or registry keys).
Answer: F-secure blacklight (free, Windows)
Answer: GMER, GMER, March 2009
One of the most complete and updated scanner/fixer, I found that it could find the most rootkits, and has a steady stream of updates.
Answer: I have had occasional success using the Ultimate Boot CD for Windows so that I can run an "offline" scan of the infected system.  The Achilles Heel of most well-known root kit scanners is that the root kits know about them as well. See: http://www.microsoft.com/emea/itsshowtime/sessionh.aspx?videoid=359
Answer: Rootkit Unhooker, ep_x0ff (now working at Microsoft), December 2007
Answer: I like Prevx
Answer: For Linux:
chkrootkit, Pangeia Informatica (BSD Open Source) 12/17/2007
rkhunter,  Rootkit.nl (GPL Open Source project) 12/31/2008
Answer: "ThreatExpert is an advanced automated threat analysis system designed to analyze and report the behavior of computer viruses, worms, trojans, adware, spyware, and other security-related risks in a fully automated mode."
-- www.threatexpert.com/default.aspx
"Our free software, Sophos Anti-Rootkit scans, detects and removes any rootkit that is hidden on your computer using advanced rootkit detection technology." -- www.sophos.com/products/free-tools/sophos-anti-rootkit.html
"SuperAntiSpyware. Detect and Remove Spyware, Adware and Remove Malware, Trojans, Dialers, Worms, KeyLoggers, HiJackers, Parasites, Rootkits, Rogue Security Products and many other types of threats." -- www.superantispyware.com/
('sorry, new users aren't allowed to add hyperlinks'. Can someone edit this and activate the links please)


Curve traced by all positions of a special point

Question: In the plane of given triangle $ABC$ if $P$ is a point satisfying geometric condition $[PAB]=[PAC]$ (where $[.]$ represents area enclosed). Then the curve traced by all such positions of $P$ divides the plane in $m$ parts then find $5m$.
I got no clue how to start and why we are saying that it will form a curve?
Comment: I think you should start by drawing some pictures for yourself.
Answer: Presumably, whoever devised the question described the locus of the point $P$ as a curve dividing the plane into some number of parts because it is, in fact, a curve dividing the plane into some number of parts.  A hint to determining whether this is true or not is to observe that the area of triangle $PAC$ is half the length of $PA$ times the (perpendicular) distance of $C$ from the line of $PA$, and the area of triangle $PAB$ is half the length of $PA$ times the distance of $B$ from the same line.  Thus, for the areas of the triangles to be the same, the line $PA$ must be equidistant from the points $B$ and $C$.


Iterating over array in series in mongodb shell

Question: I need to iterate over array inside mongoshell with the aid of async library in the following way:
load('/opt/kif/crons/dashboard/node_modules/async/lib/async.js');
async.series([
  function(cb) { print("First"); cb(null,1); },
  function(cb) { print("Second"); cb(null,2); },
  function(cb) { print("Third"); cb(null,3); }
], function(err, res) {
  printjson(res);
});

and running
mongo testasync.js

which returns
MongoDB shell version: 3.2.0
connecting to: test
First
2016-05-01T15:41:45.589+0000 E QUERY    [thread1] ReferenceError: setTimeout is not defined :
_delay<@/opt/kif/crons/dashboard/node_modules/async/lib/async.js:196:9
async.eachOfSeries/iterate/<@/opt/kif/crons/dashboard/node_modules/async/lib/async.js:272:29
only_once/<@/opt/kif/crons/dashboard/node_modules/async/lib/async.js:44:13
_parallel/</<@/opt/kif/crons/dashboard/node_modules/async/lib/async.js:723:17
_restParam/<@/opt/kif/crons/dashboard/node_modules/async/lib/async.js:167:1
@testasync.js:3:33
_parallel/<@/opt/kif/crons/dashboard/node_modules/async/lib/async.js:718:1
iterate@/opt/kif/crons/dashboard/node_modules/async/lib/async.js:262:1
async.eachOfSeries@/opt/kif/crons/dashboard/node_modules/async/lib/async.js:281:9
_parallel@/opt/kif/crons/dashboard/node_modules/async/lib/async.js:717:1
async.series@/opt/kif/crons/dashboard/node_modules/async/lib/async.js:739:9
@testasync.js:2:1

failed to load: testasync.js
[root@NQPC002 dashboard]#

How do I do that?
Comment: The MongoDB shell is generally synchronous; what async operations are you performing where you need this?
Comment: I have an array of object Ids and I want to update each of them one after another in such a fashion: for (var i=0;i<arr.length;i++) { db.dash.update({_id: arr[i].id}, {$inc: {prizes: arr[i].prize}}); } Is that operation synchronous?
Comment: Yep, the update methods in the shell are synchronous.
Answer: While the MongoDB shell uses JavaScript, its database access methods are all synchronous so a sequence of calls is already performed serially.
So a method like db.collection.update directly returns a WriteResult instead of using a callback.


Issue with not being able to pars LDIF file (invalid format (line 5) entry: "cn=schema")

Question: Trying to add a new attribute to a schema by using this command:
ldapmodify -f ./add-id-attribute.ldif  -h localhost -p 50389 -D "cn=Directory Manager" -w mySecretPassword
And this LDIF file
dn: cn=schema
changetype: modify
add: attributetypes
attributetypes: ( 22.214.171.124.4.1.32474 NAME 'myAttribute'
    USAGE userApplications )
    DESC 'The attribute'

But it gives me the following response: ldapmodify: invalid format (line 5) entry: "cn=schema"
I already changed the line endings to UNIX but that did not help.
I am using a docker image of OpenAM 6.5.2 which using OpenDJ as the directory server.
Answer: Your LDiF is not formatted correctly.
The DESC line comes after the closing bracket ) on the USAGE line and can therefore not be parsed.
You need to move the ) so the attributeTypes definition becomes fully enclosed by ( )
dn: cn=schema
changetype: modify
add: attributetypes
attributetypes: ( 184.108.40.206.4.1.32474 NAME 'myAttribute'
    USAGE userApplications
    DESC 'The attribute' )


Seasonal ARIMA estimate with non-significant variance

Question: I'm trying to fit a seasonal ARIMA model for a real data time series, 300 samples long, sawtooth looking. I'll write down a resume of my work trying to be clear without many plots.
The ACF of the original data slowly tapering towards 0 and the value PACF(1)=0.8 both suggest a non-seasonal differencing of order 1. As a consequence, both ACF and PACF correlations of the differencied data fall in the 95% confidence interval except for ACF(43)=+0.5 and PACF(~40)=-0.3. This value roughly corresponds to the period of my spikes in the signal.
I therefore applied a seasonal differencing for seasonality=43 multiplied by the non-seas. differencing. The correlograms follow:

What are the negative correlations at lag=1 telling me, now? Maybe differencing is too much and an AR(1) should be employed?
However, I tried some models with combinations of AR(1), MA(1), SAR(1) and SMA(1) and I got from minimization of AIC and BIC the following best models:
$$(1,0,0)\times(0,1,1)_{43}$$
$$(1,0,1)\times(0,1,0)_{43}$$
$$(1,0,0)\times(0,1,0)_{43}$$
For example, the residuals correlograms for the latter:

which look not bad to me even though some significant spikes around the lag of seasonality remain. Can be this due to the imperfect seasonality (data are from extremely fine sampled measurements!)?
Anyway, I have other two concerns:

the estimated variance of the model is $\sigma=1.7\times 10^{-10}$ with st. error$=4.6\times 10^{-8}$ which gives a t-statistic$=0.002$ really low!
the qq-plot of residuals shows a non-agreement with the Gaussian distribution:

In conclusion, how much can I trust my estimated model given these two problems?
Answer: Probably not at all !  Your data might disclose changes in parameters over time or deterministic changes in error variance over time suggesting Weighted Least  Squares or the need to identify and incorporate latent deterministic structure like pulses, step/level shifts or local time trends OR the need to incorporate seasonal dummies to deal with seasonal structure (often a good choice ! ).
Post your data and let's find out what your data knows.
EDITED AFTER RECEIPT OF YOUR DATA:
To review , auto.arima in a brute force list-based procedure that tries a fixed set of models and selects the calculated AIC based upon estimated parameters. The AIC should be calculated from residuals using models that control for intervention administration, otherwise the intervention effects are taken to be Gaussian noise, underestimating the actual model's autoregressive effect and thus miscalculates the model parameters which leads directly to an incorrect error sum of squares and ultimately an incorrect AIC.
The acf of the original is useful in assessing ARIMA structure ( that's the big  print ! ) when there are no deterministic factors/features in play like period #
( that's the small print ! ) . Here is the acf of the original data  .
Your 301 values are indeed non-stationary BUT there is more than 1 remedy for non-stationarity. Your series has deterministic effects for certain periods in the 43 period cycle . See I have correlogram ACF and PACF below for a temperature time series. Can I say it is MA(2) from ACF? What about AR? for a similar but different but related discussion.
I took your 301 values into AUTOBOX a piece of software that I had helped to develop and I asked it to tell me what it could find out by studying the 301 historical values. It hesitated for a very brief amount of time and told me the following.
Here is the Actual /Fit and Forecast graph
3: https://i.stack.imgur.com/lbD0m.png and a less busy Actual/Forecast   . The USEFUL equation that was found ( Note all models are "rong" but some are useful and some are very wrong ) is here in two parts.  and  providing clarity that the arima portion is simply (1,0,0) .
The statistics for the model are presented here
The residuals look pristine  with a very clean acf  .
A closeup of the forecasts is here ....
You said " I therefore applied a seasonal differencing for seasonality=43 " ... and I say that the data says no .
Periods 1-8 AND 36-43 ... are definitely non-players as they have little or no impact on what you are measuring.
It turns out your data had a lot to say about itself ...
With respect to your NON-SIGNIFICANT VARIANCE  ... this is probably due to a numerical flaw in the software that you used ...
Comment: Thank you for your reply. Here you can find the raw data: http://pasted.co/93147588
Comment: If you like my answer ..please accept it and close the question
Comment: thanks for the detailed reply. I'm still trying to fully understand it, but in the meanwhile I accepted your answer.
Comment: If I can help please feel free to contact me via email ...in order to clear up any questions
Comment: or open up a new question ...and ask 1 or more so that you can better understand ... ... . If you can't frame the question perhaps dialogue would help. I am interested in what aspect of physics is this ..what were you measuring and how frequently
Comment: thanks for your interest. It is a magnetic signal from a plasma discharge on a Tokamak. In this case, the periodic activity is due to an instability of plasma which leads to rearrangement of the local magnetic field along with an outwards flux of heat. The shapes of the signal gives the name of sawtooth to this phenomenon.

What I understood is that an ARIMA(1,0,0) would be enough (and I found the same in my analysis) but I didn't get how you approached the seasonal part of the signal.
Also your "Periods 1-8 AND 36-43 ... are definitely non-players" sounds a bit obscure to me. Cheers!
Comment: send me an email and perhaps we can chat on SKYPE
Comment: The data suggests that there is a systematic cycle of 43 periods where periods1-8 and 36-43 do not materially effect the observations i.e. they are not significant. However there appears to be a deterministic effect e.g. a Monday effect on daily dales  for other periods in the cycle. This explains the saw-tooth appearance. This explains the saw-tooth phenomenon being "caused by an unspecified predictor" i.e an exogenous effect. ARIMA model treat all effects as endogenous while Intervention Detection leads to ARMAX models whose effects are latent and waiting to be discovered.
Comment: to put things in another light suppose your are analyzing daily sales and you find that tuesday's sales are always higher than any other day. After identifying the tuesday effect one would naturally be curious as to why? Upon research one might find that the owner of the store sets a lower price on Tuesday. IN tour case there is a background/unreported/exogenous series that is "causing" the effects . Note that it is not always a cycle of 43 but "close". Now that you have identified the presence of another variable,you might want to pursue "it" and use it to aid the prediction of your series,


Inner product of a finite sum

Question: I have been working on this question for very long, but I can't find the right answer. I know that I have to check the properties for an inner product, but it gives me a hard time. The question is:

Can anyone help me?
Comment: Are you stuck on part (a)? If so, which of symmetric, linear, positive definite are you unable to show?
Answer: (a) Let $f,g,h\in S$ and $c\in\mathbb{R}$, and let $M,N\in\mathbb{N}$
be such that $f(n_1)=g(n_2)=0$ for all $n_1>M$ and $n_2>N$.
To verify $\langle\cdot,\cdot\rangle$ is an inner product,
we have to check the followings.

We have
\begin{align}
\langle f,g\rangle
=\sum_{n=0}^\infty f(n)g(n)
=\sum_{n=0}^N f(n)g(n)
=\sum_{n=0}^M g(n)f(n)
=\sum_{n=0}^\infty g(n)f(n)
=\langle g,f\rangle.
\end{align}
We have
\begin{align}
\langle f+h,g\rangle
&=\sum_{n=0}^\infty (f+h)(n)g(n)
=\sum_{n=0}^{N} (f+h)(n)g(n)
=\sum_{n=0}^{N} [f(n)+h(n)]g(n)\\
&=\sum_{n=0}^{N} [f(n)g(n)+h(n)g(n)]
=\sum_{n=0}^{N} f(n)g(n)+\sum_{n=0}^{N}h(n)g(n)\\
&=\sum_{n=0}^{\infty} f(n)g(n)+\sum_{n=0}^{\infty}h(n)g(n)
=\langle f,g\rangle+\langle h,g\rangle.
\end{align}
We have
\begin{align}
\langle cf,g\rangle
&=\sum_{n=0}^\infty (cf)(n)g(n)
=\sum_{n=0}^{N} (cf)(n)g(n)
=c\sum_{n=0}^{N} f(n)g(n)
=c\sum_{n=0}^{\infty} f(n)g(n)
=c\langle f,g\rangle.
\end{align}
We have
\begin{align}
\langle f,f\rangle
&=\sum_{n=0}^\infty f(n)f(n)
=\sum_{n=0}^{M} [f(n)]^2
\ge 0.
\end{align}

(b) We first show that $B$ is a basis for $S$. Given distinct vectors
$e_{n_1},e_{n_2},\ldots,e_{n_m}\in B$ and scalars
$a_1,a_2,\ldots,a_m\in\mathbb{R}$ such that
$\displaystyle\sum_{i=1}^ma_ie_{n_i}={\it 0}$. Then for $j=1,2,\ldots,m$,
$$0=\left(\sum_{i=1}^ma_ie_{n_i}\right)(n_j)=\sum_{i=1}^ma_ie_{n_i}(n_j)
=\sum_{i=1}^ma_i\delta_{n_in_j}=a_j,$$
where $\delta_{n_in_j}$ is the Kronecker delta function.
Hence $B$ is linearly independent. Next, given $f\in S$, choose $N\in\mathbb{N}$ such that $f(n)=0$ for all $n>N$. Define
$f^\ast=\displaystyle\sum_{n=1}^Nf(n)e_n$. For $k>N$, we have
$f^\ast(k)=0=f(k)$. For $k\le N$,
$$f^\ast(k)=\left(\sum_{n=1}^Nf(n)e_n\right)(k)
=\sum_{n=1}^Nf(n)e_n(k)=\sum_{n=1}^Nf(n)\delta_{nk}=f(k).$$
So $f^\ast=f$, which shows that $f$ is a linear combination of
vectors in $B$. Hence $B$ is a basis for $S$. Finally, we show that
$B$ is orthonormal. For each $m,n\in\mathbb{N}$ with $n\ne m$, we have
$$\langle e_m,e_n\rangle
=\sum_{k=1}^\infty e_m(k)e_n(k)
=\sum_{k=1}^\infty\delta_{mk}\delta_{nk}
=\delta_{mn}\delta_{nm}+\delta_{mn}\delta_{nn}=0+0=0.
$$
Also,
$\Vert e_n\Vert^2=\langle e_n,e_n\rangle
=\displaystyle\sum_{k=1}^\infty [e_n(k)]^2
=\sum_{k=1}^\infty \delta_{nk}^2=\delta_{nn}^2=1$. Hence $B$ is orthonormal.

Inner product of a finite sum


Configure page title block for contact form pages only

Question: I want the page title block to display on the contact form pages, because the nodes have their titles in their display.
It seems for a form you can't add the title to the form display, thus leaving me with the option to display it via the page title core block.
What I've tried as configuration for the block under visibility:

Contact form bundle: none selected (= for me, assuming: all)

Custom menu link bundle: Negate the condition (= for me, assuming: none)
Content type: Negate the condition (= for me, assuming: none)
Redirect type: Negate the condition (= for me, assuming: none)
All other configurations -> untouched (= for me, assuming: all)

But, the page title is never being displayed. Only when I deselect everything I see my page title... but I only need it on some pages.
Summarized, I want to only display the page title on specific pages, in a structural way (which means: no CSS hack)
Comment: So you're suggesting to create a new block with a module and adding this to the page with my custom/copied html? Although it is an option, isn't this a very circuitous approach?
Comment: So for each contact form, you suggest a custom block? I only see that option as the last one to implement as it is not very constructive to dynamic development...
Comment: I am now having two contact pages. But it could be that the user (who is not the superuser) wants to add new forms. I'll have to explain the process of creating new custom blocks too then? The average Joe or Jane doesn't like working like that, isn't it?
Comment: I've deleted the previous comments to avoid clutter.
Answer: You only need to select the Contact form bundles you want to display the page title on. Leave anything else untouched.
Comment: It's a bug in ctools: https://www.drupal.org/node/2695955
Comment: The strange thing is, if I do this approach, it doesn't include the block. I think this should be the standard approach. I've tried this before and tried this again. I'm considering this for now as a bug(?).
Answer: What about doing it in hook_from_alter()? Something like this should work, but I think this will screw with the login block as well, something to watch out for:
<code>function hook_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  switch ($form_id) {
    case 'user_login_form';
    case 'user_register_form';
    case 'user_pass';
      $request = \Drupal::request();
      $route_match = \Drupal::routeMatch();
      $title = \Drupal::service('title_resolver')->getTitle($request, $route_match->getRouteObject());
      $form['title'] = array(
        '#theme' => 'page_title',
        '#title' => $title,
        '#weight' => -1000,
      );
    break;
  }
}
</code>
Problem is of course the title is below the tabs.
Comment: The problem is indeed that the location of the title element is not in the correct place. It resides inside the form. This could be a sufficient approach, if the design allows this. Otherwise, you'll have to add a container around the form except for the title leaving it to be a considerable option.


ggplot2: Use every N-th legend key label

Question: I have a data.frame with 72 discrete categories. When I colour by these categories I get 72 different keys in the legend. I would prefer to only use every 2nd or 3rd key.
Any idea how I cut down on the number of lines in the legend?
Thanks
H.
Code that reproduces my problem is given below.
t=seq(0,2*pi,length.out=10)
RR=rep(cos(t),72)+0.1*rnorm(720)
dim(RR)=c(10,72)
stuff=data.frame(alt,RR)
names(stuff)=c("altitude",
               paste(rep(15:20,each=12),
               rep(c("00","05",as.character(seq(from=10,to=55,by=5))),6),
               sep=":"))

bb=melt(stuff,id.vars=c(1))
names(bb)[2:3]=c("period","velocity")
ggplot(data=bb,aes(altitude,velocity))+geom_point(aes(color=period))+geom_smooth()

Comment: Would you like to exclude certain categories or merge them together?
Answer: You can treat your period values as numeric in geom_point(). That will make colors as gradient (values from 1 to 72 corresponding to number of levels). Then with scale_colour_gradient() you can set number of breaks you need and add labels as your actual period values.
ggplot(data=bb,aes(altitude,velocity))+
  geom_point(aes(color=as.numeric(period)))+
  geom_smooth()+
  scale_colour_gradient("Period",low="red", high="blue",
          breaks=c(seq(1,72,12),72),labels=unique(bb$period)[c(seq(1,72,12),72)])

Answer: It looks hard to customize the legend here for a discrete_color_scale!So  I propose a lattice solution. You need just to give the right text to the auto.key list.
libarry(latticeExtra)
labels.time <- unique(bb$period)[rep(c(F,F,T),each=3)] ## recycling here to get third label
 g <- xyplot(velocity~altitude, data=bb,groups=period,
       auto.key=list(text=as.character(labels.time),
                     columns=length(labels.time)/3),
       par.settings = ggplot2like(),   axis = axis.grid,
       panel = function(x,y,...){
         panel.xyplot(x,y,...)
         panel.smoother(x,y,...)
       })