问:
HTML and CSS multiple tables display problem
I need help, how I can remove this space below the tables?
I want to have 3 tables in 1 row and below also 3 tables in 1 row etc.. I've been trying for a few days but I can't succeed. :(
I hope you understand me, any help is welcome .

Each new table in a new row depends on the previous table row which has several rows and it includes the same height.

Each new table in a new row depends on the previous table row which has several rows and it includes the same height.

```
<pre class="snippet-code-html lang-html prettyprint-override"><code><table class="table1">
    <tbody>
       <tr><th>TABLE HEADER EXAMPLE</th></tr>
     <tr><td>Table Rows Example</td></tr>
     <tr><td>Table Rows Example</td></tr>
     <tr><td>Table Rows Example</td></tr>
     <tr><td>Table Rows Example</td></tr>
     <tr><td>Table Rows Example</td></tr>
     <tr><td>Table Rows Example</td></tr>
     <tr><td>Table Rows Example</td></tr>
     <tr><td>Table Rows Example</td></tr>
 </tbody>
</table>

<table class="table2">
   <tbody>
        <tr><th>TABLE HEADER EXAMPLE</th></tr>
     <tr><td>Table Rows Example</td></tr>
     <tr><td>Table Rows Example</td></tr>
     <tr><td>Table Rows Example</td></tr>
     <tr><td>Table Rows Example</td></tr>
     <tr><td>Table Rows Example</td></tr>
     <tr><td>Table Rows Example</td></tr>
    <tr><td>Table Rows Example</td></tr>
     <tr><td>Table Rows Example</td></tr>
     <tr><td>Table Rows Example</td></tr>
     <tr><td>Table Rows Example</td></tr>
   </tbody>
</table>

<table class="table3">
    <tbody>
        <tr><th>TABLE HEADER EXAMPLE</th></tr>
      <tr><td>Table Rows Example</td></tr>
      <tr><td>Table Rows Example</td></tr>
      <tr><td>Table Rows Example</td></tr>
      <tr><td>Table Rows Example</td></tr>
      <tr><td>Table Rows Example</td></tr>
      <tr><td>Table Rows Example</td></tr>
      <tr><td>Table Rows Example</td></tr>
      <tr><td>Table Rows Example</td></tr>
      <tr><td>Table Rows Example</td></tr>
      <tr><td>Table Rows Example</td></tr>
      <tr><td>Table Rows Example</td></tr>
      <tr><td>Table Rows Example</td></tr>
      <tr><td>Table Rows Example</td></tr>
      <tr><td>Table Rows Example</td></tr>
      <tr><td>Table Rows Example</td></tr>
      <tr><td>Table Rows Example</td></tr>
      <tr><td>Table Rows Example</td></tr>
    </tbody>
</table>

<table class="table4">
    <tbody>
         <tr><th>TABLE HEADER EXAMPLE</th></tr>
     <tr><td>Table Rows Example</td></tr>
     <tr><td>Table Rows Example</td></tr>
     <tr><td>Table Rows Example</td></tr>
     <tr><td>Table Rows Example</td></tr>
     <tr><td>Table Rows Example</td></tr>
  </tbody>
</table>

<table class="table5">
     <tbody>
          <tr><th>TABLE HEADER EXAMPLE</th></tr>
    <tr><td>Table Rows Example</td></tr>
    <tr><td>Table Rows Example</td></tr>
    <tr><td>Table Rows Example</td></tr>
    <tr><td>Table Rows Example</td></tr>
    <tr><td>Table Rows Example</td></tr>
    <tr><td>Table Rows Example</td></tr>
   </tbody>
</table>

<table class="table6">
    <tbody>
         <tr><th>TABLE HEADER EXAMPLE</th></tr>
     <tr><td>Table Rows Example</td></tr>
     <tr><td>Table Rows Example</td></tr>
     <tr><td>Table Rows Example</td></tr>
     <tr><td>Table Rows Example</td></tr>
     <tr><td>Table Rows Example</td></tr>
     <tr><td>Table Rows Example</td></tr>
     <tr><td>Table Rows Example</td></tr>
     <tr><td>Table Rows Example</td></tr>
     <tr><td>Table Rows Example</td></tr>
  </tbody>
</table>

<table class="table7">
    <tbody>
        <tr><th>TABLE HEADER EXAMPLE</th></tr>
     <tr><td>Table Rows Example</td></tr>
     <tr><td>Table Rows Example</td></tr>
  </tbody>
</table>

<table class="table8">
    <tbody>
        <tr><th>TABLE HEADER EXAMPLE</th></tr>
     <tr><td>Table Rows Example</td></tr>
     <tr><td>Table Rows Example</td></tr>
     <tr><td>Table Rows Example</td></tr>
     <tr><td>Table Rows Example</td></tr>
  </tbody>
</table>

<table class="table9">
   <tbody>
        <tr><th>TABLE HEADER EXAMPLE</th></tr>
       <tr><td>Table Rows Example</td></tr>
       <tr><td>Table Rows Example</td></tr>
       <tr><td>Table Rows Example</td></tr>
       <tr><td>Table Rows Example</td></tr>
       <tr><td>Table Rows Example</td></tr>
       <tr><td>Table Rows Example</td></tr>
  </tbody>
</table></code>```

答:
I am not sure this is what you are looking for but check it out-

```<code><!DOCTYPE html>
<html>
<head>
    <title></title>
    <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
    <div class="masonry">
        <div class="item">
            <table class="table1">
                <tbody>
                    <tr><th>TABLE HEADER EXAMPLE</th></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                </tbody>
            </table>
        </div>
        <div class="item">
            <table class="table2">
                <tbody>
                    <tr><th>TABLE HEADER EXAMPLE</th></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                </tbody>
            </table>
        </div>
        <div class="item">
            <table class="table3">
                <tbody>
                    <tr><th>TABLE HEADER EXAMPLE</th></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                </tbody>
            </table>
        </div>
        <div class="item">
            <table class="table4">
                <tbody>
                    <tr><th>TABLE HEADER EXAMPLE</th></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                </tbody>
            </table>
        </div>
        <div class="item">
            <table class="table5">
                <tbody>
                    <tr><th>TABLE HEADER EXAMPLE</th></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                </tbody>
            </table>
        </div>
        <div class="item">
            <table class="table6">
                <tbody>
                    <tr><th>TABLE HEADER EXAMPLE</th></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                </tbody>
            </table>
        </div>
        <div class="item">
            <table class="table7">
                <tbody>
                    <tr><th>TABLE HEADER EXAMPLE</th></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                </tbody>
            </table>
        </div>
        <div class="item">
            <table class="table8">
                <tbody>
                    <tr><th>TABLE HEADER EXAMPLE</th></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                </tbody>
            </table>
        </div>
        <div class="item">
            <table class="table9">
                <tbody>
                    <tr><th>TABLE HEADER EXAMPLE</th></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                </tbody>
            </table>
        </div>
        Run code snippet
    </div>
</body>
</html>
</code>```

and the basic css needed just for layout -

```<code>.masonry { /* Masonry container */
  column-count: 4;
  column-gap: 1em;
}

.item { /* Masonry bricks or child elements */
  background-color: #eee;
  display: inline-block;
  margin: 0 0 1em;
  width: 100%;
}
</code>```

Note: this layout renders items in top-to-bottom manner. For more details, you can check-
https://w3bits.com/css-masonry/

Body:
I need help, how I can remove this space below the tables?
I want to have 3 tables in 1 row and below also 3 tables in 1 row etc.. I've been trying for a few days but I can't succeed. :(
I hope you understand me, any help is welcome .

Each new table in a new row depends on the previous table row which has several rows and it includes the same height.

Each new table in a new row depends on the previous table row which has several rows and it includes the same height.

TABLE HEADER EXAMPLE

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

TABLE HEADER EXAMPLE

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

TABLE HEADER EXAMPLE

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

TABLE HEADER EXAMPLE

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

TABLE HEADER EXAMPLE

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

TABLE HEADER EXAMPLE

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

TABLE HEADER EXAMPLE

Table Rows Example

Table Rows Example

TABLE HEADER EXAMPLE

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

TABLE HEADER EXAMPLE

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

Table Rows Example

Body:
I am not sure this is what you are looking for but check it out-

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
    <div class="masonry">
        <div class="item">
            <table class="table1">
                <tbody>
                    <tr><th>TABLE HEADER EXAMPLE</th></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                </tbody>
            </table>
        </div>
        <div class="item">
            <table class="table2">
                <tbody>
                    <tr><th>TABLE HEADER EXAMPLE</th></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                </tbody>
            </table>
        </div>
        <div class="item">
            <table class="table3">
                <tbody>
                    <tr><th>TABLE HEADER EXAMPLE</th></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                </tbody>
            </table>
        </div>
        <div class="item">
            <table class="table4">
                <tbody>
                    <tr><th>TABLE HEADER EXAMPLE</th></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                </tbody>
            </table>
        </div>
        <div class="item">
            <table class="table5">
                <tbody>
                    <tr><th>TABLE HEADER EXAMPLE</th></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                </tbody>
            </table>
        </div>
        <div class="item">
            <table class="table6">
                <tbody>
                    <tr><th>TABLE HEADER EXAMPLE</th></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                </tbody>
            </table>
        </div>
        <div class="item">
            <table class="table7">
                <tbody>
                    <tr><th>TABLE HEADER EXAMPLE</th></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                </tbody>
            </table>
        </div>
        <div class="item">
            <table class="table8">
                <tbody>
                    <tr><th>TABLE HEADER EXAMPLE</th></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                </tbody>
            </table>
        </div>
        <div class="item">
            <table class="table9">
                <tbody>
                    <tr><th>TABLE HEADER EXAMPLE</th></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                    <tr><td>Table Rows Example</td></tr>
                </tbody>
            </table>
        </div>
        Run code snippet
    </div>
</body>
</html>

and the basic css needed just for layout -

.masonry { /* Masonry container */
  column-count: 4;
  column-gap: 1em;
}

.item { /* Masonry bricks or child elements */
  background-color: #eee;
  display: inline-block;
  margin: 0 0 1em;
  width: 100%;
}

Note: this layout renders items in top-to-bottom manner. For more details, you can check-
https://w3bits.com/css-masonry/


来源: stackexchange

问:
Android Writing Logs to text File
I'm Trying to Write Logs to Custom Log.txt File on Android File using this code of Mine but then this method creates file but contains nothing. Basically I want to read previous contents of the file and then append my data with the existing content.

The Code is as follows :

```<code>public static void write(String str)
    {
        InputStream fileInputStream = null;
        FileOutputStream fileOutpurStream = null;
        try
        {
            fileInputStream = new FileInputStream(file);
            fileOutpurStream = new FileOutputStream(file);
            if(file.exists())
            {
                int ch = 0;
                int current = 0;
                StringBuffer buffer = new StringBuffer();
                while((ch = fileInputStream.read()) != -1)
                {
                    buffer.append((char) ch);
                    current++;
                }
                byte data[]=new byte[(int)file.length()];
                fileInputStream.read(data);
                fileOutpurStream.write(data);
                fileOutpurStream.write(str.getBytes(),0,str.getBytes().length);
                fileOutpurStream.flush();
            }
            else
            {
                file.createNewFile();
                fileOutpurStream.write(str.getBytes(),0,str.getBytes().length);
                fileOutpurStream.flush();
            }
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
        finally
        {
            try
            {
                fileInputStream.close();
                fileOutpurStream.flush();
                fileOutpurStream.close();
                fileOutpurStream = null;
                fileInputStream = null;
            }
            catch (IOException e)
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
</code>```

答:
Hope this can help...</p>

```<code>public void appendLog(String text)
{
   File logFile = new File("sdcard/log.file");
   if (!logFile.exists())
   {
      try
      {
         logFile.createNewFile();
      }
      catch (IOException e)
      {
         // TODO Auto-generated catch block
         e.printStackTrace();
      }
   }
   try
   {
      //BufferedWriter for performance, true to set append to file flag
      BufferedWriter buf = new BufferedWriter(new FileWriter(logFile, true));
      buf.append(text);
      buf.newLine();
      buf.close();
   }
   catch (IOException e)
   {
      // TODO Auto-generated catch block
      e.printStackTrace();
   }
}
</code>```

ContentLicense: CC BY-SA 3.0

Title: Android Writing Logs to text File

Body:
I'm Trying to Write Logs to Custom Log.txt File on Android File using this code of Mine but then this method creates file but contains nothing. Basically I want to read previous contents of the file and then append my data with the existing content.

The Code is as follows :

public static void write(String str)
    {
        InputStream fileInputStream = null;
        FileOutputStream fileOutpurStream = null;
        try
        {
            fileInputStream = new FileInputStream(file);
            fileOutpurStream = new FileOutputStream(file);
            if(file.exists())
            {
                int ch = 0;
                int current = 0;
                StringBuffer buffer = new StringBuffer();
                while((ch = fileInputStream.read()) != -1)
                {
                    buffer.append((char) ch);
                    current++;
                }
                byte data[]=new byte[(int)file.length()];
                fileInputStream.read(data);
                fileOutpurStream.write(data);
                fileOutpurStream.write(str.getBytes(),0,str.getBytes().length);
                fileOutpurStream.flush();
            }
            else
            {
                file.createNewFile();
                fileOutpurStream.write(str.getBytes(),0,str.getBytes().length);
                fileOutpurStream.flush();
            }
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
        finally
        {
            try
            {
                fileInputStream.close();
                fileOutpurStream.flush();
                fileOutpurStream.close();
                fileOutpurStream = null;
                fileInputStream = null;
            }
            catch (IOException e)
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

Body:
Hope this can help...

public void appendLog(String text)
{
   File logFile = new File("sdcard/log.file");
   if (!logFile.exists())
   {
      try
      {
         logFile.createNewFile();
      }
      catch (IOException e)
      {
         // TODO Auto-generated catch block
         e.printStackTrace();
      }
   }
   try
   {
      //BufferedWriter for performance, true to set append to file flag
      BufferedWriter buf = new BufferedWriter(new FileWriter(logFile, true));
      buf.append(text);
      buf.newLine();
      buf.close();
   }
   catch (IOException e)
   {
      // TODO Auto-generated catch block
      e.printStackTrace();
   }
}


问:
How to debug in VS Code a Firebase Cloud Function that is fired on a document onDelete?
I'm having a hard time trying to debug a firebase cloud function, for now what I'm doing is to add some console logs, changing code and deploying everytime.

I've found a couple tutorials on how to do this, but they are too old and doesn't really work anymore.
Besides, these tutorials doesn't show how to debug a function that is fired when a document is deleted on Firebase, which is my case.

For example:

```<code>exports.DeleteDevelopment = functions.firestore
  .document('developments/{Id}')
  .onDelete(async (snap) => triggers.deleteDevelopment(snap));
</code>```

After this code is fired when a document is deleted inside de developments collection, I would like to set some breakpoints inside my function deleteDevelopment

Is there any "easy" way to debug my function inside VS Code?

Thanks,
Bruno

[EDIT]
After trying a little further on this issue, here are some things I've done so far...
I've used the 'firebase init' again, changing some settings on my local environment.
So, this is how I did it:

Then, back into my function folder, npm install, npm run build, everything ok...

I've run 'firebase emulators:start', and everything initialized...
(besides other logs, my function initialized as below)
functions[DeleteDevelopment]: firestore function initialized.
┌──────────────────────────────────────────────────────────────┐
│ ✔  All emulators ready! It is now safe to connect your apps. │
└──────────────────────────────────────────────────────────────┘

┌───────────┬────────────────┐
│ Emulator  │ Host:Port      │
├───────────┼────────────────┤
│ Functions │ localhost:5001 │
├───────────┼────────────────┤
│ Firestore │ localhost:8080 │
├───────────┼────────────────┤
│ Database  │ localhost:9000 │
├───────────┼────────────────┤
│ Hosting   │ localhost:5000 │
└───────────┴────────────────┘

Now, the problem is, I still can't debug locally my DeleteDevelopment.
I'm on a trial and error quest without even knowing what I'm doing (I know, it's sad)...
Tried the 'firebase emulators:start --only functions', 'firebase serve --only functions', 'functions deploy DeveleDevelopment', and a couple of combination changing the order of the commands.

If anyone could give a hint to solve this, it would be great!

Thanks again,
Bruno.

答: Try the firebase server --only functions from the functions directory. The functions emulator should load up any functions you have created. To set a breakpoint on a function running live, you need to create a json configuration file for debugging. There are more steps with examples outline here at this https://medium.com/@david_shortman/build-and-debug-firebase-functions-in-vscode-73efb76166cf</p>

ContentLicense: CC BY-SA 4.0

Body:
I'm having a hard time trying to debug a firebase cloud function, for now what I'm doing is to add some console logs, changing code and deploying everytime.

I've found a couple tutorials on how to do this, but they are too old and doesn't really work anymore.
Besides, these tutorials doesn't show how to debug a function that is fired when a document is deleted on Firebase, which is my case.

For example:

exports.DeleteDevelopment = functions.firestore
  .document('developments/{Id}')
  .onDelete(async (snap) => triggers.deleteDevelopment(snap));

After this code is fired when a document is deleted inside de developments collection, I would like to set some breakpoints inside my function deleteDevelopment

Is there any "easy" way to debug my function inside VS Code?

Thanks,
Bruno

[EDIT]
After trying a little further on this issue, here are some things I've done so far...
I've used the 'firebase init' again, changing some settings on my local environment.
So, this is how I did it:

Then, back into my function folder, npm install, npm run build, everything ok...

I've run 'firebase emulators:start', and everything initialized...
(besides other logs, my function initialized as below)
functions[DeleteDevelopment]: firestore function initialized.
┌──────────────────────────────────────────────────────────────┐
│ ✔  All emulators ready! It is now safe to connect your apps. │
└──────────────────────────────────────────────────────────────┘

┌───────────┬────────────────┐
│ Emulator  │ Host:Port      │
├───────────┼────────────────┤
│ Functions │ localhost:5001 │
├───────────┼────────────────┤
│ Firestore │ localhost:8080 │
├───────────┼────────────────┤
│ Database  │ localhost:9000 │
├───────────┼────────────────┤
│ Hosting   │ localhost:5000 │
└───────────┴────────────────┘

Now, the problem is, I still can't debug locally my DeleteDevelopment.
I'm on a trial and error quest without even knowing what I'm doing (I know, it's sad)...
Tried the 'firebase emulators:start --only functions', 'firebase serve --only functions', 'functions deploy DeveleDevelopment', and a couple of combination changing the order of the commands.

If anyone could give a hint to solve this, it would be great!

Thanks again,
Bruno.


问:
MySQL heavy disk activity even with no queries running
Trying to troubleshoot an issue with a mysterious disk io bottleneck caused by MySQL.

I'm using the following commands to test disk read/write speed:

```<code>#write
dd if=/dev/zero of=/tmp/writetest bs=1M count=1024 conv=fdatasync,notrunc

#read
echo 3 > /proc/sys/vm/drop_caches; dd if=/tmp/writetest of=/dev/null bs=1M count=1024
</code>```

I rebooted the machine, disabled cron so none of my usual processes are running queries, killed the web server which usually runs, and killed mysqld.

When I run the read test without mysqld running, I get 1073741824 bytes (1.1 GB) copied, 2.19439 s, 489 MB/s. Consistently around 450-500 MB/s.

When I start back up the mysql service back up, then run the read test again, I get 1073741824 bytes (1.1 GB) copied, 135.657 s, 7.9 MB/s. Consistently around 5MB/s.

Running show full processlist in mysql doesn't show any queries (and I disabled everything that would be running queries anyway). In MySQLWorkbench's Server Status tab, I can see InnoDB reads fluctuate between 30-200 reads per second, and 3-15 writes per second even when no queries are running.

If I run iotop -oPa I can see that mysqld is racking up like 1MB disk reads per second when no queries are running. That seems like a lot considering no queries are running, but at the same time that doesn't seem like enough to cause my dd command to take so long... The only other thing performing disk io is jbd2/sda3-8.

Not sure if it's related, but if I try to kill the mysql server with service mysql stop it says "Attempt to stop MySQL timed out", and the mysqld process continues running, but I can no longer connect to the DB. I have to use kill -9 to kill the mysqld process and restart the server.

All of this appears to be out of the blue. This server was doing heavy duty log parsing, high volume inserts and selects for months, until this last weekend we started seeing this disk io bottleneck.

How can I find out why MySQL is doing so much disk reading when it's essentially idle?

答:
Did you update/delete/insert a large number rows?  If so, consider these "delays" in writing to disk:

The block containing the data is not written back to disk immediately.

Ditto for UNIQUE keys.

Updates to secondary indexes go into the "change buffer"  They get folded into the index blocks, often even later.

Updates/deletes leave behind a "history list" that needs to be cleaned up after the transaction is complete.

Those things are handled by background tasks that do not show up in the PROCESSLIST.  They may be visible on mysqld process(es), mostly as I/O.  (CPU is probably minimal.)

Was there a ROLLBACK?  Transactions are "optimistic".  So a ROLLBACK has to do a lot of work to "undo" what was optimistically already committed.

If you abruptly kill mysqld (or turn off the power), then the ROLLBACK occurs after restarting.

SSDs have no "seek" time.  HDDs must move the read/write heads by a variable amount; this takes time.  If your dd is working on one end of the disk, and mysqld is working on the other end, the "seeking" adds to the apparent I/O time.

Body:
Trying to troubleshoot an issue with a mysterious disk io bottleneck caused by MySQL.

I'm using the following commands to test disk read/write speed:

#write
dd if=/dev/zero of=/tmp/writetest bs=1M count=1024 conv=fdatasync,notrunc

#read
echo 3 > /proc/sys/vm/drop_caches; dd if=/tmp/writetest of=/dev/null bs=1M count=1024

I rebooted the machine, disabled cron so none of my usual processes are running queries, killed the web server which usually runs, and killed mysqld.

When I run the read test without mysqld running, I get 1073741824 bytes (1.1 GB) copied, 2.19439 s, 489 MB/s. Consistently around 450-500 MB/s.

When I start back up the mysql service back up, then run the read test again, I get 1073741824 bytes (1.1 GB) copied, 135.657 s, 7.9 MB/s. Consistently around 5MB/s.

Running show full processlist in mysql doesn't show any queries (and I disabled everything that would be running queries anyway). In MySQLWorkbench's Server Status tab, I can see InnoDB reads fluctuate between 30-200 reads per second, and 3-15 writes per second even when no queries are running.

If I run iotop -oPa I can see that mysqld is racking up like 1MB disk reads per second when no queries are running. That seems like a lot considering no queries are running, but at the same time that doesn't seem like enough to cause my dd command to take so long... The only other thing performing disk io is jbd2/sda3-8.

Not sure if it's related, but if I try to kill the mysql server with service mysql stop it says "Attempt to stop MySQL timed out", and the mysqld process continues running, but I can no longer connect to the DB. I have to use kill -9 to kill the mysqld process and restart the server.

All of this appears to be out of the blue. This server was doing heavy duty log parsing, high volume inserts and selects for months, until this last weekend we started seeing this disk io bottleneck.

How can I find out why MySQL is doing so much disk reading when it's essentially idle?


问:
How to include header files for external libraries in my source code?
I am trying to extract archived files in my project using Libarchive.
On a standalone code, i include libarchive's archive.h using:

#include <archive.h>

But I have seen on projects that header files are not included directly, they use:

#include <poppler/cpp/poppler-document.h>

Why is poppler-document.h not directly included?
So how are these directories specified?

答: If you're on visual studio you can go on Project Properties/"C/C++"/General and look at the additional include directories where you can add the directory of where those includes are. For including the .libs themselves you'll need to go in Linker/Additional Library Directories</p>


问:
How to use variables/values as arguments for imported modules/functions
The context of this is that I'm trying to make a common module that can be imported into other programs. The code here is from the common module. The idea of this function is that it checks if the value given from the main program is a positive integer or not.

```<code>def checkpoints(x):
        if x.isdigit() == False:
                num = print('Please enter valid interger.')
                return num
        else:
                print('all g')
                return
</code>```

Another question is that is it possible to use a variable from the main program and have that set as an argument in an imported function/module? How would I do that?

答:
To import variables and functions from files, treat the file name as a module. This only works if the 2 files are in the same directory.</p>

```<code># File Name, Function/Variables/Wildcard
from file import *
</code>```

Body:
The context of this is that I'm trying to make a common module that can be imported into other programs. The code here is from the common module. The idea of this function is that it checks if the value given from the main program is a positive integer or not.

def checkpoints(x):
        if x.isdigit() == False:
                num = print('Please enter valid interger.')
                return num
        else:
                print('all g')
                return

Another question is that is it possible to use a variable from the main program and have that set as an argument in an imported function/module? How would I do that?

Body:
To import variables and functions from files, treat the file name as a module. This only works if the 2 files are in the same directory.

# File Name, Function/Variables/Wildcard
from file import *


问:
Error when installing a python module in Linux
I am encoutering two kinds of issues while trying to install a package called Boltztrap2.

1) Trying to install Boltztrap2 using 'pip3'. However, when I punch in the command, the process goes smoothly for a while and then spits out an error :

```<code>BoltzTraP2/sphere/frontend.cpp:32:20: fatal error: Python.h: No such file or directory
 #include "Python.h"
                    ^
compilation terminated.
error: command 'gcc' failed with exit status 1
</code>```

I did some troubleshooting and found out that it is just a path issue - I confirmed this by typing 'locate Python.h'. However, I don't get how to manually incorporate this change since the 'pip3' command that I use downloads the program and compiles it automatically. I don't seem to have access to change any scripts, or rather I do not know how to, since I'm kind of new to all this.

PS: I do not have sudo access.

2) Trying to install Boltztrap2 by manually compiling the python setup file: This seems to work fine until the system spits out an error saying:

Error:numpy is not installed.

PS: Again, I do not have sudo access.

I would be very glad if someone could help me install this package through either method. I just want to get the software to work. Thanks in advance for any assistance.

答:
```<code>python3 -m pip install --upgrade pip
pip3 install numpy
</code>```

Check if you can upgrade pip?
If that works then you can pip install numpy.

Body:
I am encoutering two kinds of issues while trying to install a package called Boltztrap2.

1) Trying to install Boltztrap2 using 'pip3'. However, when I punch in the command, the process goes smoothly for a while and then spits out an error :

BoltzTraP2/sphere/frontend.cpp:32:20: fatal error: Python.h: No such file or directory
 #include "Python.h"
                    ^
compilation terminated.
error: command 'gcc' failed with exit status 1

I did some troubleshooting and found out that it is just a path issue - I confirmed this by typing 'locate Python.h'. However, I don't get how to manually incorporate this change since the 'pip3' command that I use downloads the program and compiles it automatically. I don't seem to have access to change any scripts, or rather I do not know how to, since I'm kind of new to all this.

PS: I do not have sudo access.

2) Trying to install Boltztrap2 by manually compiling the python setup file: This seems to work fine until the system spits out an error saying:

Error:numpy is not installed.

PS: Again, I do not have sudo access.

I would be very glad if someone could help me install this package through either method. I just want to get the software to work. Thanks in advance for any assistance.

Body:
python3 -m pip install --upgrade pip
pip3 install numpy

Check if you can upgrade pip?
If that works then you can pip install numpy.


问:
ASP.NET WebApp in Azure using lots of CPU
We have a long running ASP.NET WebApp in Azure which has no real endpoints exposed – it serves a single functional purpose primarily reading and manipulating database data,  effectively a batched, scheduled task, triggered by a timer every 30 seconds.
The app runs fine most of the time but we are seeing occasional issues where the CPU load for the app goes close to the maximum for the AppServicePlan, instantaneously rather than gradually, and stops executing any more timer triggers and we cannot find anything explicitly in the executing code to account for it (no signs of deadlocks etc. and all code paths have try/catch so there should be no unhandled exceptions). More often than not we see errors getting a connection to a database but it’s not clear if those are cause or symptoms.

Note, this is the only resource within the AppService Plan.  The Azure SQL database is in the same region and whilst utilised by other apps is very lightly used by them and they also exhibit none of the issues seen by the problem app.

It feels like this is infrastructure related but we have been unable to find anything to explain what is happening so if anyone has any suggestions for where we should be looking they would be gratefully received.  We have enabled basic Application Insights (not SDK) but other than seeing CPU load spike prior to loss of app response there is little information of interest given our limited knowledge of how to best utilise Insights.

答:
According to your description, I thought of two points to troubleshoot your problem. First of all, you can track the running status of your program through the code, and put a log at the beginning and end of your batch scheduled tasks to record the status of each run. If possible, record request and response information and start and end information. This can completely record the time and running status of your task.

Secondly, you can record logs before the program starts database operations, and whether the database connection is successful. The best case is to be able to record, what business will trigger CPU load when operating, and track the specific operating conditions, in order to specifically analyze what causes the database connection failure.

Because you cannot reproduce your problem, you can only guess the cause of the problem. If you still can't find where the problem is through the above two points, then modify your timer appropriately, and let the program trigger once every 5 minutes instead of 30s.


问:
'Back' browser action in Ruby on Rails
Can the 'Back' browser functionality be invoked from a Rails 'Back' link? </p>

答:
In Rails 3 and earlier:

```<code>link_to_function "Back", "history.back()"
</code>```

In Rails 4, this method has been removed. See Andreas's comment.

OwnerDisplayName: alamodey

ContentLicense: CC BY-SA 2.5

Title: 'Back' browser action in Ruby on Rails

Body:
In Rails 3 and earlier:

link_to_function "Back", "history.back()"

In Rails 4, this method has been removed. See Andreas's comment.

OwnerDisplayName: Ben Alpert


问:
MySQL improve performance large tables
I am new to MySQl. Please excuse some wrong terminologies. I have a question about indexing and splitting tables in MySQL. I am working on a web server. There are 3 very large tables that are frequently queried. The tables and their fields are as follows:

Alignment: ali_id, chain1_id, chain2_id .....; Seed: seed_id, ali_id, .....; Fragment: seed_id .......

Seed contains one or more records for a given Alignment. Fragment contains one or more records for Seed.

The size of the tables is Alignment - 8.3GB, Seed - 26GB and Fragment - 127GB

These tables have very large indexes: Alignment has index for chain1_id, chain2_id, ali_id, (chain1_id and chain2_id) and (chain2_id and chain1_id). As a result size of index file itself is 27G which is roughly 3 time size of the Alignment table.

Is this appropriate?

Also since the table size is becoming very large, the server keeps on crashing. Is it a good idea to split up the tables into smaller ones. I am confused because I am not sure if multiple select statements will also slow down the server.

Thank you.

Regards,
Amit.

Tables were already created by someone else.I guess they were as follows:

```<code>create Table Alignment (
 ali_id int(11) PRIMARY KEY,
 chain_id1 int(11),
 chain_id2 int(11),
 param_id smallint(6),
 date datetime);

create Table Seed(
 seed_id int(11),
 Ne smallint(5),
 rmsd float,
 ali_id int(11),
 identics smallint(6));

* Seed has 5 more fields, all are smallint(6)

create table Fragment (
 start1 smallint(6),
 start2 smallint(6),
 len smallint(6),
 seed_id bigint(20));
</code>```

There query that takes long time is:

```<code>select a.chain_id2, s.Ne, s.rmsd, s.zN, s.ali_id, s.identics, s.positives, s.nFrg, s.cMatch, s.cont1, s.cont2, s.bMatch, s.back1, s.back2, s.seed_id

from Alignment AS a, Chain AS c, Seed AS s

WHERE (a.chain_id1 = c.chain_id) and a.ali_id = s.ali_id and c.pdb_chain = "$pdb_here" and s.zN > $ZLIM;
</code>```

The number of hits may vary from 100-2000

It is run on an apache server on a Linux machine witn Intel Quad Core @2.5 GHz with 4 GB RAM.

答:
I might have assumed that your db has not been optimized.   In MySQL, you can rebuild indexes, you can optimize table, you can execute a few of the table maintenance statements [1]

[1]http://dev.mysql.com/doc/refman/5.1/en/table-maintenance-sql.html

The next step, seeing that your data might be exponentially growing.

Take a look at http://www.mysql.com/products/cluster/, see if you can prep yourself for that too.

Title: MySQL improve performance large tables

Body:
I am new to MySQl. Please excuse some wrong terminologies. I have a question about indexing and splitting tables in MySQL. I am working on a web server. There are 3 very large tables that are frequently queried. The tables and their fields are as follows:

Alignment: ali_id, chain1_id, chain2_id .....; Seed: seed_id, ali_id, .....; Fragment: seed_id .......

Seed contains one or more records for a given Alignment. Fragment contains one or more records for Seed.

The size of the tables is Alignment - 8.3GB, Seed - 26GB and Fragment - 127GB

These tables have very large indexes: Alignment has index for chain1_id, chain2_id, ali_id, (chain1_id and chain2_id) and (chain2_id and chain1_id). As a result size of index file itself is 27G which is roughly 3 time size of the Alignment table.

Is this appropriate?

Also since the table size is becoming very large, the server keeps on crashing. Is it a good idea to split up the tables into smaller ones. I am confused because I am not sure if multiple select statements will also slow down the server.

Thank you.

Regards,
Amit.

Tables were already created by someone else.I guess they were as follows:

create Table Alignment (
 ali_id int(11) PRIMARY KEY,
 chain_id1 int(11),
 chain_id2 int(11),
 param_id smallint(6),
 date datetime);

create Table Seed(
 seed_id int(11),
 Ne smallint(5),
 rmsd float,
 ali_id int(11),
 identics smallint(6));

* Seed has 5 more fields, all are smallint(6)

create table Fragment (
 start1 smallint(6),
 start2 smallint(6),
 len smallint(6),
 seed_id bigint(20));

There query that takes long time is:

select a.chain_id2, s.Ne, s.rmsd, s.zN, s.ali_id, s.identics, s.positives, s.nFrg, s.cMatch, s.cont1, s.cont2, s.bMatch, s.back1, s.back2, s.seed_id

from Alignment AS a, Chain AS c, Seed AS s

WHERE (a.chain_id1 = c.chain_id) and a.ali_id = s.ali_id and c.pdb_chain = "$pdb_here" and s.zN > $ZLIM;

The number of hits may vary from 100-2000

It is run on an apache server on a Linux machine witn Intel Quad Core @2.5 GHz with 4 GB RAM.


问:
how do I make an element not work as href in an entire href card

So I have this card that works as an entire link but inside that, I have an icon under a span tag and I don't want it to work as the card's link rather just act like an icon, Ik I can solve this if I don't make the entire card href but then I'd have to manually turn all the required elements present inside the card into href which I feel like isn't efficient and neat. So any suggestions on how do I go from here?

```<code>.card {
  width: 250px;
  height: 350;
  border-radius: 10px;
  box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
  background-color: white;
  margin-left: 30px;
  margin-right: 30px;
  margin-top: 30px;
  margin-bottom: 30px;
  cursor: pointer;
}

.top {
  display: flex;
  justify-content: space-between;

}

.year {
  padding-top: 5px;
  padding-left: 5px;
  font-family: Circular Std Book;

}

.span-bookmark {
  padding-left: 5px;
  cursor: pointer;

}

{% for m in mlist %}
    <div class="card">
        <a href="http://www.google.com/search?q={{m.Name}}" target="_blank">
            <div class="top">
                <div class="year">{{m.Year}}</div>
                <span class="span-bookmark"><i class="material-icons bookmark" id="bookmark-style">bookmark</i></span>
            </div>

            <div class="middle">
                <div class="img-container"><img src="{{ m.Image.url }}"></div>
            </div>

            <div class="bottom">
                <div class="title">{{m.Name}}</div>
                <div class="target_id">{{m.targetid}}</div>
            </div>
        </a>
    </div>
{% endfor %}
</code>```

答: Make sure you have a position set on both the card and the icon div. Then set a z-index for the icon that is higher than the card in your css. Then if you assign the icon to be clickable, it won't click the card link when you click the icon. You can use z-index to arrange all the layers in your card. </p>

Body:
So I have this card that works as an entire link but inside that, I have an icon under a span tag and I don't want it to work as the card's link rather just act like an icon, Ik I can solve this if I don't make the entire card href but then I'd have to manually turn all the required elements present inside the card into href which I feel like isn't efficient and neat. So any suggestions on how do I go from here?

.card {
  width: 250px;
  height: 350;
  border-radius: 10px;
  box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
  background-color: white;
  margin-left: 30px;
  margin-right: 30px;
  margin-top: 30px;
  margin-bottom: 30px;
  cursor: pointer;
}

.top {
  display: flex;
  justify-content: space-between;

}

.year {
  padding-top: 5px;
  padding-left: 5px;
  font-family: Circular Std Book;

}

.span-bookmark {
  padding-left: 5px;
  cursor: pointer;

}

{% for m in mlist %}

{{m.Year}}

                bookmark

{{m.Name}}

{{m.targetid}}

{% endfor %}


问:
Using IsPost in asp.net core razor page to display text after form submission
I'm trying to use the IsPost method in my asp.net core web page, but it says it does not exist in the current context. Since I'm not using MVC, (other than the fact that I have a models folder), is it possible for me to use IsPost in my razor page? Basically I am trying to display confirmation text on the same page after the user hits the submit button, so if anyone has a better way of doing this, please suggest so. Thanks

FreeConsultation.cshtml

@page
@model GuptaAccounting.Pages.FreeConsultationModel
@{
    ViewData["Title"] = "FreeConsultation";
}

Get a FREE Consultation

    @if (IsPost)
    {

Consultation requested. I will get back to you as soon as possible

    }
    else
    {
        <form method="post">

                    <input type="submit" value="Submit" onclick="return Validate()"  class="btn btn-primary form-control" />

        </form>
    }```
</div>
</div>
</p>

<p><strong>FreeConsultation.cshtml.cs</strong></p>

```public class FreeConsultationModel : PageModel
{
    private readonly ApplicationDbContext _db;

    public FreeConsultationModel(ApplicationDbContext db)
    {
        _db = db;
    }

    [BindProperty]
    public Client Client { get; set; }

    public void OnGet()
    {

    }

    public async Task<IActionResult> OnPost()
    {
        if (ModelState.IsValid)
        {
            Client.IsConsultationClient = true;
            await _db.Client.AddAsync(Client);
            await _db.SaveChangesAsync();

            return RedirectToPage("Index");
        }
        else
        {
            return Page();
        }
    }
}
```

答: I don't think razor pages have an IsPost method but you could add an IsPost property to your FreeConsultationModel and set it to true in the OnPost() method.</p>

Body:
I'm trying to use the IsPost method in my asp.net core web page, but it says it does not exist in the current context. Since I'm not using MVC, (other than the fact that I have a models folder), is it possible for me to use IsPost in my razor page? Basically I am trying to display confirmation text on the same page after the user hits the submit button, so if anyone has a better way of doing this, please suggest so. Thanks

FreeConsultation.cshtml

@page
@model GuptaAccounting.Pages.FreeConsultationModel
@{
    ViewData["Title"] = "FreeConsultation";
}

Get a FREE Consultation

    @if (IsPost)
    {

Consultation requested. I will get back to you as soon as possible

    }
    else
    {
        <form method="post">

                    <input type="submit" value="Submit" onclick="return Validate()"  class="btn btn-primary form-control" />

        </form>
    }

FreeConsultation.cshtml.cs

public class FreeConsultationModel : PageModel
{
    private readonly ApplicationDbContext _db;

    public FreeConsultationModel(ApplicationDbContext db)
    {
        _db = db;
    }

    [BindProperty]
    public Client Client { get; set; }

    public void OnGet()
    {

    }

    public async Task<IActionResult> OnPost()
    {
        if (ModelState.IsValid)
        {
            Client.IsConsultationClient = true;
            await _db.Client.AddAsync(Client);
            await _db.SaveChangesAsync();

            return RedirectToPage("Index");
        }
        else
        {
            return Page();
        }
    }
}


问:
Deploying NestJS to Azure DevOps: Error: Cannot find module '../commands'
I have a very basic "Hello World" NestJS app that I'm trying to get deployed to an Azure Web App instance in Azure DevOps.

I have set up a build pipeline using a YAML file which outputs a build artifact with the dist and node_modules directories.

Then, in my release pipeline, I have a continuous deployment set up to download that artifact and deploy it. The release pipeline consists of a single step to Deploy Azure App Service. Furthermore, after this step, I entered some Post-Deployment Actions which are npm install, npm update, and npm run start:prod to get the NestJS server started.

However, when running the pipeline, that step takes an inordinate amount of time eventually erroring with:

When I visit the web app instance that I have set up (https://<project-name>.azurewebsites.net/), I see:

So, I click on "Diagnostic Resources" to try to figure out why my release is failing and eventually discover this error:

```<code>2020-05-29T20:01:30.864090341Z   _____
2020-05-29T20:01:30.864143041Z   /  _  \ __________ _________   ____
2020-05-29T20:01:30.864149941Z  /  /_\  \___   /  |  \_  __ \_/ __ \
2020-05-29T20:01:30.864153741Z /    |    \/    /|  |  /|  | \/\  ___/
2020-05-29T20:01:30.864157341Z \____|__  /_____ \____/ |__|    \___  >
2020-05-29T20:01:30.864161141Z         \/      \/                  \/
2020-05-29T20:01:30.864164541Z A P P   S E R V I C E   O N   L I N U X
2020-05-29T20:01:30.864167941Z
2020-05-29T20:01:30.864171141Z Documentation: http://aka.ms/webapp-linux
2020-05-29T20:01:30.864174441Z NodeJS quickstart: https://aka.ms/node-qs
2020-05-29T20:01:30.864177741Z NodeJS Version : v12.13.0
2020-05-29T20:01:30.864181041Z Note: Any data outside '/home' is not persisted
2020-05-29T20:01:30.864184441Z
2020-05-29T20:01:30.951441760Z Oryx Version: 0.2.20191105.2, Commit: 67e159d71419415435cb5d10c05a0f0758ee8809, ReleaseTagName: 20191105.2
2020-05-29T20:01:30.951840160Z Cound not find build manifest file at '/home/site/wwwroot/oryx-manifest.toml'
2020-05-29T20:01:30.951915661Z Could not find operation ID in manifest. Generating an operation id...
2020-05-29T20:01:30.952061661Z Build Operation ID: dfd18989-3b7b-4e2e-a64e-cf7310361e99
2020-05-29T20:01:32.750738663Z Writing output script to '/opt/startup/startup.sh'
2020-05-29T20:01:33.355033998Z Running #!/bin/sh
2020-05-29T20:01:33.359017599Z
2020-05-29T20:01:33.359033399Z # Enter the source directory to make sure the script runs where the user expects
2020-05-29T20:01:33.359644199Z cd "/home/site/wwwroot"
2020-05-29T20:01:33.359658399Z
2020-05-29T20:01:33.359664799Z export NODE_PATH=$(npm root --quiet -g):$NODE_PATH
2020-05-29T20:01:33.360538899Z if [ -z "$PORT" ]; then
2020-05-29T20:01:33.360552699Z         export PORT=8080
2020-05-29T20:01:33.360557899Z fi
2020-05-29T20:01:33.360561499Z
2020-05-29T20:01:33.361582699Z npm start
2020-05-29T20:01:35.698639821Z
2020-05-29T20:01:35.698668521Z > <project-name>@0.0.1 start /home/site/wwwroot
2020-05-29T20:01:35.698675121Z > nest start
2020-05-29T20:01:35.698679221Z
2020-05-29T20:01:35.930729770Z internal/modules/cjs/loader.js:797
2020-05-29T20:01:35.930766970Z     throw err;
2020-05-29T20:01:35.930772870Z     ^
2020-05-29T20:01:35.930776770Z
2020-05-29T20:01:35.930780670Z Error: Cannot find module '../commands'
2020-05-29T20:01:35.930784670Z Require stack:
2020-05-29T20:01:35.930788470Z - /home/site/wwwroot/node_modules/.bin/nest
2020-05-29T20:01:35.930792370Z     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15)
2020-05-29T20:01:35.930803370Z     at Function.Module._load (internal/modules/cjs/loader.js:687:27)
2020-05-29T20:01:35.930807770Z     at Module.require (internal/modules/cjs/loader.js:849:19)
2020-05-29T20:01:35.930811570Z     at require (internal/modules/cjs/helpers.js:74:18)
2020-05-29T20:01:35.930815370Z     at Object. (/home/site/wwwroot/node_modules/.bin/nest:5:20)
2020-05-29T20:01:35.930819770Z     at Module._compile (internal/modules/cjs/loader.js:956:30)
2020-05-29T20:01:35.930823570Z     at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
2020-05-29T20:01:35.930827470Z     at Module.load (internal/modules/cjs/loader.js:812:32)
2020-05-29T20:01:35.930831270Z     at Function.Module._load (internal/modules/cjs/loader.js:724:14)
2020-05-29T20:01:35.930835070Z     at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10) {
2020-05-29T20:01:35.930838970Z   code: 'MODULE_NOT_FOUND',
2020-05-29T20:01:35.930842770Z   requireStack: [ '/home/site/wwwroot/node_modules/.bin/nest' ]
2020-05-29T20:01:35.930846670Z }
2020-05-29T20:01:35.970252977Z npm ERR! code ELIFECYCLE
2020-05-29T20:01:35.979824678Z npm ERR! errno 1
2020-05-29T20:01:35.981324478Z npm ERR! <project-name>@0.0.1 start: `nest start`
2020-05-29T20:01:35.982002178Z npm ERR! Exit status 1
2020-05-29T20:01:35.982641778Z npm ERR!
2020-05-29T20:01:35.991823280Z npm ERR! Failed at the <project-name>@0.0.1 start script.
2020-05-29T20:01:35.991838780Z npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-05-29T20:01:36.118651500Z
2020-05-29T20:01:36.119439400Z npm ERR! A complete log of this run can be found in:
2020-05-29T20:01:36.128548002Z npm ERR!     /root/.npm/_logs/2020-05-29T20_01_35_990Z-debug.log
</code>```

At this point I can't figure out what is wrong. Any help would be greatly appreciated.

答: More than likely, you're using npm start which is mapped to nest start by default. The problem you'll run into with this is that @nestjs/cli (where the nest command comes from) is a part of devDependencies by default, so unless you've moved it, Azure is probably scrubbing the devDeps and keeping on prod deps. You should be using node dist/main to start your app instead to remove this problem without bloating your dependencies. Otherwise, adding @nestjs/cli to dependencies should fix it.

Body:
I have a very basic "Hello World" NestJS app that I'm trying to get deployed to an Azure Web App instance in Azure DevOps.

I have set up a build pipeline using a YAML file which outputs a build artifact with the dist and node_modules directories.

Then, in my release pipeline, I have a continuous deployment set up to download that artifact and deploy it. The release pipeline consists of a single step to Deploy Azure App Service. Furthermore, after this step, I entered some Post-Deployment Actions which are npm install, npm update, and npm run start:prod to get the NestJS server started.

However, when running the pipeline, that step takes an inordinate amount of time eventually erroring with:

When I visit the web app instance that I have set up (https://<project-name>.azurewebsites.net/), I see:

So, I click on "Diagnostic Resources" to try to figure out why my release is failing and eventually discover this error:

2020-05-29T20:01:30.864090341Z   _____
2020-05-29T20:01:30.864143041Z   /  _  \ __________ _________   ____
2020-05-29T20:01:30.864149941Z  /  /_\  \___   /  |  \_  __ \_/ __ \
2020-05-29T20:01:30.864153741Z /    |    \/    /|  |  /|  | \/\  ___/
2020-05-29T20:01:30.864157341Z \____|__  /_____ \____/ |__|    \___  >
2020-05-29T20:01:30.864161141Z         \/      \/                  \/
2020-05-29T20:01:30.864164541Z A P P   S E R V I C E   O N   L I N U X
2020-05-29T20:01:30.864167941Z
2020-05-29T20:01:30.864171141Z Documentation: http://aka.ms/webapp-linux
2020-05-29T20:01:30.864174441Z NodeJS quickstart: https://aka.ms/node-qs
2020-05-29T20:01:30.864177741Z NodeJS Version : v12.13.0
2020-05-29T20:01:30.864181041Z Note: Any data outside '/home' is not persisted
2020-05-29T20:01:30.864184441Z
2020-05-29T20:01:30.951441760Z Oryx Version: 0.2.20191105.2, Commit: 67e159d71419415435cb5d10c05a0f0758ee8809, ReleaseTagName: 20191105.2
2020-05-29T20:01:30.951840160Z Cound not find build manifest file at '/home/site/wwwroot/oryx-manifest.toml'
2020-05-29T20:01:30.951915661Z Could not find operation ID in manifest. Generating an operation id...
2020-05-29T20:01:30.952061661Z Build Operation ID: dfd18989-3b7b-4e2e-a64e-cf7310361e99
2020-05-29T20:01:32.750738663Z Writing output script to '/opt/startup/startup.sh'
2020-05-29T20:01:33.355033998Z Running #!/bin/sh
2020-05-29T20:01:33.359017599Z
2020-05-29T20:01:33.359033399Z # Enter the source directory to make sure the script runs where the user expects
2020-05-29T20:01:33.359644199Z cd "/home/site/wwwroot"
2020-05-29T20:01:33.359658399Z
2020-05-29T20:01:33.359664799Z export NODE_PATH=$(npm root --quiet -g):$NODE_PATH
2020-05-29T20:01:33.360538899Z if [ -z "$PORT" ]; then
2020-05-29T20:01:33.360552699Z         export PORT=8080
2020-05-29T20:01:33.360557899Z fi
2020-05-29T20:01:33.360561499Z
2020-05-29T20:01:33.361582699Z npm start
2020-05-29T20:01:35.698639821Z
2020-05-29T20:01:35.698668521Z > <project-name>@0.0.1 start /home/site/wwwroot
2020-05-29T20:01:35.698675121Z > nest start
2020-05-29T20:01:35.698679221Z
2020-05-29T20:01:35.930729770Z internal/modules/cjs/loader.js:797
2020-05-29T20:01:35.930766970Z     throw err;
2020-05-29T20:01:35.930772870Z     ^
2020-05-29T20:01:35.930776770Z
2020-05-29T20:01:35.930780670Z Error: Cannot find module '../commands'
2020-05-29T20:01:35.930784670Z Require stack:
2020-05-29T20:01:35.930788470Z - /home/site/wwwroot/node_modules/.bin/nest
2020-05-29T20:01:35.930792370Z     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15)
2020-05-29T20:01:35.930803370Z     at Function.Module._load (internal/modules/cjs/loader.js:687:27)
2020-05-29T20:01:35.930807770Z     at Module.require (internal/modules/cjs/loader.js:849:19)
2020-05-29T20:01:35.930811570Z     at require (internal/modules/cjs/helpers.js:74:18)
2020-05-29T20:01:35.930815370Z     at Object. (/home/site/wwwroot/node_modules/.bin/nest:5:20)
2020-05-29T20:01:35.930819770Z     at Module._compile (internal/modules/cjs/loader.js:956:30)
2020-05-29T20:01:35.930823570Z     at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
2020-05-29T20:01:35.930827470Z     at Module.load (internal/modules/cjs/loader.js:812:32)
2020-05-29T20:01:35.930831270Z     at Function.Module._load (internal/modules/cjs/loader.js:724:14)
2020-05-29T20:01:35.930835070Z     at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10) {
2020-05-29T20:01:35.930838970Z   code: 'MODULE_NOT_FOUND',
2020-05-29T20:01:35.930842770Z   requireStack: [ '/home/site/wwwroot/node_modules/.bin/nest' ]
2020-05-29T20:01:35.930846670Z }
2020-05-29T20:01:35.970252977Z npm ERR! code ELIFECYCLE
2020-05-29T20:01:35.979824678Z npm ERR! errno 1
2020-05-29T20:01:35.981324478Z npm ERR! <project-name>@0.0.1 start: `nest start`
2020-05-29T20:01:35.982002178Z npm ERR! Exit status 1
2020-05-29T20:01:35.982641778Z npm ERR!
2020-05-29T20:01:35.991823280Z npm ERR! Failed at the <project-name>@0.0.1 start script.
2020-05-29T20:01:35.991838780Z npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-05-29T20:01:36.118651500Z
2020-05-29T20:01:36.119439400Z npm ERR! A complete log of this run can be found in:
2020-05-29T20:01:36.128548002Z npm ERR!     /root/.npm/_logs/2020-05-29T20_01_35_990Z-debug.log

At this point I can't figure out what is wrong. Any help would be greatly appreciated.


答:
Don't worry about the size of the tables. It should not cause any problems if you make sure the indexes are properly set up. Additionally, you want to make sure that any information that is redundant is stored into a separate database. You can easily retrieve it through a JOIN query.

If your server keeps on crashing, it is either not capable enough to handle the load (with databases that big, I assume that you also have quite a visitor's load) or you might have some hardware issues (like a faulty HDD, for example). Also, your queries might need some optimizing. Slow queries can cause your table to be locked for extended amounts of time, putting new queries on hold....and well, any following scenario is not good.

Title: MySQL improve performance large tables


问:
Azure Event Hub : Create Logger - 400 Invalid Hostname
I am trying to create a proof of concept with Azure APIM and am stuck at a 400 invalid hostname error.

I have tried following this example

https://learn.microsoft.com/en-gb/azure/api-management/api-management-howto-log-event-hubs

which leads me to this page

https://learn.microsoft.com/en-us/rest/api/apimanagement/2019-12-01/logger/createorupdate

I have in postman the put command with the following url, edited out the personal details

https://management.azure.com/subscriptions/xxxxx-yyyy-zzz-a4ed-b0b5ddddddd/resourceGroups/xx-Trial/providers/Microsoft.ApiManagement/service/xxx-API-Management-Services/loggers/loggerId?api-version=2019-12-01

This is being sent as a PUT command

This is the body that is also being sent

```<code>{
 "type": "AzureEventHub",
 "description": "xx Poc description",
 "credentials": {
   "name": "apim",
   "connectionString": "Endpoint=sb://xx-poc.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=yyyyyyK/ixxxxxxxxxxxxxxc="
 }
}
</code>```

The response that comes back is

```<code><h2>Bad Request - Invalid Hostname</h2>
<hr>
<p>HTTP Error 400. The request hostname is invalid.</p>
</code>```

I would be grateful if anyone can help me progress this forward as I cannot see what I have missed.

Thanks

答:
I believe there'are something wrong with the request body.

```<code>{
 "type": "AzureEventHub",
 "description": "xx Poc description",
 "credentials": {
   "name": "apim",
   "connectionString": "Endpoint=sb://xx-poc.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=yyyyyyK/ixxxxxxxxxxxxxxc="
 }
}
</code>```

Please check the following settings in your request body:

For name, please make sure it's the Event hub instance name, not the Eventhub namespace name. And you can refer to this doc for more details about them.

For connectionString, please make sure it's the Eventhub namespace connectiong string(do not use the Eventhub instance level connection string). For more details, please refer to this doc.

At the end, please also check if the eventhub instance is disabled or not.

Body:
I am trying to create a proof of concept with Azure APIM and am stuck at a 400 invalid hostname error.

I have tried following this example

https://learn.microsoft.com/en-gb/azure/api-management/api-management-howto-log-event-hubs

which leads me to this page

https://learn.microsoft.com/en-us/rest/api/apimanagement/2019-12-01/logger/createorupdate

I have in postman the put command with the following url, edited out the personal details

https://management.azure.com/subscriptions/xxxxx-yyyy-zzz-a4ed-b0b5ddddddd/resourceGroups/xx-Trial/providers/Microsoft.ApiManagement/service/xxx-API-Management-Services/loggers/loggerId?api-version=2019-12-01

This is being sent as a PUT command

This is the body that is also being sent

{
 "type": "AzureEventHub",
 "description": "xx Poc description",
 "credentials": {
   "name": "apim",
   "connectionString": "Endpoint=sb://xx-poc.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=yyyyyyK/ixxxxxxxxxxxxxxc="
 }
}

The response that comes back is

Bad Request - Invalid Hostname

HTTP Error 400. The request hostname is invalid.

I would be grateful if anyone can help me progress this forward as I cannot see what I have missed.

Thanks

Body:
I believe there'are something wrong with the request body.

{
 "type": "AzureEventHub",
 "description": "xx Poc description",
 "credentials": {
   "name": "apim",
   "connectionString": "Endpoint=sb://xx-poc.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=yyyyyyK/ixxxxxxxxxxxxxxc="
 }
}

Please check the following settings in your request body:

For name, please make sure it's the Event hub instance name, not the Eventhub namespace name. And you can refer to this doc for more details about them.

For connectionString, please make sure it's the Eventhub namespace connectiong string(do not use the Eventhub instance level connection string). For more details, please refer to this doc.

At the end, please also check if the eventhub instance is disabled or not.


问:
Entity Framework includes the unexpected child if the child is ready called in another statement
I am using ASP.NET Core 3.1.2, Pomelo.EntityFramework 3.1.1 to link with a MySQL database. Here is a minimum example to demonstrate my problem.

Two model classes are defined. The model Field includes multiple zones:

public class Field
{
    [Key]
    public int Id { get; set; }
    public virtual ICollection<Zone> Zones { get; set; }

    public Field()
    {
        Zones = new HashSet<Zone>();
    }
}

public class Zone
{
    [Key]
    public int Id { get; set; }
    public int FieldId { get; set; }
    public virtual Field Field { get; set; }
}
```

<p>Then an API is created to get the data for a zone. </p>

<pre class="lang-cs prettyprint-override"><code>[Route("api/field/{field}/zone/{id}")]
[HttpGet]
public async Task<ActionResult<List<Field>>> GetZone(
    [FromRoute] int field,
    [FromRoute] int id)
{
    Zone Zone = await _context.Zone
                              .Where(m => m.FieldId == field && m.Id == id)
                              .SingleOrDefaultAsync();
    return Ok(_context.Field);
}
</code>```

In the demo code, I expect to return the list of Field without Zone. However, the results include the contents for Zone equals id if calling /api/field/16/zone/15.

```<code>[
    {
        "zone": [],
        "id": 7
    },
    {
        "zone": [
            {
                "id": 15
            }
        ],
        "id": 16
    }
]
</code>```

It seems the contents are kept if the child is called in another place. I would not want to return child. Any suggestions?

答:
You can add   [JsonIgnore] and [IgnoreDataMember] attributes in the Zones property in Field class.

```<code> public class Field
        {
            [Key]
            public int Id { get; set; }
            [JsonIgnore]
            [IgnoreDataMember]
            public virtual ICollection<Zone> Zones { get; set; }

            public Field()
            {
                Zones = new HashSet<Zone>();
            }
        }
</code>```

More details, please refer to this.

Body:
I am using ASP.NET Core 3.1.2, Pomelo.EntityFramework 3.1.1 to link with a MySQL database. Here is a minimum example to demonstrate my problem.

Two model classes are defined. The model Field includes multiple zones:

public class Field
{
    [Key]
    public int Id { get; set; }
    public virtual ICollection<Zone> Zones { get; set; }

    public Field()
    {
        Zones = new HashSet<Zone>();
    }
}

public class Zone
{
    [Key]
    public int Id { get; set; }
    public int FieldId { get; set; }
    public virtual Field Field { get; set; }
}

Then an API is created to get the data for a zone.

[Route("api/field/{field}/zone/{id}")]
[HttpGet]
public async Task<ActionResult<List<Field>>> GetZone(
    [FromRoute] int field,
    [FromRoute] int id)
{
    Zone Zone = await _context.Zone
                              .Where(m => m.FieldId == field && m.Id == id)
                              .SingleOrDefaultAsync();
    return Ok(_context.Field);
}

In the demo code, I expect to return the list of Field without Zone. However, the results include the contents for Zone equals id if calling /api/field/16/zone/15.

[
    {
        "zone": [],
        "id": 7
    },
    {
        "zone": [
            {
                "id": 15
            }
        ],
        "id": 16
    }
]

It seems the contents are kept if the child is called in another place. I would not want to return child. Any suggestions?

Body:
You can add   [JsonIgnore] and [IgnoreDataMember] attributes in the Zones property in Field class.

 public class Field
        {
            [Key]
            public int Id { get; set; }
            [JsonIgnore]
            [IgnoreDataMember]
            public virtual ICollection<Zone> Zones { get; set; }

            public Field()
            {
                Zones = new HashSet<Zone>();
            }
        }

More details, please refer to this.


问:
How can I know the size of a file using a recursive program?
I have to make a program that measures the size of a given directory by using recursivity. I need to use the OS module. When I used

```<code>os.path.getsize()
</code>```

The response was 0 bytes, which makes no sense.

答:
I get your question, the same problem i also got, you can visit here for ans : https://github.com/ASHWIN990/sizeof/blob/master/sizeof

I have made a Pythton script which find the size of file and directories recurcively

Body:
I have to make a program that measures the size of a given directory by using recursivity. I need to use the OS module. When I used

os.path.getsize()

The response was 0 bytes, which makes no sense.


问:
horizontal scrollbar on top and bottom of table
I've a very large table on my page. So I decided to put a horizontal scrollbar on the bottom of the table. But I would like this scrollbar to be also on top on the table.

What I have in the template is this:

```<code><div style="overflow:auto; width:100%; height:130%">
<table id="data" style="width:100%">...</table>
</div>
</code>```

Is this possible to do in HTML and CSS only?

答:
Here is an example for VueJS

index.page

```<code><template>
  <div>
    <div ref="topScroll" class="top-scroll" @scroll.passive="handleScroll">
      <div
        :style="{
          width: `${contentWidth}px`,
          height: '12px'
        }"
      />
    </div>
    <div ref="content" class="content" @scroll.passive="handleScroll">
      <div
        :style="{
          width: `${contentWidth}px`
        }"
      >
        Lorem ipsum dolor sit amet, ipsum dictum vulputate molestie id magna,
        nunc laoreet maecenas, molestie ipsum donec lectus ut et sit, aut ut ut
        viverra vivamus mollis in, integer diam purus penatibus. Augue consequat
        quis phasellus non, congue tristique ac arcu cras ligula congue, elit
        hendrerit lectus faucibus arcu ligula a, id hendrerit dolor nec nec
        placerat. Vel ornare tincidunt tincidunt, erat amet mollis quisque, odio
        cursus gravida libero aliquam duis, dolor sed nulla dignissim praesent
        erat, voluptatem pede aliquam. Ut et tellus mi fermentum varius, feugiat
        nullam nunc ultrices, ullamcorper pede, nunc vestibulum, scelerisque
        nunc lectus integer. Nec id scelerisque vestibulum, elit sit, cursus
        neque varius. Fusce in, nunc donec, volutpat mauris wisi sem, non
        sapien. Pellentesque nisl, lectus eros hendrerit dui. In metus aptent
        consectetuer, sociosqu massa mus fermentum mauris dis, donec erat nunc
        orci.
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      contentWidth: 1000
    }
  },
  methods: {
    handleScroll(event) {
      if (event.target._prevClass === 'content') {
        this.$refs.topScroll.scrollLeft = this.$refs.content.scrollLeft
      } else {
        this.$refs.content.scrollLeft = this.$refs.topScroll.scrollLeft
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.top-scroll,
.content {
  overflow: auto;
  max-width: 100%;
}
.top-scroll {
  margin-top: 50px;
}
</style>

</code>```

TAKE NOTE on the height: 12px.. I made it 12px so it will be noticed on Mac Users as well. But w/ windows, 0.1px is good enough

Body:
I've a very large table on my page. So I decided to put a horizontal scrollbar on the bottom of the table. But I would like this scrollbar to be also on top on the table.

What I have in the template is this:

...

Is this possible to do in HTML and CSS only?

Body:
Here is an example for VueJS

index.page

<template>
  <div>
    <div ref="topScroll" class="top-scroll" @scroll.passive="handleScroll">
      <div
        :style="{
          width: `${contentWidth}px`,
          height: '12px'
        }"
      />
    </div>
    <div ref="content" class="content" @scroll.passive="handleScroll">
      <div
        :style="{
          width: `${contentWidth}px`
        }"
      >
        Lorem ipsum dolor sit amet, ipsum dictum vulputate molestie id magna,
        nunc laoreet maecenas, molestie ipsum donec lectus ut et sit, aut ut ut
        viverra vivamus mollis in, integer diam purus penatibus. Augue consequat
        quis phasellus non, congue tristique ac arcu cras ligula congue, elit
        hendrerit lectus faucibus arcu ligula a, id hendrerit dolor nec nec
        placerat. Vel ornare tincidunt tincidunt, erat amet mollis quisque, odio
        cursus gravida libero aliquam duis, dolor sed nulla dignissim praesent
        erat, voluptatem pede aliquam. Ut et tellus mi fermentum varius, feugiat
        nullam nunc ultrices, ullamcorper pede, nunc vestibulum, scelerisque
        nunc lectus integer. Nec id scelerisque vestibulum, elit sit, cursus
        neque varius. Fusce in, nunc donec, volutpat mauris wisi sem, non
        sapien. Pellentesque nisl, lectus eros hendrerit dui. In metus aptent
        consectetuer, sociosqu massa mus fermentum mauris dis, donec erat nunc
        orci.
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      contentWidth: 1000
    }
  },
  methods: {
    handleScroll(event) {
      if (event.target._prevClass === 'content') {
        this.$refs.topScroll.scrollLeft = this.$refs.content.scrollLeft
      } else {
        this.$refs.content.scrollLeft = this.$refs.topScroll.scrollLeft
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.top-scroll,
.content {
  overflow: auto;
  max-width: 100%;
}
.top-scroll {
  margin-top: 50px;
}
</style>

TAKE NOTE on the height: 12px.. I made it 12px so it will be noticed on Mac Users as well. But w/ windows, 0.1px is good enough


问:
how to identify when a dynamic element is ready?
I need to identify when a dynamic element is ready or when $('root').append(""); is loaded, so that I can load another element within child element.

Currently I have:

$('root').after("");
setTimeout(function(){
  $('#child').append("
brah
");
}, 1000);
```

While the above solution does work, 1 second is too long to wait for each element. And if I set the timer to 0, it become inconsistent.

Is there any better way to identify when a DOM is fully loaded?

答:
Just pass a callback to .append, and load your other element.

$('#root').append("", () => {
  // Your code here!
});
```

Body:
I need to identify when a dynamic element is ready or when $('root').append(""); is loaded, so that I can load another element within child element.

Currently I have:

$('root').after("");
setTimeout(function(){
  $('#child').append("
brah
");
}, 1000);

While the above solution does work, 1 second is too long to wait for each element. And if I set the timer to 0, it become inconsistent.

Is there any better way to identify when a DOM is fully loaded?

Body:
Just pass a callback to .append, and load your other element.

$('#root').append("<span id=\"child\"></span>", () => {
  // Your code here!
});


问:
Selenium click() method on angular.js site
I am scraping an angular.js site. My initial link has a search button. I find by xpath and click with no issues. After I click search, I want to be able to click each of the athletes in the table to go to their info pages, but I am not having success with the click method. The links are attached to their names. </p>

```<code>from selenium import webdriver
from selenium.common.exceptions import TimeoutException

TIMEOUT = 5

driver = webdriver.Firefox()
driver.set_page_load_timeout(TIMEOUT)
url = 'https://n.rivals.com/search#?formValues=%7B%22sport%22:%22Football%22,%22recruit_year%22:2021,%22offer_and_visit_type%22:%5B%22Offer%22%5D,%22prospect_profiles.prospect_colleges.offer%22:true,%22page_number%22:1,%22page_size%22:50%7D'

try:
    driver.get(url)
except TimeoutException:
    pass

search_button = driver.find_element_by_xpath('//*[@id="articles"]/div/div[2]/div/div/div[1]/form/div[2]/div[5]/button')
search_button.click();
#below is where I tried, but could not get to click
first_athlete = driver.find_element_by_xpath('//*[@id="content_"]/td[1]/div[2]/a')
first_athlete.click();
</code>```

答:
Works if you remove the last /a in the xpath:

```<code>first_athlete = driver.find_element_by_xpath('//*[@id="content_"]/td[1]/div[2]')
first_athlete.click()
</code>```

Body:
I am scraping an angular.js site. My initial link has a search button. I find by xpath and click with no issues. After I click search, I want to be able to click each of the athletes in the table to go to their info pages, but I am not having success with the click method. The links are attached to their names.

from selenium import webdriver
from selenium.common.exceptions import TimeoutException

TIMEOUT = 5

driver = webdriver.Firefox()
driver.set_page_load_timeout(TIMEOUT)
url = 'https://n.rivals.com/search#?formValues=%7B%22sport%22:%22Football%22,%22recruit_year%22:2021,%22offer_and_visit_type%22:%5B%22Offer%22%5D,%22prospect_profiles.prospect_colleges.offer%22:true,%22page_number%22:1,%22page_size%22:50%7D'

try:
    driver.get(url)
except TimeoutException:
    pass

search_button = driver.find_element_by_xpath('//*[@id="articles"]/div/div[2]/div/div/div[1]/form/div[2]/div[5]/button')
search_button.click();
#below is where I tried, but could not get to click
first_athlete = driver.find_element_by_xpath('//*[@id="content_"]/td[1]/div[2]/a')
first_athlete.click();

Body:
Works if you remove the last /a in the xpath:

first_athlete = driver.find_element_by_xpath('//*[@id="content_"]/td[1]/div[2]')
first_athlete.click()


问:
How to specify property of type Organization which accepts itemtype Service?
The google structured data testing tool doesn't recognize provider as an object of type Organization.
Here's the example:

```<code><body itemscope itemtype="https://schema.org/Organization">
  <div itemprop="provider" itemscope itemtype="https://schema.org/Service">
    <meta itemprop="serviceType" content="Front end" />
      <div class="row" itemprop="hasOfferCatalog" itemscope itemtype="https://schema.org/OfferCatalog">
        //The service itemlists' offered
      </div>
  </div>
</body>
</code>```

Is there any other way out to specify a service.

答:
provider is a property in Service which can be set to an Organization. What you have is the reverse of that.

You could swap things around:

```<code><body itemscope itemtype="https://schema.org/Service">
  <meta itemprop="serviceType" content="Front end" />
  <div itemprop="provider" itemscope itemtype="https://schema.org/Organization"></div>
  <div class="row" itemprop="hasOfferCatalog" itemscope itemtype="https://schema.org/OfferCatalog">
      //The service itemlistsoffered'
  </div>
</body>
</code>```

Body:
The google structured data testing tool doesn't recognize provider as an object of type Organization.
Here's the example:

    <meta itemprop="serviceType" content="Front end" />

        //The service itemlists' offered

Is there any other way out to specify a service.

Body:
provider is a property in Service which can be set to an Organization. What you have is the reverse of that.

You could swap things around:

<body itemscope itemtype="https://schema.org/Service">
  <meta itemprop="serviceType" content="Front end" />
  <div itemprop="provider" itemscope itemtype="https://schema.org/Organization"></div>
  <div class="row" itemprop="hasOfferCatalog" itemscope itemtype="https://schema.org/OfferCatalog">
      //The service itemlistsoffered'
  </div>
</body>


问:
Sorting and grouping a mutlidimensional array in php
I need some help with sorting a multidimensional array in php. I need the array to be grouped into months, and then sorted by month. Here's my original array:

```<code>Array
(
    [0] => Array
        (
            [IdEvent] => 5
            [EventName] => Copy of Opening snow weekend
            [Year] => 2011
            [Month] => 08
        )

    [1] => Array
        (
            [IdEvent] => 7
            [EventName] => Copy of Copy of Opening snow weekend
            [Year] => 2011
            [Month] => 07
        )

    [2] => Array
        (
            [IdEvent] => 1
            [EventName] => Opening snow weekend
            [Year] => 2011
            [Month] => 05
        )

    [3] => Array
        (
            [IdEvent] => 6
            [EventName] => Copy of Opening snow weekend
            [Year] => 2011
            [Month] => 05
        )

)
</code>```

And here's what I'm hoping to get:

```<code>Array
(

    [0] => Array (

        [0] => Array
            (
                [IdEvent] => 1
                [EventName] => Opening snow weekend
                [Year] => 2011
                [Month] => 05
            )

        [1] => Array
            (
                [IdEvent] => 6
                [EventName] => Copy of Opening snow weekend
                [Year] => 2011
                [Month] => 05
            )

    )

    [1] => Array (

        [0] => Array
            (
                [IdEvent] => 7
                [EventName] => Copy of Copy of Opening snow weekend
                [Year] => 2011
                [Month] => 07
            )

    )

    [2] => Array (

        [0] => Array
            (
                [IdEvent] => 5
                [EventName] => Copy of Opening snow weekend
                [Year] => 2011
                [Month] => 08
            )
    )

)
</code>```

答:
Maybe, just maybe something like this:

```<code>$sortedArray = array();

foreach ($unsortedArray as $key => $row) {
  $month[$key] = $row['month'];
  $year[$key]  = $row['year'];
}

$sortedArray =  array_multisort($year, SORT_ASC, $month, SORT_ASC, $unsortedArray);
</code>```

Totally untried, untested, exprerimental and from the top of my head.

You may need SORT_NUMERIC instead of SORT_ASC, I ain't sure.

Body:
I need some help with sorting a multidimensional array in php. I need the array to be grouped into months, and then sorted by month. Here's my original array:

Array
(
    [0] => Array
        (
            [IdEvent] => 5
            [EventName] => Copy of Opening snow weekend
            [Year] => 2011
            [Month] => 08
        )

    [1] => Array
        (
            [IdEvent] => 7
            [EventName] => Copy of Copy of Opening snow weekend
            [Year] => 2011
            [Month] => 07
        )

    [2] => Array
        (
            [IdEvent] => 1
            [EventName] => Opening snow weekend
            [Year] => 2011
            [Month] => 05
        )

    [3] => Array
        (
            [IdEvent] => 6
            [EventName] => Copy of Opening snow weekend
            [Year] => 2011
            [Month] => 05
        )

)

And here's what I'm hoping to get:

Array
(

    [0] => Array (

        [0] => Array
            (
                [IdEvent] => 1
                [EventName] => Opening snow weekend
                [Year] => 2011
                [Month] => 05
            )

        [1] => Array
            (
                [IdEvent] => 6
                [EventName] => Copy of Opening snow weekend
                [Year] => 2011
                [Month] => 05
            )

    )

    [1] => Array (

        [0] => Array
            (
                [IdEvent] => 7
                [EventName] => Copy of Copy of Opening snow weekend
                [Year] => 2011
                [Month] => 07
            )

    )

    [2] => Array (

        [0] => Array
            (
                [IdEvent] => 5
                [EventName] => Copy of Opening snow weekend
                [Year] => 2011
                [Month] => 08
            )
    )

)

Body:
Maybe, just maybe something like this:

$sortedArray = array();

foreach ($unsortedArray as $key => $row) {
  $month[$key] = $row['month'];
  $year[$key]  = $row['year'];
}

$sortedArray =  array_multisort($year, SORT_ASC, $month, SORT_ASC, $unsortedArray);

Totally untried, untested, exprerimental and from the top of my head.

You may need SORT_NUMERIC instead of SORT_ASC, I ain't sure.


问:
React Leaflet Offline - save button component
I need help to make this component work for the savebuttons.
The leaflet.offline package is this one:
https://github.com/allartk/leaflet.offline/blob/master/docs/api.md

React Typescript.

I am trying to extend react-leaflet as per documentation. With createLeafletElement and updateLeafletElement. I get no errors but nothing is adding to the map.

My Layer component is called OfflineTileLayer.

Here is the component:

```<code>import L from 'leaflet';
import 'leaflet.offline';
import { MapControl, withLeaflet, MapControlProps } from 'react-leaflet';

type LeafletElement = MapControl;
type Props = { url: string } & MapControlProps;
class OfflineSaveControls extends MapControl<LeafletElement, Props> {
  mapControl;
  constructor(props, context) {
    super(props);
  }

  createLeafletElement(props: Props): LeafletElement {
    return this.mapControl = new L.control.savetiles(props.layer, {
      zoomlevels: [13, 16], // optional zoomlevels to save, default current zoomlevel
      confirm(layer, succescallback) {
        if (window.confirm(`Save ${layer._tilesforSave.length}`)) {
          succescallback();
        }
      },
      confirmRemoval(layer, successCallback) {
        if (window.confirm('Remove all the tiles?')) {
          successCallback();
        }
      },
      saveText: '<i class="fa fa-download" aria-hidden="true" title="Save tiles"></i>',
      rmText: '<i class="fa fa-trash" aria-hidden="true"  title="Remove tiles"></i>',
    }).addTo(Map);
  }
  updateLeafletElement(fromProps: Props, toProps: Props) {
    super.updateLeafletElement(fromProps, toProps);
  }

}
export default withLeaflet<Props, OfflineSaveControls>(OfflineSaveControls);
</code>```

If this is just pure wrong, does anyone have another implementation of leaflet.offline in react?. Seems really hard to extend react-leaflet for some reason.

答:
These are the relevant bits from my extension for leaflet.offline, only it's not in Typescript. Hopefully it saves you (or the next person) a bit of time.

/**
 * OfflineTileLayer.jsx
 */

import L from "leaflet";
import { GridLayer, withLeaflet } from "react-leaflet";
import "leaflet.offline/src/TileLayerOffline";

class OfflineTileLayer extends GridLayer {
    constructor(props) {
        super(props);
        this.createTile = this.createTile.bind(this);
        this.setDataUrl = this.setDataUrl.bind(this);
        this._getStorageKey = this._getStorageKey.bind(this);
        this.getTileUrls = this.getTileUrls.bind(this);
        this.fire = this.fireLeafletEvent.bind(this);
    }

    createLeafletElement(props) {
        return L.tileLayer.offline(props.url, this.getOptions(props));
    }

    updateLeafletElement(fromProps, toProps) {
        super.updateLeafletElement(fromProps, toProps);
        if (toProps.url !== fromProps.url) {
            this.leafletElement.setUrl(toProps.url);
        }
    }

    createTile(coords, done) {
        return this.leafletElement.createTile(coords, done);
    }

    setDataUrl(coords) {
        return this.leafletElement.setDataUrl(coords);
    }

    _getStorageKey(coords) {
        return this.leafletElement._getStorageKey(coords);
    }

    getTileUrls(bounds, zoom) {
        return this.leafletElement.getTileUrls(bounds, zoom);
    }
}

export default withLeaflet(OfflineTileLayer);
```

<pre class="lang-js prettyprint-override"><code>/**
 * SaveTilesControl.jsx
 */

import L from "leaflet";
import { MapControl, withLeaflet } from "react-leaflet";
import "leaflet.offline/src/ControlSaveTiles";

class SaveTilesControl extends MapControl {
    constructor(props) {
        super(props);
        this.removeTiles = this.removeTiles.bind(this);
    }

    createLeafletElement({ layer, ...props }) {
        return L.control.savetiles(layer, props);
    }

    updateLeafletElement(fromProps, toProps) {
        super.updateLeafletElement(fromProps, toProps);
        if (toProps.layer !== fromProps.layer) {
            this.leafletElement.setLayer(toProps.layer);
        }
    }

    removeTiles() {
        this.leafletElement._rmTiles();
    }
}

export default withLeaflet(SaveTilesControl);
</code>```

and then to use them:

```<code>import SaveTilesControl from "./SaveTilesControl.jsx";
import OfflineTileLayer from "./OfflineTileLayer.jsx";
import { mapOptions, layerOptions, controlOptions } from "./config.js";

const MapView = () => {
    const baselayer = useRef(null);
    return (
        <Map id="mymap" {...mapOptions}>
            <OfflineTileLayer ref={baselayer} {...layerOptions} />
            {baselayer.current && (
                <SaveTilesControl layer={baselayer.current} {...controlOptions} />
            )}
        </Map>
    );
}
</code>```

Body:
I need help to make this component work for the savebuttons.
The leaflet.offline package is this one:
https://github.com/allartk/leaflet.offline/blob/master/docs/api.md

React Typescript.

I am trying to extend react-leaflet as per documentation. With createLeafletElement and updateLeafletElement. I get no errors but nothing is adding to the map.

My Layer component is called OfflineTileLayer.

Here is the component:

import L from 'leaflet';
import 'leaflet.offline';
import { MapControl, withLeaflet, MapControlProps } from 'react-leaflet';

type LeafletElement = MapControl;
type Props = { url: string } & MapControlProps;
class OfflineSaveControls extends MapControl<LeafletElement, Props> {
  mapControl;
  constructor(props, context) {
    super(props);
  }

  createLeafletElement(props: Props): LeafletElement {
    return this.mapControl = new L.control.savetiles(props.layer, {
      zoomlevels: [13, 16], // optional zoomlevels to save, default current zoomlevel
      confirm(layer, succescallback) {
        if (window.confirm(`Save ${layer._tilesforSave.length}`)) {
          succescallback();
        }
      },
      confirmRemoval(layer, successCallback) {
        if (window.confirm('Remove all the tiles?')) {
          successCallback();
        }
      },
      saveText: '',
      rmText: '',
    }).addTo(Map);
  }
  updateLeafletElement(fromProps: Props, toProps: Props) {
    super.updateLeafletElement(fromProps, toProps);
  }

}
export default withLeaflet<Props, OfflineSaveControls>(OfflineSaveControls);

If this is just pure wrong, does anyone have another implementation of leaflet.offline in react?. Seems really hard to extend react-leaflet for some reason.

Body:
These are the relevant bits from my extension for leaflet.offline, only it's not in Typescript. Hopefully it saves you (or the next person) a bit of time.

/**
 * OfflineTileLayer.jsx
 */

import L from "leaflet";
import { GridLayer, withLeaflet } from "react-leaflet";
import "leaflet.offline/src/TileLayerOffline";

class OfflineTileLayer extends GridLayer {
    constructor(props) {
        super(props);
        this.createTile = this.createTile.bind(this);
        this.setDataUrl = this.setDataUrl.bind(this);
        this._getStorageKey = this._getStorageKey.bind(this);
        this.getTileUrls = this.getTileUrls.bind(this);
        this.fire = this.fireLeafletEvent.bind(this);
    }

    createLeafletElement(props) {
        return L.tileLayer.offline(props.url, this.getOptions(props));
    }

    updateLeafletElement(fromProps, toProps) {
        super.updateLeafletElement(fromProps, toProps);
        if (toProps.url !== fromProps.url) {
            this.leafletElement.setUrl(toProps.url);
        }
    }

    createTile(coords, done) {
        return this.leafletElement.createTile(coords, done);
    }

    setDataUrl(coords) {
        return this.leafletElement.setDataUrl(coords);
    }

    _getStorageKey(coords) {
        return this.leafletElement._getStorageKey(coords);
    }

    getTileUrls(bounds, zoom) {
        return this.leafletElement.getTileUrls(bounds, zoom);
    }
}

export default withLeaflet(OfflineTileLayer);

/**
 * SaveTilesControl.jsx
 */

import L from "leaflet";
import { MapControl, withLeaflet } from "react-leaflet";
import "leaflet.offline/src/ControlSaveTiles";

class SaveTilesControl extends MapControl {
    constructor(props) {
        super(props);
        this.removeTiles = this.removeTiles.bind(this);
    }

    createLeafletElement({ layer, ...props }) {
        return L.control.savetiles(layer, props);
    }

    updateLeafletElement(fromProps, toProps) {
        super.updateLeafletElement(fromProps, toProps);
        if (toProps.layer !== fromProps.layer) {
            this.leafletElement.setLayer(toProps.layer);
        }
    }

    removeTiles() {
        this.leafletElement._rmTiles();
    }
}

export default withLeaflet(SaveTilesControl);

and then to use them:

import SaveTilesControl from "./SaveTilesControl.jsx";
import OfflineTileLayer from "./OfflineTileLayer.jsx";
import { mapOptions, layerOptions, controlOptions } from "./config.js";

const MapView = () => {
    const baselayer = useRef(null);
    return (
        <Map id="mymap" {...mapOptions}>
            <OfflineTileLayer ref={baselayer} {...layerOptions} />
            {baselayer.current && (
                <SaveTilesControl layer={baselayer.current} {...controlOptions} />
            )}
        </Map>
    );
}