Sum in Java (built in method)'s Implementation?

Question: Hello and Happy new Year to all guys.
I came from world of matlab, and before one year started to code in java.
I'm in countering problem that might be easy but bear with me please!
here's the code of matlab:
state is a variable of 3d array which its size: 2x4x64.
state value is:(that's what I get on the editor of matlab)
state(:,:,1) =

     1     0     0     0
     2     0     1     1

state(:,:,2) =

     3     0     1     0
     4     0     0     1

state(:,:,3) =

     5     0     1     1
     6     0     0     0

state(:,:,4) =

     7     0     0     1
     8     0     1     0

state(:,:,5) =

     9     0     1     1
    10     0     0     0

state(:,:,6) =

    11     0     0     1
    12     0     1     0

state(:,:,7) =

    13     0     0     0
    14     0     1     1

state(:,:,8) =

    15     0     1     0
    16     0     0     1

state(:,:,9) =

    17     0     0     0
    18     0     1     1

state(:,:,10) =

    19     0     1     0
    20     0     0     1

state(:,:,11) =

    21     0     1     1
    22     0     0     0

state(:,:,12) =

    23     0     0     1
    24     0     1     0

state(:,:,13) =

    25     0     1     1
    26     0     0     0

state(:,:,14) =

    27     0     0     1
    28     0     1     0

state(:,:,15) =

    29     0     0     0
    30     0     1     1

state(:,:,16) =

    31     0     1     0
    32     0     0     1

state(:,:,17) =

    33     0     0     1
    34     0     1     0

state(:,:,18) =

    35     0     1     1
    36     0     0     0

state(:,:,19) =

    37     0     1     0
    38     0     0     1

state(:,:,20) =

    39     0     0     0
    40     0     1     1

state(:,:,21) =

    41     0     1     0
    42     0     0     1

state(:,:,22) =

    43     0     0     0
    44     0     1     1

state(:,:,23) =

    45     0     0     1
    46     0     1     0

state(:,:,24) =

    47     0     1     1
    48     0     0     0

state(:,:,25) =

    49     0     0     1
    50     0     1     0

state(:,:,26) =

    51     0     1     1
    52     0     0     0

state(:,:,27) =

    53     0     1     0
    54     0     0     1

state(:,:,28) =

    55     0     0     0
    56     0     1     1

state(:,:,29) =

    57     0     1     0
    58     0     0     1

state(:,:,30) =

    59     0     0     0
    60     0     1     1

state(:,:,31) =

    61     0     0     1
    62     0     1     0

state(:,:,32) =

    63     0     1     1
    64     0     0     0

state(:,:,33) =

     1     1     1     1
     2     1     0     0

state(:,:,34) =

     3     1     0     1
     4     1     1     0

state(:,:,35) =

     5     1     0     0
     6     1     1     1

state(:,:,36) =

     7     1     1     0
     8     1     0     1

state(:,:,37) =

     9     1     0     0
    10     1     1     1

state(:,:,38) =

    11     1     1     0
    12     1     0     1

state(:,:,39) =

    13     1     1     1
    14     1     0     0

state(:,:,40) =

    15     1     0     1
    16     1     1     0

state(:,:,41) =

    17     1     1     1
    18     1     0     0

state(:,:,42) =

    19     1     0     1
    20     1     1     0

state(:,:,43) =

    21     1     0     0
    22     1     1     1

state(:,:,44) =

    23     1     1     0
    24     1     0     1

state(:,:,45) =

    25     1     0     0
    26     1     1     1

state(:,:,46) =

    27     1     1     0
    28     1     0     1

state(:,:,47) =

    29     1     1     1
    30     1     0     0

state(:,:,48) =

    31     1     0     1
    32     1     1     0

state(:,:,49) =

    33     1     1     0
    34     1     0     1

state(:,:,50) =

    35     1     0     0
    36     1     1     1

state(:,:,51) =

    37     1     0     1
    38     1     1     0

state(:,:,52) =

    39     1     1     1
    40     1     0     0

state(:,:,53) =

    41     1     0     1
    42     1     1     0

state(:,:,54) =

    43     1     1     1
    44     1     0     0

state(:,:,55) =

    45     1     1     0
    46     1     0     1

state(:,:,56) =

    47     1     0     0
    48     1     1     1

state(:,:,57) =

    49     1     1     0
    50     1     0     1

state(:,:,58) =

    51     1     0     0
    52     1     1     1

state(:,:,59) =

    53     1     0     1
    54     1     1     0

state(:,:,60) =

    55     1     1     1
    56     1     0     0

state(:,:,61) =

    57     1     0     1
    58     1     1     0

state(:,:,62) =

    59     1     1     1
    60     1     0     0

state(:,:,63) =

    61     1     1     0
    62     1     0     1

state(:,:,64) =

    63     1     0     0
    64     1     1     1
%%%%%%%%%%%%%%%%%%%

revealed =[1 0];
tmp=[0,0];
for m=1:2
tmp[1]=sum(abs(state(l, 3:4 ,j)-revealed)) % here  state(m, 3:4 ,j) is actually the 3rd and 4th columns substracting from them the array revealed at every row (m=1, 2) of given j.
end
so at the end it returns tmp.

to who doesn't understand matlab is that there's an array state with size 2x4x64 and state(l, 3:4 ,j) gives me the two columns values according to j and then we subtract the array revealed from then and
we do afterwards abs and then sum to the array result.
for example: state (m, 3:4 , 1) .
J=1 gives me [0 0] and [1 1] for m=1 , m=2 at third and 4th columns. so at every m I subtract revealed
[1 0] from the two value of third columns and 4th columns values according to m.
so here at m=1 we have [0 0] so [0 0] - revealed => [0 0]-[1 0] => [-1 0] and we do abs([-1 0]) so
we get [1 0] and then we do sum which it's 1+0 => 1.
At m=1 we get [1 1] so [1 1]-[1 0] => [1 0] we do abs on this array => [1 0] and then afterwards we do sum 1+0 => 1 .
I'm trying to do the same thing / same concept in java (to convert this code matlab to java) . so what I've done is this:
int[64][2][4] state=
{
{{ 1    , 0 ,    0 ,    0},
 { 2    , 0   ,  1,     1 }},

    {{ 3 ,    0 , 1 ,    0},
    {4   ,  0  ,   0  ,   1}},

    {{  5   ,  0 ,    1  ,   1},
    {6   ,  0 ,    0    , 0}},

    {{ 7    , 0   ,  0    , 1},
    { 8 ,    0  ,   1 ,    0 }}

   { {9     ,0  ,   1   ,  1},
    {10  ,   0   ,  0    , 0}},

    { { 11  ,   0   ,  0 ,    1},
      {12   ,  0   ,  1  ,   0}},

    { { 13  ,   0  ,   0  ,  0},
    {14   ,  0    , 1  ,   1}},

    { { 15  ,   0   ,  1 ,    0},
    { 16  ,   0  ,   0  ,   1} },

    {{17  ,   0  ,   0  ,   0},
    {18  ,   0  ,   1 ,    1 }},

    {{19  ,   0  ,   1   ,  0},
     {20  ,   0  ,   0  ,   1}},

    {{21   ,  0  ,   1 ,    1},
    { 22   ,  0   ,  0 ,    0}},

    { { 23 ,    0 ,    0,     1} ,
    {24  ,   0  ,   1  ,   0}},

    { {25  ,   0  ,   1 ,    1},
    {26   ,  0   ,  0  ,   0}},

    { {27   ,  0  ,   0 ,    1},
      {28  ,   0  ,   1  ,   0}},

    {{29   ,  0  ,   0  ,   0},
     {30  ,   0 ,    1 ,    1}},

    {{ 31   ,  0    , 1  ,   0},
     {32   ,  0  ,  0   ,  1}},

    { { 33 ,    0   ,  0 ,    1},
    {34   ,  0  ,   1 ,    0} },

    {{35  ,   0   ,  1   ,  1},
    {36  ,   0    , 0   ,  0}},

    {{ 37  ,   0  ,   1 ,    0},
     {38   ,  0  ,   0  ,   1}},

    {{39   ,  0  ,   0  ,   0},
     { 40   ,  0  ,   1  ,   1}},

    {{41  ,   0   ,  1 ,    0},
    { 42  ,   0  ,   0  ,   1}},

    {{ 43  ,   0  ,   0 ,    0},
     { 44  ,  0   ,  1  ,   1}}

    {45 ,    0  ,   0  ,   1},
    {46  ,   0  ,   1  ,   0} },

   { { 47   ,  0 ,    1  ,   1 },
     { 48   ,  0  ,   0  ,   0 } },

    {{ 49  ,   0  ,   0  ,   1 },
     { 50  ,   0   ,  1   ,  0 }},

  { { 51   ,  0    , 1 ,    1 },
    {52   ,  0   , 0  ,  0} },

    { { 53  ,   0,     1  ,   0 },
      {54   ,  0 ,   0  ,  1} },

    { { 55  ,   0   ,  0   ,  0 },
      { 56  ,   0   ,  1  ,   1} },

   { {57  ,   0  ,   1  ,   0},
     {58  ,   0  ,   0  ,   1} },

   { { 59   ,  0   ,  0 ,    0 },
      { 60   ,  0   ,  1  ,   1} },

   { { 61 ,    0 ,    0  ,   1 },
     { 62   ,  0  ,   1  ,   0} },

  { { 63   ,  0  ,   1 ,   1},
    { 64  ,  0  ,   0 ,   0 } },
};

 public class GlobalMember
    {
     int[] revealed =[1 0];
     int[] tmp= {0,0};
   for(int j=0 ; j<64 ; j++)
     { for (int m = 0 ; l < 2 ; l++)
       {
           tmp[l] =
             IntStream.of((Math.abs(state[m, 3 : 4, j] - revealed))).sum();
             //note that I always just check 3rd and 4th columns values which
            //they are implicitly an array with two element at every row of
           //the two rows at every j(j is range from 0 to 64).
       }
     }
    }

but it sounds Im missing something and it doesn't compile at all, could anyone please help me
how do I implement this code matlab in java? I mean to implement the same concept of matlab code in java.
Im struggling this about one week and I didn't understand where's exactly the problem.
thanks alot.
Comment: The numbers in your array initializer should be separated by commas, not just by spaces.
Comment: You will be surprised how many errors you can remove by comma seperating your numbers
Comment: my issue is not comma, it's more in the function itself, and I will fix the comma issue but it's far away that it's all the issue .
Comment: I updated the code also.
Comment: @ErwinBolwidt  Any help please?
Comment: @Syncit I updated my thread/code , could you please help me?!
Comment: @ErwinBolwidt I updated my thread/code , could you please help me?!
Comment: It would help if you posted the actual error that you get so that we don't have to guess. Glancing further, I see `state[m, 3 : 4, j]` - that's not valid Java syntax. I'm not sure what you're trying to do there but this is not the right way.
Answer: you have to fix the initialization sintax (comma separated values), something similar was asked here Syntax for creating a two-dimensional array
I guess you should do something like this:
int[64][2][4] state=
{
{{1,0,0,0},
{2,0,1,1}},
{{3,0,1,0},
...

Comment: but what I've done in my code is the same as you assume ..
Comment: any help please?
Comment: I updated my thread/code , could you please help me?!
Answer: First lets get familiar with the basics. let's start with 2D arrays.
a) 2D Arrays
Imagine 2D arrays not as an grid of numbers but as layers of 1D array's because each of these layers can have an 1D array of any length,lets look at an example
 //This 2D array has 3 layers, each layer is denoted using {} brackets

 int[][] test={
               {1,2}            //Layer 0 has 2 elements
              ,{3,4,5}          //Layer 1 has 3 elements
              ,{6,7,8,9}        //Layer 2 has 4 elements
             };

To query this code you would do like this
int layers=test.length;  //This gives us the total layers in the 2D array
System.out.println(layers);
for(int i=0;i<layers;i++){System.out.println(test[i].length);}//This queries the number of elements in each layer

Output:
3  //Number of layers=3
2  //Layer 0 has 2 elements
3  //Layer 1 has 3 elements
4  //Layer 2 has 4 elements

You can also initialize an 2D array like this
int rows=2;
int cols=3;
int[][] test=new int[rows][cols];

However one limitation is you would have guessed it from above is that you can initialize your 2D array only in an grid fashion. The number of layers is the rows and the length of each 1D array in each layer is the columns.
To iterate over each element you would do it like this
for(int layer=0;layer<test.length;layer++)  //iterate over each layer
{
 for(int i=0;i<test[layer].length;i++)      //for each layer iterate over all elements in that layer
 {
  int element=test[layer][i];
 }
}

b) 3D Arrays
Now just as 2D arrays contain multiple layers of 1D arrays 3D arrays contains multiple layers of 2D arrays, let's look at an example
 int[][][] test=
  {
   {                     //This is layer 0
     {0,1}
    ,{2,3,4}
   }
   ,
   {                     //This is layer 1
     {5,6}
    ,{7,8,9}
    ,{10,11,12}
   }
   ,
   {                      //This is layer 2
     {13,14}
    ,{15,16,17}
    ,{18,19,20,21}
    ,{22,23,24,25,26}
   }
  };

Again you can also initialize an 3D array like this
int layers=3;
int rows=4;
int col=5;
int[][][] test=new int[layers][rows][col];

With again the limitation that every 2D array layer must be initialized in an grid fashion
In fact you can reference an 2D array from any layer in this 3D array like this
int[][] test2=test[0]; //get the 2D array stored in layer 0

also to loop over every element in this 3D array you have dig through all the layers
for(int layer2D=0;layer2D<test.length;layer2D++)  //Iterate over every 2D array layer in this 3D array
{
 for(int layer1D=0;layer1D<test[layer2D].length;layer1D++)  //iterate over every 1D layer of this current 2D array
 {
  for(int element=0;element<test[layer2D][layer1D].length;element++) //finally iterate over every element of this current 1D layer or 1D array
  {
   int value=test[layer2D][layer1D][element];

  }
 }
}

Ok after all of that let's address your problem now.
1) Fix your array
Since you are initializing your 3D array using approach one you don't need to specify the lengths. Here is your final array
int[][][] state=              //No need to specify lengths just use empty brackets
  {
   {                          //Layer 0
    {1    , 0 ,    0 ,    0},
    {2    , 0   ,  1,     1 }
   }
   ,
   {                          //Layer 1 and so on
    {3 ,    0 , 1 ,    0},
    {4   ,  0  ,   0  ,   1}
   }
   ,
   {
    {5   ,  0 ,    1  ,   1},
    {6   ,  0 ,    0    , 0}
   }
   ,
   {
    {7    , 0   ,  0    , 1},
    {8 ,    0  ,   1 ,    0 }
   }
   ,
   {
    {9     ,0  ,   1   ,  1},
    {10  ,   0   ,  0    , 0}
   }
   ,
   {
    {11  ,   0   ,  0 ,    1},
    {12   ,  0   ,  1  ,   0}
   }
   ,
   {
    {13  ,   0  ,   0  ,  0},
    {14   ,  0    , 1  ,   1}
   }
   ,
   {
    {15  ,   0   ,  1 ,    0},
    {16  ,   0  ,   0  ,   1}
   }
   ,
   {
    {17  ,   0  ,   0  ,   0},
    {18  ,   0  ,   1 ,    1 }
   }
   ,
   {
    {19  ,   0  ,   1   ,  0},
    {20  ,   0  ,   0  ,   1}
   }
  ,
  {
   {21   ,  0  ,   1 ,    1},
   {22   ,  0   ,  0 ,    0}
  }
  ,
  {
   {23 ,    0 ,    0,     1},
   {24  ,   0  ,   1  ,   0}
  }
  ,
  {
   {25  ,   0  ,   1 ,    1},
   {26   ,  0   ,  0  ,   0}
  }
  ,
  {
   {27   ,  0  ,   0 ,    1},
   {28  ,   0  ,   1  ,   0}
  }
  ,
  {
   {29   ,  0  ,   0  ,   0},
   {30  ,   0 ,    1 ,    1}
  }
  ,
  {
   {31   ,  0    , 1  ,   0},
   {32   ,  0  ,  0   ,  1}
  }
  ,
  {
   {33 ,    0   ,  0 ,    1},
   {34   ,  0  ,   1 ,    0}
  }
  ,
  {
   {35  ,   0   ,  1   ,  1},
   {36  ,   0    , 0   ,  0}
  }
  ,
  {
   {37  ,   0  ,   1 ,    0},
   {38   ,  0  ,   0  ,   1}
  }
  ,
  {
   {39   ,  0  ,   0  ,   0},
   {40   ,  0  ,   1  ,   1}
  }
  ,
  {
   {41  ,   0   ,  1 ,    0},
   {42  ,   0  ,   0  ,   1}
  }
  ,
  {
   {43  ,   0  ,   0 ,    0},
   {44  ,  0   ,  1  ,   1}
  }
  ,
  {
   {45 ,    0  ,   0  ,   1},
   {46  ,   0  ,   1  ,   0}
  }
  ,
  {
   {47   ,  0 ,    1  ,   1 },
   {48   ,  0  ,   0  ,   0 }
  }
  ,
  {
   { 49  ,   0  ,   0  ,   1 },
   { 50  ,   0   ,  1   ,  0 }
  }
  ,
  {
   {51   ,  0    , 1 ,    1 },
   {52   ,  0   , 0  ,  0}
  }
  ,
  {
   {53  ,   0,     1  ,   0 },
   {54   ,  0 ,   0  ,  1}
  }
  ,
  {
   {55  ,   0   ,  0   ,  0 },
   {56  ,   0   ,  1  ,   1}
  }
  ,
  {
   {57  ,   0  ,   1  ,   0},
   {58  ,   0  ,   0  ,   1}
  }
  ,
  {
   {59   ,  0   ,  0 ,    0 },
   {60   ,  0   ,  1  ,   1}
  }
  ,
  {
   {61 ,    0 ,    0  ,   1 },
   {62   ,  0  ,   1  ,   0}
  }
  ,
  {
   {63   ,  0  ,   1 ,   1},
   {64  ,  0  ,   0 ,   0 }
  }
  };

Fix Your code

This code right here

public class GlobalMember
    {
     int[] revealed =[1 0];
     int[] tmp= {0,0};
   for(int j=0 ; j<64 ; j++)
     { for (int m = 0 ; l < 2 ; l++)
       {
           tmp[l] =
             IntStream.of((Math.abs(state[m, 3 : 4, j] - revealed))).sum();
             //note that I always just check 3rd and 4th columns values which
            //they are implicitly an array with two element at every row of
           //the two rows at every j(j is range from 0 to 64).
       }
     }
    }

Won't do you see every program in java begins with a class and an main method and so everything you do needs to encapsulated in an method which is further inside an class you can read this simple tutorial
Let's put that in an method and forgive me if i don't understand your logic but basically if you are trying to find the sum of all elements you have to declare an variable to store the result and keep adding to it to get your result. While we are at it let's declare your main method as well in this class
public class FindSum
{
 public static void main(String[] args)
 {
  int[][][] state=//The array i showed above cause i can't be asked to paste that here again

  System.out.println(findSum(state)); //You call that function here
 }

 public static int findSum(int[][][] state)
 {
  int sum=0;

  //Using the same logic from above

   for(int layer2D=0;layer2D<state.length;layer2D++)  //Iterate over every 2D array layer in this 3D array
   {
     for(int layer1D=0;layer1D<state[layer2D].length;layer1D++)  //iterate over every 1D layer of this current 2D array
     {
      for(int element=0;element<state[layer2D][layer1D].length;element++) //finally iterate over every element of this current 1D layer or 1D array
      {
       int value=state[layer2D][layer1D][element];

       sum+=value;
      }
     }
   }
   return sum;
 }
}

I have covered only the basics here So find some good tutorials and there a lot out there.
Comment: I understand thank you much but you're misunderstanding me so bear with me please because Im struggling on this problem about two weeks. I want to add just the two elements of the 3rd and fourth columns for each row of the array (each four values of the array I take the last two values, there's 64 rows in the array). for first row for instance the value of 3rd and fourth columns of array is [0 0] , for second row the value of 3rd and fourth columns value are [1 1]  ; so I need to return just the sum of 3rd and fourth values of the columns at each row.
Comment: Then your problem becomes even simpler cause you don't need a 3d array but just a 2d one. Your inner loop of the 2d array(which I have shown how to iterate above) just needs to loop from 2->3[3rd and 4th column cause array indices start from 0->n-1] and then use the same sum logic which I have shown above.


How do I initialize app with external JSON?

Question: I need to initialize my app with external json data. The problem I'm getting is that I can't force the app to wait loading children components for after the data arrives.
For example, let's use this as an example (not external loading here, I'm using setTimeout to make a point of waiting for data to arrive).
new Vue({
  el: '#app',
  router,
  render: h => h(App),
  beforeCreate() {
    setTimeout(() => {
      this.myConfig = 'loaded'; // I realize I'm not using $data here, but nevermind
    }, 1000)
  },
});

And in my child component
created() {
  console.log(this.$root.myConfig);
},

The problem is that created from the child is called before the beforeCreate finishes.
Data won't change from initial state. Thus, I don't need the reactivity of VueX.
As I'm using vue-router, an option maybe is to create a loading component as the default route, which should load the data, and then on arrival switch to the correct initial state.
Also, by looking at Async Components, maybe it's what I should use, but I get the feeling that it's a little more complicated than what I need.
Is there a best practice way to achieve this?
Answer: You can use a simple boolean to hide the components while the data is loading with v-if. Set a variable named loading to true and change it to false when you're done loading. Then use v-if="!loading" on your component. You might want a nice loading text or spinner there for the user.

new Vue({
  el: '#app',
  data () {
    return {
      loading: true,
      myConfig: ''
    }
  },
  created () {
    setTimeout(() => {
      this.loading = false
      this.myConfig = 'loaded'
    }, 2000)
  },
});

loading...

{{ myConfig }}

Answer: Maybe this directs you:

console.log('wait for 1 second')

new Vue({
  template: '#app',
  created () {
    setTimeout(() => {
      this.myConfig = 'loaded'
      this.$mount('#app')
    }, 1000)
  },
});
<template id="app">

{{ myConfig }}

</template>

For more advanced 'preinitialization' look at this example.


Can a cadence happen only at the end of a measure?

Question: In this chord progression, <code>| I  vi  IV  V | I  vi  IV  V |  I |</code>, there seems to be a perfect cadence that occurs at the end of one chord progression/measure (V) and the beginning of the next chord progression/measure (I). Is this still taught as a perfect cadence or is the progression 'left hanging'?
This lesson has it seem that the chord progression has to end on the tonic in order to have a perfect cadence
(https://colinarcher99.medium.com/chord-progressions-part-2-92e90e942000)
Comment: I tried to rewrite your question based on our discussion, but please let me know if I failed to capture your intent.
Comment: You need to read further into the referenced link. A music phrase ending on V is a "half cadence".
Comment: Yes but the phrase does not end it goes back to the tonic from the V.  The V is resolved and not left hanging. If you read my post I explained this. There is a perfect cadence it just happens when the progression repeats.
Comment: I'm not following the question then. If the phrase keeps going, then the chord progression hasn't ended either. Cadences by definition only happen at the ends of phrases. V going to I in the middle of a phrase isn't a cadence.
Comment: That website says a perfect cadence involves a chord progression as (I IV V I). The cadence in every example happens before the progression ends.
Comment: Still not sure what you mean. The website shows six examples of perfect cadences. It's six separate chord progressions; not one single chord progression.
Comment: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/126491/discussion-between-aaron-and-pabble-goobs).
Answer: No. It can go in different places in regard to bar lines. But, as Aaron pointed out, cadences end phrases, so identify phrases and the cadences that demark them.
A few terms to be aware of regarding phrase endings (cadences) and bar lines (metrical position) are:

masculine ending where the final cadence chord is on beat one after a bar line
feminine ending where the final cadence chord is on the last beat of a measure, or at least after beat one
elision, elided phrases where the ending of one phrase and the beginning of the next phrase overlap.
Answer: Before answering, some clarification of terms.

chord progression: Any sequence of two or more chords
measure: A set number of musical pulses
phrase: A complete musical idea, typically ending with a cadence
cadence: A special chord progression creating a sense of pause or ending

Chord progressions, measures, and phrases all can act independently of each other. A phrase can span one or more measures, including partial measures, so a cadence can occur and the end of a measure, or anywhere at the beginning or middle as well. It's fine for a cadence to occur across the boundaries of a measure, such as the V chord at the end of one measure and the I chord at the beginning of the next.
A chord progression corresponding to a musical phrase, would end in a cadence. Given the above relationship between phrases and measures, a chord progression can begin or end at any point within a measure. "Chord progression", being a general term, could encompass just part of a phrase, a complete phrase, or multiple phrases — even an entire piece could be discussed in terms of its chord progression.
Regarding perfect cadences
A perfect cadence is a V chord followed by a I chord, but a V chord followed by a I chord is not necessarily a perfect cadence. A V chord followed by a I chord at the end of a phrase is a perfect cadence, but V-I chords can occur anywhere within a phrase.
This is true for any set of cadential chords. They can occur anywhere within a phrase; it's only at the end of a phrase that they form a cadence.
Comment: I like this answer. It seems to me OP was a little confused by certain terms - this clears up that. The example OP uses is the basic U.K. explanation of cadences - excluding all the U.S.(?) subtle alterations - which is a good thing here. Bars (measures) have little relationship with cadences.Chord progressions are not necessarily correspondent to phrases. It seems only two cadences are actually cadences - perfect and plagal. Others aren't cadences - hence 'half-cadence - as they don't (usually) end a sequence. Your last para. - are *cadential chords* actually cadential when they're not ...
Comment: ...at the end of that phrase. I'd say they're just *chords*.
Comment: When going from ii-I , is this not a cadence? I can't find any name for such a cadence. It doesn't sound too bad playing I-IV-ii-I.
Comment: @PabbleGoobs A cadence is just an ending point. In that respect, anything can be a cadence. But some cadences are so common, like V-I, that they receive names. ii-I can certainly serve as a cadence, it just doesn't have a special name.
Answer: A cadence comes at the end of a musical phrase.   A phrase doesn't necessarily end at a barline. Here's three cadences.


How can I remove milliseconds from timestamp in oracle insert query using TO_DATE?

Question: I have a value like this '2019-05-04 12:34:20' which I obtain from another database using python code
But when I run the below query in oracle,
INSERT INTO sample_table(SCHEDULED_DATE)
VALUES (TO_DATE('2019-05-04 12:34:20','YYYY-MM-DD HH24:MI:SS'));

I am getting an output like this,
'04-05-19 12:34:20.000000000 PM'

What I want is:
'2019-05-04 12:34:20'

Answer: What you are expecting and what you are getting is the same value.
It is just the representation. SCHEDULED_DATE is the timestamp data type and it shows milliseconds as 000..
You can use TO_CHAR to see the value in the format that you want(to_char(SCHEDULED_DATE, 'YYYY-MM-DD HH24:MI:SS')). and anyway you are adding date into timestamp so your timestamp will always have 000.. in the millisecond.
Comment: Hi Tejash. Presently you have 1,175 instances of the word "cheers" in your answers. Are you aware that we prefer not to add thanks, signatures and other chatty material? That is a lot of repair work for volunteers.
Comment: I do greet the people with Cheers, I don't think there is any harm in it. I will take care of it from next time.
Comment: You could argue the case for non-technical writing on _Meta Stack Overflow_ if you wish, but I am certain it would be unpopular (these discussions have been had a lot already). If an editor were to edit out five of these every day, it would take them around eight months. I appreciate you changing course, but it would be even better if you would help with the historical repair.


PHP - Create image from blob file and combining with another while keeping transparency

Question: Im trying to combine an image I create from a blob I pull from my database with another I create on the fly thats transparent. My reason for doing this is because I need the image dimensions to be within the power of two so I can use them as textures in opengl. Im kind of at a loss on how to place the blob image within the one I create on the fly exactly where I want it. Not only that but when I create the image from the blob it occasionally leaves any black spots transparent which definitely sucks.
So how can I create an image from a blob file and combine it with another while maintaining transparency. Im using the gd library by the way.
Answer: There's imagecreatefromstring(), so you'd simply have
<code>$img = imagecreatefromstring($blob);
</code>
and then use $img as you would any other picture that'd you loaded from imagecreatefromjpeg/gif/png. The string version is actually somewhat intelligent and will try to figure out what type of picture you've got in the string, unlike the quite stupid imagecreatefromSOMETHING() versions, which have no brains whatsoever.


A minimal structure that is a model of a complete theory must be a prime model

Question: I am trying to see that if $\underline{A}$ is a minimal $L$-structure that is a model of a complete theory $T$, then $\underline{A}$ is a prime model of $T$. I see that if $T$ is assumed to have a prime model this holds, but I can't seem to get it without this assumption.
Here, $\underline{A}$ a $minimal$ $structure$ means $\underline{A}$ has no proper substructure. A $complete$ $theory$ is a satisfiable, deductively closed set of $L$-sentences such that for every $L$-sentence $\phi$, we must have $\phi$ in $T$ or $¬\phi$ in $T$. $\underline{A}$ is a $prime$ $model$ of $T$ if for any other model $\underline{B}$ of $T$, there exists an elementary embedding $\pi$ : $\underline{A} $$\rightarrow$$\underline{B}$.
Any help/ideas would be greatly appreciated. So would any links to examples of questions about equivalence of certain types of models.
Comment: Minimal should mean that it has no proper *elementary* substructure, right?
Comment: @AlexKruckman for me a "minimal model" A of a theory T is such that it has no proper elementary substructure/ submodel (of T), but a "minimal L-structure" A is simply a structure such that there is no L-structure embedding from A' -->A where the domain/universe of A' is a proper subset of A, and the map is simply inclusion.
Comment: Oh, but this just means that every element of $A$ is named by a term in the constants. Then there's obviously a map from $A$ to any other model of $T$, and it's elementary since $T$ specifies the type of every tuple from $A$. If this is really the question you meant to ask, I'll convert this comment to an answer.
Comment: This is the question I meant, yes. Thank you, that is much more straightforward than I thought.
Comment: @AlexKruckman Why? The theory of the infinite line graph (with two unary functions symbols to go forward and backward, instead of a binary predicate) satisfies the conditions of the question, but has no constants.
Comment: @zarathustra I prefer to allow empty structures, and your example has a proper (empty) substructure. If you ban empty structures, your example is indeed a minimal structure... but then the statement ech-93 is trying to prove is false! I'll post an answer explaining this soon.
Answer: First, let's observe that any structure $A$ contains the substructure generated by the empty set: $$\langle \emptyset\rangle_A = \{t^A\mid t\text{ is a term}\}.$$
When I talk about terms in this answer, I mean terms with no free variables or parameters, i.e. terms built up from the constant symbols by applications of the function symbols. If there are no constants, there are no terms in this sense, and $\langle \emptyset\rangle_A$ is empty. $t^A$ is the term $t$ evaluated in the structure $A$.
Now if $A$ is a minimal structure, in the sense that it contains no proper substructure, we have $A=\langle\emptyset\rangle_A$, and hence every element of $A$ is named by a term.
Let $T = \text{Th}(A)$, and suppose $B\models T$. Then there is a map $A\to B$ given by $t^A\mapsto t^B$. This map is well-defined and injective, since for terms $s$ and $t$, we have $$s^A = t^A \iff T\models s = t \iff s^B = t^B.$$ And it is an elementary embedding, since for any tuple $t_1^A,\dots,t_n^A$ and $L$-formula $\varphi(x_1,\dots,x_n)$, we have $$A\models \varphi(t_1^A,\dots,t_n^A) \iff T\models \varphi(t_1,\dots,t_n) \iff B\models \varphi(t_1^B,\dots,t_n^B).$$

There are two ways to make this question less trivial.

Maybe you don't allow the empty structure, so "$A$ is minimal" means "$A$ has no proper nonempty substructure". If there are no constant symbols in the language, then a minimal structure $A$ in this sense has the unusual feature that for any element $a\in A$, $\langle a\rangle_A = A$. I view this interpretation of the question (and the banning of the empty structure, more generally) to be wrongheaded - in this case, it introduces an artificial distinction between languages with constant symbols and those without constant symbols.
You could ask the analogous question for elementary embeddings. That is, is it the case that a structure with no proper elementary substructure is a prime model for its theory?

The answer is no for both of these questions, and I can give you a single counterexample that works for both.
Let $L = \{s,p\}$, where $s$ and $p$ are unary function symbols, and let $L^* = L\cup \{P\}$, where $P$ is a unary relation symbol.
Let $T$ be the $L$-theory which asserts that $s$ is a bijection with no cycles and $p$ is its inverse. So models of $T$ look like disjoint unions of copies of $\mathbb{Z}$, with $s$ and $p$ interpreted as successor and predecessor.
If we expand a model of $T$ to an $L^*$-structure, we think of tagging each element with $0$ or a $1$, depending on whether $P$ holds. Now let $T^*$ be $T$, together with axioms asserting that any finite binary sequence is realized somewhere. For example, given the binary sequence $1101$, we have an axiom that says $\exists x\, P(x)\land P(s(x)) \land \lnot P(s(s(x)) \land P(s(s(s(x)))$. In fancy language, $T^*$ is the model companion of $T$ in the language $L^*$, and it states that $P$ is a generic predicate on models of $T$.
Here are some things to check:

$T^*$ is complete. This can be proven using an Ehrenfeucht–Fraïssé game argument, for example.
$T^*$ has a model $A$ whose reduct to $L$ is just a single copy of $\mathbb{Z}$. You can build $A$ by hand, by taking the list of all finite binary sequences and tacking them on one by one.
$A$ has the property that it is generated as an $L^*$-structure by any single element. Thus, it has no nonempty proper substructure (and, in particular, no proper elementary substructure). So it is minimal in the sense of both 1. and 2. above.
$A$ is not a prime model for $T^*$. Why? Given any particular element $a\in A$, $\text{tp}(a)$ contains the whole binary sequence on $a, s(a), s(s(a)), s(s(s(a))),\dots$. This type is not isolated, and it can be omitted in another model of $T^*$ (in fact, you can build this model by hand too, though the construction is a little tricker, since you have to realize all finite binary sequences, while also blocking any particular element from beginning the infinite binary sequence encoded by $\text{tp}(a)$).


Bootstrap - Collapse item with 'special' attribute on it

Question: this is my first question so don't eat me.
I want to use collapse from bootstrap but I don't want to use id/class in data-target/aria-controls. Is there a way to call it by attribute like that ?

Answer: Yes you can! The data-target attributes accepts any valid CSS Selector (Bootstrap docs).
So using data-attribute CSS selectors (CSS Tricks article) you can do exactly what you want.
Here's a minimal working example (only tested in Chrome. Formatted for readability).
I'm a button

   I'm some stuff in a collapsible

Bootply example
Should work in all browsers that support attribute selectors, which were present in CSS level 2.1, so should be fine across all in use browsers - http://caniuse.com/#feat=css-sel2


On the intersection of affine open with the blowing-up of $\Bbb C^n$ at the origin

Question: the blowup of $\Bbb C^n$ at the origin is the subvariety of $ \Bbb P^{n-1} \times \Bbb C^n$  given by

$B = V(x_{i-1} y_j - x_{j-1} y_i \mid 1 \le i < j \le n)$.$\  \  \ $ (1)

I am interested in computing $B\cap (U_{i-1} \times \Bbb C^n)$ for $i\in \{1,...,n\}$, where $U_{i-1}=\Bbb P^{n-1} \setminus V(x_{i-1}) = \operatorname{Spec} \Bbb C [\frac{x_0}{x_{i-1}},...,\frac{x_{i-2}}{x_{i-1}},\frac{x_{i}}{x_{i-1}},...,\frac{x_{n-1}}{x_{i-1}}]$.
I see in the literature the following and I don't see where it comes from:

$B\cap (U_{i-1}\times \Bbb C^n) = \operatorname{Spec} \Bbb C[\frac{x_0}{x_{i-1}},...,\frac{x_{i-2}}{x_{i-1}},\frac{x_{i}}{x_{i-1}},...,\frac{x_{n-1}}{x_{i-1}}, y_i]$ (2)

I guess we have only $n$ coordinates because in the following expansion for expression (1), we have $B=\operatorname{Spec} \Bbb C[x_0,...,x_{i},\frac{y_{i+1}}{y_{i}},...,\frac{y_{n}}{y_{i}}]$ but I don't see how we get (2)
Thank you for your help
Answer: Here is the case of $n=2$, and one can extend this calculation in an obvious way to the general case.
In this case, $B$ in $P^1 \times C^2$ is defined by the single function $x_0y_1- x_1y_0$. In the chart $U_0 \times C^2$, where $U_0 = P^1 - V(x_0) = \operatorname{Spec} C[x_1/x_0]$, the equation $x_0y_1- x_1y_0 = 0$ can be written as $y_1 = (x_1/x_0) y_0$. Thus, the coordinate ring of $U_0 \times C^2$ is
$$
C[x_1/x_0,y_0,y_1] = C[x_1/x_0,y_0].
$$
In the general case, on $U_0 \subset P^n$, use the equations $x_0y_j - x_jy_0 = 0$ to see $y_j = (x_j/x_0) y_0$ for $j>0$.


Finding Transformation matrix

Question: Give a formula for the linear transformation $T: P_2 \rightarrow P_2$ with $T(1) = x^2$, $T(1 + x) = x^2 - 1$, $T(1 + x +x^2) = 2x^2 - 1$ What is the kernel of $T$?
So, if I'm getting this right, the two bases are:
$$B = \{1,x,x^2\}$$ and $$B' = \{1,x,x^2\}$$
So
$$[T(1)]_{B'} = \begin{bmatrix} 0\\0\\1 \end{bmatrix}$$
$$[T(1 + x)]_{B'} = \begin{bmatrix} -1\\0\\1 \end{bmatrix}$$
$$[T(1 + x + x^2)]_{B'} = \begin{bmatrix} -1\\0\\2 \end{bmatrix}$$
$$[T]_{B',B} = \begin{bmatrix} 0&-1&-1\\0&0&0\\1&1&2\end{bmatrix}$$
I'm not sure how to get the Kernel, but is this correct?
Answer: Note that $$T(x) = T(1+x) - T(1) = x^2-1-x^2 = -1 $$
and
$$T(x^2) = T(1+x+x^2) - T(1+x) = 2x^2 - 1 -(x^2-1) = x^2, $$
so
$$T(a_0+a_1x+a_2x^2) = a_0T(1) + a_1T(x) + a_2T(x^2) = -a_1 + (a_0+a_2)x^2.  $$
It follows that the kernel of $T$ is
$$\{a_0+a_2x^2: a_0+a_2=0\}.  $$

Finding Transformation matrix


How to align chords, melody and lyrics in LilyPond?

Question: I have to write down a simple song with LilyPond (my iPad music book did disappear when I've tried to recover a backup, so I think it is save to store the music sheets in text form), but I can't figure out, how to align words, melody and chord. I've managed somehow to align words and melody (it seems, as if they are associated over the timing), but I can't find it. I tried everything, but the chords showed up only directly from the beginning of then song, over every note, not about the bars or wherever I would place them.
While I saw some examples, where they were correctly set, I never managed to do it. Also, I can't figure out how to set a partial with two notes. This is my experiment:
\include "predefined-guitar-fretboards.ly"

verseI = \lyricmode {
  \set stanza = #"1."
  Ach was |
  wird denn meine Mutter |
  sagen wenn |
  ich einst kehr zu ihr | zurück?
}

verseII = \lyricmode {
  \set stanza = #"2."
  This is the second verse.
}

theChords = \chordmode {
   d | g | a | d
}

staffMelody = \relative c' {
   \key c \major
   \clef treble
   \time 4/4
 \partial 8*4 a8 d8 |
 f4 f8 f8 g4 f4 |
 e2 b b' |
 a g f |
  % \bar "|."
}

\score {
  <<
   \context ChordNames { \theChords }
    \new Staff {
      \context Voice = "voiceMelody" { \staffMelody }
    }
    \new Lyrics = "lyricsI" {
    \lyricsto "voiceMelody" \verseI
    }
    \new Lyrics = "lyricsII" {
    \lyricsto "voiceMelody" \verseII
  }
 >>
 \layout { }
 \midi { }

}
Comment: I suspect you have to specify rhythm for the chord names and the default rhythm is quarter note (crotchet), which is why the names are showing up every quarter note. If it's anything like other notation packages, you'll probably have to manually break words into syllables, like putting "Mut-ter" if those syllables are supposed to be on different notes.
Answer: There are several different ways to input lyrics to Lilypond, and the differences between them are confusing. This just describes one way, to get you started.
You need to input "something" as a lyric for every note in the melody, but the underscore character _ doesn't print anything, so you can use that to leave a space.
Also, you need to split the words into syllables. You should always input -- where there might be a hyphen. Lilypond won't print the hyphen if there is no room for it. (In the example, the hyphen is printed in "sa-gen" but not in "Mutter"). Note, there should be spaces between the syllables and any -- or _ characters in the input.
For the chords, you need to specify the rhythm in the same way as for notes. You can use s to make an "invisible rest," as at the start of the song.
I found your song here:
http://www.heimat-bayern.de/uploads/8445f14732c410b3a0669cfdc345d6bd.pdf
I added the correct key signature, and fixed some of your notes and rhythms to match the PDF version.
\version "2.18.2"
\include "predefined-guitar-fretboards.ly"

verseI = \lyricmode {
  \set stanza = #"1."
  Ach was |
  wird denn meine Mut -- ter |
  sa -- gen wenn |
  ich einst kehr komm nach  | Haus?
}

verseII = \lyricmode {
  \set stanza = #"2."
  This _ | is _ the se -- cond | verse. _
  One | two _ _ three | four.
}

theChords = \chordmode {
   s4 | d1 | g1 | a1 | d1
}

staffMelody = \relative c' {
   \key d \major
   \clef treble
   \time 4/4
 \partial 4 a8 d8 |
 fis4 fis8 fis8 g4 fis4 |
 e2 b4 b' |
 a4. g8 fis4 eis | fis2
  % \bar "|."
}

\score {
  <<
   \context ChordNames { \theChords }
    \new Staff {
      \context Voice = "voiceMelody" { \staffMelody }
    }
    \new Lyrics = "lyricsI" {
    \lyricsto "voiceMelody" \verseI
    }
    \new Lyrics = "lyricsII" {
    \lyricsto "voiceMelody" \verseII
  }
 >>
 \layout { }
 \midi { }
}

Comment: Hello Alephzero, i marked your answer as correct, as it showed me some tricks, with which could answer some fundamental questions about the typesetting in lilypond. It is a very complex tool, and i wonder every time, why there are always only complex documentations, seemingly for already experts (not only lilypond, nearly every tool). Nevertheless, there is much work to do for me because i have to adapt many subtle thing, which aren't quite obvious. The song you found is the right one, but traditions vary and i have a very different piece, which i try to adapt. Thank you!


1 Gig LAN transfer speed on 12 MB/s

Question: I'm transfering files between 2 linux servers on the same network.
This is the Network configuration on both of them:
server 1:

Settings for eth0:
    Supported ports: [ TP ]
    Supported link modes:   10baseT/Half 10baseT/Full
                            100baseT/Half 100baseT/Full
                            1000baseT/Full
    Supported pause frame use: No
    Supports auto-negotiation: Yes
    Advertised link modes:  1000baseT/Full
    Advertised pause frame use: No
    Advertised auto-negotiation: Yes
    Speed: 1000Mb/s
    Duplex: Full
    Port: Twisted Pair
    PHYAD: 1
    Transceiver: internal
    Auto-negotiation: on
    MDI-X: on
    Supports Wake-on: pumbag
    Wake-on: g
    Current message level: 0x00000001 (1)
                           drv
    Link detected: yes

server 2:

Settings for eth0:
          Supported ports: [ TP ]
    Supported link modes:   10baseT/Half 10baseT/Full
                            100baseT/Half 100baseT/Full
                            1000baseT/Full
    Supported pause frame use: Symmetric
    Supports auto-negotiation: Yes
    Advertised link modes:  10baseT/Half 10baseT/Full
                            100baseT/Half 100baseT/Full
                            1000baseT/Full
    Advertised pause frame use: Symmetric
    Advertised auto-negotiation: Yes
    Speed: 1000Mb/s
    Duplex: Full
    Port: Twisted Pair
    PHYAD: 1
    Transceiver: internal
    Auto-negotiation: on
    MDI-X: Unknown
    Supports Wake-on: pumbg
    Wake-on: g
    Current message level: 0x00000007 (7)
                           drv probe link
    Link detected: yes

Both servers connected to the same switch, which supported 1 Gig, with Cat5e / Cat6.
I really don't know what could possibly cause that speed.
I've read that maybe the 'auto-negotiation' configure may do it?
Can I check what is the negotiated speed then somehow?
Comment: What are you using to transfer the files?
Comment: Please detail your hardware config, switch model and the specific command are you using for the transfer.
Comment: Hi, I'm using 'rsync -avzh --progress' command. my switch is hp v1910-48g. I also just tried to replace the Cat 5e cable to cat7, same speed.
Comment: Update: I just remvoed the '-h' from the rsync command, and the speed is now on 40 MB/s... any explanation ?
Comment: Is this a principal rsync (ie, copying stuff over for the first time), or a simple check-for-a-few-added-files-and-copy-them rsync?  If the former, when you repeated the test without `-h`, did you first delete the destination tree?
Comment: Hi, this is a principal rsync, copying for the first time. is 40 MB/s is a good speed for 1 gb link?
Comment: And when you retested without the `-h`, did you first delete the destination tree (ie, rerun the copy from scratch)?
Comment: Hi, No, I did not delete the destination tree, But when I ran the command again, It's just continue from the point he stopped.. If I delete the destination tree, he will just copy from the beginning, no?
Answer: To add to iwaseatenbyagrue's answer, there are likely several things going on here, and keeping your eye on what you're testing is important.
Firstly, the first run of rsync involves write overhead on the destination.  When a small number of large files are being copied, this is fairly cheap, assuming you have half-decent discs, though it can make things slower than your network would suggest.  When a large number of small files are being copied, this can be extremely expensive: each time a file is laid down on disc, the inodes must be updated, the directory file brought up-to-date, and so on, and this introduces latency.  The time required for these FS operations eats up time that could be used for copying more file contents, so your apparent throughput drops like a stone.
Secondly, the -h business.  When you kill an rsync halfway through then rerun it, the rsync starts from scratch again, but because rsync is wise to content that already exists on the destination side and does not recopy it, the apparent throughput will be much better, at least until it runs past the point where it stopped first time around.  Thus the first and second runs of rsync with no other changes whatsoever will likely differ considerably in performance.  Make sure you're comparing apples with apples before getting worried that the second apple is a funny colour, ie, orange.
You may also find that if your corpus of files to copy is a mix of small and large files, your rsync varies in performance depending on how far through the corpus it is; see above.
Upshot: if you want to test your network, test only your network, do not conflate other issues by picking a test that also tests your FSes, underlying storage devices, etc.  netcat is a very nice tool for removing as much extraneous material as possible from a network test, inasmuch as you can feed it incompressible data from /dev/urandom at one end, and shove that across a network with very little tool overhead (no compression, encryption, etc.).
Comment: I'd suggest, this on the client: `dd if=/dev/zero bs=16384 count=1638400 | nc 192.168.10.10 11211` and `nc -l 11211 > /dev/null` on the host 192.168.10.10
Answer: Not quite an answer, but you might want to validate your network throughput alone, rather than using network + disk throughput (+ possibly other factors, like the encryption overhead if using rsync over SSH, compression overhead if you use compression, etc).
iperf is a good tool for doing that, and should allow you to confirm how your network performs, as opposed to how your end to end throughput performs.
I suspect that in your case (based notably on the differences you mention between rsync runs), your network throughput would end up being roughly what it should be, which would tend to point away from the network being your bottleneck - but that is pure speculation.
Comment: @iwaseatenbyagrue whilst I agree that would be a good question, it's not *this* question.  We're not so fond of chameleon questions around here, where we solve one problem and the questioner mutates the question into their followup question, which then changes again as we solve the followup issue.  If the OP wants to ask about that, I think accepting an answer to this question and asking a new one that references this question is a better idea.
Comment: I was thinking about trying 'iperf', but the server i'm transfering files from, is currently in 'read-only' system, because of raid fail.. This is why I'm transfering all the files to another server. So I cannot install iperf on it..
Comment: Ah, right - then yes, iperf is kind of waste of time - I had thought the concern was that something was wrong with the network  - I didn't realise the context was needing to get the files from A to B before A fails. Maybe worth updating your question to mention this fact - it could help get some suggestions to improve your ability to pull the data ASAP.
Comment: @MadHatter - thanks for correcting me. And I agree - although the comments to the question paint a different picture than the question itself does (and I was thinking of that overall), the question itself is about throughput. And, it turns out, network throughput is very likely not the actual issue here - so I guess this is an [XY problem](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem)
Comment: @iwaseatenbyagrue you put it very well indeed, thank you.

1 Gig LAN transfer speed on 12 MB/s


Auto create nodes from external RSS source

Question: The scenario I am trying to fulfil is the automatic creation of Drupal nodes from an RSS list.
At the initial execution of cron, the module, custom/contributed, should parse some remote RSS and for each entry in the RSS a Drupal node with matching title, body etc is created.
The next hour when cron fires, any matching content previously created is ignored. Only when there is a new entry in the RSS should new node(s) be created.
Is there an existing module for doing what I have described above?
OR,
Can anyone direct me on how best to implement such a service?
Thanks.
Answer: The feeds module can 'Import or aggregate RSS/Atom feeds'.
https://www.drupal.org/project/feeds
You can set how often it imports and map to fields.
Here's a guide on how to create/edit importers:
https://www.drupal.org/node/638804


Is there a phrase for or meaning to a function that is its own composite?

Question: If there is a function such that $$ f(f(x))=f(x) $$ and $$ f(f(f(x)))=f(x) $$ and so one and so forth for all composites, is there a specific name for that? It's not an involution because it's not it's own inverse, but I figured there must be some term for it.
Comment: Such property is called idempotence: https://en.wikipedia.org/wiki/Idempotence
Comment: $f(f(x))=f(x)$ implies $f(f(f(x)))=f(x)$ and so on.
Comment: You can call the map idempotent.
Comment: An element such that x*x = x is called an idempotent element (for the operation *). So under compsition, $f$ is idempotent.
Comment: Also useful to know, thanks.
Answer: That is an idempotent function. From wikipedia:

A unary operation $f$, that is, a map from some set $S$ into itself, is called idempotent if, for all $x$ in $S$, $\;f(f(x))=f(x)\,$.

It follows by definition that an idempotent function satisfies $f(f(f(x)))=f(x)\,$, and by induction $f(f(\cdots f(x)\cdots)) = f(x)\,$.
Answer: I would use the word idempotent.


How $\int_{\gamma\times\gamma} F(x,y)dxdy$ and $\int_{\gamma} F(x,x)dx$ are related

Question: Let $F(x,y)$ be a function of two complex variables, such that $F:{\mathbb C}\times {\mathbb C}\to {\mathbb C}$ is also a Mercer kernel (i.e. $[F(x_i, x_j)]$ is always a PSD matrix), and $F(x,\cdot)^\ast$ and $F(\cdot,x)$ are holomorphic for any $x$ (with possibly only 1 singular point, 0). Let $\gamma\subseteq {\mathbb C}$ be a boundary of a connected closed region containing 0.
How are $\int_{\gamma\times\gamma} F(x,y)dxdy$ and $\int_{\gamma} F(x,x)dx$ related (which inequalities hold)?
Also, the general question: is there any simple criteria for $\int_{\gamma\times\gamma} F(x,y)dxdy$ to be finite?
Comment: I haven't found a definition of complex-valued kernels, or whether Mercer's theorem applies to them.
Comment: To simplify, let $F(x,y) = \sum_i \phi_i(x)\phi_i (y)^\ast$, where $\phi_i$ is holomorphic with a singular point 0.
Comment: So, $F(x,y)$ is a symmetric, positive definite kernel on a set ${\mathbb C}$.
Answer: A helpful(?) Hint:
The mentioned Mercer's theorem itself is a generalization of the result that any symmetric positive-semidefinite matrix is the Gramian matrix of a set of vectors.
For Gramian matrix we can use the triangle inequality:
$\langle v_1,v_1 \rangle +\langle v_1,v_2 \rangle +\ldots=\| v_1 +v_2 +\ldots\|^2\leq (\| v_1\| + \|v_2\| +\ldots)^2$
Taking square root and generalizing (!?), I claim that:
$$\int F(x,y)dxdy\leq \int F(x,x)dx$$


Como pegar coordenadas pelo click do mouse com Python?

Question: Eu tenho um código que me retorna o valor de uma cor em hexadecimal em uma determinada coordenada, no caso do código as coordenadas são 200 e 200, o problema é que ficar colocando esses valores pelo teclado  é meio trabalhoso, teria alguma forma de adicionar essas coordenadas através de um clique de mouse ?. tipo ao clicar no ponto onde quero as coordenadas vão diretamente para ali, para o getpixel()? Muito obrigado
<code>import pyautogui

pixelColor = pyautogui.screenshot().getpixel((200,200,)) pixelColor = '#%02x%02x%02x' % (pixelColor) print(pixelColor)
</code>
Answer: Bom uma forma de fazer isso em pyautogui seria basicamente assim:
<code>#pega o retorno da posicao atual de x e y do mouse e passa o valor da tupla para as duas variaveis
x, y = pyautogui.position()
print ("Posicao atual do mouse:")
print ("x = "+str(x)+" y = "+str(y))

#retorna True se x & y estiverem dentro da tela
print ("\nEsta dentro da tela?")
resp = pyautogui.onScreen(x, y)
print (str(resp))
</code>
Comment: Obrigado campeão mas acho que me expressei mal, eu não queria as coordenadas do mouse, queria pegar as coordenadas com o click do mouse ao invés de eu ficar colocando os valores através do teclado. Eu clico na minha tela e ele captura as coordenadas e as joga no meu código.


Show that $f:X\rightarrow Y$ is continuous in all points $x\in X$ which are not accumulation points of $X$

Question: I have the following task:

Let $X$ and $Y$ be topological spaces and $f:X\rightarrow Y$ a
  mapping. Show that $f$ is continuous in every $x\in X$ which is not an
  accumulation point of $X$.

I'm using the following definitions:
Definition 1:
Let $X$ and $Y$ be topological spaces and $f:X\rightarrow Y$ a mapping. Mapping $f$ is continuous at point $x_0\in X$ if for every neighborhood $V$ of $f(x_0)$ there exists a neighborhood $U$ of $x_0$ such that $f(x)\in V$ always when $x\in U$.
Definition 2:
Let $X$ be a topological space and $A\subset X$. Point $x\in X$ is called an accumulation point of $A$ if for every neighborhood U of $x$ we have $(U\setminus\{x\})\cap A\neq \emptyset$.
I went on trying to solve this by assuming that $f$ is continuous at $x_0\in X$ and that $x_0$ is an accumulation point of $X$. That is for each neighborhood $U$ of $x_0$ we have $(U\setminus\{x_0\}) \cap X = U\setminus\{x_0\}$.
How should I proceed, how can I show that $f$ can't be now continuous at $x_0$? Thank you for any help!
Comment: The question is only about points that *are not* accumulation points of $X$; you don't have to prove anything about points that *are* accumulation points of $X$.
Comment: Aah, funny me...I misread the problem. Sorry about that stupid mistake x) Thank you!
Answer: You have to start with $x_0$ not being an accumulation point of $X$ and then show that $f$ is continuous at $x_0$ using the definition.
Write down what it means that $x_0$ is not an accumulation point of $X$: for some open neighbourhood $U$ of $x_0$ we have that ....
Now use this $U$ in the definition of continuity.
Comment: Thank you, got it. I somehow misunderstood the problem. Clear now :)
Comment: Glad to be able to help!
Comment: Hi Henno, I have one more question to ask :) I tried to solve this now by assuming that $x_0$ is not an accumulation point. That is, there exists neighborhood $U$ of $x_0$ such that $(U\setminus \{x_0\}) \cap X =\emptyset$. Because $U\subset X$ this means that $U=\{x_0\}$. I think this means now that $U\cap X=U\neq \emptyset$ for all neighborhoods of $x_0$. I'm not sure why this means that $f$ is continuous at $x_0$.
Comment: @jjepsuomi Well, start from the definition: take any neighbourhood $V$ of $f(x_0)$. Now try plugging in $U = \{x_0\}$ (which we now know is open (!) by virtue of not being an accumulation point of $X$)...
Comment: Okay, I'll try and get back to you to confirm if I got it right =) appreciate it
Comment: I tried like this: Let $V$ be a neighborhood of $f(x_0)$ in $Y$. If for $x_0$ there is a neighborhood $U=\{x_0\}$, then clearly $f(x)\in V$ when $x\in U=\{x_0\}$. So for every point $x\in X$ for which there exists a neighborhood $U=\{x\}$ then $f$ is continuous at $x$. Does this make sense? :)
Comment: Yes, quite. You can always get close to $f(x_0)$ if you can force $x = x_0$, essentially.
Comment: Thank you very much! sorry if I have funny questions, I'm a beginner in topology and some definitions etc. are still a bit unclear here and there. This was a bit confusing problem because the answer seemed too obvious =)
Comment: It shows for instance that if $X = [0,1] \cup \{2\}$ then it does not matter how we define $f$ on $2$ for continuity at $2$. We cannot get close to it with other points.
Comment: I see :) Thank you for the example. You've been most helpful!


Eigenvalues of Operator on $L^{2}[0, 1]$

Question: Let $X=L^{2}[0, 1]$ and $$Ax(t)=\int_{0}^{1}{ts(1-ts)x(s)}ds.$$ I have shown that this operator is compact, hence all non-zero elements of the spectrum $\sigma(A)$ are eigenvalues of $A$. But then I am stuck to find the eigenvalues in order to find the spectrum, i.e. all $\lambda \ne 0$ such that $$\int_{0}^{1}{ts(1-ts)x(s)}ds=\lambda x(t).$$ Can someone help?
Comment: Note that $Ax$ is always a quadratic function without constant terms. In particular eigenfunctions must also have this form.
Answer: Old, Naive, Too Complicated Solution.
Suppose that $x$ is an eigenfunction of $A$ w/ eigenvalue $\lambda$.  That is,
$$\lambda x(t)=Ax(t)=\int_0^1 ts(1-ts)x(s)\ ds.$$
See a remark in the comment section below that proves differentiability of $x$.  Note that
$$\lambda x'(t)=\int_0^1 s(1-ts)x(s)\ ds-t\int_0^1s^2x(s)\ ds.$$
That is,
$$\lambda t x'(t)=\lambda x(t)-t^2\gamma(x)\tag{1}$$
where $\gamma:L^2[0,1]\to \Bbb C$ is given by $\gamma(x)=\int_0^1 s^2 x(s)\ ds$.
Observe that the eigenspace with the eigenvalue $0$ is given by
$$\ker A=\left\{x\in L^2[0,1]:\int_0^1sx(s)\ ds=0\wedge \int_0^1s^2x(s)\ ds=0\right\}.$$
From now on suppose that $\lambda\ne 0$.
From (1), we get
$$\frac{d}{dt}\frac{x(t)}{t}=-\frac{1}{\lambda}\gamma(x).$$
Therefore,
$$\frac{x(t)}{t}=C-\frac{t}{\lambda}\gamma(x)$$
or
$$x(t)=Ct-\frac{t^2}{\lambda}\gamma(x).$$
Since $\gamma(x)=\int_0^1s^2x(s)\ ds$, we need
$$\gamma(x)=\int_0^1s^2\left(Cs-\frac{s^2}{\lambda}\gamma(x)\right)\ ds.$$
So
$$\gamma(x)=\frac{C}{4}-\frac{1}{5\lambda}\gamma(x)\implies C=\left(4+\frac4{5\lambda}\right)\gamma(x).$$
Hence,
$$x(t)=\gamma(x)\Biggl(\left(4+\frac4{5\lambda}\right){t}-\frac{t^2}{\lambda}\Biggr).\tag{2}$$
Therefore, the eigenspace of $A$ w/ eigenvalue $\lambda \ne 0$ is a subspace of the span of
$$x_\lambda(t)=\left(4+\frac4{5\lambda}\right){t}-\frac{t^2}{\lambda}.$$
Plugging this into $\lambda x_\lambda (t)=Ax_\lambda (t)$, it turns out that $\lambda$ must satisfy
$$\lambda\left(4+\frac{4}{5\lambda}\right)=\frac{\frac{1}{\lambda}+80}{60}.$$   That is, $\lambda=\frac{4\pm\sqrt{31}}{61}$.

Simpler Solution.
Suppose that $x$ is an eigenfunction of $A$ w/ eigenvalue $\lambda\neq 0$.  Then,
$$x(t)=\frac{Ax(t)}{\lambda}=\left(\frac{\int_0^1 sx(s)\ ds}{\lambda}\right)t+\left(-\frac{\int_0^1s^2x(s)\ ds}{\lambda}\right)t^2.$$
That is, $x(t)=at+bt^2$ for some constants $a,b$.  Plugging this into $\lambda x=Ax$, we get
$$\lambda(at+bt^2)=\left(\frac{a}{3}+\frac{b}{4}\right) t +\left(-\frac{a}{4}-\frac{b}{5}\right)t^2.$$
Hence,
$$\frac{a}{3}+\frac{b}{4}=\lambda a\wedge -\frac{a}{4}-\frac{b}{5}=\lambda b.$$
So $\lambda$ is an eigenvalue of the matrix
$$\begin{pmatrix}\frac13 & \frac14\\ -\frac14 &-\frac15\end{pmatrix},$$ which means $\lambda=\frac{4\pm\sqrt{31}}{60}$.
Comment: @MartinArgerami  That is because $Ax(t)$ is a polynomial in $t$, so it is differentiable.  Hence if $x$ is an eigenfunction of $A$ with non-zero eig.value, then $x$ is differentiable.  Thanks for the remark, and I have added a remark in my answer.
Comment: I think the spectrum here has to be at most countable...how does that fit together?
Comment: @ShaqAttack1337  I forgot to verify which $\lambda$ gives the right result.
Comment: Thank you for your answer!
Comment: +1, but you need to justify that the eigenfunctions are necessarily differentiable.
Answer: Here is how I would approach this question: Keep differentiating both sides with respect to $t$ until you reach zero on one side. This will show that an eigenfunction has to be a polynomial of a certain degree. Work out the equations for the coefficients of that polynomial from the equation we got so far…
By the way: This operator seems to have a pretty large null space.


MYSQL no route to host

Question: I've looked through the others that use these words.  Not applicable.  I have two machines plugged into the same switch with IP's of 192.168.0.7 and .10.  7 is the client.  10 is the server.  I've checked netstat on the server and it is showing:
<code>Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 192.168.0.10:3306       0.0.0.0:*               LISTEN
</code>
I can ping, sftp and so forth in both directions from either machine.  The PHP itself is as follows:
<code>$host = "192.168.0.10";
$user = "web";
$pass = redacted;
$db = "appliance";
// open connection
$connection = new mysqli($host, $user, $pass, $db);
if ($connection->connect_errno) {
  echo "Error: Failed to make a MySQL connection, here is why: \n";
  echo "Errno: " . $connection->connect_errno . "\n";
  echo "Error: " . $connection->connect_error . "\n";
  exit;
}
</code>
I get this at the browser (3rd machine - same network):

Error: Failed to make a MySQL connection, here is why: Errno: 2002
  Error: No route to host

I've even tried adding the explicit port argument.  Same error.
I don't even know where to look at this point.
Answer: Can You execute this code in both CLI and HTTP environment?
If apache has problem, therefore in cli there was no problem.
Answer: Check if the firewall on your MySQL server is blocking port 3306. For me it caused the 'No route to host' error.
Answer: check your connection to remote and check remote's firewall.
and check bind address in remote my.ini
Comment: It doesn't appear you read the information given, or you wouldn't have suggested any of these.  I've already established that connectivity is possible via other techniques.  Firewall blocking wouldn't generate the error of 'no route to host'.  The netstat output establishes the port is correctly configured and listening.
Comment: More information.  I setup a simple TCP echo server on the same machine (the server at .10) and wrote a PHP client for it.  I get the same 'no route to host' error at the 'socket_connect()' step of that client.  It looks to be that for some reason the local network isn't available to PHP running with apache.

MYSQL no route to host


jhipster translation-not-found[error.url.not.found]

Question: I am currently working on a jhipster project.
I had to encounter some difficulties with jhipster translation-not-found[error.url.not.found],
that I was able to solve and I would like to share the result of my research.
here is my problem in a few pictures.

After refreshing the page, the credentials no longer work
Infos :
jhipsterVersion: 6.10.5
applicationType: monolith
clientFramework: angularX
Environment and Tools
java version "11.0.12" 2021-07-20 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.12+8-LTS-237)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.12+8-LTS-237, mixed mode)
git version 2.15.0
node: v12.16.1
npm: 6.13.4
Docker version 20.10.7, build f0df350
docker-compose version 1.29.2, build 5becea4c
Answer: Resolution,
The problem is due to the high size of the headers at the FRONT (Angular) and BACKEND (Spring-boot) level.
1- FRONT correction :
Edit package.json (Edit the package.json file and add the following parameter On title webpack-dev-server and webpack : <code>--max-http-header-size=102400000</code>)

2- BACKEND correction :
Edit application.propertie files (application-dev.yml and application-prod.yml), add : server.max-http-header-size: 102400000

I humbly hope this helps you
Translator: Google translate
Comment: Have you found which header was huge and why?


I have an old Windows NT Workstation with AutoLogon. How can I disable this to login as an Admin?

Question: I have an running Windows NT (in a virtual box) that runs some legacy services.
It logins automatically with user and password (for availability reasons).
Now i need to do some administration, and the connected user has no piviliges.
Logging off automatically logs me on again.
how can i solve this?
Thanks,
Peter
Answer: On XP, holding the Shift key on boot will prevent the autologon which would need to be done from the VM console. I don't have an NT machine to test this on though.
Answer: Using your own machine (or any other) connect remotely to the machine using "net use" and an authorized account. Then run regedit, connect to the remote machine, and edit the registry key responsible for the AutoLogon.


Showing HTML when JS says it should not be

Question: I have a select that the shows the title property on load. I have some JS so that when certain options are selected different divs show. My issue is that the divs show on load and I don't want them to show until their correct option is selected.

function typePicker() {
  var sel = document.getElementById("type");
  var manufacturer = document.getElementById("manufacturer");
  var model = document.getElementById("model");
  var typeInputs = document.getElementById("typeInputs");
  var aps = document.getElementById("aps");
  var cables = '
<input type="text" class="form-control" id="type" name="cableType" placeholder="Type">

<input type="number" class="form-control" id="cost" name="cost" placeholder="Cost">

<input type="number" class="form-control" id="quantity" name="quantity" placeholder="Quantity">

<input type="text" class="form-control" id="location" name="location" placeholder="Location">
';
  // Yes I know this is improper that is why I am doing the switch over and came across this issue

  if (sel.value == "aps") {
    aps.style.display = 'block';
  } else {
    aps.style.display = 'none';
  }

  if (sel.value == "cables") {
    manufacturer.style.display = 'none';
    model.style.display = 'none';
    typeInputs.innerHTML = cables; // This line will be changed soon to the style above in process of doing this to all.
  } else {
    manufacturer.style.display = 'block';
    model.style.display = 'block';
  }
}

  Type
  <select class="form-control selectpicker" title="Type of Asset" name="type" data-live-search="true" id="type" onchange="typePicker()">
<option value="aps">Access Point</option>
<option value="cables">Cable</option>
<option value="desktops">Desktop</option>
<option value="laptops">Laptop</option>
 <option value="deskPhones">Desk Phone</option>
<option value="mobilePhones">Mobile Phone</option>
<option value="monitors">Monitor</option>
<option value="printers">Printer</option>
<option value="projectors">Projector</option>
 <option value="routers">Router</option>
 <option value="switches">Switch</option>
  <option value="tablets">Tablet</option>
  <option value="other">Other</option>
     </select>

      <input type="text" class="form-control" name="ipaddress" id="ipaddress" placeholder="IP Address">

      <input type="text" class="form-control" name="mac-address" id="mac-address" placeholder="MAC Address">

      <input type="text" class="form-control" name="range" id="range" placeholder="Range in M">

      <input type="text" class="textbox-n form-control" name="bands" id="bands" placeholder="Bands">

      <input type="text" class="form-control" name="channels" id="channels" placeholder="Channel(s)">

      <input placeholder="Date Bought" class="textbox-n form-control" type="text" onfocus="(this.type=\'date\')" onblur="(this.type\'text\')" id="date-bought" name="dateBought">

      PoE

      <input type="radio" name="poe" id="option1"> Yes
      <input type="radio" name="poe" id="option2"> No

      <input placeholder="Warranty Expiration Date" class="textbox-n form-control" type="text" onfocus="(this.type=\'date\')" onblur="(this.type=\'text\')" id="warranty-date" name="warrantyDate">

      <input class="form-control" id="location" placeholder="Location">

I can not get the snippet to work at all when you select another option. The only one there is code for in the snippet is for the aps and cables ones. Code works file on my server and is good enough for this snippet I believe. The main issue of the aps div showing upon load is the problem. How can I make it not show on load?
If additional code or info is needed please ask away.
Comment: Instead of snippet you may try http://jsfiddle.net or https://plnkr.co or whatever...
Comment: Just a note really but this seems like a good way to develop - show everything so that users without js get all content and then only if they have js should that content then be hidden and controlled by js. According to the priciples of unobtrusive javascript anyway. So, I just wish to warn against hiding them on load using CSS since users without js won't have an option to display them. Hide them on load using js.
Comment: @wunth I have multiple fields with the same name but for different models to save in your way would not work. Plus who doesn't have JavaScript anymore? Chrome, Safari, Firefox, Edge ect all gave it by default.
Comment: @joshkirby I'll take note that #aps{display:none} (your accepted solution) isn't possible in javascript. Also be aware that in order to show each section you'll have to once again show the containing div (using javascript) and manage the visibility of the individual divs within (which is what you should do in the first place). Google crawlers won't interact with you page to see content so it's also an SEO concern so not so much 'who' as 'what'.
Comment: @wunth the SEO is not an issue because this page will be behind a subscription paywall. Google can't get to it without a valid account.
Answer: I implemented what your question is asking for in CSS.
#aps {
  display: none;
}

This will hide you div with the ID of 'aps' by default, on load. You can then modify the style to display it when you need it.

function typePicker(){
  var sel = document.getElementById("type");
  var manufacturer = document.getElementById("manufacturer");
  var model = document.getElementById("model");
  var typeInputs = document.getElementById("typeInputs");
  var aps = document.getElementById("aps");
  var cables = '
<input type="text" class="form-control" id="type" name="cableType" placeholder="Type">

<input type="number" class="form-control" id="cost" name="cost" placeholder="Cost">

<input type="number" class="form-control" id="quantity" name="quantity" placeholder="Quantity">

<input type="text" class="form-control" id="location" name="location" placeholder="Location">
';
   // Yes I know this is improper that is why I am doing the switch over and came across this issue

  if(sel.value=="aps"){
    aps.style.display = 'block';
  }else{
    aps.style.display = 'none';
  }

  if(sel.value=="cables"){
    manufacturer.style.display = 'none';
    model.style.display = 'none';
    typeInputs.innerHTML=cables; // This line will be changed soon to the style above in process of doing this to all.
  }else{
    manufacturer.style.display = 'block';
    model.style.display = 'block';
  }
}
#aps {
  display: none;
}

        Type
        <select class="form-control selectpicker" title="Type of Asset" name="type" data-live-search="true" id="type" onchange="typePicker()">
            <option value="aps">Access Point</option>
            <option value="cables">Cable</option>
            <option value="desktops">Desktop</option>
            <option value="laptops">Laptop</option>
            <option value="deskPhones">Desk Phone</option>
            <option value="mobilePhones">Mobile Phone</option>
            <option value="monitors">Monitor</option>
            <option value="printers">Printer</option>
            <option value="projectors">Projector</option>
            <option value="routers">Router</option>
            <option value="switches">Switch</option>
            <option value="tablets">Tablet</option>
            <option value="other">Other</option>
        </select>

                <input type="text" class="form-control" name="ipaddress" id="ipaddress" placeholder="IP Address">

                <input type="text" class="form-control" name="mac-address" id="mac-address" placeholder="MAC Address">

                <input type="text" class="form-control" name="range" id="range" placeholder="Range in M">

                <input type="text" class="textbox-n form-control" name="bands" id="bands" placeholder="Bands" >

                <input type="text" class="form-control" name="channels" id="channels" placeholder="Channel(s)">

                <input placeholder="Date Bought" class="textbox-n form-control" type="text" onfocus="(this.type=\'date\')" onblur="(this.type\'text\')" id="date-bought" name="dateBought">

                PoE

                <input type="radio" name="poe" id="option1"> Yes
                <input type="radio" name="poe" id="option2"> No

                <input placeholder="Warranty Expiration Date" class="textbox-n form-control" type="text" onfocus="(this.type=\'date\')" onblur="(this.type=\'text\')" id="warranty-date" name="warrantyDate">

                <input class="form-control"  id="location" placeholder="Location">

Comment: Thanks didn't think of using CSS, was looking only at J's but you're right CSS will work good enough and likely is "better" depending on who you ask


A basic question on denseness in a metric space

Question: Suppose we have a metric space with a countable dense subset. Now consider a subset $E$ and a $p \in E$. Now consider the set $\cup_{q \in E, q \neq p}N_{r_i}(q)$. Does it set covers $p$, $\forall r_i >0$. It looks like so. How to prove it ?
The notation $r_i$ means that radius of a neighbourhood of $q$ depends on the point $q$. For example, in $\Bbb R$ suppose we have a neighbourhood $N_r(p)$ of a point $p$. Then if I choose any neighbourhood for each $q \in N_r(p), q \neq p$ and take the union of this neighbourhoods. Does this set covers $p$ ? If true, is it true for any metric space with countable dense subset in general ? Does it make sense now ?
Comment: Are you too busy asking such a lot of questions, that you can't reply to the comments people leaves asking for clarification? It is good to ask questions, it's very important actually, but you'll get more chances to get them answered if you are more responsive.
Comment: It isn't clear what you're asking. First, your use of the subscript $i$ makes no sense: if $i$ is a constant, you just don't need it, and if it depends on $q$, you should say so. I'm going to assume that you mean $r_q$, a radius that depends on $q$. If there is some $q\in E\setminus\{p\}$ for which $r_q>d(q,p)$, then of course $p\in N_{r_q}(q)$, which is a subset of your union. On the other hand, if $r_q\le d(p,q)$ for each $q\in E\setminus\{p\}$, then your union does not contain $p$.
Comment: Is it your question: "Suppose we have a metric space, with a countable dense subset $Q$. Now consider the set $$\bigcup_{\substack{ q \in Q\cap (E\setminus\{p\})\\ r\gt 0}}N_r(q).$$ Does it covers $p$?" ?
Comment: @leo: sorry, I clarified the problem definition now.
Comment: @leo: I am asking even whether the set $\cup_{E-\{p\}}N_r(q)$ covers $p$. Here $r$ depends on the point $q$.
Answer: Suppose that for each $q\in E\setminus\{p\}$ we've chosen a radius $r(q)>0$. Whether or not $p\in\bigcup_{q\in E\setminus\{p\}}N_{r(q)}(q)$ depends entirely on the choice of radii $r(q)$.

If $r(q)\le d(p,q)$ for each $q\in E\setminus\{p\}$, then for each $q\in E\setminus\{p\}$ we have $p\notin N_{r(q)}(q)$, so of course $$p\notin\bigcup_{q\in E\setminus\{p\}}N_{r(q)}(q)\;.$$
If there is a $q_0\in E\setminus\{p\}$ such that $r(q_0)>d(p,q_0)$, then $p\in N_{r(q_0)}(q_0)$, so $$p\in\bigcup_{q\in E\setminus\{p\}}N_{r(q)}(q)\;.$$
Comment: yes, I understood now.
Comment: @Prasenjit: Excellent.


Django QuerySet with Models

Question: I'm new to Django and trying to understand how to use querysets with models.
Model
class Channel(models.Model):
    name = models.CharField(max_length=200)
    accountid = models.CharField(max_length=34)

    def get_channel_list(self):
        return self.get_queryset().name()

What I want to do is return the entire name column as an array if account id matches. I'd like to use a function in the models.py but I haven't found an online sample that caters to what I'm looking for.
The above isn't returning any data even without a filter.
Any point in the right direction would be amazing.
Comment: do you want to return a name field value for an record with given accountid?
Comment: I want to return all name field values for all records with the given accountid.
Answer: Use objects.filter and classmethod:
class Channel(models.Model):
    name = models.CharField(max_length=200)
    accountid = models.CharField(max_length=34)

    @classmethod
    def get_channel_list(cls, acc):
        return cls.objects.filter(accountid=acc).values_list('name', flat=True)

There is another technique to do such things in django - define custom manager to model. (for example, you have several Channel models inherited from one base proxy model and you want to put same get_channel_list functions to some models - custom Manager is the way to go):
class ChannelManager(models.Manager):
    def get_channel_list(self, acc):
        return self.filter(accountid=acc).values_list('name', flat=True)

class Channel(models.Model):
    name = models.CharField(max_length=200)
    accountid = models.CharField(max_length=34)

    objects = ChannelManager()

Comment: You could also use `self.objects.filter(accountid=self.accountid)`, since you're calling this as an instance method. If you don't do that, it might be purer design to declare the above as a class method.
Comment: How would I call this in a view? like I said, very new to Django. :\
Comment: Neither of these will work, as you can't access `objects`from an instance.
Comment: I think that he is looking for a static method, but of course +1 for an exact answer and for flat=True
Comment: I'm looking for it to be dynamic depending on whos logged in
Comment: @AndrewWilson just call Channel.get_channel_list(ACCOUNTID_YOU_NEED) and list with names will returned
Comment: You sir are the man, this works perfectly for what I need and I can expand off of this.
Comment: @ndpu I'm having troubles sorting by asc i'm using `return cls.objects.filter(accountid=account).order_by('-name').values_list('name', 'channelid')` It's listing them in this order
"TEST",
"B TEST",
"A TEST CHANNEL",
"A TEST CHANNEL",
"A TEST 2",
"A B TEST",
"TEST CHANNEL",
"TEST 3",
"TEST 3",
"TEST 2 CHANNEL"... Any thoughts?
Comment: figured out it's because it's case sensitive, hmmph. still stumped
Comment: Since it's really a new question, I posted it's own question for it http://stackoverflow.com/questions/20768955/django-query-sort-case-insensitive-using-model-method-with-postgresql
Answer: You have failed to understand the difference between managers and models. It's the manager that it's responsible for creating queries, and which has the get_queryset method. From a model, you need to access the manager, which is usually named objects. Note, you cannot do that from an instance, so this needs to be a classmethod.
@classmethod
def get_channel_list(cls, accountid):
    return cls.objects.filter(accountid=accountid).values_list('name')

Answer: I needed to access the queryset/manager for a different reason, since google brought me here - this ended up my solution:
class Channel(models.Model):
    name = models.CharField(max_length=200)
    accountid = models.CharField(max_length=34)

    def get_channel_list(cls, acc):
        return self.__class__.objects.filter(accountid=acc).values_list('name', flat=True)

Django QuerySet with Models


How to rank observations with two variables (website performance)

Question: I have no background in statistics, so I find myself confused by this simple problem. I'm not even sure which search terms to use.
I have some website performance data. I have the number of times a page was requested/visited, and how long it took to load (average time and percentiles in seconds).

I want to identify pages that are often requested/visited but take a long time to load. So for example, if an "FAQ" page takes 30 seconds to load but is only visited a few times a day, this is less important than a "Search" page that takes 2 seconds to load but is used thousands of times a day. The purpose is to make a "Top 10" list or something like that which some website developers will use to improve performance.
I had thought to do something simple like create a new column with NUM_TRANSACTIONS * AVERAGE and sort that, but I'm wondering if there is something wrong with this approach.

SOLVED: Edgar's answer worked well for me. I created the plot he suggested, and the scoring mechanism, and they produced similar results. The number markers indicate ranking.
Comment: Log scale often helps on such graphs.
Comment: On log scale lines with $xy$ constant are straight too.
Comment: You are interested in the product $xy$ of your two variables. On log scale hyperbolas  $xy =$ constant are mapped to straight lines $\log x + \log y =$ another constant. I find straight lines easier to compare than hyperbolas. Also, log scale will spread your data more evenly.
Comment: Thanks for the tip, @NickCox, it is easier to read now. I don't understand your second comment though. Are you suggesting another improvement?
Comment: Thanks for explaining, @NickCox. It's a big help.
Answer: NUM_TRANSACTIONS * AVERAGE is the total time spent loading this page (e.g. page 1: the sum of all 891 343 loading times of this page), since AVERAGE = TOTALTIME/NUM_TRANSACTIONS. This is not a good measure for your problem, since you lose the information which pages are requested frequently.
For the start, it might be helpful to plot the NUM_TRANSACTIONS versus the AVERAGE time to load (since we don't know anything else about the pages like number of images/javascript code/whatever) and inspect visually if there are unusually high AVERAGE loading times associated with high NUM_TRANSACTIONS.
Alternatively, if you want to identify the Top 10 problematic candidates, you could find the overall average loading time: TOTALAVERAGE = (sum of all (NUM_TRANSACTIONS*AVERAGE))/(sum of all NUM_TRANSACTIONS), then sort your pages by decreasing NUM_TRANSACTIONS and take the 10 topmost pages where AVERAGE is above TOTALAVERAGE.
Bulding on this, you could calculate a rough SCORE = NUM_TRANSACTIONS*(AVERAGE-TOTALAVERAGE) for all pages and take the Top 10 with the highest positive SCORE.
Comment: Thank you Edgar. Your first paragraph shows exactly the sort of bone-headed mistake I was trying to avoid. I'm going to try both of the approaches you suggest. My goal is to make something like a "Top 10" list. (I will mark a question correct this afternoon.)
Comment: I edited my answer, adding a very rough score that might help you associating number of transactions and higher-than-average loading times.
Comment: Just checking, but I think you must mean `TOTALAVERAGE = (sum of all (NUM_TRANSACTIONS*AVERAGE))/(sum of all NUM_TRANSACTIONS)`?
Comment: yes, that's correct :)
Comment: If you have a moment for a mini-question: is this just "basic stats"? I feel like I just stumbled upon a big blank spot in my education and I'd like to fill it with something, but I'm not sure what the topic is -- "stats" seems too broad.
Comment: It's more like data analysis. This is more of an ad hoc solution, since it's not a classical problem from statistics.


Second order non-linear differential equation (damped oscillator)

Question: I am trying to solve this second-order non-linear differential equation. $m$, $k$, $t$ are all constants. This equation describes the position of a sprung, damped mass.
$$mf''(t) = -k(f(t)-1) -c(f'(t)$$
where
$$f(1)\approx1; f(0)\approx0; f'(0)=0; f''(0)=0$$
A simplified example:
$$f''(t) = -180(f(t)-1) -12(f'(t)$$
Has a verified (graphed) solution of:
$$f(t) = -\frac{1}{2}e^{-6t}(-2e^{6t}+sin(12t)+2cos(12t)) $$
The goal is to find an equation where we can supply the mass, spring and damping constants and then find the position over time.
I am concerned that will not be possible, perhaps the correct format for this equation is
$$mf''(t,m,k,c) = -k(f(t,m,k,c)-1) -c(f'(t,m,k,c)$$
It has been many years since I took differential equations and any guidance would be appreciated.
Answer: With $$y=f(t)$$
Your equation is $$ my''+cy'+ky=k $$
The Characteristic polynomial is $$ m\lambda ^2+c\lambda +k=0$$
The eigenvalues are roots of the above equation.
The solution to the homogeneous equation are found to be the linear combinations of $e^{\lambda _1t}$ and $e^{\lambda _2t}$ and your particular solution is simply $y_p=1$
the general solution is $$y=f(t) =c_1 e^{\lambda _1t} + c_2 e^{\lambda _2t}+1$$ You then find the coefficients from the initial values.
Comment: Hi Mohammad, thank you, where can I learn the steps to resolve the coefficients. I apologize for the spoon feeding, I haven't touched a DifEqs in years.
Comment: You need some information for example f(0)=0 and f'(0)=1 to plug in your general solution and solve for coefficients. For a second order equation you just need two initial values to find the two coefficients.
Answer: You wrote :

A simplified example:
  $$f''(t) = -180(f(t)-1) -12(f'(t)$$
  Has a verified solution of:
  $$1-\frac{1}{2}e^{6t}(-2e^{6t}+sin(12t)+2cos(12t)) $$

This is false. Your solution doesn't agree with the ODE. Check it.
Obviously there is a typo in the first exponential which should be $e^{-6t}$ instead of $e^{6t}$.
But even the typo corrected your solution is not solution of the ODE. Check it.
The correct general solution of $\quad f''(t) = -180(f(t)-1) -12(f'(t)\quad$ is :
$$f(t)=1+c_1e^{-6t}\sin(12t)+c_2e^{-6t}\cos(12t)$$
The conditions $f'(0)=0$ and $f''(0)=0$ imply $c_1=0$ and $c_2=0$. Thus the unique solution is
$$f(t)=1$$
Thus $f(0)=1$. This is not $f(0)\approx 1$.
Please, provide a correct example and improve the wording of your question to make it understandable. What you exactly expect is rather fishy.
NOTE : It is strange that you specify $y'(0)=y''(0)=0$ because the solution becomes constant, that is $f$ doesn't depend on $t$ and remains equal to $f(0)$ any values of $m,k,c,t$.
Comment: Hello, I realized a typo in my solution. I say it is verified because it provides a realistic spring curve where $f(0)\approx0$ and $f(1)\approx1$. I am not sure where to discuss these types of questions so I came to stack exchange, any recommendations for making this question better are much appreciated.
Comment: I am trying to come up with an equation to describe damped spring motion for the purpose of animation. I have been able to use Wolfram Alpha to find a single solution where $m=1$, $k=180$ and $c=20$, but I would like to be able to set the mass, spring constant, and damping coefficient to generate animation curves instead of having to solve with Wolfram and type it in every time. I have noticed that $m=1$, $k=180$, $c\geq36$ the result turns from an oscillating function (using sin/cos) into a critically damped (using e^x only) function
Comment: Use the general solution already given by Mohammad Riazi-Kermani. $$f(t) =c_1 e^{\lambda _1t} + c_2 e^{\lambda _2t}+1$$ First compute $\lambda_1$ and $\lambda_2$ by solving the equation $$m\lambda ^2+c\lambda +k=0$$ Then compute $c_1$ and $c_2$ by solving the system $$\lambda_1c_1+\lambda_2c_2=y'(0)$$ $$\lambda_1^2c_1+\lambda_2^2c_2=y''(0)$$ Don't forget that if $y'(0)=0$ and $y''(0)=0$ the fonction $f(t)$ is necessarily constant.
Comment: If the solutions $\lambda_1$ and $\lambda_2$ are not real, that is complex on the form $\lambda=\alpha+i \beta$ then $e^{(\alpha +i \beta)t}$ the solution becomes $$f(t)=e^{\alpha t}(C_1\sin(\beta t)+C_2\cos(\beta t))+1$$ This explains why some solutions are osculating, some not oscilating, depending on the values of $m,c,k$.


Upload de imagem fora da pasta do LARAVEL

Question: Boa tarde, estou com uma duvida, é possivel eu fazer upload de uma imagem no laravel para fora da pasta do projeto?
Pois estou com um projeto que a pasta do site é fora da pasta do laravel e preciso exibir imagens upadas no laravel neste site.
\WWW\
     DESTINO_IMAGEM\
     LARAVEL\

Answer: Não cheguei a testar, mas acredito que você possa criar um novo disco com o rootapontando para essa pasta fora do laravel.
Os discos funcionam como forma de você informar como fará seu armazenamento, podendo ser no sistema de arquivo local (usando local como seu driver) ou mesmo na nuvem (ex: aws s3)
Como configurar
As configurações dos discos estão no arquivo config/filesystems e basta você adicionar mais um item ao array disks. Um exemplo para o seu caso seria:
'disks' => [
    ...
    'pasta_externa' => [
        'driver' => 'local',
        'root' => '/var/www/DESTINO_IMAGEM'
    ]
]


Ornament Symbol for Triplet

Question: I am writing a piece of music that has a lot of triplets used as ornaments. Is there a symbol like this:

that will be played as as a triplet on the note?
Example: note is G. With symbol over it, it is played as G-F-G (in a triplet). Does this exist?
Answer: The short answer is "if you want a triplet, write a triplet".
Ornament signs are not "exact" prescriptions for anything. For contemporary music they not used much, except for trills. Of course they were common in baroque music, but the interpretation was intentionally left up to the performer to a very great degree.
The sign in your example usually meant a short trill: not necessarily starting on the written note - it might start on the note above - not necessarily only three notes long, and usually with the final note longer than the others.
There is a similar sign with a vertical line through it, which does mean three notes, i.e. the written note, the note below, and the written note repeated, but (1) "the note below" might be interpreted as "a semitone below," i.e. F# not F, and (2) the first two notes are short compared with the third one - it's not a triplet rhythm.
Also, in any period after the Baroque, such ornaments are often interpreted (rightly or wrongly) as being played before the beat, with the final note on the beat - which certainly isn't "a triplet".
Answer: If you want  single-pitch triplets, use the abbreviation notation.  There are examples on that page for triplets.
Here's an example I tripped across on the webz:

The red circles helpfully point you to triplets both written out and abbreviated; they are played the same way.
And no, there is no symbol for groups of 3 notes which are not the same pitch. It should be reasonably obvious why.

Ornament Symbol for Triplet


Postfix, forwarding mail to g-apps for unknown users

Question: I have installed postfix+dovecot+mysql. Everything works fine. But I need to do one specific thing:
If a user doesn't exist (e.g. firstname.lastname@example.com), then the message needs to be forwarded to google apps. I need to the forward original message (like it was send to g-apps directly), not forward it to some bin@g-apps.
Can somene point me to the solution?
Comment: Do not accept mail you cannot deliver.
Comment: Are you going to serve in such way local users (i.e. mydomain.tld is in your 'mydestination' in main.cf) or virtual users?
Comment: Only virtual users.
Comment: And what do you mean under 'send to g-apps directly'? Forward original email to specific email address?
Comment: Do the MX records for mydomain.tld point to the postfix server or Google?
Answer: DISCLAIMER: I take no responsibility for the undeliverable bounce messages that will get stuck in your mailqueue as a result of this. adaptr's comment is correct; you should only accept mail you can deliver. Ideally, you should check against the google-apps domain to see if a recipient is valid. If at all possible, do that.
You can use a Perl Compatible Regular Expression's table using TEXT SUBSTITUTION as your last virtual alias map.
Answer: You can setup catch-all account in your virtual_alias_maps file.
But this would open a hole for lots of spam.
See http://www.postfix.org/VIRTUAL_README.html#virtual_alias for details.
Comment: I know about catch-all account. I have one now, but it can be (as far as i know) used only to redirect to specific mail address => Mail originally to email@example.com is redirected and send to firstname.lastname@example.com. But what i want is redirect it to google apps account like there is no postfix and redirection.
Thank you
Comment: What do you mean under 'redirect to google apps account'?
Comment: Customer has google apps on his domain and uses it for e-mails. Now he want to use his server (postfix, etc...) as mail server, but only for specific accounts and the users not listed in virtual users on his server should be "redirected" (as i described befeore) to google apps, which he uses now. Is it possible to do this? Thanks.


Views - adding relationship adds duplicate row for each relation

Question: Sorry if the title is a little vague, I don't know how else to describe it in the space.
I have a view that shows Drupal Commerce
orders. I am trying to add the SKUs of each product in an order as a field for filtering reasons. However, when I add a relationship to reference line items in the orders, I end up with duplicate rows, one for every line item in an order. I've tried aggregation and making queries distinct, neither of which do what I want.
Answer: Do this:
Add relationships:
1. Commerce Order: Referenced line items
2. Commerce Line item: Referenced products
In Other set Set Aggregation to Yes
Include fields:
1. Commerce Line Item: Line item ID, set aggregation to COUNT and tick Exclude from display
2. Commerce Product: SKU, set aggregation to COUNT and tick Exclude from display.
Add a Filter criteria:
1. Commerce Product: SKU. Expose it to the visitor to your liking, and leave aggregation type to Group results together.
Now you will have only one row returned with no duplicates and you can filter SKU
Comment: You are a genius, thank you! Not entirely sure how it works though...


How to practice bass drum without pedals

Question: I don't have drum set in my room, so I was trying to practice bare foot with mimicking the motion of my foot when I kick with a pedal. I have several concerns about this practice.
First, practicing bare foot. I am not sure if this is harmful or not.
Secondly, the feeling and motion is in general not the same when you are on drums. I know it is pretty normal that practicing drum bass without pedals would not be ideal but I just want to optimize the practicing method.
I found some material in the web which try to answer the question, but I suspect the quality and scope of them generally. I also would like to learn more from drummers here.
I also would like to here some rudiments (if they exists) which are more suitable for a pedalless practice. Also, using the motion of pedal to do some more kicks without full effort kind of techniques are obviously hard or impossible to do in my setup and a recommendation in that aspect would also be appreciated.
Comment: it may depend on your pedal technique - whether you do the toe-bounce or the duck-flap... personally I find toe-bounce easier to 'fake' without the real pedal springback... duck-flap I find just makes my shin muscles hurt
Comment: @Tetsujin I think that I am not doing both of them, just a normal whip motion mostly from the ankle and a video suggested to both practice toe-bounce and duck-flap (if I am understanding them correctly) without pedal.
Answer: For an apartment it is generally a good recommendation to go with electronic drums for the purpose of practicing. So, to borrow from that book, you could simply create a soft pad to use in place of the bass drum, that would be hit with the beater of a regular pedal.
Another option would be something like Triggera Krigg, a sensor that is hit with the pedal surface, not the beater. It is the most quiet sensor with a realistic play feel.
Apart from the sound of the beater hit, there is also the vibration that transmits through the floor. For this purpose there are noise eaters that are placed underneath the pedal and absorb a lot of that vibration. You can also create one yourself, just look for "DIY tennis ball drum raiser".
But, to answer your question - apart from exercising the leg muscles immitating the pedal moves, I see no good way to do this. The bass pedal skill is mostly based on pedal technique and this can be practiced only with a pedal.
As stated earlier, there are different ways to get a practice pedal without getting the whole drumset in a room.
Also, I find it better to have a slick layer underneath the feet so I wear slippers when playing drums in a room. This helps with sliding techniques a lot.
Answer: Why not buy a practice-pad and pedal combo?  Here's one example.  THere are plenty of variants out there.
Comment: Great idea, but I am little bit worried if it is too much disturbing in a building (I live in 6th floor) and besides, if I can fix the pedal without making a permanent/serious change on the floor (?) .
Comment: You can put a exercise pad to absrove the sound and a rug to prevent slivering underneath...


Let $E = \{a_0+a_1t+a_2t^2|a_i \in \Bbb Z_2 | t^3=1+t \}$, find the roots of $g(x)=x^2+tx+1+t^2$.

Question: Let $E$ be the field defined by
$E = \{a_0+a_1t+a_2t^2|a_i \in \Bbb Z_2 | t^3=1+t \}$. I want to find the zeroes of the polynomial $g(x)=x^2+tx+1+t^2$. I am given that they are $t^2, t^2+t$, but I am struggling to verify this is true for $t^2$
Subbing in $g(t)=t^4+t^3+1+t^2=t^4+2(1+t^2)=t^4=t(1+t^2)=t+t^3=-1$.
Here I am stuck, hints appreciated.
Answer: $g(t)=t^4+t^3+1+t^2\\=t^4+(1+t)+1+t^2\\=2+t^4+t+t^2=t^4+t(1+t)\\=t^4+t\cdot t^3=2t^4=0$
Comment: Thanks, I see my mistake now.