问:
serial device ignores EscapeCommFunction with C
I am migrating (finally) from MSDOS to Windows XP for controlling a meter via the serial port. My old C DOS code works fine.

I want to do as follows:

meter is continuously taking readings
every few sec, but does not send any
info until it is requested by the
computer

when computer is ready to receive
info from meter, it requests it. It does not accept info otherwise.

My problem is that the readings are just coming into the computer as they are generated by the meter.

I have set the DCB serail params as follows, intending to control communication using RTS and DTR:

```<code>dcbSerialParams.BaudRate=CBR_4800;
dcbSerialParams.ByteSize=7;
dcbSerialParams.StopBits=TWOSTOPBITS;
dcbSerialParams.Parity=EVENPARITY;
dcbSerialParams.fDtrControl=DTR_CONTROL_ENABLE;
dcbSerialParams.fRtsControl=RTS_CONTROL_ENABLE;
</code>```

My old code under DOS was like this:

```<code> outportb(COM1+4,0x03);  /* start Minolta reading */

 for(j=0;j<=10;j++) /*each reading consists of 11 ascii characters*/
  {
  while(!((inportb(COM1+5)) & 1)); /*wait until char received*/
  reading[j]=inportb(COM1);
  }
 sscanf ( &reading[4], "%f", &lum[k] );

 outportb(COM1+4,0x00);  /* stop Minolta reading */
</code>```

It seems to me that this should work:

```<code>void serial_notready(void)
{
EscapeCommFunction(hSerial,CLRDTR);
EscapeCommFunction(hSerial,CLRRTS);
}

void serial_ready(void)
{
EscapeCommFunction(hSerial,SETDTR);
EscapeCommFunction(hSerial,SETRTS);
}

int serial_read(char reading[])
{
DWORD dwBytesRead = 0;
int nbytes=11;
ReadFile(hSerial, reading, nbytes, &dwBytesRead, NULL);
return(dwBytesRead);
}

serial_ready(void);
x = 0; while(x == 0){x=serial_read(reading);}
serial_notready(void);
</code>```

HOWEVER, the Minolta does not wait to receive the RTS from the computer. It just goes ahead and sends readings as each becomes available. At the same time, the computer does not reject any unwanted reading, but accepts it.

I have been bashing my head against the wall trying to figure this out, trying all kinds of permutations to no avail. Any help greatly appreciated!

Update:

The underlying story is that I present a given luminance (brightness) on a display and then need the corresponding luminance reading. This is done for a whole set of luminances.

```<code>L   ---
U      ---
M         ---
     TIME
</code>```

I present lum1, lum2, lum3, lum4,.... If the measurements are not synchronised to the display, then I may get a supposed reading3 that is actually lum2, or some sort of average because the reading crossed the border between the lum2 and lum3 displays. And, as you said, Hans,the readings will always lag behind the display luminances. Even if I were always systematically one reading behind it would be bad (my situation is worse-- it is a a random relation between the reading and the luminance).

So the behaviour of the windows serial routines is a nightmare for me. Thanks again for the help!

答: The first thing to do would be to check the return values of the calls to EscapeCommFunction(). If the return value is zero, the call failed and you should use GetLastError() to receive more error information.

Body:
I am migrating (finally) from MSDOS to Windows XP for controlling a meter via the serial port. My old C DOS code works fine.

I want to do as follows:

meter is continuously taking readings
every few sec, but does not send any
info until it is requested by the
computer

when computer is ready to receive
info from meter, it requests it. It does not accept info otherwise.

My problem is that the readings are just coming into the computer as they are generated by the meter.

I have set the DCB serail params as follows, intending to control communication using RTS and DTR:

dcbSerialParams.BaudRate=CBR_4800;
dcbSerialParams.ByteSize=7;
dcbSerialParams.StopBits=TWOSTOPBITS;
dcbSerialParams.Parity=EVENPARITY;
dcbSerialParams.fDtrControl=DTR_CONTROL_ENABLE;
dcbSerialParams.fRtsControl=RTS_CONTROL_ENABLE;

My old code under DOS was like this:

 outportb(COM1+4,0x03);  /* start Minolta reading */

 for(j=0;j<=10;j++) /*each reading consists of 11 ascii characters*/
  {
  while(!((inportb(COM1+5)) & 1)); /*wait until char received*/
  reading[j]=inportb(COM1);
  }
 sscanf ( &reading[4], "%f", &lum[k] );

 outportb(COM1+4,0x00);  /* stop Minolta reading */

It seems to me that this should work:

void serial_notready(void)
{
EscapeCommFunction(hSerial,CLRDTR);
EscapeCommFunction(hSerial,CLRRTS);
}

void serial_ready(void)
{
EscapeCommFunction(hSerial,SETDTR);
EscapeCommFunction(hSerial,SETRTS);
}

int serial_read(char reading[])
{
DWORD dwBytesRead = 0;
int nbytes=11;
ReadFile(hSerial, reading, nbytes, &dwBytesRead, NULL);
return(dwBytesRead);
}

serial_ready(void);
x = 0; while(x == 0){x=serial_read(reading);}
serial_notready(void);

HOWEVER, the Minolta does not wait to receive the RTS from the computer. It just goes ahead and sends readings as each becomes available. At the same time, the computer does not reject any unwanted reading, but accepts it.

I have been bashing my head against the wall trying to figure this out, trying all kinds of permutations to no avail. Any help greatly appreciated!

Update:

The underlying story is that I present a given luminance (brightness) on a display and then need the corresponding luminance reading. This is done for a whole set of luminances.

L   ---
U      ---
M         ---
     TIME

I present lum1, lum2, lum3, lum4,.... If the measurements are not synchronised to the display, then I may get a supposed reading3 that is actually lum2, or some sort of average because the reading crossed the border between the lum2 and lum3 displays. And, as you said, Hans,the readings will always lag behind the display luminances. Even if I were always systematically one reading behind it would be bad (my situation is worse-- it is a a random relation between the reading and the luminance).

So the behaviour of the windows serial routines is a nightmare for me. Thanks again for the help!


来源: stackexchange

问:
How to read two columns using python
How to read two columns the first of which contains letters and the second of the values.

```<code>C0      -0.158040
C1      -0.157117
C2      -0.143805
C3      -0.140561
S4      0.059175
H5      0.128940
H6      0.129007
H7      0.142421
H8      0.139979
</code>```

I often used this script below (it works for two or more columns), but not for this time !!

```<code>with open('file.csv') as f:
    f=[x.strip() for x in f if x.strip()]
    data=[tuple(map(float,x.split())) for x in f[2:]]
    oX=[x[0] for x in data]
    oY=[x[1] for x in data]
</code>```

Thanks for your help.

答:
If the separator contains a variable number of space chars:</p>

```<code>import csv
with open('myfile.csv', newline='') as cf:
   cfr = csv.reader(cf, delimiter=' ')
   oX=[]
   oY=[]
   for row in cfr:
       oX.append(row[0])
       oY.append(float(row[-1]))
</code>```

ContentLicense: CC BY-SA 3.0

Title: How to read two columns using python

Body:
How to read two columns the first of which contains letters and the second of the values.

C0      -0.158040
C1      -0.157117
C2      -0.143805
C3      -0.140561
S4      0.059175
H5      0.128940
H6      0.129007
H7      0.142421
H8      0.139979

I often used this script below (it works for two or more columns), but not for this time !!

with open('file.csv') as f:
    f=[x.strip() for x in f if x.strip()]
    data=[tuple(map(float,x.split())) for x in f[2:]]
    oX=[x[0] for x in data]
    oY=[x[1] for x in data]

Thanks for your help.

Body:
If the separator contains a variable number of space chars:

import csv
with open('myfile.csv', newline='') as cf:
   cfr = csv.reader(cf, delimiter=' ')
   oX=[]
   oY=[]
   for row in cfr:
       oX.append(row[0])
       oY.append(float(row[-1]))


问:
Navigation Drawer lag on Android
I'm having a problem with Navigation Drawer , it is too slow, the solution I'm looking for is to close the drawer first and then show the activity, but It is not working, certainly I'm missing something. </p>

```<code>private class DrawerItemClickListener implements ListView.OnItemClickListener {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int posicao, long id) {
            setLastPosition(posicao);
            setFragmentList(lastPosition);
            layoutDrawer.closeDrawer(linearDrawer);
        }
    }

    private OnClickListener userOnClick = new OnClickListener() {
        @Override
        public void onClick(View v) {
            layoutDrawer.closeDrawer(linearDrawer);
        }
    };

    private void setFragmentList(int posicao) {

        FragmentManager fragmentManager = getSupportFragmentManager();
        Fragment fragment = new FragmentViagens();

        switch (posicao) {

            case 0:
                fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();
                break;
            case 1:
                fragmentManager.beginTransaction().replace(R.id.content_frame, new FragmentPedidos()).commit();
                break;
            case 2:
                fragmentManager.beginTransaction().replace(R.id.content_frame, new FragmentClientes()).commit();
                break;

        }

        navigationAdapter.setChecked(posicao, true);
        setTitleFragments(lastPosition);
        navigationAdapter.resetarCheck();
        layoutDrawer.closeDrawer(linearDrawer);

    }
</code>```

答:
I just Solved this issue in just One-Line

go to your Menifest file In your drawer Activity just put HardwareAccelerated true to prevent lag of opening drawer

```<code><activity
        android:name=".activity.YourDrawerActivity"
        android:configChanges="keyboardHidden|orientation"
        android:screenOrientation="portrait"
        android:hardwareAccelerated="true"  //important
        android:theme="@style/AppTheme.NoActionBar"
        android:windowSoftInputMode="stateHidden" />
</code>```

Title: Navigation Drawer lag on Android

Body:
I'm having a problem with Navigation Drawer , it is too slow, the solution I'm looking for is to close the drawer first and then show the activity, but It is not working, certainly I'm missing something.

private class DrawerItemClickListener implements ListView.OnItemClickListener {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int posicao, long id) {
            setLastPosition(posicao);
            setFragmentList(lastPosition);
            layoutDrawer.closeDrawer(linearDrawer);
        }
    }

    private OnClickListener userOnClick = new OnClickListener() {
        @Override
        public void onClick(View v) {
            layoutDrawer.closeDrawer(linearDrawer);
        }
    };

    private void setFragmentList(int posicao) {

        FragmentManager fragmentManager = getSupportFragmentManager();
        Fragment fragment = new FragmentViagens();

        switch (posicao) {

            case 0:
                fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();
                break;
            case 1:
                fragmentManager.beginTransaction().replace(R.id.content_frame, new FragmentPedidos()).commit();
                break;
            case 2:
                fragmentManager.beginTransaction().replace(R.id.content_frame, new FragmentClientes()).commit();
                break;

        }

        navigationAdapter.setChecked(posicao, true);
        setTitleFragments(lastPosition);
        navigationAdapter.resetarCheck();
        layoutDrawer.closeDrawer(linearDrawer);

    }

Body:
I just Solved this issue in just One-Line

go to your Menifest file In your drawer Activity just put HardwareAccelerated true to prevent lag of opening drawer

<activity
        android:name=".activity.YourDrawerActivity"
        android:configChanges="keyboardHidden|orientation"
        android:screenOrientation="portrait"
        android:hardwareAccelerated="true"  //important
        android:theme="@style/AppTheme.NoActionBar"
        android:windowSoftInputMode="stateHidden" />


问:
How to resolve Singleton instance from two different IOC Containers
I am new to IOC, I am building an Application where we are using IOC containers while discussing we decided an architecture that each module will have two Assemblies one for all module level work which is not exposed outside of that module and one with public access for the functions we want to expose outside.

My problem is I needs to create two IOC containers one at APP level and one at module level and there is a singleton instance which I want to register to both but the moment I resolve them two instances of the class got created on both levels is there a way to just get one instance.

One way is to create a Singleton class and inhibits to generate another instance but that I think will removed the concept of IOC is there any other way to just resolve singleton instance between two IOC containers.

Thanks

答:
I am new to IoC, even I just understand the need of this concept few days ago. But, from your situation, why don't just rely registering the Singleton in one container while the other resolve from the one you registered.
Do this solution break concept of IoC too? I am sorry if this is not answer you search for. I am learning.</p>


问:
i have been committing to my repository along with a team of two people using git
I had no issues since two weeks but i am getting this error now

```<code>murta@DESKTOP-Q8IFK52 MINGW64 ~/Code_Dump/homunculi (haji13)
$ git pull origin develop
fatal: FileNotFoundException encountered.
Could not load file or assembly 'System.Net.Http, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its
dependencies. The system cannot find the file specified.
remote: Counting objects: 69, done.
remote: Compressing objects: 100% (56/56), done.
remote: Total 69 (delta 35), reused 32 (delta 10)
error: unable to create temporary file: Invalid argument
fatal: failed to write object
fatal: unpack-objects failed
</code>```

i also checked out my branches all exist

```<code>murta@DESKTOP-Q8IFK52 MINGW64 ~/Code_Dump/homunculi (master)
$ git branch
develop
haji10
haji11
haji12
haji13
haji5
haji6
haji7
haji8
haji9
* master
</code>```

tried this as well

```<code> git push --set-upstream origin haji13
 fatal: FileNotFoundException encountered.
 Could not load file or assembly 'System.Net.Http, Version=4.0.0.0,
 Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its
 dependencies. The system cannot find the file specified.
 Total 0 (delta 0), reused 0 (delta 0)
 remote:
 remote: Create pull request for haji13:
 remote:   https://bitbucket.org/murtazahaji/homunculi/pull-requests/new?
 source=haji13&t=1
 remote:
 To https://bitbucket.org/murtazahaji/homunculi.git
 * [new branch]      haji13 -> haji13
 Branch haji13 set up to track remote branch haji13 from origin
</code>```

if anyone could help me it would be great

答:
To avoid any interference with another software, use for your Git push a CMD shell where you set a simplified PATH:

```<code>set G=c:\path\to\latest\git
set PATH=%G%\bin;%G%\usr\bin;%G%\mingw64\bin
set PATH=%PATH%;C:\windows\system32;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\
</code>```

If GH (the Git installation folder) is set before Windows\System32, the find from Git will be chosen over the default Windows one.

Then type 'bash', to get a shell session within your (tailored) CMD shell.

And try again your git push.

The OP Murtaza Haji mentions in the comments:

Anyway, the issue was resolved after I restarted my PC.

ContentLicense: CC BY-SA 4.0

Body:
I had no issues since two weeks but i am getting this error now

murta@DESKTOP-Q8IFK52 MINGW64 ~/Code_Dump/homunculi (haji13)
$ git pull origin develop
fatal: FileNotFoundException encountered.
Could not load file or assembly 'System.Net.Http, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its
dependencies. The system cannot find the file specified.
remote: Counting objects: 69, done.
remote: Compressing objects: 100% (56/56), done.
remote: Total 69 (delta 35), reused 32 (delta 10)
error: unable to create temporary file: Invalid argument
fatal: failed to write object
fatal: unpack-objects failed

i also checked out my branches all exist

murta@DESKTOP-Q8IFK52 MINGW64 ~/Code_Dump/homunculi (master)
$ git branch
develop
haji10
haji11
haji12
haji13
haji5
haji6
haji7
haji8
haji9
* master

tried this as well

 git push --set-upstream origin haji13
 fatal: FileNotFoundException encountered.
 Could not load file or assembly 'System.Net.Http, Version=4.0.0.0,
 Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its
 dependencies. The system cannot find the file specified.
 Total 0 (delta 0), reused 0 (delta 0)
 remote:
 remote: Create pull request for haji13:
 remote:   https://bitbucket.org/murtazahaji/homunculi/pull-requests/new?
 source=haji13&t=1
 remote:
 To https://bitbucket.org/murtazahaji/homunculi.git
 * [new branch]      haji13 -> haji13
 Branch haji13 set up to track remote branch haji13 from origin

if anyone could help me it would be great

Body:
To avoid any interference with another software, use for your Git push a CMD shell where you set a simplified PATH:

set G=c:\path\to\latest\git
set PATH=%G%\bin;%G%\usr\bin;%G%\mingw64\bin
set PATH=%PATH%;C:\windows\system32;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\

If GH (the Git installation folder) is set before Windows\System32, the find from Git will be chosen over the default Windows one.

Then type 'bash', to get a shell session within your (tailored) CMD shell.

And try again your git push.

The OP Murtaza Haji mentions in the comments:

Anyway, the issue was resolved after I restarted my PC.


问:
Avoiding ConcurrentModificationException in dijkstra's algorithm
For this program, I read in a excel file that lays out a map of towns, towns adjacent to them, and the distance between them, which looks like:

```<code>Bourke  Nyngan  200
Brewarrina  Walgett 134
Broken Hill Mildura 266
Broken Hill Wilcannia   195
Bungendore  Queanbeyan  54
etc.
</code>```

And that's working great. Everything seems perfect. I'm trying to make a program that if I give it two towns, it returns the shortest possible path between the two.

I can get my program to correctly read in the file, and set up everything, so I know that this issue isn't anything to do with the setup. To the best of my knowledge this part of my program works, as my program can get through it without throwing errors:

```<code>   //returns the Vertex with the smallest distance from a list of Vertices
   public static Vertex minDist(List<Vertex> Q){
  int min = 2147483647;
  Vertex closest = new Vertex("Closest");

  for(Vertex v : Q){
     if(v.distance < min){
        closest = v;
     }
  }
  return closest;
  }

 //used to relax (change the distance of a town)
 public static void relax(Vertex u, Vertex v, int w){
  if(v.distance > u.distance + w){
     v.distance = u.distance + w;
     v.predecessor = u;
    }
   }

public static void Dijkstra(Graph G, Vertex s){
  Vertex u = new Vertex("not good");
  List<Vertex> Q = V;
  Vertex v = new Vertex("oh no");

//while Q is not empty:
  while(!Q.isEmpty()){

  //the vertex in Q that has the smallest distance (at first s with 0, then we relax and that changes things)
     u = minDist(Q);

     if(u.name.equals("Closest")){
        //Q.remove(u);
        return;
     }
     Q.remove(u);

     S.add(u);

  //for each edge e in u's adjacencyList:
     for(Edge e : u.roadList){

        if(e != null && !e.finish.name.equals(u.name) ){
           v = e.finish;

           relax(u,v,w(u,v)); //w(u,v) returns the distance between u and v
        }

     }
  }

  System.out.println("Q is null");
}
</code>```

So I have that, and things look okay to me. I know it's a bit Frankenstein'ed together, but I got it to at least run without errors, because the ConcurrentModificationException gets thrown AFTER this method returns in my main method.

This is where my Dijkstra method gets called in my main method. I never reach the line in my code that prints "SHOULD REACH HERE" because the program throws the ConcurrentModificationException.

```<code>        //if both towns exist and are unique, find the shortest route between them.
        if(isTown(town1,V) && isTown(town2,V) && !town1.equals(town2)){

           for(Vertex f : V){
              if(f.name.equals(town2)){
                 destination  = f;
              }
           }

           System.out.println("Traveling...");

           Graph G = new Graph(V,E);

           for(Vertex s : V){

              if(s.name.equals(town1)){
              //////////////////DIJKSTRA STUFF GOES HERE///////////////////
                 initialize(G,s);

                 Dijkstra(G, s);
                 System.out.println("FINISHED DIJKSTRA");

                 //Print out the things in the vertex array S with their distances.
                 for(Vertex b : S){
                    System.out.println(b.name + " (" + b.distance + ")");
                 }

               ///////////////////////////////////////////////
              }

           }
           System.out.println("SHOULD REACH HERE");
        }
</code>```

I have never seen a ConcurrentModificationException, my lab TA has never seen a ConcurrentModificationException, and even my professor has never seen a ConcurrentModificationException. Can I get some help with avoiding this? A person in a higher class said that he has only seen this happening when working with multiple threads, and I don't even know what that really means so I assume my program doesn't do that.

If I run the program with with town1 = Grafton and town2 = Bathurst, then the output should be:

```<code>First town: Grafton
Second town: Bathurst
Bathurst (820)
Lithgow (763)
Windsor (672)
Singleton (511)
Muswellbrook (463)
Tamworth (306)
Bendemeer (264)
Uralla (218)
Armidale (195)
Ebor (106)
Grafton
</code>```

But is instead

```<code>First town: Grafton
Second town: Bathurst
Grafton (0)
Glen Innes (158)
Inverell (225)
Warialda (286)
Coffs Harbour (86)
I/O error: java.util.ConcurrentModificationException
</code>```

答: You're getting this because you're removing from Q while iterating over it it. See Iterating through a Collection, avoiding ConcurrentModificationException when removing in loop</p>

Body:
For this program, I read in a excel file that lays out a map of towns, towns adjacent to them, and the distance between them, which looks like:

Bourke  Nyngan  200
Brewarrina  Walgett 134
Broken Hill Mildura 266
Broken Hill Wilcannia   195
Bungendore  Queanbeyan  54
etc.

And that's working great. Everything seems perfect. I'm trying to make a program that if I give it two towns, it returns the shortest possible path between the two.

I can get my program to correctly read in the file, and set up everything, so I know that this issue isn't anything to do with the setup. To the best of my knowledge this part of my program works, as my program can get through it without throwing errors:

   //returns the Vertex with the smallest distance from a list of Vertices
   public static Vertex minDist(List<Vertex> Q){
  int min = 2147483647;
  Vertex closest = new Vertex("Closest");

  for(Vertex v : Q){
     if(v.distance < min){
        closest = v;
     }
  }
  return closest;
  }

 //used to relax (change the distance of a town)
 public static void relax(Vertex u, Vertex v, int w){
  if(v.distance > u.distance + w){
     v.distance = u.distance + w;
     v.predecessor = u;
    }
   }

public static void Dijkstra(Graph G, Vertex s){
  Vertex u = new Vertex("not good");
  List<Vertex> Q = V;
  Vertex v = new Vertex("oh no");

//while Q is not empty:
  while(!Q.isEmpty()){

  //the vertex in Q that has the smallest distance (at first s with 0, then we relax and that changes things)
     u = minDist(Q);

     if(u.name.equals("Closest")){
        //Q.remove(u);
        return;
     }
     Q.remove(u);

     S.add(u);

  //for each edge e in u's adjacencyList:
     for(Edge e : u.roadList){

        if(e != null && !e.finish.name.equals(u.name) ){
           v = e.finish;

           relax(u,v,w(u,v)); //w(u,v) returns the distance between u and v
        }

     }
  }

  System.out.println("Q is null");
}

So I have that, and things look okay to me. I know it's a bit Frankenstein'ed together, but I got it to at least run without errors, because the ConcurrentModificationException gets thrown AFTER this method returns in my main method.

This is where my Dijkstra method gets called in my main method. I never reach the line in my code that prints "SHOULD REACH HERE" because the program throws the ConcurrentModificationException.

        //if both towns exist and are unique, find the shortest route between them.
        if(isTown(town1,V) && isTown(town2,V) && !town1.equals(town2)){

           for(Vertex f : V){
              if(f.name.equals(town2)){
                 destination  = f;
              }
           }

           System.out.println("Traveling...");

           Graph G = new Graph(V,E);

           for(Vertex s : V){

              if(s.name.equals(town1)){
              //////////////////DIJKSTRA STUFF GOES HERE///////////////////
                 initialize(G,s);

                 Dijkstra(G, s);
                 System.out.println("FINISHED DIJKSTRA");

                 //Print out the things in the vertex array S with their distances.
                 for(Vertex b : S){
                    System.out.println(b.name + " (" + b.distance + ")");
                 }

               ///////////////////////////////////////////////
              }

           }
           System.out.println("SHOULD REACH HERE");
        }

I have never seen a ConcurrentModificationException, my lab TA has never seen a ConcurrentModificationException, and even my professor has never seen a ConcurrentModificationException. Can I get some help with avoiding this? A person in a higher class said that he has only seen this happening when working with multiple threads, and I don't even know what that really means so I assume my program doesn't do that.

If I run the program with with town1 = Grafton and town2 = Bathurst, then the output should be:

First town: Grafton
Second town: Bathurst
Bathurst (820)
Lithgow (763)
Windsor (672)
Singleton (511)
Muswellbrook (463)
Tamworth (306)
Bendemeer (264)
Uralla (218)
Armidale (195)
Ebor (106)
Grafton

But is instead

First town: Grafton
Second town: Bathurst
Grafton (0)
Glen Innes (158)
Inverell (225)
Warialda (286)
Coffs Harbour (86)
I/O error: java.util.ConcurrentModificationException


问:
css/sass :not(:first-of-type) not working, is hiding all elements of type
I have a sass block that i have tried several different ways:

I've tried this:

```<code>.progress-body {
    display: none;
    &:first-of-type {
        display: block;
    }
}
</code>```

and this:

```<code>.progress-body {
    &:not(:first-of-type) {
        display: none;
    }
}
</code>```

and this:

```<code>.progress-body:not(:first-of-type) {
    display: none;
}
</code>```

when applied to HTML that looks like this:

```<code><div class="panel">
    <div class="panel-heading">
    </div>
    <div class="panel-body progress-body">
            <div class="row">
                <div class="col-md-12">
                    <p class="lead">Step 1: Choose your template...</p>
                </div>
            </div>
    </div>
    <div class="panel-body progress-body">
            <div class="row">
                <div class="col-md-12">
                    <p class="lead">Step 2: Compose your email...</p>
                </div>
            </div>
    </div>
</div>
</code>```

the result is that it hides all the elements with the progress-body class. This is normally  pretty straight forward CSS so no idea what is wrong here...

答:
In this case progress-body is not the first-of-type, this would technically be .panel-heading since the first-of-type refers to the type element selector (div) and not the class.

The :first-of-type CSS pseudo-class represents the first element of
  its type among a group of sibling elements.

Ref: :first-of-type - CSS | MDN

Consider wrapping your .progress-body elements in a containing element, you will achieve the expected behaviour, since .progress-body would be the first of its type with the class name .progress-body.

Code Snippet Demonstration:

.progress-body:not(:first-of-type) {
  display: none;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="panel">
  <div class="panel-heading">
  </div>
  <div class="panel-outer-body">
    <div class="panel-body progress-body">
      <div class="row">
        <div class="col-md-12">
          <p class="lead">Step 1: Choose your template...</p>
        </div>
      </div>
    </div>
    <div class="panel-body progress-body">
      <div class="row">
        <div class="col-md-12">
          <p class="lead">Step 2: Compose your email...</p>
        </div>
      </div>
    </div>
  </div>
</div></code>```

Body:
I have a sass block that i have tried several different ways:

I've tried this:

.progress-body {
    display: none;
    &:first-of-type {
        display: block;
    }
}

and this:

.progress-body {
    &:not(:first-of-type) {
        display: none;
    }
}

and this:

.progress-body:not(:first-of-type) {
    display: none;
}

when applied to HTML that looks like this:

Step 1: Choose your template...

Step 2: Compose your email...

the result is that it hides all the elements with the progress-body class. This is normally  pretty straight forward CSS so no idea what is wrong here...

Body:
In this case progress-body is not the first-of-type, this would technically be .panel-heading since the first-of-type refers to the type element selector (div) and not the class.

The :first-of-type CSS pseudo-class represents the first element of
  its type among a group of sibling elements.

Ref: :first-of-type - CSS | MDN

Consider wrapping your .progress-body elements in a containing element, you will achieve the expected behaviour, since .progress-body would be the first of its type with the class name .progress-body.

Code Snippet Demonstration:

.progress-body:not(:first-of-type) {
  display: none;
}

<div class="panel">
  <div class="panel-heading">
  </div>
  <div class="panel-outer-body">
    <div class="panel-body progress-body">
      <div class="row">
        <div class="col-md-12">
          <p class="lead">Step 1: Choose your template...</p>
        </div>
      </div>
    </div>
    <div class="panel-body progress-body">
      <div class="row">
        <div class="col-md-12">
          <p class="lead">Step 2: Compose your email...</p>
        </div>
      </div>
    </div>
  </div>
</div>


答:
I would use tf.gather_nd where you need to provide indices to gather items from the given tensor. For example:

```<code>data1 = tf.constant(
    [
        [[1,1,1],[2,2,2]],
        [[3,3,3],[4,4,4]]

    ]
)
indices = tf.constant([
    [[0,0], [1,0]],
    [[0,1], [1,1]]
])
result = tf.gather_nd(data1, indices)
</code>```

will give:

```<code>[[[1 1 1]
  [3 3 3]]

 [[2 2 2]
 [4 4 4]]]
</code>```

and then you can use concat with axis=0 to transform the tensor to your desired format

Title: tensorflow concat tensors row wise

Body:
I have an BasicLSTMCell which is fed into a static_rnn that unfolds sent_max_len = 2 times. The input is a batch of sentences of batch_size = 2. Each word has an embed_size = 6. The output looks like this:

       e1           e2           e3            e4          e5           e6
[[-0.01236094, -0.00423804, -0.01091367,  0.00286771, -0.00911439, -0.00964547]  s1.w1
[-0.0316297 ,  0.00904978, -0.02972977, -0.00720989,  0.00432076,  0.00946513]] s2.w1
                                       t1

[[-0.03660333,  0.00613474, -0.03758694, -0.0070029 , -0.00036427, 0.00386676], s1.w2
[-0.04840172,  0.01757939, -0.05444464, -0.01508901,  0.01216465, 0.01938537]] s2.w2
                                        t2
s1 = sentence 1
w1 = word 1
t1 = timestep 1
e1 = embedding 1

I want to concatenate the outputs. But the problem is when I do tf.concat along axis=0, it takes the output of t1 and concatenates with t2, like this:

[[-0.01236094 -0.00423804 -0.01091367  0.00286771 -0.00911439 -0.00964547]  s1.w1
 [-0.0316297   0.00904978 -0.02972977 -0.00720989  0.00432076  0.00946513]  s2.w1
 [-0.03660333  0.00613474 -0.03758694 -0.0070029  -0.00036427  0.00386676]  s1.w2
 [-0.04840172  0.01757939 -0.05444464 -0.01508901  0.01216465  0.01938537]  s2.w2

But I want to concatenate like this:

[[-0.01236094 -0.00423804 -0.01091367  0.00286771 -0.00911439 -0.00964547]  s1.w1
 [-0.03660333  0.00613474 -0.03758694 -0.0070029  -0.00036427  0.00386676]  s1.w2
 [-0.0316297   0.00904978 -0.02972977 -0.00720989  0.00432076  0.00946513]  s2.w1
 [-0.04840172  0.01757939 -0.05444464 -0.01508901  0.01216465  0.01938537]  s2.w2

Because this concated_output goes through other layers and my final predicted_output is compared with actual_output where, the actual_output looks like this:

[[s1.w1.actualOutput]
 [s1.w2.actualOutput]
 [s2.w1.actualOutput]
 [s2.w2.actualOutput]
]

Obviously I cannot concat along axis=1, as even though it will give the output in the right order, the word embeddings will be combined.

Body:
I would use tf.gather_nd where you need to provide indices to gather items from the given tensor. For example:

data1 = tf.constant(
    [
        [[1,1,1],[2,2,2]],
        [[3,3,3],[4,4,4]]

    ]
)
indices = tf.constant([
    [[0,0], [1,0]],
    [[0,1], [1,1]]
])
result = tf.gather_nd(data1, indices)

will give:

[[[1 1 1]
  [3 3 3]]

 [[2 2 2]
 [4 4 4]]]

and then you can use concat with axis=0 to transform the tensor to your desired format


问:
Joining 3 tables and adding a total column in MySQL
I have three tables in a MySQL database

Table 1(vendors) contains all of my vendors

Table 2(puchaseorders) contains all of my purchaseorders and with a common column being 'vendor'

Table 3 contains all of the individual items from those orders with a common column being purchase_order

In the vendors table I have a historical balance that I want to add the running total to.

This is what I have right now. It works perfect but it only returns the vendors that are in the purchaseorders table.

I want to return all of the vendors in the vendors table. If there isn't a "running_total" don't do anything to the balance.

```<code>SELECT *, vendors.balance + vend.running_total AS total FROM vendors
INNER JOIN
(SELECT vendor, SUM(orderhistory.qty_received *
orderhistory.estimated_price) AS running_total FROM orderhistory
INNER JOIN purchaseorders ON
orderhistory.purchase_order=purchaseorders.purchase_order
GROUP BY purchaseorders.vendor) AS vend ON vend.vendor=vendors.vendor;
</code>```

答:
Try the following (LEFT JOIN and IFNULL)

```<code>SELECT *, vendors.balance + IFNULL(vend.running_total,0) AS total
FROM vendors
LEFT JOIN
  (
    SELECT vendor, SUM(orderhistory.qty_received * orderhistory.estimated_price) AS running_total
    FROM orderhistory
    INNER JOIN purchaseorders ON orderhistory.purchase_order=purchaseorders.purchase_order
    GROUP BY purchaseorders.vendor
  ) AS vend
ON vend.vendor=vendors.vendor;
</code>```

Body:
I have three tables in a MySQL database

Table 1(vendors) contains all of my vendors

Table 2(puchaseorders) contains all of my purchaseorders and with a common column being 'vendor'

Table 3 contains all of the individual items from those orders with a common column being purchase_order

In the vendors table I have a historical balance that I want to add the running total to.

This is what I have right now. It works perfect but it only returns the vendors that are in the purchaseorders table.

I want to return all of the vendors in the vendors table. If there isn't a "running_total" don't do anything to the balance.

SELECT *, vendors.balance + vend.running_total AS total FROM vendors
INNER JOIN
(SELECT vendor, SUM(orderhistory.qty_received *
orderhistory.estimated_price) AS running_total FROM orderhistory
INNER JOIN purchaseorders ON
orderhistory.purchase_order=purchaseorders.purchase_order
GROUP BY purchaseorders.vendor) AS vend ON vend.vendor=vendors.vendor;

Body:
Try the following (LEFT JOIN and IFNULL)

SELECT *, vendors.balance + IFNULL(vend.running_total,0) AS total
FROM vendors
LEFT JOIN
  (
    SELECT vendor, SUM(orderhistory.qty_received * orderhistory.estimated_price) AS running_total
    FROM orderhistory
    INNER JOIN purchaseorders ON orderhistory.purchase_order=purchaseorders.purchase_order
    GROUP BY purchaseorders.vendor
  ) AS vend
ON vend.vendor=vendors.vendor;


问:
Unable to add volume to image via docker-compose
I'm trying to add a volume to the mattermost/mattermost-preview docker image. The Dockerfile for this image (not controlled by me) is:

```<code># Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
# See License.txt for license information.
FROM mysql:5.7

# Install ca-certificates to support TLS of Mattermost v3.5
RUN apt-get update && apt-get install -y ca-certificates

#
# Configure SQL
#

ENV MYSQL_ROOT_PASSWORD=mostest
ENV MYSQL_USER=mmuser
ENV MYSQL_PASSWORD=mostest
ENV MYSQL_DATABASE=mattermost_test

#
# Configure Mattermost
#
WORKDIR /mm

# Copy over files
ADD https://releases.mattermost.com/4.4.4/mattermost-team-4.4.4-linux-amd64.tar.gz .
RUN tar -zxvf ./mattermost-team-4.4.4-linux-amd64.tar.gz
ADD config_docker.json ./mattermost/config/config_docker.json
ADD docker-entry.sh .

RUN chmod +x ./docker-entry.sh
ENTRYPOINT ./docker-entry.sh

# Create default storage directory
RUN mkdir ./mattermost-data
VOLUME ./mattermost-data

# Ports
EXPOSE 8065
</code>```

I want to add a volume to this image, and a custom entrypoint so that I can add some test data to the mysql database before my container starts up. I'm trying to use docker-compose to do this:

```<code>version: '3'
services:
  mattermost:
    ports:
     - "8065:8065"
    image: mattermost/mattermost-preview
    volumes:
      - ./end_to_end/mattermost/mock-mount:/mm/mock-mount
    entrypoint: /mm/mock-mount/docker-entry.sh
</code>```

But I'm unfortunately not able to get this to start, when I try running docker-compose up, I get the error

```<code>ERROR: for mattermost  Cannot create container for service mattermost: invalid bind mount spec "39742853c03b3b2747f11c942a4a76e4cd138ad41d54f70f71d7aa9ccc36dcca:mattermost-data:rw": invalid volume specification: '39742853c03b3b2747f11c942a4a76e4cd138ad41d54f70f71d7aa9ccc36dcca:mattermost-data:rw': invalid mount config for type "volume": invalid mount path: 'mattermost-data' mount path must be absolute
ERROR: Encountered errors while bringing up the project.
</code>```

The weird thing is - if I take out the volumes and entrypoint sections from my docker-compose.yml file, then the container starts up no problem, even though it seems to me that the error is with the original image. Is there a way to do what I want here?

答:
i think in your image docker-remote.registry.kroger.com/mattermost/mattermost-preview not exist folder /mm/mock-mount.

Try change entrypoint to

entrypoint: /bin/bash -c "/mm/mock-mount/docker-entry.sh"

Body:
I'm trying to add a volume to the mattermost/mattermost-preview docker image. The Dockerfile for this image (not controlled by me) is:

# Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
# See License.txt for license information.
FROM mysql:5.7

# Install ca-certificates to support TLS of Mattermost v3.5
RUN apt-get update && apt-get install -y ca-certificates

#
# Configure SQL
#

ENV MYSQL_ROOT_PASSWORD=mostest
ENV MYSQL_USER=mmuser
ENV MYSQL_PASSWORD=mostest
ENV MYSQL_DATABASE=mattermost_test

#
# Configure Mattermost
#
WORKDIR /mm

# Copy over files
ADD https://releases.mattermost.com/4.4.4/mattermost-team-4.4.4-linux-amd64.tar.gz .
RUN tar -zxvf ./mattermost-team-4.4.4-linux-amd64.tar.gz
ADD config_docker.json ./mattermost/config/config_docker.json
ADD docker-entry.sh .

RUN chmod +x ./docker-entry.sh
ENTRYPOINT ./docker-entry.sh

# Create default storage directory
RUN mkdir ./mattermost-data
VOLUME ./mattermost-data

# Ports
EXPOSE 8065

I want to add a volume to this image, and a custom entrypoint so that I can add some test data to the mysql database before my container starts up. I'm trying to use docker-compose to do this:

version: '3'
services:
  mattermost:
    ports:
     - "8065:8065"
    image: mattermost/mattermost-preview
    volumes:
      - ./end_to_end/mattermost/mock-mount:/mm/mock-mount
    entrypoint: /mm/mock-mount/docker-entry.sh

But I'm unfortunately not able to get this to start, when I try running docker-compose up, I get the error

ERROR: for mattermost  Cannot create container for service mattermost: invalid bind mount spec "39742853c03b3b2747f11c942a4a76e4cd138ad41d54f70f71d7aa9ccc36dcca:mattermost-data:rw": invalid volume specification: '39742853c03b3b2747f11c942a4a76e4cd138ad41d54f70f71d7aa9ccc36dcca:mattermost-data:rw': invalid mount config for type "volume": invalid mount path: 'mattermost-data' mount path must be absolute
ERROR: Encountered errors while bringing up the project.

The weird thing is - if I take out the volumes and entrypoint sections from my docker-compose.yml file, then the container starts up no problem, even though it seems to me that the error is with the original image. Is there a way to do what I want here?


问:
How to show the arrangement of the blocks in following fashion can have utmost two different colours
You are given 10 boxes, each large enough to contain exactly 10 wooden blocks, and a total of 100 blocks in 10 different colours.There might not be the same number in each colour, so you might not be able to pack the blocks into the boxes in such a way that each box contains only one colour of block.  Show that it is possible to pack the blocks into the boxes so that each box contains at most two different colours.</p>

答:
Arrange the blocks by color. The smallest group will have no more than 10 blocks.
Fill one box with this color, fill the remainder with blocks from the biggest pile.
You now have on box less to fill & 1 Color gone.
Repeat.

See http://mei.org.uk/images/Nov09_miotm_solution.JPG

ContentLicense: CC BY-SA 2.5


问:
How is K8S_HOST_URL used and what needs it in EFK

Question

What is the purpose of the K8S_HOST_URL configuration parameter in EFK? In EFK, K8S_HOST_URL exists as an environment variable and it looks being used to communicate to the Kubernetes API server by fluentd as being specified in the filter-k8s-meta.conf of the fluentd configuration.

Looking for the documentation but not in the OpenShift Aggregating Container Logs documentation. Searched in Google but could not find a definite answer.

Please suggest the documentation which explains in detail.

答:
From RHEL

The environment variable K8S_HOST_URL in fluend is an internal url for reaching the master API. Not documented yet.


问:
Accessibility Inspector doesn't work on iOS 11.2
it seems the accessibility inspector is not working well with iOS 11.2. Is there a known workaround or maybe apple introduced a new switch?

Thanks!

iOS 11.2

iOS 11.0.1 is working correctly

答:
Luckily this fixes the issue

```<code>Simulator > Hardware > Erase all contents and settings
</code>```

Body:
Luckily this fixes the issue

Simulator > Hardware > Erase all contents and settings


问:
git can't push my updates to remote
```<code>$ git log
 commit 49a37bc9fd27c909e4fe77812041fd38b9755f61 (HEAD -> master)
 Author: chenghuang <574637816@qq.com>
 Date:   Thu Dec 7 14:15:42 2017 +0900

useless

commit e9b08e2b428f9dd58aa0b792ebeb29da4270dfab
Author: chenghuang <574637816@qq.com>
Date:   Tue Dec 5 22:45:31 2017 +0900

20171205_Checklist_well
</code>```

I just have to commits in my git log.

```<code>$ git branch #my current branch is master
 * master

$ git remote -v #This is my remote github url
origin  https://github.com/ekoopgj/Shell_learning.git (fetch)
origin  https://github.com/ekoopgj/Shell_learning.git (push)

$ git push -u origin master
Username for 'https://github.com':
Password for 'https://ekoopgj@github.com':
To https://github.com/ekoopgj/Shell_learning.git
! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/ekoopgj/Shell_learning.git'
 hint: Updates were rejected because the remote contains work that you do
 hint: not have locally. This is usually caused by another repository pushing
 hint: to the same ref. You may want to first integrate the remote changes
 hint: (e.g., 'git pull ...') before pushing again.
 hint: See the 'Note about fast-forwards' in 'git push --help' for details.
</code>```

I can't push my updates to remote . What's it mean that "remote work contains that you do"?

答:
The full sentence is

```<code>the remote contains work that you do not have locally.
</code>```

That means someone has pushed on the remote master before you.

A git pull (or better: git pull --rebase) will allow you to get those modification, and to push yours back.

Title: git can't push my updates to remote

Body:
$ git log
 commit 49a37bc9fd27c909e4fe77812041fd38b9755f61 (HEAD -> master)
 Author: chenghuang <574637816@qq.com>
 Date:   Thu Dec 7 14:15:42 2017 +0900

useless

commit e9b08e2b428f9dd58aa0b792ebeb29da4270dfab
Author: chenghuang <574637816@qq.com>
Date:   Tue Dec 5 22:45:31 2017 +0900

20171205_Checklist_well

I just have to commits in my git log.

$ git branch #my current branch is master
 * master

$ git remote -v #This is my remote github url
origin  https://github.com/ekoopgj/Shell_learning.git (fetch)
origin  https://github.com/ekoopgj/Shell_learning.git (push)

$ git push -u origin master
Username for 'https://github.com':
Password for 'https://ekoopgj@github.com':
To https://github.com/ekoopgj/Shell_learning.git
! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/ekoopgj/Shell_learning.git'
 hint: Updates were rejected because the remote contains work that you do
 hint: not have locally. This is usually caused by another repository pushing
 hint: to the same ref. You may want to first integrate the remote changes
 hint: (e.g., 'git pull ...') before pushing again.
 hint: See the 'Note about fast-forwards' in 'git push --help' for details.

I can't push my updates to remote . What's it mean that "remote work contains that you do"?

Body:
The full sentence is

the remote contains work that you do not have locally.

That means someone has pushed on the remote master before you.

A git pull (or better: git pull --rebase) will allow you to get those modification, and to push yours back.


问:
Mapview swift add multiple markers
```<code>for result in swiftyData.arrayValue {
                        let classId = result[0].stringValue
                        let className = result[1].stringValue
                        let longitude = result[2].doubleValue
                        let latitude = result[3].doubleValue
                        let newClass = NearestClasses()
                        newClass.classId = classId
                        newClass.className = className
                        newClass.longitude = longitude
                        newClass.latitude = latitude
                        nearestClasses?.append(newClass)

                        let locationSec = CLLocationCoordinate2DMake(CLLocationDegrees(latitude), CLLocationDegrees(longitude))
                        dropPin.coordinate = newYorkLocation
                        dropPin.title =  className
                        self.mapeView.addAnnotation(dropPin)*/
                        let dropPin =  MKPointAnnotation()
                        dropPin.coordinate = locationSec
                        dropPin.title =  className
                        self.mapeView.addAnnotation(dropPin)
                    }
</code>```

If its one loop, this function works perfectly in swift 3. But if its multiple loop, no markers are showing on the map. Thank you

答:
In Swift 3

```<code>@IBOutlet weak var mapView: MKMapView!
    var latitude:Double!
    var longitude:Double!
    var locationManager =  CLLocationManager()
    var green:Bool = false
    var red:Bool = false
    var yellow:Bool = false
    var blue:Bool = false
    var darkBlue:Bool = false
    var liteGreen:Bool = false

  override func viewDidLoad() {
        super.viewDidLoad()

        if (CLLocationManager.locationServicesEnabled())
        {
            locationManager.delegate = self
            locationManager.desiredAccuracy = kCLLocationAccuracyBest
            if ((UIDevice.current.systemVersion as NSString).floatValue >= 8)
            {
                locationManager.requestWhenInUseAuthorization()
            }

            locationManager.startUpdatingLocation()
        }
        else
        {
            #if debug
                println("Location services are not enabled");
            #endif
        }
 addAnnotationPoint()
    }
</code>```

Add Annotation Function

```<code> func addAnnotationPoint()
    {

                       for data in yourArray
                {

                    let point = MKPointAnnotation()

                    let pointlatitude = Double(data.latitude!)!
                    let pointlongitude = Double(data.longitude!)!
                    point.title = data.event_name

                    point.coordinate = CLLocationCoordinate2DMake(pointlatitude ,pointlongitude)
                    //print(point.coordinate)
                    mapView.addAnnotation(point)

                }
                let span = MKCoordinateSpanMake(0.075, 0.075)
                let region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: latitude, longitude: longitude), span: span)
                mapView.setRegion(region, animated: true)

        }
</code>```

Annotation View Method

```<code>func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
        // Don't want to show a custom image if the annotation is the user's location.
        guard !(annotation is MKUserLocation) else {
            return nil
        }

        // Better to make this class property
        let annotationIdentifier = "AnnotationIdentifier"

        var annotationView: MKAnnotationView?
        if let dequeuedAnnotationView = mapView.dequeueReusableAnnotationView(withIdentifier: annotationIdentifier) {
            annotationView = dequeuedAnnotationView
            annotationView?.annotation = annotation
        }
        else {
            annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: annotationIdentifier)
            annotationView?.rightCalloutAccessoryView = UIButton(type: .detailDisclosure)
        }

        if let annotationView = annotationView {

           // annotationView.canShowCallout = true

                if blue == true
                {
                    blue = false
                    green = true
                    yellow = false
                    red = false
                    darkBlue = false
                    liteGreen = false

                    annotationView.image =  imageLiteral(resourceName: "Bluepin")

                }
                else if green == true
                {
                    blue = false
                    green = false
                    darkBlue = false
                    liteGreen = false
                    yellow = true
                    red = false
                    annotationView.image =  imageLiteral(resourceName: "Greenpin")

                }
                else if yellow == true
                {
                    blue = false
                    green = false
                    yellow = false
                    darkBlue = false
                    liteGreen = false
                    red = true
                    annotationView.image =  imageLiteral(resourceName: "Yellopin")

                }
                else if red == true
                {
                    blue = false
                    green = false
                    yellow = false
                    darkBlue = true
                    liteGreen = false
                    red = false
                    annotationView.image =  imageLiteral(resourceName: "Redpin")

            }
                else if darkBlue == true
                {
                    blue = false
                    green = false
                    yellow = false
                    darkBlue = false
                    liteGreen = true
                    red = false
                    annotationView.image =  imageLiteral(resourceName: "DarkBlue")

                }
                else if liteGreen == true
                {
                    blue = true
                    green = false
                    yellow = false
                    darkBlue = false
                    liteGreen = false
                    red = false
                    annotationView.image =  imageLiteral(resourceName: "LiteGreen")

                }
            else
                {
                    blue = true
                    green = false
                    yellow = false
                    red = false
                    annotationView.image =  imageLiteral(resourceName: "Pinkpin")
            }

        }

        return annotationView
    }
</code>```

Title: Mapview swift add multiple markers

Body:
for result in swiftyData.arrayValue {
                        let classId = result[0].stringValue
                        let className = result[1].stringValue
                        let longitude = result[2].doubleValue
                        let latitude = result[3].doubleValue
                        let newClass = NearestClasses()
                        newClass.classId = classId
                        newClass.className = className
                        newClass.longitude = longitude
                        newClass.latitude = latitude
                        nearestClasses?.append(newClass)

                        let locationSec = CLLocationCoordinate2DMake(CLLocationDegrees(latitude), CLLocationDegrees(longitude))
                        dropPin.coordinate = newYorkLocation
                        dropPin.title =  className
                        self.mapeView.addAnnotation(dropPin)*/
                        let dropPin =  MKPointAnnotation()
                        dropPin.coordinate = locationSec
                        dropPin.title =  className
                        self.mapeView.addAnnotation(dropPin)
                    }

If its one loop, this function works perfectly in swift 3. But if its multiple loop, no markers are showing on the map. Thank you

Body:
In Swift 3

@IBOutlet weak var mapView: MKMapView!
    var latitude:Double!
    var longitude:Double!
    var locationManager =  CLLocationManager()
    var green:Bool = false
    var red:Bool = false
    var yellow:Bool = false
    var blue:Bool = false
    var darkBlue:Bool = false
    var liteGreen:Bool = false

  override func viewDidLoad() {
        super.viewDidLoad()

        if (CLLocationManager.locationServicesEnabled())
        {
            locationManager.delegate = self
            locationManager.desiredAccuracy = kCLLocationAccuracyBest
            if ((UIDevice.current.systemVersion as NSString).floatValue >= 8)
            {
                locationManager.requestWhenInUseAuthorization()
            }

            locationManager.startUpdatingLocation()
        }
        else
        {
            #if debug
                println("Location services are not enabled");
            #endif
        }
 addAnnotationPoint()
    }

Add Annotation Function

 func addAnnotationPoint()
    {

                       for data in yourArray
                {

                    let point = MKPointAnnotation()

                    let pointlatitude = Double(data.latitude!)!
                    let pointlongitude = Double(data.longitude!)!
                    point.title = data.event_name

                    point.coordinate = CLLocationCoordinate2DMake(pointlatitude ,pointlongitude)
                    //print(point.coordinate)
                    mapView.addAnnotation(point)

                }
                let span = MKCoordinateSpanMake(0.075, 0.075)
                let region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: latitude, longitude: longitude), span: span)
                mapView.setRegion(region, animated: true)

        }

Annotation View Method

func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
        // Don't want to show a custom image if the annotation is the user's location.
        guard !(annotation is MKUserLocation) else {
            return nil
        }

        // Better to make this class property
        let annotationIdentifier = "AnnotationIdentifier"

        var annotationView: MKAnnotationView?
        if let dequeuedAnnotationView = mapView.dequeueReusableAnnotationView(withIdentifier: annotationIdentifier) {
            annotationView = dequeuedAnnotationView
            annotationView?.annotation = annotation
        }
        else {
            annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: annotationIdentifier)
            annotationView?.rightCalloutAccessoryView = UIButton(type: .detailDisclosure)
        }

        if let annotationView = annotationView {

           // annotationView.canShowCallout = true

                if blue == true
                {
                    blue = false
                    green = true
                    yellow = false
                    red = false
                    darkBlue = false
                    liteGreen = false

                    annotationView.image =  imageLiteral(resourceName: "Bluepin")

                }
                else if green == true
                {
                    blue = false
                    green = false
                    darkBlue = false
                    liteGreen = false
                    yellow = true
                    red = false
                    annotationView.image =  imageLiteral(resourceName: "Greenpin")

                }
                else if yellow == true
                {
                    blue = false
                    green = false
                    yellow = false
                    darkBlue = false
                    liteGreen = false
                    red = true
                    annotationView.image =  imageLiteral(resourceName: "Yellopin")

                }
                else if red == true
                {
                    blue = false
                    green = false
                    yellow = false
                    darkBlue = true
                    liteGreen = false
                    red = false
                    annotationView.image =  imageLiteral(resourceName: "Redpin")

            }
                else if darkBlue == true
                {
                    blue = false
                    green = false
                    yellow = false
                    darkBlue = false
                    liteGreen = true
                    red = false
                    annotationView.image =  imageLiteral(resourceName: "DarkBlue")

                }
                else if liteGreen == true
                {
                    blue = true
                    green = false
                    yellow = false
                    darkBlue = false
                    liteGreen = false
                    red = false
                    annotationView.image =  imageLiteral(resourceName: "LiteGreen")

                }
            else
                {
                    blue = true
                    green = false
                    yellow = false
                    red = false
                    annotationView.image =  imageLiteral(resourceName: "Pinkpin")
            }

        }

        return annotationView
    }


问:
Proper way to share temporary data between two users
Here is my case in django,i need to create a match between two users, users take turn, after one of them has finished, i need to send user1 score to user2 and vise versa.

How can i create a match between two players?

How do i store their data(scores) in a way that can be accessed for both users.

Here is what i've tried : user1 sends GET request to get a user2 as a opponent by getting user2 id (i can say i made a match there), then after user1 finished he make another GET request with his id and score to django. and here is where i stuck :

I don't know how to send user1 score to user2.

I don't know how to store the data so both users can access each other score.

I'm quite new to django, so i did all that based on my basic knowledge of the framework, please correct me if i'm wrong and possibly suggest a better approach.

答:
An approach I would take would be to create two models one for Match and the other for turn. Match would contain fields including foreign keys to player_1 and player_2 and the overall score, game active and which players turn it is. The second model I would create would be a turn which has the details of the turn and a foreign key to the match.

Each time a turn occurs it would be a CreateView, see Class based views in the django docs. This will create a new turn, and you should be able to automatically add in the game that it belongs to.

The problem you will have then is then notifying the other user that the new turn has been taken. The simplest way would be to just wait and let the user reload the page but that may lead to a subpar user experience.

The next way would be to create a javascript loop to periodically poll your backend and create an alert when the other player has taken their turn.

Finally if you want to do a push from the backend to the browser you will need to investigate django channels which allows you to setup a websocket connection from the backend to the front end. This will allow you to update your UI as new data is available.

For a new user you might want to progress through the options in the order that has been outlined just to build your experience.


答:
```<code>dcbSerialParams.fDtrControl=DTR_CONTROL_ENABLE;
dcbSerialParams.fRtsControl=RTS_CONTROL_ENABLE;
</code>```

You enable the DTR and RTS signals right away.  The meter will immediately start sending data when you open the port.  That data gets buffered in the driver's receive buffer.  You didn't have a buffer before in the DOS code.  It depends how long it takes for you to call serial_notready().  You'll have a pretty full buffer if that takes a second or so.  Yes, that makes it look like the meter is just sending data.  And you are always reading an old sample.

Start with the DCB values set to DISABLE.  Beware that the scheme is brittle, you could turn the signal off pretty reliably back in the DOS.  Now you've got a driver in between.  You may well end up turning RTS off too late.  Which risks getting a stale reading.  An alternative is to startup a thread that just reads continuously.  And have your main code just use the last value that it read.  The overhead is quite low, serial ports are slow.

Title: serial device ignores EscapeCommFunction with C

Body:
I am migrating (finally) from MSDOS to Windows XP for controlling a meter via the serial port. My old C DOS code works fine.

I want to do as follows:

meter is continuously taking readings
every few sec, but does not send any
info until it is requested by the
computer

when computer is ready to receive
info from meter, it requests it. It does not accept info otherwise.

My problem is that the readings are just coming into the computer as they are generated by the meter.

I have set the DCB serail params as follows, intending to control communication using RTS and DTR:

dcbSerialParams.BaudRate=CBR_4800;
dcbSerialParams.ByteSize=7;
dcbSerialParams.StopBits=TWOSTOPBITS;
dcbSerialParams.Parity=EVENPARITY;
dcbSerialParams.fDtrControl=DTR_CONTROL_ENABLE;
dcbSerialParams.fRtsControl=RTS_CONTROL_ENABLE;

My old code under DOS was like this:

 outportb(COM1+4,0x03);  /* start Minolta reading */

 for(j=0;j<=10;j++) /*each reading consists of 11 ascii characters*/
  {
  while(!((inportb(COM1+5)) & 1)); /*wait until char received*/
  reading[j]=inportb(COM1);
  }
 sscanf ( &reading[4], "%f", &lum[k] );

 outportb(COM1+4,0x00);  /* stop Minolta reading */

It seems to me that this should work:

void serial_notready(void)
{
EscapeCommFunction(hSerial,CLRDTR);
EscapeCommFunction(hSerial,CLRRTS);
}

void serial_ready(void)
{
EscapeCommFunction(hSerial,SETDTR);
EscapeCommFunction(hSerial,SETRTS);
}

int serial_read(char reading[])
{
DWORD dwBytesRead = 0;
int nbytes=11;
ReadFile(hSerial, reading, nbytes, &dwBytesRead, NULL);
return(dwBytesRead);
}

serial_ready(void);
x = 0; while(x == 0){x=serial_read(reading);}
serial_notready(void);

HOWEVER, the Minolta does not wait to receive the RTS from the computer. It just goes ahead and sends readings as each becomes available. At the same time, the computer does not reject any unwanted reading, but accepts it.

I have been bashing my head against the wall trying to figure this out, trying all kinds of permutations to no avail. Any help greatly appreciated!

Update:

The underlying story is that I present a given luminance (brightness) on a display and then need the corresponding luminance reading. This is done for a whole set of luminances.

L   ---
U      ---
M         ---
     TIME

I present lum1, lum2, lum3, lum4,.... If the measurements are not synchronised to the display, then I may get a supposed reading3 that is actually lum2, or some sort of average because the reading crossed the border between the lum2 and lum3 displays. And, as you said, Hans,the readings will always lag behind the display luminances. Even if I were always systematically one reading behind it would be bad (my situation is worse-- it is a a random relation between the reading and the luminance).

So the behaviour of the windows serial routines is a nightmare for me. Thanks again for the help!

Body:
dcbSerialParams.fDtrControl=DTR_CONTROL_ENABLE;
dcbSerialParams.fRtsControl=RTS_CONTROL_ENABLE;

You enable the DTR and RTS signals right away.  The meter will immediately start sending data when you open the port.  That data gets buffered in the driver's receive buffer.  You didn't have a buffer before in the DOS code.  It depends how long it takes for you to call serial_notready().  You'll have a pretty full buffer if that takes a second or so.  Yes, that makes it look like the meter is just sending data.  And you are always reading an old sample.

Start with the DCB values set to DISABLE.  Beware that the scheme is brittle, you could turn the signal off pretty reliably back in the DOS.  Now you've got a driver in between.  You may well end up turning RTS off too late.  Which risks getting a stale reading.  An alternative is to startup a thread that just reads continuously.  And have your main code just use the last value that it read.  The overhead is quite low, serial ports are slow.


问:
Callback is not a function error [Nodejs]
I have the following code

```<code>var getUrl = function(callback) {
  ref.once('value')
    .then(function(snap) {
      let article_url = snap.val();
      console.log(article_url);
      callback(null, article_url); // I dont want to throw an error, so I pass null for the error argument
    });
};

var getImage = function(err, data, callback) {
  //if (err) throw err; // Check for the error and throw if it exists.
  textapi.extract({
    url: data,
    best_image: true
  }, function(error, response) {
    if (error === null) {
      //console.log(response.image);
      if (response.image == null || response.image == "") {
        image = "https://www.wefornews.com/wp-content/uploads/2017/01/news-3.jpg"
      } else {
        image = response.image;
      }
    }
  });
  callback(null, image); // Otherwise proceed as usual.
};

var updateDatabase = function(err, data) {
  //if (err) throw err; // Check for the error and throw if it exists.
  refupdate.update ({
    "Article_Image_URL": data
  });
  console.log('success'); // Otherwise proceed as usual
};

getUrl(getImage);
getImage(updateDatabase);
</code>```

However I get an error callback is not a function at the line callback(null, image);

The thing is if I remove the updateDatabase function then I get no errors. However when it is within the code I get the error mentioned above.
Can someone please tell me what can be causing this error?

答: because you don't provide any callback on this call getImage(updateDatabase); (last line) ?

Body:
I have the following code

var getUrl = function(callback) {
  ref.once('value')
    .then(function(snap) {
      let article_url = snap.val();
      console.log(article_url);
      callback(null, article_url); // I dont want to throw an error, so I pass null for the error argument
    });
};

var getImage = function(err, data, callback) {
  //if (err) throw err; // Check for the error and throw if it exists.
  textapi.extract({
    url: data,
    best_image: true
  }, function(error, response) {
    if (error === null) {
      //console.log(response.image);
      if (response.image == null || response.image == "") {
        image = "https://www.wefornews.com/wp-content/uploads/2017/01/news-3.jpg"
      } else {
        image = response.image;
      }
    }
  });
  callback(null, image); // Otherwise proceed as usual.
};

var updateDatabase = function(err, data) {
  //if (err) throw err; // Check for the error and throw if it exists.
  refupdate.update ({
    "Article_Image_URL": data
  });
  console.log('success'); // Otherwise proceed as usual
};

getUrl(getImage);
getImage(updateDatabase);

However I get an error callback is not a function at the line callback(null, image);

The thing is if I remove the updateDatabase function then I get no errors. However when it is within the code I get the error mentioned above.
Can someone please tell me what can be causing this error?


问:
Wordpress giving 404 error after url change
Just recently setup Wordpress on Server 2016 through IIS. Everything works fine at the defaults, with localhost as the defaults. However, whenever I add bindings to the site, it begins to not work and will give an error.
Error code is here.
Permissions seem to be fine, unless I missed an important step.

Anyone have any ideas on how to fix this? I can no longer access via localhost, the IP, or the domain name.

答:
You need to update Permalink.
go your Dashboard -> Setting -> permalink
click on save change button. Here you can change URL structure for your permalinks and archives.


问:
Passing a multidimensional array through hidden input via POST
So I researched online to see how I can pass an array which I POST through form.

Here's what I did.

```<code>    $itemsArr = array();
    while ($row = $result->fetch_assoc()) {
    $totalPrice += $row['item_price'];
    $totalItemsOnCart += $row['quantity'];
    $itemId = $row['item_idPK'];
    $itemName = $row['item_name'];
    $itemPrice = $row['item_price'];
    $itemQty = $row['quantity'];
    $itemsArr[] = array($userId, $itemId, $itemQty);

    echo "<tr>";
    echo "<td>".$itemId."</td>";
    echo "<td>".$itemName."</td>";
    echo "<td>".$itemPrice."</td>";
    echo "<td>".$itemQty."</td>";
    echo "</tr>";
    }
</code>```

Then, I used the foreach loop to iterate through the multidimensional array.

```<code>echo "<form class = 'BreadCode' action='Function_Cart.php' method='POST'>";
foreach($itemsArr as $value){
    print_r($value);
    echo '<input type="hidden" name="itemsArr[]" value="'. $value. '">';
}
    echo "<input type='hidden' name='userId' value='$userId'>";
    echo "<input type='hidden' name='itemId' value='$itemId'>";
    echo "<input type='hidden' name='quantity' value='$itemQty'>";
    echo "<input class='PayButton' type='submit' name='Btn-pay' value='Pay'>";
    echo "</form>";
</code>```

I keep getting an  "Array to string conversion" error with or without the echo for the hidden input within the foreach() loop

I haven't really tried sending an array via form through POST method in the past. I just don't know how to go about this.

Below is the result of print_r()

```<code>Array ( [0] => 5112 [1] => 105 [2] => 2 )
Array ( [0] => 5112 [1] => 104 [2] => 1 )
</code>```

Please help.

Thank you.

答:
There is no need for place foreach and increase execution time. You can simply do that by using json_encode.

```<code>echo "<form class = 'BreadCode' action='Function_Cart.php' method='POST'>";
echo '<input type="hidden" name="itemsArr" value="' . json_encode($itemsArr) . '">';

echo "<input type='hidden' name='userId' value='$userId'>";
echo "<input type='hidden' name='itemId' value='$itemId'>";
echo "<input type='hidden' name='quantity' value='$itemQty'>";
echo "<input class='PayButton' type='submit' name='Btn-pay' value='Pay'>";
echo "</form>";
</code>```

Body:
So I researched online to see how I can pass an array which I POST through form.

Here's what I did.

    $itemsArr = array();
    while ($row = $result->fetch_assoc()) {
    $totalPrice += $row['item_price'];
    $totalItemsOnCart += $row['quantity'];
    $itemId = $row['item_idPK'];
    $itemName = $row['item_name'];
    $itemPrice = $row['item_price'];
    $itemQty = $row['quantity'];
    $itemsArr[] = array($userId, $itemId, $itemQty);

    echo "
";
    echo "".$itemId."	";
    echo "".$itemName."	";
    echo "".$itemPrice."	";
    echo "".$itemQty."	";
    echo "
";
    }

Then, I used the foreach loop to iterate through the multidimensional array.

echo "<form class = 'BreadCode' action='Function_Cart.php' method='POST'>";
foreach($itemsArr as $value){
    print_r($value);
    echo '<input type="hidden" name="itemsArr[]" value="'. $value. '">';
}
    echo "<input type='hidden' name='userId' value='$userId'>";
    echo "<input type='hidden' name='itemId' value='$itemId'>";
    echo "<input type='hidden' name='quantity' value='$itemQty'>";
    echo "<input class='PayButton' type='submit' name='Btn-pay' value='Pay'>";
    echo "</form>";

I keep getting an  "Array to string conversion" error with or without the echo for the hidden input within the foreach() loop

I haven't really tried sending an array via form through POST method in the past. I just don't know how to go about this.

Below is the result of print_r()

Array ( [0] => 5112 [1] => 105 [2] => 2 )
Array ( [0] => 5112 [1] => 104 [2] => 1 )

Please help.

Thank you.

Body:
There is no need for place foreach and increase execution time. You can simply do that by using json_encode.

echo "<form class = 'BreadCode' action='Function_Cart.php' method='POST'>";
echo '<input type="hidden" name="itemsArr" value="' . json_encode($itemsArr) . '">';

echo "<input type='hidden' name='userId' value='$userId'>";
echo "<input type='hidden' name='itemId' value='$itemId'>";
echo "<input type='hidden' name='quantity' value='$itemQty'>";
echo "<input class='PayButton' type='submit' name='Btn-pay' value='Pay'>";
echo "</form>";


问:
HTML within markdown files doesn't get rendered
I have a table that I need to include in a markdown document in our TFS 2017 on-prem repository. The table needs to include multiple values separated by a line break within one of the columns. I can write it and see the expected results using HTML tags in Visual Studio Code however, TFS 2017 doesn't render it correctly.

```<code>Top of the **markdown** file

<table>
    <tr>
        <th>Key</th>
        <th>Description</th>
        <th>Value</th>
        <th>Example</th>
        <th>Required</th>
    </tr>
    <tr>
        <td>app-name</td>
        <td>The name of the application that the resource was provisioned for.</td>
        <td>The app name is a simplified version of the project-name tag below, if the resource was created for a project. Otherwise, use the product name.</td>
        <td>foo-bar<br/>product-evaluation</td>
        <td>If associated to an app, yes.</td>
    </tr>
</table>

Bottom of the *markdown* file.
</code>```

Taking the above markdown file example, Visual Studio renders it like this:

Once I've pushed it to TFS 2017 however, the HTML isn't rendered at all. The markdown parts are still rendered correctly though.

Is this expected behavior, and is there anything on the roadmap to support HTML within markdown files? The markdown specifications support this. If HTML isn't supported, what can I do to use line-breaks in a standard MD table column?

答:
Yes, it's the expected behavior.

For now, it's not supported for TFS on-premise. However in VSTS (TFS on line) it can be rendered in preview, but still cannot be rendered in Dashboard (Add to dashboard).

We don’t have a public timeline for this feature to support right now. However VSTS alread support the preview, So maybe will full support soon. You can track the feature timeline in here: https://www.visualstudio.com/en-us/news/release-archive-vso, that’s the first place update.

In your scenario you can use Markdown to render the table instead of html:

You can create tables by assembling a list of words and dividing them with hyphens - (for the first row), and then separating each column with a pipe |:

```<code>| Key | Description | Value |  Example |Required |
|-----------|:-----------:|-----------:|-----------:|-----------:|
| app-name  | The name of the application that the resource was provisioned for. |The app name is a simplified version of the project-name tag below, if the resource was created for a project. Otherwise, use the product name. | foo-bar product-evaluation | If associated to an app, yes.|
</code>```

See Syntax guidance for Markdown files for details.

Besides, Wiki feature introduced in TFS 2018, it supports for HTML tags in markdown. You can upgrade to TFS 2018 if that's an option.

Body:
I have a table that I need to include in a markdown document in our TFS 2017 on-prem repository. The table needs to include multiple values separated by a line break within one of the columns. I can write it and see the expected results using HTML tags in Visual Studio Code however, TFS 2017 doesn't render it correctly.

Top of the **markdown** file

        Key
        Description
        Value
        Example
        Required

        app-name
        The name of the application that the resource was provisioned for.
        The app name is a simplified version of the project-name tag below, if the resource was created for a project. Otherwise, use the product name.
        foo-bar
product-evaluation
        If associated to an app, yes.

Bottom of the *markdown* file.

Taking the above markdown file example, Visual Studio renders it like this:

Once I've pushed it to TFS 2017 however, the HTML isn't rendered at all. The markdown parts are still rendered correctly though.

Is this expected behavior, and is there anything on the roadmap to support HTML within markdown files? The markdown specifications support this. If HTML isn't supported, what can I do to use line-breaks in a standard MD table column?

Body:
Yes, it's the expected behavior.

For now, it's not supported for TFS on-premise. However in VSTS (TFS on line) it can be rendered in preview, but still cannot be rendered in Dashboard (Add to dashboard).

We don’t have a public timeline for this feature to support right now. However VSTS alread support the preview, So maybe will full support soon. You can track the feature timeline in here: https://www.visualstudio.com/en-us/news/release-archive-vso, that’s the first place update.

In your scenario you can use Markdown to render the table instead of html:

You can create tables by assembling a list of words and dividing them with hyphens - (for the first row), and then separating each column with a pipe |:

| Key | Description | Value |  Example |Required |
|-----------|:-----------:|-----------:|-----------:|-----------:|
| app-name  | The name of the application that the resource was provisioned for. |The app name is a simplified version of the project-name tag below, if the resource was created for a project. Otherwise, use the product name. | foo-bar product-evaluation | If associated to an app, yes.|

See Syntax guidance for Markdown files for details.

Besides, Wiki feature introduced in TFS 2018, it supports for HTML tags in markdown. You can upgrade to TFS 2018 if that's an option.


答: This means that your copy of source code is not latest and causing mismatch. Take latest from master, may be in other location merge your changes with it and then try to push again</p>

Title: git can't push my updates to remote


问:
Using nested Master Pages
I'm very new to ASP.NET, help me please understand MasterPages conception more.

I have Site.master with common header data (css, meta, etc), center form (blank) and footer (copyright info, contact us link, etc).

```<code><%@ Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="_SiteMaster" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="tagHead" runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" href="styles.css" type="text/css" />
</head>
<body>
    <form id="frmMaster" runat="server">
    <div>
        <asp:ContentPlaceHolder ID="holderForm" runat="server"></asp:ContentPlaceHolder>
        <asp:ContentPlaceHolder ID="holderFooter" runat="server">Some footer here</asp:ContentPlaceHolder>
    </div>
    </form>
</body>
</html>
</code>```

and I want to use second master page for a project into sub directory, which would contains SQL query on Page_Load for logging (it isn't necessary for whole site).

```<code><%@ Master Language="C#" AutoEventWireup="true" CodeFile="Project.master.cs" Inherits="_ProjectMaster" MasterPageFile="~/Site.master" %>
<asp:Content ContentPlaceHolderID="holderForm" runat="server">
    <asp:ContentPlaceHolder ID="holderForm" runat="server" EnableViewState="true"></asp:ContentPlaceHolder>
</asp:Content>
<asp:Content ContentPlaceHolderID="holderFooter" runat="server">
    <asp:ContentPlaceHolder ID="holderFooter" runat="server" EnableViewState="true"></asp:ContentPlaceHolder>
</asp:Content>
</code>```

But I have a problem: footer isn't displayed.

Where is my mistake? Am I right to use second master page as super class for logging?

Project page looks like this:

```<code><%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" MasterPageFile="~/Project.master" %>
<asp:Content ContentPlaceHolderID="holderForm" runat="server">
    <p>Hello World!</p>
</asp:Content>
<asp:Content ContentPlaceHolderID="holderFooter" runat="Server">
    Some footer content
</asp:Content>
</code>```

答:
I have next inheritance tree:

```<code>Site.master <-- Page1.aspx
<-- Project.master <-- Page2.aspx
</code>```

And I don't know why Page2 display only content of itself and it's master page - Project. But doesn't display a content of Site (as Page1 does) Why? What have I to write for doing that?

OwnerDisplayName: abatishchev

Title: Using nested Master Pages

Body:
I'm very new to ASP.NET, help me please understand MasterPages conception more.

I have Site.master with common header data (css, meta, etc), center form (blank) and footer (copyright info, contact us link, etc).

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="_SiteMaster" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" href="styles.css" type="text/css" />

    <form id="frmMaster" runat="server">

        <asp:ContentPlaceHolder ID="holderForm" runat="server"></asp:ContentPlaceHolder>
        <asp:ContentPlaceHolder ID="holderFooter" runat="server">Some footer here</asp:ContentPlaceHolder>

    </form>

and I want to use second master page for a project into sub directory, which would contains SQL query on Page_Load for logging (it isn't necessary for whole site).

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Project.master.cs" Inherits="_ProjectMaster" MasterPageFile="~/Site.master" %>
<asp:Content ContentPlaceHolderID="holderForm" runat="server">
    <asp:ContentPlaceHolder ID="holderForm" runat="server" EnableViewState="true"></asp:ContentPlaceHolder>
</asp:Content>
<asp:Content ContentPlaceHolderID="holderFooter" runat="server">
    <asp:ContentPlaceHolder ID="holderFooter" runat="server" EnableViewState="true"></asp:ContentPlaceHolder>
</asp:Content>

But I have a problem: footer isn't displayed.

Where is my mistake? Am I right to use second master page as super class for logging?

Project page looks like this:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" MasterPageFile="~/Project.master" %>
<asp:Content ContentPlaceHolderID="holderForm" runat="server">

Hello World!

</asp:Content>
<asp:Content ContentPlaceHolderID="holderFooter" runat="Server">
    Some footer content
</asp:Content>

LastEditorDisplayName: buyutec

Body:
I have next inheritance tree:

Site.master <-- Page1.aspx
<-- Project.master <-- Page2.aspx

And I don't know why Page2 display only content of itself and it's master page - Project. But doesn't display a content of Site (as Page1 does) Why? What have I to write for doing that?