问:
What is causing the error in my CruiseControl.Net Project?
I'm a bit baffled by the results I'm seeing in my CruiseControl.Net build log. The build fails after a few minutes but I can't figure out what's causing it.</p>

```<code> <cruisecontrol project="Bromley Live">
  <request source="ITUSER-PC" buildCondition="ForceBuild">Build (ForceBuild) triggered from ITUSER-PC</request>
  <parameters>
    <parameter name="CCNetForceBuildReason" value="Debugging" />
    <parameter name="$CCNetArtifactDirectory" value="C:\CCNet\Projects\Bromley Live\Artifacts" />
    <parameter name="$CCNetBuildCondition" value="ForceBuild" />
    <parameter name="$CCNetBuildDate" value="2011-06-02" />
    <parameter name="$CCNetBuildTime" value="14:34:38" />
    <parameter name="$CCNetFailureUsers" value="System.Collections.ArrayList" />
    <parameter name="$CCNetIntegrationStatus" value="Unknown" />
    <parameter name="$CCNetLabel" value="1.0.0.0" />
    <parameter name="$CCNetLastIntegrationStatus" value="Failure" />
    <parameter name="$CCNetListenerFile" value="C:\CCNet\Projects\Bromley Live\Artifacts\Bromley Live_ListenFile.xml" />
    <parameter name="$CCNetModifyingUsers" value="System.Collections.ArrayList" />
    <parameter name="$CCNetNumericLabel" value="0" />
    <parameter name="$CCNetProject" value="Bromley Live" />
    <parameter name="$CCNetProjectUrl" value="http://CIBuildServer/CruiseControl/server/local/project/Bromley Live/ViewProjectReport.aspx" />
    <parameter name="$CCNetRequestSource" value="OCL-DEV-WEB" />
    <parameter name="$CCNetUser" value="" />
    <parameter name="$CCNetWorkingDirectory" value="C:\CCNet\Projects\Bromley Live\WorkingDirectory" />
  </parameters>
  <modifications />
  <integrationProperties>
    <CCNetArtifactDirectory>C:\CCNet\Projects\Bromley Live\Artifacts</CCNetArtifactDirectory>
    <CCNetBuildCondition>ForceBuild</CCNetBuildCondition>
    <CCNetBuildDate>2011-06-02</CCNetBuildDate>
    <CCNetBuildTime>14:34:38</CCNetBuildTime>
    <CCNetFailureUsers />
    <CCNetIntegrationStatus>Failure</CCNetIntegrationStatus>
    <CCNetLabel>1.0.0.0</CCNetLabel>
    <CCNetLastIntegrationStatus>Failure</CCNetLastIntegrationStatus>
    <CCNetListenerFile>C:\CCNet\Projects\Bromley Live\Artifacts\Bromley Live_ListenFile.xml</CCNetListenerFile>
    <CCNetModifyingUsers />
    <CCNetNumericLabel>0</CCNetNumericLabel>
    <CCNetProject>Bromley Live</CCNetProject>
    <CCNetProjectUrl>http://CIBuildServer/CruiseControl/server/local/project/Bromley Live/ViewProjectReport.aspx</CCNetProjectUrl>
    <CCNetRequestSource>ITUSER-PC</CCNetRequestSource>
    <CCNetWorkingDirectory>C:\CCNet\Projects\Bromley Live\WorkingDirectory</CCNetWorkingDirectory>
    <LastIntegrationStatus>Failure</LastIntegrationStatus>
    <LastSuccessfulIntegrationLabel>UNKNOWN</LastSuccessfulIntegrationLabel>
    <LastModificationDate>01/06/2011 14:35:34</LastModificationDate>
    <CCNetForceBuildReason>Debugging</CCNetForceBuildReason>
  </integrationProperties>
  <build date="2011-06-02 14:34:38" buildtime="00:00:56" error="true" buildcondition="ForceBuild">

<buildresults>
  <message>The command completed successfully.</message>
</buildresults>

<buildresults>
  <message>-------------------------------------------------------------------------------</message>
  <message>   ROBOCOPY     ::     Robust File Copy for Windows                              </message>
  <message>-------------------------------------------------------------------------------</message>
  <message>  Started : Thu Jun 02 14:34:38 2011</message>
  <message>   Source : C:\CCNet\Projects\Bromley Live\WorkingDirectory\Website\</message>
  <message>     Dest : \\LiveServer\wwwroot$\Bromley\</message>
  <message>    Files : *.*</message>
  <message>     </message>
  <message>Exc Files : Thumbs.db</message>
  <message>     *.scc</message>
  <message>     </message>
  <message> Exc Dirs : .hg</message>
  <message>     </message>
  <message>  Options : *.* /NS /NC /NDL /S /E /COPY:DAT /NP /XO /XA:H /R:1000000 /W:30 </message>
  <message>------------------------------------------------------------------------------</message>
  <message>             \\LiveServer\wwwroot$\Bromley\admin\legacy\selfAssessment\uploadVisitReport.asp</message>
  <message>             \\LiveServer\wwwroot$\Bromley\Bin\AjaxControlToolkit.pdb</message>
  <message>             C:\CCNet\Projects\Bromley Live\WorkingDirectory\Website\userControls\IconMenuTopControl.ascx</message>
  <message>             C:\CCNet\Projects\Bromley Live\WorkingDirectory\Website\userControls\IconMenuTopControl.ascx.vb</message>
  <message>------------------------------------------------------------------------------</message>
  <message>               Total    Copied   Skipped  Mismatch    FAILED    Extras</message>
  <message>    Dirs :       212         0       212         0         0        16</message>
  <message>   Files :      1804        45      1759         0         0       203</message>
  <message>   Bytes :   44.46 m    2.89 m   41.57 m         0         0    2.03 m</message>
  <message>   Times :   0:00:55   0:00:16                       0:00:00   0:00:39</message>
  <message>   Speed :              185068 Bytes/sec.</message>
  <message>   Speed :              10.589 MegaBytes/min.</message>
  <message>   Ended : Thu Jun 02 14:35:34 2011</message>
</buildresults>
</build>
</cruisecontrol>
</code>```

答: Robocopy does not return proper exit status codes (that is, 0 on success). To work around this, you have to use the successExitCodes attibute on your executable task. Setting it to "0,1,2" should work (you want the task to fail on other results). (Robocopy exit codes list as a reference.)

Body:
I'm a bit baffled by the results I'm seeing in my CruiseControl.Net build log. The build fails after a few minutes but I can't figure out what's causing it.

 <cruisecontrol project="Bromley Live">
  <request source="ITUSER-PC" buildCondition="ForceBuild">Build (ForceBuild) triggered from ITUSER-PC</request>
  <parameters>
    <parameter name="CCNetForceBuildReason" value="Debugging" />
    <parameter name="$CCNetArtifactDirectory" value="C:\CCNet\Projects\Bromley Live\Artifacts" />
    <parameter name="$CCNetBuildCondition" value="ForceBuild" />
    <parameter name="$CCNetBuildDate" value="2011-06-02" />
    <parameter name="$CCNetBuildTime" value="14:34:38" />
    <parameter name="$CCNetFailureUsers" value="System.Collections.ArrayList" />
    <parameter name="$CCNetIntegrationStatus" value="Unknown" />
    <parameter name="$CCNetLabel" value="1.0.0.0" />
    <parameter name="$CCNetLastIntegrationStatus" value="Failure" />
    <parameter name="$CCNetListenerFile" value="C:\CCNet\Projects\Bromley Live\Artifacts\Bromley Live_ListenFile.xml" />
    <parameter name="$CCNetModifyingUsers" value="System.Collections.ArrayList" />
    <parameter name="$CCNetNumericLabel" value="0" />
    <parameter name="$CCNetProject" value="Bromley Live" />
    <parameter name="$CCNetProjectUrl" value="http://CIBuildServer/CruiseControl/server/local/project/Bromley Live/ViewProjectReport.aspx" />
    <parameter name="$CCNetRequestSource" value="OCL-DEV-WEB" />
    <parameter name="$CCNetUser" value="" />
    <parameter name="$CCNetWorkingDirectory" value="C:\CCNet\Projects\Bromley Live\WorkingDirectory" />
  </parameters>
  <modifications />
  <integrationProperties>
    <CCNetArtifactDirectory>C:\CCNet\Projects\Bromley Live\Artifacts</CCNetArtifactDirectory>
    <CCNetBuildCondition>ForceBuild</CCNetBuildCondition>
    <CCNetBuildDate>2011-06-02</CCNetBuildDate>
    <CCNetBuildTime>14:34:38</CCNetBuildTime>
    <CCNetFailureUsers />
    <CCNetIntegrationStatus>Failure</CCNetIntegrationStatus>
    <CCNetLabel>1.0.0.0</CCNetLabel>
    <CCNetLastIntegrationStatus>Failure</CCNetLastIntegrationStatus>
    <CCNetListenerFile>C:\CCNet\Projects\Bromley Live\Artifacts\Bromley Live_ListenFile.xml</CCNetListenerFile>
    <CCNetModifyingUsers />
    <CCNetNumericLabel>0</CCNetNumericLabel>
    <CCNetProject>Bromley Live</CCNetProject>
    <CCNetProjectUrl>http://CIBuildServer/CruiseControl/server/local/project/Bromley Live/ViewProjectReport.aspx</CCNetProjectUrl>
    <CCNetRequestSource>ITUSER-PC</CCNetRequestSource>
    <CCNetWorkingDirectory>C:\CCNet\Projects\Bromley Live\WorkingDirectory</CCNetWorkingDirectory>
    <LastIntegrationStatus>Failure</LastIntegrationStatus>
    <LastSuccessfulIntegrationLabel>UNKNOWN</LastSuccessfulIntegrationLabel>
    <LastModificationDate>01/06/2011 14:35:34</LastModificationDate>
    <CCNetForceBuildReason>Debugging</CCNetForceBuildReason>
  </integrationProperties>
  <build date="2011-06-02 14:34:38" buildtime="00:00:56" error="true" buildcondition="ForceBuild">

<buildresults>
  <message>The command completed successfully.</message>
</buildresults>

<buildresults>
  <message>-------------------------------------------------------------------------------</message>
  <message>   ROBOCOPY     ::     Robust File Copy for Windows                              </message>
  <message>-------------------------------------------------------------------------------</message>
  <message>  Started : Thu Jun 02 14:34:38 2011</message>
  <message>   Source : C:\CCNet\Projects\Bromley Live\WorkingDirectory\Website\</message>
  <message>     Dest : \\LiveServer\wwwroot$\Bromley\</message>
  <message>    Files : *.*</message>
  <message>     </message>
  <message>Exc Files : Thumbs.db</message>
  <message>     *.scc</message>
  <message>     </message>
  <message> Exc Dirs : .hg</message>
  <message>     </message>
  <message>  Options : *.* /NS /NC /NDL /S /E /COPY:DAT /NP /XO /XA:H /R:1000000 /W:30 </message>
  <message>------------------------------------------------------------------------------</message>
  <message>             \\LiveServer\wwwroot$\Bromley\admin\legacy\selfAssessment\uploadVisitReport.asp</message>
  <message>             \\LiveServer\wwwroot$\Bromley\Bin\AjaxControlToolkit.pdb</message>
  <message>             C:\CCNet\Projects\Bromley Live\WorkingDirectory\Website\userControls\IconMenuTopControl.ascx</message>
  <message>             C:\CCNet\Projects\Bromley Live\WorkingDirectory\Website\userControls\IconMenuTopControl.ascx.vb</message>
  <message>------------------------------------------------------------------------------</message>
  <message>               Total    Copied   Skipped  Mismatch    FAILED    Extras</message>
  <message>    Dirs :       212         0       212         0         0        16</message>
  <message>   Files :      1804        45      1759         0         0       203</message>
  <message>   Bytes :   44.46 m    2.89 m   41.57 m         0         0    2.03 m</message>
  <message>   Times :   0:00:55   0:00:16                       0:00:00   0:00:39</message>
  <message>   Speed :              185068 Bytes/sec.</message>
  <message>   Speed :              10.589 MegaBytes/min.</message>
  <message>   Ended : Thu Jun 02 14:35:34 2011</message>
</buildresults>
</build>
</cruisecontrol>


来源: stackexchange

问:
Forming an sql query
I really hope that you can help me forming an sql query that can do the following:

I have 2 tables

```<code>Pages
(
    [Id] [int] IDENTITY(1,1) NOT NULL,
    [Key] [nvarchar](450) NULL,
    [CreatedAt] [datetimeoffset](7) NOT NULL,
    [Title] [nvarchar](max) NULL
)

Contents
(
    [Id] [int] IDENTITY(1,1) NOT NULL,
    [PageId] [int] NULL,
    [Key] [nvarchar](450) NULL,
    [Version] [int] NOT NULL,
    [Text] [nvarchar](max) NULL
)

Id |   Key   | CreatedAt | Title
---+---------+-----------+-------
 1 | "page1" | 20200101  | ....

Id | PageId |   Key  | Version | Text
---+--------+--------+---------+------
 1 |    1   | "key1" |    1    | .....
 2 |    1   | "key1" |    2    | .....
 3 |    1   | "key2" |    1    | .....
 4 |    1   | "key2" |    2    | .....
 5 |    1   | "key3" |    1    | .....
</code>```

I'm interested in getting the page and the newest version of each content where PageId matches the page.

** Update **

Key is the key that is passed to get the result

```<code>Select * from Pages where [Key] = 'the key of the page'
</code>```

The desired result would be something like

```<code>Page.Id | Page.Key | Page.CreatedAt | Page.Title | Content.Id | Content.PageId | Content.Key | Content.Version | Content.Text
---------------------------------------------------------------------------------------------------------------------------------
   1    |  "Page1" |    20200101    |   ......   |     2      |        1       |    "Key1"     |    2     | ......
   1    |  "Page1" |    20200101    |   ......   |     4      |        1       |    "Key2"     |    2     | ......
   1    |  "Page1" |    20200101    |   ......   |     5      |        1       |    "Key3"     |    1     | ......
</code>```

答:
If by newest you mean the max version then you can use ROW_NUMBER() window function:

```<code>select p.*, c.*
from Pages p
left join (
  select *, row_number() over (partition by PageId, [Key] order by version desc) rn
  from Contents
) c on c.PageId = p.Id and c.rn = 1
</code>```

See the demo.

ContentLicense: CC BY-SA 4.0

Title: Forming an sql query

Body:
I really hope that you can help me forming an sql query that can do the following:

I have 2 tables

Pages
(
    [Id] [int] IDENTITY(1,1) NOT NULL,
    [Key] [nvarchar](450) NULL,
    [CreatedAt] [datetimeoffset](7) NOT NULL,
    [Title] [nvarchar](max) NULL
)

Contents
(
    [Id] [int] IDENTITY(1,1) NOT NULL,
    [PageId] [int] NULL,
    [Key] [nvarchar](450) NULL,
    [Version] [int] NOT NULL,
    [Text] [nvarchar](max) NULL
)

Id |   Key   | CreatedAt | Title
---+---------+-----------+-------
 1 | "page1" | 20200101  | ....

Id | PageId |   Key  | Version | Text
---+--------+--------+---------+------
 1 |    1   | "key1" |    1    | .....
 2 |    1   | "key1" |    2    | .....
 3 |    1   | "key2" |    1    | .....
 4 |    1   | "key2" |    2    | .....
 5 |    1   | "key3" |    1    | .....

I'm interested in getting the page and the newest version of each content where PageId matches the page.

** Update **

Key is the key that is passed to get the result

Select * from Pages where [Key] = 'the key of the page'

The desired result would be something like

Page.Id | Page.Key | Page.CreatedAt | Page.Title | Content.Id | Content.PageId | Content.Key | Content.Version | Content.Text
---------------------------------------------------------------------------------------------------------------------------------
   1    |  "Page1" |    20200101    |   ......   |     2      |        1       |    "Key1"     |    2     | ......
   1    |  "Page1" |    20200101    |   ......   |     4      |        1       |    "Key2"     |    2     | ......
   1    |  "Page1" |    20200101    |   ......   |     5      |        1       |    "Key3"     |    1     | ......

Body:
If by newest you mean the max version then you can use ROW_NUMBER() window function:

select p.*, c.*
from Pages p
left join (
  select *, row_number() over (partition by PageId, [Key] order by version desc) rn
  from Contents
) c on c.PageId = p.Id and c.rn = 1

See the demo.


问:
How can i Implement synchronized in Java?
i have an Assignment about Multithreading and i need some help.

I have a Ressource class which cannot be changed

```<code>public class Ressource {
    public int val;
    public void incr() {
        val++;

    }
    public void decr() {
        val--;

    }
</code>```

And i have my main Class

```<code>public class TwoThreads {
    public static Ressource res = new Ressource();
    public static void main(String[] args)  {
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                for(int i = 0; i < 100; i++){
                    res.incr();
                }
                System.out.println(res.val);
            }
        });
        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                for(int i = 0; i < 100; i++){
                    res.decr();
                }
                System.out.println(res.val);
            }
        });
        t1.start();
        t2.start();

    }
}
</code>```

I tried to use synchronized inside my Override methods but it didn't work. I know that if i used

```<code> public synchronized void incr() {
        val++;

    }
</code>```

it will work but i should not change anything in the Ressources Class. Any Ideas?

答:
i want to increase to 100 and then decrease to 0.First t1 should run
  and when its finished should t2 start.But i have to do it in the main
  method.

You can do it as follows:

```<code>t1.start();
t1.join();
t2.start();
</code>```

Demo:

```<code>class Ressource {
    public int val;

    public void incr() {
        val++;

    }

    public void decr() {
        val--;

    }
}

public class Main {
    public static Ressource res = new Ressource();

    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 100; i++) {
                    System.out.println(res.val);
                    res.incr();
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        });
        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 100; i++) {
                    System.out.println(res.val);
                    res.decr();
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                System.out.println(res.val);
            }
        });
        t1.start();
        t1.join();
        t2.start();
    }
}
</code>```

Body:
i have an Assignment about Multithreading and i need some help.

I have a Ressource class which cannot be changed

public class Ressource {
    public int val;
    public void incr() {
        val++;

    }
    public void decr() {
        val--;

    }

And i have my main Class

public class TwoThreads {
    public static Ressource res = new Ressource();
    public static void main(String[] args)  {
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                for(int i = 0; i < 100; i++){
                    res.incr();
                }
                System.out.println(res.val);
            }
        });
        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                for(int i = 0; i < 100; i++){
                    res.decr();
                }
                System.out.println(res.val);
            }
        });
        t1.start();
        t2.start();

    }
}

I tried to use synchronized inside my Override methods but it didn't work. I know that if i used

 public synchronized void incr() {
        val++;

    }

it will work but i should not change anything in the Ressources Class. Any Ideas?

Body:
i want to increase to 100 and then decrease to 0.First t1 should run
  and when its finished should t2 start.But i have to do it in the main
  method.

You can do it as follows:

t1.start();
t1.join();
t2.start();

Demo:

class Ressource {
    public int val;

    public void incr() {
        val++;

    }

    public void decr() {
        val--;

    }
}

public class Main {
    public static Ressource res = new Ressource();

    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 100; i++) {
                    System.out.println(res.val);
                    res.incr();
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        });
        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 100; i++) {
                    System.out.println(res.val);
                    res.decr();
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                System.out.println(res.val);
            }
        });
        t1.start();
        t1.join();
        t2.start();
    }
}


问:
Thymeleaf nested Set<Object>
I'm having a problem accessing a nested Set of objects.
I have defined the below objects :

```<code>@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "site")
public class Site {
    @Id
    @GeneratedValue(strategy = GerationType.IDENTITY)
    @Column(name="id", updatable=false,nullable=false)
    private Long id;

    private String siteName;
    private String siteLocation;

    @OneToMany(cascade=CascadeType.ALL, mappedBy = "site")
    private Set<Rack> rack = new HashSet<>();
}

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "rack")
public class Rack {

    @Id
    @GeneratedValue(strategy = GerationType.IDENTITY)
    @Column(name="id", updatable=false,nullable=false)
    private Long id;
    private String rackName;
    private String rackAssetTag;
    private String rackCMDBCode;

    @ManyToOne
    @JoinColumn(name = "site_id")
    private Site site;

    @OneToMany(cascade=CascadeType.ALL, mappedBy = "box")
    private Set<Box> box = new HashSet<>();
}

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "box")
public class Box {
    @Id
    @GeneratedValue(strategy = GerationType.IDENTITY)
    @Column(name="id", updatable=false,nullable=false)
    private Long id;
    private boxAssetTag;
    private boxCMDBCode;

    ManyToOne
    @JoinColumn(name = "rack_id")
    private Rack rack;

}
</code>```

All relation mapping work tiptop.
The problem is when I want to create a nice nested table for this(css formating and conditional thymeleaf validation removed since it's irrelevant) :

```<code><div>
    <table>
        <thead>
            <tr>
                <th>Rack name</th>
                <th>Rack asset tag</th>
                <th>Rack CMDB code</th>
            </tr>
        </thead>
        <tbody>
            <tr th:each="rack:${site.rack}">
                <td th:text="${rack.rackName}"></td>
                <td th:text="${rack.rackAssetTag}"></td>
                <td th:text="${rack.rackCMDBCode}"></td>
            </tr>
            <tr>
                <td>
                    <table>
                        <thead>
                            <tr>
                                <th>Box asset tag</th>
                                <th>Box CMDB code</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr th:each="box:${rack.box}">
                                <td th:text="${box.boxAssetTag}">
                                <td th:text="${box.boxCMDBCode}">
                            </tr>
                        </tbody>
                    </table>
                </td>
            </tr>
        </tbody>
    </table>
</div>
</code>```

Controller adds one object 'site' to the model that holds all relation.
When accessing the page I receive and error:
Property or field 'box' cannot be found on null

I think that when I move to the second table thymeleaf looses the context of the object rack created in the outer table. Therefore when I try to invoke the th:each in the inner table the there is no rack object to perform ${rack.box}.
The question is how to be able to access the 'deeper' object in thymeleaf without loosing the context of the object above?

Regards,
Jarek.

答:
Ok so I've managed to work out a solution.
I'll write it up. Maybe someone some day will need it.

So the idea is to cycle through each object but on the body element not on the row. This lets You have the context of the object much wider

```<code><div>
<table>
    <thead>
        <th>Rack name</th>
        <th>Rack asset tag</th>
        <th>Rack CMDB code</th>
    </thead>
    <tbody th:each="rack:${site.rack}">
        <tr>
            <td th:text="${rack.rackName}"></td>
            <td th:text="${rack.rackAssetTag}"></td>
            <td th:text="${rack.rackCMDBCode}"></td>
        </tr>
        <tr>
            <td>
                <table>
                    <thead>
                        <tr>
                            <th>Box asset tag</th>
                            <th>Box CMDB code</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr th:each="box:${rack.box}">
                            <td th:text="${box.boxAssetTag}">
                            <td th:text="${box.boxCMDBCode}">
                        </tr>
                    </tbody>
                </table>
            </td>
        </tr>
    </tbody>
</table>
</code>```

Title: Thymeleaf nested Set<Object>

Body:
I'm having a problem accessing a nested Set of objects.
I have defined the below objects :

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "site")
public class Site {
    @Id
    @GeneratedValue(strategy = GerationType.IDENTITY)
    @Column(name="id", updatable=false,nullable=false)
    private Long id;

    private String siteName;
    private String siteLocation;

    @OneToMany(cascade=CascadeType.ALL, mappedBy = "site")
    private Set<Rack> rack = new HashSet<>();
}

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "rack")
public class Rack {

    @Id
    @GeneratedValue(strategy = GerationType.IDENTITY)
    @Column(name="id", updatable=false,nullable=false)
    private Long id;
    private String rackName;
    private String rackAssetTag;
    private String rackCMDBCode;

    @ManyToOne
    @JoinColumn(name = "site_id")
    private Site site;

    @OneToMany(cascade=CascadeType.ALL, mappedBy = "box")
    private Set<Box> box = new HashSet<>();
}

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "box")
public class Box {
    @Id
    @GeneratedValue(strategy = GerationType.IDENTITY)
    @Column(name="id", updatable=false,nullable=false)
    private Long id;
    private boxAssetTag;
    private boxCMDBCode;

    ManyToOne
    @JoinColumn(name = "rack_id")
    private Rack rack;

}

All relation mapping work tiptop.
The problem is when I want to create a nice nested table for this(css formating and conditional thymeleaf validation removed since it's irrelevant) :

                Rack name
                Rack asset tag
                Rack CMDB code

                                Box asset tag
                                Box CMDB code

Controller adds one object 'site' to the model that holds all relation.
When accessing the page I receive and error:
Property or field 'box' cannot be found on null

I think that when I move to the second table thymeleaf looses the context of the object rack created in the outer table. Therefore when I try to invoke the th:each in the inner table the there is no rack object to perform ${rack.box}.
The question is how to be able to access the 'deeper' object in thymeleaf without loosing the context of the object above?

Regards,
Jarek.

Body:
Ok so I've managed to work out a solution.
I'll write it up. Maybe someone some day will need it.

So the idea is to cycle through each object but on the body element not on the row. This lets You have the context of the object much wider

<div>
<table>
    <thead>
        <th>Rack name</th>
        <th>Rack asset tag</th>
        <th>Rack CMDB code</th>
    </thead>
    <tbody th:each="rack:${site.rack}">
        <tr>
            <td th:text="${rack.rackName}"></td>
            <td th:text="${rack.rackAssetTag}"></td>
            <td th:text="${rack.rackCMDBCode}"></td>
        </tr>
        <tr>
            <td>
                <table>
                    <thead>
                        <tr>
                            <th>Box asset tag</th>
                            <th>Box CMDB code</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr th:each="box:${rack.box}">
                            <td th:text="${box.boxAssetTag}">
                            <td th:text="${box.boxCMDBCode}">
                        </tr>
                    </tbody>
                </table>
            </td>
        </tr>
    </tbody>
</table>


问:
How to repeat the last few frames of animation for React Animation
I have an app which the user holds down the screen and an animation starts to play. This is not a normal animation. It uses multiple frames to create this animation much like a cartoon from Disney :)
The animation plays from the start to the end and loops. But I want it to loop over the last 4 or 5 frames repeatedly. At the moment it doesn't do this.

Here is the code:

Initialisation in the constructor:

```<code>this.animations = new Animated.Value(0);
  this.opacity = [];
  Images.map((item, index) => {

    this.opacity.push(
       this.animations.interpolate({
            inputRange: [index - 1, index, index + 1],
            outputRange: [0, 100, 0],
        }),
      )
    })
</code>```

The animation function and the hold screen function (for what it's worth):

```<code>startAnimation = () => {
  Animated.loop(
    Animated.timing(this.animations, {
      toValue: length - 1,
      duration: 50 * length,
      easing: Easing.linear,
      useNativeDriver: true,
    })
  ).start();

}

onItemMouseDown = () => {
  this.startAnimation()
this.setState({
  isOn: true,
  pauseToggle: 'down',
  mouseUp: 'no',
  twoSecOver: false,

})

</code>```

The render:

```<code>{this.state.isOn === true ? (
        <View style={styles.container}>

          {Images.map((item, index) => {
            const opacity = this.opacity[index];

            return (
              <Animated.View
                key={item.id}
                style={[styles.anim, { animations: item, opacity}]}
              >
              <Image source={item.source} style={styles.animSize}/>
              <Text style={styles.timer}>Timer:{ms(this.state.time,{verbose: true})}</Text>
              </Animated.View>
            );
          })}
        </View>
      ) : null}

</code>```

I've looked at this: Looping over the last few entries of an array
and this:
using array.map with repeat in Javascript
but I'm doomed to failure, so need some help.
I've been advised to call:

Images.slice(startIndex, endIndex).map instead of just .map? Set startIndex to Images.length - 6 and endIndex to Images.length initially, then Images.length-6 and images.length afterwards. This actually plays the last few frames on a loop but doesn't play the first 18 frames so isn't useful! I don't know how to get it to map through the first 28 frames, then start the loop through the last 6.
How would I incorporate that into the render?

I've also tried using Animated.Sequence (https://reactnative.dev/docs/animations#tracking-dynamic-values) but have no idea how to do it.

T

答:
You could try this:

Define a state for your images stateImages if you have already have the images you can define in the constructor:

```<code>this.state = {
  stateImages: Images,
}
</code>```

Remove the loop onstartAnimation and set a callback on the completion to start the loop

```<code>startAnimation = () => {
  Animated.timing(this.animations, {
    toValue: length - 1,
    duration: 50 * length,
    easing: Easing.linear,
    useNativeDriver: true,
  }).start(({ finished }) => {
    // completion callback

    // if the user have the mouse down. You should track the current state because
    // you want the animation if the user stop the action
    if (isMouseDown) {
      startLoopAnimation();
    }
  });
}

// The animation loop function
startLoopAnimation = () => {

  this.animations = new Animated.Value(0);
   this.opacity = [];
    Images.map((item, index) => {

    this.opacity.push(
     this.animations.interpolate({
     inputRange: [index - 1, index, index + 1],
                 outputRange: [0, 100, 0],
            }),
           )
         })
  let orderedImages = Images.slice(Images.length - 6, Images.length);
  this.setState({
      stateImages: orderedImages,
    });
  Animated.timing(this.animations, {
    toValue: length - 1,
    duration: 50 * length,
    easing: Easing.linear,
    useNativeDriver: true,
  }).start(({ finished }) => {
    // completion callback

    // if the user have the mouse down. You should track the current state because
    // you want the animation stop if the user stop the action
    if (isMouseDown) {
      startLoopAnimation();
    }
  });
}
</code>```

Your render should be almost the same, but the Images map is processed with the stateImages that holds your current portion of the loop.

```<code>{this.state.isOn === true ? (
  <View style={styles.container}>

    {this.state.stateImages.map((item, index) => {
      const opacity = this.opacity[index];

      return (
        <Animated.View
          key={item.id}
          style={[styles.anim, { animations: item, opacity}]}
        >
        <Image source={item.source} style={styles.animSize}/>
        <Text style={styles.timer}>Timer:{ms(this.state.time,{verbose: true})}</Text>
        </Animated.View>
      );
    })}
  </View>
) : null}
</code>```

When the the user stop the animation action, you must restart your stateImages:

```<code>this.setState({
  stateImages: Images,
});
</code>```

The code is untested but this is the idea.

Body:
I have an app which the user holds down the screen and an animation starts to play. This is not a normal animation. It uses multiple frames to create this animation much like a cartoon from Disney :)
The animation plays from the start to the end and loops. But I want it to loop over the last 4 or 5 frames repeatedly. At the moment it doesn't do this.

Here is the code:

Initialisation in the constructor:

this.animations = new Animated.Value(0);
  this.opacity = [];
  Images.map((item, index) => {

    this.opacity.push(
       this.animations.interpolate({
            inputRange: [index - 1, index, index + 1],
            outputRange: [0, 100, 0],
        }),
      )
    })

The animation function and the hold screen function (for what it's worth):

startAnimation = () => {
  Animated.loop(
    Animated.timing(this.animations, {
      toValue: length - 1,
      duration: 50 * length,
      easing: Easing.linear,
      useNativeDriver: true,
    })
  ).start();

}

onItemMouseDown = () => {
  this.startAnimation()
this.setState({
  isOn: true,
  pauseToggle: 'down',
  mouseUp: 'no',
  twoSecOver: false,

})

The render:

{this.state.isOn === true ? (
        <View style={styles.container}>

          {Images.map((item, index) => {
            const opacity = this.opacity[index];

            return (
              <Animated.View
                key={item.id}
                style={[styles.anim, { animations: item, opacity}]}
              >
              <Image source={item.source} style={styles.animSize}/>
              <Text style={styles.timer}>Timer:{ms(this.state.time,{verbose: true})}</Text>
              </Animated.View>
            );
          })}
        </View>
      ) : null}

I've looked at this: Looping over the last few entries of an array
and this:
using array.map with repeat in Javascript
but I'm doomed to failure, so need some help.
I've been advised to call:

Images.slice(startIndex, endIndex).map instead of just .map? Set startIndex to Images.length - 6 and endIndex to Images.length initially, then Images.length-6 and images.length afterwards. This actually plays the last few frames on a loop but doesn't play the first 18 frames so isn't useful! I don't know how to get it to map through the first 28 frames, then start the loop through the last 6.
How would I incorporate that into the render?

I've also tried using Animated.Sequence (https://reactnative.dev/docs/animations#tracking-dynamic-values) but have no idea how to do it.

T

Body:
You could try this:

Define a state for your images stateImages if you have already have the images you can define in the constructor:

this.state = {
  stateImages: Images,
}

Remove the loop onstartAnimation and set a callback on the completion to start the loop

startAnimation = () => {
  Animated.timing(this.animations, {
    toValue: length - 1,
    duration: 50 * length,
    easing: Easing.linear,
    useNativeDriver: true,
  }).start(({ finished }) => {
    // completion callback

    // if the user have the mouse down. You should track the current state because
    // you want the animation if the user stop the action
    if (isMouseDown) {
      startLoopAnimation();
    }
  });
}

// The animation loop function
startLoopAnimation = () => {

  this.animations = new Animated.Value(0);
   this.opacity = [];
    Images.map((item, index) => {

    this.opacity.push(
     this.animations.interpolate({
     inputRange: [index - 1, index, index + 1],
                 outputRange: [0, 100, 0],
            }),
           )
         })
  let orderedImages = Images.slice(Images.length - 6, Images.length);
  this.setState({
      stateImages: orderedImages,
    });
  Animated.timing(this.animations, {
    toValue: length - 1,
    duration: 50 * length,
    easing: Easing.linear,
    useNativeDriver: true,
  }).start(({ finished }) => {
    // completion callback

    // if the user have the mouse down. You should track the current state because
    // you want the animation stop if the user stop the action
    if (isMouseDown) {
      startLoopAnimation();
    }
  });
}

Your render should be almost the same, but the Images map is processed with the stateImages that holds your current portion of the loop.

{this.state.isOn === true ? (
  <View style={styles.container}>

    {this.state.stateImages.map((item, index) => {
      const opacity = this.opacity[index];

      return (
        <Animated.View
          key={item.id}
          style={[styles.anim, { animations: item, opacity}]}
        >
        <Image source={item.source} style={styles.animSize}/>
        <Text style={styles.timer}>Timer:{ms(this.state.time,{verbose: true})}</Text>
        </Animated.View>
      );
    })}
  </View>
) : null}

When the the user stop the animation action, you must restart your stateImages:

this.setState({
  stateImages: Images,
});

The code is untested but this is the idea.


问:
Python 'different_locale' bad locale conversion
```<code>conditions = []
for i in range(1, 13):
    with different_locale('lt_LT'):
        conditions.append(calendar.month_name[i])
</code>```

Trying to get all months in my native "Lithuanian" language.
Result of the code :

```<code>['sausis', 'vasaris', 'kovas', 'balandis', 'geguþë', 'birþelis', 'liepa', 'rugpjûtis', 'rugsëjis', 'spalis', 'lapkritis', 'gruodis']
</code>```

expected result:

```<code>['sausis', 'vasaris', 'kovas', 'balandis', 'gegužė', 'birželis', 'liepa', 'rugpjūtis', 'rugsėjis', 'spalis', 'lapkritis', 'gruodis']
</code>```

Also tried "lt_LT.UTF-8" but got these results : 'geguÅ¾Ä\x97', 'birÅ¾elis'

Any ideas why?

答:
I would recommend using django's translation.override context manager. Here is a docs example.

I've tried the following script locally and it returned the desired result.

```<code>import calendar
from django.utils import translation
from django.utils.translation import gettext as _
conditions = []
    for i in range(1, 13):
        with translation.override('lt_LT'):
            conditions.append(_(calendar.month_name[i]))
</code>```

Output:

```<code>['sausis', 'vasaris', 'kovas', 'balandis', 'gegu\xc5\xbe\xc4\x97', 'bir\xc5\xbeelis', 'liepa', 'rugpj\xc5\xabtis', 'rugs\xc4\x97jis', 'spalis', 'lapkritis', 'gruodis']
</code>```

If you print them it yields:

```<code>sausis
vasaris
kovas
balandis
gegužė
birželis
liepa
rugpjūtis
rugsėjis
spalis
lapkritis
gruodis
</code>```

Body:
conditions = []
for i in range(1, 13):
    with different_locale('lt_LT'):
        conditions.append(calendar.month_name[i])

Trying to get all months in my native "Lithuanian" language.
Result of the code :

['sausis', 'vasaris', 'kovas', 'balandis', 'geguþë', 'birþelis', 'liepa', 'rugpjûtis', 'rugsëjis', 'spalis', 'lapkritis', 'gruodis']

expected result:

['sausis', 'vasaris', 'kovas', 'balandis', 'gegužė', 'birželis', 'liepa', 'rugpjūtis', 'rugsėjis', 'spalis', 'lapkritis', 'gruodis']

Also tried "lt_LT.UTF-8" but got these results : 'geguÅ¾Ä\x97', 'birÅ¾elis'

Any ideas why?

Body:
I would recommend using django's translation.override context manager. Here is a docs example.

I've tried the following script locally and it returned the desired result.

import calendar
from django.utils import translation
from django.utils.translation import gettext as _
conditions = []
    for i in range(1, 13):
        with translation.override('lt_LT'):
            conditions.append(_(calendar.month_name[i]))

Output:

['sausis', 'vasaris', 'kovas', 'balandis', 'gegu\xc5\xbe\xc4\x97', 'bir\xc5\xbeelis', 'liepa', 'rugpj\xc5\xabtis', 'rugs\xc4\x97jis', 'spalis', 'lapkritis', 'gruodis']

If you print them it yields:

sausis
vasaris
kovas
balandis
gegužė
birželis
liepa
rugpjūtis
rugsėjis
spalis
lapkritis
gruodis


问:
Serverless Nodejs Application gives Error "Unsupported Framework" when invoking
I am trying to deploy an existing node js application using serverless on AWS infrastructure.

my yaml is like :

```<code>service: todo-app-api
provider:
  name: aws
  runtime: nodejs10.x

functions:
     app:
        handler: server.run
        events:
          - http:
              path: /
              method: ANY
              cors: false
          - http:
              path: /{proxy+}
              method: ANY
              cors: false
plugins:
  - serverless-offline
</code>```

SLS deploy works fine and it creates lambda and other resources well. But when invoking that getting internal server error, when I see aws logs it gives error details as

```<code>    "errorType": "Error",
    "errorMessage": "Unsupported framework",
    "stack": [
        "Error: Unsupported framework",
        "    at getFramework (/var/task/node_modules/serverless-http/lib/framework/get-framework.js:69:9)",
        "    at module.exports (/var/task/node_modules/serverless-http/serverless-http.js:14:21)",
        "    at Object.<anonymous> (/var/task/server.js:31:22)",
        "    at Module._compile (internal/modules/cjs/loader.js:778:30)",
        "    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)",
        "    at Module.load (internal/modules/cjs/loader.js:653:32)",
        "    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)",
        "    at Function.Module._load (internal/modules/cjs/loader.js:585:3)",
        "    at Module.require (internal/modules/cjs/loader.js:692:17)",
        "    at require (internal/modules/cjs/helpers.js:25:18)",
        "    at _tryRequire (/var/runtime/UserFunction.js:75:12)",
        "    at _loadUserApp (/var/runtime/UserFunction.js:95:12)",
        "    at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)",
        "    at Object.<anonymous> (/var/runtime/index.js:45:30)",
        "    at Module._compile (internal/modules/cjs/loader.js:778:30)",
        "    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)"
    ]
}
</code>```

can somebody tell me if anything wrong I have done?

Thanks In Advance.

答:
I had the same problem and even opened an issue in the official repo. Everything was because I had in my serverless.yml:

```<code>plugins:
  - serverless-http # <---- delete this line
  - serverless-offline
</code>```

I don't really know how it got there but deleting it solved my problem. I hope it helps and good luck :-)

Body:
I am trying to deploy an existing node js application using serverless on AWS infrastructure.

my yaml is like :

service: todo-app-api
provider:
  name: aws
  runtime: nodejs10.x

functions:
     app:
        handler: server.run
        events:
          - http:
              path: /
              method: ANY
              cors: false
          - http:
              path: /{proxy+}
              method: ANY
              cors: false
plugins:
  - serverless-offline

SLS deploy works fine and it creates lambda and other resources well. But when invoking that getting internal server error, when I see aws logs it gives error details as

    "errorType": "Error",
    "errorMessage": "Unsupported framework",
    "stack": [
        "Error: Unsupported framework",
        "    at getFramework (/var/task/node_modules/serverless-http/lib/framework/get-framework.js:69:9)",
        "    at module.exports (/var/task/node_modules/serverless-http/serverless-http.js:14:21)",
        "    at Object.<anonymous> (/var/task/server.js:31:22)",
        "    at Module._compile (internal/modules/cjs/loader.js:778:30)",
        "    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)",
        "    at Module.load (internal/modules/cjs/loader.js:653:32)",
        "    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)",
        "    at Function.Module._load (internal/modules/cjs/loader.js:585:3)",
        "    at Module.require (internal/modules/cjs/loader.js:692:17)",
        "    at require (internal/modules/cjs/helpers.js:25:18)",
        "    at _tryRequire (/var/runtime/UserFunction.js:75:12)",
        "    at _loadUserApp (/var/runtime/UserFunction.js:95:12)",
        "    at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)",
        "    at Object.<anonymous> (/var/runtime/index.js:45:30)",
        "    at Module._compile (internal/modules/cjs/loader.js:778:30)",
        "    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)"
    ]
}

can somebody tell me if anything wrong I have done?

Thanks In Advance.

Body:
I had the same problem and even opened an issue in the official repo. Everything was because I had in my serverless.yml:

plugins:
  - serverless-http # <---- delete this line
  - serverless-offline

I don't really know how it got there but deleting it solved my problem. I hope it helps and good luck :-)


答:
I think rle will do what you're looking for. However, you're currently not calculating the quantile by month, we could use group_by from dplyr for that.

```<code>library(dplyr)
dat2 <- dat %>%
  group_by(YY,MM) %>%
  mutate(extreme = RR > quantile(RR,0.95,na.rm=TRUE))
# A tibble: 372 x 5
# Groups:   YY, MM [12]
      YY    MM    DD    RR extreme
   <int> <int> <int> <dbl> <lgl>
 1  1979    10     1  65.3 TRUE
 2  1979    10     2   2.6 FALSE
 3  1979    10     3   3.8 FALSE
 4  1979    10     4  93.5 TRUE
 5  1979    10     5   0   FALSE
 6  1979    10     6   0   FALSE
 7  1979    10     7   1   FALSE
 8  1979    10     8   0   FALSE
 9  1979    10     9   0   FALSE
10  1979    10    10   0   FALSE
# … with 362 more rows
</code>```

Now we can use rle to get the length between events:

```<code>result <- rle(dat2$extreme)
result
#Run Length Encoding
#  lengths: int [1:36] 1 2 1 54 2 27 2 16 1 1 ...
#  values : logi [1:36] TRUE FALSE TRUE FALSE TRUE FALSE ...
result$lengths[result$values]
 [1] 1 1 2 2 1 1 1 1 2 2 1 1 2 1 1 2 1 1
hist(result$lengths[result$values],breaks = c(0:5), xlab = "Length of extreme events", main = "")
</code>```

Title: Historgram of duration and intensity using R

Body:
I have the following data file. This is a daily data of rainfall with four columns (YY,MM,DD,RR). Apologies, this is the smallest data that I can generate.

structure(list(YY = c(1979L, 1979L, 1979L, 1979L, 1979L, 1979L,
1979L, 1979L, 1979L, 1979L, 1979L, 1979L, 1979L, 1979L, 1979L,
1979L, 1979L, 1979L, 1979L, 1979L, 1979L, 1979L, 1979L, 1979L,
1979L, 1979L, 1979L, 1979L, 1979L, 1979L, 1979L, 1980L, 1980L,
1980L, 1980L, 1980L, 1980L, 1980L, 1980L, 1980L, 1980L, 1980L,
1980L, 1980L, 1980L, 1980L, 1980L, 1980L, 1980L, 1980L, 1980L,
1980L, 1980L, 1980L, 1980L, 1980L, 1980L, 1980L, 1980L, 1980L,
1980L, 1980L, 1981L, 1981L, 1981L, 1981L, 1981L, 1981L, 1981L,
1981L, 1981L, 1981L, 1981L, 1981L, 1981L, 1981L, 1981L, 1981L,
1981L, 1981L, 1981L, 1981L, 1981L, 1981L, 1981L, 1981L, 1981L,
1981L, 1981L, 1981L, 1981L, 1981L, 1981L, 1982L, 1982L, 1982L,
1982L, 1982L, 1982L, 1982L, 1982L, 1982L, 1982L, 1982L, 1982L,
1982L, 1982L, 1982L, 1982L, 1982L, 1982L, 1982L, 1982L, 1982L,
1982L, 1982L, 1982L, 1982L, 1982L, 1982L, 1982L, 1982L, 1982L,
1982L, 1983L, 1983L, 1983L, 1983L, 1983L, 1983L, 1983L, 1983L,
1983L, 1983L, 1983L, 1983L, 1983L, 1983L, 1983L, 1983L, 1983L,
1983L, 1983L, 1983L, 1983L, 1983L, 1983L, 1983L, 1983L, 1983L,
1983L, 1983L, 1983L, 1983L, 1983L, 1984L, 1984L, 1984L, 1984L,
1984L, 1984L, 1984L, 1984L, 1984L, 1984L, 1984L, 1984L, 1984L,
1984L, 1984L, 1984L, 1984L, 1984L, 1984L, 1984L, 1984L, 1984L,
1984L, 1984L, 1984L, 1984L, 1984L, 1984L, 1984L, 1984L, 1984L,
1985L, 1985L, 1985L, 1985L, 1985L, 1985L, 1985L, 1985L, 1985L,
1985L, 1985L, 1985L, 1985L, 1985L, 1985L, 1985L, 1985L, 1985L,
1985L, 1985L, 1985L, 1985L, 1985L, 1985L, 1985L, 1985L, 1985L,
1985L, 1985L, 1985L, 1985L, 1986L, 1986L, 1986L, 1986L, 1986L,
1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L,
1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L,
1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1987L,
1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L,
1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L,
1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L,
1987L, 1987L, 1987L, 1988L, 1988L, 1988L, 1988L, 1988L, 1988L,
1988L, 1988L, 1988L, 1988L, 1988L, 1988L, 1988L, 1988L, 1988L,
1988L, 1988L, 1988L, 1988L, 1988L, 1988L, 1988L, 1988L, 1988L,
1988L, 1988L, 1988L, 1988L, 1988L, 1988L, 1988L, 1989L, 1989L,
1989L, 1989L, 1989L, 1989L, 1989L, 1989L, 1989L, 1989L, 1989L,
1989L, 1989L, 1989L, 1989L, 1989L, 1989L, 1989L, 1989L, 1989L,
1989L, 1989L, 1989L, 1989L, 1989L, 1989L, 1989L, 1989L, 1989L,
1989L, 1989L, 1990L, 1990L, 1990L, 1990L, 1990L, 1990L, 1990L,
1990L, 1990L, 1990L, 1990L, 1990L, 1990L, 1990L, 1990L, 1990L,
1990L, 1990L, 1990L, 1990L, 1990L, 1990L, 1990L, 1990L, 1990L,
1990L, 1990L, 1990L, 1990L, 1990L, 1990L), MM = c(10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L), DD = c(1L, 2L, 3L, 4L, 5L, 6L, 7L,
8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L,
21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 1L, 2L,
3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L,
17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L,
30L, 31L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L,
13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L,
26L, 27L, 28L, 29L, 30L, 31L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L,
22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 1L, 2L, 3L,
4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L,
18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L,
31L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L,
14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L,
27L, 28L, 29L, 30L, 31L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L,
10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L,
23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 1L, 2L, 3L, 4L,
5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L,
19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L,
1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L,
15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L,
28L, 29L, 30L, 31L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L,
11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L,
24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 1L, 2L, 3L, 4L, 5L, 6L,
7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L,
20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 1L,
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L,
16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L,
29L, 30L, 31L), RR = c(65.3, 2.6, 3.8, 93.5, 0, 0, 1, 0, 0, 0,
20.6, 3.4, 0, 0, 0, 0, 0, 0, 29.2, 6.6, 0.5, 1, 18.5, 3.3, 0,
2, 2.8, 0, 0, 12.8, 15.8, 0, 1.6, 0.3, 25, 3.6, 0, 19.6, 1.8,
0, 0, 0, 0, 25.9, 0, 6.6, 15.7, 1.3, 30, 0, 0, 0, 0.5, 17, 14.7,
6.1, 0.5, 67.6, 133.8, 114.6, 0, 0, 0, 25.1, 1.8, 1.4, 0, 0,
0, 0, 0, 2, 55.7, 36.9, 65, 3.1, 0, 0, 0, 0, 0, 0, 0, 41.4, 13.2,
29.8, 1, 170.7, 115, 72.9, 25.9, 18, 15.7, 1.3, 4, 0, 0, 0, 8.9,
0, 1, 0, 0, 6.1, 9.4, 21.6, 11, 13.1, 2.3, 0, 11.3, 4.9, 0.8,
0, 0.3, 0, 0, 0, 0.3, 6.4, 0, 0, 2.3, 6.9, 21.4, 57.7, 0.3, 35.5,
2.3, 0, 8.1, 0, 0, 108.2, 7.1, 8.2, 9.4, 14.2, 42.7, 0, 0, 1.3,
0, 45.2, 203.2, 14.5, 9.2, 22.2, 2.9, 0, 59.5, 19.9, 162.9, 0,
1, 0, 0, 0, 1.8, 9.9, 54, 8.1, 9.4, 0, 0.8, 0, 0, 0, 0, 0.3,
0, 0, 7.4, 28.5, 101.2, 87.9, 26.9, 128.9, 78.1, 3.6, 0, 0, 77.5,
130.1, 262.5, 105.5, 14.9, 0, 0, 0, 2.5, 2.3, 15.5, 28.8, 4.6,
34.8, 22.1, 60.5, 0.5, 24.1, 0, 0, 37, 128.3, 26, 27.8, 2.3,
2.3, 195.9, 227.7, 0.8, 2.8, 0, 0, 5.1, 0.3, 0, 0, 0, 0, 9.7,
125.9, 64.9, 78.3, 3.3, 0, 0, 46.2, 52.6, 3, 24.9, 22.1, 14.2,
0, 0, 170.6, 64.5, 30.3, 35.8, 204.5, 5.3, 0.5, 3.1, 0, 0, 17.2,
136.6, 37.9, 0.8, 0, 0.3, 5.1, 2.4, 0, 9.8, 0, 0, 0, 0.2, 0,
0.3, 0, 0.3, 1.5, 1, 0, 0, 0, 0, 0, 0.8, 1.3, 7.8, 0, 12, 25.2,
74.3, 26.5, 1.6, 11.2, 0, 0, 0, 0, 5.4, 186.1, 99.7, 46.3, 2.8,
7.6, 5.6, 22.9, 81, 2, 0, 7.1, 24, 68, 121.8, 10.4, 0, 24.4,
77.1, 18, 8.9, 0.8, 0, 18.6, 0, 2, 1.3, 0, 18.8, 0, 0, 8.6, 5.6,
0, 0.5, 61.8, 146.6, 16.5, 0, 18.6, 0, 0, 0, 8.1, 59.4, 8.5,
1, 54.8, 0, 21.6, 0, 0, 0, 0, 0, 0, 0, 44.2, 0.5, 0, 1.3, 0,
1.8, 1, 0, 9.7, 93.5, 48.5, 158.3, 78.5, 2.8, 4.1, 13, 98.8,
55.2, 76.3, 56.3, 0, 6.1, 0, 0, 0, 0, 5.3, 0, 14.5, 0, 0)), row.names =
c(274L,
275L, 276L, 277L, 278L, 279L, 280L, 281L, 282L, 283L, 284L, 285L,
286L, 287L, 288L, 289L, 290L, 291L, 292L, 293L, 294L, 295L, 296L,
297L, 298L, 299L, 300L, 301L, 302L, 303L, 304L, 640L, 641L, 642L,
643L, 644L, 645L, 646L, 647L, 648L, 649L, 650L, 651L, 652L, 653L,
654L, 655L, 656L, 657L, 658L, 659L, 660L, 661L, 662L, 663L, 664L,
665L, 666L, 667L, 668L, 669L, 670L, 1005L, 1006L, 1007L, 1008L,
1009L, 1010L, 1011L, 1012L, 1013L, 1014L, 1015L, 1016L, 1017L,
1018L, 1019L, 1020L, 1021L, 1022L, 1023L, 1024L, 1025L, 1026L,
1027L, 1028L, 1029L, 1030L, 1031L, 1032L, 1033L, 1034L, 1035L,
1370L, 1371L, 1372L, 1373L, 1374L, 1375L, 1376L, 1377L, 1378L,
1379L, 1380L, 1381L, 1382L, 1383L, 1384L, 1385L, 1386L, 1387L,
1388L, 1389L, 1390L, 1391L, 1392L, 1393L, 1394L, 1395L, 1396L,
1397L, 1398L, 1399L, 1400L, 1735L, 1736L, 1737L, 1738L, 1739L,
1740L, 1741L, 1742L, 1743L, 1744L, 1745L, 1746L, 1747L, 1748L,
1749L, 1750L, 1751L, 1752L, 1753L, 1754L, 1755L, 1756L, 1757L,
1758L, 1759L, 1760L, 1761L, 1762L, 1763L, 1764L, 1765L, 2101L,
2102L, 2103L, 2104L, 2105L, 2106L, 2107L, 2108L, 2109L, 2110L,
2111L, 2112L, 2113L, 2114L, 2115L, 2116L, 2117L, 2118L, 2119L,
2120L, 2121L, 2122L, 2123L, 2124L, 2125L, 2126L, 2127L, 2128L,
2129L, 2130L, 2131L, 2466L, 2467L, 2468L, 2469L, 2470L, 2471L,
2472L, 2473L, 2474L, 2475L, 2476L, 2477L, 2478L, 2479L, 2480L,
2481L, 2482L, 2483L, 2484L, 2485L, 2486L, 2487L, 2488L, 2489L,
2490L, 2491L, 2492L, 2493L, 2494L, 2495L, 2496L, 2831L, 2832L,
2833L, 2834L, 2835L, 2836L, 2837L, 2838L, 2839L, 2840L, 2841L,
2842L, 2843L, 2844L, 2845L, 2846L, 2847L, 2848L, 2849L, 2850L,
2851L, 2852L, 2853L, 2854L, 2855L, 2856L, 2857L, 2858L, 2859L,
2860L, 2861L, 3196L, 3197L, 3198L, 3199L, 3200L, 3201L, 3202L,
3203L, 3204L, 3205L, 3206L, 3207L, 3208L, 3209L, 3210L, 3211L,
3212L, 3213L, 3214L, 3215L, 3216L, 3217L, 3218L, 3219L, 3220L,
3221L, 3222L, 3223L, 3224L, 3225L, 3226L, 3562L, 3563L, 3564L,
3565L, 3566L, 3567L, 3568L, 3569L, 3570L, 3571L, 3572L, 3573L,
3574L, 3575L, 3576L, 3577L, 3578L, 3579L, 3580L, 3581L, 3582L,
3583L, 3584L, 3585L, 3586L, 3587L, 3588L, 3589L, 3590L, 3591L,
3592L, 3927L, 3928L, 3929L, 3930L, 3931L, 3932L, 3933L, 3934L,
3935L, 3936L, 3937L, 3938L, 3939L, 3940L, 3941L, 3942L, 3943L,
3944L, 3945L, 3946L, 3947L, 3948L, 3949L, 3950L, 3951L, 3952L,
3953L, 3954L, 3955L, 3956L, 3957L, 4292L, 4293L, 4294L, 4295L,
4296L, 4297L, 4298L, 4299L, 4300L, 4301L, 4302L, 4303L, 4304L,
4305L, 4306L, 4307L, 4308L, 4309L, 4310L, 4311L, 4312L, 4313L,
4314L, 4315L, 4316L, 4317L, 4318L, 4319L, 4320L, 4321L, 4322L
), class = "data.frame")

I want to:

[1] Get the days exceeding the longterm monthly 95th percentile.

[2] Plot the histogram of duration (i.e., number of consecutive events, so count vs duration)

[3] Plot the histogram of intensity (i.e., frequency of occurrence vs rainfall values)

What I have to far:

Code:

thresh<-quantile(dat$RR,0.95,na.rm=T)
extreme<-dat[which(dat$RR>=thresh),]
hist(extreme$RR)

I can do [1] and [3] but I am having trouble how to plot [2]. How do I get the length of the unique events and plot its histogram?

I want to count how many events have 1 day only duration, 2 day consecutive duration, 3 day consecutive duration. Then plot the histogram of this.

Body:
I think rle will do what you're looking for. However, you're currently not calculating the quantile by month, we could use group_by from dplyr for that.

library(dplyr)
dat2 <- dat %>%
  group_by(YY,MM) %>%
  mutate(extreme = RR > quantile(RR,0.95,na.rm=TRUE))
# A tibble: 372 x 5
# Groups:   YY, MM [12]
      YY    MM    DD    RR extreme
   <int> <int> <int> <dbl> <lgl>
 1  1979    10     1  65.3 TRUE
 2  1979    10     2   2.6 FALSE
 3  1979    10     3   3.8 FALSE
 4  1979    10     4  93.5 TRUE
 5  1979    10     5   0   FALSE
 6  1979    10     6   0   FALSE
 7  1979    10     7   1   FALSE
 8  1979    10     8   0   FALSE
 9  1979    10     9   0   FALSE
10  1979    10    10   0   FALSE
# … with 362 more rows

Now we can use rle to get the length between events:

result <- rle(dat2$extreme)
result
#Run Length Encoding
#  lengths: int [1:36] 1 2 1 54 2 27 2 16 1 1 ...
#  values : logi [1:36] TRUE FALSE TRUE FALSE TRUE FALSE ...
result$lengths[result$values]
 [1] 1 1 2 2 1 1 1 1 2 2 1 1 2 1 1 2 1 1
hist(result$lengths[result$values],breaks = c(0:5), xlab = "Length of extreme events", main = "")


问:
Java compare XML tags with different names
I have two XML's which have basically the same content but a single tag has a different name:

actualSource:

```<code><ns2:Message xmlns:ns2="http://blabla.blabla.com">
    <data>
        <fieldabc>aaaa</fieldabc>
    </data>
    <asset>
        <field1>50.85</field1>
        <field2>Scooter</field2>
        <field3>Small</field3>
    </asset>
</code>```

expectedSource:

```<code><ns2:Message xmlns:ns2="http://different.blabla.com">
    <data>
        <fieldabc>aaaa</fieldabc>
    </data>
    <product>
        <field1>50.85</field1>
        <field2>Scooter</field2>
        <field3>Small</field3>
    </product>
</ns2:Message>
</code>```

The 'asset' and 'product' tags have same content, same fields name. I am using xmlunit:

```<code>    <dependency>
        <groupId>org.xmlunit</groupId>
        <artifactId>xmlunit-core</artifactId>
        <version>2.7.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.xmlunit</groupId>
        <artifactId>xmlunit-matchers</artifactId>
        <version>2.7.0</version>
        <scope>test</scope>
    </dependency>
</code>```

I am trying to compare the via DiffBuilder:

```<code>Diff diff = DiffBuilder.compare(expectedSource).withTest(actualSource)
                .ignoreWhitespace()
                .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText))
                .checkForSimilar()
                .build()
</code>```

In differences I receive:

```<code>Expected child 'null' but was '{http://blabla.blabla.com}Message' - comparing <NULL> to <ns2:Message...> at /Message[1] (DIFFERENT)
Expected child '{http://different.blabla.com}Message' but was 'null' - comparing <ns2:Message...> at /Message[1] to <NULL> (DIFFERENT)
</code>```

I need to compare those 2 messages if they are equal without unmarshalling them to java objects, I need to assert pure XML's.

答:
ElementSelectors.byNameAndText has not considered your two Message elements as candidates for comparison as it is sensitive to XML namespace URIs. This is true for all built-in ElementSelectors. From an XML perspective the two elements are completely different things.

You need to provide an ElementSelector implementation that only looks at the local name of your elements. Something like

    @Override
    public boolean canBeCompared(final Element controlElement,
                                 final Element testElement) {
        if (controlElement == null || testElement == null) {
            return false;
        }
        final String controlLocal = controlElement.getLocalName();
        final String controlName = controlLocal == null ? controlElement.getNodeName() : controlLocal;
        final String testLocal = testElement.getLocalName();
        final String testName = testLocal == null ? testElement.getNodeName() : testLocal;
        return controlName.equals(testName);
    }
```

would be a namespace ignoring version of byName.

Using this will not be enough, though, as you'll get differences of type ComparisonType.NAMESPACE_URI which will make your documents DIFFERENT. In order to get rid of them you must also override the DifferenceEvaluator. The easiest solution is to use DifferenceEvaluators.downgradeDifferencesToSimilar(ComparisonType.NAMESPACE_URI).

With a combination like this you basically remove namespace sensitivity from XMLUnit's difference engine.

Personally I'd recommend fixing the cause of the difference in namespace URIs, though. I'm afraid it is going to byte you sooner or later as namespace URIs are all but irrelevant to a lot of XML processing tools. But you will certainly know your case a lot better than I do.

Body:
I have two XML's which have basically the same content but a single tag has a different name:

actualSource:

<ns2:Message xmlns:ns2="http://blabla.blabla.com">
    <data>
        <fieldabc>aaaa</fieldabc>
    </data>
    <asset>
        <field1>50.85</field1>
        <field2>Scooter</field2>
        <field3>Small</field3>
    </asset>

expectedSource:

<ns2:Message xmlns:ns2="http://different.blabla.com">
    <data>
        <fieldabc>aaaa</fieldabc>
    </data>
    <product>
        <field1>50.85</field1>
        <field2>Scooter</field2>
        <field3>Small</field3>
    </product>
</ns2:Message>

The 'asset' and 'product' tags have same content, same fields name. I am using xmlunit:

    <dependency>
        <groupId>org.xmlunit</groupId>
        <artifactId>xmlunit-core</artifactId>
        <version>2.7.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.xmlunit</groupId>
        <artifactId>xmlunit-matchers</artifactId>
        <version>2.7.0</version>
        <scope>test</scope>
    </dependency>

I am trying to compare the via DiffBuilder:

Diff diff = DiffBuilder.compare(expectedSource).withTest(actualSource)
                .ignoreWhitespace()
                .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText))
                .checkForSimilar()
                .build()

In differences I receive:

Expected child 'null' but was '{http://blabla.blabla.com}Message' - comparing <NULL> to <ns2:Message...> at /Message[1] (DIFFERENT)
Expected child '{http://different.blabla.com}Message' but was 'null' - comparing <ns2:Message...> at /Message[1] to <NULL> (DIFFERENT)

I need to compare those 2 messages if they are equal without unmarshalling them to java objects, I need to assert pure XML's.

Body:
ElementSelectors.byNameAndText has not considered your two Message elements as candidates for comparison as it is sensitive to XML namespace URIs. This is true for all built-in ElementSelectors. From an XML perspective the two elements are completely different things.

You need to provide an ElementSelector implementation that only looks at the local name of your elements. Something like

    @Override
    public boolean canBeCompared(final Element controlElement,
                                 final Element testElement) {
        if (controlElement == null || testElement == null) {
            return false;
        }
        final String controlLocal = controlElement.getLocalName();
        final String controlName = controlLocal == null ? controlElement.getNodeName() : controlLocal;
        final String testLocal = testElement.getLocalName();
        final String testName = testLocal == null ? testElement.getNodeName() : testLocal;
        return controlName.equals(testName);
    }

would be a namespace ignoring version of byName.

Using this will not be enough, though, as you'll get differences of type ComparisonType.NAMESPACE_URI which will make your documents DIFFERENT. In order to get rid of them you must also override the DifferenceEvaluator. The easiest solution is to use DifferenceEvaluators.downgradeDifferencesToSimilar(ComparisonType.NAMESPACE_URI).

With a combination like this you basically remove namespace sensitivity from XMLUnit's difference engine.

Personally I'd recommend fixing the cause of the difference in namespace URIs, though. I'm afraid it is going to byte you sooner or later as namespace URIs are all but irrelevant to a lot of XML processing tools. But you will certainly know your case a lot better than I do.


问:
Passing multiple parameters to function using settAtribute "onclick" in Javascript?
In my code I need to do this:

```<code>function myFunction() {
        /*more code*/
        let id = 12;
        let name = "something";
        deleteBtn.setAttribute("onclick", "otherFunction("+id+","+name+")");
}
</code>```

In which

```<code>function otherFunction(id, name){
        /*does other stuf*/
}
</code>```

The issue is, when I run the code and load the html page I get this error:
SyntaxError: missing ) after argument list.

I can't figure out what I'm doing wrong.

答:
when it comes to syntax error recheck what you have typed

first i dont see you declare the deleteBtn variable

```<code>deleteBtn.setAttribute("onclick", "otherFunction("+id+","+name+")");
</code>```

check this code it works

```<code>document.getElementById('asd').setAttribute('onclick', `otherFunction("${id}","${name}")`);
</code>```

Body:
In my code I need to do this:

function myFunction() {
        /*more code*/
        let id = 12;
        let name = "something";
        deleteBtn.setAttribute("onclick", "otherFunction("+id+","+name+")");
}

In which

function otherFunction(id, name){
        /*does other stuf*/
}

The issue is, when I run the code and load the html page I get this error:
SyntaxError: missing ) after argument list.

I can't figure out what I'm doing wrong.

Body:
when it comes to syntax error recheck what you have typed

first i dont see you declare the deleteBtn variable

deleteBtn.setAttribute("onclick", "otherFunction("+id+","+name+")");

check this code it works

document.getElementById('asd').setAttribute('onclick', `otherFunction("${id}","${name}")`);


问:
Memory-mapped files and low-memory scenarios
How does the iOS platform handle memory-mapped files during low-memory scenarios? By low-memory scenarios, I mean when the OS sends the UIApplicationDidReceiveMemoryWarningNotification notification to all observers in the application.

Our files are mapped into memory using +[NSData dataWithContentsOfMappedFile:], the documentation for which states:

A mapped file uses virtual memory techniques to avoid copying pages of the file into memory until they are actually needed.

Does this mean that the OS will also unmap the pages when they're no longer in use? Is it possible to mark pages as being no longer in use? This data is read-only, if that changes the scenario. How about if we were to use mmap() directly? Would this be preferable?

答:
Standard virtual memory techniques for file-backed memory says that the OS is free to throw away pages whenever it wants because it can always get them again later.  I have not used iOS, but this has been the behavior of virtual memory on many other operating systems for a long time.

The simplest way to test it is to map several large files into memory, read through them to guarantee that it pages them into memory, and see if you can force a low memory situation.  If you can't, then the OS must have unmapped the pages once it decided that they were no longer in use.

ContentLicense: CC BY-SA 3.0


问:
How do I find highest value using pointer?
I want to find the highest value from an array using two given pointer int *p,*max;, but the code doesn't work.

```<code>#include <iostream>
#include <string>
using namespace std;
int main() {
  int a[10], i, index;
  int *p, *max;
  for (i = 0; i < 10; i++) cin >> a[i];
  max = 0;
  p = &a[10];
  for (index = 0; index < 10; index++) {
    if ((p[index]) > *max) {
      *max = (p[index]);
    }
  }
  cout << "Highest value=" << *max << endl << "is at index=" << index << endl;
  return 0;
}
</code>```

答:
The code is buggy. First of all, you assign

```<code>p=&a[10];
</code>```

This assigns p to a memory address past a. Furthermore, you then index as p[index], which essentially is the same as a[10 + index].

Also, max is a wild pointer. It does not point to anything. You are assigning values to an undefined memory location.

I would strongly suggest to read up on pointers and to properly understand them before using them. Also, in modern C++, it is not very often than you need pointers.

Also, in idiomatic C++, we would probably write

```<code>auto p = std::max_element(a, a + 10);
</code>```

Body:
I want to find the highest value from an array using two given pointer int *p,*max;, but the code doesn't work.

#include <iostream>
#include <string>
using namespace std;
int main() {
  int a[10], i, index;
  int *p, *max;
  for (i = 0; i < 10; i++) cin >> a[i];
  max = 0;
  p = &a[10];
  for (index = 0; index < 10; index++) {
    if ((p[index]) > *max) {
      *max = (p[index]);
    }
  }
  cout << "Highest value=" << *max << endl << "is at index=" << index << endl;
  return 0;
}

Body:
The code is buggy. First of all, you assign

p=&a[10];

This assigns p to a memory address past a. Furthermore, you then index as p[index], which essentially is the same as a[10 + index].

Also, max is a wild pointer. It does not point to anything. You are assigning values to an undefined memory location.

I would strongly suggest to read up on pointers and to properly understand them before using them. Also, in modern C++, it is not very often than you need pointers.

Also, in idiomatic C++, we would probably write

auto p = std::max_element(a, a + 10);


问:
pandas printing maximum value found in a column with an f string
If I have some made up data... How do I print just the index (date & time stamp) of the maximum value found in a column named Temperature?

```<code>import numpy as np
import pandas as pd
np.random.seed(11)

rows,cols = 50000,2
data = np.random.rand(rows,cols)
tidx = pd.date_range('2019-01-01', periods=rows, freq='H')
df = pd.DataFrame(data, columns=['Temperature','Value'], index=tidx)

maxy = df.Temperature.max()
maxDate = df.loc[df['Temperature'].idxmax()]
</code>```

If I print maxDate there is alot of unwanted info..

```<code>print(maxy)
print(maxDate)
</code>```

This outputs:

```<code>0.9999949674183947
Temperature    0.999995
Value          0.518413
Name: 2023-01-06 02:00:00, dtype: float64
</code>```

Ultimately I am hoping to create an f string that just prints maximum temperature recorded in the dataset is 0.999995 found on 2023-01-06 02:00:00, Without the extra information such as Name: and , dtype: float64 and the Value          0.518413 column... Thanks for any tips & tricks

答:
There can be more than 1 entry with the maximum temperature.

maxy = df.Temperature.max()
max_dates = df[df['Temperature'] == maxy].index.astype(str).to_list()
print(f'Max temperature recorded in dataset is {maxy} on {",".join(max_dates)}')
```

<p>Output:</p>

```Max temperature recorded in dataset is 0.9999949674183947 on 2023-01-06 02:00:00
```

Body:
If I have some made up data... How do I print just the index (date & time stamp) of the maximum value found in a column named Temperature?

import numpy as np
import pandas as pd
np.random.seed(11)

rows,cols = 50000,2
data = np.random.rand(rows,cols)
tidx = pd.date_range('2019-01-01', periods=rows, freq='H')
df = pd.DataFrame(data, columns=['Temperature','Value'], index=tidx)

maxy = df.Temperature.max()
maxDate = df.loc[df['Temperature'].idxmax()]

If I print maxDate there is alot of unwanted info..

print(maxy)
print(maxDate)

This outputs:

0.9999949674183947
Temperature    0.999995
Value          0.518413
Name: 2023-01-06 02:00:00, dtype: float64

Ultimately I am hoping to create an f string that just prints maximum temperature recorded in the dataset is 0.999995 found on 2023-01-06 02:00:00, Without the extra information such as Name: and , dtype: float64 and the Value          0.518413 column... Thanks for any tips & tricks

Body:
There can be more than 1 entry with the maximum temperature.

maxy = df.Temperature.max()
max_dates = df[df['Temperature'] == maxy].index.astype(str).to_list()
print(f'Max temperature recorded in dataset is {maxy} on {",".join(max_dates)}')

Output:

Max temperature recorded in dataset is 0.9999949674183947 on 2023-01-06 02:00:00


问:
In angular simple app, I have to show common header to all pages after login, but common header is not visible to user details page
In angular simple app, I have to show common header to all pages after login,  but common header is not visible to user details page

I want to make common header visible to user details page also, which is not going to happen.

```<code>-myapp
  -src
   -layout
    -common
      -header
       header.component.css
       header.component.html
       header.component.spec.ts
       header.component.ts
    -dashboard
     dashboard-routing.module.ts
     dashboard.component.css
     dashboard.component.html
     dashboard.component.spec.ts
     dashboard.module.ts
     dashboard.component.ts
     - userdetails
       userdetails-routing.module.ts
       userdetails.component.css
       userdetails.component.html
       userdetails.component.spec.ts
       userdetails.module.ts
       userdetails.component.ts
   layout-routing.module.ts
   layout.component.css
   layout.component.html
   layout.component.spec.ts
   layout.module.ts
   layout.component.ts
 -login
 -services
 app-routing.module.ts
 app.component.css
 app.component.html
 app.component.spec.ts
 app.module.ts
 app.component.ts
</code>```

layout & dashboard components module & routing files are lazy files

app.modules.ts:

```<code>import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { LoginComponent } from './login/login.component';

import { LayoutModule } from './layout/layout.module';

@NgModule({
  declarations: [
    AppComponent,
    LoginComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    FormsModule,
    ReactiveFormsModule,
    LayoutModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
</code>```

layout.modules.ts:

```<code>import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { LayoutRoutingModule } from './layout-routing.module';
import { LayoutComponent } from './layout.component';
import { DashboardModule } from './dashboard/dashboard.module';
import { HeaderComponent } from './common/header/header.component';

@NgModule({
  declarations: [
    LayoutComponent,
    HeaderComponent
  ],
  imports: [
    CommonModule,
    LayoutRoutingModule,
    DashboardModule
  ],
  exports: [HeaderComponent]
})
export class LayoutModule { }
</code>```

dashbard.modules.ts:

```<code>import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { DashboardRoutingModule } from './dashboard-routing.module';
import { DashboardComponent } from './dashboard.component'

import { UserdetailsModule } from './userdetails/userdetails.module';

@NgModule({
  declarations: [DashboardComponent],
  imports: [
    CommonModule,
    DashboardRoutingModule,
    UserdetailsModule
  ],
  exports: [DashboardComponent]
})
export class DashboardModule { }
</code>```

app.component.html:

```<code><router-outlet></router-outlet>
</code>```

layout.component.html:

```<code><app-header></app-header>
<router-outlet></router-outlet>
</code>```

dashboard.component.html:

```<code><router-outlet></router-outlet>
..
..
</code>```

app-routing.module.ts:

```<code>import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { LoginComponent } from './login/login.component';
import { DashboardComponent } from './layout/dashboard/dashboard.component';

const routes: Routes = [
  { path: "", component: LoginComponent },
  { path: 'layout', loadChildren: './layout/layout.module#LayoutModule'}
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule { }
</code>```

layout-routing.module.ts:

```<code>import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { DashboardComponent } from './dashboard/dashboard.component';
import { LayoutComponent } from './layout.component';

const routes: Routes = [
  {
    path: '', component: LayoutComponent,
    children: [
      { path: 'dashboard', loadChildren: './dashboard/dashboard.module#DashboardModule' }
    ]
  }
];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule]
})
export class LayoutRoutingModule { }
</code>```

dashboard-routing.module.ts:

```<code>import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { DashboardComponent } from './dashboard.component';
import { UserdetailsComponent } from './userdetails/userdetails.component';

const routes: Routes = [
  {
    path: '', component: DashboardComponent,
    children: [
      {path: "user-details/:id", loadChildren: './userdetails/userdetails.module#UserdetailsModule'}
    ]
  }
];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule]
})
export class DashboardRoutingModule { }
</code>```

Please suggest me changes to show that common header on user-details page also..

答:
Seems like it is just a router configuration issue. I have made some changes to your code . Please Refer : https://stackblitz.com/edit/angular-ivy-rtzy77

I have not added routing module but have created the routes in the module itself .

The only Change that i have done is removal of <router-outlet></router-outlet> from dashboard.component.ts .

You don't need a 3rd router outlet .

EDIT 1 : Even after adding the 3rd route , i have covered your use case. . The example should work . Please refer to the stackblitz example

Open : https://angular-ivy-rtzy77.stackblitz.io/layout/dashboard/user for the required header and user component

EDIT 2 :
Also ,instead Of using multiple nesting , you can make changes to your layout-routing.module in the following way keeping the user module inside layout module rather than dashboard module and then remove router-outlet from dashboard.component .

```<code>import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { DashboardComponent } from './dashboard/dashboard.component';
import { LayoutComponent } from './layout.component';

const routes: Routes = [
  {
    path: '', component: LayoutComponent,
        children: [
      { path: 'dashboard', loadChildren: './dashboard/dashboard.module#DashboardModule' },
{path: "user-details/:id", loadChildren: './userdetails/userdetails.module#UserdetailsModule'}
    ]
  }
];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule]
})
export class LayoutRoutingModule { }
</code>```

And then in dashboard.component.html , remove router-outlet . With just 2 router-outlet you can meet your requirements .

Body:
In angular simple app, I have to show common header to all pages after login,  but common header is not visible to user details page

I want to make common header visible to user details page also, which is not going to happen.

-myapp
  -src
   -layout
    -common
      -header
       header.component.css
       header.component.html
       header.component.spec.ts
       header.component.ts
    -dashboard
     dashboard-routing.module.ts
     dashboard.component.css
     dashboard.component.html
     dashboard.component.spec.ts
     dashboard.module.ts
     dashboard.component.ts
     - userdetails
       userdetails-routing.module.ts
       userdetails.component.css
       userdetails.component.html
       userdetails.component.spec.ts
       userdetails.module.ts
       userdetails.component.ts
   layout-routing.module.ts
   layout.component.css
   layout.component.html
   layout.component.spec.ts
   layout.module.ts
   layout.component.ts
 -login
 -services
 app-routing.module.ts
 app.component.css
 app.component.html
 app.component.spec.ts
 app.module.ts
 app.component.ts

layout & dashboard components module & routing files are lazy files

app.modules.ts:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { LoginComponent } from './login/login.component';

import { LayoutModule } from './layout/layout.module';

@NgModule({
  declarations: [
    AppComponent,
    LoginComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    FormsModule,
    ReactiveFormsModule,
    LayoutModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

layout.modules.ts:

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { LayoutRoutingModule } from './layout-routing.module';
import { LayoutComponent } from './layout.component';
import { DashboardModule } from './dashboard/dashboard.module';
import { HeaderComponent } from './common/header/header.component';

@NgModule({
  declarations: [
    LayoutComponent,
    HeaderComponent
  ],
  imports: [
    CommonModule,
    LayoutRoutingModule,
    DashboardModule
  ],
  exports: [HeaderComponent]
})
export class LayoutModule { }

dashbard.modules.ts:

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { DashboardRoutingModule } from './dashboard-routing.module';
import { DashboardComponent } from './dashboard.component'

import { UserdetailsModule } from './userdetails/userdetails.module';

@NgModule({
  declarations: [DashboardComponent],
  imports: [
    CommonModule,
    DashboardRoutingModule,
    UserdetailsModule
  ],
  exports: [DashboardComponent]
})
export class DashboardModule { }

app.component.html:

<router-outlet></router-outlet>

layout.component.html:

<app-header></app-header>
<router-outlet></router-outlet>

dashboard.component.html:

<router-outlet></router-outlet>
..
..

app-routing.module.ts:

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { LoginComponent } from './login/login.component';
import { DashboardComponent } from './layout/dashboard/dashboard.component';

const routes: Routes = [
  { path: "", component: LoginComponent },
  { path: 'layout', loadChildren: './layout/layout.module#LayoutModule'}
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule { }

layout-routing.module.ts:

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { DashboardComponent } from './dashboard/dashboard.component';
import { LayoutComponent } from './layout.component';

const routes: Routes = [
  {
    path: '', component: LayoutComponent,
    children: [
      { path: 'dashboard', loadChildren: './dashboard/dashboard.module#DashboardModule' }
    ]
  }
];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule]
})
export class LayoutRoutingModule { }

dashboard-routing.module.ts:

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { DashboardComponent } from './dashboard.component';
import { UserdetailsComponent } from './userdetails/userdetails.component';

const routes: Routes = [
  {
    path: '', component: DashboardComponent,
    children: [
      {path: "user-details/:id", loadChildren: './userdetails/userdetails.module#UserdetailsModule'}
    ]
  }
];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule]
})
export class DashboardRoutingModule { }

Please suggest me changes to show that common header on user-details page also..

Body:
Seems like it is just a router configuration issue. I have made some changes to your code . Please Refer : https://stackblitz.com/edit/angular-ivy-rtzy77

I have not added routing module but have created the routes in the module itself .

The only Change that i have done is removal of <router-outlet></router-outlet> from dashboard.component.ts .

You don't need a 3rd router outlet .

EDIT 1 : Even after adding the 3rd route , i have covered your use case. . The example should work . Please refer to the stackblitz example

Open : https://angular-ivy-rtzy77.stackblitz.io/layout/dashboard/user for the required header and user component

EDIT 2 :
Also ,instead Of using multiple nesting , you can make changes to your layout-routing.module in the following way keeping the user module inside layout module rather than dashboard module and then remove router-outlet from dashboard.component .

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { DashboardComponent } from './dashboard/dashboard.component';
import { LayoutComponent } from './layout.component';

const routes: Routes = [
  {
    path: '', component: LayoutComponent,
        children: [
      { path: 'dashboard', loadChildren: './dashboard/dashboard.module#DashboardModule' },
{path: "user-details/:id", loadChildren: './userdetails/userdetails.module#UserdetailsModule'}
    ]
  }
];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule]
})
export class LayoutRoutingModule { }

And then in dashboard.component.html , remove router-outlet . With just 2 router-outlet you can meet your requirements .


问:
How can I bind radio buttons to a property which is an enum?
I'm working on radio buttons using Blazor. There have to be 2 radio buttons for the salutation of a person. But the salutation of the person is already clear. So for example if it's a man, I need the man radio button to be checked when I load the page. The problem is that I can't use @bind-Value for a radio button. Can anyone help me?

答:
Please model your code after this sample:

```<code>@foreach (var choice in new[] { Choices.Red, Choices.Green, Choices.Blue })
{
    <label>
        <input name="yourColor" type="radio"
               value="@choice"
               checked="@(currentChoice == choice)"
               @onchange="@(() => { currentChoice = choice; })">
        @choice.ToString()
    </label>
}

<p>You chose: @currentChoice</p>

@code {
    enum Choices { Red, Green, Blue };
    Choices currentChoice = Choices.Red;
}
</code>```

Hope this helps...

Source: https://github.com/dotnet/aspnetcore/issues/5579#issuecomment-548061223

Body:
Please model your code after this sample:

@foreach (var choice in new[] { Choices.Red, Choices.Green, Choices.Blue })
{
    <label>
        <input name="yourColor" type="radio"
               value="@choice"
               checked="@(currentChoice == choice)"
               @onchange="@(() => { currentChoice = choice; })">
        @choice.ToString()
    </label>
}

<p>You chose: @currentChoice</p>

@code {
    enum Choices { Red, Green, Blue };
    Choices currentChoice = Choices.Red;
}

Hope this helps...

Source: https://github.com/dotnet/aspnetcore/issues/5579#issuecomment-548061223


问:
A handler for menu
I have created the menu contribution in my Eclipse RCP application as an extension (org.eclipse.ui.menus). The items of this menu contribution are made as commands with handlers. I want to have such handlers not only for items (commands), but also for menus which are containing their items too (such as "File", "Edit"...).

The menus can have a field "commandID" in plugin.xml. I tried to create the command with this ID with a Handler extended the AbstractHandler, but it does't work.

答:
Menus can take commandIds so they can display a key shortcut.  That part is simply a display convenience.  There's still work to do behind the scenes to make the menu auto-popup.

See how the command org.eclipse.ui.navigate.showInQuickMenu is defined and used in the org.eclipse.ui.ide plugin.

It also has some supporting code in the org.eclipse.ui.internal.ide.WorkbenchActionBuilder:

```<code>    String showInQuickMenuId = IWorkbenchCommandConstants.NAVIGATE_SHOW_IN_QUICK_MENU;
    showInQuickMenu = new QuickMenuAction(showInQuickMenuId) {
        protected void fillMenu(IMenuManager menu) {
            menu.add(ContributionItemFactory.VIEWS_SHOW_IN
                    .create(window));
        }
    };
    register(showInQuickMenu);
</code>```

Title: A handler for menu

Body:
Menus can take commandIds so they can display a key shortcut.  That part is simply a display convenience.  There's still work to do behind the scenes to make the menu auto-popup.

See how the command org.eclipse.ui.navigate.showInQuickMenu is defined and used in the org.eclipse.ui.ide plugin.

It also has some supporting code in the org.eclipse.ui.internal.ide.WorkbenchActionBuilder:

    String showInQuickMenuId = IWorkbenchCommandConstants.NAVIGATE_SHOW_IN_QUICK_MENU;
    showInQuickMenu = new QuickMenuAction(showInQuickMenuId) {
        protected void fillMenu(IMenuManager menu) {
            menu.add(ContributionItemFactory.VIEWS_SHOW_IN
                    .create(window));
        }
    };
    register(showInQuickMenu);


问:
Dockerfile RUN powershell wget and see progress
In my dockerfile want to use the following sequence of commands to download and extract a large zip file:

```<code>RUN powershell -Command                           \
    wget http://my_server/big_huge.zip            \
        -OutFile C:\big_huge.zip ;                \
    Expand-Archive -Path C:\big_huge.zip          \
                   -DestinationPath C:\big_huge ; \
    Remove-Item C:\big_huge.zip -Force
</code>```

I don't want to use ADD to download the zip file isn't going to change and I want this step to be cached.

What I have above seems to work but I do not get any indication of the progress of the download like I normally would. That's a bummer because this is a large download. The progress of the download is obscured I suppose because Invoke-WebRequest which wget is an alias to is a cmdlet. Is there any way to pipe the output of a cmdlet to stdout so I can see it when I am running docker build?

答: I gave up on trying to do the download from the Dockerfile and instead wrote a separate script that pre-downloads the files I need and expands their archives if the files aren't already present. This script then calls docker build, docker run, etc. In the Dockerfile I am copying the directory where I expanded the archives.

Body:
In my dockerfile want to use the following sequence of commands to download and extract a large zip file:

RUN powershell -Command                           \
    wget http://my_server/big_huge.zip            \
        -OutFile C:\big_huge.zip ;                \
    Expand-Archive -Path C:\big_huge.zip          \
                   -DestinationPath C:\big_huge ; \
    Remove-Item C:\big_huge.zip -Force

I don't want to use ADD to download the zip file isn't going to change and I want this step to be cached.

What I have above seems to work but I do not get any indication of the progress of the download like I normally would. That's a bummer because this is a large download. The progress of the download is obscured I suppose because Invoke-WebRequest which wget is an alias to is a cmdlet. Is there any way to pipe the output of a cmdlet to stdout so I can see it when I am running docker build?