Using coefficient of variation in lab testing

Question: In order to determine the accuracy of a specific method, I need to determine if the results are statistically precise. In the example below, I am taking a sample from 7 individuals and running their sample twice. For each row I calculated the mean SD and Coefficient of Variation. Ideally the CV should be <15%. Is it appropriate to average the CV values?

My question is whether or not it is acceptable to average the CV values to get one CV. Or is there another more appropriate way to approach this problem?
Answer: First, if you are working with a measurement system where you expect a constant CV over a range of necessarily positive values, then it's often best to work with logarithmically-scaled data instead of the raw values. The assumptions behind many statistical tests require that the magnitudes of residual values around mean values be independent of the magnitudes of the values themselves; roughly, the SDs should be independent of the mean values. That's not true with your data in their original scale, but if you expect constant CV among samples then it should be true on a log scale.
Second, the CV is the ratio of the SD to the Mean, and the sample SD is a biased estimator. So it would be inappropriate to average the necessarily biased CV values.
It's best to use variances rather than SDs for this type of analysis, as the variance of a sum of independent variables is the sum of their individual variances. Given your type of data, you could consider working with values transformed on a natural log scale, and then performing a simple analysis of variance (ANOVA) among the samples.
ANOVA will give a residual mean square, representing the estimated variance of observations around the corresponding sample mean values, pooled among all the samples. The square root of that residual mean square is an estimate of the SD around the mean values, and with natural-log-transformed data that square root directly provides a pooled estimate of the CV.
Note, however, that your estimate of the CV from just a few samples like this can be quite different from the true underlying CV. See this paper for the number of cases that need to be examined to obtain CV estimates with desired confidence limits.


What are valid entity_id and entity_type values for node content?

Question: I'm trying to track down some performance issues on a Drupal 7 site where out of nowhere the site will stall rendering content or dealing with administrative duties like updating a piece of content. Checking the logs, I've found errors when cron runs for:

EntityMalformedException: Missing bundle property on entity of type node
Notice: Undefined property: stdClass::$nid in node_build_content()
Notice: Trying to get property of non-object in _node_index_node()

This prompted me to create a view to look at all content types and return

title,
node_id,
entity_id
entity_type

This view shows the majority of site content has entity_id = 0 and entity_type = null (nothing).
Out of roughly 400 nodes, less than 20 have proper entity_types and entity_id values. Even creating a simple basic page with a title and body results in entity_id = 0 and no value for the entity_type.
You would think that the content wouldn't render however, all of this content will render at /node/xxx or pulled up in views and can be edited as usual.
I think this is one of the causes of the poor performance if not the cause so I'm looking to repair the broken nodes and and prevent this site from continuing this odd behavior. I'm pretty sure the entity_id should equal node_id and I'm pretty sure the entity_type should equal node.
Drupal 7.34
Answer: This error can be caused by having a term reference field that references a deleted term. This reference is not deleted when a term is deleted.
You can check if this is the case using this query
<code>SELECT nid, title from node WHERE nid
   IN (select entity_id from  field_data_field_some_ref
   WHERE field_some_ref_tid not IN (select tid from taxonomy_term_data))
</code>
https://www.drupal.org/node/1778572#comment-7256200
There are other cases where this error can occur. Read the issue comments in the link for more info.
Comment: Thanks Chris,
I just ran the query. I only have a single term reference field called Categories so the query is as follows:

SELECT nid, title from node WHERE nid IN (select entity_id from field_data_field_categories WHERE field_categories_tid not IN (select tid from taxonomy_term_data))

It returns zero rows.
Comment: On second thought, I think your answer prompted part of the solution. When I looked at one of the content types I noticed there was an entity reference field for the Tags Taxonomy term. We weren't using it and a quick check showed none of the content was "tagged" so I removed that field from the content type and I no longer am receiving the first error: EntityMalformedException.

I am still receiving the "Trying to get property of non-object" and the "Undefined property: stdClass::$nid".
Comment: Try the accepted answer from [here](http://stackoverflow.com/questions/12719384/drupal-7-exception-entitymalformedexception-trying-to-run-search-index-cron#answer-13445925?). It looks like possibly the same issue.
Comment: Hi Chris,
Thanks for the direction. I had a look at that discussion and by a total fluke I found out it was the Site Info module that was causing the errors to be thrown. Now that it has been removed, the errors are gone but node content is still being produced without an entity_type and with entity_id = 0. I'm going to vote up your answer and search for discussions where entity_type is null and entity_id = 0. Thanks for all the help!


Append html after node content in custom module in Drupal 7

Question: I have an custom tpl.php inside of theme for some node type. It works fine but I would like my custom module to append some HTML after each such node (content of tpl.php). And I don't want to override the output from tpl.php inside of theme (just add something at the end of it).
Is there an hook for that or should I use different approach?
Answer: You can use the node view alter hook in your module to add/change your node object:

This hook is called after the content has been assembled in a structured array and may be used for doing processing which requires that the complete node content structure has been built.

If you have devel enabled, you can dpm($node) inside your node_view_alter function to see the node structure and then you can add to it as needed from the module.
Comment: Should be `mymodule_node_view_alter(&$build)`  Did you clear caches after implementing this? Can you add your code to your original question? You can also read this excellent tutorial on [understanding the hook system](https://www.drupal.org/docs/7/creating-custom-modules/understanding-the-hook-system-for-drupal-modules)
Comment: Sorry for a bit silly question but should the function be `function hook_node_view_alter(&$build)` or `function mymodule_hook_node_view_alter(&$build)`? I tried both but it looks like neither of them is called. Could you maybe provide sample body of this function?
Comment: Thank you for the link and clarification. After clearing cache everything works fine :)


Replace elements above by below of a diagonal in a matrix

Question: I want to make a program which replaces the elements below the main diagonal by the elements below the main diagonal in a matrix, I made a function called swap and it doesn't do what I want it to do, the output is the same for some reason. What could be the reason for that?
static int[,] swap(int[,] mat, int row, int col)
{
    int temp;
    temp = mat[row, col];
    mat[row, col] = mat[col, row];
    mat[col, row] = temp;

    return mat;
}

static void viceVersa(int[,] mat, int N)
{
    for (int row = 0; row < N; row++)
        for (int col = 0; col < N; col++)
            mat = swap(mat, row, col);
}

Expected output
Before

{5, 4, 3, 2}
{6, 1, 2, 4}
{9, 0, 2, 1}
{1, 2, 6, 2}

After

{5, 6, 2, 1}
{1, 1, 0, 9}
{4, 2, 2, 6}
{2, 3, 4, 2}

Answer: The nested loop in viceVersa function causes the problem, each element in the matrix (outside of the diagonal) is swaped twice so nothing changes after all.
This is one possible version:
static void viceVersa(int[,] mat, int N)
    {
        for (int row = 0; row < N; row++)
        for (int col = 0; col < N; col++)
        {
            if(row>col)
               mat = swap(mat, row, col);
        }

    }


JAVA: Why can't I access a method in the same class?

Question: I can't seem to find out why my static method is not able to call other methods in the same class. What should I do?
<code>    import java.util.Scanner;
    import java.util.*;

    public class MashupII {

      public void Append(Sound clip, boolean rev, double scale){

        //Void methods...

            //main method
      public static void main (String [] args) {

        Scanner keyboard = new Scanner(System.in);

        clips = new Sound[100];

        System.out.println("Please enter your command (A, I, D, P or Q)");
        char command = Character.toUpperCase(keyboard.next().charAt(0));

        while (command != 'Q'){
          switch (command){
            case 'A':

              //APPENDING
              //pick the clip
              System.out.println("Please pick a file.");
              Sound clip = new Sound(FileChooser.pickAFile());

              //reversing
              System.out.println("Would you like to reverse the clip? (Y|N)");
              String reverse = keyboard.nextLine();

              boolean rev = reverse.equalsIgnoreCase("Y");

              //scaling
              System.out.println("How much should the clip be scaled? (1 is no scaling)");
              double scale = keyboard.nextDouble();

              clips.Append(clip,rev,scale);

              break;
            case 'I':
              break;
            case 'D':
              System.out.println("Which clip would you like to delete? (1- end)");
              int p = keyboard.nextInt();
              clips.Delete(p);
              break;
            case 'P':
              break;
            default:
              System.out.println("Error! Please enter one of the available commands (A, I, D, P or Q)");
          }
          System.out.println("Please enter another command (A, I, D, P or Q)");
          command = Character.toUpperCase(keyboard.next().charAt(0));
        }
      }
}
</code>
I get the error in the switch case. It gives me a symbol not found. Any help would be great!
Comment: `clips.Append(clip,rev,scale);`... Clips is your sound array.
Comment: which symbol is not found?
Comment: I don't see you using any method declared in `MashupII`.
Comment: agree.. @user1760791 please put proper code snippet.
Comment: Please post a short but *complete* program demonstrating the problem.
Answer: clips is not an instance of your MashupII class, which is why you are not able to call MashupII's append() method.


Installed self-compiled Python 3.7.0 as "python", how to remove it?

Question: I have made a huge mistake on my Ubuntu 16.04 server.
I compiled and installed Python 3.7.0 from source using make altinstall, but I did not include all of the core dependencies I needed, so I was going to remove it and install a pre-packaged deb instead.
However, to remove it, I used this method with checkinstall. I generated a deb so that I could then remove all of the files created by the original installation, but for the deb's package name, I just left the default python.
Now, I have the following package installed:
$ sudo dpkg -l python
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                                  Version                         Architecture                    Description
+++-=====================================================-===============================-===============================-===============================================================================================================
ri  python                                                3.7.0-1                         amd64                           Package created with checkinstall 1.6.2

This means that I cannot run dpkg -r python because system packages depend on a metapackage just called python:
$ sudo dpkg -r python
dpkg: dependency problems prevent removal of python:
 python-ldb depends on python (<< 2.8).
 python-ldb depends on python (>= 2.7~).
 python-ldb depends on python (<< 2.8).
 python-ldb depends on python (>= 2.7~).
 python-ldb depends on python (<< 2.8).
 python-ldb depends on python (>= 2.7~).
 python-talloc depends on python (<< 2.8).
 python-talloc depends on python (>= 2.7~).
 python-talloc depends on python (<< 2.8).
 python-talloc depends on python (>= 2.7~).
 python-pyicu depends on python (>= 2.7).
 python-pyicu depends on python (<< 2.8).
 python-pyicu depends on python (>= 2.7).
 python-pyicu depends on python (<< 2.8).
 samba-common-bin depends on python.
 samba depends on python (>= 2.7).
 samba depends on python (<< 2.8).
 samba depends on python (>= 2.7).
 samba depends on python (<< 2.8).
 iotop depends on python (>= 2.7.1-0ubuntu2).
 iotop depends on python (<< 2.8).
 iotop depends on python (>= 2.7.1-0ubuntu2).
 iotop depends on python (<< 2.8).
 python-cryptography depends on python (<< 2.8).
 py
dpkg: error processing package python (--remove):
 dependency problems - not removing
Errors were encountered while processing:
 python

And I cannot install the default version of python again because I have the wrong version installed for python:
$ sudo apt install python
Reading package lists... Done
Building dependency tree
Reading state information... Done
python is already the newest version (3.7.0-1).
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 iotop : Depends: python (< 2.8) but 3.7.0-1 is to be installed
 python-acme : Depends: python:any (< 2.8)
               Depends: python:any (>= 2.7.5-5~)
 python-asn1crypto : Depends: python:any (< 2.8)
                     Depends: python:any (>= 2.7.5-5~)
 python-certifi : Depends: python (< 2.8) but 3.7.0-1 is to be installed
 python-cffi-backend : Depends: python (< 2.8) but 3.7.0-1 is to be installed
 python-chardet : Depends: python:any (< 2.8)
                  Depends: python:any (>= 2.7.5-5~)
 python-configparser : Depends: python (< 2.8) but 3.7.0-1 is to be installed
 python-crypto : Depends: python (< 2.8) but 3.7.0-1 is to be installed
                 Depends: python:any (>= 2.7.5-5~)
 python-cryptography : Depends: python (< 2.8) but 3.7.0-1 is to be installed
                       Depends: python:any (>= 2.7.5-5~)
 python-dnspython : Depends: python:any (< 2.8)
                    Depends: python:any (>= 2.7.5-5~)
 python-enum34 : Depends: python:any (< 2.8)
                 Depends: python:any (>= 2.7.5-5~)
 python-funcsigs : Depends: python:any (< 2.8)
                   Depends: python:any (>= 2.7.5-5~)
 python-future : Depends: python:any (< 2.8)
                 Depends: python:any (>= 2.7.5-5~)
 python-idna : Depends: python:any (< 2.8)
               Depends: python:any (>= 2.7.5-5~)
 python-ipaddress : Depends: python:any (< 2.8)
                    Depends: python:any (>= 2.7.5-5~)
 python-josepy : Depends: python:any (< 2.8)
                 Depends: python:any (>= 2.7.5-5~)
 python-ldb : Depends: python (< 2.8) but 3.7.0-1 is to be installed
              Depends: python:any (>= 2.7.5-5~)
 python-mock : Depends: python:any (< 2.8)
               Depends: python:any (>= 2.7.5-5~)
 python-openssl : Depends: python:any (< 2.8)
                  Depends: python:any (>= 2.7.5-5~)
 python-parsedatetime : Depends: python:any (< 2.8)
                        Depends: python:any (>= 2.7.5-5~)
 python-pbr : Depends: python:any (< 2.8)
              Depends: python:any (>= 2.7.5-5~)
 python-pkg-resources : Depends: python:any (< 2.8)
                        Depends: python:any (>= 2.7.5-5~)
 python-pyicu : Depends: python (< 2.8) but 3.7.0-1 is to be installed
 python-requests : Depends: python:any (< 2.8)
                   Depends: python:any (>= 2.7.5-5~)
 python-requests-toolbelt : Depends: python:any (< 2.8)
                            Depends: python:any (>= 2.7.5-5~)
 python-rfc3339 : Depends: python:any (< 2.8)
                  Depends: python:any (>= 2.7.5-5~)
 python-samba : Depends: python (< 2.8) but 3.7.0-1 is to be installed
 python-setuptools : Depends: python:any (< 2.8)
                     Depends: python:any (>= 2.7.5-5~)
 python-six : Depends: python:any (< 2.8)
              Depends: python:any (>= 2.7.5-5~)
 python-talloc : Depends: python (< 2.8) but 3.7.0-1 is to be installed
 python-tdb : Depends: python (< 2.8) but 3.7.0-1 is to be installed
              Depends: python:any (>= 2.7.5-5~)
 python-tz : Depends: python (< 2.8) but 3.7.0-1 is to be installed
 python-urllib3 : Depends: python:any (< 2.8)
                  Depends: python:any (>= 2.7.5-5~)
 samba : Depends: python (< 2.8) but 3.7.0-1 is to be installed
         Recommends: attr but it is not going to be installed
         Recommends: samba-dsdb-modules but it is not going to be installed
         Recommends: samba-vfs-modules but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

Running that scares me, so I chose no:
$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages will be REMOVED:
  iotop python-acme python-asn1crypto python-certifi python-cffi-backend python-chardet python-configparser python-crypto python-cryptography python-dnspython python-enum34 python-funcsigs python-future python-idna python-ipaddress
  python-josepy python-ldb python-mock python-openssl python-parsedatetime python-pbr python-pkg-resources python-pyicu python-requests python-requests-toolbelt python-rfc3339 python-samba python-setuptools python-six python-talloc
  python-tdb python-tz python-urllib3 samba samba-common-bin samba-libs
0 upgraded, 0 newly installed, 36 to remove and 0 not upgraded.
After this operation, 56.7 MB disk space will be freed.
Do you want to continue? [Y/n]

Is there any way to recover from this?
Thanks in advance!
Comment: `sudo apt-get dist-upgrade` would be my first choice.
Comment: @MichaelHampton Thanks for the suggestion, but it wants to do the same thing as `apt-get -f install`
Comment: It wanted to remove exactly the same set of packages? That doesn't make sense. Can you copy and paste the output you saw?
Comment: @MichaelHampton Sure thing: https://pastebin.com/HNvAuGWc
Comment: That's very different output, and it should also be in your question.
Answer: Normally an apt-get dist-upgrade will sort this out, by replacing packages with those in the actual apt sources you have enabled, but it doesn't seem to have done so this time on your system.
It looks like you're going to find a way need to reinstall the original Python package.
Fortunately you can do this by specifying the package version you want.
But first you have to figure out what that version is. For that, use apt policy. You should see something similar to this:
error@vmtest-ubuntu1604:~$ sudo apt policy python
python:
  Installed: 3.7.0-1
  Candidate: 2.7.12-1~16.04
  Version table:
 *** 2.7.12-1~16.04 500
        500 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     2.7.11-1 500
        500 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 Packages

Now that you have its version number, you can install it specifically:
error@vmtest-ubuntu1604:~$ sudo apt install python=2.7.12-1~16.04

(Don't use -f here, even if prompted.)
Comment: This worked perfectly! Thank you for an easy solution :)


tips for switching from g chord to c chord on guitar

Question: I've been playing guitar for about a month following Justin guitar's beginners course and I could do some basic chord changes quite fine but I find myself really struggling when I'm trying to change from a G chord to a C chord.
I've been trying to get it smoothly for about a week now trying different things but I still cant get it right. Any tips?
Comment: After about a month, it would be pretty amazing if you could change between these two chords really fast. Give it more time. When I have a moment, I will post an answer about a way to switch between these chords really fast, but it will take you a lot more than a week to get the method I will propose down also, so you just need to be patient and keep practicing.
Comment: It took me a few years before I could change at a speed I consider fast, so don't be concerned if this takes you some time
Comment: Practice moving one finger at a time. Place them in order starting with the lowest string. Examine the movement of each finger in turn. Do not attempt to place all the fingers at once. That'll happen naturally once you're comfortable,
Answer: The answers given so far offer excellent and accurate advice on learning chord changes in general!  But I will offer a tip that will help many beginning (and some experienced) guitarist with the specific change from G to C which is what your question is about.
I am not sure how you are fingering your G and C chords but there are several different ways to play a G chord in first (open) position as detailed here: How to Play a G Chord
Probably the most common way many beginner guitar course books and instructors teach the G chord is the formation and fingering shown below using the First (a/k/a index), Second (a/k/a middle) and 3rd (a/k/a ring) fingers (notated as 1,2 and 3 respectively).

From this G fingering - you must flip flop your entire hand from top to bottom to get to the most common first position C chord (pictured above).  With this G fingering - your first finger is at the bass end of the fretboard and the other fingers are below it and with the standard common C in first position your index finger is at the treble (opposite) end of the fretboard and the other fingers are above it.
This complete reversal requires a great deal of movement (fingers travel a great distance between chords) and although it is a very common transition, it may be one of the more difficult transitions to master effectively at any modicum of speed.
For that reason, I teach my beginning guitar students to play the G chord using their pinkie on the 3rd fret g of the high e string instead of their ring finger.  Your middle (2) and ring (3) finger are used to fret the two bass strings as shown in the diagram below.

When playing the G in this formation, you can hold your first finger directly above the first fret on the B string so that when you transition to the standard first position C chord you only have to move your first finger to the string and move your middle and index finger south by one string each.  Transitioning from this G fingering to the C chord requires very little movement and can be done very rapidly.
It's also easier to transition from the G major to the standard first position G7 when fingering the G chord with the pinkie on the e string.
 Image from tvonline12-2.besaba.com
Note that from the position shown in this picture, you can very easily transition from G to G7 or vice versa by alternating between your first finger on the first fret of the high e and your pinkie on the 3rd fret using an almost imperceptible amount of movement. Also notice that the first, second and third fingers are aligned the same way as they will be when playing a standard C chord and going from G to C will require only a slight shift from this position.
It is a little more difficult to play any chord using your pinkie in the beginning because the pinkie is a finger that we rarely use in every day life so it is weaker and less coordinated.  But the sooner you learn to start using your pinkie in chords, the faster you will progress as a guitar student.
One other "cheat" I often teach beginners to help get them playing two and three chord songs quickly so they are more encouraged to continue guitar lessons - is using the Cadd9 chord (as a substitute for C major) to G chord transition using a third way to play the G h.  This cheat only requires a very slight movement of two fingers to change from C (Cadd9 substitute) to G.
To try this chord transition (which actually sounds kind of cool and will usually work in place of a G to C) play the G using the fingering pictured below:

From this G you can easily transition to the Cadd9 (pictured above) simply by moving your first (index) and second (middle) fingers down slightly from the E and A string to the A and D string. Don't remove your 3rd (ring) and 4th (pinkie) fingers from the strings - just leave them right where they are.
The G to C / C to G transition described above (using a Cadd9 as a substitute for C major) might be one of the easiest transitions a beginning guitarist can learn and can get them playing two chord songs in the key of G or C right out of the gate.
It all takes practice but hopefully some of these tips will help you with the G to C transition.  Enjoy the journey!
Comment: @Basstickler Thanks for the comment.  I up-voted your answer before posting mine because you did an excellent job describing the frustration that is inherent in learning to contort your hands and fingers into very unnatural shapes in order to play guitar chord.
Comment: @jorS  My opinion is that practice sessions should incorporate several different exercises to prevent boredom.  I would suggest spending a portion of your practice time on some other changes as well - perhaps a G to D or C to D change.  If you can master all the changes between any (just one each) fingering of a G C and D chord, you will be able to play thousands of three chord songs in the key of G.  Add the easy Em chord and you can add another thousand 4 chord songs in G.  With a capo you can play those songs in many other keys as well.  Good luck and have fun.
Comment: @AlexMA I would not describe them as "stopgaps" or "best practices".  They are suggestions based on what works well for me.  Each guitarist will develop their own best practices based on what works for them.  A beginning guitar student should start with techniques that are widely recommended and later can experiment with other ideas.  As an experienced player, I am comfortable with many alternate fingerings of different chords and will use the version I feel fits best with whatever piece I am playing based on the context of how the chord fits in with other chords & other considerations.
Comment: Thanks for a very detailed answer! One question though, if i used that G chord fingering that you mentioned for a while then i got used to it, should i try to learn the "standard"  G chord fingering to C chord as well?
Comment: Great answer.  I totally support the OP's decision to change the accepted answer from mine to yours, as you offered much more specific advice to the question at hand, not to mention the addition of some charts/pictures, which is very helpful.
Comment: @jorS That's a great question.  The answer is absolutely, defiantly, yes!  You should endeavor to learn multiple ways to play many of the common chords and learning several ways to play a G chord in open position is no more difficult than learning any two distinct chords.  There will be situations in some songs or arrangements where the original fingering or voicing of the open G will work better.
Comment: Thanks for the great advice! I'm mostly just practicing this chord change lately and now i'm wondering if i should do anything else aside from this one or should I try to focus on this one before learning anything else?
Comment: Would you describe these tips as "stopgaps", or true "best practices" that one *should use* as an experienced player? I know there's no true right or wrong answer, but I'm curious if you have an opinion on this.
Answer: First finger the C chord.  Take as much time as you need.  Then move your fingers up and away from the fretboard and refinger the chord, trying to get all of your fingers hitting the frets accurately and all at the same time.  Start with a short distance and then gradually increase the distance until you can do it with all of your fingers fully extended at the beginning.  When you can do it with your fingers fully extended, then learn to do it as fast as you can.
Repeat this method with the G chord.
When you have mastered playing the G and C chords this way play alternating G and C chords with your fingers fully extended each time.  Then decrease the starting distance between your fingers and the fretboard until your fingers barely rise above the fingerboard.
Analysis:  For the first parts you are learning to hit each chord with all fingers at once instead of thinking about the placement of each finger.  Then you are transitioning between ending the first chord with your fingers fully extended and beginning the second chord with your fingers fully extended, something you've already mastered.  Then you learn to transition between chords with your fingers close to the fretboard, which now is giving you difficulty because you're having to stop and think about it.  With the chords firmly residing in muscle memory, your thinking block will be broken.
Answer: A few thoughts for you.  Learning to play chords on guitar doesn't really fit the mechanics that most people are used to with their hands.  Having difficulty with some chords (or chord voicings) after one month is not surprising or uncommon.
You could try arpeggiating the chords (playing out each note of the chord individually).  This would allow you to practice placing each finger individually.  You would want to make sure that you end up with all of the appropriate fingers held down at the same time so that you're not just practicing individual notes.  I would recommend doing this from the bottom up and the top down.  You could even do it from the middle outward, it's just a little less intuitive.  Ideally this will help your hands get used to the shapes and be more easily able to build them on demand; it's not intended to make the switching faster so much as the ability to form the chord faster, which will make it easier to switch quickly.
You can also try to slow things down a bit, which will give you a little more time to get your fingers in place.  In general, teachers always suggest moving the tempo around to get a better understanding of things and ingrain each aspect a little better by having a different context.  This is most typically applied to playing certain rhythms or fast melodic lines but could certainly be used in this setting as well.  They always say that if you can't play it slow, you can't really play it.
You can also work on adding a space between the two chords.  Similar to slowing things down, this gives you some room to move around.  It would be best to do this with a consistent tempo, so if you have a metronome, I would suggest using it (in general but specifically for this exercise).  I would recommend playing a chord for one beat, then resting for the next beat, then the next chord, followed by another rest.  I would start slower (maybe around 60 bpm), to give yourself more time, then increase the tempo incrementally. The idea here is that you have an allotted amount of time to get to the next chord, so you want to choose tempos that line up with your ability to switch.  If it's difficult for you to follow the beat that slow (which is common), you can try setting the tempo to twice that (120 bpm to start) and play each chord for two beats, then rest for two beats.
Since the mechanics of forming chords aren't intuitive, you should expect it to take a little time.  Make sure to practice regularly to get the fastest results and remember that practicing for long periods of time is not always better.  Practice smarter, not harder, as they say.  Basically practicing for too long will wear you out, especially as a beginner, and make things stick less well.  Practicing for 20 min a couple times a day will likely yield better results than practicing for 40 min once a day.
Comment: I guess i'm rushing things a little bit. I'm gonna try to slow my pace down and try to do as you said and yeah i do practice regularly and all i do is trying to do this chord change smoothly. What i've been doing is basically strumming 4 times then change to the next chord without trying to stop and slowly increasing my tempo. Is this the right way of practicing chord changes or am i doing it wrong?
Comment: You can also try some other chord transitions, like a progression where the chord transitions are a little easier for you.  That would allow you to get more practice with the shapes themselves without having to focus on the difficulty of this particular transition.  Maybe try D, C, D G or E minor, C, D, G.  You're basically trying to train your hands to move around to different shapes on demand, so as much as it may not seem to make sense, playing different chord shapes that come easier may actually improve those you find difficult. Similarly, practicing scales could improve your chords.
Comment: @jorS That is a good method in general, practicing slow and increasing tempo, but if you don't have a good grasp of the technique, then you often just end up frustrated.  I would also recommend adding some variation to your practice in some way.  Run scales a little, run chords a little, play melodies a little, etc.  You can take a day or session to work on a single thing but if you're not feeling any progress over time, then you're not practicing effectively. This is hard to measure as a beginner, since you don't have an accurate concept of how long something should take to learn.
Answer: I don't think one should really get stuck into learning one specific way to switch from one chord to another. I'm self taught and playing for a year now, so my methods may not be the best, but here are my take on this:
One thing that I have learned is to not get stuck on one shape to play a chord or a specific way to change between chords. This can cramp your style and again make other chord changes a challange. There are some considerations that you need take into account when changing between chords, like what is the preceding chord, next chord and what type of embellishment do you want to apply to the current chord being played, and most importantly, what is more comfortable for you and what works for you with the least amount of effort. I think most entry level chord books comes with one basic fingering for a chord which beginners think is the alpha and omega. One need to remember, there is no wrong way to finger a chord, and that is also not the only way to play a chord.
Lets look at the G chord. I play my G, by default, the four finger way with my ring and pinky on the third frets of the B and high E strings. I also alternatively play it the three finger way with my pinky on third fret high E. This always leaves my index finger in a position for emballishing the G chord. Which G shape I'm using is almost always dependant on the preceding chord. When coming from something like a D chord, I use the 4 finger G (works great when moving from G to Cadd9), and when coming from an open F chord or a C chord, I use the three finger G (this finger pattern also works great when moving from G to G7). When coming from E, Em, A or Am, I tend to alternate depending on the next chord, so if C is the next chord after G, I will use the three finger G then. (As an extra, if I come from a full F barre chord, I tend to slight up a whole step to a full barre G chord)
So, when I move from G to C, I could be coming from a full G barre chord, 3 finger G or a 4 finger G depending on the chord that came before that. So, for me, there is no predefined way of moving from a G to a C.
What is important is your wrist position when forming the C chord, whether or not you are coming from a G or not. I remember seeing a tutorial by Marty Swartz (I think it was for Linger by the Cranberries). In that video, he gave a tip that, when forming a C chord, one should use your ring finger as an anchor. As beginner, this should be your leading finger, the first finger that you should get down. With your ring finger down, your wrist is stabilized and cannot swivel around, this also positions your wrist perfectly. It is then just basically a matter of fretting your 2 remaining fingers. I think that when you can really master a C chord this way, it would be much easier to switch to a C from any other chord.
To conclude, the only real way to learn is to practice. I really put a lot of time into practicing. Get yourself a few easy beginner songs with easy chord changes. Being a Nirvana fan, I chose a lot of their songs, most of then is really easy to play, specially on acoustic. For me, this is still a fun way to learn new tricks, and what is really nice is, at the end of the day, while learning something like chord changes, you also learn to play some of your favorite songs, which in turn can be great fun around the braai or campfire.
Good luck and have fun, and never ever give up if you do not immediately succeed. Your favorite guitarplayer was also a beginner, just like you, which had the same issues as you. What made him where he is today, was (and still is) lots of practice and never giving up
Answer: First of all there is more than one way to finger each chord so commit to one and learn that smoothly before moving on to others.
If you are a beginner you need to know that it takes a lot of time to build muscle memory and good technique.  And that is what you should focus on, good technique.
The chord form on the accepted answer is not the best, nor is it the only version of an open string G maj chord.  Also, no offense, the pic of the hand position is terrible.  This is not a good way to hold the guitar neck.
If you are fingering the C chord (x, 3, 2, 0, 1, 0) where numbers here are fingers (which also happen to match fret number in this case) then an easy transition to G maj would be (3, 2, 0, 0, 0, 4) on frets (3, 2, 0, 0, 0, 3).  When playing the C chord the pinky should already be floating over the 3rd fret.  All you need to do is move the two fingers (3, 2) from the (A, D) strings to the (E, A) strings, then lift the index finger from the C chord and place the pinky down.  Even though it seems easy it still takes time to learn to move the two fingers in sync.
A perhaps little known concept is that many chords (especially those used in a key for progressions) have similar fingerings.  There will likely be a fixed finger, about which the others move, or there is a common form that just gets moved around.
The pair of fingers (3, 2) placed in the 3rd and 2nd frets of consecutive strings are part of 5 different chords in open position.  A list is provided below.
(3, 2) on (E, A) --> G maj (3, 2, 0, 0, 0, 4)
(3, 2) on (A, D) --> C maj (x, 3, 2, 0, 1, 0)
(3, 2) on (D, G) --> F maj (x, x, 3, 2, 1, 1)
(3, 2) on (G, B) --> Bb min (x, x, x, 3, 2, 1)
(3, 2) on (B, e) --> D maj (x, x, 0, 1, 3, 2)
Once you see that pattern I'd recommend just practicing moving the (3, 2) pair across the strings to different chords, like C --> F --> G --> C, etc.
Once this is in the muscle memory put the other finger in place.  The hand should be relaxed, thumb behind the neck, palm NOT touching the neck.
When playing a G7 chord in a C maj progression life is even easier since the fingering for G7 is (3, 2, 0, 0, 0, 1).  This is the exact same shape as the C maj chord just "opened up", moving (3, 2) down a string and 1 up a string (down/up in terms of pitch).
In this manner the entire I --> VI --> V7 group in C maj has a single fingering with (3, 2, 1) in a diagonal shape for all.
As for moving quickly you will need to be capable of forming the chord correctly first.  Then I'd recommend the following, give yourself 4 beats on a metronome as a slow tempo.  Play chord 1 on the first beat of a group of 4 (4/4 time).  Allow yourself the next three beats to get to the next chord comfortably and prepare.  Then on beat 1 of the next measure play chord 2.
I teach my students something like this...
On beats (1, 2, 3, 4) do the following (Play, mute, move to next chord, nothing), repeat
It may seem pedantic but it works, and gets results fast.  Once you can play the chords back and forth don't speed up the metronome, but take beats away from your transition time and put it on your chord time.  So, play chord 1 for 2 beats, then release, move, and set in 2 beats.  Then play chord for 3 beats, and execute the other tasks in 1.  After a few rounds you will find that you can execute the movement to the next chord in a fraction of a beat (the goal).


Understand group extensions

Question: I will try to explain what I know so far (not certain is it right though):

A group extension is denoted by $G = N.Q$ or $N:Q$ (the second case is a semidirect product) I think this just means $G/N \unlhd Q$. but it is not fully specified by this, you also have to give an action of $Q$ on $N$.

now what I want to ask is what are the basic important facts that are useful to know about $G$ we can deduce from knowing about $N$ and $Q$ but not knowing the action?
Comment: If we know the action is fixed point free, but nothing more than that, then $G=N:Q$ is a Frobenius group with kernel $N$ and complement $Q$, and we've got that $N$ is nilpotent and each Sylow subgroup of $Q$ are either cyclic or generalized quaternion.  There is in general more than one possible fixed point free automorphism to pick for the semidirect product, so we don't need to know the exact action here.
Comment: I'd start with a finite group theory book (I like Isaacs) since finite group extensions are currently a little better understood.  Also [here](http://sierra.nmsu.edu/morandi/notes/GroupExtensions.pdf) is a neat little survey article about them.  Group extensions are a pretty broad topic, though.  Is there anything in particular you want to know about them?
Comment: Where can I learn more about group extensions?
Answer: In finite group theory, we can get a basic important fact without knowing the action: Order.
$$ \lvert G \rvert = \lvert G/N \rvert \lvert N \rvert = \lvert Q \rvert \lvert N \rvert. $$
And subgroups of $N$ and $Q$ are embedded into $G$, so we know its subgroups structure a little.

Understand group extensions


Detect that statusBar had collapsed

Question: I implemented in my app button that expand statusBar although the statusBar is hidden. for achive this I do this inside OnClick:
<code>@Override
 public void onClick(View view) {
    Utils.showTitleBar(ctx, false);
    Utils.setNotification(ctx);
}
</code>
This work well, however, i want to hide statusBar when the statusBar collaps, and to achive this, i implements this:
<code>@Override
    public void onWindowFocusChanged(boolean hasFocus) {
        Log.i("TAG", "  boolen:" + Boolean.toString(hasFocus));
        if (hasFocus && pref.getBoolean("belStatus", false))
            Utils.showTitleBar(ctx, true);
    }
</code>
This work fine too but just one time. in the next time that I press on the Button and expand the statusBar, when I collapse it, the 'onWindowDocousChanged' never called anymore so the statusBar remain.
So, there is another way to detect that statusBar collapsed? Or someone could help me figure why the 'onWindowFocousChanged' not called in second time?
If it help the method I using is those:
<code> public static void setNotification(Context ctx){
        Object sbservice = ctx.getSystemService( "statusbar" );
        Class<?> statusbarManager;
        try {
            statusbarManager = Class.forName("android.app.StatusBarManager");
            Method showsb;
            if (Build.VERSION.SDK_INT >= 17) {
                showsb = statusbarManager.getMethod("expandNotificationsPanel");
            }
            else {
                showsb = statusbarManager.getMethod("expand");
            }
            showsb.invoke( sbservice );
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }

 public static void showBelTitleBar(MainActivity ctx, boolean show){
        View status = ctx.findViewById(R.id.status_bar);
        if (show) {
            if (Build.VERSION.SDK_INT < 16) {
                ctx.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                        WindowManager.LayoutParams.FLAG_FULLSCREEN);
            } else {
                ctx.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
            }

        } else {
            if (Build.VERSION.SDK_INT < 16) {
                ctx.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
            } else {
                ctx.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
            }
        }

    }
</code>
Answer: If it will help someone, I achieved my goal by adding some delay to the opening of the notification bar. this way the onWindowFocusChanged() method always called as needed.
So now my code implemented this way:
<code>findViewById(R.id.status_bar).setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent e) {
                Utils.showBelTitleBar(ctx, false, updateClkBtry, handler);
                ctx.handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        Utils.setNotification(ctx);
                    }
                }, 100);
                return false;
            }
        });
</code>

Detect that statusBar had collapsed


Obtaining exit code from schtasks

Question: I'm trying to start a scheduled task from a Powershell script, like this:
schtasks /Run /TN "Test" > nul

I'm testing as I go, so I've set up the task to call a batch file that intentionally does not exist.
Once this happens, I see on the next line of code that the error level was 0, despite seeing 0x1 in the Task Scheduler's Last Run Result column.
In the console, I see
SUCCESS: Attempted to run the scheduled task "Test"

This looks to me as though it's considering the launch successful, and not waiting around to capture the error reported to Task Scheduler. (0x1)
How can I detect this error in Powershell?
Answer: I seem to remember that schtasks.exe just instructs the the task scheduler to go run a job and immediately exists without waiting around. Hence it always  returning 0 unless the task itself can't be found (exit code: 1) or something catastrophic happens (exit code: no idea).
If you want to get the "Last Run Result" you'll need to query the task, for example:
schtasks.exe /v /query /tn "A Real Task" /fo list

This will return the task details including its run status as a list of fields and values which will include the "Last Run Result".
To see more formatting options run:
schtasks.exe /query /?

So you could capture data about a task (in this case CSV formatted) by doing:
$taskinfo = schtasks.exe /query /tn "A Real Task" /FO CSV /V

...then process it in some way. Obviously you'd need to check the task's run status to make sure it's completed before reading the "Last Run Result".
Comment: For anyone seeing this on a search result, the "last run result" can be parsed into a variable by following the instructions at http://serverfault.com/questions/436720/is-it-possible-for-a-powershell-script-to-return-the-last-run-result-from-window
Comment: @iank - yes, I was going to add a bit about that, but it was way past my bedtime :)

Obtaining exit code from schtasks


Proof about n x n matrices and determinants

Question: Prove.
Let $X$ and $P $ be $n \times n $ matrices with $P$ invertible; let $A = PXP^{-1}$.
Then, det $A =$ det $X$, and $A^3 = PX^3P^{-1}$.
Comment: What have you tried so far?
Comment: $A^3=(PXP^{-1})(PXP^{-1})(PXP^{-1})=?$
Comment: $X$ and $A$ are [similar](https://en.wikipedia.org/wiki/Matrix_similarity) matrices
Answer: Hint for det $A$= det $X$:
The determinant of a product is the product of the determinants.
Hint for $A^3=PX^3P^{-1}$:
$A^3=(PXP^{-1})(PXP^{-1})(PXP^{-1})$.  Use the associative property and note $P^{-1}PX=IX=X$.


Como aumentar limite de memória de um processo?

Question: Existe uma maneira de ilimitar a memória utilizada por um processo no Ubuntu?
Answer: Voce pode usar o comando
<code>ulimit -v unlimited
</code>
antes de chamar o processo. Veja também se há alguma restrição no arquivo /etc/security/limits.conf . Isso vai ilimitar o uso de memória virtual. Aparentemente não há como setar uma restrição para memória residente se você não estiver escrevendo o próprio código do programa.
Fonte: https://unix.stackexchange.com/questions/32368/how-to-limit-application-memory-usage


Drupal Time field for hour:minute:second.tenth of a second

Question: Is there a drupal field type to represent time for athletics sports events. e.g. for 100m sprint: 10.42 seconds but for 800m 1:40.89 (1 minute, 40.89 seconds)
In the format : hour:minute:second.tenth of a second
Comment: I finally got around to getting my sandboxed project promoted to a full project:  https://www.drupal.org/project/racetime
Comment: I created a project to do the same thing. It's currently in the review process and as soon as it's been approved, I'll send you the link.
Comment: The module Robbert referred to is still a sandbox available from https://www.drupal.org/sandbox/robbertv/2158841, but hasn't been thoroughly reviewed or promoted to a full module yet.  I still haven't been able to find a good solution for this.
Answer: No time field will give you what you are looking for. They all work with Unix time, which is defined as 'the number of seconds since midnight, January 1, 1970'. The maximum granularity you will see is one second.
If you wish to record this information to one one-hundredth of a second, you will need to define the field and its formatting yourself.
Answer: Not sure if this module does what you need. But http://drupal.org/project/cck_time may work if it allows you to create a format using PHP. There is also

http://drupal.org/project/time_entry
Answer: Checkout this module HMS Field

Displays a integer formatted as Hours, Minutes or Seconds.
  The field stores values as integer. Both input and output can be formatted as Hours, Minutes and/or Seconds. Alter functions provides developers a way to add their own format.
Comment: This doesn't support tenth of seconds as required by the OP
Answer: This is currently being developed too: https://www.drupal.org/project/timeperiod


Retrieve Webform submission data from database

Question: Here's a little background on my project: I have 10 or so webforms let's call them Forms A thru J which are for different departments of a college.  I also, have 1 credit card processing form let's call Form Z.  I will be collecting information from a form like Form A specific to that departments needs and upon submission will redirect the user to Form Z to process a credit card transaction.  I have created a webform handler to redirect the user from Forms A-J to Form Z and a handler to process the credit card transaction.  In the redirect handler I am able to pass all of the information from Forms A-J to Form Z using the query string in the URL.  I want to avoid this since there would be Personal Identifiable Information (PII) being passed through the URL.
I want to be able to retrieve the data submitted on say Form A from the database when Form Z is loading.  I should be able to pass the webform node ID and submission ID to Form Z through the URL query string and use them to get the data from the database.  I found these posts which give me an idea of how to retrieve the data from the database:
Programmatically update Webform Submission by sid
Load webform submission
https://www.drupal.org/project/webform/issues/2911356
What I can't find is how do I get this to run when Form Z is loading.  I've seen a couple of posts on hook_form_alter but those posts are using it in a different way from what I am trying to do so I don't know it that's the way I need to go.
Once I retrieve the data from the database I need to populate that data into I'm thinking some hidden webform fields on Form Z.  I'd like to be able to fill billing address with the address submitted with the previous form upon request (checkbox or button).  Also, I need to be able to have the data from the previous form available once Form Z submits so that I can send a custom email Confirmation depending on which form the information came from (i.e. Form A or B or J).
Being new to drupal development I've gotten some great assistance with this project from this site and I am very grateful to those who have been assisting me.  :)
EDIT:
So based on Remy's recommendations I have created a custom module with these two files in \modules\custom\cc_processing_getsubmissiondata:
cc_processing_getsubmissiondata.info.yml
name: 'CC Processing Get SubmissionData'
description: 'Provides a custom webform handler for retrieving the previous forms submission data'
core_version_requirement: ^8.8
Core: 8.x
package: Custom
type: module

CCProcessingGetSubmissionData.module
<?php

/**
 * Implementation of hook_form_alter
 */

 use Drupal\Core\Form\FormStateInterface;

 function CCProcessingGetSubmissionData_form_alter(&$form, FormStateInterface $form_state, $form_id) {
    echo "form alter hook triggered";
        $form['street_1'] = '92-2000 Some Rd.';

    if($form['#webform_id'] == 'credit_card_billing_information') {
        echo "form alter form id found";
        $form['credit_card_name'] = 'Jared';
    }
 }

At this stage I am just trying to get the hook_form_alter to just do something so that I know it is being triggered.  However, I am getting nothing.  I even tried the function name CCProcessingGetSubmissionData_webform_credit_card_billing_information_form_alter but that didn't work either.  Any suggestions?
Comment: Try a multi-step (wizard) form ;) - https://www.drupal.org/docs/8/modules/webform/webform-features#s-form-settings
Comment: If at all possible I want to keep the process as object oriented as possible.  Using multi-step (wizard) form, I'd have a credit card processing step on every form on Forms A-J.  That number could grow in the future which just means if I needed to make any modifications to the credit card processing step, I'd have to do it 10+ times for each form.
Comment: There are nice yaml import and export features ;)
Answer: Easiest is probably to preprocess the webform's new submission, load the desired submission, and then pre-populate your fields. I doubt that this is built-in.
fe
<?php
function HOOK_webform_submission_form_alter(array &$form, FormStateInterface $form_state, $form_id) {
  if ($form['#webform_id'] == 'your_webfom') {
    $form['elements']['your_element']['#default_value'] = $your_value;
  }
}

There may be several ways by not-coding, but using modules.
LMGTFY - https://www.drupal.org/forum/support/post-installation/2021-02-01/how-to-use-webforms-submissions-in-other-forms

Install the 'Webform Views Integration' module.
Create the view for display submissions of the 'Client' webform.
Add to the view the 'Entity Reference' display and add the 'Name' field (or any field you want to see on the 'Project' webform).
Click on the 'Settings' and check the field that will use for serach.
In the 'Client' webform select the following reference method: 'View: Filter by an entity reference view'.
Select the view created by you from the 'View used to select the entities' list.

The screenshots of the example:

https://ibb.co/ZJxgK9w
https://ibb.co/C6sxCFv
https://ibb.co/mFWDCTX
https://ibb.co/QcwYYm6
Comment: So there's 2 reasons this won't work for us.  First, this seems like it would populate a dropdown list on Form Z with the names or some field from lets say Form A.  Then on Form Z the user would have to select their name in the dropdown list to populate the fields in Form Z.  This won't work because that would mean anyone could select any name in the dropdown list thus exposing the PII I am trying to avoid exposing in the URL.  I would be better off using the URL query string.  Secondly, those who control our Drupal installation won't approve use of a module that hasn't already passed release.
Comment: As you seem to be sophisticated team, go for the pre-population approach - see my updates.


Custom text in volta with Lilypond

Question: I'm trying to put custom text in voltas when engraving with Lilypond. The problem is not adding text, but adding it with the formatting I want. I am aware that a similar question was asked and answered (Markup text inside second volta bracket) but it doesn't answer my problem because the result is really ugly. It's what I already have, except the method is different; I tried it, so expect if I did something wrong, it's not what I want.
What I have for now looks like:

The idea is that the text in the voltas would rather look like the text I put under the B and the C in the first two measures.
My code for now is :
\version "2.20.0"

aaaa = _\markup { \italic \teeny "Suite" }

bbbb = \tweak DynamicText.self-alignment-X #LEFT
    #(make-dynamic-script
        (markup
            #:with-dimensions '(0 . 5) '(0 . 0) #:line
            (#:normal-text #:italic #:teeny "Fin")))

pianoUpper = \relative c' {
    \override DynamicLineSpanner.staff-padding = #3
    \clef "treble"
    \key f \major

    bes1 \bbbb
    \set Score.repeatCommands = #'((volta "Suite"))
    c \aaaa
    \set Score.repeatCommands = #'((volta #f))
    \bar "||"
    \set Score.repeatCommands = #'((volta "Fin"))
    d
    \set Score.repeatCommands = #'((volta #f))
    \bar "||"
    e_"D.S. al Fine"
    \bar "S-S"
    \break
}

pianoLower = \relative c {
    \clef "bass"
    \key f \major

}

\score {
    \new PianoStaff
        <<
            \new Staff = "upper" {
                \pianoUpper
            }
            \new Staff = "lower" {
                \pianoLower
            }
        >>
}

How can I get formatting (italics) in the volta bracket text?
Answer: This seems to work. Just don't put anything before \text. Modified
\set Score.repeatCommands = #(list(list 'volta finVoltaTxt) 'end-repeat) to same form as \set Score.repeatCommands = #(list(list 'volta suiteVoltaTxt)) because the two variables suiteVoltaTxt and finVoltaTxt should really be together; not one done one way, the other done another way.
suiteVoltaTxt = \markup { \text \italic Suite}
finVoltaTxt = \markup { \text \italic Fin}

pianoUpper = \relative c' {
  \key f \major
  \time 4/4

   bes1
   \set Score.repeatCommands = #(list(list 'volta suiteVoltaTxt))
   c1
   \set Score.repeatCommands = #(list(list 'volta finVoltaTxt) 'end-repeat)
   d1
   \set Score.repeatCommands = #'((volta #f))
   e |

}

Custom text in volta with Lilypond


Filling a 3d array

Question: My problem is in the last method "Printhands", I am trying to pass value from the 2d array called hands to the 3d array called fourDecks. I managed to pass the 1st dimesional array deckOfCard to the 2d array hands but the method doesn't seem to work for 3d array.And Also its a must I use 3d array no other choice...TY.
import java.util.Random;

public class Decks {

public static void main(String[] args) {

    int[] deckOfCard = new int[52];
    int[][] hands = new int[4][13];
     int [][][]fourDecks = new int[4][4][13];
    generateCard(deckOfCard);
    printCard(deckOfCard, 13, 5);
    deal(deckOfCard, hands);

}

public static void generateCard(int deckOfCard[]) {

    boolean[] check = new boolean[52];
    int all = 0;
    int ranNum;

    while (all < 52) {
        ranNum = (int) (Math.random() * 52);
        if (!check[ranNum]) {
            check[ranNum] = true;
            deckOfCard[all] = ranNum;
            all++;
        }
    }
}

public static void printCard(int deckOfCard[], int row, int space) {
    System.out.println("Print Card:");
    int num = 0;
    for (int print = 0; print < deckOfCard.length; print++) {
        String format = "%" + space + "s";
        System.out.printf(format, deckOfCard[print]);
        num++;
        if (num == row) {
            System.out.println();
            num = 0;
        }
    }
}

public static void deal(int deckOfCard[], int hands[][]) {
    System.out.println("DEAL:");
    int x = 0;
    for (int row = 0; row < hands.length; row++) {
        for (int col = 0; col < hands[row].length; col++) {
            if (x < deckOfCard.length) {
                hands[row][col] = deckOfCard[x];
                x++;

            }
        }
    }

    for (int i = 0; i < hands.length; i++) {
        for (int j = 0; j < hands[i].length; j++) {

            System.out.print(hands[i][j] + "  ");
        }
        System.out.println();
    }
}

public static void PrintHands(String fourDecks[][][], int hands[][] ) {

     String[] suits = {"Spades", "Hearts", "Diamonds", "Clubs"};
        String[] ranks = {"Ace", "2", "3", "4", "5", "6", "7", "8", "9",
          "10", "Jack", "Queen", "King"};

    for (int deck = 0; deck < fourDecks.length; deck++) {
        for (int row = 0; row < fourDecks[deck].length; row++) {
            for (int col = 0; col < fourDecks[deck][row].length; col++) {

                for(int z = 0; z < hands.length; z++){

                    for(int y = 0; y<hands[z].length;z++){

                        fourDecks[deck][row][col] = hands[z][y];
                    }
                }

            }
        }
    }
}}

Answer: Error is here:
fourDecks[deck][row][col] = hands[z][y];

you are trying to assign integer value to a string
use Integer.toString() or something like that
Answer: This is error in logic
for(int z = 0; z < hands.length; z++){

                for(int y = 0; y<hands[z].length;z++){

                    fourDecks[deck][row][col] = hands[z][y];
                }

You keep assigning hands[z][y] to the same location in fourDecks - the fourDecks indices dont advance so only the last z, y will be kept.

Filling a 3d array


Will image styles be applied when they do not logically apply?

Question: I have a set of biography images in the site I'm working on, and I have an image style that will enforce the correct size for these.   Of course I'd rather not have them resized if they don't need it, so I'm wondering if the resize & crop effect will be skipped if the image is already the perfect size.
In other words, if the image is 130 x 170, and the effect of the image style would be to resize & crop it to make it 130 x 170, will the Image module be clever enough to skip that effect and leave it alone (so as not to degrade quality)?
If it will process the image anyway, then obviously I'll want to simply display the original image.  It would be very useful if the module were clever enough to know when not to run, so the image style could be there as a failsafe in case some future content editor is too lazy to crop the images beforehand.
Answer: It is all up to the PHP toolkit used to manipulate images. The code that is executed from the image effect is the following one. (See image_scale_and_crop_effect().)
function image_scale_and_crop(stdClass $image, $width, $height) {
  $scale = max($width / $image->info['width'], $height / $image->info['height']);
  $x = ($image->info['width'] * $scale - $width) / 2;
  $y = ($image->info['height'] * $scale - $height) / 2;

  if (image_resize($image, $image->info['width'] * $scale, $image->info['height'] * $scale)) {
    return image_crop($image, $x, $y, $width, $height);
  }
  return FALSE;
}

The IF-statement is only used because image_resize() can return FALSE if the PHP image toolkit doesn't support the operation being executed on the image. The function called from image_size() (image_toolkit_invoke()) is generic, and it doesn't make assumptions about the operations currently enabled from the selected image toolkit.
Comment: Yes you're right.  I realized there was a way I could test this: I set my JPEG quality down to 5%, and worked around the bugs with image styles by adding then removing an effect, then viewed the results: terrible quality, confirming the images were all processed even though they didn't need to be.   It would be really nice if the Image module provided a way to say "only run this effect IF the size is not already x,y"..... so I guess it's time to make a feature request...


How can I disable TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 cipher in Apache2?

Question: In SSL labs, I got that I'm using this "weak cipher":
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384

Now in Apache, this is the set of suites I have enabled:
SSLCipherSuite ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384

To that list above, I tried adding !ECDHE-RSA-AES256-CBC-SHA384, but that didn't help. I also tried adding !CBC, and that doesn't fix the problem in SSL Labs either. What should I do to disable this cipher?
I'm on Debian Buster. The Apache version I'm using is 2.4.38-3+deb10u3. Everything is up-to-date.
Answer: The cipher suite you are trying to remove is called ECDHE-RSA-AES256-SHA384 by openssl.
Whenever in your list of ciphers appears AES256 not followed by GCM, it means the server will use AES in Cipher Block Chaining mode. This cipher is by no means broken or weak (especially when used with a good hash function like the SHA-2 variants you have in your list). It is just less recommended than Galois Counter Mode.
Before manually choosing your ciphers your should read Mozilla's Server Side TLS page to make an aware choice. E.g. Debian 8 is just 4 years old and it doesn't have openssl version 1.1.
Once you edit your list of cipher suites as you like, you can test the result with:
openssl ciphers -v 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384'

Comment: Thank you. That works! I think they don't prefer CBC cipher mode because it doesn't have authentication, so it might cause problems. I, personally, don't use any encryption without authentication anymore.


How to get a node in a tree by its label in nltk python?

Question: I have a tree:
<code>(S
    (WH-QUERY Which)
    (FLIGHT-NP
        (FLIGHT-CNP
            (FLIGHT-CNP (FLIGHT-N flight))
            (FLIGHT-DEST to (CITY-NP (CITY-NAME Hue) (CITY-N city)))))
    (FLIGHT-VP
        (FLIGHT-V arrives)
        (FLIGHT-TIME (P-TIME at) (TIME-MOD 20:00HR))))
</code>
I want to get a specific node by its label in nltk. For example, I have label "CITY-NAME", and I want to get the node (CITY-NAM Hue). How can I achieve this?
Answer: One way to do it is to walk the tree searching for nodes that match:
<code>for subtree in tree.subtrees():
     if subtree.label() == 'CITY-NAME':
          print subtree.leaves()
</code>
Answer: Look at the  _get_node method in the function.
http://www.nltk.org/_modules/nltk/tree.html
Comment: `_get_node()` has been replaced with `label()`, and that tells you the label of a tree.  It doesn't find a tree by its label.


Gerenciamento de vetores na memória do programa em Java

Question: Boa tarde galera, estou com uma dificuldade em alguns pontos em um desafio da faculdade. Bem, a ideia é fazer com que eu adicione e remova elementos de uma lista estática, porem de forma que eu aumente e diminua o tamanho dela (resumidamente fazer a variável apontar para outro vetor de tamanho diferente), mas foi ai que achei o problema, fico preocupado com o consumo de memória com o tempo, se caso adicione e remova muuitos elementos, não consigo pensar em uma forma de otimizar bem essa memória.
Comment: Se vai criar outro array, basta descartar o anterior, que o garbage collector se encarrega de limpá-lo da memória. Aliás, a ideia de usar Java (e qualquer outra linguagem com gerenciamento automático de memória) é justamente não ter que se preocupar com isso (na verdade as preocupações são diferentes, mas não vem ao caso).
Answer: acredito que vc nao precisa se preocupar com isso agora, o garbage collector do java pode cuidar da memoria para voce. Da uma pesquisada sobre isso, mas talvez se esse vetor precisar armazenar uma grande quantidade de dados, talvez voce precise mesmo ve uma forma de otimizar esse gerenciamento de memória


use xmlrpc to authenticate and create a node via services module 3.x and drupal 7

Question: I want to use services module 3.x, drupal 7 and xmlrpc to create a node from a php client. However, I don't know how to deal with the authentication. I enable the session authentication but I don't know what I should do and I get error: HTTP/1.0 401 Unauthorized: Access denied for user anonymous.
ps: I can get session name and session id from user.login
Comment: change permissions for anonymous user and check again
Answer: Note: this is valid after SERVICES 3.5 (lower version are deprecated, anyway)
<code>// USER LOGIN
$authenticate = xmlrpc($settings['server'], Array('user.login' => array($settings['user'] , $settings['password']),));

// CREATE HEADERS
$options['headers']['Cookie'] = $authenticate['session_name'] . '=' . $authenticate['sessid'];

// GET TOKEN
$token = xmlrpc(url($this->endpoint, array('absolute' => TRUE)), array('user.token' => array()), $this->headers);

//INSERT TOKEN INTO HEADERS
$options['headers']['X-CSRF-Token'] = $token['token'];
</code>
At this point you should be authenticated and could create nodes at will.
Answer: Please go through the below given link and I am sure it will help
How do I POST a new node using the Services module?
Before doing please read https://drupal.org/node/1354202
Services 3 - POST node.create with custom fields ...test your services first on various tools. link browser add-ons and other apps. after that you can use this services in any flatforms like PHP, JAVA ....etc
Answer: As you said After logging in using web service ,you are getting a response with session name and session id.For making a request to create a node ,you should specify the session name and session id in the header of the request.
The session name and id are used for authentication,If it does not match with the current session,then you will not be authorized


Apache RewriteEngine afetando tomcat - Ubuntu 16 server

Question: Estou com o seguinte problema.
Configurei o arquivo htaccess para que todas requisições sejam redirecionadas para utilização de ssl (https). Até então tudo funcionou corretamente, porém recentemente instalei o Tomcat no servidor e precisei "ignorar" o redirecionamento no caso de acesso pela porta 8080 (porta padrão do tomcat), modifiquei o arquivo htaccess da seguinte forma:
RewriteEngine On

# Redirect all HTTP traffic to HTTPS.
RewriteCond %{HTTPS} !=on
RewriteCond "%{SERVER_PORT}" "!^8080$"
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [L,NC,R]

# Send / to /roundcube.
RewriteRule ^/?$ /roundcube [L]

Porém ao tentar acessar o dominio pelo navegador na porta 8080 "my.hostname.com.br:8080" ele reescreve a URL para "https://my.hostname.com.br:8080" gostaria que neste caso especifico nao houvesse nenhuma alteração ou seja quando acessado "my.hostname.com.br:8080" apenas acesse "http://my.hostname.com.br:8080" normalmente.
Como devo proceder?
Comment: Solução que encontrei foi criar um novo subdominio
Answer: Após criado um novo subdomínio consegui fazer a configuração especifica do rewrite específica para o subdominio.
no arquivo "/etc/apache2/sites-enabled/000-default.conf" inclui a seguinte tratativa.
<VirtualHost *:80>
        ServerName tomcat.mydomain.com

        ServerAdmin firstname.lastname@example.com
        LogLevel warn
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

RewriteEngine on
RewriteCond %{SERVER_NAME} =tomcat.mydomain.com
RewriteRule ^ http://%{SERVER_NAME}:8080%{REQUEST_URI}
</VirtualHost>

Para mim resolveu, pois utilizar outro subdomínio exclusivo par ao tomcat ficou até melhor para mim.


Fresh CentOS 7.2 VM hangs before asking for drive password after initial yum update and subsequent crash

Question: Sequence of events:

Start install CentOs 7.2 using Everything ISO in Vmware vSphere 5.5
Choose Server with Gui, manual partitioning, encrypted sdd contains /home, /data
Initial boot is great, fast, works; requests partition password, login with password
Start terminal, run yum update and then yum upgrade -y (I know wrong order)
Do other stuff, eventually it HANGS in VMRC console, and I reboot gracefully with guest tools shutdown
On restart, GRUB2 has two kernels to choose, either one has same result
In either case, hangs before requesting partition password, eventually times out during plymouth and I get dracut shell

It warns me that there is no swap partition detected at /dev/mapper/swap.  Note that I put swap to cover the entire sdc on its own, so it takes most of the space.
I am so lost, so any help is appreciated.
Comment: Reboot, and this time _remove_ the words `rhgb quiet` from the kernel command line. Try booting again without these. You should see some additional information on screen which may be helpful to resolving the problem.
Answer: So you're dropped into the initramfs shell. That's a very useful diagnostic tool.
You need to know what block abstraction system is backing your root volume. It's it lvm, or just a partition? Also, what filesystem is it? This is important, as getting dropped to the initramfs shell is almost always due to a failure to discover the root filesystem as defined in the kernel args passed by the grub (either because the path to the root filesystem is wrong, or because Dracut made an initramfs without the tools needed to mount it, such as lacking btrfs or lvm modules).
/dev/mapper/swap seems wrong, or at least not lvm. Is it encrypted?
You should have some basic commands in the Dracut shell that will help you gather all of this information. Some possible ones are:
'df -h'
'mount'
'blkid'
'lsblk'
'lvm'
The lvm command will open an lvm shell that should give you access to all of the typical lvm commands.
Also provide your boot time arguments from the 'linux' line in your grub boot menu entry so I can see what we're trying to mount.
I'll adjust my answer as more information comes in. I suppose screen shots are the best you can provide, but any information will help,  ESPECIALLY any info regarding how things are meant to be laid out on your disks.


Smaller model number and larger stepping value mean newer CPU version in /proc/cpuinfo in Linux?

Question: I am checking the CPU information on two Linux VMs, on one VM, I see:
processor       : 1
vendor_id       : GenuineIntel
cpu family      : 6
model           : 37
model name      : Intel(R) Xeon(R) CPU E5-2680 0 @ 2.70GHz
stepping        : 1
cpu MHz         : 2699.999
cache size      : 20480 KB
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes

On another one, I see:
processor       : 1
vendor_id       : GenuineIntel
cpu family      : 6
model           : 26
model name      : Intel(R) Xeon(R) CPU E5-2680 0 @ 2.70GHz
stepping        : 4
cpu MHz         : 2700.000
cache size      : 20480 KB
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes

May I ask if smaller model number and larger stepping value mean newer CPU version?
Answer: Model is the model number of the CPU.
Stepping is the incremental version number of the CPU.
Comment: @zhengyu Model numbers tend to include more significant digits which *usually* increase over time with the less significant digits used to define specific SKUs (differing in frequency, core count, cache size, etc.). Stepping refers to a small change in the design commonly to fix behavioral issues (bugs) or to make minor improvements. Stepping is *roughly* comparable to sub-minor version in software, while model number combines branding (cf. Windows XP), SKU (cf. Home vs. Professional), and higher order version number.
Comment: Thanks, so larger stepping number and smaller model number mean newer version?


Triple integral of $E$ inside the sphere $x^2 + y^2 + (z-3)^2 = 9$ and above the half cone $z = 2 - (x^2+y^2)^{1/2}$.

Question: So I have to do a triple integral of $E$ inside the sphere
$x^2 + y^2 + (z-3)^2 = 9$ and above the half cone
$z = 2 - (x^2+y^2)^{1/2}$.
I don't know what bounds to use since the sphere isn't centered to the origin and the cone isn't either.
I have to use spherical coordinates.
Comment: You could start by doing a change of variables to center it at the origin
Answer: Make the following change of variables (spherical coordinates)
$ x = \rho \sin \theta \cos \phi $
$ y = \rho \sin \theta \sin \phi $
$ z = 3 + \rho \cos \theta $
where $\rho \in [0, 3] $.
Now we we want
$ z \ge 2 - \sqrt{ x^2 + y^2} $
Therefore, we want
$ 3 + \rho \cos \theta \ge 2 - \rho \sin \theta $
So that
$ \rho  \cos(\theta -\dfrac{\pi}{4} ) \ge -\sqrt{2} $
For $ \theta \in [ 0 , \dfrac{3\pi}{4} ] $, this is automatically satisfied.
For $ \theta \in [ \dfrac{3\pi}{4} , \pi]$ ,
$ \rho \le -\dfrac{\sqrt{2} }{\cos (\theta - \dfrac{\pi}{4} )} $
Let's see when this upper limit is equal to $3$
$\cos( \theta - \dfrac{\pi}{4} ) = - \dfrac{\sqrt{2}}{3} $
Gives $\theta = 2.8471 $
While $ \dfrac{3\pi}{4} =2.35619 $
Hence the integral now is as follows
$\begin{equation} \begin{split}
 I &= \displaystyle \left(\int_{\phi = 0}^{2\pi} \int_{\theta = 0}^{2.8471} \int_{\rho = 0}^3 f(\phi, \theta, \rho) \rho^2 \sin(\theta) d\rho d\theta d\phi\right) \\
&+\left(\int_{\phi = 0}^{2\pi} \int_{\theta = 2.8471}^{\pi} \int_{\rho = 0}^{g(\theta) } f(\phi, \theta, \rho) \rho^2 \sin(\theta) d\rho d\theta d\phi\right) \end{split}\end{equation} $
where $g(\theta) = \dfrac{-\sqrt{2}}{\cos(\theta - \frac{\pi}{4}) } $


og:image com imagem do banco - symfony php

Question: Oi, eu tenho uma página de notícias que o usuário pode curtir e compartilhar as notícias. Cada notícia tem a sua imagem específica. Em algumas notícias há um album de fotos espefícico. Quando há o album para a notícia, o compartilhar do facebook pega uma imagem do album e não a imagem da notícia.
Pesquisei por ai e achei que devo utilizar a meta tag og:image, mas só que não estou consegui fazer isso, olha só o meu código
a imagem é inserida na tabela da noticia.
no action:
$this->imagem = Doctrine_core::getTable('tbnews')
                ->createQuery('im')
                ->select('im.id, im.imagem')
                ->where("im.imagem != ''")
                ->andWhere('im.id = ', $request->getParameter('id'))
        ->limit(1)
        ->execute();

    $response = $this->getResponse();
    $response->addMeta("og:image", "http://www.meusite.gov.br/upload/noticias/<?php echo $this->imagem;");

e é isso que eu tenho como resposta na renderização da página:
<meta content="http://www.meusite.gov.br/upload/noticias/<?php echo
 Doctrine_Collection data : Array( 0 : Object(tbNews) )
; ?>" name="og:image">

Answer: Troque o:
$response->addMeta(
    "og:image",
    "http://www.meusite.gov.br/upload/noticias/<?php echo $this->imagem;"
);

... por:
$response->addMeta(
    "og:image",
    "http://www.meusite.gov.br/upload/noticias/" . $this->imagem->getAtributo()
);

No exemplo acima eu usei um método getAtributo() (que provavelmente não existe) da classe tbnews para imprimir esse atributo na meta tag. Troque o método por outro de sua preferência.
Comment: eu obtive isso com resposta: Fatal error: Call to undefined method Doctrine_Collection::getImagem(). E isso que aparece no html:
Comment: A sua query retorna uma coleção de entidades, e não apenas uma única entidade. Você precisa pegar o primeiro objeto do *resultset* e então imprimir o atributo do ebjeto que você deseja na meta tag.
Comment: sim pois é, mas não ta rolando isso. hum.
Comment: Tente acessar o primeiro objeto da collection com: `$this->imagem[0]->getAtributo()`
Comment: é com isso imprime uma imagem do banco na tela, mas não a imagem certa, pega uma qualquer e joga a mesma imagem pra todas as páginas :T
Comment: mas de qualquer forma o og:image não está pegando a imagem que apareceu na meta tag.
Comment: Qual a meta tag que está sendo gerada?
Comment: Vamos [continuar esta discussão no chat](http://chat.stackexchange.com/rooms/31308/discussion-between-estacio-di-fabio-and-rodrigo-rigotti).
Answer: Achei a solução. Tive que reescrever a função addMeta() para que o parametro name fosse substituido por property.


How to blur without specific element

Question: When I use blur event the input form clear. But I need blur event to include all html page except submit button.
html code:
<form method="POST" action="#" id="form">

<input type="text" id="email" value="EMAIL ADDRESS_" maxlength="65"/>

<input type="submit" value="" id="submit"/>

</form>

jQuery code:
$(document).ready(function(){
    $('#email[type=text]').focus(function(){
         $(this).val("");

    }).blur(function(){
       if(this.value==""){
         $(this).val("EMAIL ADDRESS_");
       }
    });
});

Comment: Sorry, my bad- I say"the input form clear",but I wanted to say, the input form filled with "EMAIL ADDRESS_"
Comment: I'm having difficulty understanding what you are trying to accomplish. Please elaborate.
Answer: Unless I'm missing something:
$('form input[type!=submit]').focus(function(){
     $(this).val("");

}).blur(function(){
   if(this.value==""){
     $(this).val("EMAIL ADDRESS_");
   }
});

Comment: Hello, I'd like that blur event doesn't affect the submit button.
Answer: So after many times spending for searching for right answer, i think this is best solution. I find the answer  here
var setTimer = { timer: null }
    $('input,select').blur(function () {
        setTimer.timer = setTimeout(function () {
           $('#text').val('text');
        }, 200);
    });

    $('input,select').focus(function () {
        setTimer.timer = setTimeout(function () {
            $('#text').val('');
        }, 200);
    });

    $("#submit").click(function () {
        clearTimeout(setTimer.timer);
        //do something
    });

How to blur without specific element


How can I get that flanger effect from "The Pretender" by Foo Fighters?

Question: I'm working on a cover of The Pretender by Foo Fighters, and I think I've got the tone I want pretty nailed down, with one exception. Near the bridge section (at the 2:44 mark) the rhythm guitar has a little flange effect going on, but with more effect, and less actual guitar or chord heard during that point. How do you get that effect?
I'm using one of the flanger effects on a Fender Mustang 3, but I can't seem to get the effect sound as isolated from the chord as it sounds in the song. Any ideas how I could separate that flanger "whoosh" effect from the guitar sound a little more?
Answer: Sounds to me like a Phaser set on low speed (also sometimes called rate) with a fair amount of resonance and a slow panning from left to right. The Phaser has probably 8 stages, which would explain the slight warble. More stages == more warble.
With eg. a EHX Small Stone (inexpensive, but quite good sounding) you'd probably be out of luck, since it only has a rate dial and not much warbling going on. Maybe an MXR EVH-90 could do the trick. It sounds warblier and juicier to me, like all MXR Phasers.
A friend of mine has an old TC XII B/K Programmable Phaser with a switch for 4/8/12 stages (called filters) that sounds just fabulous. The B/K version is the one for bass and keyboard, but he uses it for guitar. I like this much more than the new non-B/K box that sounded a little thin to me when I tested it in the shop extensivly for about three minutes ;-)
I myself have a Moog MF-103 that can be operated in either 6 or 12 stage mode. Very warm and warbly and it can be set to ring modulator like shrieking. I use it with bass guitar and it rocks. Think Hangin Tree by QOTSA.
Comment: I would add that there is a volume control as well: either someone manually fading the volume, or something automagical such as an envelope or an input level modifier. This would allow it to be super quiet (off) until a note is struck which triggers a volume change with a slow rolloff
Answer: Dave Grohl is a person who doesn't like pedals but is using them. But not so many is he using. His chain is starting in a BOSS TU-3, then is going into a MXR phase 90 (setting: 11 o'clock) and with as last one a BOSS DD-3.


Which of these regression models would be the most appropriate to test the given research question?

Question: If we want to test: population with a high level of education were less likely to contract COVID, which of the following regression(s) we should run? Explain whether each one is appropriate.
LN is natural log.
(1) CASES on POPULATION PHIGHSCOOL
(2) LN(CASES) on POPULATION PHIGHSCOOL
(3) LN(CASES) on LN(POPULATION) PHIGHSCHOOL
(4) CASES/POPULATION on PHIGHSCHOOL
(5) LN(CASES/POPULATION) on PHIGHSCOOL
(6) LN(CASES/POPULATION) on LN(PHIGHSCHOOL)
Data set includes:
COUNTRY Country name
REGION      Country region
CASES       Total number of COVID cases thus far in the country
DEATHS      Total number of COVID death thus far in the country
CPI         Current consumer price index of the country
PHIGHSCHOOL Percent of adults achieved high school education
LIFEEXPECTANCY  Years
GDP     GDP in current year
POPULATION  Number of population
For this question, I'm not allowed to use excel, stata, etc,.. to check how the data is skewed.
Semi-log and log-log are throwing me off a bit here since both 3 and 6 looks like appropriate models to me.
Since PHIGHSCHOOL is the only one that's not a count variable, do we still need LN it like in model 6? If not, would that make model 3 the most appropriate?
Comment: First, I think you should explain your notation a bit. I'm guessing "LN" here means the natural log, but that's not clear. Additionally, it would be very helpful to know the distributional aspects of your data before applying such methods. Log-log regressions, for example, are typically performed on pairs of variables which are both heavily right skewed. The biggest thing that sticks out to me is that education is discrete and takes on few values while COVID cases are always non-negative (thus bounded to a degree). Scatterplots would illuminate a lot.
Comment: Yes, LN is natural log. Thank you for your answer.
Comment: This reads like a homework question. If so, please add the `self-study` tag and read its [description](https://stats.stackexchange.com/tags/self-study/info).
Comment: @COOLSerdash Will do. Thank you for the suggestion
Answer: I think the answer to this question should always include "inspect your data" (or at least check model fit) as one of the steps. It looks like this is more of a textbook exercise though, so I would theorize along these lines:
Your outcome is a count, meaning non-negative integers only. An appropriate model should account for this, so a Poisson or negative binomial GLM would be a good starting point. That has relatively little to do with the choice of dependent and independent variables though.
Because a count cannot be less than zero, the predictor is usually log-linked to ensure the model does not predict anything below 0. A side effect of this transformation is that it plays along with the usual mean-variance trend that counts display - larger counts tend to have higher variance, but will be squished closer together by the transformation. If $y$ is your count and $\mathbf{\beta X}$ your linear predictor, you could write this as $ln(y)=\mathbf{\beta X}$ but in reality you would be fitting $y=e^{\mathbf{\beta X}}$. So, an appropriate model works in the log scale, but you would not be taking the log of the count yourself (unless you're shoehorning all of this into an ordinary least squares or something).
A second aspect in counting is to keep in mind the basis of that count. If one population is much larger than another you'd expect them to have higher counts just by virtue of there being more people (if they have roughly the same chance of being a case). What you really want to model is the number of cases divided by the total possible cases: if we add $n$ to express the size of each population our previous model becomes $ln(\frac{y}{n})=\mathbf{\beta X}$. Through the rules of logarithms we can shuffle this to be $ln(y)=\mathbf{\beta X}+ln(n)$. Two important points here: this new term is not a model parameter like the other $\mathbf{\beta}$, but rather an additive term in the intercept, and is usually called an offset (it moves the prediction within each population by a constant proportional amount). Secondly, you would be taking the log of this variable yourself when fitting the model under a log link, which in the link scale is now $y=e^{\mathbf{\beta X+ln(n)}}$. The result of such offset is that the model no longer predicts a raw case count, but a number of cases per number of persons.
The above two I would always do when building a model on event rates. The last question is what to do with the proportion of high-schooled adults in the predictor. There may be arguments, especially for interpretability, to put this in the model untransformed, and if the proportion is never close to $0$ or $1$ that shouldn't be much of an issue. Just like a count such proportions are (even more) restricted in their support though, and the model doesn't know this - it will just calculate a Gaussian error term onto it. A transformation can help so that predictions make more sense, i.e stay within the support of the variable. Taking the log helps if the proportion is very close to $0$ but not so when it is close to $1$. I would guess that most populations have a sizeable fraction of high-schooled adults, so for that reason I would actually consider a logit transform here which will also handle the upper end of the domain. A major disadvantage is that you'd now have to express model effects as multiplicative changes in counts (because of the log link) in relation to multiplicative changes in high school education (because of the second log/logit), which makes interpretation quite a bit more complicated but is numerically more well-behaved.
That was quite a bit of text without answering your question directly, but I hope this helps you assess the adequacy of each proposed model structure (the notation of which isn't sufficiently specific to me to give an exact answer).
Comment: Getting predictions does not seem to be the goal of the analysis, so the transformation hunt is not worth the powder, given the complexity of interpretation of the education coefficient it introduces. And what is good for the logit goose, it just as good for the log gander.
Comment: I certainly see your first point, which is why I didn't put that under 'would always do'. There's a case to be made for either though I agree that interpretability matters a lot. However, the log does not nearly 'stretch out' the parameter space as much near 1 as it does near 0, so I would still consider other transformations more appropriate if proportions ~1 do occur in the data? (and if you choose to transform in the first place)
Comment: Yes, this was a great help. Thank you for taking the time to explain each part of the model. @PBulls


How to set 'grant type' with lwp

Question: I'm trying to connect to a server with LWP::UserAgent. I have succeeded to do anonymous searches with LWP::UserAgent on that same server, but now I have to "secret" stuff and that requires to use authentication on that server. I have used the code:
my $ua = LWP::UserAgent->new;
$ua->default_header('Content-Type'  => "application/x-www-form-urlencoded");
$ua->default_header('Authorization' => "Basic ".$Authent);
my $resp  = $ua->post($uri);

The server reponds: error 400, Required param: grant_type
So, how do I set the grand type parameter with LWP?
I have not found any page concerning the grand type problem.
I have tried also:
$ua->default_header('grant_type'    => "client_credentials");

and
my $resp  = $ua->post($uri, grant_type => "client_credentials");

All three gives exactly the same error message.
I have no idea how to get things work.
Comment: https://metacpan.org/pod/LWP::UserAgent#ua-credentials-netloc-realm
Comment: Thanks for fast respond. I have no idea, how to use that. The server does not use user id and password. It uses authorization on header to verify user rights. That was given on my code. The problem is on grant_type, which must be changed.
Answer: TA-DAA! I found an answer.
The grant_type is not header stuff, it belongs to body.
So, the working way to do this is:
$ua->default_header('Content-Type'  => "application/x-www-form-urlencoded");
$ua->default_header('Authorization' => "Basic ".$Authent);
my $resp  = $ua->post($uri, Content => ['grant_type' =>  "client_credentials"]);

Thanks anyway!

How to set 'grant type' with lwp


How much does a referee/umpire earn in a year?

Question: Is it possible to create an approximate draw with the earning of the referee in the most important sports(Soccer/Basketball/Volleyball/Tennis/Cricket etc.)?
Comment: I know that in soccer some of the refs have a full time job alongside their career as a referee so I can't imagine they earn a lot unless there is a big difference between what top refs make in comparison to middle of the road refs
Comment: @RoB The referee appointed for the Champions League final has a job alongside.
Answer: Referees and umpires get paid much differently depending on the sport.
For the first example, let's take the most watched sport in the world: football (known to Americans as soccer). European soccer referees get paid, on average, about the equivalent of $120,000 a year (salary plus match fees). Of course, this depends on the quality of the referee, but it is quite apparent that this is nothing compared to soccer players (about a two weeks salary in average).
For the most watched sport in the United States, American football, referees get paid much higher. For the 2013-2014 season, NFL referees got paid on average $173,000 (an increase from $149,000 the preceding year). Of course, rookie (first year) referees make much less, and verteran referees can make up to $200,000 per season.
In tennis, the idea is different. Umpires get paid by the match, since every tournament has a different level of importance (Grand Slams being the most important). The salaries also differ depending on the tournament. For the sake of simplicity, let's compare the salaries of "Gold Badge Umpires" (the highest position for a tennis umpire), from the four grand slams.  A spreadsheet obtained by The New York Times showed that Wimbledon paid gold badge umpires £189, or about $306 daily. The French Open paid 190 euros (about $270), even for the tournament's qualifying rounds, while the United States Open pays $185 a day for its qualifying rounds.
At the Australian Open, gold badge umpires earn about $383 for each main draw day, and they make overtime if they work more than 10 hours, a perk none of the other Grand Slam tournaments provide.
Cricket umpires can make anything from $30,000 to $45,000 in annual salary. This is just the salary. Depending on the match, either a ODI (one day international) or a test match (which last considerably longer than ODI's), they also gain match day fees. For a test match, the fee is usually around $3,000 while a ODI can pay around $800-$1,000.
Answer: Goal.com had a table on how much refs get paid in the top leagues in Europe from around 2011.
How Much Officials Earn Per Domestic League Game (€)
England   1,170* (Referee)    375 (Referee Assistant)
Spain     6,000 (Referee)     2,000 (Referee Assistant)
Germany   3,600  (Referee)    1,800 (Referee Assistant)
Italy     3,400   (Referee)   1,700 (Referee Assistant)
France    2,751  (Referee)    -
Portugal  1,188 (Referee)     594 (Referee Assistant)
*EPL referees are paid a retainer of €38,500 per season which explains why their fee per game is lower than some of the other leagues.
On average top tennis umpires can expect to earn £50-£60,000 per annum, but it takes a long time to get there! Most earn around £30,000. On average a line judge can expect to earn £20,000 (BBC Sport).
In cricket;
ELITE PANEL OF ICC UMPIRES
1   Aleem Dar (Umpire)         $45,000  (Basic Yearly Salary)           $3,000  (Test Match Fee)    $850 (ODI Match Fee)
2   Steve Davis (Umpire)           $45,000             $3,000       $1000
3   Tony Hill (Umpire)         $30,000             $3,000       $850
4   Ian Gould (Umpire)         $45,000             $3,000       $1000
5   Rod Tucker (Umpire)        $45,000             $3,000       $1000
6   Marais Erasmus (Umpire)        $35,000             $3,000       $850
7   Kumar Dharmasena (Umpire)      $30,000             $3,000       $850